do not throw warn if content is null
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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 },
|
||||
|
||||
Reference in New Issue
Block a user