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(horizontal-rule): fix insertion behavior #4898
base: main
Are you sure you want to change the base?
Conversation
- when a horizontal rule is placed in the position of a gapcursor under a node, it no longer appears above the node - when a selection stops at the beginning of a text node, it doesn't prevent the rule from replacing the entire selection - if a single node is selected, the rule is placed under it instead of replacing it
✅ Deploy Preview for tiptap-embed ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Looks good. Could you add a test case for this in cypress? |
Sure! I'll add it shortly when I'm back home. |
3f9bc20
to
6259959
Compare
I've added test cases. I wasn't sure exactly what I should do in order to test the insertion related to image nodes. That is, whether I should modify the horizontal rule demo to include some other empty leaf node or add a case to the integration tests folder. I decided on the latter. Also I refactored the code a bit to get rid of a trailing break left after selection replacement. |
Please describe your changes
This PR contains fixes to the
HorizontalRule
extension, which behaves a bit unintuitively in certain cases.How did you accomplish your changes
This clause now checks if there's indeed just a cursor at this position (ensuring
from
andto
match). The value decremented from$originTo.pos
is now1
instead of2
, which prevents the rule from appearing before the node.This clause is responsible for preventing replacement of nodes by the horizontal rule.
How can we verify your changes
By adding an image node to the horizontal rule demo and then setting the rule.
Remarks
The behavior of the rule replacing image nodes when selected might be something that only I find undesirable, making it more of a feature proposal than a fix, I guess.
Checklist
Related issues