-
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
Quote Block: Adding alignment controls to the quote block #511
Changes from 4 commits
76f8742
39abb03
95723f3
e5ba308
be27f94
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,6 +137,11 @@ class VisualEditorBlock extends wp.element.Component { | |
wrapperProps = settings.getEditWrapperProps( block.attributes ); | ||
} | ||
|
||
// Normalize controls as an array of arrays (toolbars of controls) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, but this component will have the following props : content, attributes, setAttributes. Or we could pass a block uid instead and duplicate |
||
const toolbars = settings.controls && settings.controls.length && ! Array.isArray( settings.controls[ 0 ] ) | ||
? [ settings.controls ] | ||
: settings.controls; | ||
|
||
// Disable reason: Each block can receive focus but must be able to contain | ||
// block children. Tab keyboard navigation enabled by tabIndex assignment. | ||
|
||
|
@@ -159,14 +164,15 @@ class VisualEditorBlock extends wp.element.Component { | |
{ isSelected && ! isTyping && | ||
<div className="editor-visual-editor__block-controls"> | ||
<BlockSwitcher uid={ block.uid } /> | ||
{ !! settings.controls && ( | ||
{ toolbars.map( ( controls, index ) => ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will error if a block doesn't define controls because |
||
<Toolbar | ||
controls={ settings.controls.map( ( control ) => ( { | ||
key={ index } | ||
controls={ controls.map( ( control ) => ( { | ||
...control, | ||
onClick: () => control.onClick( block.attributes, this.setAttributes ), | ||
isActive: control.isActive( block.attributes ) | ||
} ) ) } /> | ||
) } | ||
) ) } | ||
<Slot name="Formatting.Toolbar" /> | ||
</div> | ||
} | ||
|
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 want the text alignment to apply to the entire quote (including citation), or just the paragraphs? cc @jasmussen
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 text alignment only applies to the selected text, not a block. Float alignment applies to the whole block.
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.
Good question @joyously and @jasmussen might help to answer here. For me considering the alignment as inline controls is relevant for the continuous Text block #447.
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.
Sorry, I missed this. Yes it would be preferrable if we were able to have the alignments be per paragraph. Let me know if you'd like a mockup.
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 I ask for a clarification? Is this for the current quote block or for the continuous Text block? Yep, some mockups could be good :)
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.
Sorry for the midstream correction on this one. Here's a mockup of a multi paragraph quote:
Note how the caret is in text that is left aligned, therefore the toolbar shows the left alignment highlighted.
Now the first paragraph is right aligned:
Note how the caret is inside the first paragraph.
Technically the behavior here would be the same as that of the "Continuous text" block.