mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-15 11:09:01 +08:00
prevent setContent if editable is set to false
This commit is contained in:
parent
5c81cddff9
commit
b7ed913860
@ -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),
|
||||
|
@ -240,6 +240,17 @@ test('clear content', () => {
|
||||
expect(editor.getHTML()).toEqual('<p></p>')
|
||||
})
|
||||
|
||||
test('clear content', () => {
|
||||
const editor = new Editor({
|
||||
editable: false,
|
||||
content: '<p>Foo</p>',
|
||||
})
|
||||
|
||||
editor.clearContent()
|
||||
|
||||
expect(editor.getHTML()).toEqual('<p>Foo</p>')
|
||||
})
|
||||
|
||||
test('init callback', done => {
|
||||
const editor = new Editor({
|
||||
content: '<p>Foo</p>',
|
||||
|
Loading…
Reference in New Issue
Block a user