mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-11-26 10:13:38 +08:00
572037ef1f
Updated content sync and preview scoll sync to work. Many features commented out until they can be updated.
49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
|
|
import {EditorView, keymap, highlightSpecialChars, drawSelection, highlightActiveLine, dropCursor,
|
|
rectangularSelection, lineNumbers, highlightActiveLineGutter} from "@codemirror/view"
|
|
import {syntaxHighlighting, bracketMatching} from "@codemirror/language"
|
|
import {defaultKeymap, history, historyKeymap} from "@codemirror/commands"
|
|
import {EditorState} from "@codemirror/state"
|
|
|
|
import {defaultLight} from "./themes";
|
|
import {getLanguageExtension} from "./languages";
|
|
|
|
export function viewer() {
|
|
return [
|
|
lineNumbers(),
|
|
highlightActiveLineGutter(),
|
|
highlightSpecialChars(),
|
|
history(),
|
|
drawSelection(),
|
|
dropCursor(),
|
|
syntaxHighlighting(defaultLight, {fallback: true}),
|
|
bracketMatching(),
|
|
rectangularSelection(),
|
|
highlightActiveLine(),
|
|
keymap.of([
|
|
...defaultKeymap,
|
|
...historyKeymap,
|
|
]),
|
|
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,
|
|
]),
|
|
getLanguageExtension(language, ''),
|
|
];
|
|
} |