-
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
Blocks: Add direction attribute / LTR button to paragraph block #10663
Conversation
@@ -65,6 +65,10 @@ const schema = { | |||
customFontSize: { | |||
type: 'number', | |||
}, | |||
direction: { | |||
type: 'string', | |||
enum: [ 'ltr', 'rtl' ], |
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.
do we support this enum
property?
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.
Not yet 😉
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.
Well, to clarify, it's supported in the server-side validation, but isn't ported to the client. Idea with adding here now is it "just works" when ported.
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.
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.
There's probably a lot of block attributes where this could be considered. align
for instance
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.
Related: #10635, #9829 (comment)
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 approach looks good to me. I wonder if we should add an RTL e2e test (not just specific to this though). I'd appreciate a review from @yoavf as he has more experience on these matters.
controls={ [ | ||
{ | ||
icon: 'editor-ltr', | ||
title: _x( 'Left to right', 'editor button' ), |
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.
In case this raises eyebrows, the hope / intention is to inherit the existing string:
Let's merge it as is and revisit later if @yoavf has some concerns. |
Is it possible to manually add/enable the direction attribute / LTR button if the current locale isn't RTL? |
We need this. |
Closes #138
This pull request seeks to add an LTR toggle button to the paragraph block toolbar when an RTL locale is active.
It adds a new
direction
block to the paragraph block. As implemented, the value will only ever beltr
orundefined
, given current UI behavior as toggle only shown when the editor is configured as RTL. When non-undefined, it assigns adir
attribute to the saved markup. This should be entirely backward-compatible with existing paragraph blocks.Future compatibility notes:
Testing Instructions:
Verify there's no LTR button when an LTR locale is active.
Verify that an LTR button is active and serves as a toggle for paragraph block when an RTL locale is active.
cc @yoavf @aahani