-
Notifications
You must be signed in to change notification settings - Fork 63
SD-1760 - feat: allow custom accept/reject handlers for TC bubbles #1921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6410f8173b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const handleReject = () => { | ||
| // Check for custom handler that replaces default behavior entirely | ||
| const customHandler = proxy.$superdoc.config.onTrackedChangeBubbleReject; | ||
| if (props.comment.trackedChange && typeof customHandler === 'function') { | ||
| customHandler(props.comment, proxy.$superdoc.activeEditor); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep dialog cleanup when using custom reject handler
When a custom tracked-change handler is configured, this early return skips the nextTick cleanup that clears activeComment and bumps commentsStore.lastUpdate. That means accepting/rejecting via the custom handler leaves the bubble UI open and the active comment pinned even if the handler resolves the change, because the handler signature only receives (comment, editor) and has no access to the internal store to clear it. Consider running the cleanup regardless of whether a custom handler is used (same issue applies to the accept handler).
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks important @mattConnHarbour
harbournick
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its a cool idea and looks like a clean implementation. @mattConnHarbour please add unit tests to this covering the new api, as well as documentation
caio-pizzol
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clean implementation - just address the comments (incld Codex's) and feel free to merge after that
| }; | ||
|
|
||
| const handleReject = () => { | ||
| // Check for custom handler that replaces default behavior entirely |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we add tests for the custom handler paths? the existing tests at only cover default behavior
we could add a case where config.onTrackedChangeBubbleAccept is set and verify it's called instead of the default
| onFontsResolved: null, | ||
|
|
||
| // Tracked change bubble handlers - replace default accept/reject behavior | ||
| // Only fires from bubble buttons, not toolbar or context menu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we document that the default behavior includes resolving the comment and clearing active state?
users might not realize they need to handle these themselves - maybe add an example showing the full flow?
|
|
||
| const handleReject = () => { | ||
| // Check for custom handler that replaces default behavior entirely | ||
| const customHandler = proxy.$superdoc.config.onTrackedChangeBubbleReject; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new handlers should be added to apps/docs/core/superdoc/configuration.mdx, e.g.
<ParamField path="onTrackedChangeBubbleAccept" type="function">
Custom handler for accepting tracked changes from comment bubbles.
Replaces default behavior entirely when provided.
```javascript
onTrackedChangeBubbleAccept: (comment, editor) => {
// Your custom logic here
editor.commands.acceptTrackedChangeById(comment.commentId);
await saveDocument(); // e.g., custom save after accept
}
Only fires from bubble buttons, not toolbar or context menu
No description provided.