-
-
Notifications
You must be signed in to change notification settings - Fork 344
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
linebreakReplacement node isn't used during joinForward/joinBackward operations #1490
Comments
That's a good point. Attached patch implements this. |
Awesome, thank you! |
Hi @marijnh, sorry to be a pain but in doing some testing I think I've found an issue with this fix. The lineBreak replacement is done in the
Unrelated: there's a small spelling typo in the function name "canAppendWithSubstitutedLinebeaks" |
FIX: Allow `Transform.join` to clear incompatible inline content from the node after the join. Issue ProseMirror/prosemirror#1490
…form.join FIX: Support implicit conversion between hard break nodes and newlines in the `joinForward` and `joinBackward` commands. Issue ProseMirror/prosemirror#1490
That's a good point. Kind of awkward to arrange for these removals and replacements to be done in the correct order, so I've moved the responsibility for cleaning up inline nodes/marks into |
Thanks! I've ran some tests and that appears to be working as expected now. 🎉 |
Previously I had reported an issue (#1460) with newlines collapsing when converting code blocks to paragraphs (or other block types) when using either
setBlockType
or as a result of ajoinForward/joinBackward
operation.The outcome of this was the introduction of the
linebreakReplacement
property that can be optionally applied to ourhardBreak
node so that it would replace newlines during these conversions instead of them being replaced by spaces.Admittedly we've been very slow to adopt this, but I'm implementing this now in our editor and I can see that the lineBreakReplacement node is not used during
joinForward
orjoinBackward
operations that are invoked by the backpace/delete key.Looking at the source (ProseMirror/prosemirror-transform@a0ab849) I can see that the property is only used by the
setBlockType
transform, whereasjoinForward
/joinBackward
continue to invoke theclearIncompatible
transform which removes newline characters, ignoringlineBreakReplacement
.Is it possible
joinForward
/joinBackward
' can behave similarly tosetBlockType
on these occasions and respect thelinebreakReplacement
setting?Steps to reproduce:
linebreakReplacement : true
enabled for thehard_break
node.code
node below it with multiple lines of code.joinBackward
Actual result:
Code is joined into the preceding paragraph with it's newlines being replaced by spaces.
Expected result:
Code is joined into the preceding paragraph with it's newlines being replaced by
hard_break
The text was updated successfully, but these errors were encountered: