@wordpress/block-editor 13.0.4 → 13.0.6

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.
Files changed (33) hide show
  1. package/build/components/block-list/use-block-props/use-block-refs.js +9 -2
  2. package/build/components/block-list/use-block-props/use-block-refs.js.map +1 -1
  3. package/build/components/block-toolbar/shuffle.js +1 -1
  4. package/build/components/block-toolbar/shuffle.js.map +1 -1
  5. package/build/components/global-styles/hooks.js +5 -1
  6. package/build/components/global-styles/hooks.js.map +1 -1
  7. package/build/components/global-styles/use-global-styles-output.js +28 -12
  8. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  9. package/build/hooks/block-style-variation.js +63 -4
  10. package/build/hooks/block-style-variation.js.map +1 -1
  11. package/build/layouts/constrained.js +6 -2
  12. package/build/layouts/constrained.js.map +1 -1
  13. package/build-module/components/block-list/use-block-props/use-block-refs.js +11 -4
  14. package/build-module/components/block-list/use-block-props/use-block-refs.js.map +1 -1
  15. package/build-module/components/block-toolbar/shuffle.js +1 -1
  16. package/build-module/components/block-toolbar/shuffle.js.map +1 -1
  17. package/build-module/components/global-styles/hooks.js +5 -1
  18. package/build-module/components/global-styles/hooks.js.map +1 -1
  19. package/build-module/components/global-styles/use-global-styles-output.js +28 -12
  20. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  21. package/build-module/hooks/block-style-variation.js +62 -4
  22. package/build-module/hooks/block-style-variation.js.map +1 -1
  23. package/build-module/layouts/constrained.js +6 -2
  24. package/build-module/layouts/constrained.js.map +1 -1
  25. package/package.json +2 -2
  26. package/src/components/block-list/use-block-props/use-block-refs.js +19 -3
  27. package/src/components/block-toolbar/shuffle.js +2 -1
  28. package/src/components/global-styles/hooks.js +5 -1
  29. package/src/components/global-styles/test/use-global-styles-output.js +2 -1
  30. package/src/components/global-styles/use-global-styles-output.js +27 -10
  31. package/src/hooks/block-style-variation.js +80 -3
  32. package/src/hooks/test/get-variation-styles-with-ref-values.js +91 -0
  33. package/src/layouts/constrained.js +10 -2
@@ -181,15 +181,19 @@ export default {
181
181
  const paddingValues = getCSSRules(style);
182
182
  paddingValues.forEach(rule => {
183
183
  if (rule.key === 'paddingRight') {
184
+ // Add unit if 0, to avoid calc(0 * -1) which is invalid.
185
+ const paddingRightValue = rule.value === '0' ? '0px' : rule.value;
184
186
  output += `
185
187
  ${appendSelectors(selector, '> .alignfull')} {
186
- margin-right: calc(${rule.value} * -1);
188
+ margin-right: calc(${paddingRightValue} * -1);
187
189
  }
188
190
  `;
189
191
  } else if (rule.key === 'paddingLeft') {
192
+ // Add unit if 0, to avoid calc(0 * -1) which is invalid.
193
+ const paddingLeftValue = rule.value === '0' ? '0px' : rule.value;
190
194
  output += `
191
195
  ${appendSelectors(selector, '> .alignfull')} {
192
- margin-left: calc(${rule.value} * -1);
196
+ margin-left: calc(${paddingLeftValue} * -1);
193
197
  }
194
198
  `;
195
199
  }
@@ -1 +1 @@
1
- {"version":3,"names":["__experimentalUseCustomUnits","useCustomUnits","__experimentalUnitControl","UnitControl","__experimentalToggleGroupControl","ToggleGroupControl","__experimentalToggleGroupControlOptionIcon","ToggleGroupControlOptionIcon","__","Icon","positionCenter","stretchWide","justifyLeft","justifyCenter","justifyRight","getCSSRules","useSettings","appendSelectors","getBlockGapCSS","getAlignmentsInfo","getGapCSSValue","shouldSkipSerialization","LAYOUT_DEFINITIONS","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","name","label","inspectorControls","DefaultLayoutInspectorControls","layout","onChange","layoutBlockSupport","wideSize","contentSize","justifyContent","allowJustification","allowCustomContentAndWideSize","onJustificationChange","value","justificationOptions","icon","availableUnits","units","children","className","labelPosition","__unstableInputWidth","nextWidth","parseFloat","__nextHasNoMarginBottom","map","toolBarControls","DefaultLayoutToolbarControls","getLayoutStyle","selector","style","blockName","hasBlockGapSupport","layoutDefinitions","blockGapStyleValue","spacing","blockGap","blockGapValue","top","marginLeft","marginRight","output","padding","paddingValues","forEach","rule","key","getOrientation","getAlignments","alignmentInfo","alignments","undefined","includes","unshift","alignment","info","wide","none"],"sources":["@wordpress/block-editor/src/layouts/constrained.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tIcon,\n\tpositionCenter,\n\tstretchWide,\n\tjustifyLeft,\n\tjustifyCenter,\n\tjustifyRight,\n} from '@wordpress/icons';\nimport { getCSSRules } from '@wordpress/style-engine';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../components/use-settings';\nimport { appendSelectors, getBlockGapCSS, getAlignmentsInfo } from './utils';\nimport { getGapCSSValue } from '../hooks/gap';\nimport { shouldSkipSerialization } from '../hooks/utils';\nimport { LAYOUT_DEFINITIONS } from './definitions';\n\nexport default {\n\tname: 'constrained',\n\tlabel: __( 'Constrained' ),\n\tinspectorControls: function DefaultLayoutInspectorControls( {\n\t\tlayout,\n\t\tonChange,\n\t\tlayoutBlockSupport = {},\n\t} ) {\n\t\tconst { wideSize, contentSize, justifyContent = 'center' } = layout;\n\t\tconst {\n\t\t\tallowJustification = true,\n\t\t\tallowCustomContentAndWideSize = true,\n\t\t} = layoutBlockSupport;\n\t\tconst onJustificationChange = ( value ) => {\n\t\t\tonChange( {\n\t\t\t\t...layout,\n\t\t\t\tjustifyContent: value,\n\t\t\t} );\n\t\t};\n\t\tconst justificationOptions = [\n\t\t\t{\n\t\t\t\tvalue: 'left',\n\t\t\t\ticon: justifyLeft,\n\t\t\t\tlabel: __( 'Justify items left' ),\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: 'center',\n\t\t\t\ticon: justifyCenter,\n\t\t\t\tlabel: __( 'Justify items center' ),\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: 'right',\n\t\t\t\ticon: justifyRight,\n\t\t\t\tlabel: __( 'Justify items right' ),\n\t\t\t},\n\t\t];\n\t\tconst [ availableUnits ] = useSettings( 'spacing.units' );\n\t\tconst units = useCustomUnits( {\n\t\t\tavailableUnits: availableUnits || [ '%', 'px', 'em', 'rem', 'vw' ],\n\t\t} );\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ allowCustomContentAndWideSize && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<div className=\"block-editor-hooks__layout-controls\">\n\t\t\t\t\t\t\t<div className=\"block-editor-hooks__layout-controls-unit\">\n\t\t\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-hooks__layout-controls-unit-input\"\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Content' ) }\n\t\t\t\t\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\t\t\t\tvalue={ contentSize || wideSize || '' }\n\t\t\t\t\t\t\t\t\tonChange={ ( nextWidth ) => {\n\t\t\t\t\t\t\t\t\t\tnextWidth =\n\t\t\t\t\t\t\t\t\t\t\t0 > parseFloat( nextWidth )\n\t\t\t\t\t\t\t\t\t\t\t\t? '0'\n\t\t\t\t\t\t\t\t\t\t\t\t: nextWidth;\n\t\t\t\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\t\t\t\t...layout,\n\t\t\t\t\t\t\t\t\t\t\tcontentSize: nextWidth,\n\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<Icon icon={ positionCenter } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div className=\"block-editor-hooks__layout-controls-unit\">\n\t\t\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-hooks__layout-controls-unit-input\"\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Wide' ) }\n\t\t\t\t\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\t\t\t\tvalue={ wideSize || contentSize || '' }\n\t\t\t\t\t\t\t\t\tonChange={ ( nextWidth ) => {\n\t\t\t\t\t\t\t\t\t\tnextWidth =\n\t\t\t\t\t\t\t\t\t\t\t0 > parseFloat( nextWidth )\n\t\t\t\t\t\t\t\t\t\t\t\t? '0'\n\t\t\t\t\t\t\t\t\t\t\t\t: nextWidth;\n\t\t\t\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\t\t\t\t...layout,\n\t\t\t\t\t\t\t\t\t\t\twideSize: nextWidth,\n\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<Icon icon={ stretchWide } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<p className=\"block-editor-hooks__layout-controls-helptext\">\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Customize the width for all elements that are assigned to the center or wide columns.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t{ allowJustification && (\n\t\t\t\t\t<ToggleGroupControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Justification' ) }\n\t\t\t\t\t\tvalue={ justifyContent }\n\t\t\t\t\t\tonChange={ onJustificationChange }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ justificationOptions.map(\n\t\t\t\t\t\t\t( { value, icon, label } ) => {\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<ToggleGroupControlOptionIcon\n\t\t\t\t\t\t\t\t\t\tkey={ value }\n\t\t\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ToggleGroupControl>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t},\n\ttoolBarControls: function DefaultLayoutToolbarControls() {\n\t\treturn null;\n\t},\n\tgetLayoutStyle: function getLayoutStyle( {\n\t\tselector,\n\t\tlayout = {},\n\t\tstyle,\n\t\tblockName,\n\t\thasBlockGapSupport,\n\t\tlayoutDefinitions = LAYOUT_DEFINITIONS,\n\t} ) {\n\t\tconst { contentSize, wideSize, justifyContent } = layout;\n\t\tconst blockGapStyleValue = getGapCSSValue( style?.spacing?.blockGap );\n\n\t\t// If a block's block.json skips serialization for spacing or\n\t\t// spacing.blockGap, don't apply the user-defined value to the styles.\n\t\tlet blockGapValue = '';\n\t\tif ( ! shouldSkipSerialization( blockName, 'spacing', 'blockGap' ) ) {\n\t\t\t// If an object is provided only use the 'top' value for this kind of gap.\n\t\t\tif ( blockGapStyleValue?.top ) {\n\t\t\t\tblockGapValue = getGapCSSValue( blockGapStyleValue?.top );\n\t\t\t} else if ( typeof blockGapStyleValue === 'string' ) {\n\t\t\t\tblockGapValue = getGapCSSValue( blockGapStyleValue );\n\t\t\t}\n\t\t}\n\n\t\tconst marginLeft =\n\t\t\tjustifyContent === 'left' ? '0 !important' : 'auto !important';\n\t\tconst marginRight =\n\t\t\tjustifyContent === 'right' ? '0 !important' : 'auto !important';\n\n\t\tlet output =\n\t\t\t!! contentSize || !! wideSize\n\t\t\t\t? `\n\t\t\t\t\t${ appendSelectors(\n\t\t\t\t\t\tselector,\n\t\t\t\t\t\t'> :where(:not(.alignleft):not(.alignright):not(.alignfull))'\n\t\t\t\t\t) } {\n\t\t\t\t\t\tmax-width: ${ contentSize ?? wideSize };\n\t\t\t\t\t\tmargin-left: ${ marginLeft };\n\t\t\t\t\t\tmargin-right: ${ marginRight };\n\t\t\t\t\t}\n\t\t\t\t\t${ appendSelectors( selector, '> .alignwide' ) } {\n\t\t\t\t\t\tmax-width: ${ wideSize ?? contentSize };\n\t\t\t\t\t}\n\t\t\t\t\t${ appendSelectors( selector, '> .alignfull' ) } {\n\t\t\t\t\t\tmax-width: none;\n\t\t\t\t\t}\n\t\t\t\t`\n\t\t\t\t: '';\n\n\t\tif ( justifyContent === 'left' ) {\n\t\t\toutput += `${ appendSelectors(\n\t\t\t\tselector,\n\t\t\t\t'> :where(:not(.alignleft):not(.alignright):not(.alignfull))'\n\t\t\t) }\n\t\t\t{ margin-left: ${ marginLeft }; }`;\n\t\t} else if ( justifyContent === 'right' ) {\n\t\t\toutput += `${ appendSelectors(\n\t\t\t\tselector,\n\t\t\t\t'> :where(:not(.alignleft):not(.alignright):not(.alignfull))'\n\t\t\t) }\n\t\t\t{ margin-right: ${ marginRight }; }`;\n\t\t}\n\n\t\t// If there is custom padding, add negative margins for alignfull blocks.\n\t\tif ( style?.spacing?.padding ) {\n\t\t\t// The style object might be storing a preset so we need to make sure we get a usable value.\n\t\t\tconst paddingValues = getCSSRules( style );\n\t\t\tpaddingValues.forEach( ( rule ) => {\n\t\t\t\tif ( rule.key === 'paddingRight' ) {\n\t\t\t\t\toutput += `\n\t\t\t\t\t${ appendSelectors( selector, '> .alignfull' ) } {\n\t\t\t\t\t\tmargin-right: calc(${ rule.value } * -1);\n\t\t\t\t\t}\n\t\t\t\t\t`;\n\t\t\t\t} else if ( rule.key === 'paddingLeft' ) {\n\t\t\t\t\toutput += `\n\t\t\t\t\t${ appendSelectors( selector, '> .alignfull' ) } {\n\t\t\t\t\t\tmargin-left: calc(${ rule.value } * -1);\n\t\t\t\t\t}\n\t\t\t\t\t`;\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t// Output blockGap styles based on rules contained in layout definitions in theme.json.\n\t\tif ( hasBlockGapSupport && blockGapValue ) {\n\t\t\toutput += getBlockGapCSS(\n\t\t\t\tselector,\n\t\t\t\tlayoutDefinitions,\n\t\t\t\t'constrained',\n\t\t\t\tblockGapValue\n\t\t\t);\n\t\t}\n\t\treturn output;\n\t},\n\tgetOrientation() {\n\t\treturn 'vertical';\n\t},\n\tgetAlignments( layout ) {\n\t\tconst alignmentInfo = getAlignmentsInfo( layout );\n\t\tif ( layout.alignments !== undefined ) {\n\t\t\tif ( ! layout.alignments.includes( 'none' ) ) {\n\t\t\t\tlayout.alignments.unshift( 'none' );\n\t\t\t}\n\t\t\treturn layout.alignments.map( ( alignment ) => ( {\n\t\t\t\tname: alignment,\n\t\t\t\tinfo: alignmentInfo[ alignment ],\n\t\t\t} ) );\n\t\t}\n\t\tconst { contentSize, wideSize } = layout;\n\n\t\tconst alignments = [\n\t\t\t{ name: 'left' },\n\t\t\t{ name: 'center' },\n\t\t\t{ name: 'right' },\n\t\t];\n\n\t\tif ( contentSize ) {\n\t\t\talignments.unshift( { name: 'full' } );\n\t\t}\n\n\t\tif ( wideSize ) {\n\t\t\talignments.unshift( { name: 'wide', info: alignmentInfo.wide } );\n\t\t}\n\n\t\talignments.unshift( { name: 'none', info: alignmentInfo.none } );\n\n\t\treturn alignments;\n\t},\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,4BAA4B,IAAIC,cAAc,EAC9CC,yBAAyB,IAAIC,WAAW,EACxCC,gCAAgC,IAAIC,kBAAkB,EACtDC,0CAA0C,IAAIC,4BAA4B,QACpE,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,IAAI,EACJC,cAAc,EACdC,WAAW,EACXC,WAAW,EACXC,aAAa,EACbC,YAAY,QACN,kBAAkB;AACzB,SAASC,WAAW,QAAQ,yBAAyB;;AAErD;AACA;AACA;AACA,SAASC,WAAW,QAAQ,4BAA4B;AACxD,SAASC,eAAe,EAAEC,cAAc,EAAEC,iBAAiB,QAAQ,SAAS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GAAGH,MAAM;IAExC,MAAM8C,UAAU,GAAG,CAClB;MAAElD,IAAI,EAAE;IAAO,CAAC,EAChB;MAAEA,IAAI,EAAE;IAAS,CAAC,EAClB;MAAEA,IAAI,EAAE;IAAQ,CAAC,CACjB;IAED,IAAKQ,WAAW,EAAG;MAClB0C,UAAU,CAACG,OAAO,CAAE;QAAErD,IAAI,EAAE;MAAO,CAAE,CAAC;IACvC;IAEA,IAAKO,QAAQ,EAAG;MACf2C,UAAU,CAACG,OAAO,CAAE;QAAErD,IAAI,EAAE,MAAM;QAAEuD,IAAI,EAAEN,aAAa,CAACO;MAAK,CAAE,CAAC;IACjE;IAEAN,UAAU,CAACG,OAAO,CAAE;MAAErD,IAAI,EAAE,MAAM;MAAEuD,IAAI,EAAEN,aAAa,CAACQ;IAAK,CAAE,CAAC;IAEhE,OAAOP,UAAU;EAClB;AACD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["__experimentalUseCustomUnits","useCustomUnits","__experimentalUnitControl","UnitControl","__experimentalToggleGroupControl","ToggleGroupControl","__experimentalToggleGroupControlOptionIcon","ToggleGroupControlOptionIcon","__","Icon","positionCenter","stretchWide","justifyLeft","justifyCenter","justifyRight","getCSSRules","useSettings","appendSelectors","getBlockGapCSS","getAlignmentsInfo","getGapCSSValue","shouldSkipSerialization","LAYOUT_DEFINITIONS","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","name","label","inspectorControls","DefaultLayoutInspectorControls","layout","onChange","layoutBlockSupport","wideSize","contentSize","justifyContent","allowJustification","allowCustomContentAndWideSize","onJustificationChange","value","justificationOptions","icon","availableUnits","units","children","className","labelPosition","__unstableInputWidth","nextWidth","parseFloat","__nextHasNoMarginBottom","map","toolBarControls","DefaultLayoutToolbarControls","getLayoutStyle","selector","style","blockName","hasBlockGapSupport","layoutDefinitions","blockGapStyleValue","spacing","blockGap","blockGapValue","top","marginLeft","marginRight","output","padding","paddingValues","forEach","rule","key","paddingRightValue","paddingLeftValue","getOrientation","getAlignments","alignmentInfo","alignments","undefined","includes","unshift","alignment","info","wide","none"],"sources":["@wordpress/block-editor/src/layouts/constrained.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tIcon,\n\tpositionCenter,\n\tstretchWide,\n\tjustifyLeft,\n\tjustifyCenter,\n\tjustifyRight,\n} from '@wordpress/icons';\nimport { getCSSRules } from '@wordpress/style-engine';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../components/use-settings';\nimport { appendSelectors, getBlockGapCSS, getAlignmentsInfo } from './utils';\nimport { getGapCSSValue } from '../hooks/gap';\nimport { shouldSkipSerialization } from '../hooks/utils';\nimport { LAYOUT_DEFINITIONS } from './definitions';\n\nexport default {\n\tname: 'constrained',\n\tlabel: __( 'Constrained' ),\n\tinspectorControls: function DefaultLayoutInspectorControls( {\n\t\tlayout,\n\t\tonChange,\n\t\tlayoutBlockSupport = {},\n\t} ) {\n\t\tconst { wideSize, contentSize, justifyContent = 'center' } = layout;\n\t\tconst {\n\t\t\tallowJustification = true,\n\t\t\tallowCustomContentAndWideSize = true,\n\t\t} = layoutBlockSupport;\n\t\tconst onJustificationChange = ( value ) => {\n\t\t\tonChange( {\n\t\t\t\t...layout,\n\t\t\t\tjustifyContent: value,\n\t\t\t} );\n\t\t};\n\t\tconst justificationOptions = [\n\t\t\t{\n\t\t\t\tvalue: 'left',\n\t\t\t\ticon: justifyLeft,\n\t\t\t\tlabel: __( 'Justify items left' ),\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: 'center',\n\t\t\t\ticon: justifyCenter,\n\t\t\t\tlabel: __( 'Justify items center' ),\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: 'right',\n\t\t\t\ticon: justifyRight,\n\t\t\t\tlabel: __( 'Justify items right' ),\n\t\t\t},\n\t\t];\n\t\tconst [ availableUnits ] = useSettings( 'spacing.units' );\n\t\tconst units = useCustomUnits( {\n\t\t\tavailableUnits: availableUnits || [ '%', 'px', 'em', 'rem', 'vw' ],\n\t\t} );\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ allowCustomContentAndWideSize && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<div className=\"block-editor-hooks__layout-controls\">\n\t\t\t\t\t\t\t<div className=\"block-editor-hooks__layout-controls-unit\">\n\t\t\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-hooks__layout-controls-unit-input\"\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Content' ) }\n\t\t\t\t\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\t\t\t\tvalue={ contentSize || wideSize || '' }\n\t\t\t\t\t\t\t\t\tonChange={ ( nextWidth ) => {\n\t\t\t\t\t\t\t\t\t\tnextWidth =\n\t\t\t\t\t\t\t\t\t\t\t0 > parseFloat( nextWidth )\n\t\t\t\t\t\t\t\t\t\t\t\t? '0'\n\t\t\t\t\t\t\t\t\t\t\t\t: nextWidth;\n\t\t\t\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\t\t\t\t...layout,\n\t\t\t\t\t\t\t\t\t\t\tcontentSize: nextWidth,\n\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<Icon icon={ positionCenter } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div className=\"block-editor-hooks__layout-controls-unit\">\n\t\t\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-hooks__layout-controls-unit-input\"\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Wide' ) }\n\t\t\t\t\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\t\t\t\tvalue={ wideSize || contentSize || '' }\n\t\t\t\t\t\t\t\t\tonChange={ ( nextWidth ) => {\n\t\t\t\t\t\t\t\t\t\tnextWidth =\n\t\t\t\t\t\t\t\t\t\t\t0 > parseFloat( nextWidth )\n\t\t\t\t\t\t\t\t\t\t\t\t? '0'\n\t\t\t\t\t\t\t\t\t\t\t\t: nextWidth;\n\t\t\t\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\t\t\t\t...layout,\n\t\t\t\t\t\t\t\t\t\t\twideSize: nextWidth,\n\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<Icon icon={ stretchWide } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<p className=\"block-editor-hooks__layout-controls-helptext\">\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Customize the width for all elements that are assigned to the center or wide columns.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t{ allowJustification && (\n\t\t\t\t\t<ToggleGroupControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Justification' ) }\n\t\t\t\t\t\tvalue={ justifyContent }\n\t\t\t\t\t\tonChange={ onJustificationChange }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ justificationOptions.map(\n\t\t\t\t\t\t\t( { value, icon, label } ) => {\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<ToggleGroupControlOptionIcon\n\t\t\t\t\t\t\t\t\t\tkey={ value }\n\t\t\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ToggleGroupControl>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t},\n\ttoolBarControls: function DefaultLayoutToolbarControls() {\n\t\treturn null;\n\t},\n\tgetLayoutStyle: function getLayoutStyle( {\n\t\tselector,\n\t\tlayout = {},\n\t\tstyle,\n\t\tblockName,\n\t\thasBlockGapSupport,\n\t\tlayoutDefinitions = LAYOUT_DEFINITIONS,\n\t} ) {\n\t\tconst { contentSize, wideSize, justifyContent } = layout;\n\t\tconst blockGapStyleValue = getGapCSSValue( style?.spacing?.blockGap );\n\n\t\t// If a block's block.json skips serialization for spacing or\n\t\t// spacing.blockGap, don't apply the user-defined value to the styles.\n\t\tlet blockGapValue = '';\n\t\tif ( ! shouldSkipSerialization( blockName, 'spacing', 'blockGap' ) ) {\n\t\t\t// If an object is provided only use the 'top' value for this kind of gap.\n\t\t\tif ( blockGapStyleValue?.top ) {\n\t\t\t\tblockGapValue = getGapCSSValue( blockGapStyleValue?.top );\n\t\t\t} else if ( typeof blockGapStyleValue === 'string' ) {\n\t\t\t\tblockGapValue = getGapCSSValue( blockGapStyleValue );\n\t\t\t}\n\t\t}\n\n\t\tconst marginLeft =\n\t\t\tjustifyContent === 'left' ? '0 !important' : 'auto !important';\n\t\tconst marginRight =\n\t\t\tjustifyContent === 'right' ? '0 !important' : 'auto !important';\n\n\t\tlet output =\n\t\t\t!! contentSize || !! wideSize\n\t\t\t\t? `\n\t\t\t\t\t${ appendSelectors(\n\t\t\t\t\t\tselector,\n\t\t\t\t\t\t'> :where(:not(.alignleft):not(.alignright):not(.alignfull))'\n\t\t\t\t\t) } {\n\t\t\t\t\t\tmax-width: ${ contentSize ?? wideSize };\n\t\t\t\t\t\tmargin-left: ${ marginLeft };\n\t\t\t\t\t\tmargin-right: ${ marginRight };\n\t\t\t\t\t}\n\t\t\t\t\t${ appendSelectors( selector, '> .alignwide' ) } {\n\t\t\t\t\t\tmax-width: ${ wideSize ?? contentSize };\n\t\t\t\t\t}\n\t\t\t\t\t${ appendSelectors( selector, '> .alignfull' ) } {\n\t\t\t\t\t\tmax-width: none;\n\t\t\t\t\t}\n\t\t\t\t`\n\t\t\t\t: '';\n\n\t\tif ( justifyContent === 'left' ) {\n\t\t\toutput += `${ appendSelectors(\n\t\t\t\tselector,\n\t\t\t\t'> :where(:not(.alignleft):not(.alignright):not(.alignfull))'\n\t\t\t) }\n\t\t\t{ margin-left: ${ marginLeft }; }`;\n\t\t} else if ( justifyContent === 'right' ) {\n\t\t\toutput += `${ appendSelectors(\n\t\t\t\tselector,\n\t\t\t\t'> :where(:not(.alignleft):not(.alignright):not(.alignfull))'\n\t\t\t) }\n\t\t\t{ margin-right: ${ marginRight }; }`;\n\t\t}\n\n\t\t// If there is custom padding, add negative margins for alignfull blocks.\n\t\tif ( style?.spacing?.padding ) {\n\t\t\t// The style object might be storing a preset so we need to make sure we get a usable value.\n\t\t\tconst paddingValues = getCSSRules( style );\n\t\t\tpaddingValues.forEach( ( rule ) => {\n\t\t\t\tif ( rule.key === 'paddingRight' ) {\n\t\t\t\t\t// Add unit if 0, to avoid calc(0 * -1) which is invalid.\n\t\t\t\t\tconst paddingRightValue =\n\t\t\t\t\t\trule.value === '0' ? '0px' : rule.value;\n\n\t\t\t\t\toutput += `\n\t\t\t\t\t${ appendSelectors( selector, '> .alignfull' ) } {\n\t\t\t\t\t\tmargin-right: calc(${ paddingRightValue } * -1);\n\t\t\t\t\t}\n\t\t\t\t\t`;\n\t\t\t\t} else if ( rule.key === 'paddingLeft' ) {\n\t\t\t\t\t// Add unit if 0, to avoid calc(0 * -1) which is invalid.\n\t\t\t\t\tconst paddingLeftValue =\n\t\t\t\t\t\trule.value === '0' ? '0px' : rule.value;\n\n\t\t\t\t\toutput += `\n\t\t\t\t\t${ appendSelectors( selector, '> .alignfull' ) } {\n\t\t\t\t\t\tmargin-left: calc(${ paddingLeftValue } * -1);\n\t\t\t\t\t}\n\t\t\t\t\t`;\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t// Output blockGap styles based on rules contained in layout definitions in theme.json.\n\t\tif ( hasBlockGapSupport && blockGapValue ) {\n\t\t\toutput += getBlockGapCSS(\n\t\t\t\tselector,\n\t\t\t\tlayoutDefinitions,\n\t\t\t\t'constrained',\n\t\t\t\tblockGapValue\n\t\t\t);\n\t\t}\n\t\treturn output;\n\t},\n\tgetOrientation() {\n\t\treturn 'vertical';\n\t},\n\tgetAlignments( layout ) {\n\t\tconst alignmentInfo = getAlignmentsInfo( layout );\n\t\tif ( layout.alignments !== undefined ) {\n\t\t\tif ( ! layout.alignments.includes( 'none' ) ) {\n\t\t\t\tlayout.alignments.unshift( 'none' );\n\t\t\t}\n\t\t\treturn layout.alignments.map( ( alignment ) => ( {\n\t\t\t\tname: alignment,\n\t\t\t\tinfo: alignmentInfo[ alignment ],\n\t\t\t} ) );\n\t\t}\n\t\tconst { contentSize, wideSize } = layout;\n\n\t\tconst alignments = [\n\t\t\t{ name: 'left' },\n\t\t\t{ name: 'center' },\n\t\t\t{ name: 'right' },\n\t\t];\n\n\t\tif ( contentSize ) {\n\t\t\talignments.unshift( { name: 'full' } );\n\t\t}\n\n\t\tif ( wideSize ) {\n\t\t\talignments.unshift( { name: 'wide', info: alignmentInfo.wide } );\n\t\t}\n\n\t\talignments.unshift( { name: 'none', info: alignmentInfo.none } );\n\n\t\treturn alignments;\n\t},\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,4BAA4B,IAAIC,cAAc,EAC9CC,yBAAyB,IAAIC,WAAW,EACxCC,gCAAgC,IAAIC,kBAAkB,EACtDC,0CAA0C,IAAIC,4BAA4B,QACpE,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAi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,CAAEc,MAAO,CAAC;IACjD,IAAKA,MAAM,CAACgD,UAAU,KAAKC,SAAS,EAAG;MACtC,IAAK,CAAEjD,MAAM,CAACgD,UAAU,CAACE,QAAQ,CAAE,MAAO,CAAC,EAAG;QAC7ClD,MAAM,CAACgD,UAAU,CAACG,OAAO,CAAE,MAAO,CAAC;MACpC;MACA,OAAOnD,MAAM,CAACgD,UAAU,CAAC3B,GAAG,CAAI+B,SAAS,KAAQ;QAChDxD,IAAI,EAAEwD,SAAS;QACfC,IAAI,EAAEN,aAAa,CAAEK,SAAS;MAC/B,CAAC,CAAG,CAAC;IACN;IACA,MAAM;MAAEhD,WAAW;MAAED;IAAS,CAAC,GAAGH,MAAM;IAExC,MAAMgD,UAAU,GAAG,CAClB;MAAEpD,IAAI,EAAE;IAAO,CAAC,EAChB;MAAEA,IAAI,EAAE;IAAS,CAAC,EAClB;MAAEA,IAAI,EAAE;IAAQ,CAAC,CACjB;IAED,IAAKQ,WAAW,EAAG;MAClB4C,UAAU,CAACG,OAAO,CAAE;QAAEvD,IAAI,EAAE;MAAO,CAAE,CAAC;IACvC;IAEA,IAAKO,QAAQ,EAAG;MACf6C,UAAU,CAACG,OAAO,CAAE;QAAEvD,IAAI,EAAE,MAAM;QAAEyD,IAAI,EAAEN,aAAa,CAACO;MAAK,CAAE,CAAC;IACjE;IAEAN,UAAU,CAACG,OAAO,CAAE;MAAEvD,IAAI,EAAE,MAAM;MAAEyD,IAAI,EAAEN,aAAa,CAACQ;IAAK,CAAE,CAAC;IAEhE,OAAOP,UAAU;EAClB;AACD,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-editor",
3
- "version": "13.0.4",
3
+ "version": "13.0.6",
4
4
  "description": "Generic block editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -86,5 +86,5 @@
86
86
  "publishConfig": {
87
87
  "access": "public"
88
88
  },
89
- "gitHead": "85486692a3e48b7d863226cf895a21d787434921"
89
+ "gitHead": "5c1d6bb774e6f78f0bbd4cdc85c4a7087da2f8a0"
90
90
  }
@@ -1,8 +1,14 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { useContext, useMemo, useRef } from '@wordpress/element';
5
- import { useRefEffect, useObservableValue } from '@wordpress/compose';
4
+ import {
5
+ useContext,
6
+ useMemo,
7
+ useRef,
8
+ useState,
9
+ useLayoutEffect,
10
+ } from '@wordpress/element';
11
+ import { useRefEffect } from '@wordpress/compose';
6
12
 
7
13
  /**
8
14
  * Internal dependencies
@@ -67,7 +73,17 @@ function useBlockRef( clientId ) {
67
73
  */
68
74
  function useBlockElement( clientId ) {
69
75
  const { refsMap } = useContext( BlockRefs );
70
- return useObservableValue( refsMap, clientId ) ?? null;
76
+ const [ blockElement, setBlockElement ] = useState( null );
77
+ // Delay setting the resulting `blockElement` until an effect. If the block element
78
+ // changes (i.e., the block is unmounted and re-mounted), this allows enough time
79
+ // for the ref callbacks to clean up the old element and set the new one.
80
+ useLayoutEffect( () => {
81
+ setBlockElement( refsMap.get( clientId ) );
82
+ return refsMap.subscribe( clientId, () =>
83
+ setBlockElement( refsMap.get( clientId ) )
84
+ );
85
+ }, [ refsMap, clientId ] );
86
+ return blockElement;
71
87
  }
72
88
 
73
89
  export { useBlockRef as __unstableUseBlockRef };
@@ -66,7 +66,8 @@ export default function Shuffle( { clientId, as = Container } ) {
66
66
  );
67
67
  } );
68
68
  }, [ categories, patterns ] );
69
- if ( sameCategoryPatternsWithSingleWrapper.length === 0 ) {
69
+
70
+ if ( sameCategoryPatternsWithSingleWrapper.length < 2 ) {
70
71
  return null;
71
72
  }
72
73
 
@@ -85,7 +85,11 @@ const VALID_SETTINGS = [
85
85
  ];
86
86
 
87
87
  export const useGlobalStylesReset = () => {
88
- const { user: config, setUserConfig } = useContext( GlobalStylesContext );
88
+ const { user, setUserConfig } = useContext( GlobalStylesContext );
89
+ const config = {
90
+ settings: user.settings,
91
+ styles: user.styles,
92
+ };
89
93
  const canReset = !! config && ! fastDeepEqual( config, EMPTY_CONFIG );
90
94
  return [
91
95
  canReset,
@@ -128,6 +128,7 @@ describe( 'global styles renderer', () => {
128
128
  },
129
129
  },
130
130
  selector: ELEMENTS.link,
131
+ skipSelectorWrapper: true,
131
132
  },
132
133
  {
133
134
  styles: {
@@ -480,7 +481,7 @@ describe( 'global styles renderer', () => {
480
481
  };
481
482
 
482
483
  expect( toStyles( tree, blockSelectors ) ).toEqual(
483
- ':where(body) {margin: 0;}.is-layout-flow > .alignleft { float: left; margin-inline-start: 0; margin-inline-end: 2em; }.is-layout-flow > .alignright { float: right; margin-inline-start: 2em; margin-inline-end: 0; }.is-layout-flow > .aligncenter { margin-left: auto !important; margin-right: auto !important; }.is-layout-constrained > .alignleft { float: left; margin-inline-start: 0; margin-inline-end: 2em; }.is-layout-constrained > .alignright { float: right; margin-inline-start: 2em; margin-inline-end: 0; }.is-layout-constrained > .aligncenter { margin-left: auto !important; margin-right: auto !important; }.is-layout-constrained > :where(:not(.alignleft):not(.alignright):not(.alignfull)) { max-width: var(--wp--style--global--content-size); margin-left: auto !important; margin-right: auto !important; }.is-layout-constrained > .alignwide { max-width: var(--wp--style--global--wide-size); }body .is-layout-flex { display:flex; }.is-layout-flex { flex-wrap: wrap; align-items: center; }.is-layout-flex > :is(*, div) { margin: 0; }body .is-layout-grid { display:grid; }.is-layout-grid > :is(*, div) { margin: 0; }:root :where(body){background-color: red;margin: 10px;padding: 10px;}:root :where(a:where(:not(.wp-element-button))){color: blue;}a:where(:not(.wp-element-button)):hover{color: orange;}a:where(:not(.wp-element-button)):focus{color: orange;}:root :where(h1){font-size: 42px;}:root :where(.wp-block-group){margin-top: 10px;margin-right: 20px;margin-bottom: 30px;margin-left: 40px;padding-top: 11px;padding-right: 22px;padding-bottom: 33px;padding-left: 44px;}:root :where(h1,h2,h3,h4,h5,h6){color: orange;}:root :where(h1 a:where(:not(.wp-element-button)),h2 a:where(:not(.wp-element-button)),h3 a:where(:not(.wp-element-button)),h4 a:where(:not(.wp-element-button)),h5 a:where(:not(.wp-element-button)),h6 a:where(:not(.wp-element-button))){color: hotpink;}h1 a:where(:not(.wp-element-button)):hover,h2 a:where(:not(.wp-element-button)):hover,h3 a:where(:not(.wp-element-button)):hover,h4 a:where(:not(.wp-element-button)):hover,h5 a:where(:not(.wp-element-button)):hover,h6 a:where(:not(.wp-element-button)):hover{color: red;}h1 a:where(:not(.wp-element-button)):focus,h2 a:where(:not(.wp-element-button)):focus,h3 a:where(:not(.wp-element-button)):focus,h4 a:where(:not(.wp-element-button)):focus,h5 a:where(:not(.wp-element-button)):focus,h6 a:where(:not(.wp-element-button)):focus{color: red;}:root :where(.wp-block-image img, .wp-block-image .wp-crop-area){border-radius: 9999px;}:root :where(.wp-block-image){color: red;}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }.has-white-color{color: var(--wp--preset--color--white) !important;}.has-white-background-color{background-color: var(--wp--preset--color--white) !important;}.has-white-border-color{border-color: var(--wp--preset--color--white) !important;}.has-black-color{color: var(--wp--preset--color--black) !important;}.has-black-background-color{background-color: var(--wp--preset--color--black) !important;}.has-black-border-color{border-color: var(--wp--preset--color--black) !important;}h1.has-blue-color,h2.has-blue-color,h3.has-blue-color,h4.has-blue-color,h5.has-blue-color,h6.has-blue-color{color: var(--wp--preset--color--blue) !important;}h1.has-blue-background-color,h2.has-blue-background-color,h3.has-blue-background-color,h4.has-blue-background-color,h5.has-blue-background-color,h6.has-blue-background-color{background-color: var(--wp--preset--color--blue) !important;}h1.has-blue-border-color,h2.has-blue-border-color,h3.has-blue-border-color,h4.has-blue-border-color,h5.has-blue-border-color,h6.has-blue-border-color{border-color: var(--wp--preset--color--blue) !important;}'
484
+ ':where(body) {margin: 0;}.is-layout-flow > .alignleft { float: left; margin-inline-start: 0; margin-inline-end: 2em; }.is-layout-flow > .alignright { float: right; margin-inline-start: 2em; margin-inline-end: 0; }.is-layout-flow > .aligncenter { margin-left: auto !important; margin-right: auto !important; }.is-layout-constrained > .alignleft { float: left; margin-inline-start: 0; margin-inline-end: 2em; }.is-layout-constrained > .alignright { float: right; margin-inline-start: 2em; margin-inline-end: 0; }.is-layout-constrained > .aligncenter { margin-left: auto !important; margin-right: auto !important; }.is-layout-constrained > :where(:not(.alignleft):not(.alignright):not(.alignfull)) { max-width: var(--wp--style--global--content-size); margin-left: auto !important; margin-right: auto !important; }.is-layout-constrained > .alignwide { max-width: var(--wp--style--global--wide-size); }body .is-layout-flex { display:flex; }.is-layout-flex { flex-wrap: wrap; align-items: center; }.is-layout-flex > :is(*, div) { margin: 0; }body .is-layout-grid { display:grid; }.is-layout-grid > :is(*, div) { margin: 0; }:root :where(body){background-color: red;margin: 10px;padding: 10px;}a:where(:not(.wp-element-button)){color: blue;}:root :where(a:where(:not(.wp-element-button)):hover){color: orange;}:root :where(a:where(:not(.wp-element-button)):focus){color: orange;}h1{font-size: 42px;}:root :where(.wp-block-group){margin-top: 10px;margin-right: 20px;margin-bottom: 30px;margin-left: 40px;padding-top: 11px;padding-right: 22px;padding-bottom: 33px;padding-left: 44px;}:root :where(h1,h2,h3,h4,h5,h6){color: orange;}:root :where(h1 a:where(:not(.wp-element-button)),h2 a:where(:not(.wp-element-button)),h3 a:where(:not(.wp-element-button)),h4 a:where(:not(.wp-element-button)),h5 a:where(:not(.wp-element-button)),h6 a:where(:not(.wp-element-button))){color: hotpink;}:root :where(h1 a:where(:not(.wp-element-button)):hover,h2 a:where(:not(.wp-element-button)):hover,h3 a:where(:not(.wp-element-button)):hover,h4 a:where(:not(.wp-element-button)):hover,h5 a:where(:not(.wp-element-button)):hover,h6 a:where(:not(.wp-element-button)):hover){color: red;}:root :where(h1 a:where(:not(.wp-element-button)):focus,h2 a:where(:not(.wp-element-button)):focus,h3 a:where(:not(.wp-element-button)):focus,h4 a:where(:not(.wp-element-button)):focus,h5 a:where(:not(.wp-element-button)):focus,h6 a:where(:not(.wp-element-button)):focus){color: red;}:root :where(.wp-block-image img, .wp-block-image .wp-crop-area){border-radius: 9999px;}:root :where(.wp-block-image){color: red;}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }.has-white-color{color: var(--wp--preset--color--white) !important;}.has-white-background-color{background-color: var(--wp--preset--color--white) !important;}.has-white-border-color{border-color: var(--wp--preset--color--white) !important;}.has-black-color{color: var(--wp--preset--color--black) !important;}.has-black-background-color{background-color: var(--wp--preset--color--black) !important;}.has-black-border-color{border-color: var(--wp--preset--color--black) !important;}h1.has-blue-color,h2.has-blue-color,h3.has-blue-color,h4.has-blue-color,h5.has-blue-color,h6.has-blue-color{color: var(--wp--preset--color--blue) !important;}h1.has-blue-background-color,h2.has-blue-background-color,h3.has-blue-background-color,h4.has-blue-background-color,h5.has-blue-background-color,h6.has-blue-background-color{background-color: var(--wp--preset--color--blue) !important;}h1.has-blue-border-color,h2.has-blue-border-color,h3.has-blue-border-color,h4.has-blue-border-color,h5.has-blue-border-color,h6.has-blue-border-color{border-color: var(--wp--preset--color--blue) !important;}'
484
485
  );
485
486
  } );
486
487
 
@@ -37,6 +37,12 @@ import { getValueFromObjectPath, setImmutably } from '../../utils/object';
37
37
  import { unlock } from '../../lock-unlock';
38
38
  import { setThemeFileUris } from './theme-file-uri-utils';
39
39
 
40
+ // Elements that rely on class names in their selectors.
41
+ const ELEMENT_CLASS_NAMES = {
42
+ button: 'wp-element-button',
43
+ caption: 'wp-element-caption',
44
+ };
45
+
40
46
  // List of block support features that can have their related styles
41
47
  // generated under their own feature level selector rather than the block's.
42
48
  const BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = {
@@ -636,6 +642,9 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
636
642
  nodes.push( {
637
643
  styles: tree.styles?.elements?.[ name ],
638
644
  selector,
645
+ // Top level elements that don't use a class name should not receive the
646
+ // `:root :where()` wrapper to maintain backwards compatibility.
647
+ skipSelectorWrapper: ! ELEMENT_CLASS_NAMES[ name ],
639
648
  } );
640
649
  }
641
650
  } );
@@ -656,7 +665,7 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
656
665
  }
657
666
  const variationSelector =
658
667
  blockSelectors[ blockName ]
659
- .styleVariationSelectors?.[ variationName ];
668
+ ?.styleVariationSelectors?.[ variationName ];
660
669
 
661
670
  // Process the variation's inner element styles.
662
671
  // This comes before the inner block styles so the
@@ -685,18 +694,18 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
685
694
  const variationBlockSelector = scopeSelector(
686
695
  variationSelector,
687
696
  blockSelectors[ variationBlockName ]
688
- .selector
697
+ ?.selector
689
698
  );
690
699
  const variationDuotoneSelector = scopeSelector(
691
700
  variationSelector,
692
701
  blockSelectors[ variationBlockName ]
693
- .duotoneSelector
702
+ ?.duotoneSelector
694
703
  );
695
704
  const variationFeatureSelectors =
696
705
  scopeFeatureSelectors(
697
706
  variationSelector,
698
707
  blockSelectors[ variationBlockName ]
699
- .featureSelectors
708
+ ?.featureSelectors
700
709
  );
701
710
 
702
711
  const variationBlockStyleNodes =
@@ -713,10 +722,10 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
713
722
  featureSelectors: variationFeatureSelectors,
714
723
  fallbackGapValue:
715
724
  blockSelectors[ variationBlockName ]
716
- .fallbackGapValue,
725
+ ?.fallbackGapValue,
717
726
  hasLayoutSupport:
718
727
  blockSelectors[ variationBlockName ]
719
- .hasLayoutSupport,
728
+ ?.hasLayoutSupport,
720
729
  styles: variationBlockStyleNodes,
721
730
  } );
722
731
 
@@ -924,8 +933,8 @@ export const toStyles = (
924
933
  ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) }
925
934
  .has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
926
935
  .has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }
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;
936
+ .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) { padding-right: 0; padding-left: 0; }
937
+ .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) > .alignfull { margin-left: 0; margin-right: 0;
929
938
  `;
930
939
  }
931
940
 
@@ -942,6 +951,7 @@ export const toStyles = (
942
951
  hasLayoutSupport,
943
952
  featureSelectors,
944
953
  styleVariationSelectors,
954
+ skipSelectorWrapper,
945
955
  } ) => {
946
956
  // Process styles for block support features with custom feature level
947
957
  // CSS selectors set.
@@ -1000,7 +1010,10 @@ export const toStyles = (
1000
1010
  disableRootPadding
1001
1011
  );
1002
1012
  if ( styleDeclarations?.length ) {
1003
- ruleset += `:root :where(${ selector }){${ styleDeclarations.join(
1013
+ const generalSelector = skipSelectorWrapper
1014
+ ? selector
1015
+ : `:root :where(${ selector })`;
1016
+ ruleset += `${ generalSelector }{${ styleDeclarations.join(
1004
1017
  ';'
1005
1018
  ) };}`;
1006
1019
  }
@@ -1094,7 +1107,11 @@ export const toStyles = (
1094
1107
  .map( ( sel ) => sel + pseudoKey )
1095
1108
  .join( ',' );
1096
1109
 
1097
- const pseudoRule = `${ _selector }{${ pseudoDeclarations.join(
1110
+ // As pseudo classes such as :hover, :focus etc. have class-level
1111
+ // specificity, they must use the `:root :where()` wrapper. This.
1112
+ // caps the specificity at `0-1-0` to allow proper nesting of variations
1113
+ // and block type element styles.
1114
+ const pseudoRule = `:root :where(${ _selector }){${ pseudoDeclarations.join(
1098
1115
  ';'
1099
1116
  ) };}`;
1100
1117
 
@@ -14,6 +14,7 @@ import {
14
14
  getBlockSelectors,
15
15
  } from '../components/global-styles';
16
16
  import { useStyleOverride } from './utils';
17
+ import { getValueFromObjectPath } from '../utils/object';
17
18
  import { store as blockEditorStore } from '../store';
18
19
  import { globalStylesDataKey } from '../store/private-keys';
19
20
  import { unlock } from '../lock-unlock';
@@ -180,6 +181,77 @@ export function __unstableBlockStyleVariationOverridesWithConfig( { config } ) {
180
181
  );
181
182
  }
182
183
 
184
+ /**
185
+ * Retrieves any variation styles data and resolves any referenced values.
186
+ *
187
+ * @param {Object} globalStyles A complete global styles object, containing settings and styles.
188
+ * @param {string} name The name of the desired block type.
189
+ * @param {variation} variation The of the block style variation to retrieve data for.
190
+ *
191
+ * @return {Object|undefined} The global styles data for the specified variation.
192
+ */
193
+ export function getVariationStylesWithRefValues(
194
+ globalStyles,
195
+ name,
196
+ variation
197
+ ) {
198
+ if ( ! globalStyles?.styles?.blocks?.[ name ]?.variations?.[ variation ] ) {
199
+ return;
200
+ }
201
+
202
+ // Helper to recursively look for `ref` values to resolve.
203
+ const replaceRefs = ( variationStyles ) => {
204
+ Object.keys( variationStyles ).forEach( ( key ) => {
205
+ const value = variationStyles[ key ];
206
+
207
+ // Only process objects.
208
+ if ( typeof value === 'object' && value !== null ) {
209
+ // Process `ref` value if present.
210
+ if ( value.ref !== undefined ) {
211
+ if (
212
+ typeof value.ref !== 'string' ||
213
+ value.ref.trim() === ''
214
+ ) {
215
+ // Remove invalid ref.
216
+ delete variationStyles[ key ];
217
+ } else {
218
+ // Resolve `ref` value.
219
+ const refValue = getValueFromObjectPath(
220
+ globalStyles,
221
+ value.ref
222
+ );
223
+
224
+ if ( refValue ) {
225
+ variationStyles[ key ] = refValue;
226
+ } else {
227
+ delete variationStyles[ key ];
228
+ }
229
+ }
230
+ } else {
231
+ // Recursively resolve `ref` values in nested objects.
232
+ replaceRefs( value );
233
+
234
+ // After recursion, if value is empty due to explicitly
235
+ // `undefined` ref value, remove it.
236
+ if ( Object.keys( value ).length === 0 ) {
237
+ delete variationStyles[ key ];
238
+ }
239
+ }
240
+ }
241
+ } );
242
+ };
243
+
244
+ // Deep clone variation node to avoid mutating it within global styles and losing refs.
245
+ const styles = JSON.parse(
246
+ JSON.stringify(
247
+ globalStyles.styles.blocks[ name ].variations[ variation ]
248
+ )
249
+ );
250
+ replaceRefs( styles );
251
+
252
+ return styles;
253
+ }
254
+
183
255
  function useBlockStyleVariation( name, variation, clientId ) {
184
256
  // Prefer global styles data in GlobalStylesContext, which are available
185
257
  // if in the site editor. Otherwise fall back to whatever is in the
@@ -194,9 +266,14 @@ function useBlockStyleVariation( name, variation, clientId ) {
194
266
  }, [] );
195
267
 
196
268
  return useMemo( () => {
197
- const styles = mergedConfig?.styles ?? globalStyles;
198
- const variationStyles =
199
- styles?.blocks?.[ name ]?.variations?.[ variation ];
269
+ const variationStyles = getVariationStylesWithRefValues(
270
+ {
271
+ settings: mergedConfig?.settings ?? globalSettings,
272
+ styles: mergedConfig?.styles ?? globalStyles,
273
+ },
274
+ name,
275
+ variation
276
+ );
200
277
 
201
278
  return {
202
279
  settings: mergedConfig?.settings ?? globalSettings,
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { getVariationStylesWithRefValues } from '../block-style-variation';
5
+
6
+ describe( 'getVariationStylesWithRefValues', () => {
7
+ it( 'should resolve ref values correctly', () => {
8
+ const globalStyles = {
9
+ styles: {
10
+ color: { background: 'red' },
11
+ blocks: {
12
+ 'core/heading': {
13
+ color: { text: 'blue' },
14
+ },
15
+ 'core/group': {
16
+ variations: {
17
+ custom: {
18
+ color: {
19
+ text: { ref: 'styles.does-not-exist' },
20
+ background: {
21
+ ref: 'styles.color.background',
22
+ },
23
+ },
24
+ blocks: {
25
+ 'core/heading': {
26
+ color: {
27
+ text: {
28
+ ref: 'styles.blocks.core/heading.color.text',
29
+ },
30
+ background: { ref: '' },
31
+ },
32
+ },
33
+ },
34
+ elements: {
35
+ link: {
36
+ color: {
37
+ text: {
38
+ ref: 'styles.elements.link.color.text',
39
+ },
40
+ background: { ref: undefined },
41
+ },
42
+ ':hover': {
43
+ color: {
44
+ text: {
45
+ ref: 'styles.elements.link.:hover.color.text',
46
+ },
47
+ },
48
+ },
49
+ },
50
+ },
51
+ },
52
+ },
53
+ },
54
+ },
55
+ elements: {
56
+ link: {
57
+ color: { text: 'green' },
58
+ ':hover': {
59
+ color: { text: 'yellow' },
60
+ },
61
+ },
62
+ },
63
+ },
64
+ };
65
+
66
+ expect(
67
+ getVariationStylesWithRefValues(
68
+ globalStyles,
69
+ 'core/group',
70
+ 'custom'
71
+ )
72
+ ).toEqual( {
73
+ color: { background: 'red' },
74
+ blocks: {
75
+ 'core/heading': {
76
+ color: { text: 'blue' },
77
+ },
78
+ },
79
+ elements: {
80
+ link: {
81
+ color: {
82
+ text: 'green',
83
+ },
84
+ ':hover': {
85
+ color: { text: 'yellow' },
86
+ },
87
+ },
88
+ },
89
+ } );
90
+ } );
91
+ } );
@@ -217,15 +217,23 @@ export default {
217
217
  const paddingValues = getCSSRules( style );
218
218
  paddingValues.forEach( ( rule ) => {
219
219
  if ( rule.key === 'paddingRight' ) {
220
+ // Add unit if 0, to avoid calc(0 * -1) which is invalid.
221
+ const paddingRightValue =
222
+ rule.value === '0' ? '0px' : rule.value;
223
+
220
224
  output += `
221
225
  ${ appendSelectors( selector, '> .alignfull' ) } {
222
- margin-right: calc(${ rule.value } * -1);
226
+ margin-right: calc(${ paddingRightValue } * -1);
223
227
  }
224
228
  `;
225
229
  } else if ( rule.key === 'paddingLeft' ) {
230
+ // Add unit if 0, to avoid calc(0 * -1) which is invalid.
231
+ const paddingLeftValue =
232
+ rule.value === '0' ? '0px' : rule.value;
233
+
226
234
  output += `
227
235
  ${ appendSelectors( selector, '> .alignfull' ) } {
228
- margin-left: calc(${ rule.value } * -1);
236
+ margin-left: calc(${ paddingLeftValue } * -1);
229
237
  }
230
238
  `;
231
239
  }