@wordpress/block-editor 15.3.1-next.6870dfe5b.0 → 15.3.1-next.6f42e1382.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/build/autocompleters/block.js +2 -4
- package/build/autocompleters/block.js.map +1 -1
- package/build/components/block-list/index.js +3 -1
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-switcher/index.js +10 -5
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +5 -2
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +10 -0
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-variation-transforms/index.js +9 -5
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/link-control/search-item.js +30 -12
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/store/private-selectors.js +7 -20
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +60 -0
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +16 -30
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +18 -0
- package/build/store/utils.js.map +1 -1
- package/build-module/autocompleters/block.js +3 -5
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/components/block-list/index.js +3 -1
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-switcher/index.js +10 -5
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +5 -2
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +11 -1
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-variation-transforms/index.js +9 -5
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/link-control/search-item.js +30 -12
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/store/private-selectors.js +7 -20
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +60 -0
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +16 -30
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +17 -0
- package/build-module/store/utils.js.map +1 -1
- package/build-style/style-rtl.css +0 -1
- package/build-style/style.css +0 -1
- package/package.json +34 -34
- package/src/autocompleters/block.js +6 -11
- package/src/components/block-list/index.js +7 -1
- package/src/components/block-switcher/index.js +8 -1
- package/src/components/block-toolbar/index.js +11 -5
- package/src/components/block-tools/insertion-point.js +19 -1
- package/src/components/block-variation-transforms/index.js +38 -27
- package/src/components/link-control/search-item.js +31 -12
- package/src/components/link-control/style.scss +0 -1
- package/src/components/link-control/test/index.js +14 -2
- package/src/store/private-selectors.js +10 -23
- package/src/store/reducer.js +105 -0
- package/src/store/selectors.js +38 -59
- package/src/store/test/reducer.js +107 -0
- package/src/store/test/selectors.js +65 -192
- package/src/store/utils.js +21 -0
package/src/store/reducer.js
CHANGED
|
@@ -2267,6 +2267,26 @@ function getDerivedBlockEditingModesForTree(
|
|
|
2267
2267
|
syncedPatternClientIds.push( clientId );
|
|
2268
2268
|
}
|
|
2269
2269
|
} );
|
|
2270
|
+
const contentOnlyTemplateLockedClientIds = Object.keys(
|
|
2271
|
+
state.blockListSettings
|
|
2272
|
+
).filter(
|
|
2273
|
+
( clientId ) =>
|
|
2274
|
+
state.blockListSettings[ clientId ]?.templateLock === 'contentOnly'
|
|
2275
|
+
);
|
|
2276
|
+
// Use array.from for better back compat. Older versions of the iterator returned
|
|
2277
|
+
// from `keys()` didn't have the `filter` method.
|
|
2278
|
+
const unsyncedPatternClientIds =
|
|
2279
|
+
!! window?.__experimentalContentOnlyPatternInsertion
|
|
2280
|
+
? Array.from( state.blocks.attributes.keys() ).filter(
|
|
2281
|
+
( clientId ) =>
|
|
2282
|
+
state.blocks.attributes.get( clientId )?.metadata
|
|
2283
|
+
?.patternName
|
|
2284
|
+
)
|
|
2285
|
+
: [];
|
|
2286
|
+
const contentOnlyParents = [
|
|
2287
|
+
...contentOnlyTemplateLockedClientIds,
|
|
2288
|
+
...unsyncedPatternClientIds,
|
|
2289
|
+
];
|
|
2270
2290
|
|
|
2271
2291
|
traverseBlockTree( state, treeClientId, ( block ) => {
|
|
2272
2292
|
const { clientId, name: blockName } = block;
|
|
@@ -2457,6 +2477,22 @@ function getDerivedBlockEditingModesForTree(
|
|
|
2457
2477
|
derivedBlockEditingModes.set( clientId, 'disabled' );
|
|
2458
2478
|
}
|
|
2459
2479
|
}
|
|
2480
|
+
|
|
2481
|
+
// Handle `templateLock=contentOnly` blocks and unsynced patterns.
|
|
2482
|
+
if ( contentOnlyParents.length ) {
|
|
2483
|
+
const hasContentOnlyParent = !! findParentInClientIdsList(
|
|
2484
|
+
state,
|
|
2485
|
+
clientId,
|
|
2486
|
+
contentOnlyParents
|
|
2487
|
+
);
|
|
2488
|
+
if ( hasContentOnlyParent ) {
|
|
2489
|
+
if ( isContentBlock( blockName ) ) {
|
|
2490
|
+
derivedBlockEditingModes.set( clientId, 'contentOnly' );
|
|
2491
|
+
} else {
|
|
2492
|
+
derivedBlockEditingModes.set( clientId, 'disabled' );
|
|
2493
|
+
}
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2460
2496
|
} );
|
|
2461
2497
|
|
|
2462
2498
|
return derivedBlockEditingModes;
|
|
@@ -2628,6 +2664,75 @@ export function withDerivedBlockEditingModes( reducer ) {
|
|
|
2628
2664
|
}
|
|
2629
2665
|
break;
|
|
2630
2666
|
}
|
|
2667
|
+
case 'UPDATE_BLOCK_LIST_SETTINGS': {
|
|
2668
|
+
// Handle the addition and removal of contentOnly template locked blocks.
|
|
2669
|
+
const addedBlocks = [];
|
|
2670
|
+
const removedClientIds = [];
|
|
2671
|
+
|
|
2672
|
+
const updates =
|
|
2673
|
+
typeof action.clientId === 'string'
|
|
2674
|
+
? { [ action.clientId ]: action.settings }
|
|
2675
|
+
: action.clientId;
|
|
2676
|
+
|
|
2677
|
+
for ( const clientId in updates ) {
|
|
2678
|
+
const isNewContentOnlyBlock =
|
|
2679
|
+
state.blockListSettings[ clientId ]?.templateLock !==
|
|
2680
|
+
'contentOnly' &&
|
|
2681
|
+
nextState.blockListSettings[ clientId ]
|
|
2682
|
+
?.templateLock === 'contentOnly';
|
|
2683
|
+
|
|
2684
|
+
const wasContentOnlyBlock =
|
|
2685
|
+
state.blockListSettings[ clientId ]?.templateLock ===
|
|
2686
|
+
'contentOnly' &&
|
|
2687
|
+
nextState.blockListSettings[ clientId ]
|
|
2688
|
+
?.templateLock !== 'contentOnly';
|
|
2689
|
+
|
|
2690
|
+
if ( isNewContentOnlyBlock ) {
|
|
2691
|
+
addedBlocks.push(
|
|
2692
|
+
nextState.blocks.tree.get( clientId )
|
|
2693
|
+
);
|
|
2694
|
+
} else if ( wasContentOnlyBlock ) {
|
|
2695
|
+
removedClientIds.push( clientId );
|
|
2696
|
+
}
|
|
2697
|
+
}
|
|
2698
|
+
|
|
2699
|
+
if ( ! addedBlocks.length && ! removedClientIds.length ) {
|
|
2700
|
+
break;
|
|
2701
|
+
}
|
|
2702
|
+
|
|
2703
|
+
const nextDerivedBlockEditingModes =
|
|
2704
|
+
getDerivedBlockEditingModesUpdates( {
|
|
2705
|
+
prevState: state,
|
|
2706
|
+
nextState,
|
|
2707
|
+
addedBlocks,
|
|
2708
|
+
removedClientIds,
|
|
2709
|
+
isNavMode: false,
|
|
2710
|
+
} );
|
|
2711
|
+
const nextDerivedNavModeBlockEditingModes =
|
|
2712
|
+
getDerivedBlockEditingModesUpdates( {
|
|
2713
|
+
prevState: state,
|
|
2714
|
+
nextState,
|
|
2715
|
+
addedBlocks,
|
|
2716
|
+
removedClientIds,
|
|
2717
|
+
isNavMode: true,
|
|
2718
|
+
} );
|
|
2719
|
+
|
|
2720
|
+
if (
|
|
2721
|
+
nextDerivedBlockEditingModes ||
|
|
2722
|
+
nextDerivedNavModeBlockEditingModes
|
|
2723
|
+
) {
|
|
2724
|
+
return {
|
|
2725
|
+
...nextState,
|
|
2726
|
+
derivedBlockEditingModes:
|
|
2727
|
+
nextDerivedBlockEditingModes ??
|
|
2728
|
+
state.derivedBlockEditingModes,
|
|
2729
|
+
derivedNavModeBlockEditingModes:
|
|
2730
|
+
nextDerivedNavModeBlockEditingModes ??
|
|
2731
|
+
state.derivedNavModeBlockEditingModes,
|
|
2732
|
+
};
|
|
2733
|
+
}
|
|
2734
|
+
break;
|
|
2735
|
+
}
|
|
2631
2736
|
case 'SET_BLOCK_EDITING_MODE':
|
|
2632
2737
|
case 'UNSET_BLOCK_EDITING_MODE':
|
|
2633
2738
|
case 'SET_HAS_CONTROLLED_INNER_BLOCKS': {
|
package/src/store/selectors.js
CHANGED
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
getInsertBlockTypeDependants,
|
|
31
31
|
getParsedPattern,
|
|
32
32
|
getGrammar,
|
|
33
|
+
mapUserPattern,
|
|
33
34
|
} from './utils';
|
|
34
35
|
import { orderBy } from '../utils/sorting';
|
|
35
36
|
import { STORE_NAME } from './constants';
|
|
@@ -2155,27 +2156,31 @@ export const getInserterItems = createRegistrySelector( ( select ) =>
|
|
|
2155
2156
|
foreground: 'var(--wp-block-synced-color)',
|
|
2156
2157
|
}
|
|
2157
2158
|
: symbol;
|
|
2158
|
-
const
|
|
2159
|
-
const { time, count = 0 } =
|
|
2159
|
+
const userPattern = mapUserPattern( reusableBlock );
|
|
2160
|
+
const { time, count = 0 } =
|
|
2161
|
+
getInsertUsage( state, userPattern.name ) || {};
|
|
2160
2162
|
const frecency = calculateFrecency( time, count );
|
|
2161
2163
|
|
|
2162
2164
|
return {
|
|
2163
|
-
id,
|
|
2165
|
+
id: userPattern.name,
|
|
2164
2166
|
name: 'core/block',
|
|
2165
2167
|
initialAttributes: { ref: reusableBlock.id },
|
|
2166
|
-
title:
|
|
2168
|
+
title: userPattern.title,
|
|
2167
2169
|
icon,
|
|
2168
2170
|
category: 'reusable',
|
|
2169
2171
|
keywords: [ 'reusable' ],
|
|
2170
2172
|
isDisabled: false,
|
|
2171
2173
|
utility: 1, // Deprecated.
|
|
2172
2174
|
frecency,
|
|
2173
|
-
content:
|
|
2174
|
-
|
|
2175
|
+
content: userPattern.content,
|
|
2176
|
+
get blocks() {
|
|
2177
|
+
return getParsedPattern( userPattern ).blocks;
|
|
2178
|
+
},
|
|
2179
|
+
syncStatus: userPattern.syncStatus,
|
|
2175
2180
|
};
|
|
2176
2181
|
};
|
|
2177
2182
|
|
|
2178
|
-
const
|
|
2183
|
+
const patternInserterItems = canInsertBlockTypeUnmemoized(
|
|
2179
2184
|
state,
|
|
2180
2185
|
'core/block',
|
|
2181
2186
|
rootClientId
|
|
@@ -2261,7 +2266,7 @@ export const getInserterItems = createRegistrySelector( ( select ) =>
|
|
|
2261
2266
|
{ core: [], noncore: [] }
|
|
2262
2267
|
);
|
|
2263
2268
|
const sortedBlockTypes = [ ...coreItems, ...nonCoreItems ];
|
|
2264
|
-
return [ ...sortedBlockTypes, ...
|
|
2269
|
+
return [ ...sortedBlockTypes, ...patternInserterItems ];
|
|
2265
2270
|
},
|
|
2266
2271
|
( state, rootClientId ) => [
|
|
2267
2272
|
getBlockTypes(),
|
|
@@ -3076,62 +3081,36 @@ export function __unstableIsWithinBlockOverlay( state, clientId ) {
|
|
|
3076
3081
|
* @return {BlockEditingMode} The block editing mode. One of `'disabled'`,
|
|
3077
3082
|
* `'contentOnly'`, or `'default'`.
|
|
3078
3083
|
*/
|
|
3079
|
-
export
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
clientId = '';
|
|
3086
|
-
}
|
|
3084
|
+
export function getBlockEditingMode( state, clientId = '' ) {
|
|
3085
|
+
// Some selectors that call this provide `null` as the default
|
|
3086
|
+
// rootClientId, but the default rootClientId is actually `''`.
|
|
3087
|
+
if ( clientId === null ) {
|
|
3088
|
+
clientId = '';
|
|
3089
|
+
}
|
|
3087
3090
|
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
// If the editor is currently not in navigation mode, check if the clientId
|
|
3091
|
-
// has an editing mode set in the regular derived map.
|
|
3092
|
-
// There may be an editing mode set here for synced patterns or in zoomed out
|
|
3093
|
-
// mode.
|
|
3094
|
-
if (
|
|
3095
|
-
! isNavMode &&
|
|
3096
|
-
state.derivedBlockEditingModes?.has( clientId )
|
|
3097
|
-
) {
|
|
3098
|
-
return state.derivedBlockEditingModes.get( clientId );
|
|
3099
|
-
}
|
|
3091
|
+
const isNavMode = isNavigationMode( state );
|
|
3100
3092
|
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
}
|
|
3093
|
+
// If the editor is currently not in navigation mode, check if the clientId
|
|
3094
|
+
// has an editing mode set in the regular derived map.
|
|
3095
|
+
// There may be an editing mode set here for synced patterns or in zoomed out
|
|
3096
|
+
// mode.
|
|
3097
|
+
if ( ! isNavMode && state.derivedBlockEditingModes?.has( clientId ) ) {
|
|
3098
|
+
return state.derivedBlockEditingModes.get( clientId );
|
|
3099
|
+
}
|
|
3109
3100
|
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3101
|
+
// If the editor *is* in navigation mode, the block editing mode states
|
|
3102
|
+
// are stored in the derivedNavModeBlockEditingModes map.
|
|
3103
|
+
if ( isNavMode && state.derivedNavModeBlockEditingModes?.has( clientId ) ) {
|
|
3104
|
+
return state.derivedNavModeBlockEditingModes.get( clientId );
|
|
3105
|
+
}
|
|
3115
3106
|
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3107
|
+
// In normal mode, consider that an explicitly set editing mode takes over.
|
|
3108
|
+
if ( state.blockEditingModes.has( clientId ) ) {
|
|
3109
|
+
return state.blockEditingModes.get( clientId );
|
|
3110
|
+
}
|
|
3120
3111
|
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
// If the parent of the block is contentOnly locked, check whether it's a content block.
|
|
3124
|
-
if ( templateLock === 'contentOnly' ) {
|
|
3125
|
-
const name = getBlockName( state, clientId );
|
|
3126
|
-
const { hasContentRoleAttribute } = unlock(
|
|
3127
|
-
select( blocksStore )
|
|
3128
|
-
);
|
|
3129
|
-
const isContent = hasContentRoleAttribute( name );
|
|
3130
|
-
return isContent ? 'contentOnly' : 'disabled';
|
|
3131
|
-
}
|
|
3132
|
-
return 'default';
|
|
3133
|
-
}
|
|
3134
|
-
);
|
|
3112
|
+
return 'default';
|
|
3113
|
+
}
|
|
3135
3114
|
|
|
3136
3115
|
/**
|
|
3137
3116
|
* Indicates if a block is ungroupable.
|
|
@@ -3575,6 +3575,7 @@ describe( 'state', () => {
|
|
|
3575
3575
|
blocks,
|
|
3576
3576
|
settings,
|
|
3577
3577
|
zoomLevel,
|
|
3578
|
+
blockListSettings,
|
|
3578
3579
|
blockEditingModes,
|
|
3579
3580
|
} )
|
|
3580
3581
|
);
|
|
@@ -3885,6 +3886,112 @@ describe( 'state', () => {
|
|
|
3885
3886
|
} );
|
|
3886
3887
|
} );
|
|
3887
3888
|
|
|
3889
|
+
describe( 'contentOnly template locking', () => {
|
|
3890
|
+
let initialState;
|
|
3891
|
+
beforeAll( () => {
|
|
3892
|
+
initialState = dispatchActions(
|
|
3893
|
+
[
|
|
3894
|
+
{
|
|
3895
|
+
type: 'RESET_BLOCKS',
|
|
3896
|
+
blocks: [
|
|
3897
|
+
{
|
|
3898
|
+
name: 'core/group',
|
|
3899
|
+
clientId: 'group-1',
|
|
3900
|
+
attributes: {},
|
|
3901
|
+
innerBlocks: [
|
|
3902
|
+
{
|
|
3903
|
+
name: 'core/paragraph',
|
|
3904
|
+
clientId: 'paragraph-1',
|
|
3905
|
+
attributes: {},
|
|
3906
|
+
innerBlocks: [],
|
|
3907
|
+
},
|
|
3908
|
+
{
|
|
3909
|
+
name: 'core/group',
|
|
3910
|
+
clientId: 'group-2',
|
|
3911
|
+
attributes: {},
|
|
3912
|
+
innerBlocks: [
|
|
3913
|
+
{
|
|
3914
|
+
name: 'core/paragraph',
|
|
3915
|
+
clientId: 'paragraph-2',
|
|
3916
|
+
attributes: {},
|
|
3917
|
+
innerBlocks: [],
|
|
3918
|
+
},
|
|
3919
|
+
],
|
|
3920
|
+
},
|
|
3921
|
+
],
|
|
3922
|
+
},
|
|
3923
|
+
],
|
|
3924
|
+
},
|
|
3925
|
+
{
|
|
3926
|
+
type: 'UPDATE_BLOCK_LIST_SETTINGS',
|
|
3927
|
+
clientId: 'group-1',
|
|
3928
|
+
settings: {
|
|
3929
|
+
templateLock: 'contentOnly',
|
|
3930
|
+
},
|
|
3931
|
+
},
|
|
3932
|
+
],
|
|
3933
|
+
testReducer,
|
|
3934
|
+
initialState
|
|
3935
|
+
);
|
|
3936
|
+
} );
|
|
3937
|
+
|
|
3938
|
+
it( 'returns the expected block editing modes for a parent block with contentOnly template locking', () => {
|
|
3939
|
+
// Only the parent pattern and its own children that have bindings
|
|
3940
|
+
// are in contentOnly mode. All other blocks are disabled.
|
|
3941
|
+
expect( initialState.derivedBlockEditingModes ).toEqual(
|
|
3942
|
+
new Map(
|
|
3943
|
+
Object.entries( {
|
|
3944
|
+
'paragraph-1': 'contentOnly',
|
|
3945
|
+
'group-2': 'disabled',
|
|
3946
|
+
'paragraph-2': 'contentOnly',
|
|
3947
|
+
} )
|
|
3948
|
+
)
|
|
3949
|
+
);
|
|
3950
|
+
} );
|
|
3951
|
+
|
|
3952
|
+
it( 'removes block editing modes when template locking is removed', () => {
|
|
3953
|
+
const { derivedBlockEditingModes } = dispatchActions(
|
|
3954
|
+
[
|
|
3955
|
+
{
|
|
3956
|
+
type: 'UPDATE_BLOCK_LIST_SETTINGS',
|
|
3957
|
+
clientId: 'group-1',
|
|
3958
|
+
settings: {
|
|
3959
|
+
templateLock: false,
|
|
3960
|
+
},
|
|
3961
|
+
},
|
|
3962
|
+
],
|
|
3963
|
+
testReducer,
|
|
3964
|
+
initialState
|
|
3965
|
+
);
|
|
3966
|
+
|
|
3967
|
+
expect( derivedBlockEditingModes ).toEqual( new Map() );
|
|
3968
|
+
} );
|
|
3969
|
+
|
|
3970
|
+
it( 'allows explicitly set blockEditingModes to override the contentOnly template locking', () => {
|
|
3971
|
+
const { derivedBlockEditingModes } = dispatchActions(
|
|
3972
|
+
[
|
|
3973
|
+
{
|
|
3974
|
+
type: 'SET_BLOCK_EDITING_MODE',
|
|
3975
|
+
clientId: 'paragraph-2',
|
|
3976
|
+
mode: 'disabled',
|
|
3977
|
+
},
|
|
3978
|
+
],
|
|
3979
|
+
testReducer,
|
|
3980
|
+
initialState
|
|
3981
|
+
);
|
|
3982
|
+
|
|
3983
|
+
expect( derivedBlockEditingModes ).toEqual(
|
|
3984
|
+
new Map(
|
|
3985
|
+
Object.entries( {
|
|
3986
|
+
'paragraph-1': 'contentOnly',
|
|
3987
|
+
'group-2': 'disabled',
|
|
3988
|
+
// Paragraph 2 already has an explicit mode, so isn't set as a derived mode.
|
|
3989
|
+
} )
|
|
3990
|
+
)
|
|
3991
|
+
);
|
|
3992
|
+
} );
|
|
3993
|
+
} );
|
|
3994
|
+
|
|
3888
3995
|
describe( 'navigation mode', () => {
|
|
3889
3996
|
let initialState;
|
|
3890
3997
|
|
|
@@ -3402,6 +3402,18 @@ describe( 'selectors', () => {
|
|
|
3402
3402
|
( item ) => item.id === 'core/block/1'
|
|
3403
3403
|
);
|
|
3404
3404
|
expect( reusableBlockItem ).toEqual( {
|
|
3405
|
+
blocks: [
|
|
3406
|
+
expect.objectContaining( {
|
|
3407
|
+
attributes: {
|
|
3408
|
+
metadata: expect.objectContaining( {
|
|
3409
|
+
name: 'Reusable Block 1',
|
|
3410
|
+
patternName: 'core/block/1',
|
|
3411
|
+
} ),
|
|
3412
|
+
},
|
|
3413
|
+
isValid: true,
|
|
3414
|
+
innerBlocks: [],
|
|
3415
|
+
} ),
|
|
3416
|
+
],
|
|
3405
3417
|
category: 'reusable',
|
|
3406
3418
|
content: '<!-- /wp:test-block-a -->',
|
|
3407
3419
|
frecency: 0,
|
|
@@ -4380,92 +4392,9 @@ describe( '__unstableGetClientIdsTree', () => {
|
|
|
4380
4392
|
|
|
4381
4393
|
describe( 'getBlockEditingMode', () => {
|
|
4382
4394
|
const baseState = {
|
|
4383
|
-
settings: {},
|
|
4384
|
-
blocks: {
|
|
4385
|
-
byClientId: new Map( [
|
|
4386
|
-
[
|
|
4387
|
-
'6cf70164-9097-4460-bcbf-200560546988',
|
|
4388
|
-
{ name: 'core/template-part' },
|
|
4389
|
-
], // Header
|
|
4390
|
-
[
|
|
4391
|
-
'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337',
|
|
4392
|
-
{ name: 'core/group' },
|
|
4393
|
-
], // Group
|
|
4394
|
-
[
|
|
4395
|
-
'b26fc763-417d-4f01-b81c-2ec61e14a972',
|
|
4396
|
-
{ name: 'core/post-title' },
|
|
4397
|
-
], // | Post Title
|
|
4398
|
-
[
|
|
4399
|
-
'9b9c5c3f-2e46-4f02-9e14-9fe9515b958f',
|
|
4400
|
-
{ name: 'core/group' },
|
|
4401
|
-
], // | Group
|
|
4402
|
-
[ 'b3247f75-fd94-4fef-97f9-5bfd162cc416', { name: 'core/p' } ], // | | Paragraph
|
|
4403
|
-
[ 'e178812d-ce5e-48c7-a945-8ae4ffcbbb7c', { name: 'core/p' } ], // | | Paragraph
|
|
4404
|
-
[
|
|
4405
|
-
'9b9c5c3f-2e46-4f02-9e14-9fed515b958s',
|
|
4406
|
-
{ name: 'core/group' },
|
|
4407
|
-
], // | | Group
|
|
4408
|
-
] ),
|
|
4409
|
-
order: new Map( [
|
|
4410
|
-
[
|
|
4411
|
-
'',
|
|
4412
|
-
[
|
|
4413
|
-
'6cf70164-9097-4460-bcbf-200560546988',
|
|
4414
|
-
'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337',
|
|
4415
|
-
],
|
|
4416
|
-
],
|
|
4417
|
-
[ '6cf70164-9097-4460-bcbf-200560546988', [] ],
|
|
4418
|
-
[
|
|
4419
|
-
'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337',
|
|
4420
|
-
[
|
|
4421
|
-
'b26fc763-417d-4f01-b81c-2ec61e14a972',
|
|
4422
|
-
'9b9c5c3f-2e46-4f02-9e14-9fe9515b958f',
|
|
4423
|
-
],
|
|
4424
|
-
],
|
|
4425
|
-
[ 'b26fc763-417d-4f01-b81c-2ec61e14a972', [] ],
|
|
4426
|
-
[
|
|
4427
|
-
'9b9c5c3f-2e46-4f02-9e14-9fe9515b958f',
|
|
4428
|
-
[
|
|
4429
|
-
'b3247f75-fd94-4fef-97f9-5bfd162cc416',
|
|
4430
|
-
'e178812d-ce5e-48c7-a945-8ae4ffcbbb7c',
|
|
4431
|
-
'9b9c5c3f-2e46-4f02-9e14-9fed515b958s',
|
|
4432
|
-
],
|
|
4433
|
-
],
|
|
4434
|
-
[ 'b3247f75-fd94-4fef-97f9-5bfd162cc416', [] ],
|
|
4435
|
-
[ 'e178812d-ce5e-48c7-a945-8ae4ffcbbb7c', [] ],
|
|
4436
|
-
[ '9b9c5c3f-2e46-4f02-9e14-9fed515b958s', [] ],
|
|
4437
|
-
] ),
|
|
4438
|
-
parents: new Map( [
|
|
4439
|
-
[ '6cf70164-9097-4460-bcbf-200560546988', '' ],
|
|
4440
|
-
[ 'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337', '' ],
|
|
4441
|
-
[
|
|
4442
|
-
'b26fc763-417d-4f01-b81c-2ec61e14a972',
|
|
4443
|
-
'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337',
|
|
4444
|
-
],
|
|
4445
|
-
[
|
|
4446
|
-
'9b9c5c3f-2e46-4f02-9e14-9fe9515b958f',
|
|
4447
|
-
'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337',
|
|
4448
|
-
],
|
|
4449
|
-
[
|
|
4450
|
-
'b3247f75-fd94-4fef-97f9-5bfd162cc416',
|
|
4451
|
-
'9b9c5c3f-2e46-4f02-9e14-9fe9515b958f',
|
|
4452
|
-
],
|
|
4453
|
-
[
|
|
4454
|
-
'e178812d-ce5e-48c7-a945-8ae4ffcbbb7c',
|
|
4455
|
-
'9b9c5c3f-2e46-4f02-9e14-9fe9515b958f',
|
|
4456
|
-
],
|
|
4457
|
-
[
|
|
4458
|
-
'9b9c5c3f-2e46-4f02-9e14-9fed515b958s',
|
|
4459
|
-
'9b9c5c3f-2e46-4f02-9e14-9fe9515b958f',
|
|
4460
|
-
],
|
|
4461
|
-
] ),
|
|
4462
|
-
},
|
|
4463
|
-
blockListSettings: {
|
|
4464
|
-
'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337': {},
|
|
4465
|
-
'9b9c5c3f-2e46-4f02-9e14-9fe9515b958f': {},
|
|
4466
|
-
},
|
|
4467
4395
|
blockEditingModes: new Map( [] ),
|
|
4468
4396
|
derivedBlockEditingModes: new Map( [] ),
|
|
4397
|
+
derivedNavModeBlockEditingModes: new Map( [] ),
|
|
4469
4398
|
};
|
|
4470
4399
|
|
|
4471
4400
|
const hasContentRoleAttribute = jest.fn( () => false );
|
|
@@ -4514,115 +4443,59 @@ describe( 'getBlockEditingMode', () => {
|
|
|
4514
4443
|
).toBe( 'contentOnly' );
|
|
4515
4444
|
} );
|
|
4516
4445
|
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
it( 'should return default if parent is set to contentOnly', () => {
|
|
4537
|
-
const state = {
|
|
4538
|
-
...baseState,
|
|
4539
|
-
blockEditingModes: new Map( [
|
|
4540
|
-
[ 'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337', 'contentOnly' ],
|
|
4541
|
-
] ),
|
|
4542
|
-
};
|
|
4543
|
-
expect(
|
|
4544
|
-
getBlockEditingMode( state, 'b3247f75-fd94-4fef-97f9-5bfd162cc416' )
|
|
4545
|
-
).toBe( 'default' );
|
|
4546
|
-
} );
|
|
4547
|
-
|
|
4548
|
-
it( 'should return disabled if overridden by a parent', () => {
|
|
4549
|
-
const state = {
|
|
4550
|
-
...baseState,
|
|
4551
|
-
blockEditingModes: new Map( [
|
|
4552
|
-
[ '', 'disabled' ],
|
|
4553
|
-
[ 'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337', 'default' ],
|
|
4554
|
-
[ '9b9c5c3f-2e46-4f02-9e14-9fe9515b958f', 'disabled' ],
|
|
4555
|
-
] ),
|
|
4556
|
-
derivedBlockEditingModes: new Map( [
|
|
4557
|
-
[ '6cf70164-9097-4460-bcbf-200560546988', 'disabled' ],
|
|
4558
|
-
[ 'b3247f75-fd94-4fef-97f9-5bfd162cc416', 'disabled' ],
|
|
4559
|
-
[ 'e178812d-ce5e-48c7-a945-8ae4ffcbbb7c', 'disabled' ],
|
|
4560
|
-
[ '9b9c5c3f-2e46-4f02-9e14-9fed515b958s', 'disabled' ],
|
|
4561
|
-
] ),
|
|
4562
|
-
};
|
|
4563
|
-
expect(
|
|
4564
|
-
getBlockEditingMode( state, 'b3247f75-fd94-4fef-97f9-5bfd162cc416' )
|
|
4565
|
-
).toBe( 'disabled' );
|
|
4566
|
-
} );
|
|
4567
|
-
|
|
4568
|
-
it( 'should return disabled if explicitly set on root', () => {
|
|
4569
|
-
const state = {
|
|
4570
|
-
...baseState,
|
|
4571
|
-
blockEditingModes: new Map( [ [ '', 'disabled' ] ] ),
|
|
4572
|
-
derivedBlockEditingModes: new Map( [
|
|
4573
|
-
[ '6cf70164-9097-4460-bcbf-200560546988', 'disabled' ],
|
|
4574
|
-
[ 'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337', 'disabled' ],
|
|
4575
|
-
[ 'b26fc763-417d-4f01-b81c-2ec61e14a972', 'disabled' ],
|
|
4576
|
-
[ '9b9c5c3f-2e46-4f02-9e14-9fe9515b958f', 'disabled' ],
|
|
4577
|
-
[ 'b3247f75-fd94-4fef-97f9-5bfd162cc416', 'disabled' ],
|
|
4578
|
-
[ 'e178812d-ce5e-48c7-a945-8ae4ffcbbb7c', 'disabled' ],
|
|
4579
|
-
[ '9b9c5c3f-2e46-4f02-9e14-9fed515b958s', 'disabled' ],
|
|
4580
|
-
] ),
|
|
4581
|
-
};
|
|
4582
|
-
expect(
|
|
4583
|
-
getBlockEditingMode( state, 'b3247f75-fd94-4fef-97f9-5bfd162cc416' )
|
|
4584
|
-
).toBe( 'disabled' );
|
|
4585
|
-
} );
|
|
4586
|
-
|
|
4587
|
-
it( 'should return default if root is contentOnly', () => {
|
|
4588
|
-
const state = {
|
|
4589
|
-
...baseState,
|
|
4590
|
-
blockEditingModes: new Map( [ [ '', 'contentOnly' ] ] ),
|
|
4591
|
-
};
|
|
4592
|
-
expect(
|
|
4593
|
-
getBlockEditingMode( state, 'b3247f75-fd94-4fef-97f9-5bfd162cc416' )
|
|
4594
|
-
).toBe( 'default' );
|
|
4595
|
-
} );
|
|
4446
|
+
describe( 'derived block editing modes override standard block editing modes', () => {
|
|
4447
|
+
it( 'should return default if explicitly set', () => {
|
|
4448
|
+
const state = {
|
|
4449
|
+
...baseState,
|
|
4450
|
+
blockEditingModes: new Map( [
|
|
4451
|
+
[ 'b3247f75-fd94-4fef-97f9-5bfd162cc416', 'contentOnly' ],
|
|
4452
|
+
] ),
|
|
4453
|
+
derivedBlockEditingModes: new Map( [
|
|
4454
|
+
[ 'b3247f75-fd94-4fef-97f9-5bfd162cc416', 'default' ],
|
|
4455
|
+
] ),
|
|
4456
|
+
};
|
|
4457
|
+
expect(
|
|
4458
|
+
getBlockEditingMode(
|
|
4459
|
+
state,
|
|
4460
|
+
'b3247f75-fd94-4fef-97f9-5bfd162cc416'
|
|
4461
|
+
)
|
|
4462
|
+
).toBe( 'default' );
|
|
4463
|
+
} );
|
|
4596
4464
|
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4465
|
+
it( 'should return disabled if explicitly set', () => {
|
|
4466
|
+
const state = {
|
|
4467
|
+
...baseState,
|
|
4468
|
+
blockEditingModes: new Map( [
|
|
4469
|
+
[ 'b3247f75-fd94-4fef-97f9-5bfd162cc416', 'contentOnly' ],
|
|
4470
|
+
] ),
|
|
4471
|
+
derivedBlockEditingModes: new Map( [
|
|
4472
|
+
[ 'b3247f75-fd94-4fef-97f9-5bfd162cc416', 'disabled' ],
|
|
4473
|
+
] ),
|
|
4474
|
+
};
|
|
4475
|
+
expect(
|
|
4476
|
+
getBlockEditingMode(
|
|
4477
|
+
state,
|
|
4478
|
+
'b3247f75-fd94-4fef-97f9-5bfd162cc416'
|
|
4479
|
+
)
|
|
4480
|
+
).toBe( 'disabled' );
|
|
4481
|
+
} );
|
|
4612
4482
|
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4483
|
+
it( 'should return contentOnly if explicitly set', () => {
|
|
4484
|
+
const state = {
|
|
4485
|
+
...baseState,
|
|
4486
|
+
blockEditingModes: new Map( [
|
|
4487
|
+
[ 'b3247f75-fd94-4fef-97f9-5bfd162cc416', 'default' ],
|
|
4488
|
+
] ),
|
|
4489
|
+
derivedBlockEditingModes: new Map( [
|
|
4490
|
+
[ 'b3247f75-fd94-4fef-97f9-5bfd162cc416', 'contentOnly' ],
|
|
4491
|
+
] ),
|
|
4492
|
+
};
|
|
4493
|
+
expect(
|
|
4494
|
+
getBlockEditingMode(
|
|
4495
|
+
state,
|
|
4496
|
+
'b3247f75-fd94-4fef-97f9-5bfd162cc416'
|
|
4497
|
+
)
|
|
4498
|
+
).toBe( 'contentOnly' );
|
|
4499
|
+
} );
|
|
4627
4500
|
} );
|
|
4628
4501
|
} );
|