[WEB-372] fix: horizontal rule extension now always divider adds below nodes #3890
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.
Description
When a horizontal rule/divider is placed in the position under an empty leaf node (such as an image/table/etc), it was not being inserted after the node.
Detailed Description of Changes:
Preventing Horizontal Rule from Appearing Before a Node:
The key change is in the way the position for inserting a horizontal rule is calculated when there's only a cursor at the position, particularly when the cursor is at the beginning (parentOffset === 0) of a node. Previously, the position calculated for insertion subtracted 2 from $originTo.pos, which could lead to the rule appearing before the intended node. This has been corrected to subtract 1 instead, ensuring the rule is inserted at the correct location, directly where the cursor is, avoiding unintended placements before the node.
This adjustment ensures that the rule is inserted in a more expected location, especially in cases where the cursor is at the very start of a node.
Demo
Screen.Recording.2024-03-06.at.6.24.44.PM.mov