From a33ea8376217f81ec00e5a6a07d113a1538eb97f Mon Sep 17 00:00:00 2001 From: sibiraj-s Date: Fri, 8 Jan 2021 15:58:57 +0530 Subject: [PATCH] fix: select image after inserting --- src/lib/commands/Image.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib/commands/Image.ts b/src/lib/commands/Image.ts index 1ab57698..eff41271 100644 --- a/src/lib/commands/Image.ts +++ b/src/lib/commands/Image.ts @@ -17,8 +17,14 @@ class Image { nodeAttrs.width = selection.node.attrs.width; } + tr.replaceSelectionWith(type.createAndFill(nodeAttrs)); + + const resolvedPos = tr.doc.resolve( + tr.selection.anchor - tr.selection.$anchor.nodeBefore.nodeSize + ); + tr - .replaceSelectionWith(type.createAndFill(nodeAttrs)) + .setSelection(new NodeSelection(resolvedPos)) .scrollIntoView(); if (tr.docChanged) {