@wordpress/block-editor 12.3.6 → 12.3.8
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/README.md +0 -4
- package/build/components/block-draggable/index.js +6 -3
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +15 -25
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/colors-gradients/control.js +4 -2
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +13 -2
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/iframe/index.js +16 -3
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/iframe/use-compatibility-styles.js +5 -0
- package/build/components/iframe/use-compatibility-styles.js.map +1 -1
- package/build/components/index.js +1 -10
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/reusable-block-rename-hint.js +23 -3
- package/build/components/inserter/reusable-block-rename-hint.js.map +1 -1
- package/build/components/link-control/constants.js +1 -1
- package/build/components/link-control/constants.js.map +1 -1
- package/build/components/link-control/search-create-button.js +5 -21
- package/build/components/link-control/search-create-button.js.map +1 -1
- package/build/components/link-control/search-item.js +13 -30
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/link-control/search-results.js +2 -2
- package/build/components/link-control/search-results.js.map +1 -1
- package/build/components/rich-text/get-rich-text-values.js +7 -1
- package/build/components/rich-text/get-rich-text-values.js.map +1 -1
- package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
- package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/axial.js +6 -2
- package/build/components/spacing-sizes-control/input-controls/axial.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/separated.js +5 -1
- package/build/components/spacing-sizes-control/input-controls/separated.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/single.js +5 -1
- package/build/components/spacing-sizes-control/input-controls/single.js.map +1 -1
- package/build/components/spacing-sizes-control/utils.js +1 -1
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/components/use-block-display-information/index.js +7 -3
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/hooks/margin.js +1 -1
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +1 -1
- package/build/hooks/padding.js.map +1 -1
- package/build/private-apis.js +5 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/index.js +10 -1
- package/build/store/index.js.map +1 -1
- package/build/store/private-actions.js +36 -36
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +3 -3
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +16 -8
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +1 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-draggable/index.js +6 -3
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +16 -23
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +3 -2
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +13 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/iframe/index.js +16 -3
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/iframe/use-compatibility-styles.js +5 -0
- package/build-module/components/iframe/use-compatibility-styles.js.map +1 -1
- package/build-module/components/index.js +0 -5
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/reusable-block-rename-hint.js +22 -3
- package/build-module/components/inserter/reusable-block-rename-hint.js.map +1 -1
- package/build-module/components/link-control/constants.js +1 -1
- package/build-module/components/link-control/constants.js.map +1 -1
- package/build-module/components/link-control/search-create-button.js +7 -20
- package/build-module/components/link-control/search-create-button.js.map +1 -1
- package/build-module/components/link-control/search-item.js +14 -28
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/link-control/search-results.js +3 -3
- package/build-module/components/link-control/search-results.js.map +1 -1
- package/build-module/components/rich-text/get-rich-text-values.js +7 -1
- package/build-module/components/rich-text/get-rich-text-values.js.map +1 -1
- package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
- package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/axial.js +7 -3
- package/build-module/components/spacing-sizes-control/input-controls/axial.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/separated.js +6 -2
- package/build-module/components/spacing-sizes-control/input-controls/separated.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/single.js +6 -2
- package/build-module/components/spacing-sizes-control/input-controls/single.js.map +1 -1
- package/build-module/components/spacing-sizes-control/utils.js +1 -1
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +7 -3
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/hooks/margin.js +1 -1
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +1 -1
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/private-apis.js +4 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/index.js +10 -1
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-actions.js +35 -32
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +2 -2
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +16 -8
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +1 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +20 -83
- package/build-style/style.css +20 -83
- package/package.json +10 -10
- package/src/components/block-draggable/index.js +13 -4
- package/src/components/block-removal-warning-modal/index.js +13 -27
- package/src/components/colors-gradients/control.js +3 -2
- package/src/components/global-styles/dimensions-panel.js +8 -2
- package/src/components/iframe/index.js +15 -10
- package/src/components/iframe/use-compatibility-styles.js +5 -0
- package/src/components/index.js +0 -5
- package/src/components/inserter/reusable-block-rename-hint.js +18 -1
- package/src/components/link-control/constants.js +1 -1
- package/src/components/link-control/search-create-button.js +8 -26
- package/src/components/link-control/search-item.js +21 -43
- package/src/components/link-control/search-results.js +48 -46
- package/src/components/link-control/style.scss +25 -95
- package/src/components/link-control/test/index.js +6 -7
- package/src/components/rich-text/get-rich-text-values.js +11 -1
- package/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
- package/src/components/spacing-sizes-control/input-controls/axial.js +17 -2
- package/src/components/spacing-sizes-control/input-controls/separated.js +17 -2
- package/src/components/spacing-sizes-control/input-controls/single.js +12 -2
- package/src/components/spacing-sizes-control/utils.js +1 -1
- package/src/components/use-block-display-information/index.js +12 -5
- package/src/hooks/margin.js +4 -1
- package/src/hooks/padding.js +4 -1
- package/src/private-apis.js +6 -0
- package/src/store/index.js +10 -0
- package/src/store/private-actions.js +33 -36
- package/src/store/private-selectors.js +2 -2
- package/src/store/reducer.js +16 -8
- package/src/store/selectors.js +1 -1
- package/src/store/test/actions.js +3 -0
- package/src/store/test/selectors.js +1 -1
package/src/private-apis.js
CHANGED
|
@@ -18,6 +18,10 @@ import { BlockRemovalWarningModal } from './components/block-removal-warning-mod
|
|
|
18
18
|
import { useLayoutClasses, useLayoutStyles } from './hooks';
|
|
19
19
|
import DimensionsTool from './components/dimensions-tool';
|
|
20
20
|
import ResolutionTool from './components/resolution-tool';
|
|
21
|
+
import {
|
|
22
|
+
default as ReusableBlocksRenameHint,
|
|
23
|
+
useReusableBlocksRenameHint,
|
|
24
|
+
} from './components/inserter/reusable-block-rename-hint';
|
|
21
25
|
|
|
22
26
|
/**
|
|
23
27
|
* Private @wordpress/block-editor APIs.
|
|
@@ -41,4 +45,6 @@ lock( privateApis, {
|
|
|
41
45
|
useLayoutStyles,
|
|
42
46
|
DimensionsTool,
|
|
43
47
|
ResolutionTool,
|
|
48
|
+
ReusableBlocksRenameHint,
|
|
49
|
+
useReusableBlocksRenameHint,
|
|
44
50
|
} );
|
package/src/store/index.js
CHANGED
|
@@ -43,3 +43,13 @@ const registeredStore = registerStore( STORE_NAME, {
|
|
|
43
43
|
} );
|
|
44
44
|
unlock( registeredStore ).registerPrivateActions( privateActions );
|
|
45
45
|
unlock( registeredStore ).registerPrivateSelectors( privateSelectors );
|
|
46
|
+
|
|
47
|
+
// TODO: Remove once we switch to the `register` function (see above).
|
|
48
|
+
//
|
|
49
|
+
// Until then, private functions also need to be attached to the original
|
|
50
|
+
// `store` descriptor in order to avoid unit tests failing, which could happen
|
|
51
|
+
// when tests create new registries in which they register stores.
|
|
52
|
+
//
|
|
53
|
+
// @see https://github.com/WordPress/gutenberg/pull/51145#discussion_r1239999590
|
|
54
|
+
unlock( store ).registerPrivateActions( privateActions );
|
|
55
|
+
unlock( store ).registerPrivateSelectors( privateSelectors );
|
|
@@ -3,11 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Platform } from '@wordpress/element';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { blockTypePromptMessages } from '../components/block-removal-warning-modal';
|
|
10
|
-
|
|
11
6
|
const castArray = ( maybeArray ) =>
|
|
12
7
|
Array.isArray( maybeArray ) ? maybeArray : [ maybeArray ];
|
|
13
8
|
|
|
@@ -155,35 +150,22 @@ export const privateRemoveBlocks =
|
|
|
155
150
|
// confirmation that they intended to remove such block(s). However,
|
|
156
151
|
// the editor instance is responsible for presenting those confirmation
|
|
157
152
|
// prompts to the user. Any instance opting into removal prompts must
|
|
158
|
-
// register using `
|
|
153
|
+
// register using `setBlockRemovalRules()`.
|
|
159
154
|
//
|
|
160
155
|
// @see https://github.com/WordPress/gutenberg/pull/51145
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
// FIXME: Without this existence check, the unit tests for
|
|
164
|
-
// `__experimentalDeleteReusableBlock` in
|
|
165
|
-
// `packages/reusable-blocks/src/store/test/actions.js` fail due to
|
|
166
|
-
// the fact that the `registry` object passed to the thunk actions
|
|
167
|
-
// doesn't include this private action. This needs to be
|
|
168
|
-
// investigated to understand whether it's a real smell or if it's
|
|
169
|
-
// because not all store code has been updated to accommodate
|
|
170
|
-
// private selectors.
|
|
171
|
-
select.isRemovalPromptSupported &&
|
|
172
|
-
select.isRemovalPromptSupported()
|
|
173
|
-
) {
|
|
156
|
+
const rules = ! forceRemove && select.getBlockRemovalRules();
|
|
157
|
+
if ( rules ) {
|
|
174
158
|
const blockNamesForPrompt = new Set();
|
|
175
159
|
|
|
176
160
|
// Given a list of client IDs of blocks that the user intended to
|
|
177
161
|
// remove, perform a tree search (BFS) to find all block names
|
|
178
162
|
// corresponding to "important" blocks, i.e. blocks that require a
|
|
179
163
|
// removal prompt.
|
|
180
|
-
//
|
|
181
|
-
// @see blockTypePromptMessages
|
|
182
164
|
const queue = [ ...clientIds ];
|
|
183
165
|
while ( queue.length ) {
|
|
184
166
|
const clientId = queue.shift();
|
|
185
167
|
const blockName = select.getBlockName( clientId );
|
|
186
|
-
if (
|
|
168
|
+
if ( rules[ blockName ] ) {
|
|
187
169
|
blockNamesForPrompt.add( blockName );
|
|
188
170
|
}
|
|
189
171
|
const innerBlocks = select.getBlockOrder( clientId );
|
|
@@ -194,7 +176,7 @@ export const privateRemoveBlocks =
|
|
|
194
176
|
// skip any other steps (thus postponing actual removal).
|
|
195
177
|
if ( blockNamesForPrompt.size ) {
|
|
196
178
|
dispatch(
|
|
197
|
-
|
|
179
|
+
displayBlockRemovalPrompt(
|
|
198
180
|
clientIds,
|
|
199
181
|
selectPrevious,
|
|
200
182
|
Array.from( blockNamesForPrompt )
|
|
@@ -246,7 +228,7 @@ export const ensureDefaultBlock =
|
|
|
246
228
|
* Returns an action object used in signalling that a block removal prompt must
|
|
247
229
|
* be displayed.
|
|
248
230
|
*
|
|
249
|
-
* Contrast with `
|
|
231
|
+
* Contrast with `setBlockRemovalRules`.
|
|
250
232
|
*
|
|
251
233
|
* @param {string|string[]} clientIds Client IDs of blocks to remove.
|
|
252
234
|
* @param {boolean} selectPrevious True if the previous block
|
|
@@ -254,16 +236,19 @@ export const ensureDefaultBlock =
|
|
|
254
236
|
* (if no previous block exists)
|
|
255
237
|
* should be selected
|
|
256
238
|
* when a block is removed.
|
|
257
|
-
* @param {string[]} blockNamesForPrompt Names of blocks
|
|
239
|
+
* @param {string[]} blockNamesForPrompt Names of the blocks that
|
|
240
|
+
* triggered the need for
|
|
241
|
+
* confirmation before removal.
|
|
242
|
+
*
|
|
258
243
|
* @return {Object} Action object.
|
|
259
244
|
*/
|
|
260
|
-
|
|
245
|
+
function displayBlockRemovalPrompt(
|
|
261
246
|
clientIds,
|
|
262
247
|
selectPrevious,
|
|
263
248
|
blockNamesForPrompt
|
|
264
249
|
) {
|
|
265
250
|
return {
|
|
266
|
-
type: '
|
|
251
|
+
type: 'DISPLAY_BLOCK_REMOVAL_PROMPT',
|
|
267
252
|
clientIds,
|
|
268
253
|
selectPrevious,
|
|
269
254
|
blockNamesForPrompt,
|
|
@@ -277,24 +262,36 @@ export function displayRemovalPrompt(
|
|
|
277
262
|
*
|
|
278
263
|
* @return {Object} Action object.
|
|
279
264
|
*/
|
|
280
|
-
export function
|
|
265
|
+
export function clearBlockRemovalPrompt() {
|
|
281
266
|
return {
|
|
282
|
-
type: '
|
|
267
|
+
type: 'CLEAR_BLOCK_REMOVAL_PROMPT',
|
|
283
268
|
};
|
|
284
269
|
}
|
|
285
270
|
|
|
286
271
|
/**
|
|
287
|
-
* Returns an action object used
|
|
288
|
-
*
|
|
272
|
+
* Returns an action object used to set up any rules that a block editor may
|
|
273
|
+
* provide in order to prevent a user from accidentally removing certain
|
|
274
|
+
* blocks. These rules are then used to display a confirmation prompt to the
|
|
275
|
+
* user. For instance, in the Site Editor, the Query Loop block is important
|
|
276
|
+
* enough to warrant such confirmation.
|
|
277
|
+
*
|
|
278
|
+
* IMPORTANT: Registering rules implicitly signals to the `privateRemoveBlocks`
|
|
279
|
+
* action that the editor will be responsible for displaying block removal
|
|
280
|
+
* prompts and confirming deletions. This action is meant to be used by
|
|
281
|
+
* component `BlockRemovalWarningModal` only.
|
|
282
|
+
*
|
|
283
|
+
* The data is a record whose keys are block types (e.g. 'core/query') and
|
|
284
|
+
* whose values are the explanation to be shown to users (e.g. 'Query Loop
|
|
285
|
+
* displays a list of posts or pages.').
|
|
289
286
|
*
|
|
290
|
-
* Contrast with `
|
|
287
|
+
* Contrast with `displayBlockRemovalPrompt`.
|
|
291
288
|
*
|
|
292
|
-
* @param {
|
|
289
|
+
* @param {Record<string,string>|false} rules Block removal rules.
|
|
293
290
|
* @return {Object} Action object.
|
|
294
291
|
*/
|
|
295
|
-
export function
|
|
292
|
+
export function setBlockRemovalRules( rules = false ) {
|
|
296
293
|
return {
|
|
297
|
-
type: '
|
|
298
|
-
|
|
294
|
+
type: 'SET_BLOCK_REMOVAL_RULES',
|
|
295
|
+
rules,
|
|
299
296
|
};
|
|
300
297
|
}
|
|
@@ -202,6 +202,6 @@ export function getRemovalPromptData( state ) {
|
|
|
202
202
|
*
|
|
203
203
|
* @return {boolean} Whether removal prompt exists.
|
|
204
204
|
*/
|
|
205
|
-
export function
|
|
206
|
-
return state.
|
|
205
|
+
export function getBlockRemovalRules( state ) {
|
|
206
|
+
return state.blockRemovalRules;
|
|
207
207
|
}
|
package/src/store/reducer.js
CHANGED
|
@@ -1480,14 +1480,14 @@ export function isSelectionEnabled( state = true, action ) {
|
|
|
1480
1480
|
*/
|
|
1481
1481
|
function removalPromptData( state = false, action ) {
|
|
1482
1482
|
switch ( action.type ) {
|
|
1483
|
-
case '
|
|
1483
|
+
case 'DISPLAY_BLOCK_REMOVAL_PROMPT':
|
|
1484
1484
|
const { clientIds, selectPrevious, blockNamesForPrompt } = action;
|
|
1485
1485
|
return {
|
|
1486
1486
|
clientIds,
|
|
1487
1487
|
selectPrevious,
|
|
1488
1488
|
blockNamesForPrompt,
|
|
1489
1489
|
};
|
|
1490
|
-
case '
|
|
1490
|
+
case 'CLEAR_BLOCK_REMOVAL_PROMPT':
|
|
1491
1491
|
return false;
|
|
1492
1492
|
}
|
|
1493
1493
|
|
|
@@ -1495,17 +1495,25 @@ function removalPromptData( state = false, action ) {
|
|
|
1495
1495
|
}
|
|
1496
1496
|
|
|
1497
1497
|
/**
|
|
1498
|
-
* Reducer
|
|
1498
|
+
* Reducer returning any rules that a block editor may provide in order to
|
|
1499
|
+
* prevent a user from accidentally removing certain blocks. These rules are
|
|
1500
|
+
* then used to display a confirmation prompt to the user. For instance, in the
|
|
1501
|
+
* Site Editor, the Query Loop block is important enough to warrant such
|
|
1502
|
+
* confirmation.
|
|
1503
|
+
*
|
|
1504
|
+
* The data is a record whose keys are block types (e.g. 'core/query') and
|
|
1505
|
+
* whose values are the explanation to be shown to users (e.g. 'Query Loop
|
|
1506
|
+
* displays a list of posts or pages.').
|
|
1499
1507
|
*
|
|
1500
1508
|
* @param {boolean} state Current state.
|
|
1501
1509
|
* @param {Object} action Dispatched action.
|
|
1502
1510
|
*
|
|
1503
|
-
* @return {
|
|
1511
|
+
* @return {Record<string,string>} Updated state.
|
|
1504
1512
|
*/
|
|
1505
|
-
function
|
|
1513
|
+
function blockRemovalRules( state = false, action ) {
|
|
1506
1514
|
switch ( action.type ) {
|
|
1507
|
-
case '
|
|
1508
|
-
return action.
|
|
1515
|
+
case 'SET_BLOCK_REMOVAL_RULES':
|
|
1516
|
+
return action.rules;
|
|
1509
1517
|
}
|
|
1510
1518
|
|
|
1511
1519
|
return state;
|
|
@@ -1924,7 +1932,7 @@ const combinedReducers = combineReducers( {
|
|
|
1924
1932
|
blockVisibility,
|
|
1925
1933
|
blockEditingModes,
|
|
1926
1934
|
removalPromptData,
|
|
1927
|
-
|
|
1935
|
+
blockRemovalRules,
|
|
1928
1936
|
} );
|
|
1929
1937
|
|
|
1930
1938
|
function withAutomaticChangeReset( reducer ) {
|
package/src/store/selectors.js
CHANGED
|
@@ -617,6 +617,7 @@ describe( 'actions', () => {
|
|
|
617
617
|
const select = {
|
|
618
618
|
getBlockRootClientId: () => undefined,
|
|
619
619
|
canRemoveBlocks: () => true,
|
|
620
|
+
getBlockRemovalRules: () => false,
|
|
620
621
|
};
|
|
621
622
|
const dispatch = Object.assign( jest.fn(), {
|
|
622
623
|
selectPreviousBlock: jest.fn(),
|
|
@@ -727,6 +728,7 @@ describe( 'actions', () => {
|
|
|
727
728
|
const select = {
|
|
728
729
|
getBlockRootClientId: () => null,
|
|
729
730
|
canRemoveBlocks: () => true,
|
|
731
|
+
getBlockRemovalRules: () => false,
|
|
730
732
|
};
|
|
731
733
|
const dispatch = Object.assign( jest.fn(), {
|
|
732
734
|
selectPreviousBlock: jest.fn(),
|
|
@@ -751,6 +753,7 @@ describe( 'actions', () => {
|
|
|
751
753
|
const select = {
|
|
752
754
|
getBlockRootClientId: () => null,
|
|
753
755
|
canRemoveBlocks: () => true,
|
|
756
|
+
getBlockRemovalRules: () => false,
|
|
754
757
|
};
|
|
755
758
|
const dispatch = Object.assign( jest.fn(), {
|
|
756
759
|
selectPreviousBlock: jest.fn(),
|
|
@@ -3351,7 +3351,7 @@ describe( 'selectors', () => {
|
|
|
3351
3351
|
id: 'core/block/1',
|
|
3352
3352
|
initialAttributes: { ref: 1 },
|
|
3353
3353
|
isDisabled: false,
|
|
3354
|
-
keywords: [],
|
|
3354
|
+
keywords: [ 'reusable' ],
|
|
3355
3355
|
name: 'core/block',
|
|
3356
3356
|
syncStatus: undefined,
|
|
3357
3357
|
title: 'Reusable Block 1',
|