Skip to content

Commit

Permalink
Allow blocks to align inlineToolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed May 1, 2018
1 parent 3478730 commit db4c94d
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 9 deletions.
4 changes: 4 additions & 0 deletions blocks/rich-text/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ a traditional `input` field, usually when the user exits the field.

*Optional.* A list of autocompleters to use instead of the default.

### `inlineToolbar: String`

*Optional.* Render the formatting toolbar inline, next to the rich text field. Needs to be a string that can be used with the `justify-content` CSS property.

## RichText.Content

When using RichText in the edit function of blocks, the usage of `RichText.Content` is recommended in the save function of your blocks to save the correct HTML.
Expand Down
5 changes: 4 additions & 1 deletion blocks/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,10 @@ export class RichText extends Component {
</BlockFormatControls>
) }
{ isSelected && inlineToolbar && (
<div className="block-rich-text__inline-toolbar">
<div
className="block-rich-text__inline-toolbar"
style={ { justifyContent: inlineToolbar } }
>
{ formatToolbar }
</div>
) }
Expand Down
2 changes: 1 addition & 1 deletion core-blocks/audio/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export const settings = {
placeholder={ __( 'Write caption…' ) }
value={ caption }
onChange={ ( value ) => setAttributes( { caption: value } ) }
inlineToolbar
inlineToolbar="center"
/>
) }
</figure>
Expand Down
2 changes: 1 addition & 1 deletion core-blocks/cover-image/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export const settings = {
placeholder={ __( 'Write title…' ) }
value={ title }
onChange={ ( value ) => setAttributes( { title: value } ) }
inlineToolbar
inlineToolbar="center"
/>
) : null }
</div>
Expand Down
2 changes: 1 addition & 1 deletion core-blocks/embed/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ function getEmbedBlockSettings( { title, description, icon, category = 'embed',
placeholder={ __( 'Write caption…' ) }
value={ caption }
onChange={ ( value ) => setAttributes( { caption: value } ) }
inlineToolbar
inlineToolbar="center"
/>
) : null }
</figure>
Expand Down
2 changes: 1 addition & 1 deletion core-blocks/gallery/gallery-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class GalleryImage extends Component {
isSelected={ this.state.captionSelected }
onChange={ ( newCaption ) => setAttributes( { caption: newCaption } ) }
onFocus={ this.onSelectCaption }
inlineToolbar
inlineToolbar="center"
/>
) : null }
</figure>
Expand Down
2 changes: 1 addition & 1 deletion core-blocks/image/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ class ImageBlock extends Component {
onFocus={ this.onFocusCaption }
onChange={ ( value ) => setAttributes( { caption: value } ) }
isSelected={ this.state.captionFocused }
inlineToolbar
inlineToolbar="center"
/>
) : null }
</figure>
Expand Down
2 changes: 1 addition & 1 deletion core-blocks/pullquote/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const settings = {
}
isSelected={ isSelected && editable === 'cite' }
onFocus={ onSetActiveEditable( 'cite' ) }
inlineToolbar
inlineToolbar="center"
/>
) }
</blockquote>
Expand Down
2 changes: 1 addition & 1 deletion core-blocks/quote/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const settings = {
placeholder={ __( 'Write citation…' ) }
isSelected={ isSelected && editable === 'cite' }
onFocus={ onSetActiveEditable( 'cite' ) }
inlineToolbar
inlineToolbar="left"
/>
) }
</blockquote>
Expand Down
2 changes: 1 addition & 1 deletion core-blocks/video/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export const settings = {
placeholder={ __( 'Write caption…' ) }
value={ caption }
onChange={ ( value ) => setAttributes( { caption: value } ) }
inlineToolbar
inlineToolbar="center"
/>
) }
</figure>
Expand Down

0 comments on commit db4c94d

Please sign in to comment.