Instruction file imported from openmarketdata/qpad3 (
.github/instructions/editor.instructions.md). Copyright stays with the author.
Code Editor — src/editor.mjs
CodeMirror 6 editor with q syntax highlighting and execution keybindings.
Conventions
- Exports
createEditor(container, onExecute)— factory function, not a class. onExecute(code)callback is called when the user presses Ctrl+Enter or Shift+Enter.- Keybindings are defined in
executeKeymaparray. - Theme is
darkTheme, defined inline. - Shares
qLanguage+qHighlightStylefromlang-q.mjs. - Exposed as
window.editorfor remote JS invocation from q server.
When Modifying
Adding new keybindings
- Add to the
executeKeymaparray following the existingCtrl-Enter/Shift-Enterpattern. - Each entry is
{ key, run }whererunreceives the EditorView. - Use
Prec.highest()if the binding must override CodeMirror defaults.