fix header hotkey cursor position

This commit is contained in:
Víctor Losada Hernández
2026-09-27 15:10:23 +02:00
parent 9acfd6bce9
commit 304d78526e
@@ -271,7 +271,12 @@ const makeHeader = (level)=>(view)=>{
const { from, to } = view.state.selection.main;
const selected = view.state.doc.sliceString(from, to);
const text = `${'#'.repeat(level)} ${selected}`;
if(selected.length === 0) {
view.dispatch({ changes: { from, to, insert: text }, selection: { anchor: from + text.length } });
} else {
view.dispatch({ changes: { from, to, insert: text } });
}
return true;
};