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
Fix the issues with
setBlockquote
andunsetBlockquote
commands.Implementation Approach
Tiptap checks
isNodeActive
by searching upwards from the current position, and based on the result, it executes eitherwrapIn
orlift
. However, ProseMirror'swrapIn
andlift
only evaluate the currentblockRange
, which can cause the command to not function as expected.To address this, add a
findWrappingUntil
helper, which will search upwards until it finds a valid wrapping position. This will resolve issue #3743.Additionally, add a
nodeType
check when retrievingblockRange
in thelift
command, which will resolve issue #4434.Testing Done
In the example default editor, a
disabled
attribute was added to the blockquote action button. This will disable the button when the action cannot be performed. Theid
attribute was also added for better Cypress testing.Three test cases were added:
toggleBlockquote
will wrap the entire list.toggleBlockquote
will wrap only the second element.toggleBlockquote
will remove the blockquote wrapping without altering the list.Verification Steps
Visit the default editor page or run the Cypress tests.
Additional Notes
It seems we should directly modify
commands.wrapIn
instead of changingsetBlockquote
in the blockquote extension. The range of checks inProseMirror.wrapIn
andtiptap.isNodeActive
are inconsistent, which may be the core issue.On the other hand, the situation with
commands.lift
is the opposite, aslift
has a specific node type. We must search upwards from the current position to find the required type.Checklist
Related Issues