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
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
}
}
11 changes: 7 additions & 4 deletions packages/super-editor/src/extensions/comment/comments-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
},
Expand All @@ -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;
Expand Down Expand Up @@ -280,6 +282,7 @@ export const CommentsPlugin = Extension.create({

// Remember the new decorations for next time
prevDecorations = decorationSet

},
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const resetLayout = async () => {
verticalOffset.value = 0;
};

watch(activeComment, () => {
watch(activeComment, (newVal, oldVal) => {
nextTick(() => {
if (!activeComment.value) return verticalOffset.value = 0;

Expand All @@ -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({
Expand Down
2 changes: 2 additions & 0 deletions packages/superdoc/src/stores/comments-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down