@@ -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
0 commit comments