Skip to content
Closed
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
2 changes: 1 addition & 1 deletion packages/super-editor/src/components/SuperEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const initEditor = async ({ content, media = {}, mediaFiles = {}, fonts = {} } =
};

const handleSuperEditorKeydown = (event) => {
emit('editor-keydown', { editor: editor.value });
props.options.onKeydown({editor: editor.value })
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harbournick Am I using this as intended? I was having issues just using an "emit" before.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to not add more hooks here that will complicate the API. Couldn't we just use the existing onUpdate hook?

};

const handleSuperEditorClick = (event) => {
Expand Down
2 changes: 2 additions & 0 deletions packages/super-editor/src/core/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export class Editor extends EventEmitter {
},
onTrackedChangesUpdate: () => null,
onCommentsUpdate: () => null,
onKeydown: () => null,
onCommentsLoaded: () => null,
onCommentClicked: () => null,
onCommentLocationsUpdate: () => null,
Expand Down Expand Up @@ -147,6 +148,7 @@ export class Editor extends EventEmitter {
this.on('commentsLoaded', this.options.onCommentsLoaded);
this.on('commentClick', this.options.onCommentClicked);
this.on('commentsUpdate', this.options.onCommentsUpdate);
this.on('keydown', this.options.onKeydown);
this.on('locked', this.options.onDocumentLocked);
this.on('collaborationReady', this.#onCollaborationReady);
this.on('paginationUpdate', this.options.onPaginationUpdate);
Expand Down
5 changes: 5 additions & 0 deletions packages/superdoc/src/SuperDoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ const onEditorException = ({ error, editor }) => {
proxy.$superdoc.emit('exception', { error, editor });
};

const onEditorKeydown = ({ editor }) => {
proxy.$superdoc.emit('editor-keydown', { editor });
}

const editorOptions = (doc) => {
const options = {
pagination: proxy.$superdoc.config.pagination,
Expand All @@ -243,6 +247,7 @@ const editorOptions = (doc) => {
onCollaborationReady: onEditorCollaborationReady,
onContentError: onEditorContentError,
onException: onEditorException,
onKeydown: onEditorKeydown,
onCommentsLoaded,
onCommentsUpdate: onEditorCommentsUpdate,
onCommentLocationsUpdate: onEditorCommentLocationsUpdate,
Expand Down
2 changes: 2 additions & 0 deletions packages/superdoc/src/core/SuperDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export class SuperDoc extends EventEmitter {
onSidebarToggle: () => null,
onCollaborationReady: () => null,
onCommentsListChange: () => null,
onEditorKeydown: () => null,
onException: () => null,

// Image upload handler
Expand Down Expand Up @@ -229,6 +230,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-keydown', this.config.onEditorKeydown);
this.on('content-error', this.onContentError);
this.on('exception', this.config.onException);
}
Expand Down