Skip to content
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

Framework: split RichText component (part 1) #15212

Merged
merged 12 commits into from
Jun 25, 2019
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import { orderBy } from 'lodash';
import { __ } from '@wordpress/i18n';
import { Toolbar, Slot, DropdownMenu } from '@wordpress/components';

const FormatToolbar = ( { controls } ) => {
const FormatToolbar = () => {
return (
<div className="editor-format-toolbar block-editor-format-toolbar">
<Toolbar>
{ controls.map( ( format ) =>
{ [ 'bold', 'italic', 'link' ].map( ( format ) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to ask, why is this hardcoded now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good question! These names are kind of hardcoded already in the formatting library. You cannot really add anything else here. But I forgot about the case where you'd remove the controls by setting an empty array. That case was already only partially working in master, see #14542. Let's try to correct it there again.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now fixed in #14542.

<Slot name={ `RichText.ToolbarControls.${ format }` } key={ format } />
) }
<Slot name="RichText.ToolbarControls">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

import { Toolbar, Slot } from '@wordpress/components';

const FormatToolbar = ( { controls } ) => {
const FormatToolbar = () => {
return (
<Toolbar>
{ controls.map( ( format ) =>
{ [ 'bold', 'italic', 'link' ].map( ( format ) =>
<Slot name={ `RichText.ToolbarControls.${ format }` } key={ format } />
) }
<Slot name="RichText.ToolbarControls" />
Expand Down
Loading