-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Apply keyboard shortcut conversions between paragraphs and headings to all editor instances #47972
Conversation
name: `core/block-editor/transform-heading-to-paragraph`, | ||
name: `core/edit-post/transform-heading-to-paragraph`, |
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 think the namespace should be unified.
Size Change: +1.01 kB (0%) Total Size: 1.33 MB
ℹ️ View Unchanged
|
const textAlign = | ||
blockName === 'core/paragraph' ? 'align' : 'textAlign'; | ||
const destinationTextAlign = | ||
destinationBlockName === 'core/paragraph' ? 'align' : 'textAlign'; | ||
|
||
replaceBlocks( | ||
currentClientId, | ||
createBlock( destinationBlockName, { | ||
level, | ||
content: currentContent, | ||
align: currentAlign, | ||
content: attributes.content, | ||
...{ [ destinationTextAlign ]: attributes[ textAlign ] }, |
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.
Heading block and paragraph block have different property name for text alignment:
- Heading Block:
textAlign
- Paragraph Block:
align
Therefore, property name and value must be properly mapped.
Flaky tests detected in f7e0a41. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4229265049
|
…o all editor instances
33cfa17
to
54dff7d
Compare
af6efee
to
2c8ea0b
Compare
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.
Can't speak for the code, but the tests look good 👍. We might need a rebase though.
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 think this is a great default functionality to have across all editors. Its kinda weird that it has to be spelled out three different times but 🤷🏻
Follow-up on: #44681
What?
This PR adds conversion keyboard shortcuts between paragraphs and headings to all editors, in addition to the post editor.
How?
In addition to adding shortcuts, the following actions have been taken:
Testing Instructions
In the post/edit-site/edit-widgets/customize-widgets, check the following: