-
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
Block Library: Replace hardcoded core/paragraph with getDefaultBlockName in onSplitAtEnd callbacks #40954
Merged
andrewserong
merged 1 commit into
trunk
from
update/on-split-end-calls-to-use-default-block-name
May 10, 2022
Merged
Block Library: Replace hardcoded core/paragraph with getDefaultBlockName in onSplitAtEnd callbacks #40954
andrewserong
merged 1 commit into
trunk
from
update/on-split-end-calls-to-use-default-block-name
May 10, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ame in onSplitAtEnd callbacks
andrewserong
added
[Type] Code Quality
Issues or PRs that relate to code quality
[Package] Block library
/packages/block-library
[Block] Audio
Affects the Audio Block
[Block] Embed
Affects the Embed Block
[Block] Gallery
Affects the Gallery Block - used to display groups of images
[Block] Image
Affects the Image Block
[Block] Pullquote
Affects the Pullquote Block
[Block] Quote
Affects the Quote Block
[Block] Table
Affects the Table Block
[Block] Video
Affects the Video Block
labels
May 10, 2022
Nik and George — I've added you both as reviewers, but this PR is low priority, so not a problem at all if you don't get time to review it 🙂 |
Size Change: +47 B (0%) Total Size: 1.24 MB
ℹ️ View Unchanged
|
ntsekouras
approved these changes
May 10, 2022
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.
Looks good, thanks @andrewserong! Also the sample block markup for testing was a cool idea 💯
andrewserong
deleted the
update/on-split-end-calls-to-use-default-block-name
branch
May 10, 2022 07:00
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
[Block] Audio
Affects the Audio Block
[Block] Embed
Affects the Embed Block
[Block] Gallery
Affects the Gallery Block - used to display groups of images
[Block] Image
Affects the Image Block
[Block] Pullquote
Affects the Pullquote Block
[Block] Quote
Affects the Quote Block
[Block] Table
Affects the Table Block
[Block] Video
Affects the Video Block
[Package] Block library
/packages/block-library
[Type] Code Quality
Issues or PRs that relate to code quality
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.
What?
This code quality PR follows on from #40934 and #40803 — here we replace all hard-coded instances of
core/paragraph
inonSplitAtEnd
callbacks in RichText fields withgetDefaultBlockName
in the following blocks:Why?
It's better for us to use
getDefaultBlockName
than a hard-coded paragraph block, so that we respect the editor's setting for the default block.The reason for this PR, is that I initially added a hard-coded paragraph block in #40803 because I was copying from examples in other blocks — if we update all blocks to use the
getDefaultBlockName
approach, then it's less likely for someone like me to make the same mistake in the future 😀How?
Use
getDefaultBlockName
in place ofcore/paragraph
in the calls tocreateBlock
inonSplitAtEnd
callbacks in RichText fields.Testing Instructions
I manually added the above blocks, and tested that hitting Enter created a paragraph block below in the editor.
I also ran the native mobile GB in the iOS simulator and confirmed that hitting enter in the Citation field of the Pullquote block, and at the end of any Caption field correctly added a paragraph block below.
If you'd like to quickly grab some markup of the updated blocks, some sample markup is below:
Sample block markup for testing (you'll need to supply your own images)