2022-08-02 19:11:02 +00:00
|
|
|
|
2023-04-10 14:01:44 +00:00
|
|
|
import {EditorView, keymap, highlightSpecialChars, drawSelection, highlightActiveLine, dropCursor,
|
2022-08-02 19:11:02 +00:00
|
|
|
rectangularSelection, lineNumbers, highlightActiveLineGutter} from "@codemirror/view"
|
2023-04-10 14:01:44 +00:00
|
|
|
import {syntaxHighlighting, bracketMatching} from "@codemirror/language"
|
2022-08-02 19:11:02 +00:00
|
|
|
import {defaultKeymap, history, historyKeymap} from "@codemirror/commands"
|
|
|
|
import {EditorState} from "@codemirror/state"
|
|
|
|
|
2023-03-21 20:53:35 +00:00
|
|
|
import {defaultLight} from "./themes";
|
|
|
|
|
2022-08-02 19:11:02 +00:00
|
|
|
export function viewer() {
|
|
|
|
return [
|
|
|
|
lineNumbers(),
|
|
|
|
highlightActiveLineGutter(),
|
|
|
|
highlightSpecialChars(),
|
|
|
|
history(),
|
|
|
|
drawSelection(),
|
|
|
|
dropCursor(),
|
2023-03-21 20:53:35 +00:00
|
|
|
syntaxHighlighting(defaultLight, {fallback: true}),
|
2022-08-02 19:11:02 +00:00
|
|
|
bracketMatching(),
|
|
|
|
rectangularSelection(),
|
|
|
|
highlightActiveLine(),
|
|
|
|
keymap.of([
|
|
|
|
...defaultKeymap,
|
|
|
|
...historyKeymap,
|
|
|
|
]),
|
|
|
|
EditorState.readOnly.of(true),
|
|
|
|
];
|
2023-04-10 14:01:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function editor(language) {
|
|
|
|
return [
|
|
|
|
lineNumbers(),
|
|
|
|
highlightActiveLineGutter(),
|
|
|
|
highlightSpecialChars(),
|
|
|
|
history(),
|
|
|
|
drawSelection(),
|
|
|
|
dropCursor(),
|
|
|
|
syntaxHighlighting(defaultLight, {fallback: true}),
|
|
|
|
bracketMatching(),
|
|
|
|
rectangularSelection(),
|
|
|
|
highlightActiveLine(),
|
|
|
|
keymap.of([
|
|
|
|
...defaultKeymap,
|
|
|
|
...historyKeymap,
|
|
|
|
]),
|
2023-04-14 13:08:40 +00:00
|
|
|
EditorView.lineWrapping,
|
2023-04-10 14:01:44 +00:00
|
|
|
];
|
2022-08-02 19:11:02 +00:00
|
|
|
}
|