do not throw warn if content is null
This commit is contained in:
@@ -177,6 +177,10 @@ export default class Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createDocument(content) {
|
createDocument(content) {
|
||||||
|
if (content === null) {
|
||||||
|
return this.schema.nodeFromJSON(this.options.emptyDocument)
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof content === 'object') {
|
if (typeof content === 'object') {
|
||||||
try {
|
try {
|
||||||
return this.schema.nodeFromJSON(content)
|
return this.schema.nodeFromJSON(content)
|
||||||
|
|||||||
@@ -25,6 +25,14 @@ test('create editor', () => {
|
|||||||
expect(editor).toBeDefined()
|
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)', () => {
|
test('check invalid content (JSON)', () => {
|
||||||
const editor = new Editor({
|
const editor = new Editor({
|
||||||
content: { thisIsNotAValidDocument: true },
|
content: { thisIsNotAValidDocument: true },
|
||||||
|
|||||||
Reference in New Issue
Block a user