@wordpress/block-editor 13.0.2 → 13.0.4
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/components/block-toolbar/shuffle.js +3 -1
- package/build/components/block-toolbar/shuffle.js.map +1 -1
- package/build/components/global-styles/background-panel.js +2 -1
- package/build/components/global-styles/background-panel.js.map +1 -1
- package/build/components/global-styles/border-panel.js +2 -1
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +2 -1
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +2 -1
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +2 -1
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/image-settings-panel.js +2 -1
- package/build/components/global-styles/image-settings-panel.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +2 -1
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +4 -3
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +17 -7
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js +0 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js +2 -1
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/hooks/block-style-variation.js +112 -5
- package/build/hooks/block-style-variation.js.map +1 -1
- package/build/hooks/duotone.js +16 -11
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/index.js +7 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +11 -6
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/hooks/utils.js +2 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +2 -1
- package/build/private-apis.js.map +1 -1
- package/build-module/components/block-toolbar/shuffle.js +3 -1
- package/build-module/components/block-toolbar/shuffle.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +3 -2
- package/build-module/components/global-styles/background-panel.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +3 -2
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +3 -2
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +3 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +3 -2
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/image-settings-panel.js +3 -2
- package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +3 -2
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +4 -3
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +15 -6
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js +0 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js +3 -2
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/hooks/block-style-variation.js +112 -5
- package/build-module/hooks/block-style-variation.js.map +1 -1
- package/build-module/hooks/duotone.js +16 -11
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +11 -6
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/hooks/utils.js +2 -0
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +3 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-style/content-rtl.css +1 -0
- package/build-style/content.css +1 -0
- package/package.json +7 -7
- package/src/components/block-toolbar/shuffle.js +3 -1
- package/src/components/global-styles/background-panel.js +3 -2
- package/src/components/global-styles/border-panel.js +3 -2
- package/src/components/global-styles/color-panel.js +3 -2
- package/src/components/global-styles/dimensions-panel.js +3 -2
- package/src/components/global-styles/filters-panel.js +3 -2
- package/src/components/global-styles/image-settings-panel.js +3 -2
- package/src/components/global-styles/test/use-global-styles-output.js +38 -3
- package/src/components/global-styles/typography-panel.js +3 -2
- package/src/components/global-styles/use-global-styles-output.js +4 -3
- package/src/components/global-styles/utils.js +17 -6
- package/src/components/iframe/content.scss +1 -0
- package/src/components/image-editor/aspect-ratio-dropdown.js +0 -1
- package/src/components/inspector-controls/block-support-tools-panel.js +3 -3
- package/src/hooks/block-style-variation.js +127 -4
- package/src/hooks/duotone.js +16 -12
- package/src/hooks/index.js +1 -0
- package/src/hooks/use-bindings-attributes.js +13 -4
- package/src/hooks/utils.js +2 -0
- package/src/private-apis.js +6 -1
|
@@ -21,7 +21,7 @@ import TextAlignmentControl from '../text-alignment-control';
|
|
|
21
21
|
import TextTransformControl from '../text-transform-control';
|
|
22
22
|
import TextDecorationControl from '../text-decoration-control';
|
|
23
23
|
import WritingModeControl from '../writing-mode-control';
|
|
24
|
-
import { getValueFromVariable,
|
|
24
|
+
import { getValueFromVariable, useToolsPanelDropdownMenuProps } from './utils';
|
|
25
25
|
import { setImmutably } from '../../utils/object';
|
|
26
26
|
|
|
27
27
|
const MIN_TEXT_COLUMNS = 1;
|
|
@@ -135,6 +135,7 @@ function TypographyToolsPanel( {
|
|
|
135
135
|
panelId,
|
|
136
136
|
children,
|
|
137
137
|
} ) {
|
|
138
|
+
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
|
|
138
139
|
const resetAll = () => {
|
|
139
140
|
const updatedValue = resetAllFilter( value );
|
|
140
141
|
onChange( updatedValue );
|
|
@@ -145,7 +146,7 @@ function TypographyToolsPanel( {
|
|
|
145
146
|
label={ __( 'Typography' ) }
|
|
146
147
|
resetAll={ resetAll }
|
|
147
148
|
panelId={ panelId }
|
|
148
|
-
dropdownMenuProps={
|
|
149
|
+
dropdownMenuProps={ dropdownMenuProps }
|
|
149
150
|
>
|
|
150
151
|
{ children }
|
|
151
152
|
</ToolsPanel>
|
|
@@ -881,6 +881,7 @@ export const toStyles = (
|
|
|
881
881
|
marginReset: true,
|
|
882
882
|
presets: true,
|
|
883
883
|
rootPadding: true,
|
|
884
|
+
variationStyles: false,
|
|
884
885
|
...styleOptions,
|
|
885
886
|
};
|
|
886
887
|
const nodesWithStyles = getNodesWithStyles( tree, blockSelectors );
|
|
@@ -923,8 +924,8 @@ export const toStyles = (
|
|
|
923
924
|
ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) }
|
|
924
925
|
.has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
|
|
925
926
|
.has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }
|
|
926
|
-
.has-global-padding :where(.has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) { padding-right: 0; padding-left: 0; }
|
|
927
|
-
.has-global-padding :where(.has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) > .alignfull { margin-left: 0; margin-right: 0;
|
|
927
|
+
.has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) { padding-right: 0; padding-left: 0; }
|
|
928
|
+
.has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) > .alignfull { margin-left: 0; margin-right: 0;
|
|
928
929
|
`;
|
|
929
930
|
}
|
|
930
931
|
|
|
@@ -1010,7 +1011,7 @@ export const toStyles = (
|
|
|
1010
1011
|
);
|
|
1011
1012
|
}
|
|
1012
1013
|
|
|
1013
|
-
if ( styleVariationSelectors ) {
|
|
1014
|
+
if ( options.variationStyles && styleVariationSelectors ) {
|
|
1014
1015
|
Object.entries( styleVariationSelectors ).forEach(
|
|
1015
1016
|
( [ styleVariationName, styleVariationSelector ] ) => {
|
|
1016
1017
|
const styleVariations =
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import fastDeepEqual from 'fast-deep-equal/es6';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useViewportMatch } from '@wordpress/compose';
|
|
10
|
+
|
|
6
11
|
/**
|
|
7
12
|
* Internal dependencies
|
|
8
13
|
*/
|
|
@@ -136,12 +141,18 @@ export const STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {
|
|
|
136
141
|
'typography.fontFamily': 'fontFamily',
|
|
137
142
|
};
|
|
138
143
|
|
|
139
|
-
export
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
144
|
+
export function useToolsPanelDropdownMenuProps() {
|
|
145
|
+
const isMobile = useViewportMatch( 'medium', '<' );
|
|
146
|
+
return ! isMobile
|
|
147
|
+
? {
|
|
148
|
+
popoverProps: {
|
|
149
|
+
placement: 'left-start',
|
|
150
|
+
// For non-mobile, inner sidebar width (248px) - button width (24px) - border (1px) + padding (16px) + spacing (20px)
|
|
151
|
+
offset: 259,
|
|
152
|
+
},
|
|
153
|
+
}
|
|
154
|
+
: {};
|
|
155
|
+
}
|
|
145
156
|
|
|
146
157
|
function findInPresetsBy(
|
|
147
158
|
features,
|
|
@@ -10,7 +10,7 @@ import { useCallback } from '@wordpress/element';
|
|
|
10
10
|
*/
|
|
11
11
|
import { store as blockEditorStore } from '../../store';
|
|
12
12
|
import { cleanEmptyObject } from '../../hooks/utils';
|
|
13
|
-
import {
|
|
13
|
+
import { useToolsPanelDropdownMenuProps } from '../global-styles/utils';
|
|
14
14
|
|
|
15
15
|
export default function BlockSupportToolsPanel( { children, group, label } ) {
|
|
16
16
|
const { updateBlockAttributes } = useDispatch( blockEditorStore );
|
|
@@ -20,7 +20,7 @@ export default function BlockSupportToolsPanel( { children, group, label } ) {
|
|
|
20
20
|
getSelectedBlockClientId,
|
|
21
21
|
hasMultiSelection,
|
|
22
22
|
} = useSelect( blockEditorStore );
|
|
23
|
-
|
|
23
|
+
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
|
|
24
24
|
const panelId = getSelectedBlockClientId();
|
|
25
25
|
const resetAll = useCallback(
|
|
26
26
|
( resetFilters = [] ) => {
|
|
@@ -72,7 +72,7 @@ export default function BlockSupportToolsPanel( { children, group, label } ) {
|
|
|
72
72
|
shouldRenderPlaceholderItems // Required to maintain fills ordering.
|
|
73
73
|
__experimentalFirstVisibleItemClass="first"
|
|
74
74
|
__experimentalLastVisibleItemClass="last"
|
|
75
|
-
dropdownMenuProps={
|
|
75
|
+
dropdownMenuProps={ dropdownMenuProps }
|
|
76
76
|
>
|
|
77
77
|
{ children }
|
|
78
78
|
</ToolsPanel>
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
import { useStyleOverride } from './utils';
|
|
17
17
|
import { store as blockEditorStore } from '../store';
|
|
18
18
|
import { globalStylesDataKey } from '../store/private-keys';
|
|
19
|
+
import { unlock } from '../lock-unlock';
|
|
19
20
|
|
|
20
21
|
const VARIATION_PREFIX = 'is-style-';
|
|
21
22
|
|
|
@@ -59,7 +60,127 @@ function getVariationNameFromClass( className, registeredStyles = [] ) {
|
|
|
59
60
|
return null;
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
|
|
63
|
+
// A helper component to apply a style override using the useStyleOverride hook.
|
|
64
|
+
function OverrideStyles( { override } ) {
|
|
65
|
+
useStyleOverride( override );
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* This component is used to generate new block style variation overrides
|
|
70
|
+
* based on an incoming theme config. If a matching style is found in the config,
|
|
71
|
+
* a new override is created and returned. The overrides can be used in conjunction with
|
|
72
|
+
* useStyleOverride to apply the new styles to the editor. Its use is
|
|
73
|
+
* subject to change.
|
|
74
|
+
*
|
|
75
|
+
* @param {Object} props Props.
|
|
76
|
+
* @param {Object} props.config A global styles object, containing settings and styles.
|
|
77
|
+
* @return {JSX.Element|undefined} An array of new block variation overrides.
|
|
78
|
+
*/
|
|
79
|
+
export function __unstableBlockStyleVariationOverridesWithConfig( { config } ) {
|
|
80
|
+
const { getBlockStyles, overrides } = useSelect(
|
|
81
|
+
( select ) => ( {
|
|
82
|
+
getBlockStyles: select( blocksStore ).getBlockStyles,
|
|
83
|
+
overrides: unlock( select( blockEditorStore ) ).getStyleOverrides(),
|
|
84
|
+
} ),
|
|
85
|
+
[]
|
|
86
|
+
);
|
|
87
|
+
const { getBlockName } = useSelect( blockEditorStore );
|
|
88
|
+
|
|
89
|
+
const overridesWithConfig = useMemo( () => {
|
|
90
|
+
if ( ! overrides?.length ) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const newOverrides = [];
|
|
94
|
+
const overriddenClientIds = [];
|
|
95
|
+
for ( const [ , override ] of overrides ) {
|
|
96
|
+
if (
|
|
97
|
+
override?.variation &&
|
|
98
|
+
override?.clientId &&
|
|
99
|
+
/*
|
|
100
|
+
* Because this component overwrites existing style overrides,
|
|
101
|
+
* filter out any overrides that are already present in the store.
|
|
102
|
+
*/
|
|
103
|
+
! overriddenClientIds.includes( override.clientId )
|
|
104
|
+
) {
|
|
105
|
+
const blockName = getBlockName( override.clientId );
|
|
106
|
+
const configStyles =
|
|
107
|
+
config?.styles?.blocks?.[ blockName ]?.variations?.[
|
|
108
|
+
override.variation
|
|
109
|
+
];
|
|
110
|
+
if ( configStyles ) {
|
|
111
|
+
const variationConfig = {
|
|
112
|
+
settings: config?.settings,
|
|
113
|
+
// The variation style data is all that is needed to generate
|
|
114
|
+
// the styles for the current application to a block. The variation
|
|
115
|
+
// name is updated to match the instance specific class name.
|
|
116
|
+
styles: {
|
|
117
|
+
blocks: {
|
|
118
|
+
[ blockName ]: {
|
|
119
|
+
variations: {
|
|
120
|
+
[ `${ override.variation }-${ override.clientId }` ]:
|
|
121
|
+
configStyles,
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
const blockSelectors = getBlockSelectors(
|
|
128
|
+
getBlockTypes(),
|
|
129
|
+
getBlockStyles,
|
|
130
|
+
override.clientId
|
|
131
|
+
);
|
|
132
|
+
const hasBlockGapSupport = false;
|
|
133
|
+
const hasFallbackGapSupport = true;
|
|
134
|
+
const disableLayoutStyles = true;
|
|
135
|
+
const disableRootPadding = true;
|
|
136
|
+
const variationStyles = toStyles(
|
|
137
|
+
variationConfig,
|
|
138
|
+
blockSelectors,
|
|
139
|
+
hasBlockGapSupport,
|
|
140
|
+
hasFallbackGapSupport,
|
|
141
|
+
disableLayoutStyles,
|
|
142
|
+
disableRootPadding,
|
|
143
|
+
{
|
|
144
|
+
blockGap: false,
|
|
145
|
+
blockStyles: true,
|
|
146
|
+
layoutStyles: false,
|
|
147
|
+
marginReset: false,
|
|
148
|
+
presets: false,
|
|
149
|
+
rootPadding: false,
|
|
150
|
+
variationStyles: true,
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
newOverrides.push( {
|
|
154
|
+
id: `${ override.variation }-${ override.clientId }`,
|
|
155
|
+
css: variationStyles,
|
|
156
|
+
__unstableType: 'variation',
|
|
157
|
+
variation: override.variation,
|
|
158
|
+
// The clientId will be stored with the override and used to ensure
|
|
159
|
+
// the order of overrides matches the order of blocks so that the
|
|
160
|
+
// correct CSS cascade is maintained.
|
|
161
|
+
clientId: override.clientId,
|
|
162
|
+
} );
|
|
163
|
+
overriddenClientIds.push( override.clientId );
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return newOverrides;
|
|
168
|
+
}, [ config, overrides, getBlockStyles, getBlockName ] );
|
|
169
|
+
|
|
170
|
+
if ( ! overridesWithConfig || ! overridesWithConfig.length ) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return (
|
|
175
|
+
<>
|
|
176
|
+
{ overridesWithConfig.map( ( override ) => (
|
|
177
|
+
<OverrideStyles key={ override.id } override={ override } />
|
|
178
|
+
) ) }
|
|
179
|
+
</>
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function useBlockStyleVariation( name, variation, clientId ) {
|
|
63
184
|
// Prefer global styles data in GlobalStylesContext, which are available
|
|
64
185
|
// if in the site editor. Otherwise fall back to whatever is in the
|
|
65
186
|
// editor settings and available in the post editor.
|
|
@@ -112,7 +233,7 @@ function useBlockProps( { name, className, clientId } ) {
|
|
|
112
233
|
const variation = getVariationNameFromClass( className, registeredStyles );
|
|
113
234
|
const variationClass = `${ VARIATION_PREFIX }${ variation }-${ clientId }`;
|
|
114
235
|
|
|
115
|
-
const { settings, styles } =
|
|
236
|
+
const { settings, styles } = useBlockStyleVariation(
|
|
116
237
|
name,
|
|
117
238
|
variation,
|
|
118
239
|
clientId
|
|
@@ -132,7 +253,7 @@ function useBlockProps( { name, className, clientId } ) {
|
|
|
132
253
|
const hasBlockGapSupport = false;
|
|
133
254
|
const hasFallbackGapSupport = true;
|
|
134
255
|
const disableLayoutStyles = true;
|
|
135
|
-
const
|
|
256
|
+
const disableRootPadding = true;
|
|
136
257
|
|
|
137
258
|
return toStyles(
|
|
138
259
|
variationConfig,
|
|
@@ -140,7 +261,7 @@ function useBlockProps( { name, className, clientId } ) {
|
|
|
140
261
|
hasBlockGapSupport,
|
|
141
262
|
hasFallbackGapSupport,
|
|
142
263
|
disableLayoutStyles,
|
|
143
|
-
|
|
264
|
+
disableRootPadding,
|
|
144
265
|
{
|
|
145
266
|
blockGap: false,
|
|
146
267
|
blockStyles: true,
|
|
@@ -148,6 +269,7 @@ function useBlockProps( { name, className, clientId } ) {
|
|
|
148
269
|
marginReset: false,
|
|
149
270
|
presets: false,
|
|
150
271
|
rootPadding: false,
|
|
272
|
+
variationStyles: true,
|
|
151
273
|
}
|
|
152
274
|
);
|
|
153
275
|
}, [ variation, settings, styles, getBlockStyles, clientId ] );
|
|
@@ -156,6 +278,7 @@ function useBlockProps( { name, className, clientId } ) {
|
|
|
156
278
|
id: `variation-${ clientId }`,
|
|
157
279
|
css: variationStyles,
|
|
158
280
|
__unstableType: 'variation',
|
|
281
|
+
variation,
|
|
159
282
|
// The clientId will be stored with the override and used to ensure
|
|
160
283
|
// the order of overrides matches the order of blocks so that the
|
|
161
284
|
// correct CSS cascade is maintained.
|
package/src/hooks/duotone.js
CHANGED
|
@@ -295,26 +295,30 @@ function useDuotoneStyles( {
|
|
|
295
295
|
return;
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
-
// Safari does not always update the duotone filter when the duotone
|
|
299
|
-
// are changed. When using Safari, force the block element to be
|
|
300
|
-
// the browser to ensure any changes are reflected
|
|
301
|
-
// that used on the site frontend in
|
|
298
|
+
// Safari does not always update the duotone filter when the duotone
|
|
299
|
+
// colors are changed. When using Safari, force the block element to be
|
|
300
|
+
// repainted by the browser to ensure any changes are reflected
|
|
301
|
+
// visually. This logic matches that used on the site frontend in
|
|
302
|
+
// `block-supports/duotone.php`.
|
|
302
303
|
if ( blockElement && isSafari ) {
|
|
303
304
|
const display = blockElement.style.display;
|
|
304
|
-
// Switch to `inline-block` to force a repaint. In the editor,
|
|
305
|
-
// is used instead of `none` to ensure that scroll
|
|
306
|
-
// as `none` results in the editor
|
|
305
|
+
// Switch to `inline-block` to force a repaint. In the editor,
|
|
306
|
+
// `inline-block` is used instead of `none` to ensure that scroll
|
|
307
|
+
// position is not affected, as `none` results in the editor
|
|
308
|
+
// scrolling to the top of the block.
|
|
307
309
|
blockElement.style.display = 'inline-block';
|
|
308
|
-
// Simply accessing el.offsetHeight flushes layout and style
|
|
309
|
-
//
|
|
310
|
+
// Simply accessing el.offsetHeight flushes layout and style changes
|
|
311
|
+
// in WebKit without having to wait for setTimeout.
|
|
310
312
|
// eslint-disable-next-line no-unused-expressions
|
|
311
313
|
blockElement.offsetHeight;
|
|
312
314
|
blockElement.style.display = display;
|
|
313
315
|
}
|
|
314
|
-
|
|
316
|
+
// `colors` must be a dependency so this effect runs when the colors
|
|
317
|
+
// change in Safari.
|
|
318
|
+
}, [ isValidFilter, blockElement, colors ] );
|
|
315
319
|
}
|
|
316
320
|
|
|
317
|
-
function useBlockProps( { name, style } ) {
|
|
321
|
+
function useBlockProps( { clientId, name, style } ) {
|
|
318
322
|
const id = useInstanceId( useBlockProps );
|
|
319
323
|
const selector = useMemo( () => {
|
|
320
324
|
const blockType = getBlockType( name );
|
|
@@ -362,7 +366,7 @@ function useBlockProps( { name, style } ) {
|
|
|
362
366
|
const shouldRender = selector && attribute;
|
|
363
367
|
|
|
364
368
|
useDuotoneStyles( {
|
|
365
|
-
clientId
|
|
369
|
+
clientId,
|
|
366
370
|
id: filterClass,
|
|
367
371
|
selector,
|
|
368
372
|
attribute,
|
package/src/hooks/index.js
CHANGED
|
@@ -88,3 +88,4 @@ export { getTypographyClassesAndStyles } from './use-typography-props';
|
|
|
88
88
|
export { getGapCSSValue } from './gap';
|
|
89
89
|
export { useCachedTruthy } from './use-cached-truthy';
|
|
90
90
|
export { useZoomOut } from './use-zoom-out';
|
|
91
|
+
export { __unstableBlockStyleVariationOverridesWithConfig } from './block-style-variation';
|
|
@@ -97,6 +97,7 @@ export const withBlockBindingSupport = createHigherOrderComponent(
|
|
|
97
97
|
unlock( select( blocksStore ) ).getAllBlockBindingsSources()
|
|
98
98
|
);
|
|
99
99
|
const { name, clientId, context } = props;
|
|
100
|
+
const hasParentPattern = !! props.context[ 'pattern/overrides' ];
|
|
100
101
|
const hasPatternOverridesDefaultBinding =
|
|
101
102
|
props.attributes.metadata?.bindings?.[ DEFAULT_ATTRIBUTE ]
|
|
102
103
|
?.source === 'core/pattern-overrides';
|
|
@@ -216,13 +217,20 @@ export const withBlockBindingSupport = createHigherOrderComponent(
|
|
|
216
217
|
}
|
|
217
218
|
}
|
|
218
219
|
|
|
219
|
-
// Only apply normal attribute updates to blocks
|
|
220
|
-
// that have partial bindings. Currently this is
|
|
221
|
-
// only skipped for pattern overrides sources.
|
|
222
220
|
if (
|
|
223
|
-
|
|
221
|
+
// Don't update non-connected attributes if the block is using pattern overrides
|
|
222
|
+
// and the editing is happening while overriding the pattern (not editing the original).
|
|
223
|
+
! (
|
|
224
|
+
hasPatternOverridesDefaultBinding &&
|
|
225
|
+
hasParentPattern
|
|
226
|
+
) &&
|
|
224
227
|
Object.keys( keptAttributes ).length
|
|
225
228
|
) {
|
|
229
|
+
// Don't update caption and href until they are supported.
|
|
230
|
+
if ( hasPatternOverridesDefaultBinding ) {
|
|
231
|
+
delete keptAttributes?.caption;
|
|
232
|
+
delete keptAttributes?.href;
|
|
233
|
+
}
|
|
226
234
|
setAttributes( keptAttributes );
|
|
227
235
|
}
|
|
228
236
|
} );
|
|
@@ -236,6 +244,7 @@ export const withBlockBindingSupport = createHigherOrderComponent(
|
|
|
236
244
|
setAttributes,
|
|
237
245
|
sources,
|
|
238
246
|
hasPatternOverridesDefaultBinding,
|
|
247
|
+
hasParentPattern,
|
|
239
248
|
]
|
|
240
249
|
);
|
|
241
250
|
|
package/src/hooks/utils.js
CHANGED
|
@@ -140,6 +140,7 @@ export function useStyleOverride( {
|
|
|
140
140
|
css,
|
|
141
141
|
assets,
|
|
142
142
|
__unstableType,
|
|
143
|
+
variation,
|
|
143
144
|
clientId,
|
|
144
145
|
} = {} ) {
|
|
145
146
|
const { setStyleOverride, deleteStyleOverride } = unlock(
|
|
@@ -159,6 +160,7 @@ export function useStyleOverride( {
|
|
|
159
160
|
css,
|
|
160
161
|
assets,
|
|
161
162
|
__unstableType,
|
|
163
|
+
variation,
|
|
162
164
|
clientId,
|
|
163
165
|
};
|
|
164
166
|
// Batch updates to style overrides to avoid triggering cascading renders
|
package/src/private-apis.js
CHANGED
|
@@ -20,7 +20,11 @@ import { cleanEmptyObject, useStyleOverride } from './hooks/utils';
|
|
|
20
20
|
import BlockQuickNavigation from './components/block-quick-navigation';
|
|
21
21
|
import { LayoutStyle } from './components/block-list/layout';
|
|
22
22
|
import { BlockRemovalWarningModal } from './components/block-removal-warning-modal';
|
|
23
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
useLayoutClasses,
|
|
25
|
+
useLayoutStyles,
|
|
26
|
+
__unstableBlockStyleVariationOverridesWithConfig,
|
|
27
|
+
} from './hooks';
|
|
24
28
|
import DimensionsTool from './components/dimensions-tool';
|
|
25
29
|
import ResolutionTool from './components/resolution-tool';
|
|
26
30
|
import TextAlignmentControl from './components/text-alignment-control';
|
|
@@ -88,4 +92,5 @@ lock( privateApis, {
|
|
|
88
92
|
PrivatePublishDateTimePicker,
|
|
89
93
|
useSpacingSizes,
|
|
90
94
|
useBlockDisplayTitle,
|
|
95
|
+
__unstableBlockStyleVariationOverridesWithConfig,
|
|
91
96
|
} );
|