Prevent editor from loosing focus when line number gutter is clicked

This commit is contained in:
Jonatan Heyman 2025-06-11 23:17:39 +02:00
parent 0e8a5dfccc
commit bc863f20fa
2 changed files with 9 additions and 3 deletions

View File

@ -265,7 +265,13 @@ export const blockLineNumbers = lineNumbers({
} }
} }
return "" return ""
} },
domEventHandlers: {
click(view, line, event) {
// editor should not loose focus when clicking on the line numbers
view.docView.dom.focus()
},
},
}) })

View File

@ -83,7 +83,7 @@ export class HeynoteEditor {
heynoteCopyCut(this), heynoteCopyCut(this),
//minimalSetup, //minimalSetup,
this.lineNumberCompartment.of(showLineNumberGutter ? [lineNumbers(), blockLineNumbers] : []), this.lineNumberCompartment.of(showLineNumberGutter ? blockLineNumbers : []),
customSetup, customSetup,
this.foldGutterCompartment.of(showFoldGutter ? [foldGutter()] : []), this.foldGutterCompartment.of(showFoldGutter ? [foldGutter()] : []),
this.closeBracketsCompartment.of(bracketClosing ? [getCloseBracketsExtensions()] : []), this.closeBracketsCompartment.of(bracketClosing ? [getCloseBracketsExtensions()] : []),
@ -369,7 +369,7 @@ export class HeynoteEditor {
setLineNumberGutter(show) { setLineNumberGutter(show) {
this.view.dispatch({ this.view.dispatch({
effects: this.lineNumberCompartment.reconfigure(show ? [lineNumbers(), blockLineNumbers] : []), effects: this.lineNumberCompartment.reconfigure(show ? blockLineNumbers : []),
}) })
} }