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>
pull/827/head
Judicael 2022-07-14 21:30:03 +03:00 zatwierdzone przez GitHub
rodzic cb00822404
commit 20d4de02c4
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 17 dodań i 2 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -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: {