Skip to content

Commit fdd3bf3

Browse files
fix(text): paste plain text instead of blocking paste in editable shapes (tldraw#8192)
When pasting tldraw clipboard data into an editable text shape (e.g. a geo shape label or note), the paste was silently blocked. This PR fixes it to extract and insert the plain text content from the clipboard instead. fixes tldraw#8187 ### Change type - [x] `bugfix` ### Test plan 1. Create two shapes with text (e.g. geo shapes with labels) 2. Select and copy one shape (Cmd+C) 3. Double-click the other shape to edit its text 4. Paste (Cmd+V) — the plain text from the copied shape should be inserted ### Release notes - Fix pasting into editable text shapes when clipboard contains tldraw data <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk: a small, localized change to paste handling for editable text, with minimal impact outside the specific tldraw-clipboard paste path. > > **Overview** > Fixes paste into editable text shapes when the clipboard contains tldraw HTML data. Instead of silently blocking the paste, `useEditablePlainText` now prevents the default and inserts the clipboard’s `text/plain` content via `document.execCommand('insertText')` to preserve undo support. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 0fa808b. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Ani Krishnan <98394024+anikrisn@users.noreply.github.com>
1 parent 81d57bb commit fdd3bf3

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

packages/tldraw/src/lib/shapes/shared/useEditablePlainText.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,13 @@ export function useEditableTextCommon(shapeId: TLShapeId) {
152152
const html = e.clipboardData.getData('text/html')
153153
if (html) {
154154
if (html.includes('<div data-tldraw')) {
155+
// Paste the plain text data instead of the tldraw data
156+
const plainText = e.clipboardData.getData('text/plain')
155157
preventDefault(e)
158+
if (plainText) {
159+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- best way to insert text with undo support
160+
document.execCommand('insertText', false, plainText)
161+
}
156162
}
157163
}
158164
}

0 commit comments

Comments
 (0)