Skip to content

Commit 893475b

Browse files
committed
fix(app): fix cursor position after pasting multi-line text
Remove document.execCommand('insertText') which creates DIV block elements for multi-line paste. getCursorPosition doesn't count the implicit newlines at block boundaries, causing cursor to land in the middle of pasted text after re-render. Now always uses addPart() which inserts via createTextFragment (text nodes + BR tags, no block elements), ensuring correct cursor positioning. Also removes deprecated execCommand API usage.
1 parent a53f407 commit 893475b

1 file changed

Lines changed: 0 additions & 9 deletions

File tree

‎packages/app/src/components/prompt-input/attachments.ts‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,6 @@ export function createPromptAttachments(input: PromptAttachmentsInput) {
103103

104104
if (!plainText) return
105105

106-
if (largePaste(plainText)) {
107-
if (input.addPart({ type: "text", content: plainText, start: 0, end: 0 })) return
108-
input.focusEditor()
109-
if (input.addPart({ type: "text", content: plainText, start: 0, end: 0 })) return
110-
}
111-
112-
const inserted = typeof document.execCommand === "function" && document.execCommand("insertText", false, plainText)
113-
if (inserted) return
114-
115106
input.addPart({ type: "text", content: plainText, start: 0, end: 0 })
116107
}
117108

0 commit comments

Comments
 (0)