Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/superdoc/src/SuperDoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -240,6 +244,7 @@ const editorOptions = (doc) => {
onDestroy: onEditorDestroy,
onFocus: onEditorFocus,
onDocumentLocked: onEditorDocumentLocked,
onUpdate: onEditorUpdate,
onSelectionUpdate: onEditorSelectionChange,
onCollaborationReady: onEditorCollaborationReady,
onContentError: onEditorContentError,
Expand Down
3 changes: 3 additions & 0 deletions packages/superdoc/src/core/SuperDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand Down Expand Up @@ -129,6 +130,7 @@ export class SuperDoc extends EventEmitter {
onPdfDocumentReady: () => null,
onSidebarToggle: () => null,
onCollaborationReady: () => null,
onEditorUpdate: () => null,
onCommentsListChange: () => null,
onException: () => null,

Expand Down Expand Up @@ -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);
}
Expand Down