diff --git a/packages/tiptap/src/Editor.js b/packages/tiptap/src/Editor.js index 0405cd6a8..133b28292 100644 --- a/packages/tiptap/src/Editor.js +++ b/packages/tiptap/src/Editor.js @@ -374,6 +374,10 @@ export default class Editor extends Emitter { } setContent(content = {}, emitUpdate = false, parseOptions) { + if (!this.view.editable) { + return + } + const newState = EditorState.create({ schema: this.state.schema, doc: this.createDocument(content, parseOptions), diff --git a/packages/tiptap/test/Editor.spec.js b/packages/tiptap/test/Editor.spec.js index 974dc76ac..bf7a97b86 100644 --- a/packages/tiptap/test/Editor.spec.js +++ b/packages/tiptap/test/Editor.spec.js @@ -240,6 +240,17 @@ test('clear content', () => { expect(editor.getHTML()).toEqual('

') }) +test('clear content', () => { + const editor = new Editor({ + editable: false, + content: '

Foo

', + }) + + editor.clearContent() + + expect(editor.getHTML()).toEqual('

Foo

') +}) + test('init callback', done => { const editor = new Editor({ content: '

Foo

',