From c2c7b4695878d8ce66a3f9bb5f3cd70313aebc8a Mon Sep 17 00:00:00 2001 From: xfy Date: Fri, 5 Jun 2026 15:21:38 +0800 Subject: [PATCH] fix(tiptap-editor): use insertContentAt with drop position in onDrop handler Previously dropped images were inserted at the current cursor position instead of the actual drop position. Now uses insertContentAt(pos, ...) to place images at the correct location. --- libs/tiptap-editor/src/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/tiptap-editor/src/index.ts b/libs/tiptap-editor/src/index.ts index 07ad028..21566a4 100644 --- a/libs/tiptap-editor/src/index.ts +++ b/libs/tiptap-editor/src/index.ts @@ -78,7 +78,10 @@ class TiptapEditorInstance { files.forEach((file) => { this.options.onImageUpload!(file) .then((url) => { - editor.chain().focus().setImage({ src: url }).run() + editor.chain().focus().insertContentAt(pos, { + type: 'image', + attrs: { src: url } + }).run() }) .catch((err) => { console.error('[TiptapEditor] Upload failed:', err)