-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
fix: edit link will break the text styles #7863
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
Reviewer's GuideThis pull request fixes a bug where text styles (like bold, italic) were lost when creating or removing links. The implementation retrieves existing text attributes before modifying link-specific attributes, ensuring other styles are preserved. Link removal logic was also refactored into an File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @asjqkkkk - I've reviewed your changes - here's some feedback:
- Consider consolidating the
getAttribute
logic to avoid duplication between the test and the extension. - The pattern of fetching existing attributes before formatting or replacing text is repeated; explore if this could be further refactored within the extension.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
if (start > startOffset) break; | ||
final length = op.length; | ||
if (start + length > startOffset) { | ||
attributes = op.attributes ?? {}; |
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.
suggestion (bug_risk): Consider cloning the attributes to avoid unintended mutation.
Since _getAttribute returns op.attributes by reference, removing keys will mutate shared state. Clone the map first (e.g., with Map.from) before modifying.
attributes = op.attributes ?? {}; | |
attributes = op.attributes != null ? Map.from(op.attributes) : {}; |
ebe3ceb
to
4651316
Compare
@@ -8,32 +8,65 @@ extension LinkExtension on EditorState { | |||
if (node == null) { | |||
return; | |||
} | |||
final attributes = _getAttribute(node, selection); |
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 we're not getting all the attributes from the selection. For example:
Before:
http://appflowy.io <- (add one more o here)
After:
http://appflowy.ioo The result should be ioo without extra formatting.
We have a slice attributes function that gets the attributes based on the index. appflowyEditorSliceAttributes
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.
yes, the logic about getting Attributes is not correct, I need to adjust it
Feature Preview
PR Checklist
Summary by Sourcery
Fix an issue with editing links that could potentially break text styles in the document editor
Bug Fixes:
Enhancements:
Tests: