diff --git a/src/components/Editor/MediaHandler.vue b/src/components/Editor/MediaHandler.vue index 1f04e62b465..c32bc8ec08b 100644 --- a/src/components/Editor/MediaHandler.vue +++ b/src/components/Editor/MediaHandler.vue @@ -194,7 +194,18 @@ export default { ? this.$editor.chain().focus(position) : this.$editor.chain() - chain.setImage({ src, alt }).insertContent('
').focus().run() + chain.setImage({ src, alt }).run() + + const selection = this.$editor.view.state.selection + if (selection.from === 0 && !selection.empty) { + // If inserted image is first element, it is selected and would get overwritten by + // subsequent editor inserts (see tiptap#3355). So unselect the image by placing + // the cursor at the end of the selection. + this.$editor.commands.focus(selection.to) + } + + // Insert a newline to allow placing the cursor in between subsequent images + this.$editor.chain().insertContent('
').focus().run() }, }, }