Skip to content

Commit 9632f47

Browse files
authored
Merge pull request #437 from Harbour-Enterprises/nick/har-9352-overlapping-comments
HAR-9352 - Allow showing comment highlights in overlapped comments
2 parents ee7c504 + d584174 commit 9632f47

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ export const CommentsPlugin = Extension.create({
212212
const { state } = view
213213
const { doc, tr } = state
214214

215-
if (prevDoc && prevDoc.eq(doc) && !shouldUpdate) return;
215+
if (prevDoc && prevDoc.eq(doc)) shouldUpdate = true;
216+
if (!shouldUpdate) return;
216217
prevDoc = doc;
217218
shouldUpdate = false;
218219

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

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

241243
const isInternal = attrs.internal;
242-
243-
const color = getHighlightColor({ activeThreadId, threadId, isInternal, editor });
244+
if (!hasActive) hasActive = activeThreadId === threadId;
245+
let color = getHighlightColor({ activeThreadId, threadId, isInternal, editor });
244246
const deco = Decoration.inline(pos, pos + node.nodeSize, {
245-
style: `background-color: ${color}`,
246-
class: 'comment-highlight',
247+
style: `background-color: ${color};`,
247248
'data-thread-id': threadId,
249+
class: 'comment-highlight',
248250
})
251+
252+
// Ignore inner marks if we need to show an outer active one
253+
if (hasActive && activeThreadId !== threadId) return;
249254
decorations.push(deco)
250255
});
251256

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,6 @@ export const useCommentsStore = defineStore('comments', () => {
550550
.filter((c) => !c.resolvedTime)
551551
.filter((c) => {
552552
const keys = Object.keys(editorCommentPositions.value);
553-
console.debug('[getFloatingComments] editorCommentPositions', keys)
554553

555554
return keys.includes(c.commentId);
556555
});

0 commit comments

Comments
 (0)