@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
package/build/store/reducer.cjs
CHANGED
|
@@ -30,7 +30,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// packages/block-editor/src/store/reducer.js
|
|
31
31
|
var reducer_exports = {};
|
|
32
32
|
__export(reducer_exports, {
|
|
33
|
-
blockEditingModes: () => blockEditingModes,
|
|
34
33
|
blockListSettings: () => blockListSettings,
|
|
35
34
|
blockVisibility: () => blockVisibility,
|
|
36
35
|
blocks: () => blocks,
|
|
@@ -174,7 +173,7 @@ function updateParentInnerBlocksInTree(state, updatedClientIds, updateChildrenOf
|
|
|
174
173
|
for (const clientId of updatedClientIds) {
|
|
175
174
|
let current = updateChildrenOfUpdatedClientIds ? clientId : state.parents.get(clientId);
|
|
176
175
|
do {
|
|
177
|
-
if (state.controlledInnerBlocks
|
|
176
|
+
if (state.controlledInnerBlocks.has(current)) {
|
|
178
177
|
controlledParents.add(current);
|
|
179
178
|
break;
|
|
180
179
|
} else {
|
|
@@ -325,27 +324,6 @@ var withBlockTree = (reducer) => (state = {}, action) => {
|
|
|
325
324
|
);
|
|
326
325
|
break;
|
|
327
326
|
}
|
|
328
|
-
case "SAVE_REUSABLE_BLOCK_SUCCESS": {
|
|
329
|
-
const updatedBlockUids = [];
|
|
330
|
-
newState.attributes.forEach((attributes, clientId) => {
|
|
331
|
-
if (newState.byClientId.get(clientId).name === "core/block" && attributes.ref === action.updatedId) {
|
|
332
|
-
updatedBlockUids.push(clientId);
|
|
333
|
-
}
|
|
334
|
-
});
|
|
335
|
-
newState.tree = new Map(newState.tree);
|
|
336
|
-
updatedBlockUids.forEach((clientId) => {
|
|
337
|
-
newState.tree.set(clientId, {
|
|
338
|
-
...newState.byClientId.get(clientId),
|
|
339
|
-
attributes: newState.attributes.get(clientId),
|
|
340
|
-
innerBlocks: newState.tree.get(clientId).innerBlocks
|
|
341
|
-
});
|
|
342
|
-
});
|
|
343
|
-
updateParentInnerBlocksInTree(
|
|
344
|
-
newState,
|
|
345
|
-
updatedBlockUids,
|
|
346
|
-
false
|
|
347
|
-
);
|
|
348
|
-
}
|
|
349
327
|
}
|
|
350
328
|
return newState;
|
|
351
329
|
};
|
|
@@ -434,44 +412,35 @@ var withInnerBlocksRemoveCascade = (reducer) => (state, action) => {
|
|
|
434
412
|
};
|
|
435
413
|
var withBlockReset = (reducer) => (state, action) => {
|
|
436
414
|
if (action.type === "RESET_BLOCKS") {
|
|
437
|
-
const
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
attributes: new Map(getFlattenedBlockAttributes(action.blocks)),
|
|
444
|
-
order: mapBlockOrder(action.blocks),
|
|
445
|
-
parents: new Map(mapBlockParents(action.blocks)),
|
|
446
|
-
controlledInnerBlocks: preservedControlledInnerBlocks
|
|
447
|
-
};
|
|
415
|
+
const newState = reducer(void 0, {
|
|
416
|
+
type: "INSERT_BLOCKS",
|
|
417
|
+
rootClientId: "",
|
|
418
|
+
blocks: action.blocks
|
|
419
|
+
});
|
|
420
|
+
const preservedControlledInnerBlocks = state?.controlledInnerBlocks ?? /* @__PURE__ */ new Set();
|
|
448
421
|
if (state?.order) {
|
|
449
|
-
for (const clientId of
|
|
450
|
-
preservedControlledInnerBlocks
|
|
451
|
-
)) {
|
|
452
|
-
if (!preservedControlledInnerBlocks[clientId]) {
|
|
453
|
-
continue;
|
|
454
|
-
}
|
|
422
|
+
for (const clientId of preservedControlledInnerBlocks) {
|
|
455
423
|
if (!newState.byClientId.has(clientId)) {
|
|
456
424
|
continue;
|
|
457
425
|
}
|
|
426
|
+
newState.controlledInnerBlocks.add(clientId);
|
|
458
427
|
const oldOrder = state.order.get(clientId);
|
|
459
428
|
if (!oldOrder?.length) {
|
|
460
429
|
continue;
|
|
461
430
|
}
|
|
462
431
|
newState.order.set(clientId, oldOrder);
|
|
463
432
|
const preserveBlock = (blockId, parentId) => {
|
|
464
|
-
const blockData = state.byClientId
|
|
433
|
+
const blockData = state.byClientId.get(blockId);
|
|
465
434
|
if (!blockData) {
|
|
466
435
|
return;
|
|
467
436
|
}
|
|
468
437
|
newState.byClientId.set(blockId, blockData);
|
|
469
438
|
newState.attributes.set(
|
|
470
439
|
blockId,
|
|
471
|
-
state.attributes
|
|
440
|
+
state.attributes.get(blockId)
|
|
472
441
|
);
|
|
473
442
|
newState.parents.set(blockId, parentId);
|
|
474
|
-
const childOrder = state.order
|
|
443
|
+
const childOrder = state.order.get(blockId) || [];
|
|
475
444
|
newState.order.set(blockId, childOrder);
|
|
476
445
|
childOrder.forEach(
|
|
477
446
|
(childId) => preserveBlock(childId, blockId)
|
|
@@ -480,35 +449,37 @@ var withBlockReset = (reducer) => (state, action) => {
|
|
|
480
449
|
oldOrder.forEach((id) => preserveBlock(id, clientId));
|
|
481
450
|
}
|
|
482
451
|
}
|
|
483
|
-
|
|
484
|
-
updateBlockTreeForBlocks(newState, action.blocks);
|
|
485
|
-
for (const clientId of Object.keys(
|
|
486
|
-
preservedControlledInnerBlocks
|
|
487
|
-
)) {
|
|
488
|
-
if (!preservedControlledInnerBlocks[clientId]) {
|
|
489
|
-
continue;
|
|
490
|
-
}
|
|
491
|
-
if (!newState.byClientId.has(clientId)) {
|
|
492
|
-
continue;
|
|
493
|
-
}
|
|
452
|
+
for (const clientId of newState.controlledInnerBlocks) {
|
|
494
453
|
const controlledOrder = newState.order.get(clientId);
|
|
495
454
|
if (!controlledOrder?.length) {
|
|
496
455
|
continue;
|
|
497
456
|
}
|
|
498
457
|
const innerBlocks = controlledOrder.map(
|
|
499
|
-
(id) =>
|
|
458
|
+
(id) => state.tree.get(id)
|
|
500
459
|
);
|
|
501
460
|
const existingEntry = newState.tree.get(clientId);
|
|
502
461
|
if (existingEntry) {
|
|
503
462
|
existingEntry.innerBlocks = innerBlocks;
|
|
504
463
|
}
|
|
505
464
|
newState.tree.set("controlled||" + clientId, { innerBlocks });
|
|
465
|
+
const preserveTreeEntry = (blockId) => {
|
|
466
|
+
const treeEntry = state.tree.get(blockId);
|
|
467
|
+
if (!treeEntry) {
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
newState.tree.set(blockId, treeEntry);
|
|
471
|
+
const childOrder = newState.order.get(blockId) || [];
|
|
472
|
+
childOrder.forEach(preserveTreeEntry);
|
|
473
|
+
};
|
|
474
|
+
controlledOrder.forEach(preserveTreeEntry);
|
|
475
|
+
}
|
|
476
|
+
const preservedBlockEditingModes = state?.blockEditingModes ?? /* @__PURE__ */ new Map();
|
|
477
|
+
for (const [clientId, mode] of preservedBlockEditingModes) {
|
|
478
|
+
if (!newState.tree.has(clientId)) {
|
|
479
|
+
continue;
|
|
480
|
+
}
|
|
481
|
+
newState.blockEditingModes.set(clientId, mode);
|
|
506
482
|
}
|
|
507
|
-
newState.tree.set("", {
|
|
508
|
-
innerBlocks: action.blocks.map(
|
|
509
|
-
(subBlock) => newState.tree.get(subBlock.clientId)
|
|
510
|
-
)
|
|
511
|
-
});
|
|
512
483
|
return newState;
|
|
513
484
|
}
|
|
514
485
|
return reducer(state, action);
|
|
@@ -518,12 +489,12 @@ var withReplaceInnerBlocks = (reducer) => (state, action) => {
|
|
|
518
489
|
return reducer(state, action);
|
|
519
490
|
}
|
|
520
491
|
const nestedControllers = {};
|
|
521
|
-
if (
|
|
492
|
+
if (state.controlledInnerBlocks.size) {
|
|
522
493
|
const stack = [...action.blocks];
|
|
523
494
|
while (stack.length) {
|
|
524
495
|
const { innerBlocks, ...block } = stack.shift();
|
|
525
496
|
stack.push(...innerBlocks);
|
|
526
|
-
if (
|
|
497
|
+
if (state.controlledInnerBlocks.has(block.clientId)) {
|
|
527
498
|
nestedControllers[block.clientId] = true;
|
|
528
499
|
}
|
|
529
500
|
}
|
|
@@ -560,26 +531,6 @@ var withReplaceInnerBlocks = (reducer) => (state, action) => {
|
|
|
560
531
|
}
|
|
561
532
|
return stateAfterInsert;
|
|
562
533
|
};
|
|
563
|
-
var withSaveReusableBlock = (reducer) => (state, action) => {
|
|
564
|
-
if (state && action.type === "SAVE_REUSABLE_BLOCK_SUCCESS") {
|
|
565
|
-
const { id, updatedId } = action;
|
|
566
|
-
if (id === updatedId) {
|
|
567
|
-
return state;
|
|
568
|
-
}
|
|
569
|
-
state = { ...state };
|
|
570
|
-
state.attributes = new Map(state.attributes);
|
|
571
|
-
state.attributes.forEach((attributes, clientId) => {
|
|
572
|
-
const { name } = state.byClientId.get(clientId);
|
|
573
|
-
if (name === "core/block" && attributes.ref === id) {
|
|
574
|
-
state.attributes.set(clientId, {
|
|
575
|
-
...attributes,
|
|
576
|
-
ref: updatedId
|
|
577
|
-
});
|
|
578
|
-
}
|
|
579
|
-
});
|
|
580
|
-
}
|
|
581
|
-
return reducer(state, action);
|
|
582
|
-
};
|
|
583
534
|
var withResetControlledBlocks = (reducer) => (state, action) => {
|
|
584
535
|
if (action.type === "SET_HAS_CONTROLLED_INNER_BLOCKS") {
|
|
585
536
|
const innerBlockOrder = state.order.get(action.clientId);
|
|
@@ -597,8 +548,6 @@ var withResetControlledBlocks = (reducer) => (state, action) => {
|
|
|
597
548
|
};
|
|
598
549
|
var blocks = (0, import_compose.pipe)(
|
|
599
550
|
import_data.combineReducers,
|
|
600
|
-
withSaveReusableBlock,
|
|
601
|
-
// Needs to be before withBlockCache.
|
|
602
551
|
withBlockTree,
|
|
603
552
|
// Needs to be before withInnerBlocksRemoveCascade.
|
|
604
553
|
withInnerBlocksRemoveCascade,
|
|
@@ -969,12 +918,38 @@ var blocks = (0, import_compose.pipe)(
|
|
|
969
918
|
}
|
|
970
919
|
return state;
|
|
971
920
|
},
|
|
972
|
-
controlledInnerBlocks(state =
|
|
921
|
+
controlledInnerBlocks(state = /* @__PURE__ */ new Set(), { type, clientId, hasControlledInnerBlocks }) {
|
|
973
922
|
if (type === "SET_HAS_CONTROLLED_INNER_BLOCKS") {
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
923
|
+
if (hasControlledInnerBlocks) {
|
|
924
|
+
if (state.has(clientId)) {
|
|
925
|
+
return state;
|
|
926
|
+
}
|
|
927
|
+
return new Set(state).add(clientId);
|
|
928
|
+
}
|
|
929
|
+
if (!state.has(clientId)) {
|
|
930
|
+
return state;
|
|
931
|
+
}
|
|
932
|
+
const newState = new Set(state);
|
|
933
|
+
newState.delete(clientId);
|
|
934
|
+
return newState;
|
|
935
|
+
}
|
|
936
|
+
return state;
|
|
937
|
+
},
|
|
938
|
+
blockEditingModes(state = /* @__PURE__ */ new Map(), action) {
|
|
939
|
+
switch (action.type) {
|
|
940
|
+
case "SET_BLOCK_EDITING_MODE":
|
|
941
|
+
if (state.get(action.clientId) === action.mode) {
|
|
942
|
+
return state;
|
|
943
|
+
}
|
|
944
|
+
return new Map(state).set(action.clientId, action.mode);
|
|
945
|
+
case "UNSET_BLOCK_EDITING_MODE": {
|
|
946
|
+
if (!state.has(action.clientId)) {
|
|
947
|
+
return state;
|
|
948
|
+
}
|
|
949
|
+
const newState = new Map(state);
|
|
950
|
+
newState.delete(action.clientId);
|
|
951
|
+
return newState;
|
|
952
|
+
}
|
|
978
953
|
}
|
|
979
954
|
return state;
|
|
980
955
|
}
|
|
@@ -1298,7 +1273,7 @@ function preferences(state = import_defaults.PREFERENCES_DEFAULTS, action) {
|
|
|
1298
1273
|
}
|
|
1299
1274
|
return state;
|
|
1300
1275
|
}
|
|
1301
|
-
var blockListSettings = (state =
|
|
1276
|
+
var blockListSettings = (state = /* @__PURE__ */ new Map(), action) => {
|
|
1302
1277
|
switch (action.type) {
|
|
1303
1278
|
case "REPLACE_BLOCKS": {
|
|
1304
1279
|
const replacementIds = /* @__PURE__ */ new Set();
|
|
@@ -1308,40 +1283,38 @@ var blockListSettings = (state = {}, action) => {
|
|
|
1308
1283
|
replacementIds.add(block.clientId);
|
|
1309
1284
|
stack.push(...block.innerBlocks);
|
|
1310
1285
|
}
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1286
|
+
const newState = new Map(state);
|
|
1287
|
+
for (const clientId of action.clientIds) {
|
|
1288
|
+
if (!replacementIds.has(clientId)) {
|
|
1289
|
+
newState.delete(clientId);
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
return newState;
|
|
1316
1293
|
}
|
|
1317
1294
|
case "REMOVE_BLOCKS": {
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1295
|
+
const newState = new Map(state);
|
|
1296
|
+
for (const clientId of action.clientIds) {
|
|
1297
|
+
newState.delete(clientId);
|
|
1298
|
+
}
|
|
1299
|
+
return newState;
|
|
1323
1300
|
}
|
|
1324
1301
|
case "UPDATE_BLOCK_LIST_SETTINGS": {
|
|
1325
|
-
const updates = typeof action.clientId === "string" ?
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
}
|
|
1331
|
-
} else if ((0, import_es6.default)(state[clientId], updates[clientId])) {
|
|
1332
|
-
delete updates[clientId];
|
|
1333
|
-
}
|
|
1334
|
-
}
|
|
1335
|
-
if (Object.keys(updates).length === 0) {
|
|
1302
|
+
const updates = typeof action.clientId === "string" ? [[action.clientId, action.settings]] : Object.entries(action.clientId);
|
|
1303
|
+
const relevantUpdates = updates.filter(
|
|
1304
|
+
([clientId, nextSettings]) => !nextSettings ? state.has(clientId) : !(0, import_es6.default)(state.get(clientId), nextSettings)
|
|
1305
|
+
);
|
|
1306
|
+
if (!relevantUpdates.length) {
|
|
1336
1307
|
return state;
|
|
1337
1308
|
}
|
|
1338
|
-
const
|
|
1339
|
-
for (const clientId
|
|
1340
|
-
if (!
|
|
1341
|
-
delete
|
|
1309
|
+
const newState = new Map(state);
|
|
1310
|
+
for (const [clientId, nextSettings] of relevantUpdates) {
|
|
1311
|
+
if (!nextSettings) {
|
|
1312
|
+
newState.delete(clientId);
|
|
1313
|
+
} else {
|
|
1314
|
+
newState.set(clientId, nextSettings);
|
|
1342
1315
|
}
|
|
1343
1316
|
}
|
|
1344
|
-
return
|
|
1317
|
+
return newState;
|
|
1345
1318
|
}
|
|
1346
1319
|
}
|
|
1347
1320
|
return state;
|
|
@@ -1438,26 +1411,21 @@ function editedContentOnlySection(state, action) {
|
|
|
1438
1411
|
if (action.type === "EDIT_CONTENT_ONLY_SECTION") {
|
|
1439
1412
|
return action.clientId;
|
|
1440
1413
|
}
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1414
|
+
if (!state) {
|
|
1415
|
+
return state;
|
|
1416
|
+
}
|
|
1444
1417
|
switch (action.type) {
|
|
1445
|
-
case "
|
|
1446
|
-
|
|
1447
|
-
|
|
1418
|
+
case "REMOVE_BLOCKS":
|
|
1419
|
+
case "REPLACE_BLOCKS":
|
|
1420
|
+
if (action.clientIds.includes(state)) {
|
|
1421
|
+
return void 0;
|
|
1448
1422
|
}
|
|
1449
|
-
|
|
1450
|
-
case "
|
|
1451
|
-
if (!
|
|
1452
|
-
return
|
|
1423
|
+
break;
|
|
1424
|
+
case "RESET_BLOCKS":
|
|
1425
|
+
if (!getFlattenedClientIds(action.blocks)[state]) {
|
|
1426
|
+
return void 0;
|
|
1453
1427
|
}
|
|
1454
|
-
|
|
1455
|
-
newState.delete(action.clientId);
|
|
1456
|
-
return newState;
|
|
1457
|
-
}
|
|
1458
|
-
case "RESET_BLOCKS": {
|
|
1459
|
-
return state.has("") ? (/* @__PURE__ */ new Map()).set("", state.get("")) : state;
|
|
1460
|
-
}
|
|
1428
|
+
break;
|
|
1461
1429
|
}
|
|
1462
1430
|
return state;
|
|
1463
1431
|
}
|
|
@@ -1596,7 +1564,6 @@ var combinedReducers = (0, import_data.combineReducers)({
|
|
|
1596
1564
|
editedContentOnlySection,
|
|
1597
1565
|
blockVisibility,
|
|
1598
1566
|
viewportModalClientIds,
|
|
1599
|
-
blockEditingModes,
|
|
1600
1567
|
styleOverrides,
|
|
1601
1568
|
removalPromptData,
|
|
1602
1569
|
blockRemovalRules,
|
|
@@ -1619,7 +1586,7 @@ function getBlockTreeBlock(state, clientId) {
|
|
|
1619
1586
|
...rootBlock
|
|
1620
1587
|
};
|
|
1621
1588
|
}
|
|
1622
|
-
if (!state.blocks.controlledInnerBlocks
|
|
1589
|
+
if (!state.blocks.controlledInnerBlocks.has(clientId)) {
|
|
1623
1590
|
return state.blocks.tree.get(clientId);
|
|
1624
1591
|
}
|
|
1625
1592
|
const controlledTree = state.blocks.tree.get(`controlled||${clientId}`);
|
|
@@ -1662,12 +1629,12 @@ function getDerivedBlockEditingModesForTree(state, treeClientId = "") {
|
|
|
1662
1629
|
const derivedBlockEditingModes = /* @__PURE__ */ new Map();
|
|
1663
1630
|
const sectionRootClientId = state.settings?.[import_private_keys.sectionRootClientIdKey];
|
|
1664
1631
|
const sectionClientIds = state.blocks.order.get(sectionRootClientId);
|
|
1665
|
-
const hasDisabledBlocks = Array.from(state.blockEditingModes).some(
|
|
1632
|
+
const hasDisabledBlocks = Array.from(state.blocks.blockEditingModes).some(
|
|
1666
1633
|
([, mode]) => mode === "disabled"
|
|
1667
1634
|
);
|
|
1668
1635
|
const templatePartClientIds = [];
|
|
1669
1636
|
const syncedPatternClientIds = [];
|
|
1670
|
-
|
|
1637
|
+
state.blocks.controlledInnerBlocks.forEach((clientId) => {
|
|
1671
1638
|
const block = state.blocks.byClientId?.get(clientId);
|
|
1672
1639
|
if (block?.name === "core/template-part") {
|
|
1673
1640
|
templatePartClientIds.push(clientId);
|
|
@@ -1676,10 +1643,10 @@ function getDerivedBlockEditingModesForTree(state, treeClientId = "") {
|
|
|
1676
1643
|
syncedPatternClientIds.push(clientId);
|
|
1677
1644
|
}
|
|
1678
1645
|
});
|
|
1679
|
-
const contentOnlyTemplateLockedClientIds =
|
|
1646
|
+
const contentOnlyTemplateLockedClientIds = Array.from(
|
|
1680
1647
|
state.blockListSettings
|
|
1681
|
-
).
|
|
1682
|
-
(clientId) =>
|
|
1648
|
+
).flatMap(
|
|
1649
|
+
([clientId, listSettings]) => listSettings?.templateLock === "contentOnly" ? [clientId] : []
|
|
1683
1650
|
);
|
|
1684
1651
|
const isIsolatedEditor = state.settings?.[import_private_keys.isIsolatedEditorKey];
|
|
1685
1652
|
const disableContentOnlyForUnsyncedPatterns = state.settings?.disableContentOnlyForUnsyncedPatterns;
|
|
@@ -1705,15 +1672,15 @@ function getDerivedBlockEditingModesForTree(state, treeClientId = "") {
|
|
|
1705
1672
|
return;
|
|
1706
1673
|
}
|
|
1707
1674
|
}
|
|
1708
|
-
if (state.blockEditingModes.has(clientId)) {
|
|
1675
|
+
if (state.blocks.blockEditingModes.has(clientId)) {
|
|
1709
1676
|
return;
|
|
1710
1677
|
}
|
|
1711
1678
|
if (hasDisabledBlocks) {
|
|
1712
1679
|
let ancestorBlockEditingMode;
|
|
1713
1680
|
let parent = state.blocks.parents.get(clientId);
|
|
1714
1681
|
while (parent !== void 0) {
|
|
1715
|
-
if (state.blockEditingModes.has(parent)) {
|
|
1716
|
-
ancestorBlockEditingMode = state.blockEditingModes.get(parent);
|
|
1682
|
+
if (state.blocks.blockEditingModes.has(parent)) {
|
|
1683
|
+
ancestorBlockEditingMode = state.blocks.blockEditingModes.get(parent);
|
|
1717
1684
|
}
|
|
1718
1685
|
if (ancestorBlockEditingMode) {
|
|
1719
1686
|
break;
|
|
@@ -1926,8 +1893,8 @@ function withDerivedBlockEditingModes(reducer) {
|
|
|
1926
1893
|
const removedClientIds = [];
|
|
1927
1894
|
const updates = typeof action.clientId === "string" ? { [action.clientId]: action.settings } : action.clientId;
|
|
1928
1895
|
for (const clientId in updates) {
|
|
1929
|
-
const isNewContentOnlyBlock = state.blockListSettings
|
|
1930
|
-
const wasContentOnlyBlock = state.blockListSettings
|
|
1896
|
+
const isNewContentOnlyBlock = state.blockListSettings.get(clientId)?.templateLock !== "contentOnly" && nextState.blockListSettings.get(clientId)?.templateLock === "contentOnly";
|
|
1897
|
+
const wasContentOnlyBlock = state.blockListSettings.get(clientId)?.templateLock === "contentOnly" && nextState.blockListSettings.get(clientId)?.templateLock !== "contentOnly";
|
|
1931
1898
|
if (isNewContentOnlyBlock) {
|
|
1932
1899
|
addedBlocks.push(
|
|
1933
1900
|
nextState.blocks.tree.get(clientId)
|
|
@@ -2089,7 +2056,6 @@ var reducer_default = (0, import_compose.pipe)(
|
|
|
2089
2056
|
)(combinedReducers);
|
|
2090
2057
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2091
2058
|
0 && (module.exports = {
|
|
2092
|
-
blockEditingModes,
|
|
2093
2059
|
blockListSettings,
|
|
2094
2060
|
blockVisibility,
|
|
2095
2061
|
blocks,
|