-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Fix/insert content at block insertions #5651
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
Conversation
🦋 Changeset detectedLatest commit: 86b1a4d 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. |
@nperez0111 tests should now work - we actually had this fix already implemented but only on an extension level for the |
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.
This looks good to me!
Changes Overview
This PR fixes an issue that was brought up by a community member about how the
insertContent
andinsertContentAt
commands always split text nodes when the selection starts at the beginning of the text. This would always lead to the inserted content having an empty paragraph inserted above it.In the following example I'll try to point out the issue more
Let's say your cursor right now is at the start of
Hello World
and you would insert an image, the resulting HTML previously would returnAfter this fix the HTML will result to this:
When the content is inserted between existing text, it will just work as usual via splitting the paragraph/text node apart.
Implementation Approach
Before we run the actual inserting of block node content, I added a check to see if
If both requirements are met, we jump out of the node via
from =- 1
to prepend said node before the current text block.Testing Done
I added two test cases for those scenarios and both run valid + did manual tests.
Verification Steps
insertContent
demoAdditional Notes
This is a major change as it could break existing insertContent usages.
Checklist