@@ -6,31 +6,55 @@ import {
6
6
RichText ,
7
7
useBlockProps ,
8
8
} from '@wordpress/block-editor' ;
9
- import { ToggleControl , PanelBody } from '@wordpress/components' ;
9
+ import {
10
+ ToggleControl ,
11
+ __experimentalToolsPanel as ToolsPanel ,
12
+ __experimentalToolsPanelItem as ToolsPanelItem ,
13
+ } from '@wordpress/components' ;
10
14
import { createBlock , getDefaultBlockName } from '@wordpress/blocks' ;
11
15
import { __ } from '@wordpress/i18n' ;
12
16
17
+ /**
18
+ * Internal dependencies
19
+ */
20
+ import { useToolsPanelDropdownMenuProps } from '../utils/hooks' ;
21
+
13
22
export default function ReadMore ( {
14
23
attributes : { content, linkTarget } ,
15
24
setAttributes,
16
25
insertBlocksAfter,
17
26
} ) {
18
27
const blockProps = useBlockProps ( ) ;
28
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps ( ) ;
29
+
19
30
return (
20
31
< >
21
32
< InspectorControls >
22
- < PanelBody title = { __ ( 'Settings' ) } >
23
- < ToggleControl
24
- __nextHasNoMarginBottom
33
+ < ToolsPanel
34
+ label = { __ ( 'Settings' ) }
35
+ resetAll = { ( ) => setAttributes ( { linkTarget : '_self' } ) }
36
+ dropdownMenuProps = { dropdownMenuProps }
37
+ >
38
+ < ToolsPanelItem
25
39
label = { __ ( 'Open in new tab' ) }
26
- onChange = { ( value ) =>
27
- setAttributes ( {
28
- linkTarget : value ? '_blank' : '_self' ,
29
- } )
40
+ isShownByDefault
41
+ hasValue = { ( ) => linkTarget !== '_self' }
42
+ onDeselect = { ( ) =>
43
+ setAttributes ( { linkTarget : '_self' } )
30
44
}
31
- checked = { linkTarget === '_blank' }
32
- />
33
- </ PanelBody >
45
+ >
46
+ < ToggleControl
47
+ __nextHasNoMarginBottom
48
+ label = { __ ( 'Open in new tab' ) }
49
+ onChange = { ( value ) =>
50
+ setAttributes ( {
51
+ linkTarget : value ? '_blank' : '_self' ,
52
+ } )
53
+ }
54
+ checked = { linkTarget === '_blank' }
55
+ />
56
+ </ ToolsPanelItem >
57
+ </ ToolsPanel >
34
58
</ InspectorControls >
35
59
< RichText
36
60
identifier = "content"
0 commit comments