-
Notifications
You must be signed in to change notification settings - Fork 4.4k
/
Copy pathindex.js
40 lines (33 loc) · 985 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* External dependencies
*/
import { orderBy } from 'lodash';
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { Toolbar, Slot, DropdownMenu, createSlotFill } from '@wordpress/components';
const { Slot: ToolbarControlsSlot } = createSlotFill( 'RichText.ToolbarControls' );
const FormatToolbar = ( { controls } ) => {
return (
<div className="editor-format-toolbar block-editor-format-toolbar">
<Toolbar>
{ controls.map( ( format ) =>
<Slot name={ `RichText.ToolbarControls.${ format }` } key={ format } />
) }
<ToolbarControlsSlot>
{ ( fills ) => fills.length !== 0 &&
<DropdownMenu
icon={ false }
position="bottom left"
label={ __( 'More Rich Text Controls' ) }
controls={ orderBy( fills.map( ( [ { props } ] ) => props ), 'title' ) }
/>
}
</ToolbarControlsSlot>
</Toolbar>
</div>
);
};
FormatToolbar.Slot = ToolbarControlsSlot;
export default FormatToolbar;