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.
This commit is contained in:
xfy 2026-06-05 15:21:38 +08:00
parent 00c5a880f4
commit c2c7b46958

View File

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