]> BookStack Code Mirror - bookstack/blob - resources/js/code/setups.js
Added handling of codemirror 6 code languages
[bookstack] / resources / js / code / setups.js
1
2 import {keymap, highlightSpecialChars, drawSelection, highlightActiveLine, dropCursor,
3     rectangularSelection, lineNumbers, highlightActiveLineGutter} from "@codemirror/view"
4 import {defaultHighlightStyle, syntaxHighlighting, bracketMatching,
5      foldKeymap} from "@codemirror/language"
6 import {defaultKeymap, history, historyKeymap} from "@codemirror/commands"
7 import {EditorState} from "@codemirror/state"
8
9 export function viewer() {
10     return [
11         lineNumbers(),
12         highlightActiveLineGutter(),
13         highlightSpecialChars(),
14         history(),
15         drawSelection(),
16         dropCursor(),
17         syntaxHighlighting(defaultHighlightStyle, {fallback: true}),
18         bracketMatching(),
19         rectangularSelection(),
20         highlightActiveLine(),
21         keymap.of([
22             ...defaultKeymap,
23             ...historyKeymap,
24             ...foldKeymap,
25         ]),
26         EditorState.readOnly.of(true),
27     ];
28 }