1 import {provideKeyBindings} from './shortcuts';
2 import {EditorView, ViewUpdate} from "@codemirror/view";
3 import {MarkdownEditor} from "./index.mjs";
4 import {CodeModule} from "../global";
5 import {MarkdownEditorEventMap} from "./dom-handlers";
8 * Initiate the codemirror instance for the Markdown editor.
10 export function init(editor: MarkdownEditor, Code: CodeModule, domEventHandlers: MarkdownEditorEventMap): EditorView {
11 function onViewUpdate(v: ViewUpdate) {
13 editor.actions.updateAndRender();
18 const cm = Code.markdownEditor(
19 editor.config.inputEl,
22 provideKeyBindings(editor),
25 // Add editor view to the window for easy access/debugging.
26 // Not part of official API/Docs
28 window.mdEditorView = cm;