Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions packages/super-editor/src/core/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,7 @@ export class Editor extends EventEmitter {
*/
#dispatchTransaction(transaction) {
if (this.isDestroyed) return;
const start = Date.now();
Comment thread
harbournick marked this conversation as resolved.

let state;
try {
Expand All @@ -1338,9 +1339,11 @@ export class Editor extends EventEmitter {
const selectionHasChanged = !this.state.selection.eq(state.selection);
this.view.updateState(state);

const end = Date.now();
this.emit('transaction', {
editor: this,
transaction,
duration: end - start,
});

if (selectionHasChanged) {
Expand Down
7 changes: 7 additions & 0 deletions packages/superdoc/src/SuperDoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ const editorOptions = (doc) => {
onCommentsUpdate: onEditorCommentsUpdate,
onCommentLocationsUpdate: onEditorCommentLocationsUpdate,
onListDefinitionsChange: onEditorListdefinitionsChange,
onTransaction: onEditorTransaction,
ydoc: doc.ydoc,
collaborationProvider: doc.provider || null,
isNewFile: doc.isNewFile || false,
Expand Down Expand Up @@ -331,6 +332,12 @@ const onEditorCommentsUpdate = (params = {}) => {
}
};

const onEditorTransaction = ({ editor, transaction, duration }) => {
if (typeof proxy.$superdoc.config.onTransaction === 'function') {
proxy.$superdoc.config.onTransaction({ editor, transaction, duration });
}
};

const isCommentsEnabled = computed(() => 'comments' in modules);
const showCommentsSidebar = computed(() => {
return (
Expand Down
2 changes: 1 addition & 1 deletion packages/superdoc/src/core/SuperDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
onCommentsListChange: () => null,
onException: () => null,
onListDefinitionsChange: () => null,

onTransaction: () => null,
Comment thread
harbournick marked this conversation as resolved.
// Image upload handler
// async (file) => url;
handleImageUpload: null,
Expand Down Expand Up @@ -402,7 +402,7 @@
/**
* Initialize telemetry service.
*/
#initTelemetry() {

Check warning on line 405 in packages/superdoc/src/core/SuperDoc.js

View workflow job for this annotation

GitHub Actions / Lint & Format Check

'#initTelemetry' is defined but never used
this.telemetry = new Telemetry({
enabled: this.config.telemetry?.enabled ?? true,
licenseKey: this.config.telemetry?.licenseKey,
Expand Down