-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.ts
37 lines (33 loc) · 1.13 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { EditorState } from '@codemirror/state'
import { keymap, EditorView, drawSelection, rectangularSelection, highlightActiveLine } from '@codemirror/view'
import { defaultKeymap, history, historyKeymap, indentWithTab } from '@codemirror/commands'
import { defaultHighlightStyle, syntaxHighlighting, indentOnInput } from '@codemirror/language'
import { languages } from '@codemirror/language-data';
import { Table } from '@lezer/markdown';
import richEditor from '../src';
import config from './markdoc';
import './style.css';
// @ts-expect-error
import doc from './example.md?raw';
const state = EditorState.create({
doc,
extensions: [
richEditor({
markdoc: config,
lezer: {
codeLanguages: languages,
extensions: [Table]
}
}),
EditorView.lineWrapping,
history(),
drawSelection(),
rectangularSelection(),
highlightActiveLine(),
indentOnInput(),
syntaxHighlighting(defaultHighlightStyle),
keymap.of([indentWithTab, ...defaultKeymap, ...historyKeymap]),
],
});
const parent = document.getElementById('app') as Element;
const view = new EditorView({ state, parent });