@wordpress/block-editor 12.14.0 → 12.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/README.md +1 -1
- package/build/components/block-list/block.native.js +2 -0
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-parent-selector/index.js +1 -1
- package/build/components/block-parent-selector/index.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +25 -16
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js +4 -2
- package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build/components/block-patterns-list/index.js +36 -19
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-rename/index.js +28 -0
- package/build/components/block-rename/index.js.map +1 -0
- package/build/components/block-rename/is-empty-string.js +10 -0
- package/build/components/block-rename/is-empty-string.js.map +1 -0
- package/build/components/block-rename/modal.js +87 -0
- package/build/components/block-rename/modal.js.map +1 -0
- package/build/components/block-rename/rename-control.js +74 -0
- package/build/components/block-rename/rename-control.js.map +1 -0
- package/build/components/block-rename/use-block-rename.js +17 -0
- package/build/components/block-rename/use-block-rename.js.map +1 -0
- package/build/components/block-settings-menu/block-settings-dropdown.js +33 -20
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +7 -0
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-toolbar/block-toolbar-menu.native.js +1 -1
- package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
- package/build/components/block-types-list/index.js +6 -2
- package/build/components/block-types-list/index.js.map +1 -1
- package/build/components/date-format-picker/index.js +8 -1
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/global-styles/advanced-panel.js +1 -1
- package/build/components/global-styles/advanced-panel.js.map +1 -1
- package/build/components/image-size-control/index.js +0 -5
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +3 -1
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/warning-max-depth-exceeded.native.js +29 -31
- package/build/components/inner-blocks/warning-max-depth-exceeded.native.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +1 -1
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/utils.js +3 -4
- package/build/components/inserter/block-patterns-tab/utils.js.map +1 -1
- package/build/components/inserter/hooks/use-patterns-state.js +2 -1
- package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build/components/inserter-listbox/index.js +11 -6
- package/build/components/inserter-listbox/index.js.map +1 -1
- package/build/components/inserter-listbox/item.js +24 -23
- package/build/components/inserter-listbox/item.js.map +1 -1
- package/build/components/inserter-listbox/row.js +5 -5
- package/build/components/inserter-listbox/row.js.map +1 -1
- package/build/components/list-view/use-list-view-expand-selected-item.js +2 -3
- package/build/components/list-view/use-list-view-expand-selected-item.js.map +1 -1
- package/build/components/preview-options/index.js +4 -2
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +1 -1
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/native/index.native.js +34 -3
- package/build/components/rich-text/native/index.native.js.map +1 -1
- package/build/components/rich-text/use-input-rules.js +30 -1
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +4 -1
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-moving-animation/index.js +2 -1
- package/build/components/use-moving-animation/index.js.map +1 -1
- package/build/components/use-settings/index.js +2 -2
- package/build/components/use-settings/index.js.map +1 -1
- package/build/hooks/block-renaming.js +42 -0
- package/build/hooks/block-renaming.js.map +1 -1
- package/build/hooks/custom-fields.js +53 -48
- package/build/hooks/custom-fields.js.map +1 -1
- package/build/hooks/index.js +0 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout.js +13 -7
- package/build/hooks/layout.js.map +1 -1
- package/build/layouts/constrained.js +4 -3
- package/build/layouts/constrained.js.map +1 -1
- package/build/store/selectors.js +2 -0
- package/build/store/selectors.js.map +1 -1
- package/build/utils/transform-styles/index.js +26 -6
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build-module/components/block-list/block.native.js +2 -0
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-parent-selector/index.js +1 -1
- package/build-module/components/block-parent-selector/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +24 -15
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js +4 -2
- package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +36 -19
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-rename/index.js +4 -0
- package/build-module/components/block-rename/index.js.map +1 -0
- package/build-module/components/block-rename/is-empty-string.js +4 -0
- package/build-module/components/block-rename/is-empty-string.js.map +1 -0
- package/build-module/components/block-rename/modal.js +79 -0
- package/build-module/components/block-rename/modal.js.map +1 -0
- package/build-module/components/block-rename/rename-control.js +66 -0
- package/build-module/components/block-rename/rename-control.js.map +1 -0
- package/build-module/components/block-rename/use-block-rename.js +10 -0
- package/build-module/components/block-rename/use-block-rename.js.map +1 -0
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +34 -21
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +7 -0
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-toolbar/block-toolbar-menu.native.js +1 -1
- package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
- package/build-module/components/block-types-list/index.js +6 -2
- package/build-module/components/block-types-list/index.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +8 -1
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/global-styles/advanced-panel.js +1 -1
- package/build-module/components/global-styles/advanced-panel.js.map +1 -1
- package/build-module/components/image-size-control/index.js +0 -5
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +3 -1
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/warning-max-depth-exceeded.native.js +30 -32
- package/build-module/components/inner-blocks/warning-max-depth-exceeded.native.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +4 -4
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +2 -2
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/utils.js +3 -4
- package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-state.js +2 -1
- package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build-module/components/inserter-listbox/index.js +13 -8
- package/build-module/components/inserter-listbox/index.js.map +1 -1
- package/build-module/components/inserter-listbox/item.js +25 -23
- package/build-module/components/inserter-listbox/item.js.map +1 -1
- package/build-module/components/inserter-listbox/row.js +6 -5
- package/build-module/components/inserter-listbox/row.js.map +1 -1
- package/build-module/components/list-view/use-list-view-expand-selected-item.js +2 -3
- package/build-module/components/list-view/use-list-view-expand-selected-item.js.map +1 -1
- package/build-module/components/preview-options/index.js +4 -2
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +1 -1
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/native/index.native.js +34 -3
- package/build-module/components/rich-text/native/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-input-rules.js +31 -2
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +4 -1
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-moving-animation/index.js +2 -1
- package/build-module/components/use-moving-animation/index.js.map +1 -1
- package/build-module/components/use-settings/index.js +2 -2
- package/build-module/components/use-settings/index.js.map +1 -1
- package/build-module/hooks/block-renaming.js +40 -0
- package/build-module/hooks/block-renaming.js.map +1 -1
- package/build-module/hooks/custom-fields.js +53 -48
- package/build-module/hooks/custom-fields.js.map +1 -1
- package/build-module/hooks/index.js +0 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout.js +13 -7
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/layouts/constrained.js +4 -3
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/store/selectors.js +2 -0
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +24 -7
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-style/content-rtl.css +6 -6
- package/build-style/content.css +6 -6
- package/build-style/style-rtl.css +10 -5
- package/build-style/style.css +10 -5
- package/package.json +31 -31
- package/src/components/block-list/block.native.js +2 -0
- package/src/components/block-parent-selector/index.js +1 -1
- package/src/components/block-pattern-setup/index.js +38 -22
- package/src/components/block-pattern-setup/setup-toolbar.js +2 -0
- package/src/components/block-pattern-setup/style.scss +4 -1
- package/src/components/block-patterns-list/README.md +4 -4
- package/src/components/block-patterns-list/index.js +60 -34
- package/src/components/block-patterns-list/style.scss +7 -0
- package/src/components/block-rename/index.js +3 -0
- package/src/components/block-rename/is-empty-string.js +3 -0
- package/src/components/block-rename/modal.js +115 -0
- package/src/components/block-rename/rename-control.js +80 -0
- package/src/components/block-rename/use-block-rename.js +10 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +38 -34
- package/src/components/block-settings-menu-controls/index.js +9 -0
- package/src/components/block-toolbar/block-toolbar-menu.native.js +1 -4
- package/src/components/block-types-list/index.js +5 -4
- package/src/components/button-block-appender/content.scss +2 -2
- package/src/components/date-format-picker/index.js +7 -0
- package/src/components/editable-text/README.md +0 -36
- package/src/components/global-styles/advanced-panel.js +1 -1
- package/src/components/image-size-control/index.js +0 -6
- package/src/components/inner-blocks/index.js +6 -2
- package/src/components/inner-blocks/warning-max-depth-exceeded.native.js +57 -33
- package/src/components/inserter/block-patterns-explorer/pattern-list.js +5 -1
- package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +7 -3
- package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +6 -1
- package/src/components/inserter/block-patterns-tab/utils.js +6 -4
- package/src/components/inserter/hooks/use-patterns-state.js +3 -1
- package/src/components/inserter-listbox/index.js +11 -7
- package/src/components/inserter-listbox/item.js +11 -12
- package/src/components/inserter-listbox/row.js +6 -12
- package/src/components/list-view/use-list-view-expand-selected-item.js +7 -8
- package/src/components/plain-text/README.md +0 -28
- package/src/components/preview-options/index.js +2 -0
- package/src/components/rich-text/README.md +0 -58
- package/src/components/rich-text/index.native.js +1 -1
- package/src/components/rich-text/native/index.native.js +45 -2
- package/src/components/rich-text/use-input-rules.js +30 -2
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
- package/src/components/url-input/README.md +1 -74
- package/src/components/use-block-drop-zone/index.js +4 -1
- package/src/components/use-moving-animation/index.js +1 -1
- package/src/components/use-settings/index.js +2 -2
- package/src/components/use-settings/test/index.js +1 -1
- package/src/hooks/block-renaming.js +47 -0
- package/src/hooks/custom-fields.js +68 -65
- package/src/hooks/index.js +0 -1
- package/src/hooks/layout.js +12 -8
- package/src/hooks/test/__snapshots__/align.native.js.snap +5 -5
- package/src/layouts/constrained.js +57 -50
- package/src/store/selectors.js +2 -0
- package/src/style.scss +1 -1
- package/src/utils/test/transform-styles.js +49 -0
- package/src/utils/transform-styles/index.js +39 -13
- package/build/hooks/block-rename-ui.js +0 -167
- package/build/hooks/block-rename-ui.js.map +0 -1
- package/build-module/hooks/block-rename-ui.js +0 -159
- package/build-module/hooks/block-rename-ui.js.map +0 -1
- package/src/hooks/block-rename-ui.js +0 -228
- /package/src/{hooks/block-rename-ui.scss → components/block-rename/style.scss} +0 -0
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';
|
|
5
|
-
import { addFilter } from '@wordpress/hooks';
|
|
6
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
7
|
-
import { hasBlockSupport } from '@wordpress/blocks';
|
|
8
|
-
import {
|
|
9
|
-
MenuItem,
|
|
10
|
-
__experimentalHStack as HStack,
|
|
11
|
-
__experimentalVStack as VStack,
|
|
12
|
-
Button,
|
|
13
|
-
TextControl,
|
|
14
|
-
Modal,
|
|
15
|
-
} from '@wordpress/components';
|
|
16
|
-
import { useState } from '@wordpress/element';
|
|
17
|
-
import { speak } from '@wordpress/a11y';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Internal dependencies
|
|
21
|
-
*/
|
|
22
|
-
import {
|
|
23
|
-
BlockSettingsMenuControls,
|
|
24
|
-
useBlockDisplayInformation,
|
|
25
|
-
InspectorControls,
|
|
26
|
-
} from '../components';
|
|
27
|
-
|
|
28
|
-
const emptyString = ( testString ) => testString?.trim()?.length === 0;
|
|
29
|
-
|
|
30
|
-
function RenameModal( { blockName, originalBlockName, onClose, onSave } ) {
|
|
31
|
-
const [ editedBlockName, setEditedBlockName ] = useState( blockName );
|
|
32
|
-
|
|
33
|
-
const nameHasChanged = editedBlockName !== blockName;
|
|
34
|
-
const nameIsOriginal = editedBlockName === originalBlockName;
|
|
35
|
-
const nameIsEmpty = emptyString( editedBlockName );
|
|
36
|
-
|
|
37
|
-
const isNameValid = nameHasChanged || nameIsOriginal;
|
|
38
|
-
|
|
39
|
-
const autoSelectInputText = ( event ) => event.target.select();
|
|
40
|
-
|
|
41
|
-
const dialogDescription = useInstanceId(
|
|
42
|
-
RenameModal,
|
|
43
|
-
`block-editor-rename-modal__description`
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
const handleSubmit = () => {
|
|
47
|
-
const message =
|
|
48
|
-
nameIsOriginal || nameIsEmpty
|
|
49
|
-
? sprintf(
|
|
50
|
-
/* translators: %s: new name/label for the block */
|
|
51
|
-
__( 'Block name reset to: "%s".' ),
|
|
52
|
-
editedBlockName
|
|
53
|
-
)
|
|
54
|
-
: sprintf(
|
|
55
|
-
/* translators: %s: new name/label for the block */
|
|
56
|
-
__( 'Block name changed to: "%s".' ),
|
|
57
|
-
editedBlockName
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
// Must be assertive to immediately announce change.
|
|
61
|
-
speak( message, 'assertive' );
|
|
62
|
-
onSave( editedBlockName );
|
|
63
|
-
|
|
64
|
-
// Immediate close avoids ability to hit save multiple times.
|
|
65
|
-
onClose();
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<Modal
|
|
70
|
-
title={ __( 'Rename' ) }
|
|
71
|
-
onRequestClose={ onClose }
|
|
72
|
-
overlayClassName="block-editor-block-rename-modal"
|
|
73
|
-
aria={ {
|
|
74
|
-
describedby: dialogDescription,
|
|
75
|
-
} }
|
|
76
|
-
focusOnMount="firstContentElement"
|
|
77
|
-
>
|
|
78
|
-
<p id={ dialogDescription }>
|
|
79
|
-
{ __( 'Enter a custom name for this block.' ) }
|
|
80
|
-
</p>
|
|
81
|
-
<form
|
|
82
|
-
onSubmit={ ( e ) => {
|
|
83
|
-
e.preventDefault();
|
|
84
|
-
|
|
85
|
-
if ( ! isNameValid ) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
handleSubmit();
|
|
90
|
-
} }
|
|
91
|
-
>
|
|
92
|
-
<VStack spacing="3">
|
|
93
|
-
<TextControl
|
|
94
|
-
__nextHasNoMarginBottom
|
|
95
|
-
__next40pxDefaultSize
|
|
96
|
-
value={ editedBlockName }
|
|
97
|
-
label={ __( 'Block name' ) }
|
|
98
|
-
hideLabelFromVision={ true }
|
|
99
|
-
placeholder={ originalBlockName }
|
|
100
|
-
onChange={ setEditedBlockName }
|
|
101
|
-
onFocus={ autoSelectInputText }
|
|
102
|
-
/>
|
|
103
|
-
<HStack justify="right">
|
|
104
|
-
<Button variant="tertiary" onClick={ onClose }>
|
|
105
|
-
{ __( 'Cancel' ) }
|
|
106
|
-
</Button>
|
|
107
|
-
|
|
108
|
-
<Button
|
|
109
|
-
aria-disabled={ ! isNameValid }
|
|
110
|
-
variant="primary"
|
|
111
|
-
type="submit"
|
|
112
|
-
>
|
|
113
|
-
{ __( 'Save' ) }
|
|
114
|
-
</Button>
|
|
115
|
-
</HStack>
|
|
116
|
-
</VStack>
|
|
117
|
-
</form>
|
|
118
|
-
</Modal>
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function BlockRenameControl( props ) {
|
|
123
|
-
const [ renamingBlock, setRenamingBlock ] = useState( false );
|
|
124
|
-
|
|
125
|
-
const { clientId, customName, onChange } = props;
|
|
126
|
-
|
|
127
|
-
const blockInformation = useBlockDisplayInformation( clientId );
|
|
128
|
-
|
|
129
|
-
return (
|
|
130
|
-
<>
|
|
131
|
-
<InspectorControls group="advanced">
|
|
132
|
-
<TextControl
|
|
133
|
-
__nextHasNoMarginBottom
|
|
134
|
-
__next40pxDefaultSize
|
|
135
|
-
label={ __( 'Block name' ) }
|
|
136
|
-
value={ customName || '' }
|
|
137
|
-
onChange={ onChange }
|
|
138
|
-
/>
|
|
139
|
-
</InspectorControls>
|
|
140
|
-
<BlockSettingsMenuControls>
|
|
141
|
-
{ ( { selectedClientIds } ) => {
|
|
142
|
-
// Only enabled for single selections.
|
|
143
|
-
const canRename =
|
|
144
|
-
selectedClientIds.length === 1 &&
|
|
145
|
-
clientId === selectedClientIds[ 0 ];
|
|
146
|
-
|
|
147
|
-
// This check ensures the `BlockSettingsMenuControls` fill
|
|
148
|
-
// doesn't render multiple times and also that it renders for
|
|
149
|
-
// the block from which the menu was triggered.
|
|
150
|
-
if ( ! canRename ) {
|
|
151
|
-
return null;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return (
|
|
155
|
-
<MenuItem
|
|
156
|
-
onClick={ () => {
|
|
157
|
-
setRenamingBlock( true );
|
|
158
|
-
} }
|
|
159
|
-
aria-expanded={ renamingBlock }
|
|
160
|
-
aria-haspopup="dialog"
|
|
161
|
-
>
|
|
162
|
-
{ __( 'Rename' ) }
|
|
163
|
-
</MenuItem>
|
|
164
|
-
);
|
|
165
|
-
} }
|
|
166
|
-
</BlockSettingsMenuControls>
|
|
167
|
-
|
|
168
|
-
{ renamingBlock && (
|
|
169
|
-
<RenameModal
|
|
170
|
-
blockName={ customName || '' }
|
|
171
|
-
originalBlockName={ blockInformation?.title }
|
|
172
|
-
onClose={ () => setRenamingBlock( false ) }
|
|
173
|
-
onSave={ ( newName ) => {
|
|
174
|
-
// If the new value is the block's original name (e.g. `Group`)
|
|
175
|
-
// or it is an empty string then assume the intent is to reset
|
|
176
|
-
// the value. Therefore reset the metadata.
|
|
177
|
-
if (
|
|
178
|
-
newName === blockInformation?.title ||
|
|
179
|
-
emptyString( newName )
|
|
180
|
-
) {
|
|
181
|
-
newName = undefined;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
onChange( newName );
|
|
185
|
-
} }
|
|
186
|
-
/>
|
|
187
|
-
) }
|
|
188
|
-
</>
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
export const withBlockRenameControls = createHigherOrderComponent(
|
|
193
|
-
( BlockEdit ) => ( props ) => {
|
|
194
|
-
const { clientId, name, attributes, setAttributes, isSelected } = props;
|
|
195
|
-
|
|
196
|
-
const supportsBlockNaming = hasBlockSupport( name, 'renaming', true );
|
|
197
|
-
|
|
198
|
-
return (
|
|
199
|
-
<>
|
|
200
|
-
{ isSelected && supportsBlockNaming && (
|
|
201
|
-
<>
|
|
202
|
-
<BlockRenameControl
|
|
203
|
-
clientId={ clientId }
|
|
204
|
-
customName={ attributes?.metadata?.name }
|
|
205
|
-
onChange={ ( newName ) => {
|
|
206
|
-
setAttributes( {
|
|
207
|
-
metadata: {
|
|
208
|
-
...attributes?.metadata,
|
|
209
|
-
name: newName,
|
|
210
|
-
},
|
|
211
|
-
} );
|
|
212
|
-
} }
|
|
213
|
-
/>
|
|
214
|
-
</>
|
|
215
|
-
) }
|
|
216
|
-
|
|
217
|
-
<BlockEdit key="edit" { ...props } />
|
|
218
|
-
</>
|
|
219
|
-
);
|
|
220
|
-
},
|
|
221
|
-
'withBlockRenameControls'
|
|
222
|
-
);
|
|
223
|
-
|
|
224
|
-
addFilter(
|
|
225
|
-
'editor.BlockEdit',
|
|
226
|
-
'core/block-rename-ui/with-block-rename-controls',
|
|
227
|
-
withBlockRenameControls
|
|
228
|
-
);
|
|
File without changes
|