]> BookStack Code Mirror - bookstack/blob - resources/js/code/setups.js
Updated cm6 theme handling to allow extension via API
[bookstack] / resources / js / code / setups.js
1
2 import {EditorView, keymap, drawSelection, highlightActiveLine, dropCursor,
3     rectangularSelection, lineNumbers, highlightActiveLineGutter} from "@codemirror/view"
4 import {syntaxHighlighting, bracketMatching} from "@codemirror/language"
5 import {defaultKeymap, history, historyKeymap} from "@codemirror/commands"
6 import {EditorState} from "@codemirror/state"
7
8 import {defaultLight} from "./themes";
9
10 export function viewer() {
11     return [
12         lineNumbers(),
13         highlightActiveLineGutter(),
14         drawSelection(),
15         dropCursor(),
16         // syntaxHighlighting(defaultLight, {fallback: false}),
17         bracketMatching(),
18         rectangularSelection(),
19         highlightActiveLine(),
20         keymap.of([
21             ...defaultKeymap,
22         ]),
23         EditorState.readOnly.of(true),
24     ];
25 }
26
27 export function editor(language) {
28     return [
29         lineNumbers(),
30         highlightActiveLineGutter(),
31         history(),
32         drawSelection(),
33         dropCursor(),
34         syntaxHighlighting(defaultLight, {fallback: true}),
35         bracketMatching(),
36         rectangularSelection(),
37         highlightActiveLine(),
38         keymap.of([
39             ...defaultKeymap,
40             ...historyKeymap,
41         ]),
42         EditorView.lineWrapping,
43     ];
44 }