diff --git a/packages/tldraw/src/state/TldrawApp.ts b/packages/tldraw/src/state/TldrawApp.ts index 6a4ccdaa2..a7fff73fd 100644 --- a/packages/tldraw/src/state/TldrawApp.ts +++ b/packages/tldraw/src/state/TldrawApp.ts @@ -1895,11 +1895,10 @@ export class TldrawApp extends StateManager { 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 diff --git a/packages/tldraw/src/state/commands/insertContent/insertContent.ts b/packages/tldraw/src/state/commands/insertContent/insertContent.ts index 960aaabf7..5d16ddf6c 100644 --- a/packages/tldraw/src/state/commands/insertContent/insertContent.ts +++ b/packages/tldraw/src/state/commands/insertContent/insertContent.ts @@ -246,6 +246,22 @@ export function insertContent( } } + const elm = document.createElement('textarea') + + Object.values(after.shapes as Record).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: {