Skip to content

Commit 31ecec7

Browse files
committed
fix: dispatch tracked changes transaction only once at import
1 parent 6b71db2 commit 31ecec7

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

packages/superdoc/src/stores/comments-store.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -472,12 +472,11 @@ export const useCommentsStore = defineStore('comments', () => {
472472

473473
// Create comments for tracked changes
474474
// that do not have a corresponding comment (created in Word).
475+
const { tr } = editor.view.state;
476+
const { dispatch } = editor.view;
477+
475478
groupedChanges.forEach(({ insertedMark, deletionMark, formatMark }, index) => {
476479
console.debug(`Create comment for track change: ${index}`);
477-
478-
const { dispatch } = editor.view;
479-
const { tr } = editor.view.state;
480-
481480
const foundComment = commentsList.value.find(
482481
(i) =>
483482
i.commentId === insertedMark?.mark.attrs.id ||
@@ -489,7 +488,6 @@ export const useCommentsStore = defineStore('comments', () => {
489488
if (foundComment) {
490489
if (isLastIteration) {
491490
tr.setMeta(CommentsPluginKey, { type: 'force' });
492-
dispatch(tr);
493491
}
494492
return;
495493
}
@@ -504,9 +502,10 @@ export const useCommentsStore = defineStore('comments', () => {
504502
if (isLastIteration) tr.setMeta(CommentsPluginKey, { type: 'force' });
505503
tr.setMeta(CommentsPluginKey, { type: 'forceTrackChanges' });
506504
tr.setMeta(TrackChangesBasePluginKey, trackChangesPayload);
507-
dispatch(tr);
508505
}
509506
});
507+
508+
dispatch(tr);
510509
};
511510

512511
const translateCommentsForExport = () => {

0 commit comments

Comments
 (0)