Fix NodePos logic for child position calculation and attribute changes #5716
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes Overview
This pull request addresses several issues in the
@tiptap/core
package, particularly focusing on fixing problems related toNodePos
attributes and child positions. The main changes include bug fixes to ensure correct handling of non-text atoms and improvements to the attribute update mechanism.Bug fixes:
.changeset/nervous-bats-film.md
: Fixed an issue while updating attributes on aNodePos
that was not a text..changeset/sweet-feet-dream.md
: Fixed issues withNodePos
child positions causing wrong positions when used on non-text atoms.Changes:
packages/core/src/NodePos.ts
: Modified the calculation oftargetPos
to correctly handle non-text atoms by adjusting the offset conditionally.packages/core/src/NodePos.ts
: Refactored thesetAttribute
method to use a transaction (tr
) for setting node markup and dispatching the update, improving the attribute update mechanism.Implementation Approach
Testing Done
Verification Steps
That's my demo:
Additional Notes
Nothing
Checklist
Related Issues
This PR should fix #5672 and fix #5671