Skip to content

Commit 941ea37

Browse files
committed
fix(text editor): if text selected - preserve the selection boundaries
1 parent 855f2f5 commit 941ea37

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/components/text-editor/prosemirror-adapter/menu/menu-commands.ts

+6
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ const toggleNodeType = (
189189
.setMeta('preserveWhitespace', true);
190190
tr.replaceSelectionWith(schema.text($from.parent.textContent));
191191

192+
const newSelection = TextSelection.create(tr.doc, $from.pos, $to.pos);
193+
tr.setSelection(newSelection);
194+
192195
if (dispatch) {
193196
dispatch(tr);
194197
}
@@ -211,6 +214,9 @@ const toggleNodeType = (
211214
);
212215
}
213216

217+
const newSelection = TextSelection.create(tr.doc, $from.pos, $to.pos);
218+
tr.setSelection(newSelection);
219+
214220
if (dispatch) {
215221
dispatch(tr);
216222
}

0 commit comments

Comments
 (0)