@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
|
@@ -6,13 +6,11 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { useState, forwardRef } from '@wordpress/element';
|
|
9
|
+
import { useEffect, useState, forwardRef } from '@wordpress/element';
|
|
10
10
|
import {
|
|
11
11
|
VisuallyHidden,
|
|
12
|
-
__unstableComposite as Composite,
|
|
13
|
-
__unstableUseCompositeState as useCompositeState,
|
|
14
|
-
__unstableCompositeItem as CompositeItem,
|
|
15
12
|
Tooltip,
|
|
13
|
+
privateApis as componentsPrivateApis,
|
|
16
14
|
__experimentalHStack as HStack,
|
|
17
15
|
} from '@wordpress/components';
|
|
18
16
|
import { useInstanceId } from '@wordpress/compose';
|
|
@@ -22,9 +20,17 @@ import { Icon, symbol } from '@wordpress/icons';
|
|
|
22
20
|
/**
|
|
23
21
|
* Internal dependencies
|
|
24
22
|
*/
|
|
23
|
+
import { unlock } from '../../lock-unlock';
|
|
25
24
|
import BlockPreview from '../block-preview';
|
|
26
25
|
import InserterDraggableBlocks from '../inserter-draggable-blocks';
|
|
27
26
|
import BlockPatternsPaging from '../block-patterns-paging';
|
|
27
|
+
import { PATTERN_TYPES } from '../inserter/block-patterns-tab/utils';
|
|
28
|
+
|
|
29
|
+
const {
|
|
30
|
+
CompositeV2: Composite,
|
|
31
|
+
CompositeItemV2: CompositeItem,
|
|
32
|
+
useCompositeStoreV2: useCompositeStore,
|
|
33
|
+
} = unlock( componentsPrivateApis );
|
|
28
34
|
|
|
29
35
|
const WithToolTip = ( { showTooltip, title, children } ) => {
|
|
30
36
|
if ( showTooltip ) {
|
|
@@ -34,11 +40,11 @@ const WithToolTip = ( { showTooltip, title, children } ) => {
|
|
|
34
40
|
};
|
|
35
41
|
|
|
36
42
|
function BlockPattern( {
|
|
43
|
+
id,
|
|
37
44
|
isDraggable,
|
|
38
45
|
pattern,
|
|
39
46
|
onClick,
|
|
40
47
|
onHover,
|
|
41
|
-
composite,
|
|
42
48
|
showTooltip,
|
|
43
49
|
} ) {
|
|
44
50
|
const [ isDragging, setIsDragging ] = useState( false );
|
|
@@ -71,20 +77,33 @@ function BlockPattern( {
|
|
|
71
77
|
} }
|
|
72
78
|
>
|
|
73
79
|
<WithToolTip
|
|
74
|
-
showTooltip={
|
|
80
|
+
showTooltip={
|
|
81
|
+
showTooltip && ! pattern.type !== PATTERN_TYPES.user
|
|
82
|
+
}
|
|
75
83
|
title={ pattern.title }
|
|
76
84
|
>
|
|
77
85
|
<CompositeItem
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
render={
|
|
87
|
+
<div
|
|
88
|
+
role="option"
|
|
89
|
+
aria-label={ pattern.title }
|
|
90
|
+
aria-describedby={
|
|
91
|
+
pattern.description
|
|
92
|
+
? descriptionId
|
|
93
|
+
: undefined
|
|
94
|
+
}
|
|
95
|
+
className={ classnames(
|
|
96
|
+
'block-editor-block-patterns-list__item',
|
|
97
|
+
{
|
|
98
|
+
'block-editor-block-patterns-list__list-item-synced':
|
|
99
|
+
pattern.type ===
|
|
100
|
+
PATTERN_TYPES.user &&
|
|
101
|
+
! pattern.syncStatus,
|
|
102
|
+
}
|
|
103
|
+
) }
|
|
104
|
+
/>
|
|
105
|
+
}
|
|
106
|
+
id={ id }
|
|
88
107
|
onClick={ () => {
|
|
89
108
|
onClick( pattern, blocks );
|
|
90
109
|
onHover?.( null );
|
|
@@ -96,10 +115,6 @@ function BlockPattern( {
|
|
|
96
115
|
onHover?.( pattern );
|
|
97
116
|
} }
|
|
98
117
|
onMouseLeave={ () => onHover?.( null ) }
|
|
99
|
-
aria-label={ pattern.title }
|
|
100
|
-
aria-describedby={
|
|
101
|
-
pattern.description ? descriptionId : undefined
|
|
102
|
-
}
|
|
103
118
|
>
|
|
104
119
|
<BlockPreview
|
|
105
120
|
blocks={ blocks }
|
|
@@ -107,15 +122,17 @@ function BlockPattern( {
|
|
|
107
122
|
/>
|
|
108
123
|
|
|
109
124
|
<HStack className="block-editor-patterns__pattern-details">
|
|
110
|
-
{ pattern.
|
|
111
|
-
|
|
112
|
-
<
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
125
|
+
{ pattern.type === PATTERN_TYPES.user &&
|
|
126
|
+
! pattern.syncStatus && (
|
|
127
|
+
<div className="block-editor-patterns__pattern-icon-wrapper">
|
|
128
|
+
<Icon
|
|
129
|
+
className="block-editor-patterns__pattern-icon"
|
|
130
|
+
icon={ symbol }
|
|
131
|
+
/>
|
|
132
|
+
</div>
|
|
133
|
+
) }
|
|
134
|
+
{ ( ! showTooltip ||
|
|
135
|
+
pattern.type === PATTERN_TYPES.user ) && (
|
|
119
136
|
<div className="block-editor-block-patterns-list__item-title">
|
|
120
137
|
{ pattern.title }
|
|
121
138
|
</div>
|
|
@@ -141,7 +158,7 @@ function BlockPatternPlaceholder() {
|
|
|
141
158
|
);
|
|
142
159
|
}
|
|
143
160
|
|
|
144
|
-
function
|
|
161
|
+
function BlockPatternsList(
|
|
145
162
|
{
|
|
146
163
|
isDraggable,
|
|
147
164
|
blockPatterns,
|
|
@@ -155,10 +172,19 @@ function BlockPatternList(
|
|
|
155
172
|
},
|
|
156
173
|
ref
|
|
157
174
|
) {
|
|
158
|
-
const
|
|
175
|
+
const compositeStore = useCompositeStore( { orientation } );
|
|
176
|
+
const { setActiveId } = compositeStore;
|
|
177
|
+
|
|
178
|
+
useEffect( () => {
|
|
179
|
+
// We reset the active composite item whenever the
|
|
180
|
+
// available patterns change, to make sure that
|
|
181
|
+
// focus is put back to the start.
|
|
182
|
+
setActiveId( undefined );
|
|
183
|
+
}, [ setActiveId, shownPatterns, blockPatterns ] );
|
|
184
|
+
|
|
159
185
|
return (
|
|
160
186
|
<Composite
|
|
161
|
-
{
|
|
187
|
+
store={ compositeStore }
|
|
162
188
|
role="listbox"
|
|
163
189
|
className="block-editor-block-patterns-list"
|
|
164
190
|
aria-label={ label }
|
|
@@ -169,11 +195,11 @@ function BlockPatternList(
|
|
|
169
195
|
return isShown ? (
|
|
170
196
|
<BlockPattern
|
|
171
197
|
key={ pattern.name }
|
|
198
|
+
id={ pattern.name }
|
|
172
199
|
pattern={ pattern }
|
|
173
200
|
onClick={ onClickPattern }
|
|
174
201
|
onHover={ onHover }
|
|
175
202
|
isDraggable={ isDraggable }
|
|
176
|
-
composite={ composite }
|
|
177
203
|
showTooltip={ showTitlesAsTooltip }
|
|
178
204
|
/>
|
|
179
205
|
) : (
|
|
@@ -185,4 +211,4 @@ function BlockPatternList(
|
|
|
185
211
|
);
|
|
186
212
|
}
|
|
187
213
|
|
|
188
|
-
export default forwardRef(
|
|
214
|
+
export default forwardRef( BlockPatternsList );
|
|
@@ -18,6 +18,13 @@
|
|
|
18
18
|
|
|
19
19
|
.block-editor-block-patterns-list__item {
|
|
20
20
|
height: 100%;
|
|
21
|
+
// This is derived from the top padding set on
|
|
22
|
+
// `.block-editor-block-patterns-explorer__list`
|
|
23
|
+
scroll-margin-top: $grid-unit-30;
|
|
24
|
+
// This is derived from the bottom padding set on
|
|
25
|
+
// `.block-editor-block-patterns-explorer__list` and
|
|
26
|
+
// the bottom margin set on `...__list-item` above
|
|
27
|
+
scroll-margin-bottom: ($grid-unit-40 + $grid-unit-30);
|
|
21
28
|
|
|
22
29
|
.block-editor-block-preview__container {
|
|
23
30
|
display: flex;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
__experimentalHStack as HStack,
|
|
6
|
+
__experimentalVStack as VStack,
|
|
7
|
+
Button,
|
|
8
|
+
TextControl,
|
|
9
|
+
Modal,
|
|
10
|
+
} from '@wordpress/components';
|
|
11
|
+
import { useInstanceId } from '@wordpress/compose';
|
|
12
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
13
|
+
import { useState } from '@wordpress/element';
|
|
14
|
+
import { speak } from '@wordpress/a11y';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Internal dependencies
|
|
18
|
+
*/
|
|
19
|
+
import isEmptyString from './is-empty-string';
|
|
20
|
+
|
|
21
|
+
export default function BlockRenameModal( {
|
|
22
|
+
blockName,
|
|
23
|
+
originalBlockName,
|
|
24
|
+
onClose,
|
|
25
|
+
onSave,
|
|
26
|
+
} ) {
|
|
27
|
+
const [ editedBlockName, setEditedBlockName ] = useState( blockName );
|
|
28
|
+
|
|
29
|
+
const nameHasChanged = editedBlockName !== blockName;
|
|
30
|
+
const nameIsOriginal = editedBlockName === originalBlockName;
|
|
31
|
+
const nameIsEmpty = isEmptyString( editedBlockName );
|
|
32
|
+
|
|
33
|
+
const isNameValid = nameHasChanged || nameIsOriginal;
|
|
34
|
+
|
|
35
|
+
const autoSelectInputText = ( event ) => event.target.select();
|
|
36
|
+
|
|
37
|
+
const dialogDescription = useInstanceId(
|
|
38
|
+
BlockRenameModal,
|
|
39
|
+
`block-editor-rename-modal__description`
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const handleSubmit = () => {
|
|
43
|
+
const message =
|
|
44
|
+
nameIsOriginal || nameIsEmpty
|
|
45
|
+
? sprintf(
|
|
46
|
+
/* translators: %s: new name/label for the block */
|
|
47
|
+
__( 'Block name reset to: "%s".' ),
|
|
48
|
+
editedBlockName
|
|
49
|
+
)
|
|
50
|
+
: sprintf(
|
|
51
|
+
/* translators: %s: new name/label for the block */
|
|
52
|
+
__( 'Block name changed to: "%s".' ),
|
|
53
|
+
editedBlockName
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
// Must be assertive to immediately announce change.
|
|
57
|
+
speak( message, 'assertive' );
|
|
58
|
+
onSave( editedBlockName );
|
|
59
|
+
|
|
60
|
+
// Immediate close avoids ability to hit save multiple times.
|
|
61
|
+
onClose();
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<Modal
|
|
66
|
+
title={ __( 'Rename' ) }
|
|
67
|
+
onRequestClose={ onClose }
|
|
68
|
+
overlayClassName="block-editor-block-rename-modal"
|
|
69
|
+
aria={ {
|
|
70
|
+
describedby: dialogDescription,
|
|
71
|
+
} }
|
|
72
|
+
focusOnMount="firstContentElement"
|
|
73
|
+
>
|
|
74
|
+
<p id={ dialogDescription }>
|
|
75
|
+
{ __( 'Enter a custom name for this block.' ) }
|
|
76
|
+
</p>
|
|
77
|
+
<form
|
|
78
|
+
onSubmit={ ( e ) => {
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
|
|
81
|
+
if ( ! isNameValid ) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
handleSubmit();
|
|
86
|
+
} }
|
|
87
|
+
>
|
|
88
|
+
<VStack spacing="3">
|
|
89
|
+
<TextControl
|
|
90
|
+
__nextHasNoMarginBottom
|
|
91
|
+
value={ editedBlockName }
|
|
92
|
+
label={ __( 'Block name' ) }
|
|
93
|
+
hideLabelFromVision={ true }
|
|
94
|
+
placeholder={ originalBlockName }
|
|
95
|
+
onChange={ setEditedBlockName }
|
|
96
|
+
onFocus={ autoSelectInputText }
|
|
97
|
+
/>
|
|
98
|
+
<HStack justify="right">
|
|
99
|
+
<Button variant="tertiary" onClick={ onClose }>
|
|
100
|
+
{ __( 'Cancel' ) }
|
|
101
|
+
</Button>
|
|
102
|
+
|
|
103
|
+
<Button
|
|
104
|
+
aria-disabled={ ! isNameValid }
|
|
105
|
+
variant="primary"
|
|
106
|
+
type="submit"
|
|
107
|
+
>
|
|
108
|
+
{ __( 'Save' ) }
|
|
109
|
+
</Button>
|
|
110
|
+
</HStack>
|
|
111
|
+
</VStack>
|
|
112
|
+
</form>
|
|
113
|
+
</Modal>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { MenuItem } from '@wordpress/components';
|
|
5
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
import { useState } from '@wordpress/element';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { store as blockEditorStore } from '../../store';
|
|
13
|
+
import { useBlockDisplayInformation } from '..';
|
|
14
|
+
import isEmptyString from './is-empty-string';
|
|
15
|
+
import BlockRenameModal from './modal';
|
|
16
|
+
|
|
17
|
+
export default function BlockRenameControl( { clientId } ) {
|
|
18
|
+
const [ renamingBlock, setRenamingBlock ] = useState( false );
|
|
19
|
+
|
|
20
|
+
const { metadata } = useSelect(
|
|
21
|
+
( select ) => {
|
|
22
|
+
const { getBlockAttributes } = select( blockEditorStore );
|
|
23
|
+
|
|
24
|
+
const _metadata = getBlockAttributes( clientId )?.metadata;
|
|
25
|
+
return {
|
|
26
|
+
metadata: _metadata,
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
[ clientId ]
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const { updateBlockAttributes } = useDispatch( blockEditorStore );
|
|
33
|
+
|
|
34
|
+
const customName = metadata?.name;
|
|
35
|
+
|
|
36
|
+
function onChange( newName ) {
|
|
37
|
+
updateBlockAttributes( [ clientId ], {
|
|
38
|
+
metadata: {
|
|
39
|
+
...( metadata && metadata ),
|
|
40
|
+
name: newName,
|
|
41
|
+
},
|
|
42
|
+
} );
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const blockInformation = useBlockDisplayInformation( clientId );
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<>
|
|
49
|
+
<MenuItem
|
|
50
|
+
onClick={ () => {
|
|
51
|
+
setRenamingBlock( true );
|
|
52
|
+
} }
|
|
53
|
+
aria-expanded={ renamingBlock }
|
|
54
|
+
aria-haspopup="dialog"
|
|
55
|
+
>
|
|
56
|
+
{ __( 'Rename' ) }
|
|
57
|
+
</MenuItem>
|
|
58
|
+
{ renamingBlock && (
|
|
59
|
+
<BlockRenameModal
|
|
60
|
+
blockName={ customName || '' }
|
|
61
|
+
originalBlockName={ blockInformation?.title }
|
|
62
|
+
onClose={ () => setRenamingBlock( false ) }
|
|
63
|
+
onSave={ ( newName ) => {
|
|
64
|
+
// If the new value is the block's original name (e.g. `Group`)
|
|
65
|
+
// or it is an empty string then assume the intent is to reset
|
|
66
|
+
// the value. Therefore reset the metadata.
|
|
67
|
+
if (
|
|
68
|
+
newName === blockInformation?.title ||
|
|
69
|
+
isEmptyString( newName )
|
|
70
|
+
) {
|
|
71
|
+
newName = undefined;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
onChange( newName );
|
|
75
|
+
} }
|
|
76
|
+
/>
|
|
77
|
+
) }
|
|
78
|
+
</>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
store as keyboardShortcutsStore,
|
|
21
21
|
__unstableUseShortcutEventMatch,
|
|
22
22
|
} from '@wordpress/keyboard-shortcuts';
|
|
23
|
-
import { pipe, useCopyToClipboard } from '@wordpress/compose';
|
|
23
|
+
import { pipe, useCopyToClipboard, useViewportMatch } from '@wordpress/compose';
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Internal dependencies
|
|
@@ -47,6 +47,38 @@ function CopyMenuItem( { blocks, onCopy, label } ) {
|
|
|
47
47
|
return <MenuItem ref={ ref }>{ copyMenuItemLabel }</MenuItem>;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
function ParentSelectorMenuItem( { parentClientId, parentBlockType } ) {
|
|
51
|
+
const isSmallViewport = useViewportMatch( 'medium', '<' );
|
|
52
|
+
const { selectBlock } = useDispatch( blockEditorStore );
|
|
53
|
+
|
|
54
|
+
// Allows highlighting the parent block outline when focusing or hovering
|
|
55
|
+
// the parent block selector within the child.
|
|
56
|
+
const menuItemRef = useRef();
|
|
57
|
+
const gesturesProps = useShowHoveredOrFocusedGestures( {
|
|
58
|
+
ref: menuItemRef,
|
|
59
|
+
highlightParent: true,
|
|
60
|
+
} );
|
|
61
|
+
|
|
62
|
+
if ( ! isSmallViewport ) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<MenuItem
|
|
68
|
+
{ ...gesturesProps }
|
|
69
|
+
ref={ menuItemRef }
|
|
70
|
+
icon={ <BlockIcon icon={ parentBlockType.icon } /> }
|
|
71
|
+
onClick={ () => selectBlock( parentClientId ) }
|
|
72
|
+
>
|
|
73
|
+
{ sprintf(
|
|
74
|
+
/* translators: %s: Name of the block's parent. */
|
|
75
|
+
__( 'Select parent block (%s)' ),
|
|
76
|
+
parentBlockType.title
|
|
77
|
+
) }
|
|
78
|
+
</MenuItem>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
50
82
|
export function BlockSettingsDropdown( {
|
|
51
83
|
block,
|
|
52
84
|
clientIds,
|
|
@@ -132,8 +164,6 @@ export function BlockSettingsDropdown( {
|
|
|
132
164
|
};
|
|
133
165
|
}, [] );
|
|
134
166
|
const isMatch = __unstableUseShortcutEventMatch();
|
|
135
|
-
|
|
136
|
-
const { selectBlock } = useDispatch( blockEditorStore );
|
|
137
167
|
const hasSelectedBlocks = selectedBlockClientIds.length > 0;
|
|
138
168
|
|
|
139
169
|
const updateSelectionAfterDuplicate = useCallback(
|
|
@@ -175,14 +205,6 @@ export function BlockSettingsDropdown( {
|
|
|
175
205
|
const removeBlockLabel =
|
|
176
206
|
count === 1 ? __( 'Delete' ) : __( 'Delete blocks' );
|
|
177
207
|
|
|
178
|
-
// Allows highlighting the parent block outline when focusing or hovering
|
|
179
|
-
// the parent block selector within the child.
|
|
180
|
-
const selectParentButtonRef = useRef();
|
|
181
|
-
const showParentOutlineGestures = useShowHoveredOrFocusedGestures( {
|
|
182
|
-
ref: selectParentButtonRef,
|
|
183
|
-
highlightParent: true,
|
|
184
|
-
} );
|
|
185
|
-
|
|
186
208
|
// This can occur when the selected block (the parent)
|
|
187
209
|
// displays child blocks within a List View.
|
|
188
210
|
const parentBlockIsSelected =
|
|
@@ -297,30 +319,12 @@ export function BlockSettingsDropdown( {
|
|
|
297
319
|
/>
|
|
298
320
|
{ ! parentBlockIsSelected &&
|
|
299
321
|
!! firstParentClientId && (
|
|
300
|
-
<
|
|
301
|
-
{
|
|
302
|
-
|
|
303
|
-
icon={
|
|
304
|
-
<BlockIcon
|
|
305
|
-
icon={
|
|
306
|
-
parentBlockType.icon
|
|
307
|
-
}
|
|
308
|
-
/>
|
|
309
|
-
}
|
|
310
|
-
onClick={ () =>
|
|
311
|
-
selectBlock(
|
|
312
|
-
firstParentClientId
|
|
313
|
-
)
|
|
322
|
+
<ParentSelectorMenuItem
|
|
323
|
+
parentClientId={
|
|
324
|
+
firstParentClientId
|
|
314
325
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
/* translators: %s: Name of the block's parent. */
|
|
318
|
-
__(
|
|
319
|
-
'Select parent block (%s)'
|
|
320
|
-
),
|
|
321
|
-
parentBlockType.title
|
|
322
|
-
) }
|
|
323
|
-
</MenuItem>
|
|
326
|
+
parentBlockType={ parentBlockType }
|
|
327
|
+
/>
|
|
324
328
|
) }
|
|
325
329
|
{ count === 1 && (
|
|
326
330
|
<BlockHTMLConvertButton
|
|
@@ -22,6 +22,8 @@ import { BlockLockMenuItem, useBlockLock } from '../block-lock';
|
|
|
22
22
|
import { store as blockEditorStore } from '../../store';
|
|
23
23
|
import BlockModeToggle from '../block-settings-menu/block-mode-toggle';
|
|
24
24
|
|
|
25
|
+
import { BlockRenameControl, useBlockRename } from '../block-rename';
|
|
26
|
+
|
|
25
27
|
const { Fill, Slot } = createSlotFill( 'BlockSettingsMenuControls' );
|
|
26
28
|
|
|
27
29
|
const BlockSettingsMenuControlsSlot = ( {
|
|
@@ -44,7 +46,9 @@ const BlockSettingsMenuControlsSlot = ( {
|
|
|
44
46
|
);
|
|
45
47
|
|
|
46
48
|
const { canLock } = useBlockLock( selectedClientIds[ 0 ] );
|
|
49
|
+
const { canRename } = useBlockRename( selectedBlocks[ 0 ] );
|
|
47
50
|
const showLockButton = selectedClientIds.length === 1 && canLock;
|
|
51
|
+
const showRenameButton = selectedClientIds.length === 1 && canRename;
|
|
48
52
|
|
|
49
53
|
// Check if current selection of blocks is Groupable or Ungroupable
|
|
50
54
|
// and pass this props down to ConvertToGroupButton.
|
|
@@ -84,6 +88,11 @@ const BlockSettingsMenuControlsSlot = ( {
|
|
|
84
88
|
clientId={ selectedClientIds[ 0 ] }
|
|
85
89
|
/>
|
|
86
90
|
) }
|
|
91
|
+
{ showRenameButton && (
|
|
92
|
+
<BlockRenameControl
|
|
93
|
+
clientId={ selectedClientIds[ 0 ] }
|
|
94
|
+
/>
|
|
95
|
+
) }
|
|
87
96
|
{ fills }
|
|
88
97
|
{ fillProps?.canMove && ! fillProps?.onlyBlock && (
|
|
89
98
|
<MenuItem
|
|
@@ -212,10 +212,7 @@ const BlockActionsMenu = ( {
|
|
|
212
212
|
},
|
|
213
213
|
convertToRegularBlocks: {
|
|
214
214
|
id: 'convertToRegularBlocksOption',
|
|
215
|
-
label:
|
|
216
|
-
innerBlockCount > 1
|
|
217
|
-
? __( 'Detach patterns' )
|
|
218
|
-
: __( 'Detach pattern' ),
|
|
215
|
+
label: __( 'Detach' ),
|
|
219
216
|
value: 'convertToRegularBlocksOption',
|
|
220
217
|
onSelect: () => {
|
|
221
218
|
/* translators: %s: name of the synced block */
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { getBlockMenuDefaultClassName } from '@wordpress/blocks';
|
|
5
|
+
import { useInstanceId } from '@wordpress/compose';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
@@ -25,11 +26,10 @@ function BlockTypesList( {
|
|
|
25
26
|
label,
|
|
26
27
|
isDraggable = true,
|
|
27
28
|
} ) {
|
|
29
|
+
const className = 'block-editor-block-types-list';
|
|
30
|
+
const listId = useInstanceId( BlockTypesList, className );
|
|
28
31
|
return (
|
|
29
|
-
<InserterListboxGroup
|
|
30
|
-
className="block-editor-block-types-list"
|
|
31
|
-
aria-label={ label }
|
|
32
|
-
>
|
|
32
|
+
<InserterListboxGroup className={ className } aria-label={ label }>
|
|
33
33
|
{ chunk( items, 3 ).map( ( row, i ) => (
|
|
34
34
|
<InserterListboxRow key={ i }>
|
|
35
35
|
{ row.map( ( item, j ) => (
|
|
@@ -43,6 +43,7 @@ function BlockTypesList( {
|
|
|
43
43
|
onHover={ onHover }
|
|
44
44
|
isDraggable={ isDraggable && ! item.isDisabled }
|
|
45
45
|
isFirst={ i === 0 && j === 0 }
|
|
46
|
+
rowId={ `${ listId }-${ i }` }
|
|
46
47
|
/>
|
|
47
48
|
) ) }
|
|
48
49
|
</InserterListboxRow>
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
.is-layout-constrained.block-editor-block-list__block:not(.is-selected) > &,
|
|
40
40
|
.is-layout-flow.block-editor-block-list__block:not(.is-selected) > &,
|
|
41
41
|
// Legacy groups have an inner container so need to be targeted separately
|
|
42
|
-
.
|
|
43
|
-
.
|
|
42
|
+
.block-editor-block-list__block:not(.is-selected) > .is-layout-constrained.wp-block-group__inner-container > &,
|
|
43
|
+
.block-editor-block-list__block:not(.is-selected) > .is-layout-flow.wp-block-group__inner-container > & {
|
|
44
44
|
pointer-events: none;
|
|
45
45
|
|
|
46
46
|
&::after {
|
|
@@ -78,12 +78,19 @@ function NonDefaultControls( { format, onChange } ) {
|
|
|
78
78
|
// formats.
|
|
79
79
|
const suggestedFormats = [
|
|
80
80
|
...new Set( [
|
|
81
|
+
/* translators: See https://www.php.net/manual/datetime.format.php */
|
|
81
82
|
'Y-m-d',
|
|
83
|
+
/* translators: See https://www.php.net/manual/datetime.format.php */
|
|
82
84
|
_x( 'n/j/Y', 'short date format' ),
|
|
85
|
+
/* translators: See https://www.php.net/manual/datetime.format.php */
|
|
83
86
|
_x( 'n/j/Y g:i A', 'short date format with time' ),
|
|
87
|
+
/* translators: See https://www.php.net/manual/datetime.format.php */
|
|
84
88
|
_x( 'M j, Y', 'medium date format' ),
|
|
89
|
+
/* translators: See https://www.php.net/manual/datetime.format.php */
|
|
85
90
|
_x( 'M j, Y g:i A', 'medium date format with time' ),
|
|
91
|
+
/* translators: See https://www.php.net/manual/datetime.format.php */
|
|
86
92
|
_x( 'F j, Y', 'long date format' ),
|
|
93
|
+
/* translators: See https://www.php.net/manual/datetime.format.php */
|
|
87
94
|
_x( 'M j', 'short date format without the year' ),
|
|
88
95
|
] ),
|
|
89
96
|
];
|
|
@@ -47,40 +47,6 @@ _Optional._ Called when the block can be removed. `forward` is true when the sel
|
|
|
47
47
|
|
|
48
48
|
## Example
|
|
49
49
|
|
|
50
|
-
{% codetabs %}
|
|
51
|
-
{% ES5 %}
|
|
52
|
-
|
|
53
|
-
```js
|
|
54
|
-
wp.blocks.registerBlockType( /* ... */, {
|
|
55
|
-
// ...
|
|
56
|
-
|
|
57
|
-
attributes: {
|
|
58
|
-
content: {
|
|
59
|
-
source: 'html',
|
|
60
|
-
selector: 'div',
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
edit: function( props ) {
|
|
65
|
-
return React.createElement( wp.editor.EditableText, {
|
|
66
|
-
className: props.className,
|
|
67
|
-
value: props.attributes.content,
|
|
68
|
-
onChange: function( content ) {
|
|
69
|
-
props.setAttributes( { content: content } );
|
|
70
|
-
}
|
|
71
|
-
} );
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
save: function( props ) {
|
|
75
|
-
return React.createElement( wp.editor.EditableText.Content, {
|
|
76
|
-
value: props.attributes.content
|
|
77
|
-
} );
|
|
78
|
-
}
|
|
79
|
-
} );
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
{% ESNext %}
|
|
83
|
-
|
|
84
50
|
```js
|
|
85
51
|
const { registerBlockType } = wp.blocks;
|
|
86
52
|
const { EditableText } = wp.editor;
|
|
@@ -110,5 +76,3 @@ registerBlockType( /* ... */, {
|
|
|
110
76
|
}
|
|
111
77
|
} );
|
|
112
78
|
```
|
|
113
|
-
|
|
114
|
-
{% end %}
|