-
-
Notifications
You must be signed in to change notification settings - Fork 430
/
Copy pathmain.ts
42 lines (36 loc) · 1.02 KB
/
main.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
38
39
40
41
42
import { Editor, rootCtx } from '@milkdown/core'
import { clipboard } from '@milkdown/plugin-clipboard'
import { history } from '@milkdown/plugin-history'
import {
commonmark,
toggleEmphasisCommand,
toggleStrongCommand,
} from '@milkdown/preset-commonmark'
import { nord } from '@milkdown/theme-nord'
import { callCommand } from '@milkdown/utils'
import { setup } from '../utils'
import '@milkdown/theme-nord/style.css'
import '../style.css'
setup(() => {
const editor = Editor.make()
.enableInspector()
.config((ctx) => {
ctx.set(rootCtx, document.getElementById('app'))
})
.config(nord)
.use(commonmark)
.use(history)
.use(clipboard)
.create()
editor
.then((instance) => {
globalThis.commands.toggleStrong = () => {
instance.action(callCommand(toggleStrongCommand.key))
}
globalThis.commands.toggleEmphasis = () => {
instance.action(callCommand(toggleEmphasisCommand.key))
}
})
.catch(console.error)
return editor
}).catch(console.error)