@wordpress/block-editor 15.3.1-next.836ecdcae.0 → 15.3.1-next.a730c9c8c.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-card/index.js +4 -2
- package/build/components/block-card/index.js.map +1 -1
- package/build/components/block-inspector/edit-contents-button.js +54 -0
- package/build/components/block-inspector/edit-contents-button.js.map +1 -0
- package/build/components/block-inspector/index.js +5 -1
- package/build/components/block-inspector/index.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-popover/use-popover-scroll.js +11 -2
- package/build/components/block-popover/use-popover-scroll.js.map +1 -1
- package/build/components/block-switcher/index.js +13 -8
- 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 +10 -6
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/border-radius-control/utils.js.map +1 -1
- package/build/components/global-styles/border-panel.js +6 -6
- package/build/components/global-styles/border-panel.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/components/url-popover/image-url-input-ui.js +7 -2
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/writing-flow/use-clipboard-handler.js +6 -1
- package/build/components/writing-flow/use-clipboard-handler.js.map +1 -1
- package/build/store/private-selectors.js +9 -21
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +114 -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/utils/block-bindings.js +1 -1
- package/build/utils/block-bindings.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-card/index.js +4 -2
- package/build-module/components/block-card/index.js.map +1 -1
- package/build-module/components/block-inspector/edit-contents-button.js +47 -0
- package/build-module/components/block-inspector/edit-contents-button.js.map +1 -0
- package/build-module/components/block-inspector/index.js +5 -1
- package/build-module/components/block-inspector/index.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-popover/use-popover-scroll.js +11 -2
- package/build-module/components/block-popover/use-popover-scroll.js.map +1 -1
- package/build-module/components/block-switcher/index.js +13 -8
- 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 +10 -6
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/border-radius-control/utils.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +6 -6
- package/build-module/components/global-styles/border-panel.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/components/url-popover/image-url-input-ui.js +9 -4
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/writing-flow/use-clipboard-handler.js +6 -1
- package/build-module/components/writing-flow/use-clipboard-handler.js.map +1 -1
- package/build-module/store/private-selectors.js +9 -21
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +114 -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-module/utils/block-bindings.js +1 -1
- package/build-module/utils/block-bindings.js.map +1 -1
- package/build-style/style-rtl.css +9 -5
- package/build-style/style.css +9 -5
- package/package.json +34 -34
- package/src/autocompleters/block.js +6 -11
- package/src/components/block-card/index.js +11 -1
- package/src/components/block-inspector/edit-contents-button.js +46 -0
- package/src/components/block-inspector/index.js +6 -1
- package/src/components/block-inspector/style.scss +5 -0
- package/src/components/block-list/index.js +7 -1
- package/src/components/block-popover/use-popover-scroll.js +10 -2
- package/src/components/block-switcher/index.js +13 -4
- package/src/components/block-toolbar/index.js +11 -5
- package/src/components/block-toolbar/style.scss +3 -5
- package/src/components/block-tools/insertion-point.js +19 -1
- package/src/components/block-variation-transforms/index.js +39 -27
- package/src/components/border-radius-control/test/utils.js +71 -0
- package/src/components/border-radius-control/utils.js +1 -0
- package/src/components/global-styles/border-panel.js +7 -6
- 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/components/url-popover/image-url-input-ui.js +18 -2
- package/src/components/writing-flow/use-clipboard-handler.js +6 -0
- package/src/store/private-selectors.js +12 -24
- package/src/store/reducer.js +188 -0
- package/src/store/selectors.js +38 -59
- package/src/store/test/reducer.js +398 -0
- package/src/store/test/selectors.js +65 -192
- package/src/store/utils.js +21 -0
- package/src/utils/block-bindings.js +1 -1
|
@@ -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
|
|
|
@@ -4398,5 +4505,296 @@ describe( 'state', () => {
|
|
|
4398
4505
|
);
|
|
4399
4506
|
} );
|
|
4400
4507
|
} );
|
|
4508
|
+
|
|
4509
|
+
// Tests for the contentOnly experiments pattern.
|
|
4510
|
+
// If/when the experiment is stabilized, this wrapping `describe` and
|
|
4511
|
+
// `beforeAll`/`afterAll` can be removed, un-nesting the tests within.
|
|
4512
|
+
describe( 'contentOnly patterns experiment', () => {
|
|
4513
|
+
beforeAll( () => {
|
|
4514
|
+
globalThis.window.__experimentalContentOnlyPatternInsertion = true;
|
|
4515
|
+
} );
|
|
4516
|
+
|
|
4517
|
+
afterAll( () => {
|
|
4518
|
+
delete globalThis.window
|
|
4519
|
+
.__experimentalContentOnlyPatternInsertion;
|
|
4520
|
+
} );
|
|
4521
|
+
|
|
4522
|
+
describe( 'unsynced patterns', () => {
|
|
4523
|
+
let initialState;
|
|
4524
|
+
beforeAll( () => {
|
|
4525
|
+
initialState = dispatchActions(
|
|
4526
|
+
[
|
|
4527
|
+
{
|
|
4528
|
+
type: 'RESET_BLOCKS',
|
|
4529
|
+
blocks: [
|
|
4530
|
+
{
|
|
4531
|
+
name: 'core/group',
|
|
4532
|
+
clientId: 'group-1',
|
|
4533
|
+
attributes: {
|
|
4534
|
+
metadata: {
|
|
4535
|
+
patternName: 'test-pattern',
|
|
4536
|
+
},
|
|
4537
|
+
},
|
|
4538
|
+
innerBlocks: [
|
|
4539
|
+
{
|
|
4540
|
+
name: 'core/paragraph',
|
|
4541
|
+
clientId: 'paragraph-1',
|
|
4542
|
+
attributes: {},
|
|
4543
|
+
innerBlocks: [],
|
|
4544
|
+
},
|
|
4545
|
+
{
|
|
4546
|
+
name: 'core/group',
|
|
4547
|
+
clientId: 'group-2',
|
|
4548
|
+
attributes: {},
|
|
4549
|
+
innerBlocks: [
|
|
4550
|
+
{
|
|
4551
|
+
name: 'core/paragraph',
|
|
4552
|
+
clientId: 'paragraph-2',
|
|
4553
|
+
attributes: {},
|
|
4554
|
+
innerBlocks: [],
|
|
4555
|
+
},
|
|
4556
|
+
],
|
|
4557
|
+
},
|
|
4558
|
+
],
|
|
4559
|
+
},
|
|
4560
|
+
],
|
|
4561
|
+
},
|
|
4562
|
+
],
|
|
4563
|
+
testReducer,
|
|
4564
|
+
initialState
|
|
4565
|
+
);
|
|
4566
|
+
} );
|
|
4567
|
+
|
|
4568
|
+
it( 'returns the expected block editing modes for an unsynced pattern', () => {
|
|
4569
|
+
expect( initialState.derivedBlockEditingModes ).toEqual(
|
|
4570
|
+
new Map(
|
|
4571
|
+
Object.entries( {
|
|
4572
|
+
'paragraph-1': 'contentOnly',
|
|
4573
|
+
'group-2': 'disabled',
|
|
4574
|
+
'paragraph-2': 'contentOnly',
|
|
4575
|
+
} )
|
|
4576
|
+
)
|
|
4577
|
+
);
|
|
4578
|
+
} );
|
|
4579
|
+
|
|
4580
|
+
it( 'removes block editing modes when an unsynced pattern is removed', () => {
|
|
4581
|
+
const { derivedBlockEditingModes } = dispatchActions(
|
|
4582
|
+
[
|
|
4583
|
+
{
|
|
4584
|
+
type: 'REMOVE_BLOCKS',
|
|
4585
|
+
clientIds: [ 'group-1' ],
|
|
4586
|
+
},
|
|
4587
|
+
],
|
|
4588
|
+
testReducer,
|
|
4589
|
+
initialState
|
|
4590
|
+
);
|
|
4591
|
+
|
|
4592
|
+
expect( derivedBlockEditingModes ).toEqual( new Map() );
|
|
4593
|
+
} );
|
|
4594
|
+
|
|
4595
|
+
it( 'removes block editing modes when the `patternName` attribute is removed from the unsynced pattern', () => {
|
|
4596
|
+
const { derivedBlockEditingModes } = dispatchActions(
|
|
4597
|
+
[
|
|
4598
|
+
{
|
|
4599
|
+
type: 'UPDATE_BLOCK_ATTRIBUTES',
|
|
4600
|
+
clientIds: [ 'group-1' ],
|
|
4601
|
+
attributes: {
|
|
4602
|
+
metadata: {
|
|
4603
|
+
patternName: undefined,
|
|
4604
|
+
},
|
|
4605
|
+
},
|
|
4606
|
+
},
|
|
4607
|
+
],
|
|
4608
|
+
testReducer,
|
|
4609
|
+
initialState
|
|
4610
|
+
);
|
|
4611
|
+
|
|
4612
|
+
expect( derivedBlockEditingModes ).toEqual( new Map() );
|
|
4613
|
+
} );
|
|
4614
|
+
|
|
4615
|
+
it( 'allows explicitly set blockEditingModes to override the unsynced pattern editing modes', () => {
|
|
4616
|
+
const { derivedBlockEditingModes } = dispatchActions(
|
|
4617
|
+
[
|
|
4618
|
+
{
|
|
4619
|
+
type: 'SET_BLOCK_EDITING_MODE',
|
|
4620
|
+
clientId: 'paragraph-2',
|
|
4621
|
+
mode: 'disabled',
|
|
4622
|
+
},
|
|
4623
|
+
],
|
|
4624
|
+
testReducer,
|
|
4625
|
+
initialState
|
|
4626
|
+
);
|
|
4627
|
+
|
|
4628
|
+
expect( derivedBlockEditingModes ).toEqual(
|
|
4629
|
+
new Map(
|
|
4630
|
+
Object.entries( {
|
|
4631
|
+
'paragraph-1': 'contentOnly',
|
|
4632
|
+
'group-2': 'disabled',
|
|
4633
|
+
// Paragraph 2 already has an explicit mode, so isn't set as a derived mode.
|
|
4634
|
+
} )
|
|
4635
|
+
)
|
|
4636
|
+
);
|
|
4637
|
+
} );
|
|
4638
|
+
|
|
4639
|
+
it( 'sets the correct block editing modes when a new unsynced pattern is inserted', () => {
|
|
4640
|
+
const { derivedBlockEditingModes } = dispatchActions(
|
|
4641
|
+
[
|
|
4642
|
+
{
|
|
4643
|
+
type: 'INSERT_BLOCKS',
|
|
4644
|
+
rootClientId: '',
|
|
4645
|
+
index: 1,
|
|
4646
|
+
blocks: [
|
|
4647
|
+
{
|
|
4648
|
+
name: 'core/group',
|
|
4649
|
+
clientId: 'group-3',
|
|
4650
|
+
attributes: {
|
|
4651
|
+
metadata: {
|
|
4652
|
+
patternName: 'test-pattern-2',
|
|
4653
|
+
},
|
|
4654
|
+
},
|
|
4655
|
+
innerBlocks: [
|
|
4656
|
+
{
|
|
4657
|
+
name: 'core/paragraph',
|
|
4658
|
+
clientId: 'paragraph-3',
|
|
4659
|
+
attributes: {},
|
|
4660
|
+
innerBlocks: [],
|
|
4661
|
+
},
|
|
4662
|
+
],
|
|
4663
|
+
},
|
|
4664
|
+
],
|
|
4665
|
+
},
|
|
4666
|
+
],
|
|
4667
|
+
testReducer,
|
|
4668
|
+
initialState
|
|
4669
|
+
);
|
|
4670
|
+
|
|
4671
|
+
expect( derivedBlockEditingModes ).toEqual(
|
|
4672
|
+
new Map(
|
|
4673
|
+
Object.entries( {
|
|
4674
|
+
'paragraph-1': 'contentOnly',
|
|
4675
|
+
'group-2': 'disabled',
|
|
4676
|
+
'paragraph-2': 'contentOnly',
|
|
4677
|
+
'paragraph-3': 'contentOnly',
|
|
4678
|
+
} )
|
|
4679
|
+
)
|
|
4680
|
+
);
|
|
4681
|
+
} );
|
|
4682
|
+
} );
|
|
4683
|
+
|
|
4684
|
+
describe( 'template parts', () => {
|
|
4685
|
+
let initialState;
|
|
4686
|
+
beforeAll( () => {
|
|
4687
|
+
// Simulates how the editor typically inserts controlled blocks,
|
|
4688
|
+
// - first the template part is inserted with no inner blocks.
|
|
4689
|
+
// - next the template part is marked as a controlled block.
|
|
4690
|
+
// - finally, once the inner blocks of the template part are received, they're inserted.
|
|
4691
|
+
initialState = dispatchActions(
|
|
4692
|
+
[
|
|
4693
|
+
{
|
|
4694
|
+
type: 'RESET_BLOCKS',
|
|
4695
|
+
blocks: [
|
|
4696
|
+
{
|
|
4697
|
+
name: 'core/template-part',
|
|
4698
|
+
clientId: 'template-part',
|
|
4699
|
+
attributes: {},
|
|
4700
|
+
innerBlocks: [],
|
|
4701
|
+
},
|
|
4702
|
+
],
|
|
4703
|
+
},
|
|
4704
|
+
{
|
|
4705
|
+
type: 'SET_HAS_CONTROLLED_INNER_BLOCKS',
|
|
4706
|
+
clientId: 'template-part',
|
|
4707
|
+
hasControlledInnerBlocks: true,
|
|
4708
|
+
},
|
|
4709
|
+
{
|
|
4710
|
+
type: 'REPLACE_INNER_BLOCKS',
|
|
4711
|
+
rootClientId: 'template-part',
|
|
4712
|
+
blocks: [
|
|
4713
|
+
{
|
|
4714
|
+
name: 'core/paragraph',
|
|
4715
|
+
clientId: 'template-part-paragraph',
|
|
4716
|
+
attributes: {},
|
|
4717
|
+
innerBlocks: [],
|
|
4718
|
+
},
|
|
4719
|
+
{
|
|
4720
|
+
name: 'core/group',
|
|
4721
|
+
clientId: 'template-part-group',
|
|
4722
|
+
attributes: {},
|
|
4723
|
+
innerBlocks: [
|
|
4724
|
+
{
|
|
4725
|
+
name: 'core/paragraph',
|
|
4726
|
+
clientId:
|
|
4727
|
+
'template-part-grouped-paragraph',
|
|
4728
|
+
attributes: {},
|
|
4729
|
+
innerBlocks: [],
|
|
4730
|
+
},
|
|
4731
|
+
],
|
|
4732
|
+
},
|
|
4733
|
+
],
|
|
4734
|
+
},
|
|
4735
|
+
],
|
|
4736
|
+
testReducer,
|
|
4737
|
+
initialState
|
|
4738
|
+
);
|
|
4739
|
+
} );
|
|
4740
|
+
|
|
4741
|
+
it( 'returns the expected block editing modes for synced patterns', () => {
|
|
4742
|
+
expect( initialState.derivedBlockEditingModes ).toEqual(
|
|
4743
|
+
new Map(
|
|
4744
|
+
Object.entries( {
|
|
4745
|
+
'template-part-paragraph': 'contentOnly',
|
|
4746
|
+
'template-part-group': 'disabled',
|
|
4747
|
+
'template-part-grouped-paragraph':
|
|
4748
|
+
'contentOnly',
|
|
4749
|
+
} )
|
|
4750
|
+
)
|
|
4751
|
+
);
|
|
4752
|
+
} );
|
|
4753
|
+
|
|
4754
|
+
it( 'removes the block editing modes when the template part is removed', () => {
|
|
4755
|
+
const { derivedBlockEditingModes } = dispatchActions(
|
|
4756
|
+
[
|
|
4757
|
+
{
|
|
4758
|
+
type: 'REMOVE_BLOCKS',
|
|
4759
|
+
clientIds: [ 'template-part' ],
|
|
4760
|
+
},
|
|
4761
|
+
{
|
|
4762
|
+
type: 'SET_HAS_CONTROLLED_INNER_BLOCKS',
|
|
4763
|
+
clientId: 'template-part',
|
|
4764
|
+
hasControlledInnerBlocks: false,
|
|
4765
|
+
},
|
|
4766
|
+
],
|
|
4767
|
+
testReducer,
|
|
4768
|
+
initialState
|
|
4769
|
+
);
|
|
4770
|
+
|
|
4771
|
+
expect( derivedBlockEditingModes ).toEqual( new Map() );
|
|
4772
|
+
} );
|
|
4773
|
+
|
|
4774
|
+
it( 'allows explicitly set blockEditingModes to override the template part editing modes', () => {
|
|
4775
|
+
const { derivedBlockEditingModes } = dispatchActions(
|
|
4776
|
+
[
|
|
4777
|
+
{
|
|
4778
|
+
type: 'SET_BLOCK_EDITING_MODE',
|
|
4779
|
+
clientId: 'template-part-grouped-paragraph',
|
|
4780
|
+
mode: 'disabled',
|
|
4781
|
+
},
|
|
4782
|
+
],
|
|
4783
|
+
testReducer,
|
|
4784
|
+
initialState
|
|
4785
|
+
);
|
|
4786
|
+
|
|
4787
|
+
expect( derivedBlockEditingModes ).toEqual(
|
|
4788
|
+
new Map(
|
|
4789
|
+
Object.entries( {
|
|
4790
|
+
'template-part-paragraph': 'contentOnly',
|
|
4791
|
+
'template-part-group': 'disabled',
|
|
4792
|
+
// template-part-grouped-paragraph already has an explicit mode, so isn't set as a derived mode.
|
|
4793
|
+
} )
|
|
4794
|
+
)
|
|
4795
|
+
);
|
|
4796
|
+
} );
|
|
4797
|
+
} );
|
|
4798
|
+
} );
|
|
4401
4799
|
} );
|
|
4402
4800
|
} );
|
|
@@ -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
|
} );
|