PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 2.0.2
GenerateBlocks v2.0.2
trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / src / components / link-block-toolbar / LinkBlockToolbar.jsx
generateblocks / src / components / link-block-toolbar Last commit date
LinkBlockToolbar.jsx 1 year ago index.js 1 year ago
LinkBlockToolbar.jsx
46 lines
1 import { __ } from '@wordpress/i18n';
2 import { ToolbarButton, Dropdown } from '@wordpress/components';
3 import { BlockControls } from '@wordpress/block-editor';
4 import { link } from '@wordpress/icons';
5 import { URLControls } from '../../components/url-controls';
6
7 export function LinkBlockToolbar( { tagName, setAttributes, htmlAttributes, context } ) {
8 const POPOVER_PROPS = {
9 position: 'bottom right',
10 };
11
12 if ( 'a' !== tagName ) {
13 return null;
14 }
15
16 const url = htmlAttributes?.href ?? '';
17
18 return (
19 <BlockControls group="inline">
20 <Dropdown
21 contentClassName="gblocks-button-link-dropdown"
22 popoverProps={ POPOVER_PROPS }
23 renderToggle={ ( { isOpen, onToggle } ) => (
24 <ToolbarButton
25 icon={ link }
26 label={ ! url ? __( 'Add Link', 'generateblocks' ) : __( 'Change Link', 'generateblocks' ) }
27 onClick={ onToggle }
28 aria-expanded={ isOpen }
29 isPressed={ !! url }
30 />
31 ) }
32 renderContent={ () => (
33 <>
34 <URLControls
35 htmlAttributes={ htmlAttributes }
36 setAttributes={ setAttributes }
37 context={ context }
38 tagName={ tagName }
39 />
40 </>
41 ) }
42 />
43 </BlockControls>
44 );
45 }
46