do not throw warn if content is null

This commit is contained in:
Philipp Kühn
2019-02-06 10:36:50 +01:00
parent 8a23c4c945
commit 44525063bc
2 changed files with 12 additions and 0 deletions

View File

@@ -177,6 +177,10 @@ export default class Editor {
}
createDocument(content) {
if (content === null) {
return this.schema.nodeFromJSON(this.options.emptyDocument)
}
if (typeof content === 'object') {
try {
return this.schema.nodeFromJSON(content)

View File

@@ -25,6 +25,14 @@ test('create editor', () => {
expect(editor).toBeDefined()
})
test('check empty content (null)', () => {
const editor = new Editor({
content: null,
})
expect(editor.getHTML()).toEqual('<p></p>')
})
test('check invalid content (JSON)', () => {
const editor = new Editor({
content: { thisIsNotAValidDocument: true },