-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
feat: Split formatted text on triple Enter #53354
Conversation
Size Change: +541 B (0%) Total Size: 1.62 MB
ℹ️ View Unchanged
|
64fa7fe
to
b84638f
Compare
It is difficult to exit a formatted text block, e.g. Verse, using only the keyboard. This splits the block when pressing enter and the two previous characters are line breaks.
Apply Verse and Preformatted block behavior to the Code block. However, this applied code does not currently run as Code relies upon the older version of `PlainText`.
Improve splitting and merging block functionality by relying upon the more robust `RichText` component. Merging blocks into Code does not always work as expected, e.g. a Paragraph into a Code block fails.
Certain contexts apply different padding for different directions, e.g. horizontal vs vertical, left vs right.
This reverts commit 6205651.
This reverts commit 37d3fa3.
d643118
to
49378a6
Compare
49378a6
to
84713d9
Compare
} else if ( canSplitAtEnd ) { | ||
onSplitAtEnd(); | ||
} else if ( | ||
// For some blocks it's desirable to split at the end of the | ||
// block when there are two line breaks at the end of the | ||
// block, so triple Enter exits the block. | ||
onSplitAtDoubleLineEnd && | ||
splitStart === splitEnd && | ||
splitEnd === text.length && | ||
text.slice( -2 ) === '\n\n' | ||
) { | ||
value.start = value.end - 2; | ||
onChange( remove( value ) ); | ||
onSplitAtDoubleLineEnd(); | ||
} else if ( ! disableLineBreaks ) { | ||
onChange( insert( value, '\n' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes were copied from the web's useEnter
implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes to this Code block file have no impact as the dev-only block relies upon an older implementation of PlainText
that does not support block split or merge functionality.
Because the block is not publicly available and refactoring to the new version of PlainText
caused styling issues, I opted to not finishing implementing the Code block. I added support in c7a8a46 and ef597ae; reverted that support in b759968 and b76d105.
I retained the remaining proposed changes as it better aligns the code with its web counterpart and could be used in the future.
Flaky tests detected in 57c4690. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6398033478
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to follow the testing steps successfully on an iPhone SE and Samsung Galaxy S20 FE, in addition to trying various other combinations of cursor positions to split and merge blocks, and did not encounter any regressions. LGTM. 🚀
This is not a regression for this branch as I was able to reproduce this in split-formatted-text-on-triple-enter.mov |
Yes, I noticed the same. The delayed feedback when pressing the Return key is also present when running the Demo editor on iOS. I checked out the There has long been lag when interacting with the Demo editor using the Metro server. I am unsure if this particular case is a degradation or expected. Given its presence in |
What?
Enable splitting or exiting a formatted block, e.g. Verse, Preformatted, Code,
by pressing Return three times.
Why?
Relates to #52773 and #53332. It is difficult to exit these formatted blocks
using the keyboard only.
How?
onEnter
implementation.Testing Instructions
Split formatted blocks on triple Enter
Splitting & Merging blocks
Testing Instructions for Keyboard
n/a
Screenshots or screencast
n/a