|
1 | | -import { Plugin, PluginKey } from 'prosemirror-state'; |
2 | | -import { TextSelection } from 'prosemirror-state'; |
| 1 | +import { Plugin, PluginKey, TextSelection } from 'prosemirror-state'; |
3 | 2 | import { Extension } from '@core/Extension.js'; |
4 | 3 | import { Decoration, DecorationSet } from 'prosemirror-view'; |
5 | 4 | import { removeCommentsById, getHighlightColor } from './comments-helpers.js'; |
@@ -237,28 +236,21 @@ export const CommentsPlugin = Extension.create({ |
237 | 236 | shouldUpdate = true; |
238 | 237 | } |
239 | 238 |
|
240 | | - if (prevActiveThreadId !== currentActiveThreadId) { |
241 | | - shouldUpdate = true; |
242 | | - prevActiveThreadId = currentActiveThreadId; |
243 | | - } |
244 | | - |
245 | 239 | // Check if document changed |
246 | 240 | if (prevDoc && !prevDoc.eq(doc)) shouldUpdate = true; |
247 | 241 |
|
248 | | - // Check if active thread changed - this is the key fix |
| 242 | + // Check if active thread changed |
249 | 243 | if (prevActiveThreadId !== currentActiveThreadId) { |
250 | 244 | shouldUpdate = true; |
251 | 245 | prevActiveThreadId = currentActiveThreadId; |
252 | 246 | } |
253 | 247 |
|
254 | 248 | if (!shouldUpdate) return; |
255 | | - |
256 | 249 | prevDoc = doc; |
257 | 250 | shouldUpdate = false; |
258 | 251 |
|
259 | 252 | const decorations = []; |
260 | 253 | const allCommentPositions = {}; |
261 | | - |
262 | 254 | doc.descendants((node, pos) => { |
263 | 255 | const { marks = [] } = node; |
264 | 256 | const commentMarks = marks.filter((mark) => mark.type.name === CommentMarkName); |
@@ -289,11 +281,6 @@ export const CommentsPlugin = Extension.create({ |
289 | 281 | editor, |
290 | 282 | }); |
291 | 283 |
|
292 | | - // Debug logging to verify color calculation |
293 | | - if (currentActiveThreadId === threadId) { |
294 | | - console.log('Active comment color:', { threadId, color, isInternal, currentActiveThreadId }); |
295 | | - } |
296 | | - |
297 | 284 | const deco = Decoration.inline(pos, pos + node.nodeSize, { |
298 | 285 | style: `background-color: ${color};`, |
299 | 286 | 'data-thread-id': threadId, |
@@ -321,7 +308,7 @@ export const CommentsPlugin = Extension.create({ |
321 | 308 | currentBounds, |
322 | 309 | node, |
323 | 310 | }); |
324 | | - // Add decoration for tracked changes |
| 311 | + // Add decoration for tracked changes when activated |
325 | 312 | const isActiveTrackedChange = currentActiveThreadId === id; |
326 | 313 | if (isActiveTrackedChange) { |
327 | 314 | const trackedChangeDeco = Decoration.inline(pos, pos + node.nodeSize, { |
@@ -674,13 +661,11 @@ function findRangeById(doc, id) { |
674 | 661 | let from = null, |
675 | 662 | to = null; |
676 | 663 | doc.descendants((node, pos) => { |
677 | | - // Check for tracked change marks |
678 | 664 | const trackedMark = node.marks.find((m) => TRACK_CHANGE_MARKS.includes(m.type.name) && m.attrs.id === id); |
679 | 665 | if (trackedMark) { |
680 | 666 | if (from === null || pos < from) from = pos; |
681 | 667 | if (to === null || pos + node.nodeSize > to) to = pos + node.nodeSize; |
682 | 668 | } |
683 | | - // Check for comment marks |
684 | 669 | const commentMark = node.marks.find( |
685 | 670 | (m) => m.type.name === CommentMarkName && (m.attrs.commentId === id || m.attrs.importedId === id), |
686 | 671 | ); |
|
0 commit comments