@wordpress/block-editor 15.15.0 → 15.16.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/block-inspector/index.cjs +2 -1
- package/build/components/block-inspector/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/inspector-controls-tabs/styles-tab.cjs +2 -1
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/hooks/background.cjs +74 -21
- package/build/hooks/background.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/utils.cjs +5 -1
- package/build/hooks/utils.cjs.map +2 -2
- package/build/store/actions.cjs +8 -4
- 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 +62 -95
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs +2 -2
- package/build/store/selectors.cjs.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-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/inspector-controls-tabs/styles-tab.mjs +2 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.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/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/utils.mjs +5 -1
- package/build-module/hooks/utils.mjs.map +2 -2
- package/build-module/store/actions.mjs +8 -4
- 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 +62 -94
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs +2 -2
- package/build-module/store/selectors.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 -7
- package/build-style/style.css +35 -7
- package/package.json +39 -39
- package/src/components/background-image-control/style.scss +0 -4
- package/src/components/block-inspector/index.js +1 -0
- 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/inspector-controls-tabs/styles-tab.js +1 -0
- package/src/hooks/background.js +122 -21
- package/src/hooks/background.scss +45 -0
- 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/test/cross-origin-isolation.js +7 -3
- package/src/hooks/utils.js +4 -0
- package/src/store/actions.js +9 -8
- package/src/store/private-selectors.js +2 -2
- package/src/store/reducer.js +84 -128
- package/src/store/selectors.js +2 -2
- package/src/store/test/private-selectors.js +67 -34
- package/src/store/test/reducer.js +436 -66
- package/src/store/test/selectors.js +81 -63
- package/src/style.scss +1 -0
package/src/store/reducer.js
CHANGED
|
@@ -403,31 +403,6 @@ const withBlockTree =
|
|
|
403
403
|
);
|
|
404
404
|
break;
|
|
405
405
|
}
|
|
406
|
-
case 'SAVE_REUSABLE_BLOCK_SUCCESS': {
|
|
407
|
-
const updatedBlockUids = [];
|
|
408
|
-
newState.attributes.forEach( ( attributes, clientId ) => {
|
|
409
|
-
if (
|
|
410
|
-
newState.byClientId.get( clientId ).name ===
|
|
411
|
-
'core/block' &&
|
|
412
|
-
attributes.ref === action.updatedId
|
|
413
|
-
) {
|
|
414
|
-
updatedBlockUids.push( clientId );
|
|
415
|
-
}
|
|
416
|
-
} );
|
|
417
|
-
newState.tree = new Map( newState.tree );
|
|
418
|
-
updatedBlockUids.forEach( ( clientId ) => {
|
|
419
|
-
newState.tree.set( clientId, {
|
|
420
|
-
...newState.byClientId.get( clientId ),
|
|
421
|
-
attributes: newState.attributes.get( clientId ),
|
|
422
|
-
innerBlocks: newState.tree.get( clientId ).innerBlocks,
|
|
423
|
-
} );
|
|
424
|
-
} );
|
|
425
|
-
updateParentInnerBlocksInTree(
|
|
426
|
-
newState,
|
|
427
|
-
updatedBlockUids,
|
|
428
|
-
false
|
|
429
|
-
);
|
|
430
|
-
}
|
|
431
406
|
}
|
|
432
407
|
|
|
433
408
|
return newState;
|
|
@@ -601,26 +576,23 @@ const withBlockReset = ( reducer ) => ( state, action ) => {
|
|
|
601
576
|
if ( action.type === 'RESET_BLOCKS' ) {
|
|
602
577
|
/**
|
|
603
578
|
* Preserve controlled inner block flags across RESET_BLOCKS.
|
|
604
|
-
*
|
|
605
|
-
*
|
|
606
|
-
*
|
|
607
|
-
*
|
|
608
|
-
*
|
|
579
|
+
* If there are old and new blocks that:
|
|
580
|
+
* - have the same `clientId`
|
|
581
|
+
* - have the `controlledInnerBlocks` flag
|
|
582
|
+
* - don't have any own, uncontrolled children
|
|
583
|
+
* then we preserve the `controlledInnerBlocks` flag and the controlled sub-trees.
|
|
584
|
+
* Nested controllers (e.g., `post-content`, patterns) don't lose their
|
|
585
|
+
* controlled status and don't unnecessarily re-clone blocks.
|
|
609
586
|
*/
|
|
587
|
+
const newState = reducer( undefined, {
|
|
588
|
+
type: 'INSERT_BLOCKS',
|
|
589
|
+
rootClientId: '',
|
|
590
|
+
blocks: action.blocks,
|
|
591
|
+
} );
|
|
592
|
+
|
|
610
593
|
const preservedControlledInnerBlocks =
|
|
611
594
|
state?.controlledInnerBlocks ?? {};
|
|
612
595
|
|
|
613
|
-
const newState = {
|
|
614
|
-
...state,
|
|
615
|
-
byClientId: new Map(
|
|
616
|
-
getFlattenedBlocksWithoutAttributes( action.blocks )
|
|
617
|
-
),
|
|
618
|
-
attributes: new Map( getFlattenedBlockAttributes( action.blocks ) ),
|
|
619
|
-
order: mapBlockOrder( action.blocks ),
|
|
620
|
-
parents: new Map( mapBlockParents( action.blocks ) ),
|
|
621
|
-
controlledInnerBlocks: preservedControlledInnerBlocks,
|
|
622
|
-
};
|
|
623
|
-
|
|
624
596
|
// Preserve controlled inner blocks data from the old state.
|
|
625
597
|
// The maps above are rebuilt solely from action.blocks, but
|
|
626
598
|
// controlled inner blocks live under cloned IDs that aren't
|
|
@@ -637,23 +609,24 @@ const withBlockReset = ( reducer ) => ( state, action ) => {
|
|
|
637
609
|
if ( ! newState.byClientId.has( clientId ) ) {
|
|
638
610
|
continue;
|
|
639
611
|
}
|
|
612
|
+
newState.controlledInnerBlocks[ clientId ] = true;
|
|
640
613
|
const oldOrder = state.order.get( clientId );
|
|
641
614
|
if ( ! oldOrder?.length ) {
|
|
642
615
|
continue;
|
|
643
616
|
}
|
|
644
617
|
newState.order.set( clientId, oldOrder );
|
|
645
618
|
const preserveBlock = ( blockId, parentId ) => {
|
|
646
|
-
const blockData = state.byClientId
|
|
619
|
+
const blockData = state.byClientId.get( blockId );
|
|
647
620
|
if ( ! blockData ) {
|
|
648
621
|
return;
|
|
649
622
|
}
|
|
650
623
|
newState.byClientId.set( blockId, blockData );
|
|
651
624
|
newState.attributes.set(
|
|
652
625
|
blockId,
|
|
653
|
-
state.attributes
|
|
626
|
+
state.attributes.get( blockId )
|
|
654
627
|
);
|
|
655
628
|
newState.parents.set( blockId, parentId );
|
|
656
|
-
const childOrder = state.order
|
|
629
|
+
const childOrder = state.order.get( blockId ) || [];
|
|
657
630
|
newState.order.set( blockId, childOrder );
|
|
658
631
|
childOrder.forEach( ( childId ) =>
|
|
659
632
|
preserveBlock( childId, blockId )
|
|
@@ -663,42 +636,47 @@ const withBlockReset = ( reducer ) => ( state, action ) => {
|
|
|
663
636
|
}
|
|
664
637
|
}
|
|
665
638
|
|
|
666
|
-
newState.tree = new Map( state?.tree );
|
|
667
|
-
updateBlockTreeForBlocks( newState, action.blocks );
|
|
668
|
-
|
|
669
639
|
// Fix tree entries for controlled blocks. updateBlockTreeForBlocks
|
|
670
640
|
// built tree entries using action.blocks' inner block structure
|
|
671
641
|
// (entity-level IDs), but we need them to reference the preserved
|
|
672
642
|
// cloned inner blocks instead. Mutating the existing object
|
|
673
643
|
// preserves references held by ancestor tree entries.
|
|
674
644
|
for ( const clientId of Object.keys(
|
|
675
|
-
|
|
645
|
+
newState.controlledInnerBlocks
|
|
676
646
|
) ) {
|
|
677
|
-
if ( ! preservedControlledInnerBlocks[ clientId ] ) {
|
|
678
|
-
continue;
|
|
679
|
-
}
|
|
680
|
-
if ( ! newState.byClientId.has( clientId ) ) {
|
|
681
|
-
continue;
|
|
682
|
-
}
|
|
683
647
|
const controlledOrder = newState.order.get( clientId );
|
|
684
648
|
if ( ! controlledOrder?.length ) {
|
|
685
649
|
continue;
|
|
686
650
|
}
|
|
687
651
|
const innerBlocks = controlledOrder.map( ( id ) =>
|
|
688
|
-
|
|
652
|
+
state.tree.get( id )
|
|
689
653
|
);
|
|
690
654
|
const existingEntry = newState.tree.get( clientId );
|
|
691
655
|
if ( existingEntry ) {
|
|
692
656
|
existingEntry.innerBlocks = innerBlocks;
|
|
693
657
|
}
|
|
694
658
|
newState.tree.set( 'controlled||' + clientId, { innerBlocks } );
|
|
659
|
+
const preserveTreeEntry = ( blockId ) => {
|
|
660
|
+
const treeEntry = state.tree.get( blockId );
|
|
661
|
+
if ( ! treeEntry ) {
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
newState.tree.set( blockId, treeEntry );
|
|
665
|
+
const childOrder = newState.order.get( blockId ) || [];
|
|
666
|
+
childOrder.forEach( preserveTreeEntry );
|
|
667
|
+
};
|
|
668
|
+
controlledOrder.forEach( preserveTreeEntry );
|
|
695
669
|
}
|
|
696
670
|
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
671
|
+
// Preserve block editing modes for blocks that are not removed.
|
|
672
|
+
const preservedBlockEditingModes =
|
|
673
|
+
state?.blockEditingModes ?? new Map();
|
|
674
|
+
for ( const [ clientId, mode ] of preservedBlockEditingModes ) {
|
|
675
|
+
if ( ! newState.tree.has( clientId ) ) {
|
|
676
|
+
continue;
|
|
677
|
+
}
|
|
678
|
+
newState.blockEditingModes.set( clientId, mode );
|
|
679
|
+
}
|
|
702
680
|
|
|
703
681
|
return newState;
|
|
704
682
|
}
|
|
@@ -780,40 +758,6 @@ const withReplaceInnerBlocks = ( reducer ) => ( state, action ) => {
|
|
|
780
758
|
return stateAfterInsert;
|
|
781
759
|
};
|
|
782
760
|
|
|
783
|
-
/**
|
|
784
|
-
* Higher-order reducer which targets the combined blocks reducer and handles
|
|
785
|
-
* the `SAVE_REUSABLE_BLOCK_SUCCESS` action. This action can't be handled by
|
|
786
|
-
* regular reducers and needs a higher-order reducer since it needs access to
|
|
787
|
-
* both `byClientId` and `attributes` simultaneously.
|
|
788
|
-
*
|
|
789
|
-
* @param {Function} reducer Original reducer function.
|
|
790
|
-
*
|
|
791
|
-
* @return {Function} Enhanced reducer function.
|
|
792
|
-
*/
|
|
793
|
-
const withSaveReusableBlock = ( reducer ) => ( state, action ) => {
|
|
794
|
-
if ( state && action.type === 'SAVE_REUSABLE_BLOCK_SUCCESS' ) {
|
|
795
|
-
const { id, updatedId } = action;
|
|
796
|
-
|
|
797
|
-
// If a temporary reusable block is saved, we swap the temporary id with the final one.
|
|
798
|
-
if ( id === updatedId ) {
|
|
799
|
-
return state;
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
state = { ...state };
|
|
803
|
-
state.attributes = new Map( state.attributes );
|
|
804
|
-
state.attributes.forEach( ( attributes, clientId ) => {
|
|
805
|
-
const { name } = state.byClientId.get( clientId );
|
|
806
|
-
if ( name === 'core/block' && attributes.ref === id ) {
|
|
807
|
-
state.attributes.set( clientId, {
|
|
808
|
-
...attributes,
|
|
809
|
-
ref: updatedId,
|
|
810
|
-
} );
|
|
811
|
-
}
|
|
812
|
-
} );
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
return reducer( state, action );
|
|
816
|
-
};
|
|
817
761
|
/**
|
|
818
762
|
* Higher-order reducer which removes blocks from state when switching parent block controlled state.
|
|
819
763
|
*
|
|
@@ -854,7 +798,6 @@ const withResetControlledBlocks = ( reducer ) => ( state, action ) => {
|
|
|
854
798
|
*/
|
|
855
799
|
export const blocks = pipe(
|
|
856
800
|
combineReducers,
|
|
857
|
-
withSaveReusableBlock, // Needs to be before withBlockCache.
|
|
858
801
|
withBlockTree, // Needs to be before withInnerBlocksRemoveCascade.
|
|
859
802
|
withInnerBlocksRemoveCascade,
|
|
860
803
|
withReplaceInnerBlocks, // Needs to be after withInnerBlocksRemoveCascade.
|
|
@@ -1290,6 +1233,25 @@ export const blocks = pipe(
|
|
|
1290
1233
|
}
|
|
1291
1234
|
return state;
|
|
1292
1235
|
},
|
|
1236
|
+
|
|
1237
|
+
blockEditingModes( state = new Map(), action ) {
|
|
1238
|
+
switch ( action.type ) {
|
|
1239
|
+
case 'SET_BLOCK_EDITING_MODE':
|
|
1240
|
+
if ( state.get( action.clientId ) === action.mode ) {
|
|
1241
|
+
return state;
|
|
1242
|
+
}
|
|
1243
|
+
return new Map( state ).set( action.clientId, action.mode );
|
|
1244
|
+
case 'UNSET_BLOCK_EDITING_MODE': {
|
|
1245
|
+
if ( ! state.has( action.clientId ) ) {
|
|
1246
|
+
return state;
|
|
1247
|
+
}
|
|
1248
|
+
const newState = new Map( state );
|
|
1249
|
+
newState.delete( action.clientId );
|
|
1250
|
+
return newState;
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
return state;
|
|
1254
|
+
},
|
|
1293
1255
|
} );
|
|
1294
1256
|
|
|
1295
1257
|
/**
|
|
@@ -2104,38 +2066,33 @@ export function editedContentOnlySection( state, action ) {
|
|
|
2104
2066
|
if ( action.type === 'EDIT_CONTENT_ONLY_SECTION' ) {
|
|
2105
2067
|
return action.clientId;
|
|
2106
2068
|
}
|
|
2107
|
-
return state;
|
|
2108
|
-
}
|
|
2109
2069
|
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
*
|
|
2116
|
-
* @return {Map} Updated state.
|
|
2117
|
-
*/
|
|
2118
|
-
export function blockEditingModes( state = new Map(), action ) {
|
|
2070
|
+
// Early return if there's no section being edited.
|
|
2071
|
+
if ( ! state ) {
|
|
2072
|
+
return state;
|
|
2073
|
+
}
|
|
2074
|
+
|
|
2119
2075
|
switch ( action.type ) {
|
|
2120
|
-
case '
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2076
|
+
case 'REMOVE_BLOCKS':
|
|
2077
|
+
case 'REPLACE_BLOCKS':
|
|
2078
|
+
// Clear if the edited section is directly among the removed/replaced blocks.
|
|
2079
|
+
// Note: this doesn't catch the case where a parent of the edited section
|
|
2080
|
+
// is removed, since action.clientIds only contains the top-level IDs.
|
|
2081
|
+
// That edge case is handled by the StopEditingContentOnlySectionOnOutsideSelect
|
|
2082
|
+
// component in block-list/index.js.
|
|
2083
|
+
if ( action.clientIds.includes( state ) ) {
|
|
2084
|
+
return undefined;
|
|
2085
|
+
}
|
|
2086
|
+
break;
|
|
2087
|
+
case 'RESET_BLOCKS':
|
|
2088
|
+
// When all blocks are reset (e.g. navigating to a different post),
|
|
2089
|
+
// check whether the edited section still exists in the new block tree.
|
|
2090
|
+
if ( ! getFlattenedClientIds( action.blocks )[ state ] ) {
|
|
2091
|
+
return undefined;
|
|
2128
2092
|
}
|
|
2129
|
-
|
|
2130
|
-
newState.delete( action.clientId );
|
|
2131
|
-
return newState;
|
|
2132
|
-
}
|
|
2133
|
-
case 'RESET_BLOCKS': {
|
|
2134
|
-
return state.has( '' )
|
|
2135
|
-
? new Map().set( '', state.get( '' ) )
|
|
2136
|
-
: state;
|
|
2137
|
-
}
|
|
2093
|
+
break;
|
|
2138
2094
|
}
|
|
2095
|
+
|
|
2139
2096
|
return state;
|
|
2140
2097
|
}
|
|
2141
2098
|
|
|
@@ -2375,7 +2332,6 @@ const combinedReducers = combineReducers( {
|
|
|
2375
2332
|
editedContentOnlySection,
|
|
2376
2333
|
blockVisibility,
|
|
2377
2334
|
viewportModalClientIds,
|
|
2378
|
-
blockEditingModes,
|
|
2379
2335
|
styleOverrides,
|
|
2380
2336
|
removalPromptData,
|
|
2381
2337
|
blockRemovalRules,
|
|
@@ -2506,7 +2462,7 @@ function getDerivedBlockEditingModesForTree( state, treeClientId = '' ) {
|
|
|
2506
2462
|
// so the default block editing mode is set to disabled.
|
|
2507
2463
|
const sectionRootClientId = state.settings?.[ sectionRootClientIdKey ];
|
|
2508
2464
|
const sectionClientIds = state.blocks.order.get( sectionRootClientId );
|
|
2509
|
-
const hasDisabledBlocks = Array.from( state.blockEditingModes ).some(
|
|
2465
|
+
const hasDisabledBlocks = Array.from( state.blocks.blockEditingModes ).some(
|
|
2510
2466
|
( [ , mode ] ) => mode === 'disabled'
|
|
2511
2467
|
);
|
|
2512
2468
|
const templatePartClientIds = [];
|
|
@@ -2582,7 +2538,7 @@ function getDerivedBlockEditingModesForTree( state, treeClientId = '' ) {
|
|
|
2582
2538
|
|
|
2583
2539
|
// If the block already has an explicit block editing mode set,
|
|
2584
2540
|
// don't override it.
|
|
2585
|
-
if ( state.blockEditingModes.has( clientId ) ) {
|
|
2541
|
+
if ( state.blocks.blockEditingModes.has( clientId ) ) {
|
|
2586
2542
|
return;
|
|
2587
2543
|
}
|
|
2588
2544
|
|
|
@@ -2593,12 +2549,12 @@ function getDerivedBlockEditingModesForTree( state, treeClientId = '' ) {
|
|
|
2593
2549
|
let ancestorBlockEditingMode;
|
|
2594
2550
|
let parent = state.blocks.parents.get( clientId );
|
|
2595
2551
|
while ( parent !== undefined ) {
|
|
2596
|
-
if ( state.blockEditingModes.has( parent ) ) {
|
|
2552
|
+
if ( state.blocks.blockEditingModes.has( parent ) ) {
|
|
2597
2553
|
// Checking the explicit block editing mode will be slower,
|
|
2598
2554
|
// as the block editing mode is more likely to be set on a
|
|
2599
2555
|
// distant ancestor.
|
|
2600
2556
|
ancestorBlockEditingMode =
|
|
2601
|
-
state.blockEditingModes.get( parent );
|
|
2557
|
+
state.blocks.blockEditingModes.get( parent );
|
|
2602
2558
|
}
|
|
2603
2559
|
if ( ancestorBlockEditingMode ) {
|
|
2604
2560
|
break;
|
package/src/store/selectors.js
CHANGED
|
@@ -3242,8 +3242,8 @@ export function getBlockEditingMode( state, clientId = '' ) {
|
|
|
3242
3242
|
}
|
|
3243
3243
|
|
|
3244
3244
|
// In normal mode, consider that an explicitly set editing mode takes over.
|
|
3245
|
-
if ( state.blockEditingModes.has( clientId ) ) {
|
|
3246
|
-
return state.blockEditingModes.get( clientId );
|
|
3245
|
+
if ( state.blocks.blockEditingModes.has( clientId ) ) {
|
|
3246
|
+
return state.blocks.blockEditingModes.get( clientId );
|
|
3247
3247
|
}
|
|
3248
3248
|
|
|
3249
3249
|
return 'default';
|
|
@@ -131,12 +131,12 @@ describe( 'private selectors', () => {
|
|
|
131
131
|
'9b9c5c3f-2e46-4f02-9e14-9fe9515b958f',
|
|
132
132
|
],
|
|
133
133
|
] ),
|
|
134
|
+
blockEditingModes: new Map( [] ),
|
|
134
135
|
},
|
|
135
136
|
blockListSettings: {
|
|
136
137
|
'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337': {},
|
|
137
138
|
'9b9c5c3f-2e46-4f02-9e14-9fe9515b958f': {},
|
|
138
139
|
},
|
|
139
|
-
blockEditingModes: new Map( [] ),
|
|
140
140
|
derivedBlockEditingModes: new Map( [] ),
|
|
141
141
|
};
|
|
142
142
|
|
|
@@ -152,7 +152,10 @@ describe( 'private selectors', () => {
|
|
|
152
152
|
it( 'should return false when top level block is not disabled', () => {
|
|
153
153
|
const state = {
|
|
154
154
|
...baseState,
|
|
155
|
-
|
|
155
|
+
blocks: {
|
|
156
|
+
...baseState.blocks,
|
|
157
|
+
blockEditingModes: new Map( [] ),
|
|
158
|
+
},
|
|
156
159
|
derivedBlockEditingModes: new Map( [] ),
|
|
157
160
|
};
|
|
158
161
|
expect(
|
|
@@ -166,9 +169,12 @@ describe( 'private selectors', () => {
|
|
|
166
169
|
it( 'should return true when top level block is disabled and there are no editing modes within it', () => {
|
|
167
170
|
const state = {
|
|
168
171
|
...baseState,
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
+
blocks: {
|
|
173
|
+
...baseState.blocks,
|
|
174
|
+
blockEditingModes: new Map( [
|
|
175
|
+
[ 'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337', 'disabled' ],
|
|
176
|
+
] ),
|
|
177
|
+
},
|
|
172
178
|
derivedBlockEditingModes: new Map( [
|
|
173
179
|
[ 'b26fc763-417d-4f01-b81c-2ec61e14a972', 'disabled' ],
|
|
174
180
|
[ '9b9c5c3f-2e46-4f02-9e14-9fe9515b958f', 'disabled' ],
|
|
@@ -187,7 +193,10 @@ describe( 'private selectors', () => {
|
|
|
187
193
|
it( 'should return true when top level block is disabled via inheritance and there are no editing modes within it', () => {
|
|
188
194
|
const state = {
|
|
189
195
|
...baseState,
|
|
190
|
-
|
|
196
|
+
blocks: {
|
|
197
|
+
...baseState.blocks,
|
|
198
|
+
blockEditingModes: new Map( [ [ '', 'disabled' ] ] ),
|
|
199
|
+
},
|
|
191
200
|
derivedBlockEditingModes: new Map( [
|
|
192
201
|
[ '6cf70164-9097-4460-bcbf-200560546988', 'disabled' ],
|
|
193
202
|
[ 'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337', 'disabled' ],
|
|
@@ -208,10 +217,13 @@ describe( 'private selectors', () => {
|
|
|
208
217
|
it( 'should return true when top level block is disabled and there are disabled editing modes within it', () => {
|
|
209
218
|
const state = {
|
|
210
219
|
...baseState,
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
220
|
+
blocks: {
|
|
221
|
+
...baseState.blocks,
|
|
222
|
+
blockEditingModes: new Map( [
|
|
223
|
+
[ 'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337', 'disabled' ],
|
|
224
|
+
[ 'b3247f75-fd94-4fef-97f9-5bfd162cc416', 'disabled' ],
|
|
225
|
+
] ),
|
|
226
|
+
},
|
|
215
227
|
derivedBlockEditingModes: new Map( [
|
|
216
228
|
[ 'b26fc763-417d-4f01-b81c-2ec61e14a972', 'disabled' ],
|
|
217
229
|
[ '9b9c5c3f-2e46-4f02-9e14-9fe9515b958f', 'disabled' ],
|
|
@@ -229,10 +241,13 @@ describe( 'private selectors', () => {
|
|
|
229
241
|
it( 'should return false when top level block is disabled and there are non-disabled editing modes within it', () => {
|
|
230
242
|
const state = {
|
|
231
243
|
...baseState,
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
244
|
+
blocks: {
|
|
245
|
+
...baseState.blocks,
|
|
246
|
+
blockEditingModes: new Map( [
|
|
247
|
+
[ 'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337', 'disabled' ],
|
|
248
|
+
[ 'b3247f75-fd94-4fef-97f9-5bfd162cc416', 'default' ],
|
|
249
|
+
] ),
|
|
250
|
+
},
|
|
236
251
|
derivedBlockEditingModes: new Map( [
|
|
237
252
|
[ 'b26fc763-417d-4f01-b81c-2ec61e14a972', 'disabled' ],
|
|
238
253
|
[ '9b9c5c3f-2e46-4f02-9e14-9fe9515b958f', 'disabled' ],
|
|
@@ -250,10 +265,13 @@ describe( 'private selectors', () => {
|
|
|
250
265
|
it( 'should return false when top level block is disabled via inheritance and there are non-disabled editing modes within it', () => {
|
|
251
266
|
const state = {
|
|
252
267
|
...baseState,
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
268
|
+
blocks: {
|
|
269
|
+
...baseState.blocks,
|
|
270
|
+
blockEditingModes: new Map( [
|
|
271
|
+
[ '', 'disabled' ],
|
|
272
|
+
[ 'b3247f75-fd94-4fef-97f9-5bfd162cc416', 'default' ],
|
|
273
|
+
] ),
|
|
274
|
+
},
|
|
257
275
|
derivedBlockEditingModes: new Map( [
|
|
258
276
|
[ '6cf70164-9097-4460-bcbf-200560546988', 'disabled' ],
|
|
259
277
|
[ 'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337', 'disabled' ],
|
|
@@ -343,7 +361,10 @@ describe( 'private selectors', () => {
|
|
|
343
361
|
it( 'should return tree containing only clientId and innerBlocks', () => {
|
|
344
362
|
const state = {
|
|
345
363
|
...baseState,
|
|
346
|
-
|
|
364
|
+
blocks: {
|
|
365
|
+
...baseState.blocks,
|
|
366
|
+
blockEditingModes: new Map( [] ),
|
|
367
|
+
},
|
|
347
368
|
derivedBlockEditingModes: new Map( [] ),
|
|
348
369
|
};
|
|
349
370
|
expect( getEnabledClientIdsTree( state ) ).toEqual( [
|
|
@@ -381,7 +402,10 @@ describe( 'private selectors', () => {
|
|
|
381
402
|
it( 'should return a subtree when rootBlockClientId is given', () => {
|
|
382
403
|
const state = {
|
|
383
404
|
...baseState,
|
|
384
|
-
|
|
405
|
+
blocks: {
|
|
406
|
+
...baseState.blocks,
|
|
407
|
+
blockEditingModes: new Map( [] ),
|
|
408
|
+
},
|
|
385
409
|
derivedBlockEditingModes: new Map( [] ),
|
|
386
410
|
};
|
|
387
411
|
expect(
|
|
@@ -413,11 +437,20 @@ describe( 'private selectors', () => {
|
|
|
413
437
|
it( 'should filter out disabled blocks', () => {
|
|
414
438
|
const state = {
|
|
415
439
|
...baseState,
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
440
|
+
blocks: {
|
|
441
|
+
...baseState.blocks,
|
|
442
|
+
blockEditingModes: new Map( [
|
|
443
|
+
[ '', 'disabled' ],
|
|
444
|
+
[
|
|
445
|
+
'b26fc763-417d-4f01-b81c-2ec61e14a972',
|
|
446
|
+
'contentOnly',
|
|
447
|
+
],
|
|
448
|
+
[
|
|
449
|
+
'9b9c5c3f-2e46-4f02-9e14-9fe9515b958f',
|
|
450
|
+
'contentOnly',
|
|
451
|
+
],
|
|
452
|
+
] ),
|
|
453
|
+
},
|
|
421
454
|
derivedBlockEditingModes: new Map( [
|
|
422
455
|
[ '6cf70164-9097-4460-bcbf-200560546988', 'disabled' ],
|
|
423
456
|
[ 'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337', 'disabled' ],
|
|
@@ -457,8 +490,8 @@ describe( 'private selectors', () => {
|
|
|
457
490
|
[ '6cf70164-9097-4460-bcbf-200560546988', [] ],
|
|
458
491
|
[ '', [ '6cf70164-9097-4460-bcbf-200560546988' ] ],
|
|
459
492
|
] ),
|
|
493
|
+
blockEditingModes: new Map(),
|
|
460
494
|
},
|
|
461
|
-
blockEditingModes: new Map(),
|
|
462
495
|
derivedBlockEditingModes: new Map(),
|
|
463
496
|
};
|
|
464
497
|
expect(
|
|
@@ -503,11 +536,11 @@ describe( 'private selectors', () => {
|
|
|
503
536
|
[ '4c2b7140-fffd-44b4-b2a7-820c670a6514' ],
|
|
504
537
|
],
|
|
505
538
|
] ),
|
|
539
|
+
blockEditingModes: new Map( [
|
|
540
|
+
[ '', 'disabled' ],
|
|
541
|
+
[ 'e178812d-ce5e-48c7-a945-8ae4ffcbbb7c', 'default' ],
|
|
542
|
+
] ),
|
|
506
543
|
},
|
|
507
|
-
blockEditingModes: new Map( [
|
|
508
|
-
[ '', 'disabled' ],
|
|
509
|
-
[ 'e178812d-ce5e-48c7-a945-8ae4ffcbbb7c', 'default' ],
|
|
510
|
-
] ),
|
|
511
544
|
derivedBlockEditingModes: new Map( [
|
|
512
545
|
[ 'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337', 'disabled' ],
|
|
513
546
|
[ '9b9c5c3f-2e46-4f02-9e14-9fe9515b958f', 'disabled' ],
|
|
@@ -556,11 +589,11 @@ describe( 'private selectors', () => {
|
|
|
556
589
|
[ '4c2b7140-fffd-44b4-b2a7-820c670a6514' ],
|
|
557
590
|
],
|
|
558
591
|
] ),
|
|
592
|
+
blockEditingModes: new Map( [
|
|
593
|
+
[ '', 'disabled' ],
|
|
594
|
+
[ '9b9c5c3f-2e46-4f02-9e14-9fe9515b958f', 'default' ],
|
|
595
|
+
] ),
|
|
559
596
|
},
|
|
560
|
-
blockEditingModes: new Map( [
|
|
561
|
-
[ '', 'disabled' ],
|
|
562
|
-
[ '9b9c5c3f-2e46-4f02-9e14-9fe9515b958f', 'default' ],
|
|
563
|
-
] ),
|
|
564
597
|
derivedBlockEditingModes: new Map( [
|
|
565
598
|
[ 'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337', 'disabled' ],
|
|
566
599
|
] ),
|