fix: only start at block with removing if not an inline node #4791
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.
Please describe your changes
In the pull request: #4341 (originally: #3859), a fix was implemented for HorizontalRule. This made sure that for this extension/node, which is a block node, it would replace the whole block. This lead to problems in my implementation where I use an inline node. This is why I decided to, instead of overwriting the inputrule handing, fixing the issue in this PR.
How did you accomplish your changes
I've looked into previous versions of @tiptap/core to see where this issue first occured, and back-tracked it to the PR's mentioned above. It seemed like this change was made taking into account existing nodes in the TipTap repository, which use NodeInputRule and are block.
From what I could figure out, I don't think you want the replacement of the whole block to happen in case of an inline node, which is why I decided to create this PR.
How have you tested your changes
I've been testing this change in the example of the HorizontalRule, but also creating a small inline node. This confirmed my suspisions, as it seemed like it now supported both only adding and removing the node, but still also supported for block nodes to replace the whole block.
How can we verify your changes
Use the demo environment from the HorizontalRule, and see if this does still work like expected. Then create a small node like
and add that as well. From this you should see that you can add the inline node on the same line, but still keep the HorizontalRule replacing the whole block.
Remarks
Tried to do everything as would be expected, but this is honestly my first time contributing to an open source project. I've tried to look if I needed to add tests somewhere, but couldn't find an already existing test file for this, so didn't add them for now. Please let me know if you need any more information.
Checklist
Related issues
#3859
#4341
#4796