mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 11:26:15 +01:00
chore(code): reintroduce vim keybindings
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
"@codemirror/legacy-modes": "6.5.1",
|
||||
"@codemirror/search": "6.5.10",
|
||||
"@codemirror/view": "6.36.7",
|
||||
"@replit/codemirror-vim": "6.3.0",
|
||||
"@ssddanbrown/codemirror-lang-smarty": "1.0.0",
|
||||
"@ssddanbrown/codemirror-lang-twig": "1.0.0",
|
||||
"codemirror-lang-hcl": "0.1.0",
|
||||
|
||||
@@ -3,6 +3,7 @@ import { EditorView, highlightActiveLine, keymap, lineNumbers, placeholder, View
|
||||
import { defaultHighlightStyle, StreamLanguage, syntaxHighlighting, indentUnit, bracketMatching } from "@codemirror/language";
|
||||
import { Compartment, type Extension } from "@codemirror/state";
|
||||
import { highlightSelectionMatches } from "@codemirror/search";
|
||||
import { vim } from "@replit/codemirror-vim";
|
||||
import byMimeType from "./syntax_highlighting.js";
|
||||
|
||||
type ContentChangedListener = () => void;
|
||||
@@ -10,6 +11,7 @@ type ContentChangedListener = () => void;
|
||||
export interface EditorConfig extends EditorViewConfig {
|
||||
placeholder?: string;
|
||||
lineWrapping?: boolean;
|
||||
vimKeybindings?: boolean;
|
||||
onContentChanged?: ContentChangedListener;
|
||||
}
|
||||
|
||||
@@ -23,7 +25,14 @@ export default class CodeMirror extends EditorView {
|
||||
const languageCompartment = new Compartment();
|
||||
const historyCompartment = new Compartment();
|
||||
|
||||
let extensions = [
|
||||
let extensions: Extension[] = [];
|
||||
|
||||
if (config.vimKeybindings) {
|
||||
extensions.push(vim());
|
||||
}
|
||||
|
||||
extensions = [
|
||||
...extensions,
|
||||
languageCompartment.of([]),
|
||||
historyCompartment.of(history()),
|
||||
syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
|
||||
@@ -36,8 +45,8 @@ export default class CodeMirror extends EditorView {
|
||||
...defaultKeymap,
|
||||
...historyKeymap,
|
||||
indentWithTab
|
||||
]),
|
||||
];
|
||||
])
|
||||
]
|
||||
|
||||
if (Array.isArray(config.extensions)) {
|
||||
extensions = [...extensions, ...config.extensions];
|
||||
|
||||
Reference in New Issue
Block a user