Blocks: Add direction attribute / LTR button to paragraph block#10663
Blocks: Add direction attribute / LTR button to paragraph block#10663
Conversation
| }, | ||
| direction: { | ||
| type: 'string', | ||
| enum: [ 'ltr', 'rtl' ], |
There was a problem hiding this comment.
do we support this enum property?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
There's probably a lot of block attributes where this could be considered. align for instance
youknowriad
left a comment
There was a problem hiding this comment.
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.
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
directionblock to the paragraph block. As implemented, the value will only ever beltrorundefined, given current UI behavior as toggle only shown when the editor is configured as RTL. When non-undefined, it assigns adirattribute 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