-
-
Notifications
You must be signed in to change notification settings - Fork 430
/
Copy pathmain.ts
50 lines (45 loc) · 1.17 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
43
44
45
46
47
48
49
50
import { Editor, rootCtx } from '@milkdown/core'
import { history } from '@milkdown/plugin-history'
import { commonmark } from '@milkdown/preset-commonmark'
import { gfm, insertTableCommand } from '@milkdown/preset-gfm'
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(() => {
return Editor.make()
.config((ctx) => {
ctx.set(rootCtx, document.getElementById('app'))
})
.config(nord)
.enableInspector()
.use(commonmark)
.use(gfm)
.use(history)
.create()
})
.then((editor1) => {
globalThis.commands.addTable = () => {
editor1.action(callCommand(insertTableCommand.key))
}
})
.catch(console.error)
setup(() => {
return Editor.make()
.config((ctx) => {
ctx.set(rootCtx, document.getElementById('app'))
})
.config(nord)
.enableInspector()
.use(commonmark)
.use(gfm)
.use(history)
.create()
})
.then((editor2) => {
globalThis.commands.addTable2 = () => {
editor2.action(callCommand(insertTableCommand.key))
}
})
.catch(console.error)