]> BookStack Code Mirror - bookstack/blobdiff - resources/js/code/setups.js
Added cm6 strategy for splitting and dyn. loading langs
[bookstack] / resources / js / code / setups.js
index e1a150856f8236f4d6200db44888737d86a5770d..cd56261d3b845603421c7febeb545bf65b2a8828 100644 (file)
@@ -1,8 +1,7 @@
 
-import {keymap, highlightSpecialChars, drawSelection, highlightActiveLine, dropCursor,
+import {EditorView, keymap, highlightSpecialChars, drawSelection, highlightActiveLine, dropCursor,
     rectangularSelection, lineNumbers, highlightActiveLineGutter} from "@codemirror/view"
-import {defaultHighlightStyle, syntaxHighlighting, bracketMatching,
-     foldKeymap} from "@codemirror/language"
+import {syntaxHighlighting, bracketMatching} from "@codemirror/language"
 import {defaultKeymap, history, historyKeymap} from "@codemirror/commands"
 import {EditorState} from "@codemirror/state"
 
@@ -23,8 +22,27 @@ export function viewer() {
         keymap.of([
             ...defaultKeymap,
             ...historyKeymap,
-            ...foldKeymap,
         ]),
         EditorState.readOnly.of(true),
     ];
+}
+
+export function editor(language) {
+    return [
+        lineNumbers(),
+        highlightActiveLineGutter(),
+        highlightSpecialChars(),
+        history(),
+        drawSelection(),
+        dropCursor(),
+        syntaxHighlighting(defaultLight, {fallback: true}),
+        bracketMatching(),
+        rectangularSelection(),
+        highlightActiveLine(),
+        keymap.of([
+            ...defaultKeymap,
+            ...historyKeymap,
+        ]),
+        EditorView.lineWrapping,
+    ];
 }
\ No newline at end of file