-
-
Notifications
You must be signed in to change notification settings - Fork 377
/
main.ts
35 lines (29 loc) 路 950 Bytes
/
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
/* Copyright 2021, Milkdown by Mirone. */
import './style.css';
import { defaultValueCtx, Editor, themeManagerCtx } from '@milkdown/core';
import { math } from '@milkdown/plugin-math';
import { slash } from '@milkdown/plugin-slash';
import { commonmark } from '@milkdown/preset-commonmark';
import { nord } from '@milkdown/theme-nord';
import { tokyo } from '@milkdown/theme-tokyo';
const sleep = (ms: number) =>
new Promise((resolve) => {
setTimeout(resolve, ms);
});
async function main() {
const editor = await Editor.make()
.config((ctx) => {
ctx.set(defaultValueCtx, '# Here is [mylink](https://milkdown.dev)');
})
.use(tokyo)
.use(commonmark)
.use(math)
.use(slash())
.create();
await sleep(2000);
editor.action(async (ctx) => {
const themeManager = ctx.get(themeManagerCtx);
themeManager.switch(ctx, nord);
});
}
main();