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