Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe changes optimize link creation and editing transactions by conditionally inserting text only when it differs from the existing document content. Both Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
When adding a link, if the end aligns with the end of a comment, the comment will be removed across the content spanned by the link.
This is because adding a link calls
tr.insertText, which replaces the content spanned by the link. This is a problem especially with comments as they are notinclusivein their TipTap mark spec. Therefore, when content that they cover gets replaced, they get cleared instead of preserved.This PR makes it so that
tr.insertTextonly gets called if the text has actually changed, which doesn't happen in most cases. If it does happen, there are a bunch of edge cases that have to be considered, e.g.:Given the following content, where {} marks the span of a link and [] marks the span of a comment:
If the link's text is changed to something completely different, like "qwe", where should the comment start?
Therefor, this PR only covers the case where the text remains the same.
Closes #2573
Rationale
It's annoying for users to accidentally clear comments when trying to add links.
Changes
tr.insertTextget called conditionally increateLink.Impact
N/A
Testing
TODO
Screenshots/Video
N/A
Checklist
Additional Notes
Summary by CodeRabbit