@wordpress/block-editor 15.15.0 → 15.16.1-next.v.202604091042.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/build/components/autocomplete/index.cjs +1 -2
- package/build/components/autocomplete/index.cjs.map +3 -3
- package/build/components/block-inspector/index.cjs +2 -1
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-list/block-crash-warning.cjs +4 -2
- package/build/components/block-list/block-crash-warning.cjs.map +2 -2
- package/build/components/block-list/block-html.cjs +6 -2
- package/build/components/block-list/block-html.cjs.map +2 -2
- package/build/components/block-mover/button.cjs +4 -3
- package/build/components/block-mover/button.cjs.map +2 -2
- package/build/components/block-mover/index.cjs +1 -8
- package/build/components/block-mover/index.cjs.map +2 -2
- package/build/components/block-visibility/modal.cjs +2 -2
- package/build/components/block-visibility/modal.cjs.map +1 -1
- package/build/components/block-visibility/viewport-visibility-info.cjs +6 -1
- package/build/components/block-visibility/viewport-visibility-info.cjs.map +2 -2
- package/build/components/global-styles/background-panel.cjs +142 -33
- package/build/components/global-styles/background-panel.cjs.map +2 -2
- package/build/components/global-styles/color-panel.cjs +18 -7
- package/build/components/global-styles/color-panel.cjs.map +2 -2
- package/build/components/global-styles/hooks.cjs +8 -4
- package/build/components/global-styles/hooks.cjs.map +2 -2
- package/build/components/iframe/get-compatibility-styles.cjs +1 -1
- package/build/components/iframe/get-compatibility-styles.cjs.map +2 -2
- package/build/components/inserter/media-tab/hooks.cjs +1 -1
- package/build/components/inserter/media-tab/hooks.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/styles-tab.cjs +2 -1
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/components/link-control/search-input.cjs +1 -1
- package/build/components/link-control/search-input.cjs.map +2 -2
- package/build/components/link-picker/link-preview.cjs +2 -1
- package/build/components/link-picker/link-preview.cjs.map +3 -3
- package/build/components/rich-text/index.cjs +1 -1
- package/build/components/rich-text/index.cjs.map +2 -2
- package/build/components/rich-text/input-event.cjs +3 -3
- package/build/components/rich-text/input-event.cjs.map +2 -2
- package/build/components/use-on-block-drop/index.cjs +1 -1
- package/build/components/use-on-block-drop/index.cjs.map +2 -2
- package/build/components/use-paste-styles/index.cjs +2 -2
- package/build/components/use-paste-styles/index.cjs.map +2 -2
- package/build/hooks/background.cjs +74 -21
- package/build/hooks/background.cjs.map +3 -3
- package/build/hooks/block-style-variation.cjs +5 -6
- package/build/hooks/block-style-variation.cjs.map +3 -3
- package/build/hooks/cross-origin-isolation.cjs +6 -6
- package/build/hooks/cross-origin-isolation.cjs.map +2 -2
- package/build/hooks/custom-css.cjs +5 -0
- package/build/hooks/custom-css.cjs.map +2 -2
- package/build/hooks/fit-text.cjs +46 -58
- package/build/hooks/fit-text.cjs.map +3 -3
- package/build/hooks/index.cjs +2 -2
- package/build/hooks/index.cjs.map +2 -2
- package/build/hooks/utils.cjs +5 -1
- package/build/hooks/utils.cjs.map +2 -2
- package/build/private-apis.cjs +1 -1
- package/build/private-apis.cjs.map +1 -1
- package/build/store/actions.cjs +8 -12
- package/build/store/actions.cjs.map +2 -2
- package/build/store/private-selectors.cjs +2 -2
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +112 -146
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs +14 -15
- package/build/store/selectors.cjs.map +2 -2
- package/build/store/utils.cjs +1 -1
- package/build/store/utils.cjs.map +2 -2
- package/build/utils/pasting.cjs +1 -1
- package/build/utils/pasting.cjs.map +2 -2
- package/build-module/components/autocomplete/index.mjs +1 -2
- package/build-module/components/autocomplete/index.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +2 -1
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-list/block-crash-warning.mjs +4 -2
- package/build-module/components/block-list/block-crash-warning.mjs.map +2 -2
- package/build-module/components/block-list/block-html.mjs +7 -3
- package/build-module/components/block-list/block-html.mjs.map +2 -2
- package/build-module/components/block-mover/button.mjs +4 -3
- package/build-module/components/block-mover/button.mjs.map +2 -2
- package/build-module/components/block-mover/index.mjs +1 -8
- package/build-module/components/block-mover/index.mjs.map +2 -2
- package/build-module/components/block-visibility/modal.mjs +2 -2
- package/build-module/components/block-visibility/modal.mjs.map +1 -1
- package/build-module/components/block-visibility/viewport-visibility-info.mjs +6 -1
- package/build-module/components/block-visibility/viewport-visibility-info.mjs.map +2 -2
- package/build-module/components/global-styles/background-panel.mjs +141 -34
- package/build-module/components/global-styles/background-panel.mjs.map +2 -2
- package/build-module/components/global-styles/color-panel.mjs +17 -7
- package/build-module/components/global-styles/color-panel.mjs.map +2 -2
- package/build-module/components/global-styles/hooks.mjs +8 -4
- package/build-module/components/global-styles/hooks.mjs.map +2 -2
- package/build-module/components/iframe/get-compatibility-styles.mjs +1 -1
- package/build-module/components/iframe/get-compatibility-styles.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/hooks.mjs +1 -1
- package/build-module/components/inserter/media-tab/hooks.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +2 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/link-control/search-input.mjs +1 -1
- package/build-module/components/link-control/search-input.mjs.map +2 -2
- package/build-module/components/link-picker/link-preview.mjs +2 -1
- package/build-module/components/link-picker/link-preview.mjs.map +2 -2
- package/build-module/components/rich-text/index.mjs +2 -2
- package/build-module/components/rich-text/index.mjs.map +2 -2
- package/build-module/components/rich-text/input-event.mjs +2 -2
- package/build-module/components/rich-text/input-event.mjs.map +2 -2
- package/build-module/components/use-on-block-drop/index.mjs +1 -1
- package/build-module/components/use-on-block-drop/index.mjs.map +2 -2
- package/build-module/components/use-paste-styles/index.mjs +2 -2
- package/build-module/components/use-paste-styles/index.mjs.map +2 -2
- package/build-module/hooks/background.mjs +76 -22
- package/build-module/hooks/background.mjs.map +2 -2
- package/build-module/hooks/block-style-variation.mjs +4 -5
- package/build-module/hooks/block-style-variation.mjs.map +2 -2
- package/build-module/hooks/cross-origin-isolation.mjs +6 -6
- package/build-module/hooks/cross-origin-isolation.mjs.map +2 -2
- package/build-module/hooks/custom-css.mjs +5 -0
- package/build-module/hooks/custom-css.mjs.map +2 -2
- package/build-module/hooks/fit-text.mjs +46 -58
- package/build-module/hooks/fit-text.mjs.map +2 -2
- package/build-module/hooks/index.mjs +2 -2
- package/build-module/hooks/index.mjs.map +2 -2
- package/build-module/hooks/utils.mjs +5 -1
- package/build-module/hooks/utils.mjs.map +2 -2
- package/build-module/private-apis.mjs +2 -2
- package/build-module/private-apis.mjs.map +1 -1
- package/build-module/store/actions.mjs +8 -12
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +2 -2
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +112 -145
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs +14 -15
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/store/utils.mjs +1 -1
- package/build-module/store/utils.mjs.map +2 -2
- package/build-module/utils/pasting.mjs +1 -1
- package/build-module/utils/pasting.mjs.map +2 -2
- package/build-style/content-rtl.css +2 -2
- package/build-style/content.css +2 -2
- package/build-style/style-rtl.css +35 -14
- package/build-style/style.css +35 -14
- package/package.json +38 -39
- package/src/autocompleters/style.scss +0 -8
- package/src/components/autocomplete/index.js +1 -2
- package/src/components/background-image-control/style.scss +0 -4
- package/src/components/block-draggable/test/helpers.native.js +1 -1
- package/src/components/block-inspector/index.js +1 -0
- package/src/components/block-list/block-crash-warning.js +3 -1
- package/src/components/block-list/block-crash-warning.native.js +3 -1
- package/src/components/block-list/block-html.js +13 -3
- package/src/components/block-mover/button.js +7 -4
- package/src/components/block-mover/index.js +1 -8
- package/src/components/block-visibility/viewport-visibility-info.js +8 -1
- package/src/components/fit-text-size-warning/style.scss +1 -5
- package/src/components/global-styles/background-panel.js +157 -11
- package/src/components/global-styles/color-panel.js +23 -7
- package/src/components/global-styles/hooks.js +12 -4
- package/src/components/global-styles/test/background-panel.js +44 -1
- package/src/components/iframe/get-compatibility-styles.js +1 -1
- package/src/components/inserter/media-tab/hooks.js +1 -1
- package/src/components/inspector-controls-tabs/styles-tab.js +1 -0
- package/src/components/link-control/README.md +2 -2
- package/src/components/link-control/search-input.js +1 -1
- package/src/components/link-picker/link-preview.js +2 -1
- package/src/components/rich-text/index.js +1 -1
- package/src/components/rich-text/index.native.js +1 -1
- package/src/components/rich-text/input-event.js +1 -1
- package/src/components/rich-text/input-event.native.js +1 -1
- package/src/components/rich-text/native/index.native.js +18 -17
- package/src/components/use-on-block-drop/index.js +1 -1
- package/src/components/use-paste-styles/index.js +2 -2
- package/src/hooks/background.js +122 -21
- package/src/hooks/background.scss +45 -0
- package/src/hooks/block-style-variation.js +3 -4
- package/src/hooks/cross-origin-isolation.js +6 -6
- package/src/hooks/custom-css.js +6 -0
- package/src/hooks/fit-text.js +73 -83
- package/src/hooks/index.js +1 -1
- package/src/hooks/test/cross-origin-isolation.js +7 -3
- package/src/hooks/utils.js +4 -0
- package/src/private-apis.js +2 -2
- package/src/store/actions.js +9 -16
- package/src/store/private-selectors.js +2 -2
- package/src/store/reducer.js +144 -193
- package/src/store/selectors.js +33 -23
- package/src/store/test/private-selectors.js +107 -71
- package/src/store/test/reducer.js +593 -152
- package/src/store/test/registry-selectors.js +1 -1
- package/src/store/test/selectors.js +345 -262
- package/src/store/utils.js +1 -1
- package/src/style.scss +1 -0
- package/src/utils/pasting.js +1 -1
- package/build/autocompleters/link.cjs +0 -81
- package/build/autocompleters/link.cjs.map +0 -7
- package/build-module/autocompleters/link.mjs +0 -50
- package/build-module/autocompleters/link.mjs.map +0 -7
- package/src/autocompleters/link.js +0 -63
|
@@ -109,7 +109,7 @@ function updateParentInnerBlocksInTree(state, updatedClientIds, updateChildrenOf
|
|
|
109
109
|
for (const clientId of updatedClientIds) {
|
|
110
110
|
let current = updateChildrenOfUpdatedClientIds ? clientId : state.parents.get(clientId);
|
|
111
111
|
do {
|
|
112
|
-
if (state.controlledInnerBlocks
|
|
112
|
+
if (state.controlledInnerBlocks.has(current)) {
|
|
113
113
|
controlledParents.add(current);
|
|
114
114
|
break;
|
|
115
115
|
} else {
|
|
@@ -260,27 +260,6 @@ var withBlockTree = (reducer) => (state = {}, action) => {
|
|
|
260
260
|
);
|
|
261
261
|
break;
|
|
262
262
|
}
|
|
263
|
-
case "SAVE_REUSABLE_BLOCK_SUCCESS": {
|
|
264
|
-
const updatedBlockUids = [];
|
|
265
|
-
newState.attributes.forEach((attributes, clientId) => {
|
|
266
|
-
if (newState.byClientId.get(clientId).name === "core/block" && attributes.ref === action.updatedId) {
|
|
267
|
-
updatedBlockUids.push(clientId);
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
newState.tree = new Map(newState.tree);
|
|
271
|
-
updatedBlockUids.forEach((clientId) => {
|
|
272
|
-
newState.tree.set(clientId, {
|
|
273
|
-
...newState.byClientId.get(clientId),
|
|
274
|
-
attributes: newState.attributes.get(clientId),
|
|
275
|
-
innerBlocks: newState.tree.get(clientId).innerBlocks
|
|
276
|
-
});
|
|
277
|
-
});
|
|
278
|
-
updateParentInnerBlocksInTree(
|
|
279
|
-
newState,
|
|
280
|
-
updatedBlockUids,
|
|
281
|
-
false
|
|
282
|
-
);
|
|
283
|
-
}
|
|
284
263
|
}
|
|
285
264
|
return newState;
|
|
286
265
|
};
|
|
@@ -369,44 +348,35 @@ var withInnerBlocksRemoveCascade = (reducer) => (state, action) => {
|
|
|
369
348
|
};
|
|
370
349
|
var withBlockReset = (reducer) => (state, action) => {
|
|
371
350
|
if (action.type === "RESET_BLOCKS") {
|
|
372
|
-
const
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
attributes: new Map(getFlattenedBlockAttributes(action.blocks)),
|
|
379
|
-
order: mapBlockOrder(action.blocks),
|
|
380
|
-
parents: new Map(mapBlockParents(action.blocks)),
|
|
381
|
-
controlledInnerBlocks: preservedControlledInnerBlocks
|
|
382
|
-
};
|
|
351
|
+
const newState = reducer(void 0, {
|
|
352
|
+
type: "INSERT_BLOCKS",
|
|
353
|
+
rootClientId: "",
|
|
354
|
+
blocks: action.blocks
|
|
355
|
+
});
|
|
356
|
+
const preservedControlledInnerBlocks = state?.controlledInnerBlocks ?? /* @__PURE__ */ new Set();
|
|
383
357
|
if (state?.order) {
|
|
384
|
-
for (const clientId of
|
|
385
|
-
preservedControlledInnerBlocks
|
|
386
|
-
)) {
|
|
387
|
-
if (!preservedControlledInnerBlocks[clientId]) {
|
|
388
|
-
continue;
|
|
389
|
-
}
|
|
358
|
+
for (const clientId of preservedControlledInnerBlocks) {
|
|
390
359
|
if (!newState.byClientId.has(clientId)) {
|
|
391
360
|
continue;
|
|
392
361
|
}
|
|
362
|
+
newState.controlledInnerBlocks.add(clientId);
|
|
393
363
|
const oldOrder = state.order.get(clientId);
|
|
394
364
|
if (!oldOrder?.length) {
|
|
395
365
|
continue;
|
|
396
366
|
}
|
|
397
367
|
newState.order.set(clientId, oldOrder);
|
|
398
368
|
const preserveBlock = (blockId, parentId) => {
|
|
399
|
-
const blockData = state.byClientId
|
|
369
|
+
const blockData = state.byClientId.get(blockId);
|
|
400
370
|
if (!blockData) {
|
|
401
371
|
return;
|
|
402
372
|
}
|
|
403
373
|
newState.byClientId.set(blockId, blockData);
|
|
404
374
|
newState.attributes.set(
|
|
405
375
|
blockId,
|
|
406
|
-
state.attributes
|
|
376
|
+
state.attributes.get(blockId)
|
|
407
377
|
);
|
|
408
378
|
newState.parents.set(blockId, parentId);
|
|
409
|
-
const childOrder = state.order
|
|
379
|
+
const childOrder = state.order.get(blockId) || [];
|
|
410
380
|
newState.order.set(blockId, childOrder);
|
|
411
381
|
childOrder.forEach(
|
|
412
382
|
(childId) => preserveBlock(childId, blockId)
|
|
@@ -415,35 +385,37 @@ var withBlockReset = (reducer) => (state, action) => {
|
|
|
415
385
|
oldOrder.forEach((id) => preserveBlock(id, clientId));
|
|
416
386
|
}
|
|
417
387
|
}
|
|
418
|
-
|
|
419
|
-
updateBlockTreeForBlocks(newState, action.blocks);
|
|
420
|
-
for (const clientId of Object.keys(
|
|
421
|
-
preservedControlledInnerBlocks
|
|
422
|
-
)) {
|
|
423
|
-
if (!preservedControlledInnerBlocks[clientId]) {
|
|
424
|
-
continue;
|
|
425
|
-
}
|
|
426
|
-
if (!newState.byClientId.has(clientId)) {
|
|
427
|
-
continue;
|
|
428
|
-
}
|
|
388
|
+
for (const clientId of newState.controlledInnerBlocks) {
|
|
429
389
|
const controlledOrder = newState.order.get(clientId);
|
|
430
390
|
if (!controlledOrder?.length) {
|
|
431
391
|
continue;
|
|
432
392
|
}
|
|
433
393
|
const innerBlocks = controlledOrder.map(
|
|
434
|
-
(id) =>
|
|
394
|
+
(id) => state.tree.get(id)
|
|
435
395
|
);
|
|
436
396
|
const existingEntry = newState.tree.get(clientId);
|
|
437
397
|
if (existingEntry) {
|
|
438
398
|
existingEntry.innerBlocks = innerBlocks;
|
|
439
399
|
}
|
|
440
400
|
newState.tree.set("controlled||" + clientId, { innerBlocks });
|
|
401
|
+
const preserveTreeEntry = (blockId) => {
|
|
402
|
+
const treeEntry = state.tree.get(blockId);
|
|
403
|
+
if (!treeEntry) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
newState.tree.set(blockId, treeEntry);
|
|
407
|
+
const childOrder = newState.order.get(blockId) || [];
|
|
408
|
+
childOrder.forEach(preserveTreeEntry);
|
|
409
|
+
};
|
|
410
|
+
controlledOrder.forEach(preserveTreeEntry);
|
|
411
|
+
}
|
|
412
|
+
const preservedBlockEditingModes = state?.blockEditingModes ?? /* @__PURE__ */ new Map();
|
|
413
|
+
for (const [clientId, mode] of preservedBlockEditingModes) {
|
|
414
|
+
if (!newState.tree.has(clientId)) {
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
417
|
+
newState.blockEditingModes.set(clientId, mode);
|
|
441
418
|
}
|
|
442
|
-
newState.tree.set("", {
|
|
443
|
-
innerBlocks: action.blocks.map(
|
|
444
|
-
(subBlock) => newState.tree.get(subBlock.clientId)
|
|
445
|
-
)
|
|
446
|
-
});
|
|
447
419
|
return newState;
|
|
448
420
|
}
|
|
449
421
|
return reducer(state, action);
|
|
@@ -453,12 +425,12 @@ var withReplaceInnerBlocks = (reducer) => (state, action) => {
|
|
|
453
425
|
return reducer(state, action);
|
|
454
426
|
}
|
|
455
427
|
const nestedControllers = {};
|
|
456
|
-
if (
|
|
428
|
+
if (state.controlledInnerBlocks.size) {
|
|
457
429
|
const stack = [...action.blocks];
|
|
458
430
|
while (stack.length) {
|
|
459
431
|
const { innerBlocks, ...block } = stack.shift();
|
|
460
432
|
stack.push(...innerBlocks);
|
|
461
|
-
if (
|
|
433
|
+
if (state.controlledInnerBlocks.has(block.clientId)) {
|
|
462
434
|
nestedControllers[block.clientId] = true;
|
|
463
435
|
}
|
|
464
436
|
}
|
|
@@ -495,26 +467,6 @@ var withReplaceInnerBlocks = (reducer) => (state, action) => {
|
|
|
495
467
|
}
|
|
496
468
|
return stateAfterInsert;
|
|
497
469
|
};
|
|
498
|
-
var withSaveReusableBlock = (reducer) => (state, action) => {
|
|
499
|
-
if (state && action.type === "SAVE_REUSABLE_BLOCK_SUCCESS") {
|
|
500
|
-
const { id, updatedId } = action;
|
|
501
|
-
if (id === updatedId) {
|
|
502
|
-
return state;
|
|
503
|
-
}
|
|
504
|
-
state = { ...state };
|
|
505
|
-
state.attributes = new Map(state.attributes);
|
|
506
|
-
state.attributes.forEach((attributes, clientId) => {
|
|
507
|
-
const { name } = state.byClientId.get(clientId);
|
|
508
|
-
if (name === "core/block" && attributes.ref === id) {
|
|
509
|
-
state.attributes.set(clientId, {
|
|
510
|
-
...attributes,
|
|
511
|
-
ref: updatedId
|
|
512
|
-
});
|
|
513
|
-
}
|
|
514
|
-
});
|
|
515
|
-
}
|
|
516
|
-
return reducer(state, action);
|
|
517
|
-
};
|
|
518
470
|
var withResetControlledBlocks = (reducer) => (state, action) => {
|
|
519
471
|
if (action.type === "SET_HAS_CONTROLLED_INNER_BLOCKS") {
|
|
520
472
|
const innerBlockOrder = state.order.get(action.clientId);
|
|
@@ -532,8 +484,6 @@ var withResetControlledBlocks = (reducer) => (state, action) => {
|
|
|
532
484
|
};
|
|
533
485
|
var blocks = pipe(
|
|
534
486
|
combineReducers,
|
|
535
|
-
withSaveReusableBlock,
|
|
536
|
-
// Needs to be before withBlockCache.
|
|
537
487
|
withBlockTree,
|
|
538
488
|
// Needs to be before withInnerBlocksRemoveCascade.
|
|
539
489
|
withInnerBlocksRemoveCascade,
|
|
@@ -904,12 +854,38 @@ var blocks = pipe(
|
|
|
904
854
|
}
|
|
905
855
|
return state;
|
|
906
856
|
},
|
|
907
|
-
controlledInnerBlocks(state =
|
|
857
|
+
controlledInnerBlocks(state = /* @__PURE__ */ new Set(), { type, clientId, hasControlledInnerBlocks }) {
|
|
908
858
|
if (type === "SET_HAS_CONTROLLED_INNER_BLOCKS") {
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
859
|
+
if (hasControlledInnerBlocks) {
|
|
860
|
+
if (state.has(clientId)) {
|
|
861
|
+
return state;
|
|
862
|
+
}
|
|
863
|
+
return new Set(state).add(clientId);
|
|
864
|
+
}
|
|
865
|
+
if (!state.has(clientId)) {
|
|
866
|
+
return state;
|
|
867
|
+
}
|
|
868
|
+
const newState = new Set(state);
|
|
869
|
+
newState.delete(clientId);
|
|
870
|
+
return newState;
|
|
871
|
+
}
|
|
872
|
+
return state;
|
|
873
|
+
},
|
|
874
|
+
blockEditingModes(state = /* @__PURE__ */ new Map(), action) {
|
|
875
|
+
switch (action.type) {
|
|
876
|
+
case "SET_BLOCK_EDITING_MODE":
|
|
877
|
+
if (state.get(action.clientId) === action.mode) {
|
|
878
|
+
return state;
|
|
879
|
+
}
|
|
880
|
+
return new Map(state).set(action.clientId, action.mode);
|
|
881
|
+
case "UNSET_BLOCK_EDITING_MODE": {
|
|
882
|
+
if (!state.has(action.clientId)) {
|
|
883
|
+
return state;
|
|
884
|
+
}
|
|
885
|
+
const newState = new Map(state);
|
|
886
|
+
newState.delete(action.clientId);
|
|
887
|
+
return newState;
|
|
888
|
+
}
|
|
913
889
|
}
|
|
914
890
|
return state;
|
|
915
891
|
}
|
|
@@ -1233,7 +1209,7 @@ function preferences(state = PREFERENCES_DEFAULTS, action) {
|
|
|
1233
1209
|
}
|
|
1234
1210
|
return state;
|
|
1235
1211
|
}
|
|
1236
|
-
var blockListSettings = (state =
|
|
1212
|
+
var blockListSettings = (state = /* @__PURE__ */ new Map(), action) => {
|
|
1237
1213
|
switch (action.type) {
|
|
1238
1214
|
case "REPLACE_BLOCKS": {
|
|
1239
1215
|
const replacementIds = /* @__PURE__ */ new Set();
|
|
@@ -1243,40 +1219,38 @@ var blockListSettings = (state = {}, action) => {
|
|
|
1243
1219
|
replacementIds.add(block.clientId);
|
|
1244
1220
|
stack.push(...block.innerBlocks);
|
|
1245
1221
|
}
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1222
|
+
const newState = new Map(state);
|
|
1223
|
+
for (const clientId of action.clientIds) {
|
|
1224
|
+
if (!replacementIds.has(clientId)) {
|
|
1225
|
+
newState.delete(clientId);
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
return newState;
|
|
1251
1229
|
}
|
|
1252
1230
|
case "REMOVE_BLOCKS": {
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1231
|
+
const newState = new Map(state);
|
|
1232
|
+
for (const clientId of action.clientIds) {
|
|
1233
|
+
newState.delete(clientId);
|
|
1234
|
+
}
|
|
1235
|
+
return newState;
|
|
1258
1236
|
}
|
|
1259
1237
|
case "UPDATE_BLOCK_LIST_SETTINGS": {
|
|
1260
|
-
const updates = typeof action.clientId === "string" ?
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
}
|
|
1266
|
-
} else if (fastDeepEqual(state[clientId], updates[clientId])) {
|
|
1267
|
-
delete updates[clientId];
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
if (Object.keys(updates).length === 0) {
|
|
1238
|
+
const updates = typeof action.clientId === "string" ? [[action.clientId, action.settings]] : Object.entries(action.clientId);
|
|
1239
|
+
const relevantUpdates = updates.filter(
|
|
1240
|
+
([clientId, nextSettings]) => !nextSettings ? state.has(clientId) : !fastDeepEqual(state.get(clientId), nextSettings)
|
|
1241
|
+
);
|
|
1242
|
+
if (!relevantUpdates.length) {
|
|
1271
1243
|
return state;
|
|
1272
1244
|
}
|
|
1273
|
-
const
|
|
1274
|
-
for (const clientId
|
|
1275
|
-
if (!
|
|
1276
|
-
delete
|
|
1245
|
+
const newState = new Map(state);
|
|
1246
|
+
for (const [clientId, nextSettings] of relevantUpdates) {
|
|
1247
|
+
if (!nextSettings) {
|
|
1248
|
+
newState.delete(clientId);
|
|
1249
|
+
} else {
|
|
1250
|
+
newState.set(clientId, nextSettings);
|
|
1277
1251
|
}
|
|
1278
1252
|
}
|
|
1279
|
-
return
|
|
1253
|
+
return newState;
|
|
1280
1254
|
}
|
|
1281
1255
|
}
|
|
1282
1256
|
return state;
|
|
@@ -1373,26 +1347,21 @@ function editedContentOnlySection(state, action) {
|
|
|
1373
1347
|
if (action.type === "EDIT_CONTENT_ONLY_SECTION") {
|
|
1374
1348
|
return action.clientId;
|
|
1375
1349
|
}
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1350
|
+
if (!state) {
|
|
1351
|
+
return state;
|
|
1352
|
+
}
|
|
1379
1353
|
switch (action.type) {
|
|
1380
|
-
case "
|
|
1381
|
-
|
|
1382
|
-
|
|
1354
|
+
case "REMOVE_BLOCKS":
|
|
1355
|
+
case "REPLACE_BLOCKS":
|
|
1356
|
+
if (action.clientIds.includes(state)) {
|
|
1357
|
+
return void 0;
|
|
1383
1358
|
}
|
|
1384
|
-
|
|
1385
|
-
case "
|
|
1386
|
-
if (!
|
|
1387
|
-
return
|
|
1359
|
+
break;
|
|
1360
|
+
case "RESET_BLOCKS":
|
|
1361
|
+
if (!getFlattenedClientIds(action.blocks)[state]) {
|
|
1362
|
+
return void 0;
|
|
1388
1363
|
}
|
|
1389
|
-
|
|
1390
|
-
newState.delete(action.clientId);
|
|
1391
|
-
return newState;
|
|
1392
|
-
}
|
|
1393
|
-
case "RESET_BLOCKS": {
|
|
1394
|
-
return state.has("") ? (/* @__PURE__ */ new Map()).set("", state.get("")) : state;
|
|
1395
|
-
}
|
|
1364
|
+
break;
|
|
1396
1365
|
}
|
|
1397
1366
|
return state;
|
|
1398
1367
|
}
|
|
@@ -1531,7 +1500,6 @@ var combinedReducers = combineReducers({
|
|
|
1531
1500
|
editedContentOnlySection,
|
|
1532
1501
|
blockVisibility,
|
|
1533
1502
|
viewportModalClientIds,
|
|
1534
|
-
blockEditingModes,
|
|
1535
1503
|
styleOverrides,
|
|
1536
1504
|
removalPromptData,
|
|
1537
1505
|
blockRemovalRules,
|
|
@@ -1554,7 +1522,7 @@ function getBlockTreeBlock(state, clientId) {
|
|
|
1554
1522
|
...rootBlock
|
|
1555
1523
|
};
|
|
1556
1524
|
}
|
|
1557
|
-
if (!state.blocks.controlledInnerBlocks
|
|
1525
|
+
if (!state.blocks.controlledInnerBlocks.has(clientId)) {
|
|
1558
1526
|
return state.blocks.tree.get(clientId);
|
|
1559
1527
|
}
|
|
1560
1528
|
const controlledTree = state.blocks.tree.get(`controlled||${clientId}`);
|
|
@@ -1597,12 +1565,12 @@ function getDerivedBlockEditingModesForTree(state, treeClientId = "") {
|
|
|
1597
1565
|
const derivedBlockEditingModes = /* @__PURE__ */ new Map();
|
|
1598
1566
|
const sectionRootClientId = state.settings?.[sectionRootClientIdKey];
|
|
1599
1567
|
const sectionClientIds = state.blocks.order.get(sectionRootClientId);
|
|
1600
|
-
const hasDisabledBlocks = Array.from(state.blockEditingModes).some(
|
|
1568
|
+
const hasDisabledBlocks = Array.from(state.blocks.blockEditingModes).some(
|
|
1601
1569
|
([, mode]) => mode === "disabled"
|
|
1602
1570
|
);
|
|
1603
1571
|
const templatePartClientIds = [];
|
|
1604
1572
|
const syncedPatternClientIds = [];
|
|
1605
|
-
|
|
1573
|
+
state.blocks.controlledInnerBlocks.forEach((clientId) => {
|
|
1606
1574
|
const block = state.blocks.byClientId?.get(clientId);
|
|
1607
1575
|
if (block?.name === "core/template-part") {
|
|
1608
1576
|
templatePartClientIds.push(clientId);
|
|
@@ -1611,10 +1579,10 @@ function getDerivedBlockEditingModesForTree(state, treeClientId = "") {
|
|
|
1611
1579
|
syncedPatternClientIds.push(clientId);
|
|
1612
1580
|
}
|
|
1613
1581
|
});
|
|
1614
|
-
const contentOnlyTemplateLockedClientIds =
|
|
1582
|
+
const contentOnlyTemplateLockedClientIds = Array.from(
|
|
1615
1583
|
state.blockListSettings
|
|
1616
|
-
).
|
|
1617
|
-
(clientId) =>
|
|
1584
|
+
).flatMap(
|
|
1585
|
+
([clientId, listSettings]) => listSettings?.templateLock === "contentOnly" ? [clientId] : []
|
|
1618
1586
|
);
|
|
1619
1587
|
const isIsolatedEditor = state.settings?.[isIsolatedEditorKey];
|
|
1620
1588
|
const disableContentOnlyForUnsyncedPatterns = state.settings?.disableContentOnlyForUnsyncedPatterns;
|
|
@@ -1640,15 +1608,15 @@ function getDerivedBlockEditingModesForTree(state, treeClientId = "") {
|
|
|
1640
1608
|
return;
|
|
1641
1609
|
}
|
|
1642
1610
|
}
|
|
1643
|
-
if (state.blockEditingModes.has(clientId)) {
|
|
1611
|
+
if (state.blocks.blockEditingModes.has(clientId)) {
|
|
1644
1612
|
return;
|
|
1645
1613
|
}
|
|
1646
1614
|
if (hasDisabledBlocks) {
|
|
1647
1615
|
let ancestorBlockEditingMode;
|
|
1648
1616
|
let parent = state.blocks.parents.get(clientId);
|
|
1649
1617
|
while (parent !== void 0) {
|
|
1650
|
-
if (state.blockEditingModes.has(parent)) {
|
|
1651
|
-
ancestorBlockEditingMode = state.blockEditingModes.get(parent);
|
|
1618
|
+
if (state.blocks.blockEditingModes.has(parent)) {
|
|
1619
|
+
ancestorBlockEditingMode = state.blocks.blockEditingModes.get(parent);
|
|
1652
1620
|
}
|
|
1653
1621
|
if (ancestorBlockEditingMode) {
|
|
1654
1622
|
break;
|
|
@@ -1861,8 +1829,8 @@ function withDerivedBlockEditingModes(reducer) {
|
|
|
1861
1829
|
const removedClientIds = [];
|
|
1862
1830
|
const updates = typeof action.clientId === "string" ? { [action.clientId]: action.settings } : action.clientId;
|
|
1863
1831
|
for (const clientId in updates) {
|
|
1864
|
-
const isNewContentOnlyBlock = state.blockListSettings
|
|
1865
|
-
const wasContentOnlyBlock = state.blockListSettings
|
|
1832
|
+
const isNewContentOnlyBlock = state.blockListSettings.get(clientId)?.templateLock !== "contentOnly" && nextState.blockListSettings.get(clientId)?.templateLock === "contentOnly";
|
|
1833
|
+
const wasContentOnlyBlock = state.blockListSettings.get(clientId)?.templateLock === "contentOnly" && nextState.blockListSettings.get(clientId)?.templateLock !== "contentOnly";
|
|
1866
1834
|
if (isNewContentOnlyBlock) {
|
|
1867
1835
|
addedBlocks.push(
|
|
1868
1836
|
nextState.blocks.tree.get(clientId)
|
|
@@ -2023,7 +1991,6 @@ var reducer_default = pipe(
|
|
|
2023
1991
|
withAutomaticChangeReset
|
|
2024
1992
|
)(combinedReducers);
|
|
2025
1993
|
export {
|
|
2026
|
-
blockEditingModes,
|
|
2027
1994
|
blockListSettings,
|
|
2028
1995
|
blockVisibility,
|
|
2029
1996
|
blocks,
|