Skip to content

Commit

Permalink
fix: select image after inserting
Browse files Browse the repository at this point in the history
  • Loading branch information
sibiraj-s committed Jan 8, 2021
1 parent 2d10e5f commit a33ea83
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lib/commands/Image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit a33ea83

Please sign in to comment.