add more tests
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ function resolveSelection(editor: Editor, position: Position = null): ResolvedSe
|
||||
|
||||
return {
|
||||
from: size,
|
||||
to: size,
|
||||
to: size - 1, // TODO: -1 only for nodes with content
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user