diff --git a/docs/src/demos/Nodes/Image/index.vue b/docs/src/demos/Nodes/Image/index.vue index 143b1322b..391a82ea6 100644 --- a/docs/src/demos/Nodes/Image/index.vue +++ b/docs/src/demos/Nodes/Image/index.vue @@ -31,7 +31,7 @@ export default { addImage() { const url = window.prompt('URL') - this.editor.chain().focus().image({ src: url }).run() + this.editor.chain().focus().setImage({ src: url }).run() }, }, diff --git a/packages/extension-image/src/index.ts b/packages/extension-image/src/index.ts index 7eeb831ba..a4c67761f 100644 --- a/packages/extension-image/src/index.ts +++ b/packages/extension-image/src/index.ts @@ -58,11 +58,13 @@ const Image = Node.create({ /** * Add an image */ - image: (options: { src: string, alt?: string, title?: string }): Command => ({ tr }) => { + setImage: (options: { src: string, alt?: string, title?: string }): Command => ({ tr, dispatch }) => { const { selection } = tr const node = this.type.create(options) - tr.replaceRangeWith(selection.from, selection.to, node) + if (dispatch) { + tr.replaceRangeWith(selection.from, selection.to, node) + } return true },