Skip to content

Commit d14f971

Browse files
authored
Merge pull request #440 from Harbour-Enterprises/HAR-9057_2
HAR-9057 - superdoc event - bubbling up update event
2 parents 305b5c4 + 065148f commit d14f971

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

packages/superdoc/src/SuperDoc.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ const onEditorDocumentLocked = ({ editor, isLocked, lockedBy }) => {
151151
proxy.$superdoc.lockSuperdoc(isLocked, lockedBy);
152152
};
153153
154+
const onEditorUpdate = ({editor}) => {
155+
proxy.$superdoc.emit('editor-update', { editor })
156+
}
157+
154158
const onEditorSelectionChange = ({ editor, transaction }) => {
155159
if (skipSelectionUpdate.value) {
156160
// When comment is added selection will be equal to comment text
@@ -240,6 +244,7 @@ const editorOptions = (doc) => {
240244
onDestroy: onEditorDestroy,
241245
onFocus: onEditorFocus,
242246
onDocumentLocked: onEditorDocumentLocked,
247+
onUpdate: onEditorUpdate,
243248
onSelectionUpdate: onEditorSelectionChange,
244249
onCollaborationReady: onEditorCollaborationReady,
245250
onContentError: onEditorContentError,

packages/superdoc/src/core/SuperDoc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ import {
6969
* @property {() => void} [onPdfDocumentReady] Callback when the PDF document is ready
7070
* @property {(isOpened: boolean) => void} [onSidebarToggle] Callback when the sidebar is toggled
7171
* @property {(params: { editor: Editor }) => void} [onCollaborationReady] Callback when collaboration is ready
72+
* @property {(params: { editor: Editor }) => void} [onEditorUpdate] Callback when document is updated
7273
* @property {(params: { error: Exception }) => void} [onException] Callback when an exception is thrown
7374
*/
7475

@@ -129,6 +130,7 @@ export class SuperDoc extends EventEmitter {
129130
onPdfDocumentReady: () => null,
130131
onSidebarToggle: () => null,
131132
onCollaborationReady: () => null,
133+
onEditorUpdate: () => null,
132134
onCommentsListChange: () => null,
133135
onException: () => null,
134136

@@ -229,6 +231,7 @@ export class SuperDoc extends EventEmitter {
229231
this.on('pdf-document-ready', this.config.onPdfDocumentReady);
230232
this.on('sidebar-toggle', this.config.onSidebarToggle);
231233
this.on('collaboration-ready', this.config.onCollaborationReady);
234+
this.on('editor-update', this.config.onEditorUpdate);
232235
this.on('content-error', this.onContentError);
233236
this.on('exception', this.config.onException);
234237
}

0 commit comments

Comments
 (0)