diff --git a/packages/superdoc/src/SuperDoc.vue b/packages/superdoc/src/SuperDoc.vue index 72f6638d65..4f15ac993a 100644 --- a/packages/superdoc/src/SuperDoc.vue +++ b/packages/superdoc/src/SuperDoc.vue @@ -151,6 +151,10 @@ const onEditorDocumentLocked = ({ editor, isLocked, lockedBy }) => { proxy.$superdoc.lockSuperdoc(isLocked, lockedBy); }; +const onEditorUpdate = ({editor}) => { + proxy.$superdoc.emit('editor-update', { editor }) +} + const onEditorSelectionChange = ({ editor, transaction }) => { if (skipSelectionUpdate.value) { // When comment is added selection will be equal to comment text @@ -240,6 +244,7 @@ const editorOptions = (doc) => { onDestroy: onEditorDestroy, onFocus: onEditorFocus, onDocumentLocked: onEditorDocumentLocked, + onUpdate: onEditorUpdate, onSelectionUpdate: onEditorSelectionChange, onCollaborationReady: onEditorCollaborationReady, onContentError: onEditorContentError, diff --git a/packages/superdoc/src/core/SuperDoc.js b/packages/superdoc/src/core/SuperDoc.js index 44a38631b1..5355a978f5 100644 --- a/packages/superdoc/src/core/SuperDoc.js +++ b/packages/superdoc/src/core/SuperDoc.js @@ -69,6 +69,7 @@ import { * @property {() => void} [onPdfDocumentReady] Callback when the PDF document is ready * @property {(isOpened: boolean) => void} [onSidebarToggle] Callback when the sidebar is toggled * @property {(params: { editor: Editor }) => void} [onCollaborationReady] Callback when collaboration is ready + * @property {(params: { editor: Editor }) => void} [onEditorUpdate] Callback when document is updated * @property {(params: { error: Exception }) => void} [onException] Callback when an exception is thrown */ @@ -129,6 +130,7 @@ export class SuperDoc extends EventEmitter { onPdfDocumentReady: () => null, onSidebarToggle: () => null, onCollaborationReady: () => null, + onEditorUpdate: () => null, onCommentsListChange: () => null, onException: () => null, @@ -229,6 +231,7 @@ export class SuperDoc extends EventEmitter { this.on('pdf-document-ready', this.config.onPdfDocumentReady); this.on('sidebar-toggle', this.config.onSidebarToggle); this.on('collaboration-ready', this.config.onCollaborationReady); + this.on('editor-update', this.config.onEditorUpdate); this.on('content-error', this.onContentError); this.on('exception', this.config.onException); }