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
15 changes: 10 additions & 5 deletions packages/super-editor/src/extensions/comment/comments-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ export const CommentsPlugin = Extension.create({
const { state } = view
const { doc, tr } = state

if (prevDoc && prevDoc.eq(doc) && !shouldUpdate) return;
if (prevDoc && prevDoc.eq(doc)) shouldUpdate = true;
if (!shouldUpdate) return;
prevDoc = doc;
shouldUpdate = false;

Expand All @@ -224,6 +225,7 @@ export const CommentsPlugin = Extension.create({
(mark) => mark.type.name === CommentMarkName
)

let hasActive = false;
commentMarks.forEach((commentMark) => {
const { attrs } = commentMark
const threadId = attrs.commentId || attrs.importedId
Expand All @@ -239,13 +241,16 @@ export const CommentsPlugin = Extension.create({
});

const isInternal = attrs.internal;

const color = getHighlightColor({ activeThreadId, threadId, isInternal, editor });
if (!hasActive) hasActive = activeThreadId === threadId;
let color = getHighlightColor({ activeThreadId, threadId, isInternal, editor });
const deco = Decoration.inline(pos, pos + node.nodeSize, {
style: `background-color: ${color}`,
class: 'comment-highlight',
style: `background-color: ${color};`,
'data-thread-id': threadId,
class: 'comment-highlight',
})

// Ignore inner marks if we need to show an outer active one
if (hasActive && activeThreadId !== threadId) return;
decorations.push(deco)
});

Expand Down
1 change: 0 additions & 1 deletion packages/superdoc/src/stores/comments-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,6 @@ export const useCommentsStore = defineStore('comments', () => {
.filter((c) => !c.resolvedTime)
.filter((c) => {
const keys = Object.keys(editorCommentPositions.value);
console.debug('[getFloatingComments] editorCommentPositions', keys)

return keys.includes(c.commentId);
});
Expand Down