mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-09-28 04:32:58 +00:00
fix header hotkey cursor position
This commit is contained in:
@@ -271,7 +271,12 @@ const makeHeader = (level)=>(view)=>{
|
|||||||
const { from, to } = view.state.selection.main;
|
const { from, to } = view.state.selection.main;
|
||||||
const selected = view.state.doc.sliceString(from, to);
|
const selected = view.state.doc.sliceString(from, to);
|
||||||
const text = `${'#'.repeat(level)} ${selected}`;
|
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 } });
|
view.dispatch({ changes: { from, to, insert: text } });
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user