@wordpress/block-editor 13.0.2 → 13.0.3
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/use-global-styles-output.js +4 -3
- package/build/components/global-styles/use-global-styles-output.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/hooks/block-style-variation.js +4 -3
- package/build/hooks/block-style-variation.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/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/image-editor/aspect-ratio-dropdown.js +0 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build-module/hooks/block-style-variation.js +4 -3
- package/build-module/hooks/block-style-variation.js.map +1 -1
- package/package.json +7 -7
- package/src/components/block-toolbar/shuffle.js +3 -1
- package/src/components/global-styles/test/use-global-styles-output.js +38 -3
- package/src/components/global-styles/use-global-styles-output.js +4 -3
- package/src/components/image-editor/aspect-ratio-dropdown.js +0 -1
- package/src/hooks/block-style-variation.js +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["check","aspectRatio","aspectRatioIcon","DropdownMenu","MenuGroup","MenuItem","__","useSettings","POPOVER_PROPS","useImageEditingContext","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","AspectRatioGroup","aspectRatios","isDisabled","label","onClick","value","children","map","name","slug","ratio","disabled","role","isSelected","icon","undefined","ratioToNumber","str","a","b","rest","split","Number","isNaN","length","NaN","presetRatioAsNumber","AspectRatioDropdown","toggleProps","isInProgress","aspect","setAspect","defaultAspect","defaultRatios","themeRatios","showDefaultRatios","popoverProps","
|
|
1
|
+
{"version":3,"names":["check","aspectRatio","aspectRatioIcon","DropdownMenu","MenuGroup","MenuItem","__","useSettings","POPOVER_PROPS","useImageEditingContext","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","AspectRatioGroup","aspectRatios","isDisabled","label","onClick","value","children","map","name","slug","ratio","disabled","role","isSelected","icon","undefined","ratioToNumber","str","a","b","rest","split","Number","isNaN","length","NaN","presetRatioAsNumber","AspectRatioDropdown","toggleProps","isInProgress","aspect","setAspect","defaultAspect","defaultRatios","themeRatios","showDefaultRatios","popoverProps","onClose","newAspect","filter"],"sources":["@wordpress/block-editor/src/components/image-editor/aspect-ratio-dropdown.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { check, aspectRatio as aspectRatioIcon } from '@wordpress/icons';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../use-settings';\nimport { POPOVER_PROPS } from './constants';\nimport { useImageEditingContext } from './context';\n\nfunction AspectRatioGroup( {\n\taspectRatios,\n\tisDisabled,\n\tlabel,\n\tonClick,\n\tvalue,\n} ) {\n\treturn (\n\t\t<MenuGroup label={ label }>\n\t\t\t{ aspectRatios.map( ( { name, slug, ratio } ) => (\n\t\t\t\t<MenuItem\n\t\t\t\t\tkey={ slug }\n\t\t\t\t\tdisabled={ isDisabled }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonClick( ratio );\n\t\t\t\t\t} }\n\t\t\t\t\trole=\"menuitemradio\"\n\t\t\t\t\tisSelected={ ratio === value }\n\t\t\t\t\ticon={ ratio === value ? check : undefined }\n\t\t\t\t>\n\t\t\t\t\t{ name }\n\t\t\t\t</MenuItem>\n\t\t\t) ) }\n\t\t</MenuGroup>\n\t);\n}\n\nexport function ratioToNumber( str ) {\n\t// TODO: support two-value aspect ratio?\n\t// https://css-tricks.com/almanac/properties/a/aspect-ratio/#aa-it-can-take-two-values\n\tconst [ a, b, ...rest ] = str.split( '/' ).map( Number );\n\tif (\n\t\ta <= 0 ||\n\t\tb <= 0 ||\n\t\tNumber.isNaN( a ) ||\n\t\tNumber.isNaN( b ) ||\n\t\trest.length\n\t) {\n\t\treturn NaN;\n\t}\n\treturn b ? a / b : a;\n}\n\nfunction presetRatioAsNumber( { ratio, ...rest } ) {\n\treturn {\n\t\tratio: ratioToNumber( ratio ),\n\t\t...rest,\n\t};\n}\n\nexport default function AspectRatioDropdown( { toggleProps } ) {\n\tconst { isInProgress, aspect, setAspect, defaultAspect } =\n\t\tuseImageEditingContext();\n\n\tconst [ defaultRatios, themeRatios, showDefaultRatios ] = useSettings(\n\t\t'dimensions.aspectRatios.default',\n\t\t'dimensions.aspectRatios.theme',\n\t\t'dimensions.defaultAspectRatios'\n\t);\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\ticon={ aspectRatioIcon }\n\t\t\tlabel={ __( 'Aspect Ratio' ) }\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\ttoggleProps={ toggleProps }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<AspectRatioGroup\n\t\t\t\t\t\tisDisabled={ isInProgress }\n\t\t\t\t\t\tonClick={ ( newAspect ) => {\n\t\t\t\t\t\t\tsetAspect( newAspect );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tvalue={ aspect }\n\t\t\t\t\t\taspectRatios={ [\n\t\t\t\t\t\t\t// All ratios should be mirrored in AspectRatioTool in @wordpress/block-editor.\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tslug: 'original',\n\t\t\t\t\t\t\t\tname: __( 'Original' ),\n\t\t\t\t\t\t\t\taspect: defaultAspect,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t...( showDefaultRatios\n\t\t\t\t\t\t\t\t? defaultRatios\n\t\t\t\t\t\t\t\t\t\t.map( presetRatioAsNumber )\n\t\t\t\t\t\t\t\t\t\t.filter( ( { ratio } ) => ratio === 1 )\n\t\t\t\t\t\t\t\t: [] ),\n\t\t\t\t\t\t] }\n\t\t\t\t\t/>\n\t\t\t\t\t{ themeRatios?.length > 0 && (\n\t\t\t\t\t\t<AspectRatioGroup\n\t\t\t\t\t\t\tlabel={ __( 'Theme' ) }\n\t\t\t\t\t\t\tisDisabled={ isInProgress }\n\t\t\t\t\t\t\tonClick={ ( newAspect ) => {\n\t\t\t\t\t\t\t\tsetAspect( newAspect );\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tvalue={ aspect }\n\t\t\t\t\t\t\taspectRatios={ themeRatios }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ showDefaultRatios && (\n\t\t\t\t\t\t<AspectRatioGroup\n\t\t\t\t\t\t\tlabel={ __( 'Landscape' ) }\n\t\t\t\t\t\t\tisDisabled={ isInProgress }\n\t\t\t\t\t\t\tonClick={ ( newAspect ) => {\n\t\t\t\t\t\t\t\tsetAspect( newAspect );\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tvalue={ aspect }\n\t\t\t\t\t\t\taspectRatios={ defaultRatios\n\t\t\t\t\t\t\t\t.map( presetRatioAsNumber )\n\t\t\t\t\t\t\t\t.filter( ( { ratio } ) => ratio > 1 ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ showDefaultRatios && (\n\t\t\t\t\t\t<AspectRatioGroup\n\t\t\t\t\t\t\tlabel={ __( 'Portrait' ) }\n\t\t\t\t\t\t\tisDisabled={ isInProgress }\n\t\t\t\t\t\t\tonClick={ ( newAspect ) => {\n\t\t\t\t\t\t\t\tsetAspect( newAspect );\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tvalue={ aspect }\n\t\t\t\t\t\t\taspectRatios={ defaultRatios\n\t\t\t\t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AM;UAC1BP,SAAS,CAAEO,SAAU,CAAC;UACtBD,OAAO,CAAC,CAAC;QACV,CAAG;QACHhC,KAAK,EAAGyB,MAAQ;QAChB7B,YAAY,EAAGgC,aAAa,CAC1B1B,GAAG,CAAEmB,mBAAoB,CAAC,CAC1Ba,MAAM,CAAE,CAAE;UAAE7B;QAAM,CAAC,KAAMA,KAAK,GAAG,CAAE;MAAG,CACxC,CACD;IAAA,CACA;EACF,CACY,CAAC;AAEjB","ignoreList":[]}
|
|
@@ -119,14 +119,15 @@ function useBlockProps({
|
|
|
119
119
|
const hasBlockGapSupport = false;
|
|
120
120
|
const hasFallbackGapSupport = true;
|
|
121
121
|
const disableLayoutStyles = true;
|
|
122
|
-
const
|
|
123
|
-
return toStyles(variationConfig, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport, disableLayoutStyles,
|
|
122
|
+
const disableRootPadding = true;
|
|
123
|
+
return toStyles(variationConfig, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport, disableLayoutStyles, disableRootPadding, {
|
|
124
124
|
blockGap: false,
|
|
125
125
|
blockStyles: true,
|
|
126
126
|
layoutStyles: false,
|
|
127
127
|
marginReset: false,
|
|
128
128
|
presets: false,
|
|
129
|
-
rootPadding: false
|
|
129
|
+
rootPadding: false,
|
|
130
|
+
variationStyles: true
|
|
130
131
|
});
|
|
131
132
|
}, [variation, settings, styles, getBlockStyles, clientId]);
|
|
132
133
|
useStyleOverride({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getBlockTypes","store","blocksStore","useSelect","useContext","useMemo","GlobalStylesContext","toStyles","getBlockSelectors","useStyleOverride","blockEditorStore","globalStylesDataKey","VARIATION_PREFIX","getVariationMatches","className","split","reduce","matches","name","startsWith","match","slice","length","push","getVariationNameFromClass","registeredStyles","variation","some","style","useBlockSyleVariation","clientId","merged","mergedConfig","globalSettings","globalStyles","select","settings","getSettings","__experimentalFeatures","_mergedConfig$styles","_mergedConfig$setting","styles","variationStyles","blocks","variations","useBlockProps","getBlockStyles","variationClass","variationConfig","blockSelectors","hasBlockGapSupport","hasFallbackGapSupport","disableLayoutStyles","
|
|
1
|
+
{"version":3,"names":["getBlockTypes","store","blocksStore","useSelect","useContext","useMemo","GlobalStylesContext","toStyles","getBlockSelectors","useStyleOverride","blockEditorStore","globalStylesDataKey","VARIATION_PREFIX","getVariationMatches","className","split","reduce","matches","name","startsWith","match","slice","length","push","getVariationNameFromClass","registeredStyles","variation","some","style","useBlockSyleVariation","clientId","merged","mergedConfig","globalSettings","globalStyles","select","settings","getSettings","__experimentalFeatures","_mergedConfig$styles","_mergedConfig$setting","styles","variationStyles","blocks","variations","useBlockProps","getBlockStyles","variationClass","variationConfig","blockSelectors","hasBlockGapSupport","hasFallbackGapSupport","disableLayoutStyles","disableRootPadding","blockGap","blockStyles","layoutStyles","marginReset","presets","rootPadding","id","css","__unstableType","hasSupport","attributeKeys","isMatch"],"sources":["@wordpress/block-editor/src/hooks/block-style-variation.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockTypes, store as blocksStore } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { useContext, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tGlobalStylesContext,\n\ttoStyles,\n\tgetBlockSelectors,\n} from '../components/global-styles';\nimport { useStyleOverride } from './utils';\nimport { store as blockEditorStore } from '../store';\nimport { globalStylesDataKey } from '../store/private-keys';\n\nconst VARIATION_PREFIX = 'is-style-';\n\nfunction getVariationMatches( className ) {\n\tif ( ! className ) {\n\t\treturn [];\n\t}\n\treturn className.split( /\\s+/ ).reduce( ( matches, name ) => {\n\t\tif ( name.startsWith( VARIATION_PREFIX ) ) {\n\t\t\tconst match = name.slice( VARIATION_PREFIX.length );\n\t\t\tif ( match !== 'default' ) {\n\t\t\t\tmatches.push( match );\n\t\t\t}\n\t\t}\n\t\treturn matches;\n\t}, [] );\n}\n\n/**\n * Get the first block style variation that has been registered from the class string.\n *\n * @param {string} className CSS class string for a block.\n * @param {Array} registeredStyles Currently registered block styles.\n *\n * @return {string|null} The name of the first registered variation.\n */\nfunction getVariationNameFromClass( className, registeredStyles = [] ) {\n\t// The global flag affects how capturing groups work in JS. So the regex\n\t// below will only return full CSS classes not just the variation name.\n\tconst matches = getVariationMatches( className );\n\n\tif ( ! matches ) {\n\t\treturn null;\n\t}\n\n\tfor ( const variation of matches ) {\n\t\tif ( registeredStyles.some( ( style ) => style.name === variation ) ) {\n\t\t\treturn variation;\n\t\t}\n\t}\n\treturn null;\n}\n\nfunction useBlockSyleVariation( name, variation, clientId ) {\n\t// Prefer global styles data in GlobalStylesContext, which are available\n\t// if in the site editor. Otherwise fall back to whatever is in the\n\t// editor settings and available in the post editor.\n\tconst { merged: mergedConfig } = useContext( GlobalStylesContext );\n\tconst { globalSettings, globalStyles } = useSelect( ( select ) => {\n\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t\tglobalSettings: settings.__experimentalFeatures,\n\t\t\tglobalStyles: settings[ globalStylesDataKey ],\n\t\t};\n\t}, [] );\n\n\treturn useMemo( () => {\n\t\tconst styles = mergedConfig?.styles ?? globalStyles;\n\t\tconst variationStyles =\n\t\t\tstyles?.blocks?.[ name ]?.variations?.[ variation ];\n\n\t\treturn {\n\t\t\tsettings: mergedConfig?.settings ?? globalSettings,\n\t\t\t// The variation style data is all that is needed to generate\n\t\t\t// the styles for the current application to a block. The variation\n\t\t\t// name is updated to match the instance specific class name.\n\t\t\tstyles: {\n\t\t\t\tblocks: {\n\t\t\t\t\t[ name ]: {\n\t\t\t\t\t\tvariations: {\n\t\t\t\t\t\t\t[ `${ variation }-${ clientId }` ]: variationStyles,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}, [\n\t\tmergedConfig,\n\t\tglobalSettings,\n\t\tglobalStyles,\n\t\tvariation,\n\t\tclientId,\n\t\tname,\n\t] );\n}\n\n// Rather than leveraging `useInstanceId` here, the `clientId` is used.\n// This is so that the variation style override's ID is predictable\n// when the order of applied style variations changes.\nfunction useBlockProps( { name, className, clientId } ) {\n\tconst { getBlockStyles } = useSelect( blocksStore );\n\n\tconst registeredStyles = getBlockStyles( name );\n\tconst variation = getVariationNameFromClass( className, registeredStyles );\n\tconst variationClass = `${ VARIATION_PREFIX }${ variation }-${ clientId }`;\n\n\tconst { settings, styles } = useBlockSyleVariation(\n\t\tname,\n\t\tvariation,\n\t\tclientId\n\t);\n\n\tconst variationStyles = useMemo( () => {\n\t\tif ( ! variation ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst variationConfig = { settings, styles };\n\t\tconst blockSelectors = getBlockSelectors(\n\t\t\tgetBlockTypes(),\n\t\t\tgetBlockStyles,\n\t\t\tclientId\n\t\t);\n\t\tconst hasBlockGapSupport = false;\n\t\tconst hasFallbackGapSupport = true;\n\t\tconst disableLayoutStyles = true;\n\t\tconst disableRootPadding = true;\n\n\t\treturn toStyles(\n\t\t\tvariationConfig,\n\t\t\tblockSelectors,\n\t\t\thasBlockGapSupport,\n\t\t\thasFallbackGapSupport,\n\t\t\tdisableLayoutStyles,\n\t\t\tdisableRootPadding,\n\t\t\t{\n\t\t\t\tblockGap: false,\n\t\t\t\tblockStyles: true,\n\t\t\t\tlayoutStyles: false,\n\t\t\t\tmarginReset: false,\n\t\t\t\tpresets: false,\n\t\t\t\trootPadding: false,\n\t\t\t\tvariationStyles: true,\n\t\t\t}\n\t\t);\n\t}, [ variation, settings, styles, getBlockStyles, clientId ] );\n\n\tuseStyleOverride( {\n\t\tid: `variation-${ clientId }`,\n\t\tcss: variationStyles,\n\t\t__unstableType: 'variation',\n\t\t// The clientId will be stored with the override and used to ensure\n\t\t// the order of overrides matches the order of blocks so that the\n\t\t// correct CSS cascade is maintained.\n\t\tclientId,\n\t} );\n\n\treturn variation ? { className: variationClass } : {};\n}\n\nexport default {\n\thasSupport: () => true,\n\tattributeKeys: [ 'className' ],\n\tisMatch: ( { className } ) =>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AAM,EAAEK,cAAc,EAAEhB,QAAQ,CAAG,CAAC;EAE9DrB,gBAAgB,CAAE;IACjBmD,EAAE,EAAG,aAAa9B,QAAU,EAAC;IAC7B+B,GAAG,EAAEnB,eAAe;IACpBoB,cAAc,EAAE,WAAW;IAC3B;IACA;IACA;IACAhC;EACD,CAAE,CAAC;EAEH,OAAOJ,SAAS,GAAG;IAAEZ,SAAS,EAAEiC;EAAe,CAAC,GAAG,CAAC,CAAC;AACtD;AAEA,eAAe;EACdgB,UAAU,EAAEA,CAAA,KAAM,IAAI;EACtBC,aAAa,EAAE,CAAE,WAAW,CAAE;EAC9BC,OAAO,EAAEA,CAAE;IAAEnD;EAAU,CAAC,KAAMD,mBAAmB,CAAEC,SAAU,CAAC,CAACQ,MAAM,GAAG,CAAC;EACzEuB;AACD,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.3",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"@wordpress/a11y": "^4.0.1",
|
|
40
40
|
"@wordpress/api-fetch": "^7.0.1",
|
|
41
41
|
"@wordpress/blob": "^4.0.1",
|
|
42
|
-
"@wordpress/blocks": "^13.0.
|
|
43
|
-
"@wordpress/commands": "^1.0.
|
|
44
|
-
"@wordpress/components": "^28.0.
|
|
42
|
+
"@wordpress/blocks": "^13.0.3",
|
|
43
|
+
"@wordpress/commands": "^1.0.3",
|
|
44
|
+
"@wordpress/components": "^28.0.3",
|
|
45
45
|
"@wordpress/compose": "^7.0.1",
|
|
46
46
|
"@wordpress/data": "^10.0.2",
|
|
47
47
|
"@wordpress/date": "^5.0.1",
|
|
@@ -52,12 +52,12 @@
|
|
|
52
52
|
"@wordpress/hooks": "^4.0.1",
|
|
53
53
|
"@wordpress/html-entities": "^4.0.1",
|
|
54
54
|
"@wordpress/i18n": "^5.0.1",
|
|
55
|
-
"@wordpress/icons": "^10.0.
|
|
55
|
+
"@wordpress/icons": "^10.0.2",
|
|
56
56
|
"@wordpress/is-shallow-equal": "^5.0.1",
|
|
57
57
|
"@wordpress/keyboard-shortcuts": "^5.0.2",
|
|
58
58
|
"@wordpress/keycodes": "^4.0.1",
|
|
59
59
|
"@wordpress/notices": "^5.0.2",
|
|
60
|
-
"@wordpress/preferences": "^4.0.
|
|
60
|
+
"@wordpress/preferences": "^4.0.3",
|
|
61
61
|
"@wordpress/private-apis": "^1.0.2",
|
|
62
62
|
"@wordpress/rich-text": "^7.0.2",
|
|
63
63
|
"@wordpress/style-engine": "^2.0.2",
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"publishConfig": {
|
|
87
87
|
"access": "public"
|
|
88
88
|
},
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "9dd5f8dcfa4fc7242e5d48be20ee789ad087b432"
|
|
90
90
|
}
|
|
@@ -60,7 +60,9 @@ export default function Shuffle( { clientId, as = Container } ) {
|
|
|
60
60
|
pattern.blocks.length === 1 &&
|
|
61
61
|
pattern.categories?.some( ( category ) => {
|
|
62
62
|
return categories.includes( category );
|
|
63
|
-
} )
|
|
63
|
+
} ) &&
|
|
64
|
+
// Check if the pattern is not a synced pattern.
|
|
65
|
+
( pattern.syncStatus === 'unsynced' || ! pattern.id )
|
|
64
66
|
);
|
|
65
67
|
} );
|
|
66
68
|
}, [ categories, patterns ] );
|
|
@@ -565,9 +565,44 @@ describe( 'global styles renderer', () => {
|
|
|
565
565
|
},
|
|
566
566
|
};
|
|
567
567
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
568
|
+
const hasBlockGapSupport = false;
|
|
569
|
+
const hasFallbackGapSupport = true;
|
|
570
|
+
const disableLayoutStyles = true;
|
|
571
|
+
const disableRootPadding = true;
|
|
572
|
+
const styleOptions = {
|
|
573
|
+
blockGap: false,
|
|
574
|
+
blockStyles: true,
|
|
575
|
+
layoutStyles: false,
|
|
576
|
+
marginReset: false,
|
|
577
|
+
presets: false,
|
|
578
|
+
rootPadding: false,
|
|
579
|
+
};
|
|
580
|
+
|
|
581
|
+
// Confirm no variation styles by default.
|
|
582
|
+
const withoutVariations = toStyles(
|
|
583
|
+
Object.freeze( tree ),
|
|
584
|
+
blockSelectors,
|
|
585
|
+
hasBlockGapSupport,
|
|
586
|
+
hasFallbackGapSupport,
|
|
587
|
+
disableLayoutStyles,
|
|
588
|
+
disableRootPadding,
|
|
589
|
+
styleOptions
|
|
590
|
+
);
|
|
591
|
+
expect( withoutVariations ).toEqual( '' );
|
|
592
|
+
|
|
593
|
+
// Includes variation styles when requested.
|
|
594
|
+
styleOptions.variationStyles = true;
|
|
595
|
+
const withVariations = toStyles(
|
|
596
|
+
Object.freeze( tree ),
|
|
597
|
+
blockSelectors,
|
|
598
|
+
hasBlockGapSupport,
|
|
599
|
+
hasFallbackGapSupport,
|
|
600
|
+
disableLayoutStyles,
|
|
601
|
+
disableRootPadding,
|
|
602
|
+
styleOptions
|
|
603
|
+
);
|
|
604
|
+
expect( withVariations ).toEqual(
|
|
605
|
+
':root :where(.is-style-foo.wp-image.wp-image-spacing){padding-top: 2px;}:root :where(.is-style-foo.wp-image.wp-image-border-color){border-color: blue;}:root :where(.is-style-foo.wp-image){color: blue;}'
|
|
571
606
|
);
|
|
572
607
|
} );
|
|
573
608
|
|
|
@@ -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 =
|
|
@@ -132,7 +132,7 @@ function useBlockProps( { name, className, clientId } ) {
|
|
|
132
132
|
const hasBlockGapSupport = false;
|
|
133
133
|
const hasFallbackGapSupport = true;
|
|
134
134
|
const disableLayoutStyles = true;
|
|
135
|
-
const
|
|
135
|
+
const disableRootPadding = true;
|
|
136
136
|
|
|
137
137
|
return toStyles(
|
|
138
138
|
variationConfig,
|
|
@@ -140,7 +140,7 @@ function useBlockProps( { name, className, clientId } ) {
|
|
|
140
140
|
hasBlockGapSupport,
|
|
141
141
|
hasFallbackGapSupport,
|
|
142
142
|
disableLayoutStyles,
|
|
143
|
-
|
|
143
|
+
disableRootPadding,
|
|
144
144
|
{
|
|
145
145
|
blockGap: false,
|
|
146
146
|
blockStyles: true,
|
|
@@ -148,6 +148,7 @@ function useBlockProps( { name, className, clientId } ) {
|
|
|
148
148
|
marginReset: false,
|
|
149
149
|
presets: false,
|
|
150
150
|
rootPadding: false,
|
|
151
|
+
variationStyles: true,
|
|
151
152
|
}
|
|
152
153
|
);
|
|
153
154
|
}, [ variation, settings, styles, getBlockStyles, clientId ] );
|