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: {
|
const json: {
|
||||||
type: string
|
type: string
|
||||||
shapes: TDShape[]
|
shapes: (TDShape & { text: string })[]
|
||||||
bindings: TDBinding[]
|
bindings: TDBinding[]
|
||||||
assets: TDAsset[]
|
assets: TDAsset[]
|
||||||
} = JSON.parse(maybeJson)
|
} = JSON.parse(maybeJson)
|
||||||
|
|
||||||
if (json.type === 'tldr/clipboard') {
|
if (json.type === 'tldr/clipboard') {
|
||||||
this.insertContent(json, { point, select: true })
|
this.insertContent(json, { point, select: true })
|
||||||
return
|
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 {
|
return {
|
||||||
id: 'insert',
|
id: 'insert',
|
||||||
before: {
|
before: {
|
||||||
|
|
Loading…
Reference in a new issue