diff --git a/packages/super-editor/src/core/helpers/getActiveFormatting.js b/packages/super-editor/src/core/helpers/getActiveFormatting.js index 7deb25f24a..3f6e14d22a 100644 --- a/packages/super-editor/src/core/helpers/getActiveFormatting.js +++ b/packages/super-editor/src/core/helpers/getActiveFormatting.js @@ -68,7 +68,6 @@ function getActiveAttributes(state) { else state.doc.nodesBetween(from, to, (node) => getAttrs(node)); return attributes; } catch (error) { - console.debug('Error getting active attributes:', error); return {}; } } diff --git a/packages/super-editor/src/extensions/comment/comments-plugin.js b/packages/super-editor/src/extensions/comment/comments-plugin.js index a144f6279d..fa48409d50 100644 --- a/packages/super-editor/src/extensions/comment/comments-plugin.js +++ b/packages/super-editor/src/extensions/comment/comments-plugin.js @@ -183,12 +183,14 @@ export const CommentsPlugin = Extension.create({ shouldUpdate = true; editor.emit('commentsUpdate', update); + + const { tr: newTr } = editor.view.state; + const { dispatch } = editor.view; + newTr.setMeta(CommentsPluginKey, { type: 'force' }); + dispatch(newTr); }; }; - const { allCommentPositions } = pluginState; - editor.emit('comment-positions', { activeThreadId, allCommentPositions }); - return pluginState }, }, @@ -207,7 +209,7 @@ export const CommentsPlugin = Extension.create({ update(view, prevState) { const { state } = view const { doc, tr } = state - + if (prevDoc && prevDoc.eq(doc) && !shouldUpdate) return; prevDoc = doc; shouldUpdate = false; @@ -280,6 +282,7 @@ export const CommentsPlugin = Extension.create({ // Remember the new decorations for next time prevDecorations = decorationSet + }, } }, diff --git a/packages/superdoc/src/components/CommentsLayer/FloatingComments.vue b/packages/superdoc/src/components/CommentsLayer/FloatingComments.vue index f682c46475..d1088769da 100644 --- a/packages/superdoc/src/components/CommentsLayer/FloatingComments.vue +++ b/packages/superdoc/src/components/CommentsLayer/FloatingComments.vue @@ -118,7 +118,7 @@ const resetLayout = async () => { verticalOffset.value = 0; }; -watch(activeComment, () => { +watch(activeComment, (newVal, oldVal) => { nextTick(() => { if (!activeComment.value) return verticalOffset.value = 0; @@ -130,10 +130,9 @@ watch(activeComment, () => { const selectionTop = comment.selection.selectionBounds.top; const renderedTop = renderedItem.top; - const scrollY = window.scrollY; const editorBounds = floatingCommentsContainer.value.getBoundingClientRect(); - verticalOffset.value = selectionTop - renderedTop - editorBounds.top + scrollY; + verticalOffset.value = selectionTop - renderedTop; setTimeout(() => { renderedItem.elementRef.value?.scrollIntoView({ diff --git a/packages/superdoc/src/stores/comments-store.js b/packages/superdoc/src/stores/comments-store.js index c6a45f42de..1d282c2b48 100644 --- a/packages/superdoc/src/stores/comments-store.js +++ b/packages/superdoc/src/stores/comments-store.js @@ -513,6 +513,8 @@ 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); }); return comments;