-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Fix getMarkRange not finding marks when at the start of a mark #5717
Conversation
🦋 Changeset detectedLatest commit: 91ad89f The changes in this PR will be included in the next version bump. This PR includes changesets to release 54 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for tiptap-embed ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
Other than the test file, looks good to me
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.
Could we add a test to prove that the look back won't cross a node boundary?
Like two paragraphs with the first having the mark we are looking for but we use the position of the first text position in the second paragraph.
The danger of looking backward is that it can misreport so I just want to prove that it doesn't in a test
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.
Added two additional tests with
- Two paragraphs, first paragraph has a link at the end - testing if putting the cursor at the end of it will result in the correct mark + if the cursor at the start of the second paragraph returns undefined.
- Two paragraphs, first paragraph doesnt have a link, second one has a link at the start - checking if the end position of the first paragraph returns undefined and the position at the start of the second paragraph returns the correct mark.
Changes Overview
This pull request addresses an issue in the
@tiptap/core
package where thegetMarkRange
function did not return the correct range when the cursor was at the start of the specified mark. The changes involve both documentation and code modifications to ensure accurate behavior.Bug Fix:
packages/core/src/helpers/getMarkRange.ts
: Updated thegetMarkRange
function to correctly handle cases where the cursor is at the start of a text node without the mark, ensuring it looks backward and returns the appropriate range.Implementation Approach
You can find out more about my implementation from the comments in code. I basically added a forward, then backward check for marks on the current nodes parent with the parent offset.
Testing Done
Tested it locally on my machine in a demo I build. (See below)
Verification Steps
My demo:
Additional Notes
Nothing to add here
Checklist
Related Issues
Fixes #5715