Skip to content

Commit c05d887

Browse files
committed
Fix issue with floating comments ignoring tracked changes if there are only tracked change comments on selection change transactions
1 parent 8f84d53 commit c05d887

4 files changed

Lines changed: 11 additions & 8 deletions

File tree

packages/super-editor/src/core/helpers/getActiveFormatting.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ function getActiveAttributes(state) {
6868
else state.doc.nodesBetween(from, to, (node) => getAttrs(node));
6969
return attributes;
7070
} catch (error) {
71-
console.debug('Error getting active attributes:', error);
7271
return {};
7372
}
7473
}

packages/super-editor/src/extensions/comment/comments-plugin.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,14 @@ export const CommentsPlugin = Extension.create({
183183

184184
shouldUpdate = true;
185185
editor.emit('commentsUpdate', update);
186+
187+
const { tr: newTr } = editor.view.state;
188+
const { dispatch } = editor.view;
189+
newTr.setMeta(CommentsPluginKey, { type: 'force' });
190+
dispatch(newTr);
186191
};
187192
};
188193

189-
const { allCommentPositions } = pluginState;
190-
editor.emit('comment-positions', { activeThreadId, allCommentPositions });
191-
192194
return pluginState
193195
},
194196
},
@@ -207,7 +209,7 @@ export const CommentsPlugin = Extension.create({
207209
update(view, prevState) {
208210
const { state } = view
209211
const { doc, tr } = state
210-
212+
211213
if (prevDoc && prevDoc.eq(doc) && !shouldUpdate) return;
212214
prevDoc = doc;
213215
shouldUpdate = false;
@@ -280,6 +282,7 @@ export const CommentsPlugin = Extension.create({
280282

281283
// Remember the new decorations for next time
282284
prevDecorations = decorationSet
285+
283286
},
284287
}
285288
},

packages/superdoc/src/components/CommentsLayer/FloatingComments.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ const resetLayout = async () => {
118118
verticalOffset.value = 0;
119119
};
120120
121-
watch(activeComment, () => {
121+
watch(activeComment, (newVal, oldVal) => {
122122
nextTick(() => {
123123
if (!activeComment.value) return verticalOffset.value = 0;
124124
@@ -130,10 +130,9 @@ watch(activeComment, () => {
130130
131131
const selectionTop = comment.selection.selectionBounds.top;
132132
const renderedTop = renderedItem.top;
133-
const scrollY = window.scrollY;
134133
135134
const editorBounds = floatingCommentsContainer.value.getBoundingClientRect();
136-
verticalOffset.value = selectionTop - renderedTop - editorBounds.top + scrollY;
135+
verticalOffset.value = selectionTop - renderedTop;
137136
138137
setTimeout(() => {
139138
renderedItem.elementRef.value?.scrollIntoView({

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,8 @@ export const useCommentsStore = defineStore('comments', () => {
513513
.filter((c) => !c.resolvedTime)
514514
.filter((c) => {
515515
const keys = Object.keys(editorCommentPositions.value);
516+
console.debug('[getFloatingComments] editorCommentPositions', keys)
517+
516518
return keys.includes(c.commentId);
517519
});
518520
return comments;

0 commit comments

Comments
 (0)