@wordpress/block-editor 13.1.0 → 13.2.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 +19 -17
- package/README.md +1 -1
- package/build/components/block-lock/modal.js +67 -67
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-mover/index.js +12 -6
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-toolbar/shuffle.js +3 -1
- package/build/components/block-toolbar/shuffle.js.map +1 -1
- package/build/components/child-layout-control/index.js +185 -127
- package/build/components/child-layout-control/index.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +4 -3
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/grid/grid-item-movers.js +97 -0
- package/build/components/grid/grid-item-movers.js.map +1 -0
- package/build/components/{grid-visualizer → grid}/grid-item-resizer.js +18 -56
- package/build/components/grid/grid-item-resizer.js.map +1 -0
- package/build/components/grid/grid-visualizer.js +225 -0
- package/build/components/grid/grid-visualizer.js.map +1 -0
- package/build/components/{grid-visualizer → grid}/index.js +14 -0
- package/build/components/grid/index.js.map +1 -0
- package/build/components/grid/use-get-number-of-blocks-before-cell.js +40 -0
- package/build/components/grid/use-get-number-of-blocks-before-cell.js.map +1 -0
- package/build/components/grid/use-grid-layout-sync.js +162 -0
- package/build/components/grid/use-grid-layout-sync.js.map +1 -0
- package/build/components/grid/utils.js +145 -0
- package/build/components/grid/utils.js.map +1 -0
- package/build/components/image-editor/aspect-ratio-dropdown.js +0 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build/components/inner-blocks/index.js +1 -1
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/rich-text/event-listeners/input-rules.js +1 -0
- package/build/components/rich-text/event-listeners/input-rules.js.map +1 -1
- package/build/components/rich-text/index.native.js +10 -4
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/native/index.native.js +14 -0
- package/build/components/rich-text/native/index.native.js.map +1 -1
- package/build/hooks/block-style-variation.js +26 -7
- package/build/hooks/block-style-variation.js.map +1 -1
- package/build/hooks/layout-child.js +29 -21
- package/build/hooks/layout-child.js.map +1 -1
- package/build/hooks/utils.js +3 -2
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/grid.js +24 -47
- package/build/layouts/grid.js.map +1 -1
- package/build/lock-unlock.js +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/store/actions.js +17 -1
- package/build/store/actions.js.map +1 -1
- package/build-module/components/block-lock/modal.js +67 -67
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-mover/index.js +12 -6
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-toolbar/shuffle.js +3 -1
- package/build-module/components/block-toolbar/shuffle.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +185 -127
- package/build-module/components/child-layout-control/index.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +4 -3
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/grid/grid-item-movers.js +90 -0
- package/build-module/components/grid/grid-item-movers.js.map +1 -0
- package/build-module/components/{grid-visualizer → grid}/grid-item-resizer.js +13 -51
- package/build-module/components/grid/grid-item-resizer.js.map +1 -0
- package/build-module/components/grid/grid-visualizer.js +217 -0
- package/build-module/components/grid/grid-visualizer.js.map +1 -0
- package/build-module/components/grid/index.js +5 -0
- package/build-module/components/grid/index.js.map +1 -0
- package/build-module/components/grid/use-get-number-of-blocks-before-cell.js +33 -0
- package/build-module/components/grid/use-get-number-of-blocks-before-cell.js.map +1 -0
- package/build-module/components/grid/use-grid-layout-sync.js +155 -0
- package/build-module/components/grid/use-grid-layout-sync.js.map +1 -0
- package/build-module/components/grid/utils.js +131 -0
- package/build-module/components/grid/utils.js.map +1 -0
- package/build-module/components/image-editor/aspect-ratio-dropdown.js +0 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +1 -1
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/rich-text/event-listeners/input-rules.js +1 -1
- package/build-module/components/rich-text/event-listeners/input-rules.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +11 -5
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/native/index.native.js +14 -0
- package/build-module/components/rich-text/native/index.native.js.map +1 -1
- package/build-module/hooks/block-style-variation.js +25 -7
- package/build-module/hooks/block-style-variation.js.map +1 -1
- package/build-module/hooks/layout-child.js +27 -19
- package/build-module/hooks/layout-child.js.map +1 -1
- package/build-module/hooks/utils.js +3 -2
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/grid.js +24 -47
- package/build-module/layouts/grid.js.map +1 -1
- package/build-module/lock-unlock.js +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/store/actions.js +17 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-style/style-rtl.css +39 -18
- package/build-style/style.css +39 -18
- package/package.json +31 -31
- package/src/components/block-lock/modal.js +95 -82
- package/src/components/block-lock/style.scss +11 -1
- package/src/components/block-mover/index.js +37 -24
- package/src/components/block-toolbar/shuffle.js +3 -1
- package/src/components/child-layout-control/index.js +224 -159
- package/src/components/global-styles/test/use-global-styles-output.js +38 -3
- package/src/components/global-styles/use-global-styles-output.js +4 -3
- package/src/components/grid/grid-item-movers.js +128 -0
- package/src/components/{grid-visualizer → grid}/grid-item-resizer.js +14 -52
- package/src/components/grid/grid-visualizer.js +267 -0
- package/src/components/grid/index.js +4 -0
- package/src/components/grid/style.scss +63 -0
- package/src/components/grid/use-get-number-of-blocks-before-cell.js +30 -0
- package/src/components/grid/use-grid-layout-sync.js +167 -0
- package/src/components/grid/utils.js +178 -0
- package/src/components/image-editor/aspect-ratio-dropdown.js +0 -1
- package/src/components/inner-blocks/index.js +3 -1
- package/src/components/rich-text/event-listeners/input-rules.js +1 -1
- package/src/components/rich-text/index.native.js +10 -8
- package/src/components/rich-text/native/index.native.js +17 -0
- package/src/hooks/block-style-variation.js +24 -6
- package/src/hooks/layout-child.js +34 -14
- package/src/hooks/utils.js +3 -1
- package/src/layouts/grid.js +54 -62
- package/src/lock-unlock.js +1 -1
- package/src/store/actions.js +21 -1
- package/src/style.scss +1 -1
- package/build/components/grid-visualizer/grid-item-resizer.js.map +0 -1
- package/build/components/grid-visualizer/grid-visualizer.js +0 -92
- package/build/components/grid-visualizer/grid-visualizer.js.map +0 -1
- package/build/components/grid-visualizer/index.js.map +0 -1
- package/build/components/grid-visualizer/utils.js +0 -10
- package/build/components/grid-visualizer/utils.js.map +0 -1
- package/build-module/components/grid-visualizer/grid-item-resizer.js.map +0 -1
- package/build-module/components/grid-visualizer/grid-visualizer.js +0 -84
- package/build-module/components/grid-visualizer/grid-visualizer.js.map +0 -1
- package/build-module/components/grid-visualizer/index.js +0 -3
- package/build-module/components/grid-visualizer/index.js.map +0 -1
- package/build-module/components/grid-visualizer/utils.js +0 -4
- package/build-module/components/grid-visualizer/utils.js.map +0 -1
- package/src/components/grid-visualizer/grid-visualizer.js +0 -101
- package/src/components/grid-visualizer/index.js +0 -2
- package/src/components/grid-visualizer/style.scss +0 -34
- package/src/components/grid-visualizer/utils.js +0 -5
- /package/src/components/font-sizes/{README.MD → README.md} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 13.2.0 (2024-06-26)
|
|
6
|
+
|
|
5
7
|
## 13.1.0 (2024-06-15)
|
|
6
8
|
|
|
7
9
|
## 13.0.0 (2024-05-31)
|
|
@@ -80,7 +82,7 @@
|
|
|
80
82
|
|
|
81
83
|
- Add `HeadingLevelDropdown` component for selecting H1-H6 and paragraph HTML tags from the block toolbar.
|
|
82
84
|
|
|
83
|
-
### Bug
|
|
85
|
+
### Bug Fixes
|
|
84
86
|
|
|
85
87
|
- Fluid typography: custom font-sizes should use max viewport width ([#51516](https://github.com/WordPress/gutenberg/pull/51516)).
|
|
86
88
|
|
|
@@ -108,13 +110,13 @@
|
|
|
108
110
|
|
|
109
111
|
## 11.5.0 (2023-03-01)
|
|
110
112
|
|
|
111
|
-
### Bug
|
|
113
|
+
### Bug Fixes
|
|
112
114
|
|
|
113
115
|
- `SpacingSizesControl`: fix white dot on thumb ([#48574](https://github.com/WordPress/gutenberg/pull/48574)).
|
|
114
116
|
|
|
115
117
|
## 11.4.0 (2023-02-15)
|
|
116
118
|
|
|
117
|
-
### Bug
|
|
119
|
+
### Bug Fixes
|
|
118
120
|
|
|
119
121
|
- `LinkControl`: fix scrollbar displayed on toggle link settings ([#47986](https://github.com/WordPress/gutenberg/pull/47986)).
|
|
120
122
|
|
|
@@ -122,7 +124,7 @@
|
|
|
122
124
|
|
|
123
125
|
## 11.2.0 (2023-01-11)
|
|
124
126
|
|
|
125
|
-
### Bug
|
|
127
|
+
### Bug Fixes
|
|
126
128
|
|
|
127
129
|
- `BlockInspector`: Fix browser warning error when block is not selected ([#46875](https://github.com/WordPress/gutenberg/pull/46875)).
|
|
128
130
|
- Move component styles needed for iframes to content styles ([#47103](https://github.com/WordPress/gutenberg/pull/47103)).
|
|
@@ -143,33 +145,33 @@
|
|
|
143
145
|
- Fluid typography: add configurable fluid typography settings for minimum font size to theme.json ([#42489](https://github.com/WordPress/gutenberg/pull/42489)).
|
|
144
146
|
- `URLInput`: Add `__nextHasNoMarginBottom` prop for opting into the new margin-free styles ([46692](https://github.com/WordPress/gutenberg/pull/46692)).
|
|
145
147
|
|
|
146
|
-
### Bug
|
|
148
|
+
### Bug Fixes
|
|
147
149
|
|
|
148
150
|
- `SpacingSizesControl`: Change ARIA role from `region` to `group` to avoid unwanted ARIA landmark regions ([#46530](https://github.com/WordPress/gutenberg/pull/46530)).
|
|
149
151
|
- `FocalPointPicker`: Fix layout misalignment when placed in the `BlockInspector` ([#46631](https://github.com/WordPress/gutenberg/pull/46631)).
|
|
150
152
|
|
|
151
153
|
## 10.5.0 (2022-11-16)
|
|
152
154
|
|
|
153
|
-
###
|
|
155
|
+
### Enhancements
|
|
154
156
|
|
|
155
157
|
- `BlockLockModal`: Move Icon component out of CheckboxControl label ([#45535](https://github.com/WordPress/gutenberg/pull/45535))
|
|
156
158
|
- Fluid typography: adjust font size min and max rules ([#45536](https://github.com/WordPress/gutenberg/pull/45536)).
|
|
157
159
|
|
|
158
160
|
## 10.4.0 (2022-11-02)
|
|
159
161
|
|
|
160
|
-
### Bug
|
|
162
|
+
### Bug Fixes
|
|
161
163
|
|
|
162
164
|
- `InserterListItem`: Fix dragging and dropping in Firefox. ([#44631](https://github.com/WordPress/gutenberg/pull/44631))
|
|
163
165
|
|
|
164
166
|
## 10.3.0 (2022-10-19)
|
|
165
167
|
|
|
166
|
-
### Bug
|
|
168
|
+
### Bug Fixes
|
|
167
169
|
|
|
168
170
|
- `FontSizePicker`: Update fluid utils so that only string, floats and integers are treated as valid font sizes for the purposes of fluid typography ([#44847](https://github.com/WordPress/gutenberg/pull/44847))
|
|
169
171
|
- `getTypographyClassesAndStyles()`: Ensure that font sizes are transformed into fluid values if fluid typography is activated ([#44852](https://github.com/WordPress/gutenberg/pull/44852))
|
|
170
172
|
- `BlockPopover`: Ensure that padding and margin visualizers display in correct position even when scrolling past block. ([#44998](https://github.com/WordPress/gutenberg/pull/44998))
|
|
171
173
|
|
|
172
|
-
### New
|
|
174
|
+
### New Features
|
|
173
175
|
|
|
174
176
|
- You can now drop files/blocks/HTML on unmodified default blocks to transform them into corresponding blocks ([#44647](https://github.com/WordPress/gutenberg/pull/44647)).
|
|
175
177
|
|
|
@@ -179,7 +181,7 @@
|
|
|
179
181
|
|
|
180
182
|
## 10.0.0 (2022-09-13)
|
|
181
183
|
|
|
182
|
-
### Breaking
|
|
184
|
+
### Breaking Changes
|
|
183
185
|
|
|
184
186
|
- `FontSizePicker`: Deprecate bottom margin style. Add a `__nextHasNoMarginBottom` prop to start opting into the margin-free styles that will become the default in a future version, currently scheduled to be WordPress 6.4 ([#43870](https://github.com/WordPress/gutenberg/pull/43870)).
|
|
185
187
|
|
|
@@ -195,7 +197,7 @@
|
|
|
195
197
|
|
|
196
198
|
## 9.3.0 (2022-06-15)
|
|
197
199
|
|
|
198
|
-
### Bug
|
|
200
|
+
### Bug Fixes
|
|
199
201
|
|
|
200
202
|
- Fix focus trap on certain `input` elements when navigating within a block with the left/right arrow keys ([#41538](https://github.com/WordPress/gutenberg/pull/41538)).
|
|
201
203
|
|
|
@@ -205,7 +207,7 @@
|
|
|
205
207
|
|
|
206
208
|
## 9.0.0 (2022-05-04)
|
|
207
209
|
|
|
208
|
-
### Breaking
|
|
210
|
+
### Breaking Changes
|
|
209
211
|
|
|
210
212
|
- `BlockNavigationDropdown` is now deprecated. Use the `Dropdown` component from the `@wordpress/components` package and the `ListView` component from this package ([#40777](https://github.com/WordPress/gutenberg/pull/40777)).
|
|
211
213
|
- `ListView` no longer accepts the `__experimentalFeatures`, `__experimentalPersistentListViewFeatures`, `__experimentalHideContainerBlockActions`, and `showNestedBlocks` props. Passing additional undocumented props through to `ListView` is also now disallowed. ([#40777](https://github.com/WordPress/gutenberg/pull/40777)).
|
|
@@ -226,7 +228,7 @@
|
|
|
226
228
|
|
|
227
229
|
## 8.1.1 (2022-02-10)
|
|
228
230
|
|
|
229
|
-
### Bug
|
|
231
|
+
### Bug Fixes
|
|
230
232
|
|
|
231
233
|
- Removed unused `@wordpress/block-serialization-default-parser`, `css-mediaquery`, `memize` and `redux-multi` dependencies ([#38388](https://github.com/WordPress/gutenberg/pull/38388)).
|
|
232
234
|
|
|
@@ -243,13 +245,13 @@
|
|
|
243
245
|
- Avoid re-rendering all List View items on block focus [#35706](https://github.com/WordPress/gutenberg/pull/35706). When List View is open Block focus time is 4 times faster in large posts.
|
|
244
246
|
- Render fixed number of items in List View [#35706](https://github.com/WordPress/gutenberg/pull/35230). Opening List View is 13 times faster in large posts.
|
|
245
247
|
|
|
246
|
-
### Breaking
|
|
248
|
+
### Breaking Changes
|
|
247
249
|
|
|
248
250
|
- List View no longer supports the `showOnlyCurrentHierarchy` flag [#35706](https://github.com/WordPress/gutenberg/pull/35706). To display a subset of blocks, use the `blocks` parameter instead.
|
|
249
251
|
|
|
250
252
|
## 7.0.0 (2021-07-29)
|
|
251
253
|
|
|
252
|
-
### Breaking
|
|
254
|
+
### Breaking Changes
|
|
253
255
|
|
|
254
256
|
- Upgraded React components to work with v17.0 ([#29118](https://github.com/WordPress/gutenberg/pull/29118)). There are no new features in React v17.0 as explained in the [blog post](https://reactjs.org/blog/2020/10/20/react-v17.html).
|
|
255
257
|
|
|
@@ -274,7 +276,7 @@
|
|
|
274
276
|
|
|
275
277
|
## 5.2.0 (2020-12-17)
|
|
276
278
|
|
|
277
|
-
### New
|
|
279
|
+
### New Features
|
|
278
280
|
|
|
279
281
|
- Added a store definition `store` for the block editor namespace to use with `@wordpress/data` API ([#26655](https://github.com/WordPress/gutenberg/pull/26655)).
|
|
280
282
|
|
|
@@ -303,7 +305,7 @@
|
|
|
303
305
|
|
|
304
306
|
- Added a `label` prop to `URLInput`. This allows the label to be set without needing to wrap the `URLInput` in a `BaseControl`.
|
|
305
307
|
|
|
306
|
-
###
|
|
308
|
+
### Deprecations
|
|
307
309
|
|
|
308
310
|
- `dropZoneUIOnly` prop in `MediaPlaceholder` component has been deprecated in favor of `disableMediaButtons` prop.
|
|
309
311
|
|
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ In this example, we're instantiating a block editor. A block editor is composed
|
|
|
45
45
|
|
|
46
46
|
Inside `BlockEditorProvider`, you can nest any of the available `@wordpress/block-editor` UI components to build the UI of your editor.
|
|
47
47
|
|
|
48
|
-
In the example above we're rendering the `BlockList` to show and edit the block list. For instance we could add a custom sidebar and use the `BlockInspector` component to be able to edit the advanced settings for the currently selected block. (See the [API](#
|
|
48
|
+
In the example above we're rendering the `BlockList` to show and edit the block list. For instance we could add a custom sidebar and use the `BlockInspector` component to be able to edit the advanced settings for the currently selected block. (See the [API](#api) for the list of all the available components).
|
|
49
49
|
|
|
50
50
|
The `BlockTools` component is used to render the toolbar for a selected block.
|
|
51
51
|
|
|
@@ -9,7 +9,6 @@ var _i18n = require("@wordpress/i18n");
|
|
|
9
9
|
var _element = require("@wordpress/element");
|
|
10
10
|
var _components = require("@wordpress/components");
|
|
11
11
|
var _icons = require("@wordpress/icons");
|
|
12
|
-
var _compose = require("@wordpress/compose");
|
|
13
12
|
var _data = require("@wordpress/data");
|
|
14
13
|
var _blocks = require("@wordpress/blocks");
|
|
15
14
|
var _useBlockLock = _interopRequireDefault(require("./use-block-lock"));
|
|
@@ -73,7 +72,6 @@ function BlockLockModal({
|
|
|
73
72
|
updateBlockAttributes
|
|
74
73
|
} = (0, _data.useDispatch)(_store.store);
|
|
75
74
|
const blockInformation = (0, _useBlockDisplayInformation.default)(clientId);
|
|
76
|
-
const instanceId = (0, _compose.useInstanceId)(BlockLockModal, 'block-editor-block-lock-modal__options-title');
|
|
77
75
|
(0, _element.useEffect)(() => {
|
|
78
76
|
setLock({
|
|
79
77
|
move: !canMove,
|
|
@@ -85,14 +83,12 @@ function BlockLockModal({
|
|
|
85
83
|
}, [canEdit, canMove, canRemove, allowsEditLocking]);
|
|
86
84
|
const isAllChecked = Object.values(lock).every(Boolean);
|
|
87
85
|
const isMixed = Object.values(lock).some(Boolean) && !isAllChecked;
|
|
88
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
86
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Modal, {
|
|
89
87
|
title: (0, _i18n.sprintf)( /* translators: %s: Name of the block. */
|
|
90
88
|
(0, _i18n.__)('Lock %s'), blockInformation.title),
|
|
91
89
|
overlayClassName: "block-editor-block-lock-modal",
|
|
92
90
|
onRequestClose: onClose,
|
|
93
|
-
children:
|
|
94
|
-
children: (0, _i18n.__)('Choose specific attributes to restrict or lock all available options.')
|
|
95
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("form", {
|
|
91
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("form", {
|
|
96
92
|
onSubmit: event => {
|
|
97
93
|
event.preventDefault();
|
|
98
94
|
updateBlockAttributes([clientId], {
|
|
@@ -101,71 +97,75 @@ function BlockLockModal({
|
|
|
101
97
|
});
|
|
102
98
|
onClose();
|
|
103
99
|
},
|
|
104
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("
|
|
105
|
-
role: "group",
|
|
106
|
-
"aria-labelledby": instanceId,
|
|
100
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("fieldset", {
|
|
107
101
|
className: "block-editor-block-lock-modal__options",
|
|
108
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
id: instanceId,
|
|
113
|
-
children: (0, _i18n.__)('Lock all')
|
|
114
|
-
}),
|
|
115
|
-
checked: isAllChecked,
|
|
116
|
-
indeterminate: isMixed,
|
|
117
|
-
onChange: newValue => setLock({
|
|
118
|
-
move: newValue,
|
|
119
|
-
remove: newValue,
|
|
120
|
-
...(allowsEditLocking ? {
|
|
121
|
-
edit: newValue
|
|
122
|
-
} : {})
|
|
123
|
-
})
|
|
124
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("ul", {
|
|
102
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("legend", {
|
|
103
|
+
children: (0, _i18n.__)('Choose specific attributes to restrict or lock all available options.')
|
|
104
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("ul", {
|
|
105
|
+
role: "list",
|
|
125
106
|
className: "block-editor-block-lock-modal__checklist",
|
|
126
|
-
children:
|
|
127
|
-
className: "block-editor-block-lock-modal__checklist-item",
|
|
128
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.CheckboxControl, {
|
|
129
|
-
__nextHasNoMarginBottom: true,
|
|
130
|
-
label: (0, _i18n.__)('Restrict editing'),
|
|
131
|
-
checked: !!lock.edit,
|
|
132
|
-
onChange: edit => setLock(prevLock => ({
|
|
133
|
-
...prevLock,
|
|
134
|
-
edit
|
|
135
|
-
}))
|
|
136
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Icon, {
|
|
137
|
-
className: "block-editor-block-lock-modal__lock-icon",
|
|
138
|
-
icon: lock.edit ? _icons.lock : _icons.unlock
|
|
139
|
-
})]
|
|
140
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("li", {
|
|
141
|
-
className: "block-editor-block-lock-modal__checklist-item",
|
|
107
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("li", {
|
|
142
108
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.CheckboxControl, {
|
|
143
109
|
__nextHasNoMarginBottom: true,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
110
|
+
className: "block-editor-block-lock-modal__options-all",
|
|
111
|
+
label: (0, _i18n.__)('Lock all'),
|
|
112
|
+
checked: isAllChecked,
|
|
113
|
+
indeterminate: isMixed,
|
|
114
|
+
onChange: newValue => setLock({
|
|
115
|
+
move: newValue,
|
|
116
|
+
remove: newValue,
|
|
117
|
+
...(allowsEditLocking ? {
|
|
118
|
+
edit: newValue
|
|
119
|
+
} : {})
|
|
120
|
+
})
|
|
121
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("ul", {
|
|
122
|
+
role: "list",
|
|
123
|
+
className: "block-editor-block-lock-modal__checklist",
|
|
124
|
+
children: [allowsEditLocking && /*#__PURE__*/(0, _jsxRuntime.jsxs)("li", {
|
|
125
|
+
className: "block-editor-block-lock-modal__checklist-item",
|
|
126
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.CheckboxControl, {
|
|
127
|
+
__nextHasNoMarginBottom: true,
|
|
128
|
+
label: (0, _i18n.__)('Restrict editing'),
|
|
129
|
+
checked: !!lock.edit,
|
|
130
|
+
onChange: edit => setLock(prevLock => ({
|
|
131
|
+
...prevLock,
|
|
132
|
+
edit
|
|
133
|
+
}))
|
|
134
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Icon, {
|
|
135
|
+
className: "block-editor-block-lock-modal__lock-icon",
|
|
136
|
+
icon: lock.edit ? _icons.lock : _icons.unlock
|
|
137
|
+
})]
|
|
138
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("li", {
|
|
139
|
+
className: "block-editor-block-lock-modal__checklist-item",
|
|
140
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.CheckboxControl, {
|
|
141
|
+
__nextHasNoMarginBottom: true,
|
|
142
|
+
label: (0, _i18n.__)('Disable movement'),
|
|
143
|
+
checked: lock.move,
|
|
144
|
+
onChange: move => setLock(prevLock => ({
|
|
145
|
+
...prevLock,
|
|
146
|
+
move
|
|
147
|
+
}))
|
|
148
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Icon, {
|
|
149
|
+
className: "block-editor-block-lock-modal__lock-icon",
|
|
150
|
+
icon: lock.move ? _icons.lock : _icons.unlock
|
|
151
|
+
})]
|
|
152
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("li", {
|
|
153
|
+
className: "block-editor-block-lock-modal__checklist-item",
|
|
154
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.CheckboxControl, {
|
|
155
|
+
__nextHasNoMarginBottom: true,
|
|
156
|
+
label: (0, _i18n.__)('Prevent removal'),
|
|
157
|
+
checked: lock.remove,
|
|
158
|
+
onChange: remove => setLock(prevLock => ({
|
|
159
|
+
...prevLock,
|
|
160
|
+
remove
|
|
161
|
+
}))
|
|
162
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Icon, {
|
|
163
|
+
className: "block-editor-block-lock-modal__lock-icon",
|
|
164
|
+
icon: lock.remove ? _icons.lock : _icons.unlock
|
|
165
|
+
})]
|
|
166
|
+
})]
|
|
153
167
|
})]
|
|
154
|
-
})
|
|
155
|
-
className: "block-editor-block-lock-modal__checklist-item",
|
|
156
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.CheckboxControl, {
|
|
157
|
-
__nextHasNoMarginBottom: true,
|
|
158
|
-
label: (0, _i18n.__)('Prevent removal'),
|
|
159
|
-
checked: lock.remove,
|
|
160
|
-
onChange: remove => setLock(prevLock => ({
|
|
161
|
-
...prevLock,
|
|
162
|
-
remove
|
|
163
|
-
}))
|
|
164
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Icon, {
|
|
165
|
-
className: "block-editor-block-lock-modal__lock-icon",
|
|
166
|
-
icon: lock.remove ? _icons.lock : _icons.unlock
|
|
167
|
-
})]
|
|
168
|
-
})]
|
|
168
|
+
})
|
|
169
169
|
}), hasTemplateLock && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToggleControl, {
|
|
170
170
|
__nextHasNoMarginBottom: true,
|
|
171
171
|
className: "block-editor-block-lock-modal__template-lock",
|
|
@@ -192,7 +192,7 @@ function BlockLockModal({
|
|
|
192
192
|
})
|
|
193
193
|
})]
|
|
194
194
|
})]
|
|
195
|
-
})
|
|
195
|
+
})
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
198
|
//# sourceMappingURL=modal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_element","_components","_icons","_compose","_data","_blocks","_useBlockLock","_interopRequireDefault","_useBlockDisplayInformation","_store","_jsxRuntime","ALLOWS_EDIT_LOCKING","getTemplateLockValue","lock","remove","move","BlockLockModal","clientId","onClose","setLock","useState","canEdit","canMove","canRemove","useBlockLock","allowsEditLocking","templateLock","hasTemplateLock","useSelect","select","getBlockName","getBlockAttributes","blockEditorStore","blockName","blockType","getBlockType","includes","attributes","applyTemplateLock","setApplyTemplateLock","updateBlockAttributes","useDispatch","blockInformation","useBlockDisplayInformation","instanceId","useInstanceId","useEffect","edit","isAllChecked","Object","values","every","Boolean","isMixed","some","jsxs","Modal","title","sprintf","__","overlayClassName","onRequestClose","children","jsx","onSubmit","event","preventDefault","undefined","role","className","CheckboxControl","__nextHasNoMarginBottom","label","id","checked","indeterminate","onChange","newValue","prevLock","Icon","icon","lockIcon","unlockIcon","ToggleControl","disabled","Flex","justify","expanded","FlexItem","Button","variant","onClick","type"],"sources":["@wordpress/block-editor/src/components/block-lock/modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useEffect, useState } from '@wordpress/element';\nimport {\n\tButton,\n\tCheckboxControl,\n\tFlex,\n\tFlexItem,\n\tIcon,\n\tModal,\n\tToggleControl,\n} from '@wordpress/components';\nimport { lock as lockIcon, unlock as unlockIcon } from '@wordpress/icons';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { getBlockType } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport useBlockLock from './use-block-lock';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { store as blockEditorStore } from '../../store';\n\n// Entity based blocks which allow edit locking\nconst ALLOWS_EDIT_LOCKING = [ 'core/block', 'core/navigation' ];\n\nfunction getTemplateLockValue( lock ) {\n\t// Prevents all operations.\n\tif ( lock.remove && lock.move ) {\n\t\treturn 'all';\n\t}\n\n\t// Prevents inserting or removing blocks, but allows moving existing blocks.\n\tif ( lock.remove && ! lock.move ) {\n\t\treturn 'insert';\n\t}\n\n\treturn false;\n}\n\nexport default function BlockLockModal( { clientId, onClose } ) {\n\tconst [ lock, setLock ] = useState( { move: false, remove: false } );\n\tconst { canEdit, canMove, canRemove } = useBlockLock( clientId );\n\tconst { allowsEditLocking, templateLock, hasTemplateLock } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockName, getBlockAttributes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( blockName );\n\n\t\t\treturn {\n\t\t\t\tallowsEditLocking: ALLOWS_EDIT_LOCKING.includes( blockName ),\n\t\t\t\ttemplateLock: getBlockAttributes( clientId )?.templateLock,\n\t\t\t\thasTemplateLock: !! blockType?.attributes?.templateLock,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst [ applyTemplateLock, setApplyTemplateLock ] = useState(\n\t\t!! templateLock\n\t);\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst instanceId = useInstanceId(\n\t\tBlockLockModal,\n\t\t'block-editor-block-lock-modal__options-title'\n\t);\n\n\tuseEffect( () => {\n\t\tsetLock( {\n\t\t\tmove: ! canMove,\n\t\t\tremove: ! canRemove,\n\t\t\t...( allowsEditLocking ? { edit: ! canEdit } : {} ),\n\t\t} );\n\t}, [ canEdit, canMove, canRemove, allowsEditLocking ] );\n\n\tconst isAllChecked = Object.values( lock ).every( Boolean );\n\tconst isMixed = Object.values( lock ).some( Boolean ) && ! isAllChecked;\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ sprintf(\n\t\t\t\t/* translators: %s: Name of the block. */\n\t\t\t\t__( 'Lock %s' ),\n\t\t\t\tblockInformation.title\n\t\t\t) }\n\t\t\toverlayClassName=\"block-editor-block-lock-modal\"\n\t\t\tonRequestClose={ onClose }\n\t\t>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'Choose specific attributes to restrict or lock all available options.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<form\n\t\t\t\tonSubmit={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tupdateBlockAttributes( [ clientId ], {\n\t\t\t\t\t\tlock,\n\t\t\t\t\t\ttemplateLock: applyTemplateLock\n\t\t\t\t\t\t\t? getTemplateLockValue( lock )\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t} );\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\trole=\"group\"\n\t\t\t\t\taria-labelledby={ instanceId }\n\t\t\t\t\tclassName=\"block-editor-block-lock-modal__options\"\n\t\t\t\t>\n\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__options-title\"\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t<span id={ instanceId }>{ __( 'Lock all' ) }</span>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tchecked={ isAllChecked }\n\t\t\t\t\t\tindeterminate={ isMixed }\n\t\t\t\t\t\tonChange={ ( newValue ) =>\n\t\t\t\t\t\t\tsetLock( {\n\t\t\t\t\t\t\t\tmove: newValue,\n\t\t\t\t\t\t\t\tremove: newValue,\n\t\t\t\t\t\t\t\t...( allowsEditLocking\n\t\t\t\t\t\t\t\t\t? { edit: newValue }\n\t\t\t\t\t\t\t\t\t: {} ),\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t<ul className=\"block-editor-block-lock-modal__checklist\">\n\t\t\t\t\t\t{ allowsEditLocking && (\n\t\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Restrict editing' ) }\n\t\t\t\t\t\t\t\t\tchecked={ !! lock.edit }\n\t\t\t\t\t\t\t\t\tonChange={ ( edit ) =>\n\t\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\t\tedit,\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\t<Icon\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__lock-icon\"\n\t\t\t\t\t\t\t\t\ticon={ lock.edit ? lockIcon : unlockIcon }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Disable movement' ) }\n\t\t\t\t\t\t\t\tchecked={ lock.move }\n\t\t\t\t\t\t\t\tonChange={ ( move ) =>\n\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\tmove,\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\t<Icon\n\t\t\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__lock-icon\"\n\t\t\t\t\t\t\t\ticon={ lock.move ? lockIcon : unlockIcon }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Prevent removal' ) }\n\t\t\t\t\t\t\t\tchecked={ lock.remove }\n\t\t\t\t\t\t\t\tonChange={ ( remove ) =>\n\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\tremove,\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\t<Icon\n\t\t\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__lock-icon\"\n\t\t\t\t\t\t\t\ticon={ lock.remove ? lockIcon : unlockIcon }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t</ul>\n\t\t\t\t\t{ hasTemplateLock && (\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__template-lock\"\n\t\t\t\t\t\t\tlabel={ __( 'Apply to all blocks inside' ) }\n\t\t\t\t\t\t\tchecked={ applyTemplateLock }\n\t\t\t\t\t\t\tdisabled={ lock.move && ! lock.remove }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetApplyTemplateLock( ! applyTemplateLock )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t<Flex\n\t\t\t\t\tclassName=\"block-editor-block-lock-modal__actions\"\n\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\texpanded={ false }\n\t\t\t\t>\n\t\t\t\t\t<FlexItem>\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\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button variant=\"primary\" type=\"submit\">\n\t\t\t\t\t\t\t{ __( 'Apply' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AASA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA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C9D,WAAA,CAAAuF,QAAQ;UAAA1B,QAAA,eACR,IAAApD,WAAA,CAAAqD,GAAA,EAAC9D,WAAA,CAAAwF,MAAM;YAACC,OAAO,EAAC,SAAS;YAACE,IAAI,EAAC,QAAQ;YAAA9B,QAAA,EACpC,IAAAH,QAAE,EAAE,OAAQ;UAAC,CACR;QAAC,CACA,CAAC;MAAA,CACN,CAAC;IAAA,CACF,CAAC;EAAA,CACD,CAAC;AAEV","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_i18n","require","_element","_components","_icons","_data","_blocks","_useBlockLock","_interopRequireDefault","_useBlockDisplayInformation","_store","_jsxRuntime","ALLOWS_EDIT_LOCKING","getTemplateLockValue","lock","remove","move","BlockLockModal","clientId","onClose","setLock","useState","canEdit","canMove","canRemove","useBlockLock","allowsEditLocking","templateLock","hasTemplateLock","useSelect","select","getBlockName","getBlockAttributes","blockEditorStore","blockName","blockType","getBlockType","includes","attributes","applyTemplateLock","setApplyTemplateLock","updateBlockAttributes","useDispatch","blockInformation","useBlockDisplayInformation","useEffect","edit","isAllChecked","Object","values","every","Boolean","isMixed","some","jsx","Modal","title","sprintf","__","overlayClassName","onRequestClose","children","jsxs","onSubmit","event","preventDefault","undefined","className","role","CheckboxControl","__nextHasNoMarginBottom","label","checked","indeterminate","onChange","newValue","prevLock","Icon","icon","lockIcon","unlockIcon","ToggleControl","disabled","Flex","justify","expanded","FlexItem","Button","variant","onClick","type"],"sources":["@wordpress/block-editor/src/components/block-lock/modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useEffect, useState } from '@wordpress/element';\nimport {\n\tButton,\n\tCheckboxControl,\n\tFlex,\n\tFlexItem,\n\tIcon,\n\tModal,\n\tToggleControl,\n} from '@wordpress/components';\nimport { lock as lockIcon, unlock as unlockIcon } from '@wordpress/icons';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { getBlockType } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport useBlockLock from './use-block-lock';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { store as blockEditorStore } from '../../store';\n\n// Entity based blocks which allow edit locking\nconst ALLOWS_EDIT_LOCKING = [ 'core/block', 'core/navigation' ];\n\nfunction getTemplateLockValue( lock ) {\n\t// Prevents all operations.\n\tif ( lock.remove && lock.move ) {\n\t\treturn 'all';\n\t}\n\n\t// Prevents inserting or removing blocks, but allows moving existing blocks.\n\tif ( lock.remove && ! lock.move ) {\n\t\treturn 'insert';\n\t}\n\n\treturn false;\n}\n\nexport default function BlockLockModal( { clientId, onClose } ) {\n\tconst [ lock, setLock ] = useState( { move: false, remove: false } );\n\tconst { canEdit, canMove, canRemove } = useBlockLock( clientId );\n\tconst { allowsEditLocking, templateLock, hasTemplateLock } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockName, getBlockAttributes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( blockName );\n\n\t\t\treturn {\n\t\t\t\tallowsEditLocking: ALLOWS_EDIT_LOCKING.includes( blockName ),\n\t\t\t\ttemplateLock: getBlockAttributes( clientId )?.templateLock,\n\t\t\t\thasTemplateLock: !! blockType?.attributes?.templateLock,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst [ applyTemplateLock, setApplyTemplateLock ] = useState(\n\t\t!! templateLock\n\t);\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\n\tuseEffect( () => {\n\t\tsetLock( {\n\t\t\tmove: ! canMove,\n\t\t\tremove: ! canRemove,\n\t\t\t...( allowsEditLocking ? { edit: ! canEdit } : {} ),\n\t\t} );\n\t}, [ canEdit, canMove, canRemove, allowsEditLocking ] );\n\n\tconst isAllChecked = Object.values( lock ).every( Boolean );\n\tconst isMixed = Object.values( lock ).some( Boolean ) && ! isAllChecked;\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ sprintf(\n\t\t\t\t/* translators: %s: Name of the block. */\n\t\t\t\t__( 'Lock %s' ),\n\t\t\t\tblockInformation.title\n\t\t\t) }\n\t\t\toverlayClassName=\"block-editor-block-lock-modal\"\n\t\t\tonRequestClose={ onClose }\n\t\t>\n\t\t\t<form\n\t\t\t\tonSubmit={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tupdateBlockAttributes( [ clientId ], {\n\t\t\t\t\t\tlock,\n\t\t\t\t\t\ttemplateLock: applyTemplateLock\n\t\t\t\t\t\t\t? getTemplateLockValue( lock )\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t} );\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<fieldset className=\"block-editor-block-lock-modal__options\">\n\t\t\t\t\t<legend>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Choose specific attributes to restrict or lock all available options.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</legend>\n\t\t\t\t\t{ /*\n\t\t\t\t\t * Disable reason: The `list` ARIA role is redundant but\n\t\t\t\t\t * Safari+VoiceOver won't announce the list otherwise.\n\t\t\t\t\t */\n\t\t\t\t\t/* eslint-disable jsx-a11y/no-redundant-roles */ }\n\t\t\t\t\t<ul\n\t\t\t\t\t\trole=\"list\"\n\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__checklist\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__options-all\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Lock all' ) }\n\t\t\t\t\t\t\t\tchecked={ isAllChecked }\n\t\t\t\t\t\t\t\tindeterminate={ isMixed }\n\t\t\t\t\t\t\t\tonChange={ ( newValue ) =>\n\t\t\t\t\t\t\t\t\tsetLock( {\n\t\t\t\t\t\t\t\t\t\tmove: newValue,\n\t\t\t\t\t\t\t\t\t\tremove: newValue,\n\t\t\t\t\t\t\t\t\t\t...( allowsEditLocking\n\t\t\t\t\t\t\t\t\t\t\t? { edit: newValue }\n\t\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\t<ul\n\t\t\t\t\t\t\t\trole=\"list\"\n\t\t\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__checklist\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ allowsEditLocking && (\n\t\t\t\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Restrict editing' ) }\n\t\t\t\t\t\t\t\t\t\t\tchecked={ !! lock.edit }\n\t\t\t\t\t\t\t\t\t\t\tonChange={ ( edit ) =>\n\t\t\t\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\t\t\t\tedit,\n\t\t\t\t\t\t\t\t\t\t\t\t} ) )\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t/>\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-block-lock-modal__lock-icon\"\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\tlock.edit\n\t\t\t\t\t\t\t\t\t\t\t\t\t? lockIcon\n\t\t\t\t\t\t\t\t\t\t\t\t\t: unlockIcon\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Disable movement' ) }\n\t\t\t\t\t\t\t\t\t\tchecked={ lock.move }\n\t\t\t\t\t\t\t\t\t\tonChange={ ( move ) =>\n\t\t\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\t\t\tmove,\n\t\t\t\t\t\t\t\t\t\t\t} ) )\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\t<Icon\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__lock-icon\"\n\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\tlock.move ? lockIcon : unlockIcon\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</li>\n\t\t\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Prevent removal' ) }\n\t\t\t\t\t\t\t\t\t\tchecked={ lock.remove }\n\t\t\t\t\t\t\t\t\t\tonChange={ ( remove ) =>\n\t\t\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\t\t\tremove,\n\t\t\t\t\t\t\t\t\t\t\t} ) )\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\t<Icon\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__lock-icon\"\n\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\tlock.remove ? lockIcon : unlockIcon\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</li>\n\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t</ul>\n\t\t\t\t\t{ /* eslint-enable jsx-a11y/no-redundant-roles */ }\n\t\t\t\t\t{ hasTemplateLock && (\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__template-lock\"\n\t\t\t\t\t\t\tlabel={ __( 'Apply to all blocks inside' ) }\n\t\t\t\t\t\t\tchecked={ applyTemplateLock }\n\t\t\t\t\t\t\tdisabled={ lock.move && ! lock.remove }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetApplyTemplateLock( ! applyTemplateLock )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</fieldset>\n\t\t\t\t<Flex\n\t\t\t\t\tclassName=\"block-editor-block-lock-modal__actions\"\n\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\texpanded={ false }\n\t\t\t\t>\n\t\t\t\t\t<FlexItem>\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\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button variant=\"primary\" type=\"submit\">\n\t\t\t\t\t\t\t{ __( 'Apply' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"],"mapp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IAAAlD,WAAA,CAAA2C,GAAA,EAACnD,WAAA,CAAAoF,MAAM;YAACC,OAAO,EAAC,UAAU;YAACC,OAAO,EAAGtE,OAAS;YAAA0C,QAAA,EAC3C,IAAAH,QAAE,EAAE,QAAS;UAAC,CACT;QAAC,CACA,CAAC,eACX,IAAA/C,WAAA,CAAA2C,GAAA,EAACnD,WAAA,CAAAmF,QAAQ;UAAAzB,QAAA,eACR,IAAAlD,WAAA,CAAA2C,GAAA,EAACnD,WAAA,CAAAoF,MAAM;YAACC,OAAO,EAAC,SAAS;YAACE,IAAI,EAAC,QAAQ;YAAA7B,QAAA,EACpC,IAAAH,QAAE,EAAE,OAAQ;UAAC,CACR;QAAC,CACA,CAAC;MAAA,CACN,CAAC;IAAA,CACF;EAAC,CACD,CAAC;AAEV","ignoreList":[]}
|
|
@@ -37,14 +37,17 @@ function BlockMover({
|
|
|
37
37
|
rootClientId,
|
|
38
38
|
isFirst,
|
|
39
39
|
isLast,
|
|
40
|
-
orientation
|
|
40
|
+
orientation,
|
|
41
|
+
isManualGrid
|
|
41
42
|
} = (0, _data.useSelect)(select => {
|
|
43
|
+
var _getBlockAttributes;
|
|
42
44
|
const {
|
|
43
45
|
getBlockIndex,
|
|
44
46
|
getBlockListSettings,
|
|
45
47
|
canMoveBlocks,
|
|
46
48
|
getBlockOrder,
|
|
47
|
-
getBlockRootClientId
|
|
49
|
+
getBlockRootClientId,
|
|
50
|
+
getBlockAttributes
|
|
48
51
|
} = select(_store.store);
|
|
49
52
|
const normalizedClientIds = Array.isArray(clientIds) ? clientIds : [clientIds];
|
|
50
53
|
const firstClientId = normalizedClientIds[0];
|
|
@@ -52,18 +55,21 @@ function BlockMover({
|
|
|
52
55
|
const firstIndex = getBlockIndex(firstClientId);
|
|
53
56
|
const lastIndex = getBlockIndex(normalizedClientIds[normalizedClientIds.length - 1]);
|
|
54
57
|
const blockOrder = getBlockOrder(_rootClientId);
|
|
58
|
+
const {
|
|
59
|
+
layout = {}
|
|
60
|
+
} = (_getBlockAttributes = getBlockAttributes(_rootClientId)) !== null && _getBlockAttributes !== void 0 ? _getBlockAttributes : {};
|
|
55
61
|
return {
|
|
56
62
|
canMove: canMoveBlocks(clientIds),
|
|
57
63
|
rootClientId: _rootClientId,
|
|
58
64
|
isFirst: firstIndex === 0,
|
|
59
65
|
isLast: lastIndex === blockOrder.length - 1,
|
|
60
|
-
orientation: getBlockListSettings(_rootClientId)?.orientation
|
|
66
|
+
orientation: getBlockListSettings(_rootClientId)?.orientation,
|
|
67
|
+
isManualGrid: layout.type === 'grid' && !!layout.columnCount && window.__experimentalEnableGridInteractivity
|
|
61
68
|
};
|
|
62
69
|
}, [clientIds]);
|
|
63
70
|
if (!canMove || isFirst && isLast && !rootClientId) {
|
|
64
71
|
return null;
|
|
65
72
|
}
|
|
66
|
-
const dragHandleLabel = (0, _i18n.__)('Drag');
|
|
67
73
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.ToolbarGroup, {
|
|
68
74
|
className: (0, _clsx.default)('block-editor-block-mover', {
|
|
69
75
|
'is-horizontal': orientation === 'horizontal'
|
|
@@ -75,14 +81,14 @@ function BlockMover({
|
|
|
75
81
|
icon: _icons.dragHandle,
|
|
76
82
|
className: "block-editor-block-mover__drag-handle",
|
|
77
83
|
"aria-hidden": "true",
|
|
78
|
-
label:
|
|
84
|
+
label: (0, _i18n.__)('Drag')
|
|
79
85
|
// Should not be able to tab to drag handle as this
|
|
80
86
|
// button can only be used with a pointer device.
|
|
81
87
|
,
|
|
82
88
|
tabIndex: "-1",
|
|
83
89
|
...draggableProps
|
|
84
90
|
})
|
|
85
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
91
|
+
}), !isManualGrid && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
86
92
|
className: "block-editor-block-mover__move-button-container",
|
|
87
93
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToolbarItem, {
|
|
88
94
|
children: itemProps => /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.BlockMoverUpButton, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_icons","_components","_data","_i18n","_blockDraggable","_button","_store","_jsxRuntime","BlockMover","clientIds","hideDragHandle","isBlockMoverUpButtonDisabled","isBlockMoverDownButtonDisabled","canMove","rootClientId","isFirst","isLast","orientation","useSelect","select","getBlockIndex","getBlockListSettings","canMoveBlocks","getBlockOrder","getBlockRootClientId","blockEditorStore","normalizedClientIds","Array","isArray","firstClientId","_rootClientId","firstIndex","lastIndex","length","blockOrder","
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_icons","_components","_data","_i18n","_blockDraggable","_button","_store","_jsxRuntime","BlockMover","clientIds","hideDragHandle","isBlockMoverUpButtonDisabled","isBlockMoverDownButtonDisabled","canMove","rootClientId","isFirst","isLast","orientation","isManualGrid","useSelect","select","_getBlockAttributes","getBlockIndex","getBlockListSettings","canMoveBlocks","getBlockOrder","getBlockRootClientId","getBlockAttributes","blockEditorStore","normalizedClientIds","Array","isArray","firstClientId","_rootClientId","firstIndex","lastIndex","length","blockOrder","layout","type","columnCount","window","__experimentalEnableGridInteractivity","jsxs","ToolbarGroup","className","clsx","children","jsx","default","fadeWhenDisabled","draggableProps","Button","icon","dragHandle","label","__","tabIndex","ToolbarItem","itemProps","BlockMoverUpButton","disabled","BlockMoverDownButton","_default","exports"],"sources":["@wordpress/block-editor/src/components/block-mover/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\n\nimport { dragHandle } from '@wordpress/icons';\nimport { ToolbarGroup, ToolbarItem, Button } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockDraggable from '../block-draggable';\nimport { BlockMoverUpButton, BlockMoverDownButton } from './button';\nimport { store as blockEditorStore } from '../../store';\n\nfunction BlockMover( {\n\tclientIds,\n\thideDragHandle,\n\tisBlockMoverUpButtonDisabled,\n\tisBlockMoverDownButtonDisabled,\n} ) {\n\tconst {\n\t\tcanMove,\n\t\trootClientId,\n\t\tisFirst,\n\t\tisLast,\n\t\torientation,\n\t\tisManualGrid,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockIndex,\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tcanMoveBlocks,\n\t\t\t\tgetBlockOrder,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockAttributes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst normalizedClientIds = Array.isArray( clientIds )\n\t\t\t\t? clientIds\n\t\t\t\t: [ clientIds ];\n\t\t\tconst firstClientId = normalizedClientIds[ 0 ];\n\t\t\tconst _rootClientId = getBlockRootClientId( firstClientId );\n\t\t\tconst firstIndex = getBlockIndex( firstClientId );\n\t\t\tconst lastIndex = getBlockIndex(\n\t\t\t\tnormalizedClientIds[ normalizedClientIds.length - 1 ]\n\t\t\t);\n\t\t\tconst blockOrder = getBlockOrder( _rootClientId );\n\t\t\tconst { layout = {} } = getBlockAttributes( _rootClientId ) ?? {};\n\n\t\t\treturn {\n\t\t\t\tcanMove: canMoveBlocks( clientIds ),\n\t\t\t\trootClientId: _rootClientId,\n\t\t\t\tisFirst: firstIndex === 0,\n\t\t\t\tisLast: lastIndex === blockOrder.length - 1,\n\t\t\t\torientation: getBlockListSettings( _rootClientId )?.orientation,\n\t\t\t\tisManualGrid:\n\t\t\t\t\tlayout.type === 'grid' &&\n\t\t\t\t\t!! layout.columnCount &&\n\t\t\t\t\twindow.__experimentalEnableGridInteractivity,\n\t\t\t};\n\t\t},\n\t\t[ clientIds ]\n\t);\n\n\tif ( ! canMove || ( isFirst && isLast && ! rootClientId ) ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ToolbarGroup\n\t\t\tclassName={ clsx( 'block-editor-block-mover', {\n\t\t\t\t'is-horizontal': orientation === 'horizontal',\n\t\t\t} ) }\n\t\t>\n\t\t\t{ ! hideDragHandle && (\n\t\t\t\t<BlockDraggable clientIds={ clientIds } fadeWhenDisabled>\n\t\t\t\t\t{ ( draggableProps ) => (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\ticon={ dragHandle }\n\t\t\t\t\t\t\tclassName=\"block-editor-block-mover__drag-handle\"\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\tlabel={ __( 'Drag' ) }\n\t\t\t\t\t\t\t// Should not be able to tab to drag handle as this\n\t\t\t\t\t\t\t// button can only be used with a pointer device.\n\t\t\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t\t\t\t{ ...draggableProps }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</BlockDraggable>\n\t\t\t) }\n\t\t\t{ ! isManualGrid && (\n\t\t\t\t<div className=\"block-editor-block-mover__move-button-container\">\n\t\t\t\t\t<ToolbarItem>\n\t\t\t\t\t\t{ ( itemProps ) => (\n\t\t\t\t\t\t\t<BlockMoverUpButton\n\t\t\t\t\t\t\t\tdisabled={ isBlockMoverUpButtonDisabled }\n\t\t\t\t\t\t\t\tclientIds={ clientIds }\n\t\t\t\t\t\t\t\t{ ...itemProps }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ToolbarItem>\n\t\t\t\t\t<ToolbarItem>\n\t\t\t\t\t\t{ ( itemProps ) => (\n\t\t\t\t\t\t\t<BlockMoverDownButton\n\t\t\t\t\t\t\t\tdisabled={ isBlockMoverDownButtonDisabled }\n\t\t\t\t\t\t\t\tclientIds={ clientIds }\n\t\t\t\t\t\t\t\t{ ...itemProps }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ToolbarItem>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</ToolbarGroup>\n\t);\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/H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;MAAc,CACnB;IACD,CACc,CAChB,EACC,CAAEjC,YAAY,iBACf,IAAAX,WAAA,CAAAoC,IAAA;MAAKE,SAAS,EAAC,iDAAiD;MAAAE,QAAA,gBAC/D,IAAAxC,WAAA,CAAAyC,GAAA,EAAC/C,WAAA,CAAAyD,WAAW;QAAAX,QAAA,EACPY,SAAS,iBACZ,IAAApD,WAAA,CAAAyC,GAAA,EAAC3C,OAAA,CAAAuD,kBAAkB;UAClBC,QAAQ,EAAGlD,4BAA8B;UACzCF,SAAS,EAAGA,SAAW;UAAA,GAClBkD;QAAS,CACd;MACD,CACW,CAAC,eACd,IAAApD,WAAA,CAAAyC,GAAA,EAAC/C,WAAA,CAAAyD,WAAW;QAAAX,QAAA,EACPY,SAAS,iBACZ,IAAApD,WAAA,CAAAyC,GAAA,EAAC3C,OAAA,CAAAyD,oBAAoB;UACpBD,QAAQ,EAAGjD,8BAAgC;UAC3CH,SAAS,EAAGA,SAAW;UAAA,GAClBkD;QAAS,CACd;MACD,CACW,CAAC;IAAA,CACV,CACL;EAAA,CACY,CAAC;AAEjB;;AAEA;AACA;AACA;AAFA,IAAAI,QAAA,GAAAC,OAAA,CAAAf,OAAA,GAGezC,UAAU","ignoreList":[]}
|
|
@@ -65,7 +65,9 @@ function Shuffle({
|
|
|
65
65
|
// otherwise we may shuffle to pattern that will not allow to continue shuffling.
|
|
66
66
|
pattern.blocks.length === 1 && pattern.categories?.some(category => {
|
|
67
67
|
return categories.includes(category);
|
|
68
|
-
})
|
|
68
|
+
}) && (
|
|
69
|
+
// Check if the pattern is not a synced pattern.
|
|
70
|
+
pattern.syncStatus === 'unsynced' || !pattern.id)
|
|
69
71
|
);
|
|
70
72
|
});
|
|
71
73
|
}, [categories, patterns]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_icons","require","_components","_i18n","_element","_data","_store","_jsxRuntime","EMPTY_ARRAY","Container","props","jsx","ToolbarGroup","children","ToolbarButton","Shuffle","clientId","as","categories","patterns","patternName","useSelect","select","getBlockAttributes","getBlockRootClientId","__experimentalGetAllowedPatterns","blockEditorStore","attributes","_categories","metadata","_patternName","rootBlock","_patterns","replaceBlocks","useDispatch","sameCategoryPatternsWithSingleWrapper","useMemo","length","filter","pattern","blocks","some","category","includes","getNextPattern","numberOfPatterns","patternIndex","findIndex","name","nextPatternIndex","ComponentToUse","label","__","icon","shuffle","onClick","nextPattern"],"sources":["@wordpress/block-editor/src/components/block-toolbar/shuffle.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { shuffle } from '@wordpress/icons';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nconst EMPTY_ARRAY = [];\n\nfunction Container( props ) {\n\treturn (\n\t\t<ToolbarGroup>\n\t\t\t<ToolbarButton { ...props } />\n\t\t</ToolbarGroup>\n\t);\n}\n\nexport default function Shuffle( { clientId, as = Container } ) {\n\tconst { categories, patterns, patternName } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\t__experimentalGetAllowedPatterns,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\t\t\tconst _categories = attributes?.metadata?.categories || EMPTY_ARRAY;\n\t\t\tconst _patternName = attributes?.metadata?.patternName;\n\t\t\tconst rootBlock = getBlockRootClientId( clientId );\n\t\t\tconst _patterns = __experimentalGetAllowedPatterns( rootBlock );\n\t\t\treturn {\n\t\t\t\tcategories: _categories,\n\t\t\t\tpatterns: _patterns,\n\t\t\t\tpatternName: _patternName,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst sameCategoryPatternsWithSingleWrapper = useMemo( () => {\n\t\tif (\n\t\t\t! categories ||\n\t\t\tcategories.length === 0 ||\n\t\t\t! patterns ||\n\t\t\tpatterns.length === 0\n\t\t) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\t\treturn patterns.filter( ( pattern ) => {\n\t\t\treturn (\n\t\t\t\t// Check if the pattern has only one top level block,\n\t\t\t\t// otherwise we may shuffle to pattern that will not allow to continue shuffling.\n\t\t\t\tpattern.blocks.length === 1 &&\n\t\t\t\tpattern.categories?.some( ( category ) => {\n\t\t\t\t\treturn categories.includes( category );\n\t\t\t\t} )\n\t\t\t);\n\t\t} );\n\t}, [ categories, patterns ] );\n\tif ( sameCategoryPatternsWithSingleWrapper.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tfunction getNextPattern() {\n\t\tconst numberOfPatterns = sameCategoryPatternsWithSingleWrapper.length;\n\t\tconst patternIndex = sameCategoryPatternsWithSingleWrapper.findIndex(\n\t\t\t( { name } ) => name === patternName\n\t\t);\n\t\tconst nextPatternIndex =\n\t\t\tpatternIndex + 1 < numberOfPatterns ? patternIndex + 1 : 0;\n\t\treturn sameCategoryPatternsWithSingleWrapper[ nextPatternIndex ];\n\t}\n\n\tconst ComponentToUse = as;\n\treturn (\n\t\t<ComponentToUse\n\t\t\tlabel={ __( 'Shuffle' ) }\n\t\t\ticon={ shuffle }\n\t\t\tonClick={ () => {\n\t\t\t\tconst nextPattern = getNextPattern();\n\t\t\t\tnextPattern.blocks[ 0 ].attributes = {\n\t\t\t\t\t...nextPattern.blocks[ 0 ].attributes,\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t...nextPattern.blocks[ 0 ].attributes.metadata,\n\t\t\t\t\t\tcategories,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\treplaceBlocks( clientId, nextPattern.blocks );\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAA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AqC,GAAG,IAAAC,gBAAO,EAAE,MAAM;IAC5D,IACC,CAAElB,UAAU,IACZA,UAAU,CAACmB,MAAM,KAAK,CAAC,IACvB,CAAElB,QAAQ,IACVA,QAAQ,CAACkB,MAAM,KAAK,CAAC,EACpB;MACD,OAAO7B,WAAW;IACnB;IACA,OAAOW,QAAQ,CAACmB,MAAM,CAAIC,OAAO,IAAM;MACtC;QACC;QACA;QACAA,OAAO,CAACC,MAAM,CAACH,MAAM,KAAK,CAAC,IAC3BE,OAAO,CAACrB,UAAU,EAAEuB,IAAI,CAAIC,QAAQ,IAAM;UACzC,OAAOxB,UAAU,CAACyB,QAAQ,CAAED,QAAS,CAAC;QACvC,CAAE;
|
|
1
|
+
{"version":3,"names":["_icons","require","_components","_i18n","_element","_data","_store","_jsxRuntime","EMPTY_ARRAY","Container","props","jsx","ToolbarGroup","children","ToolbarButton","Shuffle","clientId","as","categories","patterns","patternName","useSelect","select","getBlockAttributes","getBlockRootClientId","__experimentalGetAllowedPatterns","blockEditorStore","attributes","_categories","metadata","_patternName","rootBlock","_patterns","replaceBlocks","useDispatch","sameCategoryPatternsWithSingleWrapper","useMemo","length","filter","pattern","blocks","some","category","includes","syncStatus","id","getNextPattern","numberOfPatterns","patternIndex","findIndex","name","nextPatternIndex","ComponentToUse","label","__","icon","shuffle","onClick","nextPattern"],"sources":["@wordpress/block-editor/src/components/block-toolbar/shuffle.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { shuffle } from '@wordpress/icons';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nconst EMPTY_ARRAY = [];\n\nfunction Container( props ) {\n\treturn (\n\t\t<ToolbarGroup>\n\t\t\t<ToolbarButton { ...props } />\n\t\t</ToolbarGroup>\n\t);\n}\n\nexport default function Shuffle( { clientId, as = Container } ) {\n\tconst { categories, patterns, patternName } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\t__experimentalGetAllowedPatterns,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\t\t\tconst _categories = attributes?.metadata?.categories || EMPTY_ARRAY;\n\t\t\tconst _patternName = attributes?.metadata?.patternName;\n\t\t\tconst rootBlock = getBlockRootClientId( clientId );\n\t\t\tconst _patterns = __experimentalGetAllowedPatterns( rootBlock );\n\t\t\treturn {\n\t\t\t\tcategories: _categories,\n\t\t\t\tpatterns: _patterns,\n\t\t\t\tpatternName: _patternName,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst sameCategoryPatternsWithSingleWrapper = useMemo( () => {\n\t\tif (\n\t\t\t! categories ||\n\t\t\tcategories.length === 0 ||\n\t\t\t! patterns ||\n\t\t\tpatterns.length === 0\n\t\t) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\t\treturn patterns.filter( ( pattern ) => {\n\t\t\treturn (\n\t\t\t\t// Check if the pattern has only one top level block,\n\t\t\t\t// otherwise we may shuffle to pattern that will not allow to continue shuffling.\n\t\t\t\tpattern.blocks.length === 1 &&\n\t\t\t\tpattern.categories?.some( ( category ) => {\n\t\t\t\t\treturn categories.includes( category );\n\t\t\t\t} ) &&\n\t\t\t\t// Check if the pattern is not a synced pattern.\n\t\t\t\t( pattern.syncStatus === 'unsynced' || ! pattern.id )\n\t\t\t);\n\t\t} );\n\t}, [ categories, patterns ] );\n\tif ( sameCategoryPatternsWithSingleWrapper.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tfunction getNextPattern() {\n\t\tconst numberOfPatterns = sameCategoryPatternsWithSingleWrapper.length;\n\t\tconst patternIndex = sameCategoryPatternsWithSingleWrapper.findIndex(\n\t\t\t( { name } ) => name === patternName\n\t\t);\n\t\tconst nextPatternIndex =\n\t\t\tpatternIndex + 1 < numberOfPatterns ? patternIndex + 1 : 0;\n\t\treturn sameCategoryPatternsWithSingleWrapper[ nextPatternIndex ];\n\t}\n\n\tconst ComponentToUse = as;\n\treturn (\n\t\t<ComponentToUse\n\t\t\tlabel={ __( 'Shuffle' ) }\n\t\t\ticon={ shuffle }\n\t\t\tonClick={ () => {\n\t\t\t\tconst nextPattern = getNextPattern();\n\t\t\t\tnextPattern.blocks[ 0 ].attributes = {\n\t\t\t\t\t...nextPattern.blocks[ 0 ].attributes,\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t...nextPattern.blocks[ 0 ].attributes.metadata,\n\t\t\t\t\t\tcategories,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\treplaceBlocks( clientId, nextPattern.blocks );\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AAAwD,IAAAM,WAAA,GAAAN,OAAA;AAZxD;AACA;AACA;;AAOA;AACA;AACA;;AAGA,MAAMO,WAAW,GAAG,EAAE;AAEtB,SAASC,SAASA,CAAEC,KAAK,EAAG;EAC3B,oBACC,IAAAH,WAAA,CAAAI,GAAA,EAACT,WAAA,CAAAU,YAAY;IAAAC,QAAA,eACZ,IAAAN,WAAA,CAAAI,GAAA,EAACT,WAAA,CAAAY,aAAa;MAAA,GAAMJ;IAAK,CAAI;EAAC,CACjB,CAAC;AAEjB;AAEe,SAASK,OAAOA,CAAE;EAAEC,QAAQ;EAAEC,EAAE,GAAGR;AAAU,CAAC,EAAG;EAC/D,MAAM;IAAES,UAAU;IAAEC,QAAQ;IAAEC;EAAY,CAAC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