Skip to content

Commit

Permalink
fix(text editor): if text selected - preserve the selection boundaries
Browse files Browse the repository at this point in the history
  • Loading branch information
john-traas committed Dec 9, 2024
1 parent 855f2f5 commit 941ea37
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ const toggleNodeType = (
.setMeta('preserveWhitespace', true);
tr.replaceSelectionWith(schema.text($from.parent.textContent));

const newSelection = TextSelection.create(tr.doc, $from.pos, $to.pos);

Check failure on line 192 in src/components/text-editor/prosemirror-adapter/menu/menu-commands.ts

View workflow job for this annotation

GitHub Actions / Lint

Replace `tr.doc,·$from.pos,·$to.pos` with `⏎····················tr.doc,⏎····················$from.pos,⏎····················$to.pos,⏎················`
tr.setSelection(newSelection);

if (dispatch) {
dispatch(tr);
}
Expand All @@ -211,6 +214,9 @@ const toggleNodeType = (
);
}

const newSelection = TextSelection.create(tr.doc, $from.pos, $to.pos);

Check failure on line 217 in src/components/text-editor/prosemirror-adapter/menu/menu-commands.ts

View workflow job for this annotation

GitHub Actions / Lint

Replace `tr.doc,·$from.pos,·$to.pos` with `⏎························tr.doc,⏎························$from.pos,⏎························$to.pos,⏎····················`
tr.setSelection(newSelection);

if (dispatch) {
dispatch(tr);
}
Expand Down

0 comments on commit 941ea37

Please sign in to comment.