@wordpress/block-editor 8.5.5 → 8.5.8
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/iframe/index.js +51 -50
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/media-placeholder/index.js +0 -2
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +0 -2
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/warning/index.js +6 -1
- package/build/components/warning/index.js.map +1 -1
- package/build/hooks/dimensions.js +14 -4
- package/build/hooks/dimensions.js.map +1 -1
- package/build/layouts/flex.js +5 -2
- package/build/layouts/flex.js.map +1 -1
- package/build-module/components/iframe/index.js +52 -51
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +0 -2
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +0 -2
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/warning/index.js +6 -1
- package/build-module/components/warning/index.js.map +1 -1
- package/build-module/hooks/dimensions.js +14 -4
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/layouts/flex.js +4 -2
- package/build-module/layouts/flex.js.map +1 -1
- package/package.json +2 -2
- package/src/components/iframe/index.js +62 -54
- package/src/components/media-placeholder/index.js +0 -2
- package/src/components/media-replace-flow/index.js +0 -2
- package/src/components/warning/index.js +47 -42
- package/src/components/warning/test/__snapshots__/index.js.snap +15 -6
- package/src/components/warning/test/index.js +1 -1
- package/src/hooks/dimensions.js +11 -3
- package/src/layouts/flex.js +11 -3
|
@@ -107,7 +107,7 @@ const useIsDimensionsDisabled = function () {
|
|
|
107
107
|
return gapDisabled && paddingDisabled && marginDisabled;
|
|
108
108
|
};
|
|
109
109
|
/**
|
|
110
|
-
* Custom hook to retrieve which padding/margin is supported
|
|
110
|
+
* Custom hook to retrieve which padding/margin/blockGap is supported
|
|
111
111
|
* e.g. top, right, bottom or left.
|
|
112
112
|
*
|
|
113
113
|
* Sides are opted into by default. It is only if a specific side is set to
|
|
@@ -116,18 +116,28 @@ const useIsDimensionsDisabled = function () {
|
|
|
116
116
|
* @param {string} blockName Block name.
|
|
117
117
|
* @param {string} feature The feature custom sides relate to e.g. padding or margins.
|
|
118
118
|
*
|
|
119
|
-
* @return {
|
|
119
|
+
* @return {?string[]} Strings representing the custom sides available.
|
|
120
120
|
*/
|
|
121
121
|
|
|
122
122
|
|
|
123
123
|
export function useCustomSides(blockName, feature) {
|
|
124
|
+
var _support$feature;
|
|
125
|
+
|
|
124
126
|
const support = getBlockSupport(blockName, SPACING_SUPPORT_KEY); // Skip when setting is boolean as theme isn't setting arbitrary sides.
|
|
125
127
|
|
|
126
128
|
if (!support || typeof support[feature] === 'boolean') {
|
|
127
129
|
return;
|
|
128
|
-
}
|
|
130
|
+
} // Return if the setting is an array of sides (e.g. `[ 'top', 'bottom' ]`).
|
|
131
|
+
|
|
129
132
|
|
|
130
|
-
|
|
133
|
+
if (Array.isArray(support[feature])) {
|
|
134
|
+
return support[feature];
|
|
135
|
+
} // Finally, attempt to return `.sides` if the setting is an object.
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
if ((_support$feature = support[feature]) !== null && _support$feature !== void 0 && _support$feature.sides) {
|
|
139
|
+
return support[feature].sides;
|
|
140
|
+
}
|
|
131
141
|
}
|
|
132
142
|
/**
|
|
133
143
|
* Custom hook to determine whether the sides configured in the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/dimensions.js"],"names":["__experimentalToolsPanelItem","ToolsPanelItem","Platform","__","getBlockSupport","InspectorControls","GapEdit","hasGapSupport","hasGapValue","resetGap","useIsGapDisabled","MarginEdit","hasMarginSupport","hasMarginValue","resetMargin","useIsMarginDisabled","PaddingEdit","hasPaddingSupport","hasPaddingValue","resetPadding","useIsPaddingDisabled","SPACING_SUPPORT_KEY","ALL_SIDES","AXIAL_SIDES","DimensionsPanel","props","isGapDisabled","isPaddingDisabled","isMarginDisabled","isDisabled","useIsDimensionsDisabled","isSupported","hasDimensionsSupport","name","defaultSpacingControls","createResetAllFilter","attribute","newAttributes","style","spacing","undefined","padding","clientId","margin","blockGap","blockName","OS","gapDisabled","paddingDisabled","marginDisabled","useCustomSides","feature","support","useIsDimensionsSupportValid","sides","some","side","includes","console","warn"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,4BAA4B,IAAIC,cAAzC,QAA+D,uBAA/D;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,eAAT,QAAgC,mBAAhC;AAEA;AACA;AACA;;AACA,OAAOC,iBAAP,MAA8B,kCAA9B;AACA,SACCC,OADD,EAECC,aAFD,EAGCC,WAHD,EAICC,QAJD,EAKCC,gBALD,QAMO,OANP;AAOA,SACCC,UADD,EAECC,gBAFD,EAGCC,cAHD,EAICC,WAJD,EAKCC,mBALD,QAMO,UANP;AAOA,SACCC,WADD,EAECC,iBAFD,EAGCC,eAHD,EAICC,YAJD,EAKCC,oBALD,QAMO,WANP;AAQA,OAAO,MAAMC,mBAAmB,GAAG,SAA5B;AACP,OAAO,MAAMC,SAAS,GAAG,CAAE,KAAF,EAAS,OAAT,EAAkB,QAAlB,EAA4B,MAA5B,CAAlB;AACP,OAAO,MAAMC,WAAW,GAAG,CAAE,UAAF,EAAc,YAAd,CAApB;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,eAAT,CAA0BC,KAA1B,EAAkC;AACxC,QAAMC,aAAa,GAAGhB,gBAAgB,CAAEe,KAAF,CAAtC;AACA,QAAME,iBAAiB,GAAGP,oBAAoB,CAAEK,KAAF,CAA9C;AACA,QAAMG,gBAAgB,GAAGb,mBAAmB,CAAEU,KAAF,CAA5C;AACA,QAAMI,UAAU,GAAGC,uBAAuB,CAAEL,KAAF,CAA1C;AACA,QAAMM,WAAW,GAAGC,oBAAoB,CAAEP,KA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kCC,cAAzC;AACA,CAND;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASC,cAAT,CAAyBL,SAAzB,EAAoCM,OAApC,EAA8C;AACpD,QAAMC,OAAO,GAAGhD,eAAe,CAAEyC,SAAF,EAAaxB,mBAAb,CAA/B,CADoD,CAGpD;;AACA,MAAK,CAAE+B,OAAF,IAAa,OAAOA,OAAO,CAAED,OAAF,CAAd,KAA8B,SAAhD,EAA4D;AAC3D;AACA;;AAED,SAAOC,OAAO,CAAED,OAAF,CAAd;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,2BAAT,CAAsCR,SAAtC,EAAiDM,OAAjD,EAA2D;AACjE,QAAMG,KAAK,GAAGJ,cAAc,CAAEL,SAAF,EAAaM,OAAb,CAA5B;;AAEA,MACCG,KAAK,IACLA,KAAK,CAACC,IAAN,CAAcC,IAAF,IAAYlC,SAAS,CAACmC,QAAV,CAAoBD,IAApB,CAAxB,CADA,IAEAF,KAAK,CAACC,IAAN,CAAcC,IAAF,IAAYjC,WAAW,CAACkC,QAAZ,CAAsBD,IAAtB,CAAxB,CAHD,EAIE;AACD;AACAE,IAAAA,OAAO,CAACC,IAAR,CACE,OAAOR,OAAS,qBAAqBN,SAAW,0EADlD;AAGA,WAAO,KAAP;AACA;;AAED,SAAO,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';\nimport { Platform } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { getBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport {\n\tGapEdit,\n\thasGapSupport,\n\thasGapValue,\n\tresetGap,\n\tuseIsGapDisabled,\n} from './gap';\nimport {\n\tMarginEdit,\n\thasMarginSupport,\n\thasMarginValue,\n\tresetMargin,\n\tuseIsMarginDisabled,\n} from './margin';\nimport {\n\tPaddingEdit,\n\thasPaddingSupport,\n\thasPaddingValue,\n\tresetPadding,\n\tuseIsPaddingDisabled,\n} from './padding';\n\nexport const SPACING_SUPPORT_KEY = 'spacing';\nexport const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];\nexport const AXIAL_SIDES = [ 'vertical', 'horizontal' ];\n\n/**\n * Inspector controls for dimensions support.\n *\n * @param {Object} props Block props.\n *\n * @return {WPElement} Inspector controls for spacing support features.\n */\nexport function DimensionsPanel( props ) {\n\tconst isGapDisabled = useIsGapDisabled( props );\n\tconst isPaddingDisabled = useIsPaddingDisabled( props );\n\tconst isMarginDisabled = useIsMarginDisabled( props );\n\tconst isDisabled = useIsDimensionsDisabled( props );\n\tconst isSupported = hasDimensionsSupport( props.name );\n\n\tif ( isDisabled || ! isSupported ) {\n\t\treturn null;\n\t}\n\n\tconst defaultSpacingControls = getBlockSupport( props.name, [\n\t\tSPACING_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\tconst createResetAllFilter = ( attribute ) => ( newAttributes ) => ( {\n\t\t...newAttributes,\n\t\tstyle: {\n\t\t\t...newAttributes.style,\n\t\t\tspacing: {\n\t\t\t\t...newAttributes.style?.spacing,\n\t\t\t\t[ attribute ]: undefined,\n\t\t\t},\n\t\t},\n\t} );\n\n\treturn (\n\t\t<InspectorControls __experimentalGroup=\"dimensions\">\n\t\t\t{ ! isPaddingDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasPaddingValue( props ) }\n\t\t\t\t\tlabel={ __( 'Padding' ) }\n\t\t\t\t\tonDeselect={ () => resetPadding( props ) }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'padding' ) }\n\t\t\t\t\tisShownByDefault={ defaultSpacingControls?.padding }\n\t\t\t\t\tpanelId={ props.clientId }\n\t\t\t\t>\n\t\t\t\t\t<PaddingEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ ! isMarginDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasMarginValue( props ) }\n\t\t\t\t\tlabel={ __( 'Margin' ) }\n\t\t\t\t\tonDeselect={ () => resetMargin( props ) }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'margin' ) }\n\t\t\t\t\tisShownByDefault={ defaultSpacingControls?.margin }\n\t\t\t\t\tpanelId={ props.clientId }\n\t\t\t\t>\n\t\t\t\t\t<MarginEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ ! isGapDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasGapValue( props ) }\n\t\t\t\t\tlabel={ __( 'Block spacing' ) }\n\t\t\t\t\tonDeselect={ () => resetGap( props ) }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'blockGap' ) }\n\t\t\t\t\tisShownByDefault={ defaultSpacingControls?.blockGap }\n\t\t\t\t\tpanelId={ props.clientId }\n\t\t\t\t>\n\t\t\t\t\t<GapEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</InspectorControls>\n\t);\n}\n\n/**\n * Determine whether there is dimensions related block support.\n *\n * @param {string} blockName Block name.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasDimensionsSupport( blockName ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\thasGapSupport( blockName ) ||\n\t\thasPaddingSupport( blockName ) ||\n\t\thasMarginSupport( blockName )\n\t);\n}\n\n/**\n * Determines whether dimensions support has been disabled.\n *\n * @param {Object} props Block properties.\n *\n * @return {boolean} If spacing support is completely disabled.\n */\nconst useIsDimensionsDisabled = ( props = {} ) => {\n\tconst gapDisabled = useIsGapDisabled( props );\n\tconst paddingDisabled = useIsPaddingDisabled( props );\n\tconst marginDisabled = useIsMarginDisabled( props );\n\n\treturn gapDisabled && paddingDisabled && marginDisabled;\n};\n\n/**\n * Custom hook to retrieve which padding/margin is supported\n * e.g. top, right, bottom or left.\n *\n * Sides are opted into by default. It is only if a specific side is set to\n * false that it is omitted.\n *\n * @param {string} blockName Block name.\n * @param {string} feature The feature custom sides relate to e.g. padding or margins.\n *\n * @return {Object} Sides supporting custom margin.\n */\nexport function useCustomSides( blockName, feature ) {\n\tconst support = getBlockSupport( blockName, SPACING_SUPPORT_KEY );\n\n\t// Skip when setting is boolean as theme isn't setting arbitrary sides.\n\tif ( ! support || typeof support[ feature ] === 'boolean' ) {\n\t\treturn;\n\t}\n\n\treturn support[ feature ];\n}\n\n/**\n * Custom hook to determine whether the sides configured in the\n * block support are valid. A dimension property cannot declare\n * support for a mix of axial and individual sides.\n *\n * @param {string} blockName Block name.\n * @param {string} feature The feature custom sides relate to e.g. padding or margins.\n *\n * @return {boolean} If the feature has a valid configuration of sides.\n */\nexport function useIsDimensionsSupportValid( blockName, feature ) {\n\tconst sides = useCustomSides( blockName, feature );\n\n\tif (\n\t\tsides &&\n\t\tsides.some( ( side ) => ALL_SIDES.includes( side ) ) &&\n\t\tsides.some( ( side ) => AXIAL_SIDES.includes( side ) )\n\t) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn(\n\t\t\t`The ${ feature } support for the \"${ blockName }\" block can not be configured to support both axial and arbitrary sides.`\n\t\t);\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/dimensions.js"],"names":["__experimentalToolsPanelItem","ToolsPanelItem","Platform","__","getBlockSupport","InspectorControls","GapEdit","hasGapSupport","hasGapValue","resetGap","useIsGapDisabled","MarginEdit","hasMarginSupport","hasMarginValue","resetMargin","useIsMarginDisabled","PaddingEdit","hasPaddingSupport","hasPaddingValue","resetPadding","useIsPaddingDisabled","SPACING_SUPPORT_KEY","ALL_SIDES","AXIAL_SIDES","DimensionsPanel","props","isGapDisabled","isPaddingDisabled","isMarginDisabled","isDisabled","useIsDimensionsDisabled","isSupported","hasDimensionsSupport","name","defaultSpacingControls","createResetAllFilter","attribute","newAttributes","style","spacing","undefined","padding","clientId","margin","blockGap","blockName","OS","gapDisabled","paddingDisabled","marginDisabled","useCustomSides","feature","support","Array","isArray","sides","useIsDimensionsSupportValid","some","side","includes","console","warn"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,4BAA4B,IAAIC,cAAzC,QAA+D,uBAA/D;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,eAAT,QAAgC,mBAAhC;AAEA;AACA;AACA;;AACA,OAAOC,iBAAP,MAA8B,kCAA9B;AACA,SACCC,OADD,EAECC,aAFD,EAGCC,WAHD,EAICC,QAJD,EAKCC,gBALD,QAMO,OANP;AAOA,SACCC,UADD,EAECC,gBAFD,EAGCC,cAHD,EAICC,WAJD,EAKCC,mBALD,QAMO,UANP;AAOA,SACCC,WADD,EAECC,iBAFD,EAGCC,eAHD,EAICC,YAJD,EAKCC,oBALD,QAMO,WANP;AAQA,OAAO,MAAMC,mBAAmB,GAAG,SAA5B;AACP,OAAO,MAAMC,SAAS,GAAG,CAAE,KAAF,EAAS,OAAT,EAAkB,QAAlB,EAA4B,MAA5B,CAAlB;AACP,OAAO,MAAMC,WAAW,GAAG,CAAE,UAAF,EAAc,YAAd,CAApB;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,eAAT,CAA0BC,KAA1B,EAAkC;AACxC,QAAMC,aAAa,GAAGhB,gBAAgB,CAAEe,KAAF,CAAtC;AACA,QAAME,iBAAiB,GAAGP,oBAAoB,CAAEK,KAAF,CAA9C;AACA,QAAMG,gBAAgB,GAAGb,mBAAmB,CAAEU,KAAF,CAA5C;AACA,QAAMI,UAAU,GAAGC,uBAAuB,CAAEL,KAAF,CAA1C;AACA,QAAMM,WAAW,GAAGC,oBAAoB,CAAEP,KAAK,CAACQ,IAAR,CAAxC;;AAEA,M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AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASC,cAAT,CAAyBL,SAAzB,EAAoCM,OAApC,EAA8C;AAAA;;AACpD,QAAMC,OAAO,GAAGhD,eAAe,CAAEyC,SAAF,EAAaxB,mBAAb,CAA/B,CADoD,CAGpD;;AACA,MAAK,CAAE+B,OAAF,IAAa,OAAOA,OAAO,CAAED,OAAF,CAAd,KAA8B,SAAhD,EAA4D;AAC3D;AACA,GANmD,CAQpD;;;AACA,MAAKE,KAAK,CAACC,OAAN,CAAeF,OAAO,CAAED,OAAF,CAAtB,CAAL,EAA2C;AAC1C,WAAOC,OAAO,CAAED,OAAF,CAAd;AACA,GAXmD,CAapD;;;AACA,0BAAKC,OAAO,CAAED,OAAF,CAAZ,6CAAK,iBAAoBI,KAAzB,EAAiC;AAChC,WAAOH,OAAO,CAAED,OAAF,CAAP,CAAmBI,KAA1B;AACA;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,2BAAT,CAAsCX,SAAtC,EAAiDM,OAAjD,EAA2D;AACjE,QAAMI,KAAK,GAAGL,cAAc,CAAEL,SAAF,EAAaM,OAAb,CAA5B;;AAEA,MACCI,KAAK,IACLA,KAAK,CAACE,IAAN,CAAcC,IAAF,IAAYpC,SAAS,CAACqC,QAAV,CAAoBD,IAApB,CAAxB,CADA,IAEAH,KAAK,CAACE,IAAN,CAAcC,IAAF,IAAYnC,WAAW,CAACoC,QAAZ,CAAsBD,IAAtB,CAAxB,CAHD,EAIE;AACD;AACAE,IAAAA,OAAO,CAACC,IAAR,CACE,OAAOV,OAAS,qBAAqBN,SAAW,0EADlD;AAGA,WAAO,KAAP;AACA;;AAED,SAAO,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';\nimport { Platform } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { getBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport {\n\tGapEdit,\n\thasGapSupport,\n\thasGapValue,\n\tresetGap,\n\tuseIsGapDisabled,\n} from './gap';\nimport {\n\tMarginEdit,\n\thasMarginSupport,\n\thasMarginValue,\n\tresetMargin,\n\tuseIsMarginDisabled,\n} from './margin';\nimport {\n\tPaddingEdit,\n\thasPaddingSupport,\n\thasPaddingValue,\n\tresetPadding,\n\tuseIsPaddingDisabled,\n} from './padding';\n\nexport const SPACING_SUPPORT_KEY = 'spacing';\nexport const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];\nexport const AXIAL_SIDES = [ 'vertical', 'horizontal' ];\n\n/**\n * Inspector controls for dimensions support.\n *\n * @param {Object} props Block props.\n *\n * @return {WPElement} Inspector controls for spacing support features.\n */\nexport function DimensionsPanel( props ) {\n\tconst isGapDisabled = useIsGapDisabled( props );\n\tconst isPaddingDisabled = useIsPaddingDisabled( props );\n\tconst isMarginDisabled = useIsMarginDisabled( props );\n\tconst isDisabled = useIsDimensionsDisabled( props );\n\tconst isSupported = hasDimensionsSupport( props.name );\n\n\tif ( isDisabled || ! isSupported ) {\n\t\treturn null;\n\t}\n\n\tconst defaultSpacingControls = getBlockSupport( props.name, [\n\t\tSPACING_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\tconst createResetAllFilter = ( attribute ) => ( newAttributes ) => ( {\n\t\t...newAttributes,\n\t\tstyle: {\n\t\t\t...newAttributes.style,\n\t\t\tspacing: {\n\t\t\t\t...newAttributes.style?.spacing,\n\t\t\t\t[ attribute ]: undefined,\n\t\t\t},\n\t\t},\n\t} );\n\n\treturn (\n\t\t<InspectorControls __experimentalGroup=\"dimensions\">\n\t\t\t{ ! isPaddingDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasPaddingValue( props ) }\n\t\t\t\t\tlabel={ __( 'Padding' ) }\n\t\t\t\t\tonDeselect={ () => resetPadding( props ) }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'padding' ) }\n\t\t\t\t\tisShownByDefault={ defaultSpacingControls?.padding }\n\t\t\t\t\tpanelId={ props.clientId }\n\t\t\t\t>\n\t\t\t\t\t<PaddingEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ ! isMarginDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasMarginValue( props ) }\n\t\t\t\t\tlabel={ __( 'Margin' ) }\n\t\t\t\t\tonDeselect={ () => resetMargin( props ) }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'margin' ) }\n\t\t\t\t\tisShownByDefault={ defaultSpacingControls?.margin }\n\t\t\t\t\tpanelId={ props.clientId }\n\t\t\t\t>\n\t\t\t\t\t<MarginEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ ! isGapDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasGapValue( props ) }\n\t\t\t\t\tlabel={ __( 'Block spacing' ) }\n\t\t\t\t\tonDeselect={ () => resetGap( props ) }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'blockGap' ) }\n\t\t\t\t\tisShownByDefault={ defaultSpacingControls?.blockGap }\n\t\t\t\t\tpanelId={ props.clientId }\n\t\t\t\t>\n\t\t\t\t\t<GapEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</InspectorControls>\n\t);\n}\n\n/**\n * Determine whether there is dimensions related block support.\n *\n * @param {string} blockName Block name.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasDimensionsSupport( blockName ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\thasGapSupport( blockName ) ||\n\t\thasPaddingSupport( blockName ) ||\n\t\thasMarginSupport( blockName )\n\t);\n}\n\n/**\n * Determines whether dimensions support has been disabled.\n *\n * @param {Object} props Block properties.\n *\n * @return {boolean} If spacing support is completely disabled.\n */\nconst useIsDimensionsDisabled = ( props = {} ) => {\n\tconst gapDisabled = useIsGapDisabled( props );\n\tconst paddingDisabled = useIsPaddingDisabled( props );\n\tconst marginDisabled = useIsMarginDisabled( props );\n\n\treturn gapDisabled && paddingDisabled && marginDisabled;\n};\n\n/**\n * Custom hook to retrieve which padding/margin/blockGap is supported\n * e.g. top, right, bottom or left.\n *\n * Sides are opted into by default. It is only if a specific side is set to\n * false that it is omitted.\n *\n * @param {string} blockName Block name.\n * @param {string} feature The feature custom sides relate to e.g. padding or margins.\n *\n * @return {?string[]} Strings representing the custom sides available.\n */\nexport function useCustomSides( blockName, feature ) {\n\tconst support = getBlockSupport( blockName, SPACING_SUPPORT_KEY );\n\n\t// Skip when setting is boolean as theme isn't setting arbitrary sides.\n\tif ( ! support || typeof support[ feature ] === 'boolean' ) {\n\t\treturn;\n\t}\n\n\t// Return if the setting is an array of sides (e.g. `[ 'top', 'bottom' ]`).\n\tif ( Array.isArray( support[ feature ] ) ) {\n\t\treturn support[ feature ];\n\t}\n\n\t// Finally, attempt to return `.sides` if the setting is an object.\n\tif ( support[ feature ]?.sides ) {\n\t\treturn support[ feature ].sides;\n\t}\n}\n\n/**\n * Custom hook to determine whether the sides configured in the\n * block support are valid. A dimension property cannot declare\n * support for a mix of axial and individual sides.\n *\n * @param {string} blockName Block name.\n * @param {string} feature The feature custom sides relate to e.g. padding or margins.\n *\n * @return {boolean} If the feature has a valid configuration of sides.\n */\nexport function useIsDimensionsSupportValid( blockName, feature ) {\n\tconst sides = useCustomSides( blockName, feature );\n\n\tif (\n\t\tsides &&\n\t\tsides.some( ( side ) => ALL_SIDES.includes( side ) ) &&\n\t\tsides.some( ( side ) => AXIAL_SIDES.includes( side ) )\n\t) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn(\n\t\t\t`The ${ feature } support for the \"${ blockName }\" block can not be configured to support both axial and arbitrary sides.`\n\t\t);\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n"]}
|
|
@@ -6,6 +6,7 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
7
|
import { justifyLeft, justifyCenter, justifyRight, justifySpaceBetween, arrowRight, arrowDown } from '@wordpress/icons';
|
|
8
8
|
import { Button, ToggleControl, Flex, FlexItem } from '@wordpress/components';
|
|
9
|
+
import { getBlockSupport } from '@wordpress/blocks';
|
|
9
10
|
/**
|
|
10
11
|
* Internal dependencies
|
|
11
12
|
*/
|
|
@@ -97,10 +98,11 @@ export default {
|
|
|
97
98
|
orientation = 'horizontal'
|
|
98
99
|
} = layout;
|
|
99
100
|
const blockGapSupport = useSetting('spacing.blockGap');
|
|
101
|
+
const fallbackValue = getBlockSupport(blockName, ['spacing', 'blockGap', '__experimentalDefault']) || '0.5em';
|
|
100
102
|
const hasBlockGapStylesSupport = blockGapSupport !== null; // If a block's block.json skips serialization for spacing or spacing.blockGap,
|
|
101
103
|
// don't apply the user-defined value to the styles.
|
|
102
104
|
|
|
103
|
-
const blockGapValue = style !== null && style !== void 0 && (_style$spacing = style.spacing) !== null && _style$spacing !== void 0 && _style$spacing.blockGap && !shouldSkipSerialization(blockName, 'spacing', 'blockGap') ? getGapCSSValue(style === null || style === void 0 ? void 0 : (_style$spacing2 = style.spacing) === null || _style$spacing2 === void 0 ? void 0 : _style$spacing2.blockGap,
|
|
105
|
+
const blockGapValue = style !== null && style !== void 0 && (_style$spacing = style.spacing) !== null && _style$spacing !== void 0 && _style$spacing.blockGap && !shouldSkipSerialization(blockName, 'spacing', 'blockGap') ? getGapCSSValue(style === null || style === void 0 ? void 0 : (_style$spacing2 = style.spacing) === null || _style$spacing2 === void 0 ? void 0 : _style$spacing2.blockGap, fallbackValue) : `var( --wp--style--block-gap, ${fallbackValue} )`;
|
|
104
106
|
const justifyContent = justifyContentMap[layout.justifyContent] || justifyContentMap.left;
|
|
105
107
|
const flexWrap = flexWrapOptions.includes(layout.flexWrap) ? layout.flexWrap : 'wrap';
|
|
106
108
|
const verticalAlignment = verticalAlignmentMap[layout.verticalAlignment] || verticalAlignmentMap.center;
|
|
@@ -118,7 +120,7 @@ export default {
|
|
|
118
120
|
${appendSelectors(selector)} {
|
|
119
121
|
display: flex;
|
|
120
122
|
flex-wrap: ${flexWrap};
|
|
121
|
-
gap: ${hasBlockGapStylesSupport ? blockGapValue :
|
|
123
|
+
gap: ${hasBlockGapStylesSupport ? blockGapValue : fallbackValue};
|
|
122
124
|
${orientation === 'horizontal' ? rowOrientation : columnOrientation}
|
|
123
125
|
}
|
|
124
126
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/layouts/flex.js"],"names":["__","justifyLeft","justifyCenter","justifyRight","justifySpaceBetween","arrowRight","arrowDown","Button","ToggleControl","Flex","FlexItem","appendSelectors","getGapCSSValue","useSetting","BlockControls","JustifyContentControl","BlockVerticalAlignmentControl","shouldSkipSerialization","justifyContentMap","left","right","center","alignItemsMap","verticalAlignmentMap","top","bottom","flexWrapOptions","name","label","inspectorControls","FlexLayoutInspectorControls","layout","onChange","layoutBlockSupport","allowOrientation","toolBarControls","FlexLayoutToolbarControls","allowSwitching","allowVerticalAlignment","orientation","save","FlexLayoutStyle","selector","style","blockName","blockGapSupport","hasBlockGapStylesSupport","blockGapValue","spacing","blockGap","justifyContent","flexWrap","includes","verticalAlignment","rowOrientation","alignItems","columnOrientation","getOrientation","getAlignments","FlexLayoutVerticalAlignmentControl","isToolbar","onVerticalAlignmentChange","value","verticalAlignmentOptions","map","icon","FlexLayoutJustifyContentControl","onJustificationChange","allowedControls","push","position","isAlternate","justificationOptions","FlexWrapControl","OrientationControl"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SACCC,WADD,EAECC,aAFD,EAGCC,YAHD,EAICC,mBAJD,EAKCC,UALD,EAMCC,SAND,QAOO,kBAPP;AAQ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QAAQ,CAAE,EACT,GAAGD,MADM;AAEToB,QAAAA,QAAQ,EAAEW,KAAK,GAAG,MAAH,GAAY;AAFlB,OAAF,CAAR;AAIA,KAPF;AAQC,IAAA,OAAO,EAAGX,QAAQ,KAAK;AARxB,IADD;AAYA;;AAED,SAASuB,kBAAT,QAAoD;AAAA,MAAvB;AAAE3C,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAAuB;AACnD,QAAM;AAAEO,IAAAA,WAAW,GAAG;AAAhB,MAAiCR,MAAvC;AACA,SACC;AAAU,IAAA,SAAS,EAAC;AAApB,KACC,8BAAU/B,EAAE,CAAE,aAAF,CAAZ,CADD,EAEC,cAAC,MAAD;AACC,IAAA,KAAK,EAAG,YADT;AAEC,IAAA,IAAI,EAAGK,UAFR;AAGC,IAAA,SAAS,EAAGkC,WAAW,KAAK,YAH7B;AAIC,IAAA,OAAO,EAAG,MACTP,QAAQ,CAAE,EACT,GAAGD,MADM;AAETQ,MAAAA,WAAW,EAAE;AAFJ,KAAF;AALV,IAFD,EAaC,cAAC,MAAD;AACC,IAAA,KAAK,EAAG,UADT;AAEC,IAAA,IAAI,EAAGjC,SAFR;AAGC,IAAA,SAAS,EAAGiC,WAAW,KAAK,UAH7B;AAIC,IAAA,OAAO,EAAG,MACTP,QAAQ,CAAE,EACT,GAAGD,MADM;AAETQ,MAAAA,WAAW,EAAE;AAFJ,KAAF;AALV,IAbD,CADD;AA2BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tjustifyLeft,\n\tjustifyCenter,\n\tjustifyRight,\n\tjustifySpaceBetween,\n\tarrowRight,\n\tarrowDown,\n} from '@wordpress/icons';\nimport { Button, ToggleControl, Flex, FlexItem } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { appendSelectors } from './utils';\nimport { getGapCSSValue } from '../hooks/gap';\nimport useSetting from '../components/use-setting';\nimport {\n\tBlockControls,\n\tJustifyContentControl,\n\tBlockVerticalAlignmentControl,\n} from '../components';\nimport { shouldSkipSerialization } from '../hooks/utils';\n\n// Used with the default, horizontal flex orientation.\nconst justifyContentMap = {\n\tleft: 'flex-start',\n\tright: 'flex-end',\n\tcenter: 'center',\n\t'space-between': 'space-between',\n};\n\n// Used with the vertical (column) flex orientation.\nconst alignItemsMap = {\n\tleft: 'flex-start',\n\tright: 'flex-end',\n\tcenter: 'center',\n};\n\nconst verticalAlignmentMap = {\n\ttop: 'flex-start',\n\tcenter: 'center',\n\tbottom: 'flex-end',\n};\n\nconst flexWrapOptions = [ 'wrap', 'nowrap' ];\n\nexport default {\n\tname: 'flex',\n\tlabel: __( 'Flex' ),\n\tinspectorControls: function FlexLayoutInspectorControls( {\n\t\tlayout = {},\n\t\tonChange,\n\t\tlayoutBlockSupport = {},\n\t} ) {\n\t\tconst { allowOrientation = true } = layoutBlockSupport;\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<Flex>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<FlexLayoutJustifyContentControl\n\t\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t{ allowOrientation && (\n\t\t\t\t\t\t\t<OrientationControl\n\t\t\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t\t<FlexWrapControl layout={ layout } onChange={ onChange } />\n\t\t\t</>\n\t\t);\n\t},\n\ttoolBarControls: function FlexLayoutToolbarControls( {\n\t\tlayout = {},\n\t\tonChange,\n\t\tlayoutBlockSupport,\n\t} ) {\n\t\tif ( layoutBlockSupport?.allowSwitching ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst { allowVerticalAlignment = true } = layoutBlockSupport;\n\t\treturn (\n\t\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t\t<FlexLayoutJustifyContentControl\n\t\t\t\t\tlayout={ layout }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tisToolbar\n\t\t\t\t/>\n\t\t\t\t{ allowVerticalAlignment &&\n\t\t\t\t\tlayout?.orientation !== 'vertical' && (\n\t\t\t\t\t\t<FlexLayoutVerticalAlignmentControl\n\t\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tisToolbar\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t</BlockControls>\n\t\t);\n\t},\n\tsave: function FlexLayoutStyle( { selector, layout, style, blockName } ) {\n\t\tconst { orientation = 'horizontal' } = layout;\n\t\tconst blockGapSupport = useSetting( 'spacing.blockGap' );\n\t\tconst hasBlockGapStylesSupport = blockGapSupport !== null;\n\t\t// If a block's block.json skips serialization for spacing or spacing.blockGap,\n\t\t// don't apply the user-defined value to the styles.\n\t\tconst blockGapValue =\n\t\t\tstyle?.spacing?.blockGap &&\n\t\t\t! shouldSkipSerialization( blockName, 'spacing', 'blockGap' )\n\t\t\t\t? getGapCSSValue( style?.spacing?.blockGap, '0.5em' )\n\t\t\t\t: 'var( --wp--style--block-gap, 0.5em )';\n\t\tconst justifyContent =\n\t\t\tjustifyContentMap[ layout.justifyContent ] ||\n\t\t\tjustifyContentMap.left;\n\t\tconst flexWrap = flexWrapOptions.includes( layout.flexWrap )\n\t\t\t? layout.flexWrap\n\t\t\t: 'wrap';\n\t\tconst verticalAlignment =\n\t\t\tverticalAlignmentMap[ layout.verticalAlignment ] ||\n\t\t\tverticalAlignmentMap.center;\n\t\tconst rowOrientation = `\n\t\tflex-direction: row;\n\t\talign-items: ${ verticalAlignment };\n\t\tjustify-content: ${ justifyContent };\n\t\t`;\n\t\tconst alignItems =\n\t\t\talignItemsMap[ layout.justifyContent ] || alignItemsMap.left;\n\t\tconst columnOrientation = `\n\t\tflex-direction: column;\n\t\talign-items: ${ alignItems };\n\t\t`;\n\n\t\treturn (\n\t\t\t<style>{ `\n\t\t\t\t${ appendSelectors( selector ) } {\n\t\t\t\t\tdisplay: flex;\n\t\t\t\t\tflex-wrap: ${ flexWrap };\n\t\t\t\t\tgap: ${ hasBlockGapStylesSupport ? blockGapValue : '0.5em' };\n\t\t\t\t\t${ orientation === 'horizontal' ? rowOrientation : columnOrientation }\n\t\t\t\t}\n\n\t\t\t\t${ appendSelectors( selector, '> *' ) } {\n\t\t\t\t\tmargin: 0;\n\t\t\t\t}\n\t\t\t` }</style>\n\t\t);\n\t},\n\tgetOrientation( layout ) {\n\t\tconst { orientation = 'horizontal' } = layout;\n\t\treturn orientation;\n\t},\n\tgetAlignments() {\n\t\treturn [];\n\t},\n};\n\nfunction FlexLayoutVerticalAlignmentControl( {\n\tlayout,\n\tonChange,\n\tisToolbar = false,\n} ) {\n\tconst { verticalAlignment = verticalAlignmentMap.center } = layout;\n\n\tconst onVerticalAlignmentChange = ( value ) => {\n\t\tonChange( {\n\t\t\t...layout,\n\t\t\tverticalAlignment: value,\n\t\t} );\n\t};\n\tif ( isToolbar ) {\n\t\treturn (\n\t\t\t<BlockVerticalAlignmentControl\n\t\t\t\tonChange={ onVerticalAlignmentChange }\n\t\t\t\tvalue={ verticalAlignment }\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst verticalAlignmentOptions = [\n\t\t{\n\t\t\tvalue: 'flex-start',\n\t\t\tlabel: __( 'Align items top' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'center',\n\t\t\tlabel: __( 'Align items center' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'flex-end',\n\t\t\tlabel: __( 'Align items bottom' ),\n\t\t},\n\t];\n\n\treturn (\n\t\t<fieldset className=\"block-editor-hooks__flex-layout-vertical-alignment-control\">\n\t\t\t<legend>{ __( 'Vertical alignment' ) }</legend>\n\t\t\t<div>\n\t\t\t\t{ verticalAlignmentOptions.map( ( value, icon, label ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ value }\n\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\tisPressed={ verticalAlignment === value }\n\t\t\t\t\t\t\tonClick={ () => onVerticalAlignmentChange( value ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t</fieldset>\n\t);\n}\n\nfunction FlexLayoutJustifyContentControl( {\n\tlayout,\n\tonChange,\n\tisToolbar = false,\n} ) {\n\tconst { justifyContent = 'left', orientation = 'horizontal' } = layout;\n\tconst onJustificationChange = ( value ) => {\n\t\tonChange( {\n\t\t\t...layout,\n\t\t\tjustifyContent: value,\n\t\t} );\n\t};\n\tconst allowedControls = [ 'left', 'center', 'right' ];\n\tif ( orientation === 'horizontal' ) {\n\t\tallowedControls.push( 'space-between' );\n\t}\n\tif ( isToolbar ) {\n\t\treturn (\n\t\t\t<JustifyContentControl\n\t\t\t\tallowedControls={ allowedControls }\n\t\t\t\tvalue={ justifyContent }\n\t\t\t\tonChange={ onJustificationChange }\n\t\t\t\tpopoverProps={ {\n\t\t\t\t\tposition: 'bottom right',\n\t\t\t\t\tisAlternate: true,\n\t\t\t\t} }\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst justificationOptions = [\n\t\t{\n\t\t\tvalue: 'left',\n\t\t\ticon: justifyLeft,\n\t\t\tlabel: __( 'Justify items left' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'center',\n\t\t\ticon: justifyCenter,\n\t\t\tlabel: __( 'Justify items center' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'right',\n\t\t\ticon: justifyRight,\n\t\t\tlabel: __( 'Justify items right' ),\n\t\t},\n\t];\n\tif ( orientation === 'horizontal' ) {\n\t\tjustificationOptions.push( {\n\t\t\tvalue: 'space-between',\n\t\t\ticon: justifySpaceBetween,\n\t\t\tlabel: __( 'Space between items' ),\n\t\t} );\n\t}\n\n\treturn (\n\t\t<fieldset className=\"block-editor-hooks__flex-layout-justification-controls\">\n\t\t\t<legend>{ __( 'Justification' ) }</legend>\n\t\t\t<div>\n\t\t\t\t{ justificationOptions.map( ( { value, icon, label } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ value }\n\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\tisPressed={ justifyContent === value }\n\t\t\t\t\t\t\tonClick={ () => onJustificationChange( value ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t</fieldset>\n\t);\n}\n\nfunction FlexWrapControl( { layout, onChange } ) {\n\tconst { flexWrap = 'wrap' } = layout;\n\treturn (\n\t\t<ToggleControl\n\t\t\tlabel={ __( 'Allow to wrap to multiple lines' ) }\n\t\t\tonChange={ ( value ) => {\n\t\t\t\tonChange( {\n\t\t\t\t\t...layout,\n\t\t\t\t\tflexWrap: value ? 'wrap' : 'nowrap',\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tchecked={ flexWrap === 'wrap' }\n\t\t/>\n\t);\n}\n\nfunction OrientationControl( { layout, onChange } ) {\n\tconst { orientation = 'horizontal' } = layout;\n\treturn (\n\t\t<fieldset className=\"block-editor-hooks__flex-layout-orientation-controls\">\n\t\t\t<legend>{ __( 'Orientation' ) }</legend>\n\t\t\t<Button\n\t\t\t\tlabel={ 'horizontal' }\n\t\t\t\ticon={ arrowRight }\n\t\t\t\tisPressed={ orientation === 'horizontal' }\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\t...layout,\n\t\t\t\t\t\torientation: 'horizontal',\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tlabel={ 'vertical' }\n\t\t\t\ticon={ arrowDown }\n\t\t\t\tisPressed={ orientation === 'vertical' }\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\t...layout,\n\t\t\t\t\t\torientation: 'vertical',\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t</fieldset>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/layouts/flex.js"],"names":["__","justifyLeft","justifyCenter","justifyRight","justifySpaceBetween","arrowRight","arrowDown","Button","ToggleControl","Flex","FlexItem","getBlockSupport","appendSelectors","getGapCSSValue","useSetting","BlockControls","JustifyContentControl","BlockVerticalAlignmentControl","shouldSkipSerialization","justifyContentMap","left","right","center","alignItemsMap","verticalAlignmentMap","top","bottom","flexWrapOptions","name","label","inspectorControls","FlexLayoutInspectorControls","layout","onChange","layoutBlockSupport","allowOrientation","toolBarControls","FlexLayoutToolbarControls","allowSwitching","allowVerticalAlignment","orientation","save","FlexLayoutStyle","selector","style","blockName","blockGapSupport","fallbackValue","hasBlockGapStylesSupport","blockGapValue","spacing","blockGap","justifyContent","flexWrap","includes","verticalAlignment","rowOrientation","alignItems","columnOrientation","getOrientation","getAlignments","FlexLayoutVerticalAlignmentControl","isToolbar","onVerticalAlignmentChange","value","verticalAlignmentOptions","map","icon","FlexLayoutJustifyContentControl","onJustificationChange","allowedControls","push","position","isAlternate","justificationOptions","FlexWrapControl","OrientationControl"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SACCC,WADD,EAECC,aAFD,EAGCC,YAHD,EAICC,mBAJD,EAKCC,UALD,EAMCC,SAND,QAOO,kBAPP;AAQA,SAASC,MAAT,EAAiBC,aAAjB,EAAgCC,IAAhC,EAAsCC,QAAtC,QAAsD,uBAAtD;AACA,SAASC,eAAT,QAAgC,mBAAhC;AAEA;AACA;AACA;;AACA,SAASC,eAAT,QAAgC,SAAhC;AACA,SAASC,cAAT,QAA+B,cAA/B;AACA,OAAOC,UAAP,MAAuB,2BAAvB;AACA,SAC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W,KAAK,GAAG,MAAH,GAAY;AAFlB,OAAF,CAAR;AAIA,KAPF;AAQC,IAAA,OAAO,EAAGX,QAAQ,KAAK;AARxB,IADD;AAYA;;AAED,SAASuB,kBAAT,QAAoD;AAAA,MAAvB;AAAE5C,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAAuB;AACnD,QAAM;AAAEO,IAAAA,WAAW,GAAG;AAAhB,MAAiCR,MAAvC;AACA,SACC;AAAU,IAAA,SAAS,EAAC;AAApB,KACC,8BAAUhC,EAAE,CAAE,aAAF,CAAZ,CADD,EAEC,cAAC,MAAD;AACC,IAAA,KAAK,EAAG,YADT;AAEC,IAAA,IAAI,EAAGK,UAFR;AAGC,IAAA,SAAS,EAAGmC,WAAW,KAAK,YAH7B;AAIC,IAAA,OAAO,EAAG,MACTP,QAAQ,CAAE,EACT,GAAGD,MADM;AAETQ,MAAAA,WAAW,EAAE;AAFJ,KAAF;AALV,IAFD,EAaC,cAAC,MAAD;AACC,IAAA,KAAK,EAAG,UADT;AAEC,IAAA,IAAI,EAAGlC,SAFR;AAGC,IAAA,SAAS,EAAGkC,WAAW,KAAK,UAH7B;AAIC,IAAA,OAAO,EAAG,MACTP,QAAQ,CAAE,EACT,GAAGD,MADM;AAETQ,MAAAA,WAAW,EAAE;AAFJ,KAAF;AALV,IAbD,CADD;AA2BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tjustifyLeft,\n\tjustifyCenter,\n\tjustifyRight,\n\tjustifySpaceBetween,\n\tarrowRight,\n\tarrowDown,\n} from '@wordpress/icons';\nimport { Button, ToggleControl, Flex, FlexItem } from '@wordpress/components';\nimport { getBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { appendSelectors } from './utils';\nimport { getGapCSSValue } from '../hooks/gap';\nimport useSetting from '../components/use-setting';\nimport {\n\tBlockControls,\n\tJustifyContentControl,\n\tBlockVerticalAlignmentControl,\n} from '../components';\nimport { shouldSkipSerialization } from '../hooks/utils';\n\n// Used with the default, horizontal flex orientation.\nconst justifyContentMap = {\n\tleft: 'flex-start',\n\tright: 'flex-end',\n\tcenter: 'center',\n\t'space-between': 'space-between',\n};\n\n// Used with the vertical (column) flex orientation.\nconst alignItemsMap = {\n\tleft: 'flex-start',\n\tright: 'flex-end',\n\tcenter: 'center',\n};\n\nconst verticalAlignmentMap = {\n\ttop: 'flex-start',\n\tcenter: 'center',\n\tbottom: 'flex-end',\n};\n\nconst flexWrapOptions = [ 'wrap', 'nowrap' ];\n\nexport default {\n\tname: 'flex',\n\tlabel: __( 'Flex' ),\n\tinspectorControls: function FlexLayoutInspectorControls( {\n\t\tlayout = {},\n\t\tonChange,\n\t\tlayoutBlockSupport = {},\n\t} ) {\n\t\tconst { allowOrientation = true } = layoutBlockSupport;\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<Flex>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<FlexLayoutJustifyContentControl\n\t\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t{ allowOrientation && (\n\t\t\t\t\t\t\t<OrientationControl\n\t\t\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t\t<FlexWrapControl layout={ layout } onChange={ onChange } />\n\t\t\t</>\n\t\t);\n\t},\n\ttoolBarControls: function FlexLayoutToolbarControls( {\n\t\tlayout = {},\n\t\tonChange,\n\t\tlayoutBlockSupport,\n\t} ) {\n\t\tif ( layoutBlockSupport?.allowSwitching ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst { allowVerticalAlignment = true } = layoutBlockSupport;\n\t\treturn (\n\t\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t\t<FlexLayoutJustifyContentControl\n\t\t\t\t\tlayout={ layout }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tisToolbar\n\t\t\t\t/>\n\t\t\t\t{ allowVerticalAlignment &&\n\t\t\t\t\tlayout?.orientation !== 'vertical' && (\n\t\t\t\t\t\t<FlexLayoutVerticalAlignmentControl\n\t\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tisToolbar\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t</BlockControls>\n\t\t);\n\t},\n\tsave: function FlexLayoutStyle( { selector, layout, style, blockName } ) {\n\t\tconst { orientation = 'horizontal' } = layout;\n\t\tconst blockGapSupport = useSetting( 'spacing.blockGap' );\n\t\tconst fallbackValue =\n\t\t\tgetBlockSupport( blockName, [\n\t\t\t\t'spacing',\n\t\t\t\t'blockGap',\n\t\t\t\t'__experimentalDefault',\n\t\t\t] ) || '0.5em';\n\n\t\tconst hasBlockGapStylesSupport = blockGapSupport !== null;\n\t\t// If a block's block.json skips serialization for spacing or spacing.blockGap,\n\t\t// don't apply the user-defined value to the styles.\n\t\tconst blockGapValue =\n\t\t\tstyle?.spacing?.blockGap &&\n\t\t\t! shouldSkipSerialization( blockName, 'spacing', 'blockGap' )\n\t\t\t\t? getGapCSSValue( style?.spacing?.blockGap, fallbackValue )\n\t\t\t\t: `var( --wp--style--block-gap, ${ fallbackValue } )`;\n\t\tconst justifyContent =\n\t\t\tjustifyContentMap[ layout.justifyContent ] ||\n\t\t\tjustifyContentMap.left;\n\t\tconst flexWrap = flexWrapOptions.includes( layout.flexWrap )\n\t\t\t? layout.flexWrap\n\t\t\t: 'wrap';\n\t\tconst verticalAlignment =\n\t\t\tverticalAlignmentMap[ layout.verticalAlignment ] ||\n\t\t\tverticalAlignmentMap.center;\n\t\tconst rowOrientation = `\n\t\tflex-direction: row;\n\t\talign-items: ${ verticalAlignment };\n\t\tjustify-content: ${ justifyContent };\n\t\t`;\n\t\tconst alignItems =\n\t\t\talignItemsMap[ layout.justifyContent ] || alignItemsMap.left;\n\t\tconst columnOrientation = `\n\t\tflex-direction: column;\n\t\talign-items: ${ alignItems };\n\t\t`;\n\n\t\treturn (\n\t\t\t<style>{ `\n\t\t\t\t${ appendSelectors( selector ) } {\n\t\t\t\t\tdisplay: flex;\n\t\t\t\t\tflex-wrap: ${ flexWrap };\n\t\t\t\t\tgap: ${ hasBlockGapStylesSupport ? blockGapValue : fallbackValue };\n\t\t\t\t\t${ orientation === 'horizontal' ? rowOrientation : columnOrientation }\n\t\t\t\t}\n\n\t\t\t\t${ appendSelectors( selector, '> *' ) } {\n\t\t\t\t\tmargin: 0;\n\t\t\t\t}\n\t\t\t` }</style>\n\t\t);\n\t},\n\tgetOrientation( layout ) {\n\t\tconst { orientation = 'horizontal' } = layout;\n\t\treturn orientation;\n\t},\n\tgetAlignments() {\n\t\treturn [];\n\t},\n};\n\nfunction FlexLayoutVerticalAlignmentControl( {\n\tlayout,\n\tonChange,\n\tisToolbar = false,\n} ) {\n\tconst { verticalAlignment = verticalAlignmentMap.center } = layout;\n\n\tconst onVerticalAlignmentChange = ( value ) => {\n\t\tonChange( {\n\t\t\t...layout,\n\t\t\tverticalAlignment: value,\n\t\t} );\n\t};\n\tif ( isToolbar ) {\n\t\treturn (\n\t\t\t<BlockVerticalAlignmentControl\n\t\t\t\tonChange={ onVerticalAlignmentChange }\n\t\t\t\tvalue={ verticalAlignment }\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst verticalAlignmentOptions = [\n\t\t{\n\t\t\tvalue: 'flex-start',\n\t\t\tlabel: __( 'Align items top' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'center',\n\t\t\tlabel: __( 'Align items center' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'flex-end',\n\t\t\tlabel: __( 'Align items bottom' ),\n\t\t},\n\t];\n\n\treturn (\n\t\t<fieldset className=\"block-editor-hooks__flex-layout-vertical-alignment-control\">\n\t\t\t<legend>{ __( 'Vertical alignment' ) }</legend>\n\t\t\t<div>\n\t\t\t\t{ verticalAlignmentOptions.map( ( value, icon, label ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ value }\n\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\tisPressed={ verticalAlignment === value }\n\t\t\t\t\t\t\tonClick={ () => onVerticalAlignmentChange( value ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t</fieldset>\n\t);\n}\n\nfunction FlexLayoutJustifyContentControl( {\n\tlayout,\n\tonChange,\n\tisToolbar = false,\n} ) {\n\tconst { justifyContent = 'left', orientation = 'horizontal' } = layout;\n\tconst onJustificationChange = ( value ) => {\n\t\tonChange( {\n\t\t\t...layout,\n\t\t\tjustifyContent: value,\n\t\t} );\n\t};\n\tconst allowedControls = [ 'left', 'center', 'right' ];\n\tif ( orientation === 'horizontal' ) {\n\t\tallowedControls.push( 'space-between' );\n\t}\n\tif ( isToolbar ) {\n\t\treturn (\n\t\t\t<JustifyContentControl\n\t\t\t\tallowedControls={ allowedControls }\n\t\t\t\tvalue={ justifyContent }\n\t\t\t\tonChange={ onJustificationChange }\n\t\t\t\tpopoverProps={ {\n\t\t\t\t\tposition: 'bottom right',\n\t\t\t\t\tisAlternate: true,\n\t\t\t\t} }\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst justificationOptions = [\n\t\t{\n\t\t\tvalue: 'left',\n\t\t\ticon: justifyLeft,\n\t\t\tlabel: __( 'Justify items left' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'center',\n\t\t\ticon: justifyCenter,\n\t\t\tlabel: __( 'Justify items center' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'right',\n\t\t\ticon: justifyRight,\n\t\t\tlabel: __( 'Justify items right' ),\n\t\t},\n\t];\n\tif ( orientation === 'horizontal' ) {\n\t\tjustificationOptions.push( {\n\t\t\tvalue: 'space-between',\n\t\t\ticon: justifySpaceBetween,\n\t\t\tlabel: __( 'Space between items' ),\n\t\t} );\n\t}\n\n\treturn (\n\t\t<fieldset className=\"block-editor-hooks__flex-layout-justification-controls\">\n\t\t\t<legend>{ __( 'Justification' ) }</legend>\n\t\t\t<div>\n\t\t\t\t{ justificationOptions.map( ( { value, icon, label } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ value }\n\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\tisPressed={ justifyContent === value }\n\t\t\t\t\t\t\tonClick={ () => onJustificationChange( value ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t</fieldset>\n\t);\n}\n\nfunction FlexWrapControl( { layout, onChange } ) {\n\tconst { flexWrap = 'wrap' } = layout;\n\treturn (\n\t\t<ToggleControl\n\t\t\tlabel={ __( 'Allow to wrap to multiple lines' ) }\n\t\t\tonChange={ ( value ) => {\n\t\t\t\tonChange( {\n\t\t\t\t\t...layout,\n\t\t\t\t\tflexWrap: value ? 'wrap' : 'nowrap',\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tchecked={ flexWrap === 'wrap' }\n\t\t/>\n\t);\n}\n\nfunction OrientationControl( { layout, onChange } ) {\n\tconst { orientation = 'horizontal' } = layout;\n\treturn (\n\t\t<fieldset className=\"block-editor-hooks__flex-layout-orientation-controls\">\n\t\t\t<legend>{ __( 'Orientation' ) }</legend>\n\t\t\t<Button\n\t\t\t\tlabel={ 'horizontal' }\n\t\t\t\ticon={ arrowRight }\n\t\t\t\tisPressed={ orientation === 'horizontal' }\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\t...layout,\n\t\t\t\t\t\torientation: 'horizontal',\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tlabel={ 'vertical' }\n\t\t\t\ticon={ arrowDown }\n\t\t\t\tisPressed={ orientation === 'vertical' }\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\t...layout,\n\t\t\t\t\t\torientation: 'vertical',\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t</fieldset>\n\t);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "8.5.
|
|
3
|
+
"version": "8.5.8",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"publishConfig": {
|
|
78
78
|
"access": "public"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "988fb5256118af4ed0546345c26a690ac9b7316b"
|
|
81
81
|
}
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
useState,
|
|
11
11
|
createPortal,
|
|
12
12
|
forwardRef,
|
|
13
|
-
useEffect,
|
|
14
13
|
useMemo,
|
|
15
14
|
useReducer,
|
|
16
15
|
} from '@wordpress/element';
|
|
@@ -34,61 +33,66 @@ const BLOCK_PREFIX = 'wp-block';
|
|
|
34
33
|
*
|
|
35
34
|
* Ideally, this hook should be removed in the future and styles should be added
|
|
36
35
|
* explicitly as editor styles.
|
|
37
|
-
*
|
|
38
|
-
* @param {Document} doc The document to append cloned stylesheets to.
|
|
39
36
|
*/
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const { ownerNode, cssRules } = styleSheet;
|
|
52
|
-
|
|
53
|
-
if ( ! cssRules ) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
37
|
+
function useStylesCompatibility() {
|
|
38
|
+
return useRefEffect( ( node ) => {
|
|
39
|
+
// Search the document for stylesheets targetting the editor canvas.
|
|
40
|
+
Array.from( document.styleSheets ).forEach( ( styleSheet ) => {
|
|
41
|
+
try {
|
|
42
|
+
// May fail for external styles.
|
|
43
|
+
// eslint-disable-next-line no-unused-expressions
|
|
44
|
+
styleSheet.cssRules;
|
|
45
|
+
} catch ( e ) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
56
48
|
|
|
57
|
-
|
|
58
|
-
// stylesheet later, which may or may not match the selectors.
|
|
59
|
-
if ( ownerNode.tagName !== 'LINK' ) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
49
|
+
const { ownerNode, cssRules } = styleSheet;
|
|
62
50
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if ( ownerNode.id === 'wp-reset-editor-styles-css' ) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const isMatch = Array.from( cssRules ).find(
|
|
71
|
-
( { selectorText } ) =>
|
|
72
|
-
selectorText &&
|
|
73
|
-
( selectorText.includes( `.${ BODY_CLASS_NAME }` ) ||
|
|
74
|
-
selectorText.includes( `.${ BLOCK_PREFIX }` ) )
|
|
75
|
-
);
|
|
51
|
+
if ( ! cssRules ) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
76
54
|
|
|
77
|
-
|
|
78
|
-
//
|
|
79
|
-
|
|
55
|
+
// Generally, ignore inline styles. We add inline styles belonging to a
|
|
56
|
+
// stylesheet later, which may or may not match the selectors.
|
|
57
|
+
if ( ownerNode.tagName !== 'LINK' ) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
80
60
|
|
|
81
|
-
|
|
61
|
+
// Don't try to add the reset styles, which were removed as a dependency
|
|
62
|
+
// from `edit-blocks` for the iframe since we don't need to reset admin
|
|
63
|
+
// styles.
|
|
64
|
+
if ( ownerNode.id === 'wp-reset-editor-styles-css' ) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
82
67
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
68
|
+
const isMatch = Array.from( cssRules ).find(
|
|
69
|
+
( { selectorText } ) =>
|
|
70
|
+
selectorText &&
|
|
71
|
+
( selectorText.includes( `.${ BODY_CLASS_NAME }` ) ||
|
|
72
|
+
selectorText.includes( `.${ BLOCK_PREFIX }` ) )
|
|
73
|
+
);
|
|
86
74
|
|
|
87
|
-
if (
|
|
88
|
-
|
|
75
|
+
if (
|
|
76
|
+
isMatch &&
|
|
77
|
+
! node.ownerDocument.getElementById( ownerNode.id )
|
|
78
|
+
) {
|
|
79
|
+
// Display warning once we have a way to add style dependencies to the editor.
|
|
80
|
+
// See: https://github.com/WordPress/gutenberg/pull/37466.
|
|
81
|
+
node.appendChild( ownerNode.cloneNode( true ) );
|
|
82
|
+
|
|
83
|
+
// Add inline styles belonging to the stylesheet.
|
|
84
|
+
const inlineCssId = ownerNode.id.replace(
|
|
85
|
+
'-css',
|
|
86
|
+
'-inline-css'
|
|
87
|
+
);
|
|
88
|
+
const inlineCssElement = document.getElementById( inlineCssId );
|
|
89
|
+
|
|
90
|
+
if ( inlineCssElement ) {
|
|
91
|
+
node.appendChild( inlineCssElement.cloneNode( true ) );
|
|
92
|
+
}
|
|
89
93
|
}
|
|
90
|
-
}
|
|
91
|
-
} );
|
|
94
|
+
} );
|
|
95
|
+
}, [] );
|
|
92
96
|
}
|
|
93
97
|
|
|
94
98
|
/**
|
|
@@ -222,12 +226,7 @@ function Iframe(
|
|
|
222
226
|
} );
|
|
223
227
|
}, [] );
|
|
224
228
|
const bodyRef = useMergeRefs( [ contentRef, clearerRef, writingFlowRef ] );
|
|
225
|
-
|
|
226
|
-
useEffect( () => {
|
|
227
|
-
if ( iframeDocument ) {
|
|
228
|
-
styleSheetsCompat( iframeDocument );
|
|
229
|
-
}
|
|
230
|
-
}, [ iframeDocument ] );
|
|
229
|
+
const styleCompatibilityRef = useStylesCompatibility();
|
|
231
230
|
|
|
232
231
|
head = (
|
|
233
232
|
<>
|
|
@@ -275,6 +274,15 @@ function Iframe(
|
|
|
275
274
|
...bodyClasses
|
|
276
275
|
) }
|
|
277
276
|
>
|
|
277
|
+
{ /*
|
|
278
|
+
* This is a wrapper for the extra styles and scripts
|
|
279
|
+
* rendered imperatively by cloning the parent,
|
|
280
|
+
* it's important that this div's content remains uncontrolled.
|
|
281
|
+
*/ }
|
|
282
|
+
<div
|
|
283
|
+
style={ { display: 'none' } }
|
|
284
|
+
ref={ styleCompatibilityRef }
|
|
285
|
+
/>
|
|
278
286
|
<StyleProvider document={ iframeDocument }>
|
|
279
287
|
{ children }
|
|
280
288
|
</StyleProvider>
|
|
@@ -73,7 +73,6 @@ export function MediaPlaceholder( {
|
|
|
73
73
|
onDoubleClick,
|
|
74
74
|
onFilesPreUpload = noop,
|
|
75
75
|
onHTMLDrop = noop,
|
|
76
|
-
onClose = noop,
|
|
77
76
|
children,
|
|
78
77
|
mediaLibraryButton,
|
|
79
78
|
placeholder,
|
|
@@ -327,7 +326,6 @@ export function MediaPlaceholder( {
|
|
|
327
326
|
gallery={ multiple && onlyAllowsImages() }
|
|
328
327
|
multiple={ multiple }
|
|
329
328
|
onSelect={ onSelect }
|
|
330
|
-
onClose={ onClose }
|
|
331
329
|
allowedTypes={ allowedTypes }
|
|
332
330
|
value={
|
|
333
331
|
Array.isArray( value )
|
|
@@ -42,7 +42,6 @@ const MediaReplaceFlow = ( {
|
|
|
42
42
|
onSelect,
|
|
43
43
|
onSelectURL,
|
|
44
44
|
onFilesUpload = noop,
|
|
45
|
-
onCloseModal = noop,
|
|
46
45
|
name = __( 'Replace' ),
|
|
47
46
|
createNotice,
|
|
48
47
|
removeNotice,
|
|
@@ -158,7 +157,6 @@ const MediaReplaceFlow = ( {
|
|
|
158
157
|
selectMedia( media, onClose )
|
|
159
158
|
}
|
|
160
159
|
allowedTypes={ allowedTypes }
|
|
161
|
-
onClose={ onCloseModal }
|
|
162
160
|
render={ ( { open } ) => (
|
|
163
161
|
<MenuItem icon={ mediaIcon } onClick={ open }>
|
|
164
162
|
{ __( 'Open Media Library' ) }
|
|
@@ -13,50 +13,55 @@ import { moreHorizontal } from '@wordpress/icons';
|
|
|
13
13
|
|
|
14
14
|
function Warning( { className, actions, children, secondaryActions } ) {
|
|
15
15
|
return (
|
|
16
|
-
<div
|
|
17
|
-
<div className=
|
|
18
|
-
<
|
|
16
|
+
<div style={ { display: 'contents', all: 'initial' } }>
|
|
17
|
+
<div className={ classnames( className, 'block-editor-warning' ) }>
|
|
18
|
+
<div className="block-editor-warning__contents">
|
|
19
|
+
<p className="block-editor-warning__message">
|
|
20
|
+
{ children }
|
|
21
|
+
</p>
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
{ ( Children.count( actions ) > 0 || secondaryActions ) && (
|
|
24
|
+
<div className="block-editor-warning__actions">
|
|
25
|
+
{ Children.count( actions ) > 0 &&
|
|
26
|
+
Children.map( actions, ( action, i ) => (
|
|
27
|
+
<span
|
|
28
|
+
key={ i }
|
|
29
|
+
className="block-editor-warning__action"
|
|
30
|
+
>
|
|
31
|
+
{ action }
|
|
32
|
+
</span>
|
|
33
|
+
) ) }
|
|
34
|
+
{ secondaryActions && (
|
|
35
|
+
<DropdownMenu
|
|
36
|
+
className="block-editor-warning__secondary"
|
|
37
|
+
icon={ moreHorizontal }
|
|
38
|
+
label={ __( 'More options' ) }
|
|
39
|
+
popoverProps={ {
|
|
40
|
+
position: 'bottom left',
|
|
41
|
+
className:
|
|
42
|
+
'block-editor-warning__dropdown',
|
|
43
|
+
} }
|
|
44
|
+
noIcons
|
|
27
45
|
>
|
|
28
|
-
{
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
onClick={ item.onClick }
|
|
48
|
-
key={ pos }
|
|
49
|
-
>
|
|
50
|
-
{ item.title }
|
|
51
|
-
</MenuItem>
|
|
52
|
-
)
|
|
53
|
-
) }
|
|
54
|
-
</MenuGroup>
|
|
55
|
-
) }
|
|
56
|
-
</DropdownMenu>
|
|
57
|
-
) }
|
|
58
|
-
</div>
|
|
59
|
-
) }
|
|
46
|
+
{ () => (
|
|
47
|
+
<MenuGroup>
|
|
48
|
+
{ secondaryActions.map(
|
|
49
|
+
( item, pos ) => (
|
|
50
|
+
<MenuItem
|
|
51
|
+
onClick={ item.onClick }
|
|
52
|
+
key={ pos }
|
|
53
|
+
>
|
|
54
|
+
{ item.title }
|
|
55
|
+
</MenuItem>
|
|
56
|
+
)
|
|
57
|
+
) }
|
|
58
|
+
</MenuGroup>
|
|
59
|
+
) }
|
|
60
|
+
</DropdownMenu>
|
|
61
|
+
) }
|
|
62
|
+
</div>
|
|
63
|
+
) }
|
|
64
|
+
</div>
|
|
60
65
|
</div>
|
|
61
66
|
</div>
|
|
62
67
|
);
|
|
@@ -2,16 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`Warning should match snapshot 1`] = `
|
|
4
4
|
<div
|
|
5
|
-
|
|
5
|
+
style={
|
|
6
|
+
Object {
|
|
7
|
+
"all": "initial",
|
|
8
|
+
"display": "contents",
|
|
9
|
+
}
|
|
10
|
+
}
|
|
6
11
|
>
|
|
7
12
|
<div
|
|
8
|
-
className="block-editor-
|
|
13
|
+
className="block-editor-warning"
|
|
9
14
|
>
|
|
10
|
-
<
|
|
11
|
-
className="block-editor-
|
|
15
|
+
<div
|
|
16
|
+
className="block-editor-warning__contents"
|
|
12
17
|
>
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
<p
|
|
19
|
+
className="block-editor-warning__message"
|
|
20
|
+
>
|
|
21
|
+
error
|
|
22
|
+
</p>
|
|
23
|
+
</div>
|
|
15
24
|
</div>
|
|
16
25
|
</div>
|
|
17
26
|
`;
|
|
@@ -18,7 +18,7 @@ describe( 'Warning', () => {
|
|
|
18
18
|
it( 'should have valid class', () => {
|
|
19
19
|
const wrapper = shallow( <Warning /> );
|
|
20
20
|
|
|
21
|
-
expect( wrapper.
|
|
21
|
+
expect( wrapper.find( '.block-editor-warning' ) ).toHaveLength( 1 );
|
|
22
22
|
expect( wrapper.find( '.block-editor-warning__actions' ) ).toHaveLength(
|
|
23
23
|
0
|
|
24
24
|
);
|
package/src/hooks/dimensions.js
CHANGED
|
@@ -147,7 +147,7 @@ const useIsDimensionsDisabled = ( props = {} ) => {
|
|
|
147
147
|
};
|
|
148
148
|
|
|
149
149
|
/**
|
|
150
|
-
* Custom hook to retrieve which padding/margin is supported
|
|
150
|
+
* Custom hook to retrieve which padding/margin/blockGap is supported
|
|
151
151
|
* e.g. top, right, bottom or left.
|
|
152
152
|
*
|
|
153
153
|
* Sides are opted into by default. It is only if a specific side is set to
|
|
@@ -156,7 +156,7 @@ const useIsDimensionsDisabled = ( props = {} ) => {
|
|
|
156
156
|
* @param {string} blockName Block name.
|
|
157
157
|
* @param {string} feature The feature custom sides relate to e.g. padding or margins.
|
|
158
158
|
*
|
|
159
|
-
* @return {
|
|
159
|
+
* @return {?string[]} Strings representing the custom sides available.
|
|
160
160
|
*/
|
|
161
161
|
export function useCustomSides( blockName, feature ) {
|
|
162
162
|
const support = getBlockSupport( blockName, SPACING_SUPPORT_KEY );
|
|
@@ -166,7 +166,15 @@ export function useCustomSides( blockName, feature ) {
|
|
|
166
166
|
return;
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
|
|
169
|
+
// Return if the setting is an array of sides (e.g. `[ 'top', 'bottom' ]`).
|
|
170
|
+
if ( Array.isArray( support[ feature ] ) ) {
|
|
171
|
+
return support[ feature ];
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Finally, attempt to return `.sides` if the setting is an object.
|
|
175
|
+
if ( support[ feature ]?.sides ) {
|
|
176
|
+
return support[ feature ].sides;
|
|
177
|
+
}
|
|
170
178
|
}
|
|
171
179
|
|
|
172
180
|
/**
|
package/src/layouts/flex.js
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
arrowDown,
|
|
12
12
|
} from '@wordpress/icons';
|
|
13
13
|
import { Button, ToggleControl, Flex, FlexItem } from '@wordpress/components';
|
|
14
|
+
import { getBlockSupport } from '@wordpress/blocks';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Internal dependencies
|
|
@@ -109,14 +110,21 @@ export default {
|
|
|
109
110
|
save: function FlexLayoutStyle( { selector, layout, style, blockName } ) {
|
|
110
111
|
const { orientation = 'horizontal' } = layout;
|
|
111
112
|
const blockGapSupport = useSetting( 'spacing.blockGap' );
|
|
113
|
+
const fallbackValue =
|
|
114
|
+
getBlockSupport( blockName, [
|
|
115
|
+
'spacing',
|
|
116
|
+
'blockGap',
|
|
117
|
+
'__experimentalDefault',
|
|
118
|
+
] ) || '0.5em';
|
|
119
|
+
|
|
112
120
|
const hasBlockGapStylesSupport = blockGapSupport !== null;
|
|
113
121
|
// If a block's block.json skips serialization for spacing or spacing.blockGap,
|
|
114
122
|
// don't apply the user-defined value to the styles.
|
|
115
123
|
const blockGapValue =
|
|
116
124
|
style?.spacing?.blockGap &&
|
|
117
125
|
! shouldSkipSerialization( blockName, 'spacing', 'blockGap' )
|
|
118
|
-
? getGapCSSValue( style?.spacing?.blockGap,
|
|
119
|
-
:
|
|
126
|
+
? getGapCSSValue( style?.spacing?.blockGap, fallbackValue )
|
|
127
|
+
: `var( --wp--style--block-gap, ${ fallbackValue } )`;
|
|
120
128
|
const justifyContent =
|
|
121
129
|
justifyContentMap[ layout.justifyContent ] ||
|
|
122
130
|
justifyContentMap.left;
|
|
@@ -143,7 +151,7 @@ export default {
|
|
|
143
151
|
${ appendSelectors( selector ) } {
|
|
144
152
|
display: flex;
|
|
145
153
|
flex-wrap: ${ flexWrap };
|
|
146
|
-
gap: ${ hasBlockGapStylesSupport ? blockGapValue :
|
|
154
|
+
gap: ${ hasBlockGapStylesSupport ? blockGapValue : fallbackValue };
|
|
147
155
|
${ orientation === 'horizontal' ? rowOrientation : columnOrientation }
|
|
148
156
|
}
|
|
149
157
|
|