fix: paste unicode (#819)
* fix: paste unicode * fix unicode * use html element to unencode * Move to insertContent Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
This commit is contained in:
parent
cb00822404
commit
20d4de02c4
2 changed files with 17 additions and 2 deletions
|
@ -1895,11 +1895,10 @@ export class TldrawApp extends StateManager<TDSnapshot> {
|
|||
|
||||
const json: {
|
||||
type: string
|
||||
shapes: TDShape[]
|
||||
shapes: (TDShape & { text: string })[]
|
||||
bindings: TDBinding[]
|
||||
assets: TDAsset[]
|
||||
} = JSON.parse(maybeJson)
|
||||
|
||||
if (json.type === 'tldr/clipboard') {
|
||||
this.insertContent(json, { point, select: true })
|
||||
return
|
||||
|
|
|
@ -246,6 +246,22 @@ export function insertContent(
|
|||
}
|
||||
}
|
||||
|
||||
const elm = document.createElement('textarea')
|
||||
|
||||
Object.values(after.shapes as Record<string, TDShape>).forEach((shape) => {
|
||||
if ('text' in shape) {
|
||||
elm.innerHTML = shape.text
|
||||
shape.text = elm.value
|
||||
}
|
||||
|
||||
if ('label' in shape) {
|
||||
elm.innerHTML = shape.label!
|
||||
shape.label = elm.value
|
||||
}
|
||||
})
|
||||
|
||||
elm.remove()
|
||||
|
||||
return {
|
||||
id: 'insert',
|
||||
before: {
|
||||
|
|
Loading…
Reference in a new issue