refactor: cursor-based sidebar expansion for comments and tracked changes#244
Merged
refactor: cursor-based sidebar expansion for comments and tracked changes#244
Conversation
Replace the DOM click handler in UnifiedSidebar with ProseMirror cursor-driven detection in DocxEditor. When the cursor lands on a comment, insertion, or deletion mark, the matching sidebar card expands automatically. This also works with keyboard navigation, not just clicks. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Two fixes: 1. Mark detection: $from.marks() misses inclusive:false marks at cursor boundaries. Now checks nodeAfter/nodeBefore marks first for reliable comment and tracked change detection. 2. Sidebar crash: Remove bidirectional state sync (activeItemId → internal state → onExpandedItemChange → parent) that caused max update depth. Make sidebar fully controlled — parent owns expansion state, sidebar just reads activeItemId prop. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Empty mark arrays are truthy in JS, so the OR chain (storedMarks || nodeAfter?.marks || nodeBefore?.marks) short-circuited on the first source with any node, even if that node had no comment/tracked-change marks. Now spreads all sources into a single array so we always find the mark. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The sidebar items only exist in allSidebarItems when showCommentsSidebar is true, but commentSidebarItems always has them. Search commentSidebarItems for mark matching, and auto-set showCommentsSidebar=true when a match is found so clicking on a comment or tracked change opens the sidebar. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1. Merge near-duplicate insertion and deletion mark handling into a single block with shared prefix-search and alias-resolution logic. 2. Stabilize toggleExpand callback with a ref so it doesn't recreate on every expandedItem change, avoiding unnecessary card re-renders on each cursor move. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
UnifiedSidebarwith ProseMirror cursor-driven mark detection inDocxEditorcomment,insertion, ordeletionmark, the matching sidebar card expands automaticallyrevisionIdAliasesprop with simpleractiveItemIdcontrolled propTest plan
🤖 Generated with Claude Code