add more tests

This commit is contained in:
Philipp Kühn
2020-03-04 10:21:48 +01:00
parent e1ee3dc0dd
commit 79b7344847
4 changed files with 76 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
import {EditorState, Plugin} from "prosemirror-state"
import {EditorView} from "prosemirror-view"
import {Schema, DOMParser} from "prosemirror-model"
import {Schema, DOMParser, DOMSerializer} from "prosemirror-model"
// @ts-ignore
import {schema} from "prosemirror-schema-basic"
// @ts-ignore
@@ -133,5 +133,20 @@ export class Editor {
// @ts-ignore
return this[name](...args)
}
public json() {
return this.state.doc.toJSON()
}
public html() {
const div = document.createElement('div')
const fragment = DOMSerializer
.fromSchema(this.schema)
.serializeFragment(this.state.doc.content)
div.appendChild(fragment)
return div.innerHTML
}
}