@wordpress/block-editor 15.13.2-next.v.202602241322.0 → 15.14.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/README.md +1 -0
- package/build/components/block-quick-navigation/index.cjs +6 -1
- package/build/components/block-quick-navigation/index.cjs.map +3 -3
- package/build/components/block-settings-menu/block-settings-dropdown.cjs +47 -4
- package/build/components/block-settings-menu/block-settings-dropdown.cjs.map +2 -2
- package/build/components/block-settings-menu-controls/index.cjs +1 -0
- package/build/components/block-settings-menu-controls/index.cjs.map +2 -2
- package/build/components/block-styles/index.cjs +68 -57
- package/build/components/block-styles/index.cjs.map +3 -3
- package/build/components/block-styles/menu-items.cjs +10 -16
- package/build/components/block-styles/menu-items.cjs.map +3 -3
- package/build/components/block-switcher/block-styles-menu.cjs +50 -2
- package/build/components/block-switcher/block-styles-menu.cjs.map +3 -3
- package/build/components/block-switcher/block-transformations-menu.cjs +2 -0
- package/build/components/block-switcher/block-transformations-menu.cjs.map +2 -2
- package/build/components/block-switcher/block-variation-transformations.cjs +2 -0
- package/build/components/block-switcher/block-variation-transformations.cjs.map +2 -2
- package/build/components/block-switcher/preview-block-popover.cjs +10 -8
- package/build/components/block-switcher/preview-block-popover.cjs.map +2 -2
- package/build/components/block-toolbar/block-toolbar-icon.cjs +1 -1
- package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
- package/build/components/block-toolbar/index.cjs +8 -4
- package/build/components/block-toolbar/index.cjs.map +2 -2
- package/build/components/block-visibility/modal.cjs +2 -2
- package/build/components/block-visibility/modal.cjs.map +2 -2
- package/build/components/dimension-control/index.cjs +4 -2
- package/build/components/dimension-control/index.cjs.map +2 -2
- package/build/components/global-styles/dimensions-panel.cjs +6 -3
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/grid/grid-visualizer.cjs +3 -0
- package/build/components/grid/grid-visualizer.cjs.map +2 -2
- package/build/components/list-view/block.cjs +2 -1
- package/build/components/list-view/block.cjs.map +2 -2
- package/build/hooks/auto-inspector-controls.cjs +26 -2
- package/build/hooks/auto-inspector-controls.cjs.map +3 -3
- package/build/index.cjs +2 -0
- package/build/index.cjs.map +2 -2
- package/build/store/reducer.cjs +13 -15
- package/build/store/reducer.cjs.map +2 -2
- package/build-module/components/block-quick-navigation/index.mjs +6 -1
- package/build-module/components/block-quick-navigation/index.mjs.map +2 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.mjs +48 -5
- package/build-module/components/block-settings-menu/block-settings-dropdown.mjs.map +2 -2
- package/build-module/components/block-settings-menu-controls/index.mjs +1 -0
- package/build-module/components/block-settings-menu-controls/index.mjs.map +2 -2
- package/build-module/components/block-styles/index.mjs +71 -61
- package/build-module/components/block-styles/index.mjs.map +2 -2
- package/build-module/components/block-styles/menu-items.mjs +10 -6
- package/build-module/components/block-styles/menu-items.mjs.map +2 -2
- package/build-module/components/block-switcher/block-styles-menu.mjs +51 -3
- package/build-module/components/block-switcher/block-styles-menu.mjs.map +2 -2
- package/build-module/components/block-switcher/block-transformations-menu.mjs +2 -0
- package/build-module/components/block-switcher/block-transformations-menu.mjs.map +2 -2
- package/build-module/components/block-switcher/block-variation-transformations.mjs +2 -0
- package/build-module/components/block-switcher/block-variation-transformations.mjs.map +2 -2
- package/build-module/components/block-switcher/preview-block-popover.mjs +11 -9
- package/build-module/components/block-switcher/preview-block-popover.mjs.map +2 -2
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs +1 -1
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
- package/build-module/components/block-toolbar/index.mjs +8 -4
- package/build-module/components/block-toolbar/index.mjs.map +2 -2
- package/build-module/components/block-visibility/modal.mjs +2 -2
- package/build-module/components/block-visibility/modal.mjs.map +2 -2
- package/build-module/components/dimension-control/index.mjs +4 -2
- package/build-module/components/dimension-control/index.mjs.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.mjs +6 -3
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/grid/grid-visualizer.mjs +3 -0
- package/build-module/components/grid/grid-visualizer.mjs.map +2 -2
- package/build-module/components/list-view/block.mjs +2 -1
- package/build-module/components/list-view/block.mjs.map +2 -2
- package/build-module/hooks/auto-inspector-controls.mjs +28 -4
- package/build-module/hooks/auto-inspector-controls.mjs.map +2 -2
- package/build-module/index.mjs +2 -0
- package/build-module/index.mjs.map +3 -3
- package/build-module/store/reducer.mjs +13 -15
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-style/content-rtl.css +12 -7
- package/build-style/content.css +13 -7
- package/build-style/style-rtl.css +0 -13
- package/build-style/style.css +0 -13
- package/package.json +39 -39
- package/src/components/block-list/content.scss +4 -0
- package/src/components/block-quick-navigation/index.js +6 -1
- package/src/components/block-settings-menu/block-settings-dropdown.js +46 -2
- package/src/components/block-settings-menu-controls/index.js +1 -0
- package/src/components/block-styles/index.js +35 -24
- package/src/components/block-styles/menu-items.js +10 -11
- package/src/components/block-styles/style.scss +0 -7
- package/src/components/block-switcher/block-styles-menu.js +47 -1
- package/src/components/block-switcher/block-transformations-menu.js +2 -0
- package/src/components/block-switcher/block-variation-transformations.js +2 -0
- package/src/components/block-switcher/preview-block-popover.js +9 -7
- package/src/components/block-switcher/style.scss +0 -8
- package/src/components/block-toolbar/block-toolbar-icon.js +6 -1
- package/src/components/block-toolbar/index.js +7 -2
- package/src/components/block-tools/style.scss +1 -14
- package/src/components/default-block-appender/content.scss +3 -25
- package/src/components/dimension-control/index.js +7 -4
- package/src/components/global-styles/dimensions-panel.js +3 -0
- package/src/components/grid/grid-visualizer.js +3 -0
- package/src/components/list-view/block.js +5 -0
- package/src/hooks/auto-inspector-controls.js +31 -4
- package/src/hooks/test/dimensions.js +16 -0
- package/src/index.js +1 -0
- package/src/store/reducer.js +23 -20
- package/src/store/test/reducer.js +109 -0
- package/build/components/block-styles/preview-panel.cjs +0 -61
- package/build/components/block-styles/preview-panel.cjs.map +0 -7
- package/build-module/components/block-styles/preview-panel.mjs +0 -30
- package/build-module/components/block-styles/preview-panel.mjs.map +0 -7
- package/src/components/block-styles/preview-panel.js +0 -35
|
@@ -41,14 +41,6 @@
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
.block-editor-block-switcher__preview-title {
|
|
45
|
-
margin-bottom: $grid-unit-15;
|
|
46
|
-
color: $gray-700;
|
|
47
|
-
text-transform: uppercase;
|
|
48
|
-
font-size: 11px;
|
|
49
|
-
font-weight: $font-weight-medium;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
44
|
.block-editor-block-switcher__preview-patterns-container {
|
|
53
45
|
padding-bottom: $grid-unit-20;
|
|
54
46
|
|
|
@@ -71,7 +71,12 @@ function getBlockIconVariant( { select, clientIds } ) {
|
|
|
71
71
|
|
|
72
72
|
if ( _showBlockSwitcher ) {
|
|
73
73
|
return 'switcher';
|
|
74
|
-
} else if (
|
|
74
|
+
} else if (
|
|
75
|
+
isContentOnlyMode &&
|
|
76
|
+
hasBlockStyles &&
|
|
77
|
+
! hasPatternOverrides &&
|
|
78
|
+
canEdit
|
|
79
|
+
) {
|
|
75
80
|
return 'styles-only';
|
|
76
81
|
} else if ( _showPatternOverrides ) {
|
|
77
82
|
return 'pattern-overrides';
|
|
@@ -78,7 +78,9 @@ export function PrivateBlockToolbar( {
|
|
|
78
78
|
showBlockVisibilityButton,
|
|
79
79
|
showSwitchSectionStyleButton,
|
|
80
80
|
areSelectedBlocksHiddenOnViewport,
|
|
81
|
+
canEdit,
|
|
81
82
|
} = useSelect( ( select ) => {
|
|
83
|
+
const { canEditBlock } = select( blockEditorStore );
|
|
82
84
|
const {
|
|
83
85
|
getBlockName,
|
|
84
86
|
getBlockMode,
|
|
@@ -122,7 +124,9 @@ export function PrivateBlockToolbar( {
|
|
|
122
124
|
|
|
123
125
|
const _isZoomOut = isZoomOut();
|
|
124
126
|
const _isSectionBlock = isSectionBlock( selectedBlockClientId );
|
|
125
|
-
const
|
|
127
|
+
const _canEditBlock = canEditBlock( selectedBlockClientId );
|
|
128
|
+
const _showSwitchSectionStyleButton =
|
|
129
|
+
_canEditBlock && ( _isZoomOut || _isSectionBlock );
|
|
126
130
|
|
|
127
131
|
const _currentDeviceType =
|
|
128
132
|
getSettings()?.[ deviceTypeKey ]?.toLowerCase() || 'desktop';
|
|
@@ -161,6 +165,7 @@ export function PrivateBlockToolbar( {
|
|
|
161
165
|
showSwitchSectionStyleButton: _showSwitchSectionStyleButton,
|
|
162
166
|
areSelectedBlocksHiddenOnViewport:
|
|
163
167
|
_areSelectedBlocksHiddenOnViewport,
|
|
168
|
+
canEdit: _canEditBlock,
|
|
164
169
|
};
|
|
165
170
|
}, [] );
|
|
166
171
|
|
|
@@ -245,7 +250,7 @@ export function PrivateBlockToolbar( {
|
|
|
245
250
|
shouldShowVisualToolbar &&
|
|
246
251
|
isMultiToolbar &&
|
|
247
252
|
showGroupButtons && <BlockGroupToolbar /> }
|
|
248
|
-
{ ! isMultiToolbar && (
|
|
253
|
+
{ ! isMultiToolbar && canEdit && (
|
|
249
254
|
<EditSectionButton clientId={ blockClientIds[ 0 ] } />
|
|
250
255
|
) }
|
|
251
256
|
{ ! areSelectedBlocksHiddenOnViewport && showShuffleButton && (
|
|
@@ -76,20 +76,7 @@
|
|
|
76
76
|
.block-editor-block-list__empty-block-inserter,
|
|
77
77
|
.block-editor-block-list__insertion-point-inserter {
|
|
78
78
|
.block-editor-inserter__toggle.components-button.has-icon {
|
|
79
|
-
|
|
80
|
-
background: $gray-900;
|
|
81
|
-
color: $white;
|
|
82
|
-
padding: 0;
|
|
83
|
-
|
|
84
|
-
// TODO: Consider passing size="small" to the Inserter toggle instead.
|
|
85
|
-
// Special dimensions for this button.
|
|
86
|
-
min-width: $button-size-small;
|
|
87
|
-
height: $button-size-small;
|
|
88
|
-
|
|
89
|
-
&:hover {
|
|
90
|
-
color: $white;
|
|
91
|
-
background: var(--wp-admin-theme-color);
|
|
92
|
-
}
|
|
79
|
+
@include inserter-toggle;
|
|
93
80
|
}
|
|
94
81
|
}
|
|
95
82
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
@use "@wordpress/base-styles/colors" as *;
|
|
2
|
+
@use "@wordpress/base-styles/mixins" as *;
|
|
2
3
|
@use "@wordpress/base-styles/variables" as *;
|
|
3
4
|
@use "@wordpress/base-styles/z-index" as *;
|
|
4
5
|
|
|
@@ -41,20 +42,7 @@
|
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
.block-editor-inserter__toggle.components-button.has-icon {
|
|
44
|
-
|
|
45
|
-
background: $gray-900;
|
|
46
|
-
color: $white;
|
|
47
|
-
padding: 0;
|
|
48
|
-
|
|
49
|
-
// TODO: Consider passing size="small" to the Inserter toggle instead.
|
|
50
|
-
// Special dimensions for this button.
|
|
51
|
-
min-width: $button-size-small;
|
|
52
|
-
height: $button-size-small;
|
|
53
|
-
|
|
54
|
-
&:hover {
|
|
55
|
-
color: $white;
|
|
56
|
-
background: var(--wp-admin-theme-color);
|
|
57
|
-
}
|
|
45
|
+
@include inserter-toggle;
|
|
58
46
|
}
|
|
59
47
|
}
|
|
60
48
|
|
|
@@ -103,26 +91,16 @@
|
|
|
103
91
|
// treating them the same, one or both can be retired.
|
|
104
92
|
.block-editor-inserter__toggle.components-button.has-icon,
|
|
105
93
|
.block-list-appender__toggle {
|
|
94
|
+
@include inserter-toggle;
|
|
106
95
|
flex-direction: row;
|
|
107
96
|
box-shadow: none;
|
|
108
|
-
height: $button-size-small;
|
|
109
97
|
width: $button-size-small;
|
|
110
|
-
min-width: $button-size-small;
|
|
111
98
|
|
|
112
99
|
// Hide by default, then we unhide it when the selected block is a direct ancestor.
|
|
113
100
|
display: none;
|
|
114
101
|
|
|
115
102
|
// Important to override styles form Button component.
|
|
116
103
|
padding: 0 !important;
|
|
117
|
-
|
|
118
|
-
// Basic look
|
|
119
|
-
background: $gray-900;
|
|
120
|
-
color: $white;
|
|
121
|
-
|
|
122
|
-
&:hover {
|
|
123
|
-
color: $white;
|
|
124
|
-
background: var(--wp-admin-theme-color);
|
|
125
|
-
}
|
|
126
104
|
}
|
|
127
105
|
|
|
128
106
|
// This content only shows up inside the empty appender.
|
|
@@ -55,9 +55,10 @@ function useDimensionSizes( presets ) {
|
|
|
55
55
|
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/dimension-control/README.md
|
|
56
56
|
*
|
|
57
57
|
* @param {Object} props
|
|
58
|
-
* @param {?string} props.label
|
|
59
|
-
* @param {( value: string ) => void } props.onChange
|
|
60
|
-
* @param {string} props.value
|
|
58
|
+
* @param {?string} props.label A label for the control.
|
|
59
|
+
* @param {( value: string ) => void } props.onChange Called when the dimension value changes.
|
|
60
|
+
* @param {string} props.value The current dimension value.
|
|
61
|
+
* @param {?Object} props.dimensionSizes Optional dimension size presets. Falls back to settings from the store.
|
|
61
62
|
*
|
|
62
63
|
* @return {Component} The component to be rendered.
|
|
63
64
|
*/
|
|
@@ -65,11 +66,13 @@ export default function DimensionControl( {
|
|
|
65
66
|
label = __( 'Dimension' ),
|
|
66
67
|
onChange,
|
|
67
68
|
value,
|
|
69
|
+
dimensionSizes: dimensionSizesProp,
|
|
68
70
|
} ) {
|
|
69
|
-
const [
|
|
71
|
+
const [ dimensionSizesFromSettings, availableUnits ] = useSettings(
|
|
70
72
|
'dimensions.dimensionSizes',
|
|
71
73
|
'spacing.units'
|
|
72
74
|
);
|
|
75
|
+
const dimensionSizes = dimensionSizesProp ?? dimensionSizesFromSettings;
|
|
73
76
|
|
|
74
77
|
const units = useCustomUnits( {
|
|
75
78
|
availableUnits: availableUnits || [
|
|
@@ -735,6 +735,7 @@ export default function DimensionsPanel( {
|
|
|
735
735
|
label={ __( 'Minimum height' ) }
|
|
736
736
|
value={ minHeightValue }
|
|
737
737
|
onChange={ setMinHeightValue }
|
|
738
|
+
dimensionSizes={ dimensions?.dimensionSizes }
|
|
738
739
|
/>
|
|
739
740
|
</ToolsPanelItem>
|
|
740
741
|
) }
|
|
@@ -752,6 +753,7 @@ export default function DimensionsPanel( {
|
|
|
752
753
|
label={ __( 'Height' ) }
|
|
753
754
|
value={ heightValue }
|
|
754
755
|
onChange={ setHeightValue }
|
|
756
|
+
dimensionSizes={ dimensions?.dimensionSizes }
|
|
755
757
|
/>
|
|
756
758
|
</ToolsPanelItem>
|
|
757
759
|
) }
|
|
@@ -769,6 +771,7 @@ export default function DimensionsPanel( {
|
|
|
769
771
|
label={ __( 'Width' ) }
|
|
770
772
|
value={ widthValue }
|
|
771
773
|
onChange={ setWidthValue }
|
|
774
|
+
dimensionSizes={ dimensions?.dimensionSizes }
|
|
772
775
|
/>
|
|
773
776
|
</ToolsPanelItem>
|
|
774
777
|
) }
|
|
@@ -82,6 +82,9 @@ const GridVisualizerGrid = forwardRef(
|
|
|
82
82
|
borderBoxSpy.observe( gridElement, { box: 'border-box' } );
|
|
83
83
|
const contentBoxSpy = new window.ResizeObserver( resizeCallback );
|
|
84
84
|
contentBoxSpy.observe( gridElement );
|
|
85
|
+
for ( const element of gridElement.children ) {
|
|
86
|
+
contentBoxSpy.observe( element );
|
|
87
|
+
}
|
|
85
88
|
return () => {
|
|
86
89
|
borderBoxSpy.disconnect();
|
|
87
90
|
contentBoxSpy.disconnect();
|
|
@@ -700,6 +700,11 @@ function ListViewBlock( {
|
|
|
700
700
|
__experimentalSelectBlock={
|
|
701
701
|
updateFocusAndSelection
|
|
702
702
|
}
|
|
703
|
+
isContentOnlyListView={
|
|
704
|
+
!! rootClientId &&
|
|
705
|
+
getBlockEditingMode( rootClientId ) ===
|
|
706
|
+
'contentOnly'
|
|
707
|
+
}
|
|
703
708
|
/>
|
|
704
709
|
) }
|
|
705
710
|
</TreeGridCell>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { getBlockType } from '@wordpress/blocks';
|
|
4
|
+
import { getBlockType, store as blocksStore } from '@wordpress/blocks';
|
|
5
5
|
import { PanelBody } from '@wordpress/components';
|
|
6
6
|
import { useSelect } from '@wordpress/data';
|
|
7
7
|
import { DataForm } from '@wordpress/dataviews';
|
|
8
|
-
import { useMemo } from '@wordpress/element';
|
|
8
|
+
import { useContext, useMemo } from '@wordpress/element';
|
|
9
9
|
import { __ } from '@wordpress/i18n';
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -14,6 +14,8 @@ import { __ } from '@wordpress/i18n';
|
|
|
14
14
|
import InspectorControls from '../components/inspector-controls';
|
|
15
15
|
import { useBlockEditingMode } from '../components/block-editing-mode';
|
|
16
16
|
import { store as blockEditorStore } from '../store';
|
|
17
|
+
import { unlock } from '../lock-unlock';
|
|
18
|
+
import BlockContext from '../components/block-context';
|
|
17
19
|
import { generateFieldsFromAttributes } from './generate-fields-from-attributes';
|
|
18
20
|
|
|
19
21
|
/**
|
|
@@ -45,9 +47,34 @@ function hasAutoGenerateControl( blockTypeAttributes ) {
|
|
|
45
47
|
function AutoRegisterControls( { name, clientId, setAttributes } ) {
|
|
46
48
|
const blockEditingMode = useBlockEditingMode();
|
|
47
49
|
|
|
50
|
+
const blockContext = useContext( BlockContext );
|
|
51
|
+
|
|
48
52
|
const attributes = useSelect(
|
|
49
|
-
( select ) =>
|
|
50
|
-
|
|
53
|
+
( select ) => {
|
|
54
|
+
const _attributes =
|
|
55
|
+
select( blockEditorStore ).getBlockAttributes( clientId );
|
|
56
|
+
if ( ! _attributes?.metadata?.bindings ) {
|
|
57
|
+
return _attributes;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const { getBlockBindingsSource } = unlock( select( blocksStore ) );
|
|
61
|
+
return Object.entries( _attributes.metadata.bindings ).reduce(
|
|
62
|
+
( acc, [ attribute, binding ] ) => {
|
|
63
|
+
const source = getBlockBindingsSource( binding.source );
|
|
64
|
+
if ( ! source ) {
|
|
65
|
+
return acc;
|
|
66
|
+
}
|
|
67
|
+
const values = source.getValues( {
|
|
68
|
+
select,
|
|
69
|
+
context: blockContext,
|
|
70
|
+
bindings: { [ attribute ]: binding },
|
|
71
|
+
} );
|
|
72
|
+
return { ...acc, ...values };
|
|
73
|
+
},
|
|
74
|
+
_attributes
|
|
75
|
+
);
|
|
76
|
+
},
|
|
77
|
+
[ blockContext, clientId ]
|
|
51
78
|
);
|
|
52
79
|
|
|
53
80
|
const blockType = getBlockType( name );
|
|
@@ -93,4 +93,20 @@ describe( 'getDimensionsClassesAndStyles', () => {
|
|
|
93
93
|
},
|
|
94
94
|
} );
|
|
95
95
|
} );
|
|
96
|
+
|
|
97
|
+
it( 'should convert preset width value to CSS var', () => {
|
|
98
|
+
const attributes = {
|
|
99
|
+
style: {
|
|
100
|
+
dimensions: {
|
|
101
|
+
width: 'var:preset|dimension|custom-width',
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
expect( getDimensionsClassesAndStyles( attributes ) ).toEqual( {
|
|
106
|
+
className: undefined,
|
|
107
|
+
style: {
|
|
108
|
+
width: 'var(--wp--preset--dimension--custom-width)',
|
|
109
|
+
},
|
|
110
|
+
} );
|
|
111
|
+
} );
|
|
96
112
|
} );
|
package/src/index.js
CHANGED
|
@@ -11,6 +11,7 @@ export {
|
|
|
11
11
|
useColorProps as __experimentalUseColorProps,
|
|
12
12
|
useCustomSides as __experimentalUseCustomSides,
|
|
13
13
|
getSpacingClassesAndStyles as __experimentalGetSpacingClassesAndStyles,
|
|
14
|
+
getDimensionsClassesAndStyles as __experimentalGetDimensionsClassesAndStyles,
|
|
14
15
|
getGapCSSValue as __experimentalGetGapCSSValue,
|
|
15
16
|
getShadowClassesAndStyles as __experimentalGetShadowClassesAndStyles,
|
|
16
17
|
useCachedTruthy,
|
package/src/store/reducer.js
CHANGED
|
@@ -2559,6 +2559,25 @@ function getDerivedBlockEditingModesForTree( state, treeClientId = '' ) {
|
|
|
2559
2559
|
traverseBlockTree( state, treeClientId, ( block ) => {
|
|
2560
2560
|
const { clientId, name: blockName } = block;
|
|
2561
2561
|
|
|
2562
|
+
const hasEditedContentOnlySection = !! state.editedContentOnlySection;
|
|
2563
|
+
let isWithinEditedContentOnlySection = false;
|
|
2564
|
+
if ( hasEditedContentOnlySection ) {
|
|
2565
|
+
isWithinEditedContentOnlySection =
|
|
2566
|
+
clientId === state.editedContentOnlySection ||
|
|
2567
|
+
!! findParentInClientIdsList( state, clientId, [
|
|
2568
|
+
state.editedContentOnlySection,
|
|
2569
|
+
] );
|
|
2570
|
+
|
|
2571
|
+
// When a contentOnly section is being edited, all blocks outside
|
|
2572
|
+
// the section are disabled. This should never be overridable by any
|
|
2573
|
+
// other block editing modes, it helps to constrain keyboard navigation
|
|
2574
|
+
// to within the edited section.
|
|
2575
|
+
if ( ! isWithinEditedContentOnlySection ) {
|
|
2576
|
+
derivedBlockEditingModes.set( clientId, 'disabled' );
|
|
2577
|
+
return;
|
|
2578
|
+
}
|
|
2579
|
+
}
|
|
2580
|
+
|
|
2562
2581
|
// If the block already has an explicit block editing mode set,
|
|
2563
2582
|
// don't override it.
|
|
2564
2583
|
if ( state.blockEditingModes.has( clientId ) ) {
|
|
@@ -2670,26 +2689,10 @@ function getDerivedBlockEditingModesForTree( state, treeClientId = '' ) {
|
|
|
2670
2689
|
}
|
|
2671
2690
|
|
|
2672
2691
|
// Set the edited section and all blocks within it to 'default', so that all changes can be made.
|
|
2673
|
-
if (
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
return;
|
|
2678
|
-
}
|
|
2679
|
-
|
|
2680
|
-
// If the block is within the edited section also use the default mode.
|
|
2681
|
-
const parentTempEditedClientId = findParentInClientIdsList(
|
|
2682
|
-
state,
|
|
2683
|
-
clientId,
|
|
2684
|
-
[ state.editedContentOnlySection ]
|
|
2685
|
-
);
|
|
2686
|
-
if ( parentTempEditedClientId ) {
|
|
2687
|
-
derivedBlockEditingModes.set( clientId, 'default' );
|
|
2688
|
-
return;
|
|
2689
|
-
}
|
|
2690
|
-
|
|
2691
|
-
// Disable blocks that are outside of the edited section.
|
|
2692
|
-
derivedBlockEditingModes.set( clientId, 'disabled' );
|
|
2692
|
+
if ( hasEditedContentOnlySection && isWithinEditedContentOnlySection ) {
|
|
2693
|
+
derivedBlockEditingModes.set( clientId, 'default' );
|
|
2694
|
+
// When there's an editedContentOnlySection, it overrides any modes that are usually
|
|
2695
|
+
// set for `contentOnlyParents`, return early to prevent continuing to code below.
|
|
2693
2696
|
return;
|
|
2694
2697
|
}
|
|
2695
2698
|
|
|
@@ -4188,6 +4188,115 @@ describe( 'state', () => {
|
|
|
4188
4188
|
);
|
|
4189
4189
|
} );
|
|
4190
4190
|
|
|
4191
|
+
it( 'disables a sibling synced pattern when an unsynced pattern is the editedContentOnlySection', () => {
|
|
4192
|
+
// Set up two sibling blocks at the root:
|
|
4193
|
+
// 1. An unsynced pattern (core/group with patternName)
|
|
4194
|
+
// 2. A synced pattern (core/block with controlled inner blocks)
|
|
4195
|
+
// When the unsynced pattern becomes the editedContentOnlySection,
|
|
4196
|
+
// the synced pattern and all its contents should be disabled.
|
|
4197
|
+
const stateWithSiblingPatterns = dispatchActions(
|
|
4198
|
+
[
|
|
4199
|
+
{
|
|
4200
|
+
type: 'UPDATE_SETTINGS',
|
|
4201
|
+
settings: {
|
|
4202
|
+
[ sectionRootClientIdKey ]: '',
|
|
4203
|
+
},
|
|
4204
|
+
},
|
|
4205
|
+
{
|
|
4206
|
+
type: 'RESET_BLOCKS',
|
|
4207
|
+
blocks: [
|
|
4208
|
+
{
|
|
4209
|
+
name: 'core/group',
|
|
4210
|
+
clientId: 'unsynced-pattern',
|
|
4211
|
+
attributes: {
|
|
4212
|
+
metadata: {
|
|
4213
|
+
patternName: 'test-pattern',
|
|
4214
|
+
},
|
|
4215
|
+
},
|
|
4216
|
+
innerBlocks: [
|
|
4217
|
+
{
|
|
4218
|
+
name: 'core/paragraph',
|
|
4219
|
+
clientId:
|
|
4220
|
+
'unsynced-pattern-paragraph',
|
|
4221
|
+
attributes: {},
|
|
4222
|
+
innerBlocks: [],
|
|
4223
|
+
},
|
|
4224
|
+
],
|
|
4225
|
+
},
|
|
4226
|
+
{
|
|
4227
|
+
name: 'core/block',
|
|
4228
|
+
clientId: 'sibling-synced-pattern',
|
|
4229
|
+
attributes: {},
|
|
4230
|
+
innerBlocks: [],
|
|
4231
|
+
},
|
|
4232
|
+
],
|
|
4233
|
+
},
|
|
4234
|
+
{
|
|
4235
|
+
type: 'SET_HAS_CONTROLLED_INNER_BLOCKS',
|
|
4236
|
+
clientId: 'sibling-synced-pattern',
|
|
4237
|
+
hasControlledInnerBlocks: true,
|
|
4238
|
+
},
|
|
4239
|
+
{
|
|
4240
|
+
type: 'REPLACE_INNER_BLOCKS',
|
|
4241
|
+
rootClientId: 'sibling-synced-pattern',
|
|
4242
|
+
blocks: [
|
|
4243
|
+
{
|
|
4244
|
+
name: 'core/paragraph',
|
|
4245
|
+
clientId: 'synced-pattern-paragraph',
|
|
4246
|
+
attributes: {},
|
|
4247
|
+
innerBlocks: [],
|
|
4248
|
+
},
|
|
4249
|
+
{
|
|
4250
|
+
name: 'core/paragraph',
|
|
4251
|
+
clientId:
|
|
4252
|
+
'synced-pattern-paragraph-with-overrides',
|
|
4253
|
+
attributes: {
|
|
4254
|
+
metadata: {
|
|
4255
|
+
bindings: {
|
|
4256
|
+
__default:
|
|
4257
|
+
'core/pattern-overrides',
|
|
4258
|
+
},
|
|
4259
|
+
},
|
|
4260
|
+
},
|
|
4261
|
+
innerBlocks: [],
|
|
4262
|
+
},
|
|
4263
|
+
],
|
|
4264
|
+
},
|
|
4265
|
+
],
|
|
4266
|
+
testReducer
|
|
4267
|
+
);
|
|
4268
|
+
|
|
4269
|
+
// Start editing the unsynced pattern section.
|
|
4270
|
+
const editingState = dispatchActions(
|
|
4271
|
+
[
|
|
4272
|
+
{
|
|
4273
|
+
type: 'EDIT_CONTENT_ONLY_SECTION',
|
|
4274
|
+
clientId: 'unsynced-pattern',
|
|
4275
|
+
},
|
|
4276
|
+
],
|
|
4277
|
+
testReducer,
|
|
4278
|
+
stateWithSiblingPatterns
|
|
4279
|
+
);
|
|
4280
|
+
|
|
4281
|
+
expect( editingState.derivedBlockEditingModes ).toEqual(
|
|
4282
|
+
new Map(
|
|
4283
|
+
Object.entries( {
|
|
4284
|
+
// Root is outside the edited section.
|
|
4285
|
+
'': 'disabled',
|
|
4286
|
+
// The edited unsynced pattern is fully editable.
|
|
4287
|
+
'unsynced-pattern': 'default',
|
|
4288
|
+
'unsynced-pattern-paragraph': 'default',
|
|
4289
|
+
// The sibling synced pattern and all its inner blocks
|
|
4290
|
+
// are disabled because they're outside the edited section.
|
|
4291
|
+
'sibling-synced-pattern': 'disabled',
|
|
4292
|
+
'synced-pattern-paragraph': 'disabled',
|
|
4293
|
+
'synced-pattern-paragraph-with-overrides':
|
|
4294
|
+
'disabled',
|
|
4295
|
+
} )
|
|
4296
|
+
)
|
|
4297
|
+
);
|
|
4298
|
+
} );
|
|
4299
|
+
|
|
4191
4300
|
it( 'returns the expected block editing modes for synced patterns when switching to zoomed out mode', () => {
|
|
4192
4301
|
const { derivedBlockEditingModes } = dispatchActions(
|
|
4193
4302
|
[
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// packages/block-editor/src/components/block-styles/preview-panel.js
|
|
31
|
-
var preview_panel_exports = {};
|
|
32
|
-
__export(preview_panel_exports, {
|
|
33
|
-
default: () => BlockStylesPreviewPanel
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(preview_panel_exports);
|
|
36
|
-
var import_element = require("@wordpress/element");
|
|
37
|
-
var import_preview_panel = __toESM(require("../inserter/preview-panel.cjs"));
|
|
38
|
-
var import_utils = require("./utils.cjs");
|
|
39
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
40
|
-
function BlockStylesPreviewPanel({
|
|
41
|
-
genericPreviewBlock,
|
|
42
|
-
style,
|
|
43
|
-
className,
|
|
44
|
-
activeStyle
|
|
45
|
-
}) {
|
|
46
|
-
const styleClassName = (0, import_utils.replaceActiveStyle)(className, activeStyle, style);
|
|
47
|
-
const previewBlocks = (0, import_element.useMemo)(() => {
|
|
48
|
-
return {
|
|
49
|
-
name: genericPreviewBlock.name,
|
|
50
|
-
title: style.label || style.name,
|
|
51
|
-
description: style.description,
|
|
52
|
-
initialAttributes: {
|
|
53
|
-
...genericPreviewBlock.attributes,
|
|
54
|
-
className: styleClassName + " block-editor-block-styles__block-preview-container"
|
|
55
|
-
},
|
|
56
|
-
example: genericPreviewBlock
|
|
57
|
-
};
|
|
58
|
-
}, [genericPreviewBlock, style, styleClassName]);
|
|
59
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_preview_panel.default, { item: previewBlocks });
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=preview-panel.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/block-styles/preview-panel.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport InserterPreviewPanel from '../inserter/preview-panel';\nimport { replaceActiveStyle } from './utils';\n\nexport default function BlockStylesPreviewPanel( {\n\tgenericPreviewBlock,\n\tstyle,\n\tclassName,\n\tactiveStyle,\n} ) {\n\tconst styleClassName = replaceActiveStyle( className, activeStyle, style );\n\tconst previewBlocks = useMemo( () => {\n\t\treturn {\n\t\t\tname: genericPreviewBlock.name,\n\t\t\ttitle: style.label || style.name,\n\t\t\tdescription: style.description,\n\t\t\tinitialAttributes: {\n\t\t\t\t...genericPreviewBlock.attributes,\n\t\t\t\tclassName:\n\t\t\t\t\tstyleClassName +\n\t\t\t\t\t' block-editor-block-styles__block-preview-container',\n\t\t\t},\n\t\t\texample: genericPreviewBlock,\n\t\t};\n\t}, [ genericPreviewBlock, style, styleClassName ] );\n\n\treturn <InserterPreviewPanel item={ previewBlocks } />;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAwB;AAKxB,2BAAiC;AACjC,mBAAmC;AAwB3B;AAtBO,SAAR,wBAA0C;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,qBAAiB,iCAAoB,WAAW,aAAa,KAAM;AACzE,QAAM,oBAAgB,wBAAS,MAAM;AACpC,WAAO;AAAA,MACN,MAAM,oBAAoB;AAAA,MAC1B,OAAO,MAAM,SAAS,MAAM;AAAA,MAC5B,aAAa,MAAM;AAAA,MACnB,mBAAmB;AAAA,QAClB,GAAG,oBAAoB;AAAA,QACvB,WACC,iBACA;AAAA,MACF;AAAA,MACA,SAAS;AAAA,IACV;AAAA,EACD,GAAG,CAAE,qBAAqB,OAAO,cAAe,CAAE;AAElD,SAAO,4CAAC,qBAAAA,SAAA,EAAqB,MAAO,eAAgB;AACrD;",
|
|
6
|
-
"names": ["InserterPreviewPanel"]
|
|
7
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// packages/block-editor/src/components/block-styles/preview-panel.js
|
|
2
|
-
import { useMemo } from "@wordpress/element";
|
|
3
|
-
import InserterPreviewPanel from "../inserter/preview-panel.mjs";
|
|
4
|
-
import { replaceActiveStyle } from "./utils.mjs";
|
|
5
|
-
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
function BlockStylesPreviewPanel({
|
|
7
|
-
genericPreviewBlock,
|
|
8
|
-
style,
|
|
9
|
-
className,
|
|
10
|
-
activeStyle
|
|
11
|
-
}) {
|
|
12
|
-
const styleClassName = replaceActiveStyle(className, activeStyle, style);
|
|
13
|
-
const previewBlocks = useMemo(() => {
|
|
14
|
-
return {
|
|
15
|
-
name: genericPreviewBlock.name,
|
|
16
|
-
title: style.label || style.name,
|
|
17
|
-
description: style.description,
|
|
18
|
-
initialAttributes: {
|
|
19
|
-
...genericPreviewBlock.attributes,
|
|
20
|
-
className: styleClassName + " block-editor-block-styles__block-preview-container"
|
|
21
|
-
},
|
|
22
|
-
example: genericPreviewBlock
|
|
23
|
-
};
|
|
24
|
-
}, [genericPreviewBlock, style, styleClassName]);
|
|
25
|
-
return /* @__PURE__ */ jsx(InserterPreviewPanel, { item: previewBlocks });
|
|
26
|
-
}
|
|
27
|
-
export {
|
|
28
|
-
BlockStylesPreviewPanel as default
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=preview-panel.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/block-styles/preview-panel.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport InserterPreviewPanel from '../inserter/preview-panel';\nimport { replaceActiveStyle } from './utils';\n\nexport default function BlockStylesPreviewPanel( {\n\tgenericPreviewBlock,\n\tstyle,\n\tclassName,\n\tactiveStyle,\n} ) {\n\tconst styleClassName = replaceActiveStyle( className, activeStyle, style );\n\tconst previewBlocks = useMemo( () => {\n\t\treturn {\n\t\t\tname: genericPreviewBlock.name,\n\t\t\ttitle: style.label || style.name,\n\t\t\tdescription: style.description,\n\t\t\tinitialAttributes: {\n\t\t\t\t...genericPreviewBlock.attributes,\n\t\t\t\tclassName:\n\t\t\t\t\tstyleClassName +\n\t\t\t\t\t' block-editor-block-styles__block-preview-container',\n\t\t\t},\n\t\t\texample: genericPreviewBlock,\n\t\t};\n\t}, [ genericPreviewBlock, style, styleClassName ] );\n\n\treturn <InserterPreviewPanel item={ previewBlocks } />;\n}\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,eAAe;AAKxB,OAAO,0BAA0B;AACjC,SAAS,0BAA0B;AAwB3B;AAtBO,SAAR,wBAA0C;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,iBAAiB,mBAAoB,WAAW,aAAa,KAAM;AACzE,QAAM,gBAAgB,QAAS,MAAM;AACpC,WAAO;AAAA,MACN,MAAM,oBAAoB;AAAA,MAC1B,OAAO,MAAM,SAAS,MAAM;AAAA,MAC5B,aAAa,MAAM;AAAA,MACnB,mBAAmB;AAAA,QAClB,GAAG,oBAAoB;AAAA,QACvB,WACC,iBACA;AAAA,MACF;AAAA,MACA,SAAS;AAAA,IACV;AAAA,EACD,GAAG,CAAE,qBAAqB,OAAO,cAAe,CAAE;AAElD,SAAO,oBAAC,wBAAqB,MAAO,eAAgB;AACrD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useMemo } from '@wordpress/element';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import InserterPreviewPanel from '../inserter/preview-panel';
|
|
10
|
-
import { replaceActiveStyle } from './utils';
|
|
11
|
-
|
|
12
|
-
export default function BlockStylesPreviewPanel( {
|
|
13
|
-
genericPreviewBlock,
|
|
14
|
-
style,
|
|
15
|
-
className,
|
|
16
|
-
activeStyle,
|
|
17
|
-
} ) {
|
|
18
|
-
const styleClassName = replaceActiveStyle( className, activeStyle, style );
|
|
19
|
-
const previewBlocks = useMemo( () => {
|
|
20
|
-
return {
|
|
21
|
-
name: genericPreviewBlock.name,
|
|
22
|
-
title: style.label || style.name,
|
|
23
|
-
description: style.description,
|
|
24
|
-
initialAttributes: {
|
|
25
|
-
...genericPreviewBlock.attributes,
|
|
26
|
-
className:
|
|
27
|
-
styleClassName +
|
|
28
|
-
' block-editor-block-styles__block-preview-container',
|
|
29
|
-
},
|
|
30
|
-
example: genericPreviewBlock,
|
|
31
|
-
};
|
|
32
|
-
}, [ genericPreviewBlock, style, styleClassName ] );
|
|
33
|
-
|
|
34
|
-
return <InserterPreviewPanel item={ previewBlocks } />;
|
|
35
|
-
}
|