-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
25 lines (21 loc) · 808 Bytes
/
main.js
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
import './style.scss'
import { EditorState } from "prosemirror-state"
import { EditorView } from "prosemirror-view"
import { DOMParser } from "prosemirror-model"
import schema from "./src/schema"
import plugins from "./src/plugins"
import { fixTables } from "prosemirror-tables"
import FootnoteView from "./src/nodes/footnote/FootnoteView"
let state = EditorState.create({
doc: DOMParser.fromSchema(schema).parse(document.querySelector("#content")),
plugins: plugins({ schema })
})
// Normalise tables so they're safe to edit
const fix = fixTables(state);
if (fix) state = state.apply(fix.setMeta('addToHistory', false));
window.view = new EditorView(document.querySelector("#editor"), {
state,
nodeViews: {
footnote(node, view, getPos) { return new FootnoteView(node, view, getPos) }
}
})