diff --git a/docs/api/editor.md b/docs/api/editor.md index ea5c21f92a..16fbd961e8 100644 --- a/docs/api/editor.md +++ b/docs/api/editor.md @@ -124,6 +124,7 @@ Update editable state of the editor. | Parameter | Type | Description | | --------- | ------- | ------------------------------------------------------------- | | editable | boolean | `true` when the user should be able to write into the editor. | +| emitUpdate | boolean | Defaults to `true`. Determines whether `onUpdate` is triggered. | ```js // Make the editor read-only diff --git a/packages/core/src/Editor.ts b/packages/core/src/Editor.ts index eba70401ef..e059273cac 100644 --- a/packages/core/src/Editor.ts +++ b/packages/core/src/Editor.ts @@ -167,9 +167,12 @@ export class Editor extends EventEmitter { /** * Update editable state of the editor. */ - public setEditable(editable: boolean): void { + public setEditable(editable: boolean, emitUpdate = true): void { this.setOptions({ editable }) - this.emit('update', { editor: this, transaction: this.state.tr }) + + if (emitUpdate) { + this.emit('update', { editor: this, transaction: this.state.tr }) + } } /**