Got markdown editor barely functional

Updated content sync and preview scoll sync to work.
Many features commented out until they can be updated.
This commit is contained in:
Dan Brown
2023-04-10 15:01:44 +01:00
parent dce5123452
commit 572037ef1f
7 changed files with 121 additions and 79 deletions

View File

@ -1,12 +1,12 @@
import {keymap, highlightSpecialChars, drawSelection, highlightActiveLine, dropCursor,
import {EditorView, keymap, highlightSpecialChars, drawSelection, highlightActiveLine, dropCursor,
rectangularSelection, lineNumbers, highlightActiveLineGutter} from "@codemirror/view"
import {defaultHighlightStyle, syntaxHighlighting, bracketMatching,
foldKeymap} from "@codemirror/language"
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 [
@ -23,8 +23,27 @@ export function viewer() {
keymap.of([
...defaultKeymap,
...historyKeymap,
...foldKeymap,
]),
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, ''),
];
}