@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
|
@@ -12,9 +12,11 @@ var _components = require("@wordpress/components");
|
|
|
12
12
|
var _compose = require("@wordpress/compose");
|
|
13
13
|
var _i18n = require("@wordpress/i18n");
|
|
14
14
|
var _icons = require("@wordpress/icons");
|
|
15
|
+
var _lockUnlock = require("../../lock-unlock");
|
|
15
16
|
var _blockPreview = _interopRequireDefault(require("../block-preview"));
|
|
16
17
|
var _inserterDraggableBlocks = _interopRequireDefault(require("../inserter-draggable-blocks"));
|
|
17
18
|
var _blockPatternsPaging = _interopRequireDefault(require("../block-patterns-paging"));
|
|
19
|
+
var _utils = require("../inserter/block-patterns-tab/utils");
|
|
18
20
|
/**
|
|
19
21
|
* External dependencies
|
|
20
22
|
*/
|
|
@@ -27,6 +29,11 @@ var _blockPatternsPaging = _interopRequireDefault(require("../block-patterns-pag
|
|
|
27
29
|
* Internal dependencies
|
|
28
30
|
*/
|
|
29
31
|
|
|
32
|
+
const {
|
|
33
|
+
CompositeV2: Composite,
|
|
34
|
+
CompositeItemV2: CompositeItem,
|
|
35
|
+
useCompositeStoreV2: useCompositeStore
|
|
36
|
+
} = (0, _lockUnlock.unlock)(_components.privateApis);
|
|
30
37
|
const WithToolTip = ({
|
|
31
38
|
showTooltip,
|
|
32
39
|
title,
|
|
@@ -40,11 +47,11 @@ const WithToolTip = ({
|
|
|
40
47
|
return (0, _react.createElement)(_react.Fragment, null, children);
|
|
41
48
|
};
|
|
42
49
|
function BlockPattern({
|
|
50
|
+
id,
|
|
43
51
|
isDraggable,
|
|
44
52
|
pattern,
|
|
45
53
|
onClick,
|
|
46
54
|
onHover,
|
|
47
|
-
composite,
|
|
48
55
|
showTooltip
|
|
49
56
|
}) {
|
|
50
57
|
const [isDragging, setIsDragging] = (0, _element.useState)(false);
|
|
@@ -79,15 +86,18 @@ function BlockPattern({
|
|
|
79
86
|
}
|
|
80
87
|
}
|
|
81
88
|
}, (0, _react.createElement)(WithToolTip, {
|
|
82
|
-
showTooltip: showTooltip && !pattern.
|
|
89
|
+
showTooltip: showTooltip && !pattern.type !== _utils.PATTERN_TYPES.user,
|
|
83
90
|
title: pattern.title
|
|
84
|
-
}, (0, _react.createElement)(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
'block-editor-block-patterns-
|
|
91
|
+
}, (0, _react.createElement)(CompositeItem, {
|
|
92
|
+
render: (0, _react.createElement)("div", {
|
|
93
|
+
role: "option",
|
|
94
|
+
"aria-label": pattern.title,
|
|
95
|
+
"aria-describedby": pattern.description ? descriptionId : undefined,
|
|
96
|
+
className: (0, _classnames.default)('block-editor-block-patterns-list__item', {
|
|
97
|
+
'block-editor-block-patterns-list__list-item-synced': pattern.type === _utils.PATTERN_TYPES.user && !pattern.syncStatus
|
|
98
|
+
})
|
|
90
99
|
}),
|
|
100
|
+
id: id,
|
|
91
101
|
onClick: () => {
|
|
92
102
|
onClick(pattern, blocks);
|
|
93
103
|
onHover?.(null);
|
|
@@ -98,20 +108,18 @@ function BlockPattern({
|
|
|
98
108
|
}
|
|
99
109
|
onHover?.(pattern);
|
|
100
110
|
},
|
|
101
|
-
onMouseLeave: () => onHover?.(null)
|
|
102
|
-
"aria-label": pattern.title,
|
|
103
|
-
"aria-describedby": pattern.description ? descriptionId : undefined
|
|
111
|
+
onMouseLeave: () => onHover?.(null)
|
|
104
112
|
}, (0, _react.createElement)(_blockPreview.default, {
|
|
105
113
|
blocks: blocks,
|
|
106
114
|
viewportWidth: viewportWidth
|
|
107
115
|
}), (0, _react.createElement)(_components.__experimentalHStack, {
|
|
108
116
|
className: "block-editor-patterns__pattern-details"
|
|
109
|
-
}, pattern.
|
|
117
|
+
}, pattern.type === _utils.PATTERN_TYPES.user && !pattern.syncStatus && (0, _react.createElement)("div", {
|
|
110
118
|
className: "block-editor-patterns__pattern-icon-wrapper"
|
|
111
119
|
}, (0, _react.createElement)(_icons.Icon, {
|
|
112
120
|
className: "block-editor-patterns__pattern-icon",
|
|
113
121
|
icon: _icons.symbol
|
|
114
|
-
})), (!showTooltip || pattern.
|
|
122
|
+
})), (!showTooltip || pattern.type === _utils.PATTERN_TYPES.user) && (0, _react.createElement)("div", {
|
|
115
123
|
className: "block-editor-block-patterns-list__item-title"
|
|
116
124
|
}, pattern.title)), !!pattern.description && (0, _react.createElement)(_components.VisuallyHidden, {
|
|
117
125
|
id: descriptionId
|
|
@@ -122,7 +130,7 @@ function BlockPatternPlaceholder() {
|
|
|
122
130
|
className: "block-editor-block-patterns-list__item is-placeholder"
|
|
123
131
|
});
|
|
124
132
|
}
|
|
125
|
-
function
|
|
133
|
+
function BlockPatternsList({
|
|
126
134
|
isDraggable,
|
|
127
135
|
blockPatterns,
|
|
128
136
|
shownPatterns,
|
|
@@ -133,11 +141,20 @@ function BlockPatternList({
|
|
|
133
141
|
showTitlesAsTooltip,
|
|
134
142
|
pagingProps
|
|
135
143
|
}, ref) {
|
|
136
|
-
const
|
|
144
|
+
const compositeStore = useCompositeStore({
|
|
137
145
|
orientation
|
|
138
146
|
});
|
|
139
|
-
|
|
140
|
-
|
|
147
|
+
const {
|
|
148
|
+
setActiveId
|
|
149
|
+
} = compositeStore;
|
|
150
|
+
(0, _element.useEffect)(() => {
|
|
151
|
+
// We reset the active composite item whenever the
|
|
152
|
+
// available patterns change, to make sure that
|
|
153
|
+
// focus is put back to the start.
|
|
154
|
+
setActiveId(undefined);
|
|
155
|
+
}, [setActiveId, shownPatterns, blockPatterns]);
|
|
156
|
+
return (0, _react.createElement)(Composite, {
|
|
157
|
+
store: compositeStore,
|
|
141
158
|
role: "listbox",
|
|
142
159
|
className: "block-editor-block-patterns-list",
|
|
143
160
|
"aria-label": label,
|
|
@@ -146,11 +163,11 @@ function BlockPatternList({
|
|
|
146
163
|
const isShown = shownPatterns.includes(pattern);
|
|
147
164
|
return isShown ? (0, _react.createElement)(BlockPattern, {
|
|
148
165
|
key: pattern.name,
|
|
166
|
+
id: pattern.name,
|
|
149
167
|
pattern: pattern,
|
|
150
168
|
onClick: onClickPattern,
|
|
151
169
|
onHover: onHover,
|
|
152
170
|
isDraggable: isDraggable,
|
|
153
|
-
composite: composite,
|
|
154
171
|
showTooltip: showTitlesAsTooltip
|
|
155
172
|
}) : (0, _react.createElement)(BlockPatternPlaceholder, {
|
|
156
173
|
key: pattern.name
|
|
@@ -159,6 +176,6 @@ function BlockPatternList({
|
|
|
159
176
|
...pagingProps
|
|
160
177
|
}));
|
|
161
178
|
}
|
|
162
|
-
var _default = (0, _element.forwardRef)(
|
|
179
|
+
var _default = (0, _element.forwardRef)(BlockPatternsList);
|
|
163
180
|
exports.default = _default;
|
|
164
181
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_classnames","_interopRequireDefault","require","_element","_components","_compose","_i18n","_icons","_blockPreview","_inserterDraggableBlocks","_blockPatternsPaging","WithToolTip","showTooltip","title","children","_react","createElement","Tooltip","text","Fragment","BlockPattern","isDraggable","pattern","onClick","onHover","composite","isDragging","setIsDragging","useState","blocks","viewportWidth","instanceId","useInstanceId","descriptionId","default","isEnabled","isPattern","draggable","onDragStart","onDragEnd","className","event","id","__unstableCompositeItem","role","as","classnames","syncStatus","onMouseEnter","onMouseLeave","description","undefined","__experimentalHStack","Icon","icon","symbol","VisuallyHidden","BlockPatternPlaceholder","BlockPatternList","blockPatterns","shownPatterns","onClickPattern","orientation","label","__","showTitlesAsTooltip","pagingProps","ref","useCompositeState","__unstableComposite","map","isShown","includes","key","name","_default","forwardRef","exports"],"sources":["@wordpress/block-editor/src/components/block-patterns-list/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useState, forwardRef } from '@wordpress/element';\nimport {\n\tVisuallyHidden,\n\t__unstableComposite as Composite,\n\t__unstableUseCompositeState as useCompositeState,\n\t__unstableCompositeItem as CompositeItem,\n\tTooltip,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { Icon, symbol } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport BlockPreview from '../block-preview';\nimport InserterDraggableBlocks from '../inserter-draggable-blocks';\nimport BlockPatternsPaging from '../block-patterns-paging';\n\nconst WithToolTip = ( { showTooltip, title, children } ) => {\n\tif ( showTooltip ) {\n\t\treturn <Tooltip text={ title }>{ children }</Tooltip>;\n\t}\n\treturn <>{ children }</>;\n};\n\nfunction BlockPattern( {\n\tisDraggable,\n\tpattern,\n\tonClick,\n\tonHover,\n\tcomposite,\n\tshowTooltip,\n} ) {\n\tconst [ isDragging, setIsDragging ] = useState( false );\n\tconst { blocks, viewportWidth } = pattern;\n\tconst instanceId = useInstanceId( BlockPattern );\n\tconst descriptionId = `block-editor-block-patterns-list__item-description-${ instanceId }`;\n\n\treturn (\n\t\t<InserterDraggableBlocks\n\t\t\tisEnabled={ isDraggable }\n\t\t\tblocks={ blocks }\n\t\t\tisPattern={ !! pattern }\n\t\t>\n\t\t\t{ ( { draggable, onDragStart, onDragEnd } ) => (\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"block-editor-block-patterns-list__list-item\"\n\t\t\t\t\tdraggable={ draggable }\n\t\t\t\t\tonDragStart={ ( event ) => {\n\t\t\t\t\t\tsetIsDragging( true );\n\t\t\t\t\t\tif ( onDragStart ) {\n\t\t\t\t\t\t\tonHover?.( null );\n\t\t\t\t\t\t\tonDragStart( event );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tonDragEnd={ ( event ) => {\n\t\t\t\t\t\tsetIsDragging( false );\n\t\t\t\t\t\tif ( onDragEnd ) {\n\t\t\t\t\t\t\tonDragEnd( event );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<WithToolTip\n\t\t\t\t\t\tshowTooltip={ showTooltip && ! pattern.id }\n\t\t\t\t\t\ttitle={ pattern.title }\n\t\t\t\t\t>\n\t\t\t\t\t\t<CompositeItem\n\t\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t\tas=\"div\"\n\t\t\t\t\t\t\t{ ...composite }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-block-patterns-list__item',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'block-editor-block-patterns-list__list-item-synced':\n\t\t\t\t\t\t\t\t\t\tpattern.id && ! pattern.syncStatus,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tonClick( pattern, blocks );\n\t\t\t\t\t\t\t\tonHover?.( null );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonMouseEnter={ () => {\n\t\t\t\t\t\t\t\tif ( isDragging ) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonHover?.( pattern );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonMouseLeave={ () => onHover?.( null ) }\n\t\t\t\t\t\t\taria-label={ pattern.title }\n\t\t\t\t\t\t\taria-describedby={\n\t\t\t\t\t\t\t\tpattern.description ? descriptionId : undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockPreview\n\t\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\t\tviewportWidth={ viewportWidth }\n\t\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t\t<HStack className=\"block-editor-patterns__pattern-details\">\n\t\t\t\t\t\t\t\t{ pattern.id && ! pattern.syncStatus && (\n\t\t\t\t\t\t\t\t\t<div className=\"block-editor-patterns__pattern-icon-wrapper\">\n\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-patterns__pattern-icon\"\n\t\t\t\t\t\t\t\t\t\t\ticon={ symbol }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ ( ! showTooltip || pattern.id ) && (\n\t\t\t\t\t\t\t\t\t<div className=\"block-editor-block-patterns-list__item-title\">\n\t\t\t\t\t\t\t\t\t\t{ pattern.title }\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</HStack>\n\n\t\t\t\t\t\t\t{ !! pattern.description && (\n\t\t\t\t\t\t\t\t<VisuallyHidden id={ descriptionId }>\n\t\t\t\t\t\t\t\t\t{ pattern.description }\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</CompositeItem>\n\t\t\t\t\t</WithToolTip>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</InserterDraggableBlocks>\n\t);\n}\n\nfunction BlockPatternPlaceholder() {\n\treturn (\n\t\t<div className=\"block-editor-block-patterns-list__item is-placeholder\" />\n\t);\n}\n\nfunction BlockPatternList(\n\t{\n\t\tisDraggable,\n\t\tblockPatterns,\n\t\tshownPatterns,\n\t\tonHover,\n\t\tonClickPattern,\n\t\torientation,\n\t\tlabel = __( 'Block patterns' ),\n\t\tshowTitlesAsTooltip,\n\t\tpagingProps,\n\t},\n\tref\n) {\n\tconst composite = useCompositeState( { orientation } );\n\treturn (\n\t\t<Composite\n\t\t\t{ ...composite }\n\t\t\trole=\"listbox\"\n\t\t\tclassName=\"block-editor-block-patterns-list\"\n\t\t\taria-label={ label }\n\t\t\tref={ ref }\n\t\t>\n\t\t\t{ blockPatterns.map( ( pattern ) => {\n\t\t\t\tconst isShown = shownPatterns.includes( pattern );\n\t\t\t\treturn isShown ? (\n\t\t\t\t\t<BlockPattern\n\t\t\t\t\t\tkey={ pattern.name }\n\t\t\t\t\t\tpattern={ pattern }\n\t\t\t\t\t\tonClick={ onClickPattern }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\tisDraggable={ isDraggable }\n\t\t\t\t\t\tcomposite={ composite }\n\t\t\t\t\t\tshowTooltip={ showTitlesAsTooltip }\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<BlockPatternPlaceholder key={ pattern.name } />\n\t\t\t\t);\n\t\t\t} ) }\n\t\t\t{ pagingProps && <BlockPatternsPaging { ...pagingProps } /> }\n\t\t</Composite>\n\t);\n}\n\nexport default forwardRef( BlockPatternList );\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAQA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAKA,IAAAM,aAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,wBAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,oBAAA,GAAAT,sBAAA,CAAAC,OAAA;AA1BA;AACA;AACA;;AAGA;AACA;AACA;;AAcA;AACA;AACA;;AAKA,MAAMS,WAAW,GAAGA,CAAE;EAAEC,WAAW;EAAEC,KAAK;EAAEC;AAAS,CAAC,KAAM;EAC3D,IAAKF,WAAW,E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nBH,WAAW,EAAGA,WAAa;MAC3BI,SAAS,EAAGA,SAAW;MACvBb,WAAW,EAAGqD;IAAqB,CACnC,CAAC,GAEF,IAAAlD,MAAA,CAAAC,aAAA,EAACyC,uBAAuB;MAACgB,GAAG,EAAGnD,OAAO,CAACoD;IAAM,CAAE,CAC/C;EACF,CAAE,CAAC,EACDR,WAAW,IAAI,IAAAnD,MAAA,CAAAC,aAAA,EAACN,oBAAA,CAAAwB,OAAmB;IAAA,GAAMgC;EAAW,CAAI,CAChD,CAAC;AAEd;AAAC,IAAAS,QAAA,GAEc,IAAAC,mBAAU,EAAElB,gBAAiB,CAAC;AAAAmB,OAAA,CAAA3C,OAAA,GAAAyC,QAAA"}
|
|
1
|
+
{"version":3,"names":["_classnames","_interopRequireDefault","require","_element","_components","_compose","_i18n","_icons","_lockUnlock","_blockPreview","_inserterDraggableBlocks","_blockPatternsPaging","_utils","CompositeV2","Composite","CompositeItemV2","CompositeItem","useCompositeStoreV2","useCompositeStore","unlock","componentsPrivateApis","WithToolTip","showTooltip","title","children","_react","createElement","Tooltip","text","Fragment","BlockPattern","id","isDraggable","pattern","onClick","onHover","isDragging","setIsDragging","useState","blocks","viewportWidth","instanceId","useInstanceId","descriptionId","default","isEnabled","isPattern","draggable","onDragStart","onDragEnd","className","event","type","PATTERN_TYPES","user","render","role","description","undefined","classnames","syncStatus","onMouseEnter","onMouseLeave","__experimentalHStack","Icon","icon","symbol","VisuallyHidden","BlockPatternPlaceholder","BlockPatternsList","blockPatterns","shownPatterns","onClickPattern","orientation","label","__","showTitlesAsTooltip","pagingProps","ref","compositeStore","setActiveId","useEffect","store","map","isShown","includes","key","name","_default","forwardRef","exports"],"sources":["@wordpress/block-editor/src/components/block-patterns-list/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useState, forwardRef } from '@wordpress/element';\nimport {\n\tVisuallyHidden,\n\tTooltip,\n\tprivateApis as componentsPrivateApis,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { Icon, symbol } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport BlockPreview from '../block-preview';\nimport InserterDraggableBlocks from '../inserter-draggable-blocks';\nimport BlockPatternsPaging from '../block-patterns-paging';\nimport { PATTERN_TYPES } from '../inserter/block-patterns-tab/utils';\n\nconst {\n\tCompositeV2: Composite,\n\tCompositeItemV2: CompositeItem,\n\tuseCompositeStoreV2: useCompositeStore,\n} = unlock( componentsPrivateApis );\n\nconst WithToolTip = ( { showTooltip, title, children } ) => {\n\tif ( showTooltip ) {\n\t\treturn <Tooltip text={ title }>{ children }</Tooltip>;\n\t}\n\treturn <>{ children }</>;\n};\n\nfunction BlockPattern( {\n\tid,\n\tisDraggable,\n\tpattern,\n\tonClick,\n\tonHover,\n\tshowTooltip,\n} ) {\n\tconst [ isDragging, setIsDragging ] = useState( false );\n\tconst { blocks, viewportWidth } = pattern;\n\tconst instanceId = useInstanceId( BlockPattern );\n\tconst descriptionId = `block-editor-block-patterns-list__item-description-${ instanceId }`;\n\n\treturn (\n\t\t<InserterDraggableBlocks\n\t\t\tisEnabled={ isDraggable }\n\t\t\tblocks={ blocks }\n\t\t\tisPattern={ !! pattern }\n\t\t>\n\t\t\t{ ( { draggable, onDragStart, onDragEnd } ) => (\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"block-editor-block-patterns-list__list-item\"\n\t\t\t\t\tdraggable={ draggable }\n\t\t\t\t\tonDragStart={ ( event ) => {\n\t\t\t\t\t\tsetIsDragging( true );\n\t\t\t\t\t\tif ( onDragStart ) {\n\t\t\t\t\t\t\tonHover?.( null );\n\t\t\t\t\t\t\tonDragStart( event );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tonDragEnd={ ( event ) => {\n\t\t\t\t\t\tsetIsDragging( false );\n\t\t\t\t\t\tif ( onDragEnd ) {\n\t\t\t\t\t\t\tonDragEnd( event );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<WithToolTip\n\t\t\t\t\t\tshowTooltip={\n\t\t\t\t\t\t\tshowTooltip && ! pattern.type !== PATTERN_TYPES.user\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttitle={ pattern.title }\n\t\t\t\t\t>\n\t\t\t\t\t\t<CompositeItem\n\t\t\t\t\t\t\trender={\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t\t\t\taria-label={ pattern.title }\n\t\t\t\t\t\t\t\t\taria-describedby={\n\t\t\t\t\t\t\t\t\t\tpattern.description\n\t\t\t\t\t\t\t\t\t\t\t? descriptionId\n\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t\t'block-editor-block-patterns-list__item',\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t'block-editor-block-patterns-list__list-item-synced':\n\t\t\t\t\t\t\t\t\t\t\t\tpattern.type ===\n\t\t\t\t\t\t\t\t\t\t\t\t\tPATTERN_TYPES.user &&\n\t\t\t\t\t\t\t\t\t\t\t\t! pattern.syncStatus,\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tid={ id }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tonClick( pattern, blocks );\n\t\t\t\t\t\t\t\tonHover?.( null );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonMouseEnter={ () => {\n\t\t\t\t\t\t\t\tif ( isDragging ) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonHover?.( pattern );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonMouseLeave={ () => onHover?.( null ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockPreview\n\t\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\t\tviewportWidth={ viewportWidth }\n\t\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t\t<HStack className=\"block-editor-patterns__pattern-details\">\n\t\t\t\t\t\t\t\t{ pattern.type === PATTERN_TYPES.user &&\n\t\t\t\t\t\t\t\t\t! pattern.syncStatus && (\n\t\t\t\t\t\t\t\t\t\t<div className=\"block-editor-patterns__pattern-icon-wrapper\">\n\t\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-patterns__pattern-icon\"\n\t\t\t\t\t\t\t\t\t\t\t\ticon={ symbol }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ ( ! showTooltip ||\n\t\t\t\t\t\t\t\t\tpattern.type === PATTERN_TYPES.user ) && (\n\t\t\t\t\t\t\t\t\t<div className=\"block-editor-block-patterns-list__item-title\">\n\t\t\t\t\t\t\t\t\t\t{ pattern.title }\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</HStack>\n\n\t\t\t\t\t\t\t{ !! pattern.description && (\n\t\t\t\t\t\t\t\t<VisuallyHidden id={ descriptionId }>\n\t\t\t\t\t\t\t\t\t{ pattern.description }\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</CompositeItem>\n\t\t\t\t\t</WithToolTip>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</InserterDraggableBlocks>\n\t);\n}\n\nfunction BlockPatternPlaceholder() {\n\treturn (\n\t\t<div className=\"block-editor-block-patterns-list__item is-placeholder\" />\n\t);\n}\n\nfunction BlockPatternsList(\n\t{\n\t\tisDraggable,\n\t\tblockPatterns,\n\t\tshownPatterns,\n\t\tonHover,\n\t\tonClickPattern,\n\t\torientation,\n\t\tlabel = __( 'Block patterns' ),\n\t\tshowTitlesAsTooltip,\n\t\tpagingProps,\n\t},\n\tref\n) {\n\tconst compositeStore = useCompositeStore( { orientation } );\n\tconst { setActiveId } = compositeStore;\n\n\tuseEffect( () => {\n\t\t// We reset the active composite item whenever the\n\t\t// available patterns change, to make sure that\n\t\t// focus is put back to the start.\n\t\tsetActiveId( undefined );\n\t}, [ setActiveId, shownPatterns, blockPatterns ] );\n\n\treturn (\n\t\t<Composite\n\t\t\tstore={ compositeStore }\n\t\t\trole=\"listbox\"\n\t\t\tclassName=\"block-editor-block-patterns-list\"\n\t\t\taria-label={ label }\n\t\t\tref={ ref }\n\t\t>\n\t\t\t{ blockPatterns.map( ( pattern ) => {\n\t\t\t\tconst isShown = shownPatterns.includes( pattern );\n\t\t\t\treturn isShown ? (\n\t\t\t\t\t<BlockPattern\n\t\t\t\t\t\tkey={ pattern.name }\n\t\t\t\t\t\tid={ pattern.name }\n\t\t\t\t\t\tpattern={ pattern }\n\t\t\t\t\t\tonClick={ onClickPattern }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\tisDraggable={ isDraggable }\n\t\t\t\t\t\tshowTooltip={ showTitlesAsTooltip }\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<BlockPatternPlaceholder key={ pattern.name } />\n\t\t\t\t);\n\t\t\t} ) }\n\t\t\t{ pagingProps && <BlockPatternsPaging { ...pagingProps } /> }\n\t\t</Composite>\n\t);\n}\n\nexport default forwardRef( BlockPatternsList );\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAMA,IAA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C;AAEd;AAAC,IAAAW,QAAA,GAEc,IAAAC,mBAAU,EAAEpB,iBAAkB,CAAC;AAAAqB,OAAA,CAAA9C,OAAA,GAAA4C,QAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "BlockRenameControl", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _renameControl.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "BlockRenameModal", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _modal.default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "useBlockRename", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return _useBlockRename.default;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
var _renameControl = _interopRequireDefault(require("./rename-control"));
|
|
26
|
+
var _modal = _interopRequireDefault(require("./modal"));
|
|
27
|
+
var _useBlockRename = _interopRequireDefault(require("./use-block-rename"));
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_renameControl","_interopRequireDefault","require","_modal","_useBlockRename"],"sources":["@wordpress/block-editor/src/components/block-rename/index.js"],"sourcesContent":["export { default as BlockRenameControl } from './rename-control';\nexport { default as BlockRenameModal } from './modal';\nexport { default as useBlockRename } from './use-block-rename';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,eAAA,GAAAH,sBAAA,CAAAC,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isEmptyString","testString","trim","length"],"sources":["@wordpress/block-editor/src/components/block-rename/is-empty-string.js"],"sourcesContent":["export default function isEmptyString( testString ) {\n\treturn testString?.trim()?.length === 0;\n}\n"],"mappings":";;;;;;AAAe,SAASA,aAAaA,CAAEC,UAAU,EAAG;EACnD,OAAOA,UAAU,EAAEC,IAAI,CAAC,CAAC,EAAEC,MAAM,KAAK,CAAC;AACxC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = BlockRenameModal;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _components = require("@wordpress/components");
|
|
10
|
+
var _compose = require("@wordpress/compose");
|
|
11
|
+
var _i18n = require("@wordpress/i18n");
|
|
12
|
+
var _element = require("@wordpress/element");
|
|
13
|
+
var _a11y = require("@wordpress/a11y");
|
|
14
|
+
var _isEmptyString = _interopRequireDefault(require("./is-empty-string"));
|
|
15
|
+
/**
|
|
16
|
+
* WordPress dependencies
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Internal dependencies
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
function BlockRenameModal({
|
|
24
|
+
blockName,
|
|
25
|
+
originalBlockName,
|
|
26
|
+
onClose,
|
|
27
|
+
onSave
|
|
28
|
+
}) {
|
|
29
|
+
const [editedBlockName, setEditedBlockName] = (0, _element.useState)(blockName);
|
|
30
|
+
const nameHasChanged = editedBlockName !== blockName;
|
|
31
|
+
const nameIsOriginal = editedBlockName === originalBlockName;
|
|
32
|
+
const nameIsEmpty = (0, _isEmptyString.default)(editedBlockName);
|
|
33
|
+
const isNameValid = nameHasChanged || nameIsOriginal;
|
|
34
|
+
const autoSelectInputText = event => event.target.select();
|
|
35
|
+
const dialogDescription = (0, _compose.useInstanceId)(BlockRenameModal, `block-editor-rename-modal__description`);
|
|
36
|
+
const handleSubmit = () => {
|
|
37
|
+
const message = nameIsOriginal || nameIsEmpty ? (0, _i18n.sprintf)( /* translators: %s: new name/label for the block */
|
|
38
|
+
(0, _i18n.__)('Block name reset to: "%s".'), editedBlockName) : (0, _i18n.sprintf)( /* translators: %s: new name/label for the block */
|
|
39
|
+
(0, _i18n.__)('Block name changed to: "%s".'), editedBlockName);
|
|
40
|
+
|
|
41
|
+
// Must be assertive to immediately announce change.
|
|
42
|
+
(0, _a11y.speak)(message, 'assertive');
|
|
43
|
+
onSave(editedBlockName);
|
|
44
|
+
|
|
45
|
+
// Immediate close avoids ability to hit save multiple times.
|
|
46
|
+
onClose();
|
|
47
|
+
};
|
|
48
|
+
return (0, _react.createElement)(_components.Modal, {
|
|
49
|
+
title: (0, _i18n.__)('Rename'),
|
|
50
|
+
onRequestClose: onClose,
|
|
51
|
+
overlayClassName: "block-editor-block-rename-modal",
|
|
52
|
+
aria: {
|
|
53
|
+
describedby: dialogDescription
|
|
54
|
+
},
|
|
55
|
+
focusOnMount: "firstContentElement"
|
|
56
|
+
}, (0, _react.createElement)("p", {
|
|
57
|
+
id: dialogDescription
|
|
58
|
+
}, (0, _i18n.__)('Enter a custom name for this block.')), (0, _react.createElement)("form", {
|
|
59
|
+
onSubmit: e => {
|
|
60
|
+
e.preventDefault();
|
|
61
|
+
if (!isNameValid) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
handleSubmit();
|
|
65
|
+
}
|
|
66
|
+
}, (0, _react.createElement)(_components.__experimentalVStack, {
|
|
67
|
+
spacing: "3"
|
|
68
|
+
}, (0, _react.createElement)(_components.TextControl, {
|
|
69
|
+
__nextHasNoMarginBottom: true,
|
|
70
|
+
value: editedBlockName,
|
|
71
|
+
label: (0, _i18n.__)('Block name'),
|
|
72
|
+
hideLabelFromVision: true,
|
|
73
|
+
placeholder: originalBlockName,
|
|
74
|
+
onChange: setEditedBlockName,
|
|
75
|
+
onFocus: autoSelectInputText
|
|
76
|
+
}), (0, _react.createElement)(_components.__experimentalHStack, {
|
|
77
|
+
justify: "right"
|
|
78
|
+
}, (0, _react.createElement)(_components.Button, {
|
|
79
|
+
variant: "tertiary",
|
|
80
|
+
onClick: onClose
|
|
81
|
+
}, (0, _i18n.__)('Cancel')), (0, _react.createElement)(_components.Button, {
|
|
82
|
+
"aria-disabled": !isNameValid,
|
|
83
|
+
variant: "primary",
|
|
84
|
+
type: "submit"
|
|
85
|
+
}, (0, _i18n.__)('Save'))))));
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_components","require","_compose","_i18n","_element","_a11y","_isEmptyString","_interopRequireDefault","BlockRenameModal","blockName","originalBlockName","onClose","onSave","editedBlockName","setEditedBlockName","useState","nameHasChanged","nameIsOriginal","nameIsEmpty","isEmptyString","isNameValid","autoSelectInputText","event","target","select","dialogDescription","useInstanceId","handleSubmit","message","sprintf","__","speak","_react","createElement","Modal","title","onRequestClose","overlayClassName","aria","describedby","focusOnMount","id","onSubmit","e","preventDefault","__experimentalVStack","spacing","TextControl","__nextHasNoMarginBottom","value","label","hideLabelFromVision","placeholder","onChange","onFocus","__experimentalHStack","justify","Button","variant","onClick","type"],"sources":["@wordpress/block-editor/src/components/block-rename/modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tButton,\n\tTextControl,\n\tModal,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport isEmptyString from './is-empty-string';\n\nexport default function BlockRenameModal( {\n\tblockName,\n\toriginalBlockName,\n\tonClose,\n\tonSave,\n} ) {\n\tconst [ editedBlockName, setEditedBlockName ] = useState( blockName );\n\n\tconst nameHasChanged = editedBlockName !== blockName;\n\tconst nameIsOriginal = editedBlockName === originalBlockName;\n\tconst nameIsEmpty = isEmptyString( editedBlockName );\n\n\tconst isNameValid = nameHasChanged || nameIsOriginal;\n\n\tconst autoSelectInputText = ( event ) => event.target.select();\n\n\tconst dialogDescription = useInstanceId(\n\t\tBlockRenameModal,\n\t\t`block-editor-rename-modal__description`\n\t);\n\n\tconst handleSubmit = () => {\n\t\tconst message =\n\t\t\tnameIsOriginal || nameIsEmpty\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t/* translators: %s: new name/label for the block */\n\t\t\t\t\t\t__( 'Block name reset to: \"%s\".' ),\n\t\t\t\t\t\teditedBlockName\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: %s: new name/label for the block */\n\t\t\t\t\t\t__( 'Block name changed to: \"%s\".' ),\n\t\t\t\t\t\teditedBlockName\n\t\t\t\t );\n\n\t\t// Must be assertive to immediately announce change.\n\t\tspeak( message, 'assertive' );\n\t\tonSave( editedBlockName );\n\n\t\t// Immediate close avoids ability to hit save multiple times.\n\t\tonClose();\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Rename' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t\toverlayClassName=\"block-editor-block-rename-modal\"\n\t\t\taria={ {\n\t\t\t\tdescribedby: dialogDescription,\n\t\t\t} }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t>\n\t\t\t<p id={ dialogDescription }>\n\t\t\t\t{ __( 'Enter a custom name for this block.' ) }\n\t\t\t</p>\n\t\t\t<form\n\t\t\t\tonSubmit={ ( e ) => {\n\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\tif ( ! isNameValid ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\thandleSubmit();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<VStack spacing=\"3\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tvalue={ editedBlockName }\n\t\t\t\t\t\tlabel={ __( 'Block name' ) }\n\t\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t\tplaceholder={ originalBlockName }\n\t\t\t\t\t\tonChange={ setEditedBlockName }\n\t\t\t\t\t\tonFocus={ autoSelectInputText }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ onClose }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\taria-disabled={ ! isNameValid }\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAOA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,cAAA,GAAAC,sBAAA,CAAAN,OAAA;AAlBA;AACA;AACA;;AAaA;AACA;AACA;;AAGe,SAASO,gBAAgBA,CAAE;EACzCC,SAAS;EACTC,iBAAiB;EACjBC,OAAO;EACPC;AACD,CAAC,EAAG;EACH,MAAM,CAAEC,eAAe,EAAEC,kBAAkB,CAAE,GAAG,IAAAC,iBAAQ,EAAEN,SAAU,CAAC;EAErE,MAAMO,cAAc,GAAGH,eAAe,KAAKJ,SAAS;EACpD,MAAMQ,cAAc,GAAG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AK,MAAA,CAAAC,aAAA,EAACjC,WAAA,CAAA6C,oBAAM;IAACC,OAAO,EAAC;EAAG,GAClB,IAAAd,MAAA,CAAAC,aAAA,EAACjC,WAAA,CAAA+C,WAAW;IACXC,uBAAuB;IACvBC,KAAK,EAAGpC,eAAiB;IACzBqC,KAAK,EAAG,IAAApB,QAAE,EAAE,YAAa,CAAG;IAC5BqB,mBAAmB,EAAG,IAAM;IAC5BC,WAAW,EAAG1C,iBAAmB;IACjC2C,QAAQ,EAAGvC,kBAAoB;IAC/BwC,OAAO,EAAGjC;EAAqB,CAC/B,CAAC,EACF,IAAAW,MAAA,CAAAC,aAAA,EAACjC,WAAA,CAAAuD,oBAAM;IAACC,OAAO,EAAC;EAAO,GACtB,IAAAxB,MAAA,CAAAC,aAAA,EAACjC,WAAA,CAAAyD,MAAM;IAACC,OAAO,EAAC,UAAU;IAACC,OAAO,EAAGhD;EAAS,GAC3C,IAAAmB,QAAE,EAAE,QAAS,CACR,CAAC,EAET,IAAAE,MAAA,CAAAC,aAAA,EAACjC,WAAA,CAAAyD,MAAM;IACN,iBAAgB,CAAErC,WAAa;IAC/BsC,OAAO,EAAC,SAAS;IACjBE,IAAI,EAAC;EAAQ,GAEX,IAAA9B,QAAE,EAAE,MAAO,CACN,CACD,CACD,CACH,CACA,CAAC;AAEV"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = BlockRenameControl;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _components = require("@wordpress/components");
|
|
10
|
+
var _data = require("@wordpress/data");
|
|
11
|
+
var _i18n = require("@wordpress/i18n");
|
|
12
|
+
var _element = require("@wordpress/element");
|
|
13
|
+
var _store = require("../../store");
|
|
14
|
+
var _ = require("..");
|
|
15
|
+
var _isEmptyString = _interopRequireDefault(require("./is-empty-string"));
|
|
16
|
+
var _modal = _interopRequireDefault(require("./modal"));
|
|
17
|
+
/**
|
|
18
|
+
* WordPress dependencies
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Internal dependencies
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
function BlockRenameControl({
|
|
26
|
+
clientId
|
|
27
|
+
}) {
|
|
28
|
+
const [renamingBlock, setRenamingBlock] = (0, _element.useState)(false);
|
|
29
|
+
const {
|
|
30
|
+
metadata
|
|
31
|
+
} = (0, _data.useSelect)(select => {
|
|
32
|
+
const {
|
|
33
|
+
getBlockAttributes
|
|
34
|
+
} = select(_store.store);
|
|
35
|
+
const _metadata = getBlockAttributes(clientId)?.metadata;
|
|
36
|
+
return {
|
|
37
|
+
metadata: _metadata
|
|
38
|
+
};
|
|
39
|
+
}, [clientId]);
|
|
40
|
+
const {
|
|
41
|
+
updateBlockAttributes
|
|
42
|
+
} = (0, _data.useDispatch)(_store.store);
|
|
43
|
+
const customName = metadata?.name;
|
|
44
|
+
function onChange(newName) {
|
|
45
|
+
updateBlockAttributes([clientId], {
|
|
46
|
+
metadata: {
|
|
47
|
+
...(metadata && metadata),
|
|
48
|
+
name: newName
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
const blockInformation = (0, _.useBlockDisplayInformation)(clientId);
|
|
53
|
+
return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_components.MenuItem, {
|
|
54
|
+
onClick: () => {
|
|
55
|
+
setRenamingBlock(true);
|
|
56
|
+
},
|
|
57
|
+
"aria-expanded": renamingBlock,
|
|
58
|
+
"aria-haspopup": "dialog"
|
|
59
|
+
}, (0, _i18n.__)('Rename')), renamingBlock && (0, _react.createElement)(_modal.default, {
|
|
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 (newName === blockInformation?.title || (0, _isEmptyString.default)(newName)) {
|
|
68
|
+
newName = undefined;
|
|
69
|
+
}
|
|
70
|
+
onChange(newName);
|
|
71
|
+
}
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=rename-control.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_components","require","_data","_i18n","_element","_store","_","_isEmptyString","_interopRequireDefault","_modal","BlockRenameControl","clientId","renamingBlock","setRenamingBlock","useState","metadata","useSelect","select","getBlockAttributes","blockEditorStore","_metadata","updateBlockAttributes","useDispatch","customName","name","onChange","newName","blockInformation","useBlockDisplayInformation","_react","createElement","Fragment","MenuItem","onClick","__","default","blockName","originalBlockName","title","onClose","onSave","isEmptyString","undefined"],"sources":["@wordpress/block-editor/src/components/block-rename/rename-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { useBlockDisplayInformation } from '..';\nimport isEmptyString from './is-empty-string';\nimport BlockRenameModal from './modal';\n\nexport default function BlockRenameControl( { clientId } ) {\n\tconst [ renamingBlock, setRenamingBlock ] = useState( false );\n\n\tconst { metadata } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockAttributes } = select( blockEditorStore );\n\n\t\t\tconst _metadata = getBlockAttributes( clientId )?.metadata;\n\t\t\treturn {\n\t\t\t\tmetadata: _metadata,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\tconst customName = metadata?.name;\n\n\tfunction onChange( newName ) {\n\t\tupdateBlockAttributes( [ clientId ], {\n\t\t\tmetadata: {\n\t\t\t\t...( metadata && metadata ),\n\t\t\t\tname: newName,\n\t\t\t},\n\t\t} );\n\t}\n\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetRenamingBlock( true );\n\t\t\t\t} }\n\t\t\t\taria-expanded={ renamingBlock }\n\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t>\n\t\t\t\t{ __( 'Rename' ) }\n\t\t\t</MenuItem>\n\t\t\t{ renamingBlock && (\n\t\t\t\t<BlockRenameModal\n\t\t\t\t\tblockName={ customName || '' }\n\t\t\t\t\toriginalBlockName={ blockInformation?.title }\n\t\t\t\t\tonClose={ () => setRenamingBlock( false ) }\n\t\t\t\t\tonSave={ ( newName ) => {\n\t\t\t\t\t\t// If the new value is the block's original name (e.g. `Group`)\n\t\t\t\t\t\t// or it is an empty string then assume the intent is to reset\n\t\t\t\t\t\t// the value. Therefore reset the metadata.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tnewName === blockInformation?.title ||\n\t\t\t\t\t\t\tisEmptyString( newName )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tnewName = undefined;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tonChange( newName );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,CAAA,GAAAL,OAAA;AACA,IAAAM,cAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAD,sBAAA,CAAAP,OA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AGb,UAAU,IAAI,EAAI;IAC9Bc,iBAAiB,EAAGV,gBAAgB,EAAEW,KAAO;IAC7CC,OAAO,EAAGA,CAAA,KAAM1B,gBAAgB,CAAE,KAAM,CAAG;IAC3C2B,MAAM,EAAKd,OAAO,IAAM;MACvB;MACA;MACA;MACA,IACCA,OAAO,KAAKC,gBAAgB,EAAEW,KAAK,IACnC,IAAAG,sBAAa,EAAEf,OAAQ,CAAC,EACvB;QACDA,OAAO,GAAGgB,SAAS;MACpB;MAEAjB,QAAQ,CAAEC,OAAQ,CAAC;IACpB;EAAG,CACH,CAED,CAAC;AAEL"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useBlockRename;
|
|
7
|
+
var _blocks = require("@wordpress/blocks");
|
|
8
|
+
/**
|
|
9
|
+
* WordPress dependencies
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
function useBlockRename(name) {
|
|
13
|
+
return {
|
|
14
|
+
canRename: (0, _blocks.getBlockSupport)(name, 'renaming', true)
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=use-block-rename.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_blocks","require","useBlockRename","name","canRename","getBlockSupport"],"sources":["@wordpress/block-editor/src/components/block-rename/use-block-rename.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\n\nexport default function useBlockRename( name ) {\n\treturn {\n\t\tcanRename: getBlockSupport( name, 'renaming', true ),\n\t};\n}\n"],"mappings":";;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGe,SAASC,cAAcA,CAAEC,IAAI,EAAG;EAC9C,OAAO;IACNC,SAAS,EAAE,IAAAC,uBAAe,EAAEF,IAAI,EAAE,UAAU,EAAE,IAAK;EACpD,CAAC;AACF"}
|
|
@@ -47,6 +47,35 @@ function CopyMenuItem({
|
|
|
47
47
|
ref: ref
|
|
48
48
|
}, copyMenuItemLabel);
|
|
49
49
|
}
|
|
50
|
+
function ParentSelectorMenuItem({
|
|
51
|
+
parentClientId,
|
|
52
|
+
parentBlockType
|
|
53
|
+
}) {
|
|
54
|
+
const isSmallViewport = (0, _compose.useViewportMatch)('medium', '<');
|
|
55
|
+
const {
|
|
56
|
+
selectBlock
|
|
57
|
+
} = (0, _data.useDispatch)(_store.store);
|
|
58
|
+
|
|
59
|
+
// Allows highlighting the parent block outline when focusing or hovering
|
|
60
|
+
// the parent block selector within the child.
|
|
61
|
+
const menuItemRef = (0, _element.useRef)();
|
|
62
|
+
const gesturesProps = (0, _utils.useShowHoveredOrFocusedGestures)({
|
|
63
|
+
ref: menuItemRef,
|
|
64
|
+
highlightParent: true
|
|
65
|
+
});
|
|
66
|
+
if (!isSmallViewport) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
return (0, _react.createElement)(_components.MenuItem, {
|
|
70
|
+
...gesturesProps,
|
|
71
|
+
ref: menuItemRef,
|
|
72
|
+
icon: (0, _react.createElement)(_blockIcon.default, {
|
|
73
|
+
icon: parentBlockType.icon
|
|
74
|
+
}),
|
|
75
|
+
onClick: () => selectBlock(parentClientId)
|
|
76
|
+
}, (0, _i18n.sprintf)( /* translators: %s: Name of the block's parent. */
|
|
77
|
+
(0, _i18n.__)('Select parent block (%s)'), parentBlockType.title));
|
|
78
|
+
}
|
|
50
79
|
function BlockSettingsDropdown({
|
|
51
80
|
block,
|
|
52
81
|
clientIds,
|
|
@@ -108,9 +137,6 @@ function BlockSettingsDropdown({
|
|
|
108
137
|
};
|
|
109
138
|
}, []);
|
|
110
139
|
const isMatch = (0, _keyboardShortcuts.__unstableUseShortcutEventMatch)();
|
|
111
|
-
const {
|
|
112
|
-
selectBlock
|
|
113
|
-
} = (0, _data.useDispatch)(_store.store);
|
|
114
140
|
const hasSelectedBlocks = selectedBlockClientIds.length > 0;
|
|
115
141
|
const updateSelectionAfterDuplicate = (0, _element.useCallback)(async clientIdsPromise => {
|
|
116
142
|
if (__experimentalSelectBlock) {
|
|
@@ -136,14 +162,6 @@ function BlockSettingsDropdown({
|
|
|
136
162
|
}, [__experimentalSelectBlock, previousBlockClientId, firstParentClientId, getBlockOrder, hasSelectedBlocks, getSelectedBlockClientIds]);
|
|
137
163
|
const removeBlockLabel = count === 1 ? (0, _i18n.__)('Delete') : (0, _i18n.__)('Delete blocks');
|
|
138
164
|
|
|
139
|
-
// Allows highlighting the parent block outline when focusing or hovering
|
|
140
|
-
// the parent block selector within the child.
|
|
141
|
-
const selectParentButtonRef = (0, _element.useRef)();
|
|
142
|
-
const showParentOutlineGestures = (0, _utils.useShowHoveredOrFocusedGestures)({
|
|
143
|
-
ref: selectParentButtonRef,
|
|
144
|
-
highlightParent: true
|
|
145
|
-
});
|
|
146
|
-
|
|
147
165
|
// This can occur when the selected block (the parent)
|
|
148
166
|
// displays child blocks within a List View.
|
|
149
167
|
const parentBlockIsSelected = selectedBlockClientIds?.includes(firstParentClientId);
|
|
@@ -218,15 +236,10 @@ function BlockSettingsDropdown({
|
|
|
218
236
|
fillProps: {
|
|
219
237
|
onClose
|
|
220
238
|
}
|
|
221
|
-
}), !parentBlockIsSelected && !!firstParentClientId && (0, _react.createElement)(
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
icon: parentBlockType.icon
|
|
226
|
-
}),
|
|
227
|
-
onClick: () => selectBlock(firstParentClientId)
|
|
228
|
-
}, (0, _i18n.sprintf)( /* translators: %s: Name of the block's parent. */
|
|
229
|
-
(0, _i18n.__)('Select parent block (%s)'), parentBlockType.title)), count === 1 && (0, _react.createElement)(_blockHtmlConvertButton.default, {
|
|
239
|
+
}), !parentBlockIsSelected && !!firstParentClientId && (0, _react.createElement)(ParentSelectorMenuItem, {
|
|
240
|
+
parentClientId: firstParentClientId,
|
|
241
|
+
parentBlockType: parentBlockType
|
|
242
|
+
}), count === 1 && (0, _react.createElement)(_blockHtmlConvertButton.default, {
|
|
230
243
|
clientId: firstBlockClientId
|
|
231
244
|
}), (0, _react.createElement)(CopyMenuItem, {
|
|
232
245
|
blocks: blocks,
|