@wordpress/block-editor 15.15.0 → 15.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/block-inspector/index.cjs +2 -1
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-visibility/modal.cjs +2 -2
- package/build/components/block-visibility/modal.cjs.map +1 -1
- package/build/components/block-visibility/viewport-visibility-info.cjs +6 -1
- package/build/components/block-visibility/viewport-visibility-info.cjs.map +2 -2
- package/build/components/global-styles/background-panel.cjs +142 -33
- package/build/components/global-styles/background-panel.cjs.map +2 -2
- package/build/components/global-styles/color-panel.cjs +18 -7
- package/build/components/global-styles/color-panel.cjs.map +2 -2
- package/build/components/global-styles/hooks.cjs +8 -4
- package/build/components/global-styles/hooks.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/styles-tab.cjs +2 -1
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/hooks/background.cjs +74 -21
- package/build/hooks/background.cjs.map +3 -3
- package/build/hooks/cross-origin-isolation.cjs +6 -6
- package/build/hooks/cross-origin-isolation.cjs.map +2 -2
- package/build/hooks/custom-css.cjs +5 -0
- package/build/hooks/custom-css.cjs.map +2 -2
- package/build/hooks/fit-text.cjs +46 -58
- package/build/hooks/fit-text.cjs.map +3 -3
- package/build/hooks/utils.cjs +5 -1
- package/build/hooks/utils.cjs.map +2 -2
- package/build/store/actions.cjs +8 -4
- package/build/store/actions.cjs.map +2 -2
- package/build/store/private-selectors.cjs +2 -2
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +62 -95
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs +2 -2
- package/build/store/selectors.cjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +2 -1
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-visibility/modal.mjs +2 -2
- package/build-module/components/block-visibility/modal.mjs.map +1 -1
- package/build-module/components/block-visibility/viewport-visibility-info.mjs +6 -1
- package/build-module/components/block-visibility/viewport-visibility-info.mjs.map +2 -2
- package/build-module/components/global-styles/background-panel.mjs +141 -34
- package/build-module/components/global-styles/background-panel.mjs.map +2 -2
- package/build-module/components/global-styles/color-panel.mjs +17 -7
- package/build-module/components/global-styles/color-panel.mjs.map +2 -2
- package/build-module/components/global-styles/hooks.mjs +8 -4
- package/build-module/components/global-styles/hooks.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +2 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/hooks/background.mjs +76 -22
- package/build-module/hooks/background.mjs.map +2 -2
- package/build-module/hooks/cross-origin-isolation.mjs +6 -6
- package/build-module/hooks/cross-origin-isolation.mjs.map +2 -2
- package/build-module/hooks/custom-css.mjs +5 -0
- package/build-module/hooks/custom-css.mjs.map +2 -2
- package/build-module/hooks/fit-text.mjs +46 -58
- package/build-module/hooks/fit-text.mjs.map +2 -2
- package/build-module/hooks/utils.mjs +5 -1
- package/build-module/hooks/utils.mjs.map +2 -2
- package/build-module/store/actions.mjs +8 -4
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +2 -2
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +62 -94
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs +2 -2
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-style/content-rtl.css +2 -2
- package/build-style/content.css +2 -2
- package/build-style/style-rtl.css +35 -7
- package/build-style/style.css +35 -7
- package/package.json +39 -39
- package/src/components/background-image-control/style.scss +0 -4
- package/src/components/block-inspector/index.js +1 -0
- package/src/components/block-visibility/viewport-visibility-info.js +8 -1
- package/src/components/fit-text-size-warning/style.scss +1 -5
- package/src/components/global-styles/background-panel.js +157 -11
- package/src/components/global-styles/color-panel.js +23 -7
- package/src/components/global-styles/hooks.js +12 -4
- package/src/components/global-styles/test/background-panel.js +44 -1
- package/src/components/inspector-controls-tabs/styles-tab.js +1 -0
- package/src/hooks/background.js +122 -21
- package/src/hooks/background.scss +45 -0
- package/src/hooks/cross-origin-isolation.js +6 -6
- package/src/hooks/custom-css.js +6 -0
- package/src/hooks/fit-text.js +73 -83
- package/src/hooks/test/cross-origin-isolation.js +7 -3
- package/src/hooks/utils.js +4 -0
- package/src/store/actions.js +9 -8
- package/src/store/private-selectors.js +2 -2
- package/src/store/reducer.js +84 -128
- package/src/store/selectors.js +2 -2
- package/src/store/test/private-selectors.js +67 -34
- package/src/store/test/reducer.js +436 -66
- package/src/store/test/selectors.js +81 -63
- package/src/style.scss +1 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/background.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport { cleanEmptyObject } from './utils';\nimport { store as blockEditorStore } from '../store';\nimport {\n\tdefault as StylesBackgroundPanel,\n\tuseHasBackgroundPanel,\n\thasBackgroundImageValue,\n} from '../components/global-styles/background-panel';\nimport { globalStylesDataKey } from '../store/private-keys';\n\nexport const BACKGROUND_SUPPORT_KEY = 'background';\n\n// Initial control values.\nexport const BACKGROUND_BLOCK_DEFAULT_VALUES = {\n\tbackgroundSize: 'cover',\n\tbackgroundPosition: '50% 50%', // used only when backgroundSize is 'contain'.\n};\n\n/**\n * Determine whether there is block support for background.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Background image feature to check for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBackgroundSupport( blockName, feature = 'any' ) {\n\tconst support = getBlockSupport( blockName, BACKGROUND_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn (\n\t\t\t!! support?.backgroundImage ||\n\t\t\t!! support?.backgroundSize ||\n\t\t\t!! support?.backgroundRepeat\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\nexport function setBackgroundStyleDefaults( backgroundStyle ) {\n\tif ( ! backgroundStyle || ! backgroundStyle?.backgroundImage?.url ) {\n\t\treturn;\n\t}\n\n\tlet backgroundStylesWithDefaults;\n\n\t// Set block background defaults.\n\tif ( ! backgroundStyle?.backgroundSize ) {\n\t\tbackgroundStylesWithDefaults = {\n\t\t\tbackgroundSize: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundSize,\n\t\t};\n\t}\n\n\tif (\n\t\t'contain' === backgroundStyle?.backgroundSize &&\n\t\t! backgroundStyle?.backgroundPosition\n\t) {\n\t\tbackgroundStylesWithDefaults = {\n\t\t\tbackgroundPosition:\n\t\t\t\tBACKGROUND_BLOCK_DEFAULT_VALUES.backgroundPosition,\n\t\t};\n\t}\n\treturn backgroundStylesWithDefaults;\n}\n\nfunction useBlockProps( { name, style } ) {\n\tif (\n\t\t! hasBackgroundSupport( name ) ||\n\t\t! style?.background?.backgroundImage\n\t) {\n\t\treturn;\n\t}\n\n\tconst backgroundStyles = setBackgroundStyleDefaults( style?.background );\n\n\tif ( ! backgroundStyles ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\tstyle: {\n\t\t\t...backgroundStyles,\n\t\t},\n\t};\n}\n\n/**\n * Generates a CSS class name if an background image is set.\n *\n * @param {Object} style A block's style attribute.\n *\n * @return {string} CSS class name.\n */\nexport function getBackgroundImageClasses( style ) {\n\treturn hasBackgroundImageValue( style ) ? 'has-background'
|
|
5
|
-
"mappings": ";AAGA,SAAS,uBAAuB;AAChC,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAK5B,OAAO,uBAAuB;AAC9B,SAAS,wBAAwB;AACjC,SAAS,SAAS,wBAAwB;AAC1C;AAAA,EACC,WAAW;AAAA,EACX;AAAA,EACA;AAAA,OACM;AACP,SAAS,2BAA2B;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport { cleanEmptyObject } from './utils';\nimport { store as blockEditorStore } from '../store';\nimport {\n\tdefault as StylesBackgroundPanel,\n\tuseHasBackgroundPanel,\n\thasBackgroundImageValue,\n\thasBackgroundGradientValue,\n} from '../components/global-styles/background-panel';\nimport { globalStylesDataKey } from '../store/private-keys';\n\nexport const BACKGROUND_SUPPORT_KEY = 'background';\n\n// Initial control values.\nexport const BACKGROUND_BLOCK_DEFAULT_VALUES = {\n\tbackgroundSize: 'cover',\n\tbackgroundPosition: '50% 50%', // used only when backgroundSize is 'contain'.\n};\n\n/**\n * Determine whether there is block support for background.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Background image feature to check for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBackgroundSupport( blockName, feature = 'any' ) {\n\tconst support = getBlockSupport( blockName, BACKGROUND_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn (\n\t\t\t!! support?.backgroundImage ||\n\t\t\t!! support?.backgroundSize ||\n\t\t\t!! support?.backgroundRepeat ||\n\t\t\t!! support?.gradient\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\nexport function setBackgroundStyleDefaults( backgroundStyle ) {\n\tif ( ! backgroundStyle || ! backgroundStyle?.backgroundImage?.url ) {\n\t\treturn;\n\t}\n\n\tlet backgroundStylesWithDefaults;\n\n\t// Set block background defaults.\n\tif ( ! backgroundStyle?.backgroundSize ) {\n\t\tbackgroundStylesWithDefaults = {\n\t\t\tbackgroundSize: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundSize,\n\t\t};\n\t}\n\n\tif (\n\t\t'contain' === backgroundStyle?.backgroundSize &&\n\t\t! backgroundStyle?.backgroundPosition\n\t) {\n\t\tbackgroundStylesWithDefaults = {\n\t\t\tbackgroundPosition:\n\t\t\t\tBACKGROUND_BLOCK_DEFAULT_VALUES.backgroundPosition,\n\t\t};\n\t}\n\treturn backgroundStylesWithDefaults;\n}\n\nfunction useBlockProps( { name, style } ) {\n\tif (\n\t\t! hasBackgroundSupport( name ) ||\n\t\t! style?.background?.backgroundImage\n\t) {\n\t\treturn;\n\t}\n\n\tconst backgroundStyles = setBackgroundStyleDefaults( style?.background );\n\n\tif ( ! backgroundStyles ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\tstyle: {\n\t\t\t...backgroundStyles,\n\t\t},\n\t};\n}\n\n/**\n * Generates a CSS class name if an background image is set.\n *\n * @param {Object} style A block's style attribute.\n *\n * @return {string} CSS class name.\n */\nexport function getBackgroundImageClasses( style ) {\n\treturn hasBackgroundImageValue( style ) ||\n\t\thasBackgroundGradientValue( style )\n\t\t? 'has-background'\n\t\t: '';\n}\n\nfunction BackgroundInspectorControl( {\n\tchildren,\n\tbackgroundGradientSupported = false,\n} ) {\n\tconst resetAllFilter = useCallback(\n\t\t( attributes ) => {\n\t\t\tconst updatedClassName = attributes.className?.includes(\n\t\t\t\t'has-background'\n\t\t\t)\n\t\t\t\t? attributes.className\n\t\t\t\t\t\t.split( ' ' )\n\t\t\t\t\t\t.filter( ( c ) => c !== 'has-background' )\n\t\t\t\t\t\t.join( ' ' ) || undefined\n\t\t\t\t: attributes.className;\n\t\t\treturn {\n\t\t\t\t...attributes,\n\t\t\t\tclassName: updatedClassName,\n\t\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t\t...attributes.style,\n\t\t\t\t\tbackground: undefined,\n\t\t\t\t\tcolor: backgroundGradientSupported\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t...attributes.style?.color,\n\t\t\t\t\t\t\t\tgradient: undefined,\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: attributes.style?.color,\n\t\t\t\t} ),\n\t\t\t};\n\t\t},\n\t\t[ backgroundGradientSupported ]\n\t);\n\treturn (\n\t\t<InspectorControls group=\"background\" resetAllFilter={ resetAllFilter }>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function BackgroundImagePanel( {\n\tclientId,\n\tname,\n\tsetAttributes,\n\tsettings,\n} ) {\n\tconst { style, className, inheritedValue } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockAttributes, getSettings } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst _settings = getSettings();\n\t\t\tconst blockAttributes = getBlockAttributes( clientId );\n\t\t\treturn {\n\t\t\t\tstyle: blockAttributes?.style,\n\t\t\t\tclassName: blockAttributes?.className,\n\t\t\t\t/*\n\t\t\t\t * To ensure we pass down the right inherited values:\n\t\t\t\t * @TODO 1. Pass inherited value down to all block style controls,\n\t\t\t\t * See: packages/block-editor/src/hooks/style.js\n\t\t\t\t * @TODO 2. Add support for block style variations,\n\t\t\t\t * See implementation: packages/block-editor/src/hooks/block-style-variation.js\n\t\t\t\t */\n\t\t\t\tinheritedValue:\n\t\t\t\t\t_settings[ globalStylesDataKey ]?.blocks?.[ name ],\n\t\t\t};\n\t\t},\n\t\t[ clientId, name ]\n\t);\n\n\tconst backgroundGradientSupported = hasBackgroundSupport(\n\t\tname,\n\t\t'gradient'\n\t);\n\n\t// Must be declared before the early return to follow Rules of Hooks.\n\t// Passes backgroundGradientSupported so that \"Reset All\" also clears\n\t// the legacy color.gradient value when background.gradient is supported.\n\tconst as = useCallback(\n\t\t( { children } ) => (\n\t\t\t<BackgroundInspectorControl\n\t\t\t\tbackgroundGradientSupported={ backgroundGradientSupported }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</BackgroundInspectorControl>\n\t\t),\n\t\t[ backgroundGradientSupported ]\n\t);\n\n\tif (\n\t\t! useHasBackgroundPanel( settings ) ||\n\t\t! hasBackgroundSupport( name )\n\t) {\n\t\treturn null;\n\t}\n\n\tconst onChange = ( newStyle ) => {\n\t\tconst isMigrating =\n\t\t\tbackgroundGradientSupported && !! style?.color?.gradient;\n\t\tconst newAttributes = {\n\t\t\tstyle: cleanEmptyObject(\n\t\t\t\tbackgroundGradientSupported\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t...newStyle,\n\t\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t\t...newStyle?.color,\n\t\t\t\t\t\t\t\tgradient: undefined,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t }\n\t\t\t\t\t: newStyle\n\t\t\t),\n\t\t};\n\n\t\t// When migrating from color.gradient to background.gradient, preserve\n\t\t// the has-background class so existing styles relying on it (e.g.\n\t\t// theme padding) are not silently broken. Only add the class when a\n\t\t// gradient value is being set \u2014 not when it is being cleared/reset.\n\t\t// Conversely, if the gradient is cleared and has-background was added\n\t\t// during a previous migration, remove it so it does not linger.\n\t\tif ( isMigrating && !! newStyle?.background?.gradient ) {\n\t\t\tnewAttributes.className = clsx( className, 'has-background' );\n\t\t} else if (\n\t\t\t! newStyle?.background?.gradient &&\n\t\t\tclassName?.includes( 'has-background' )\n\t\t) {\n\t\t\tnewAttributes.className =\n\t\t\t\tclassName\n\t\t\t\t\t.split( ' ' )\n\t\t\t\t\t.filter( ( c ) => c !== 'has-background' )\n\t\t\t\t\t.join( ' ' ) || undefined;\n\t\t}\n\n\t\tsetAttributes( newAttributes );\n\t};\n\n\t// When background.gradient is supported but not yet explicitly set, fall\n\t// back to color.gradient for display. Any write from this panel migrates\n\t// the value to background.gradient and clears color.gradient atomically.\n\tconst styleValue =\n\t\tbackgroundGradientSupported &&\n\t\t! style?.background?.gradient &&\n\t\tstyle?.color?.gradient\n\t\t\t? {\n\t\t\t\t\t...style,\n\t\t\t\t\tbackground: {\n\t\t\t\t\t\t...style?.background,\n\t\t\t\t\t\tgradient: style?.color?.gradient,\n\t\t\t\t\t},\n\t\t\t }\n\t\t\t: style;\n\n\tconst updatedSettings = {\n\t\t...settings,\n\t\tbackground: {\n\t\t\t...settings.background,\n\t\t\tbackgroundSize:\n\t\t\t\tsettings?.background?.backgroundSize &&\n\t\t\t\thasBackgroundSupport( name, 'backgroundSize' ),\n\t\t},\n\t};\n\n\tconst defaultControls = getBlockSupport( name, [\n\t\tBACKGROUND_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\treturn (\n\t\t<StylesBackgroundPanel\n\t\t\tinheritedValue={ inheritedValue }\n\t\t\tas={ as }\n\t\t\tpanelId={ clientId }\n\t\t\tdefaultValues={ BACKGROUND_BLOCK_DEFAULT_VALUES }\n\t\t\tsettings={ updatedSettings }\n\t\t\tonChange={ onChange }\n\t\t\tdefaultControls={ defaultControls }\n\t\t\tvalue={ styleValue }\n\t\t/>\n\t);\n}\n\nexport default {\n\tuseBlockProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport: hasBackgroundSupport,\n};\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,uBAAuB;AAChC,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAK5B,OAAO,uBAAuB;AAC9B,SAAS,wBAAwB;AACjC,SAAS,SAAS,wBAAwB;AAC1C;AAAA,EACC,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,2BAA2B;AAkIlC;AAhIK,IAAM,yBAAyB;AAG/B,IAAM,kCAAkC;AAAA,EAC9C,gBAAgB;AAAA,EAChB,oBAAoB;AAAA;AACrB;AAUO,SAAS,qBAAsB,WAAW,UAAU,OAAQ;AAClE,QAAM,UAAU,gBAAiB,WAAW,sBAAuB;AAEnE,MAAK,YAAY,MAAO;AACvB,WAAO;AAAA,EACR;AAEA,MAAK,YAAY,OAAQ;AACxB,WACC,CAAC,CAAE,SAAS,mBACZ,CAAC,CAAE,SAAS,kBACZ,CAAC,CAAE,SAAS,oBACZ,CAAC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AAU,YAAY,UAAW;AACvD,oBAAc,YAAY,KAAM,WAAW,gBAAiB;AAAA,IAC7D,WACC,CAAE,UAAU,YAAY,YACxB,WAAW,SAAU,gBAAiB,GACrC;AACD,oBAAc,YACb,UACE,MAAO,GAAI,EACX,OAAQ,CAAE,MAAO,MAAM,gBAAiB,EACxC,KAAM,GAAI,KAAK;AAAA,IACnB;AAEA,kBAAe,aAAc;AAAA,EAC9B;AAKA,QAAM,aACL,+BACA,CAAE,OAAO,YAAY,YACrB,OAAO,OAAO,WACX;AAAA,IACA,GAAG;AAAA,IACH,YAAY;AAAA,MACX,GAAG,OAAO;AAAA,MACV,UAAU,OAAO,OAAO;AAAA,IACzB;AAAA,EACA,IACA;AAEJ,QAAM,kBAAkB;AAAA,IACvB,GAAG;AAAA,IACH,YAAY;AAAA,MACX,GAAG,SAAS;AAAA,MACZ,gBACC,UAAU,YAAY,kBACtB,qBAAsB,MAAM,gBAAiB;AAAA,IAC/C;AAAA,EACD;AAEA,QAAM,kBAAkB,gBAAiB,MAAM;AAAA,IAC9C;AAAA,IACA;AAAA,EACD,CAAE;AAEF,SACC;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAU;AAAA,MACV,eAAgB;AAAA,MAChB,UAAW;AAAA,MACX;AAAA,MACA;AAAA,MACA,OAAQ;AAAA;AAAA,EACT;AAEF;AAEA,IAAO,qBAAQ;AAAA,EACd;AAAA,EACA,eAAe,CAAE,OAAQ;AAAA,EACzB,YAAY;AACb;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -34,12 +34,12 @@ if (window.crossOriginIsolated) {
|
|
|
34
34
|
if (!el.querySelectorAll) {
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
el.querySelectorAll(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (["
|
|
37
|
+
el.querySelectorAll("source,script,video,link").forEach(
|
|
38
|
+
(v) => {
|
|
39
|
+
addCrossOriginAttribute(v);
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
if (["SOURCE", "SCRIPT", "VIDEO", "LINK"].includes(
|
|
43
43
|
el.nodeName
|
|
44
44
|
)) {
|
|
45
45
|
addCrossOriginAttribute(el);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/cross-origin-isolation.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * Adds crossorigin=\"anonymous\" to an element if missing.\n *\n * @param {Element} el The element to modify.\n */\nfunction addCrossOriginAttribute( el ) {\n\tif ( ! el.hasAttribute( 'crossorigin' ) ) {\n\t\tel.setAttribute( 'crossorigin', 'anonymous' );\n\t}\n}\n\n// Only add the mutation observer if the site is cross-origin isolated.\nif ( window.crossOriginIsolated ) {\n\t/*\n\t * Detects dynamically added DOM nodes that are missing the `crossorigin` attribute.\n\t */\n\tconst observer = new window.MutationObserver( ( mutations ) => {\n\t\tmutations.forEach( ( mutation ) => {\n\t\t\t[ mutation.addedNodes, mutation.target ].forEach( ( value ) => {\n\t\t\t\tconst nodes =\n\t\t\t\t\tvalue instanceof window.NodeList ? value : [ value ];\n\t\t\t\tnodes.forEach( ( node ) => {\n\t\t\t\t\tconst el = node;\n\n\t\t\t\t\tif ( ! el.querySelectorAll ) {\n\t\t\t\t\t\t// Most likely a text node.\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tel.querySelectorAll(
|
|
5
|
-
"mappings": ";AAKA,SAAS,wBAAyB,IAAK;AACtC,MAAK,CAAE,GAAG,aAAc,aAAc,GAAI;AACzC,OAAG,aAAc,eAAe,WAAY;AAAA,EAC7C;AACD;AAGA,IAAK,OAAO,qBAAsB;AAsCjC,MAAS,qBAAT,WAA8B;AAC7B,QAAK,SAAS,MAAO;AACpB,eAAS,QAAS,SAAS,MAAM;AAAA,QAChC,WAAW;AAAA,QACX,YAAY;AAAA,QACZ,SAAS;AAAA,MACV,CAAE;AAAA,IACH,WAAY,SAAS,eAAe,WAAY;AAE/C,eAAS,iBAAkB,oBAAoB,MAAM;AACpD,YAAK,SAAS,MAAO;AACpB,mBAAS,QAAS,SAAS,MAAM;AAAA,YAChC,WAAW;AAAA,YACX,YAAY;AAAA,YACZ,SAAS;AAAA,UACV,CAAE;AAAA,QACH;AAAA,MACD,CAAE;AAAA,IACH;AAAA,EACD;AAnBS,EAAAA,sBAAA;AAlCT,QAAM,WAAW,IAAI,OAAO,iBAAkB,CAAE,cAAe;AAC9D,cAAU,QAAS,CAAE,aAAc;AAClC,OAAE,SAAS,YAAY,SAAS,MAAO,EAAE,QAAS,CAAE,UAAW;AAC9D,cAAM,QACL,iBAAiB,OAAO,WAAW,QAAQ,CAAE,KAAM;AACpD,cAAM,QAAS,CAAE,SAAU;AAC1B,gBAAM,KAAK;AAEX,cAAK,CAAE,GAAG,kBAAmB;AAE5B;AAAA,UACD;AAEA,aAAG
|
|
4
|
+
"sourcesContent": ["/**\n * Adds crossorigin=\"anonymous\" to an element if missing.\n *\n * @param {Element} el The element to modify.\n */\nfunction addCrossOriginAttribute( el ) {\n\tif ( ! el.hasAttribute( 'crossorigin' ) ) {\n\t\tel.setAttribute( 'crossorigin', 'anonymous' );\n\t}\n}\n\n// Only add the mutation observer if the site is cross-origin isolated.\nif ( window.crossOriginIsolated ) {\n\t/*\n\t * Detects dynamically added DOM nodes that are missing the `crossorigin` attribute.\n\t */\n\tconst observer = new window.MutationObserver( ( mutations ) => {\n\t\tmutations.forEach( ( mutation ) => {\n\t\t\t[ mutation.addedNodes, mutation.target ].forEach( ( value ) => {\n\t\t\t\tconst nodes =\n\t\t\t\t\tvalue instanceof window.NodeList ? value : [ value ];\n\t\t\t\tnodes.forEach( ( node ) => {\n\t\t\t\t\tconst el = node;\n\n\t\t\t\t\tif ( ! el.querySelectorAll ) {\n\t\t\t\t\t\t// Most likely a text node.\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tel.querySelectorAll( 'source,script,video,link' ).forEach(\n\t\t\t\t\t\t( v ) => {\n\t\t\t\t\t\t\taddCrossOriginAttribute( v );\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t[ 'SOURCE', 'SCRIPT', 'VIDEO', 'LINK' ].includes(\n\t\t\t\t\t\t\tel.nodeName\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\taddCrossOriginAttribute( el );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} );\n\t\t} );\n\t} );\n\n\t/**\n\t * Start observing the document body, waiting for it to be available if needed.\n\t */\n\tfunction startObservingBody() {\n\t\tif ( document.body ) {\n\t\t\tobserver.observe( document.body, {\n\t\t\t\tchildList: true,\n\t\t\t\tattributes: true,\n\t\t\t\tsubtree: true,\n\t\t\t} );\n\t\t} else if ( document.readyState === 'loading' ) {\n\t\t\t// Wait for DOM to be ready.\n\t\t\tdocument.addEventListener( 'DOMContentLoaded', () => {\n\t\t\t\tif ( document.body ) {\n\t\t\t\t\tobserver.observe( document.body, {\n\t\t\t\t\t\tchildList: true,\n\t\t\t\t\t\tattributes: true,\n\t\t\t\t\t\tsubtree: true,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t}\n\n\tstartObservingBody();\n}\n"],
|
|
5
|
+
"mappings": ";AAKA,SAAS,wBAAyB,IAAK;AACtC,MAAK,CAAE,GAAG,aAAc,aAAc,GAAI;AACzC,OAAG,aAAc,eAAe,WAAY;AAAA,EAC7C;AACD;AAGA,IAAK,OAAO,qBAAsB;AAsCjC,MAAS,qBAAT,WAA8B;AAC7B,QAAK,SAAS,MAAO;AACpB,eAAS,QAAS,SAAS,MAAM;AAAA,QAChC,WAAW;AAAA,QACX,YAAY;AAAA,QACZ,SAAS;AAAA,MACV,CAAE;AAAA,IACH,WAAY,SAAS,eAAe,WAAY;AAE/C,eAAS,iBAAkB,oBAAoB,MAAM;AACpD,YAAK,SAAS,MAAO;AACpB,mBAAS,QAAS,SAAS,MAAM;AAAA,YAChC,WAAW;AAAA,YACX,YAAY;AAAA,YACZ,SAAS;AAAA,UACV,CAAE;AAAA,QACH;AAAA,MACD,CAAE;AAAA,IACH;AAAA,EACD;AAnBS,EAAAA,sBAAA;AAlCT,QAAM,WAAW,IAAI,OAAO,iBAAkB,CAAE,cAAe;AAC9D,cAAU,QAAS,CAAE,aAAc;AAClC,OAAE,SAAS,YAAY,SAAS,MAAO,EAAE,QAAS,CAAE,UAAW;AAC9D,cAAM,QACL,iBAAiB,OAAO,WAAW,QAAQ,CAAE,KAAM;AACpD,cAAM,QAAS,CAAE,SAAU;AAC1B,gBAAM,KAAK;AAEX,cAAK,CAAE,GAAG,kBAAmB;AAE5B;AAAA,UACD;AAEA,aAAG,iBAAkB,0BAA2B,EAAE;AAAA,YACjD,CAAE,MAAO;AACR,sCAAyB,CAAE;AAAA,YAC5B;AAAA,UACD;AAEA,cACC,CAAE,UAAU,UAAU,SAAS,MAAO,EAAE;AAAA,YACvC,GAAG;AAAA,UACJ,GACC;AACD,oCAAyB,EAAG;AAAA,UAC7B;AAAA,QACD,CAAE;AAAA,MACH,CAAE;AAAA,IACH,CAAE;AAAA,EACH,CAAE;AA0BF,qBAAmB;AACpB;AAtBU,IAAAA;",
|
|
6
6
|
"names": ["startObservingBody"]
|
|
7
7
|
}
|
|
@@ -5,6 +5,7 @@ import { useInstanceId } from "@wordpress/compose";
|
|
|
5
5
|
import { getBlockType, hasBlockSupport } from "@wordpress/blocks";
|
|
6
6
|
import { __, sprintf } from "@wordpress/i18n";
|
|
7
7
|
import { processCSSNesting } from "@wordpress/global-styles-engine";
|
|
8
|
+
import { useBlockEditingMode } from "../components/block-editing-mode/index.mjs";
|
|
8
9
|
import InspectorControls from "../components/inspector-controls/index.mjs";
|
|
9
10
|
import AdvancedPanel, {
|
|
10
11
|
validateCSS
|
|
@@ -15,6 +16,10 @@ import { jsx } from "react/jsx-runtime";
|
|
|
15
16
|
var CUSTOM_CSS_INSTANCE_REFERENCE = {};
|
|
16
17
|
var EMPTY_STYLE = {};
|
|
17
18
|
function CustomCSSControl({ blockName, setAttributes, style }) {
|
|
19
|
+
const blockEditingMode = useBlockEditingMode();
|
|
20
|
+
if (blockEditingMode !== "default") {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
18
23
|
const blockType = getBlockType(blockName);
|
|
19
24
|
function onChange(newStyle) {
|
|
20
25
|
const css = newStyle?.css?.trim() ? newStyle.css : void 0;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/custom-css.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { getBlockType, hasBlockSupport } from '@wordpress/blocks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { processCSSNesting } from '@wordpress/global-styles-engine';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport AdvancedPanel, {\n\tvalidateCSS,\n} from '../components/global-styles/advanced-panel';\nimport { cleanEmptyObject, useStyleOverride } from './utils';\nimport { store as blockEditorStore } from '../store';\n\n// Stable reference for useInstanceId.\nconst CUSTOM_CSS_INSTANCE_REFERENCE = {};\n\n// Stable empty object reference for useSelect.\nconst EMPTY_STYLE = {};\n\n/**\n * Inspector control for custom CSS.\n *\n * @param {Object} props Component props.\n * @param {string} props.blockName Block name.\n * @param {Function} props.setAttributes Function to set block attributes.\n * @param {Object} props.style Block style attribute.\n */\nfunction CustomCSSControl( { blockName, setAttributes, style } ) {\n\tconst blockType = getBlockType( blockName );\n\n\tfunction onChange( newStyle ) {\n\t\t// Normalize whitespace-only CSS to undefined so it gets cleaned up.\n\t\tconst css = newStyle?.css?.trim() ? newStyle.css : undefined;\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( { ...newStyle, css } ),\n\t\t} );\n\t}\n\n\tconst cssHelpText = sprintf(\n\t\t// translators: %s: is the name of a block e.g., 'Image' or 'Quote'.\n\t\t__(\n\t\t\t'Add your own CSS to customize the appearance of the %s block. You do not need to include a CSS selector, just add the property and value, e.g. color: red;.'\n\t\t),\n\t\tblockType?.title\n\t);\n\n\treturn (\n\t\t<InspectorControls group=\"advanced\">\n\t\t\t<AdvancedPanel\n\t\t\t\tvalue={ style }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tinheritedValue={ style }\n\t\t\t\thelp={ cssHelpText }\n\t\t\t/>\n\t\t</InspectorControls>\n\t);\n}\n\nfunction CustomCSSEdit( { clientId, name, setAttributes } ) {\n\tconst { style, canEditCSS } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockAttributes, getSettings } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn {\n\t\t\t\tstyle: getBlockAttributes( clientId )?.style || EMPTY_STYLE,\n\t\t\t\tcanEditCSS: getSettings().canEditCSS,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// Don't render the panel if user lacks edit_css capability.\n\tif ( ! canEditCSS ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<CustomCSSControl\n\t\t\tblockName={ name }\n\t\t\tsetAttributes={ setAttributes }\n\t\t\tstyle={ style }\n\t\t/>\n\t);\n}\n\n/**\n * Hook to handle custom CSS for a block in the editor.\n * Generates a unique class and applies scoped CSS via style override.\n *\n * @param {Object} props Block props.\n * @param {Object} props.style Block style attribute.\n * @return {Object} Block props including className for custom CSS scoping.\n */\nfunction useBlockProps( { style } ) {\n\tconst customCSS = style?.css;\n\n\t// Validate CSS is non-empty and passes validation checks.\n\tconst isValidCSS =\n\t\ttypeof customCSS === 'string' &&\n\t\tcustomCSS.trim().length > 0 &&\n\t\tvalidateCSS( customCSS );\n\n\tconst customCSSIdentifier = useInstanceId(\n\t\tCUSTOM_CSS_INSTANCE_REFERENCE,\n\t\t'wp-custom-css'\n\t);\n\n\tconst customCSSSelector = `.${ customCSSIdentifier }`;\n\n\t// Transform the custom CSS using the same logic as global styles.\n\t// Only process if CSS is valid (doesn't contain HTML markup).\n\tconst transformedCSS = useMemo( () => {\n\t\tif ( ! isValidCSS ) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn processCSSNesting( customCSS, customCSSSelector );\n\t}, [ customCSS, customCSSSelector, isValidCSS ] );\n\n\t// Inject the CSS via style override.\n\tuseStyleOverride( { css: transformedCSS } );\n\n\t// Only add the class if there's valid custom CSS.\n\tif ( ! isValidCSS ) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\tclassName: `has-custom-css ${ customCSSIdentifier }`,\n\t};\n}\n\n/**\n * Adds a marker class to blocks with custom CSS for server-side rendering.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type definition.\n * @param {Object} attributes Block's attributes.\n * @return {Object} Filtered props applied to save element.\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif ( ! hasBlockSupport( blockType, 'customCSS', true ) ) {\n\t\treturn props;\n\t}\n\n\tif ( ! attributes?.style?.css?.trim() ) {\n\t\treturn props;\n\t}\n\n\t// Add a class to indicate this block has custom CSS.\n\t// The actual CSS is rendered server-side using the render_block filter.\n\tconst className = props.className\n\t\t? `${ props.className } has-custom-css`\n\t\t: 'has-custom-css';\n\n\treturn {\n\t\t...props,\n\t\tclassName,\n\t};\n}\n\nexport default {\n\tedit: CustomCSSEdit,\n\tuseBlockProps,\n\taddSaveProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, 'customCSS', true );\n\t},\n};\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAC9B,SAAS,cAAc,uBAAuB;AAC9C,SAAS,IAAI,eAAe;AAC5B,SAAS,yBAAyB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { getBlockType, hasBlockSupport } from '@wordpress/blocks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { processCSSNesting } from '@wordpress/global-styles-engine';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport AdvancedPanel, {\n\tvalidateCSS,\n} from '../components/global-styles/advanced-panel';\nimport { cleanEmptyObject, useStyleOverride } from './utils';\nimport { store as blockEditorStore } from '../store';\n\n// Stable reference for useInstanceId.\nconst CUSTOM_CSS_INSTANCE_REFERENCE = {};\n\n// Stable empty object reference for useSelect.\nconst EMPTY_STYLE = {};\n\n/**\n * Inspector control for custom CSS.\n *\n * @param {Object} props Component props.\n * @param {string} props.blockName Block name.\n * @param {Function} props.setAttributes Function to set block attributes.\n * @param {Object} props.style Block style attribute.\n */\nfunction CustomCSSControl( { blockName, setAttributes, style } ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tif ( blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\tconst blockType = getBlockType( blockName );\n\n\tfunction onChange( newStyle ) {\n\t\t// Normalize whitespace-only CSS to undefined so it gets cleaned up.\n\t\tconst css = newStyle?.css?.trim() ? newStyle.css : undefined;\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( { ...newStyle, css } ),\n\t\t} );\n\t}\n\n\tconst cssHelpText = sprintf(\n\t\t// translators: %s: is the name of a block e.g., 'Image' or 'Quote'.\n\t\t__(\n\t\t\t'Add your own CSS to customize the appearance of the %s block. You do not need to include a CSS selector, just add the property and value, e.g. color: red;.'\n\t\t),\n\t\tblockType?.title\n\t);\n\n\treturn (\n\t\t<InspectorControls group=\"advanced\">\n\t\t\t<AdvancedPanel\n\t\t\t\tvalue={ style }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tinheritedValue={ style }\n\t\t\t\thelp={ cssHelpText }\n\t\t\t/>\n\t\t</InspectorControls>\n\t);\n}\n\nfunction CustomCSSEdit( { clientId, name, setAttributes } ) {\n\tconst { style, canEditCSS } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockAttributes, getSettings } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn {\n\t\t\t\tstyle: getBlockAttributes( clientId )?.style || EMPTY_STYLE,\n\t\t\t\tcanEditCSS: getSettings().canEditCSS,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// Don't render the panel if user lacks edit_css capability.\n\tif ( ! canEditCSS ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<CustomCSSControl\n\t\t\tblockName={ name }\n\t\t\tsetAttributes={ setAttributes }\n\t\t\tstyle={ style }\n\t\t/>\n\t);\n}\n\n/**\n * Hook to handle custom CSS for a block in the editor.\n * Generates a unique class and applies scoped CSS via style override.\n *\n * @param {Object} props Block props.\n * @param {Object} props.style Block style attribute.\n * @return {Object} Block props including className for custom CSS scoping.\n */\nfunction useBlockProps( { style } ) {\n\tconst customCSS = style?.css;\n\n\t// Validate CSS is non-empty and passes validation checks.\n\tconst isValidCSS =\n\t\ttypeof customCSS === 'string' &&\n\t\tcustomCSS.trim().length > 0 &&\n\t\tvalidateCSS( customCSS );\n\n\tconst customCSSIdentifier = useInstanceId(\n\t\tCUSTOM_CSS_INSTANCE_REFERENCE,\n\t\t'wp-custom-css'\n\t);\n\n\tconst customCSSSelector = `.${ customCSSIdentifier }`;\n\n\t// Transform the custom CSS using the same logic as global styles.\n\t// Only process if CSS is valid (doesn't contain HTML markup).\n\tconst transformedCSS = useMemo( () => {\n\t\tif ( ! isValidCSS ) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn processCSSNesting( customCSS, customCSSSelector );\n\t}, [ customCSS, customCSSSelector, isValidCSS ] );\n\n\t// Inject the CSS via style override.\n\tuseStyleOverride( { css: transformedCSS } );\n\n\t// Only add the class if there's valid custom CSS.\n\tif ( ! isValidCSS ) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\tclassName: `has-custom-css ${ customCSSIdentifier }`,\n\t};\n}\n\n/**\n * Adds a marker class to blocks with custom CSS for server-side rendering.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type definition.\n * @param {Object} attributes Block's attributes.\n * @return {Object} Filtered props applied to save element.\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif ( ! hasBlockSupport( blockType, 'customCSS', true ) ) {\n\t\treturn props;\n\t}\n\n\tif ( ! attributes?.style?.css?.trim() ) {\n\t\treturn props;\n\t}\n\n\t// Add a class to indicate this block has custom CSS.\n\t// The actual CSS is rendered server-side using the render_block filter.\n\tconst className = props.className\n\t\t? `${ props.className } has-custom-css`\n\t\t: 'has-custom-css';\n\n\treturn {\n\t\t...props,\n\t\tclassName,\n\t};\n}\n\nexport default {\n\tedit: CustomCSSEdit,\n\tuseBlockProps,\n\taddSaveProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, 'customCSS', true );\n\t},\n};\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAC9B,SAAS,cAAc,uBAAuB;AAC9C,SAAS,IAAI,eAAe;AAC5B,SAAS,yBAAyB;AAClC,SAAS,2BAA2B;AAKpC,OAAO,uBAAuB;AAC9B,OAAO;AAAA,EACN;AAAA,OACM;AACP,SAAS,kBAAkB,wBAAwB;AACnD,SAAS,SAAS,wBAAwB;AA0CvC;AAvCH,IAAM,gCAAgC,CAAC;AAGvC,IAAM,cAAc,CAAC;AAUrB,SAAS,iBAAkB,EAAE,WAAW,eAAe,MAAM,GAAI;AAChE,QAAM,mBAAmB,oBAAoB;AAE7C,MAAK,qBAAqB,WAAY;AACrC,WAAO;AAAA,EACR;AACA,QAAM,YAAY,aAAc,SAAU;AAE1C,WAAS,SAAU,UA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AAE;AAGhD,mBAAkB,EAAE,KAAK,eAAe,CAAE;AAG1C,MAAK,CAAE,YAAa;AACnB,WAAO,CAAC;AAAA,EACT;AAEA,SAAO;AAAA,IACN,WAAW,kBAAmB,mBAAoB;AAAA,EACnD;AACD;AAUA,SAAS,aAAc,OAAO,WAAW,YAAa;AACrD,MAAK,CAAE,gBAAiB,WAAW,aAAa,IAAK,GAAI;AACxD,WAAO;AAAA,EACR;AAEA,MAAK,CAAE,YAAY,OAAO,KAAK,KAAK,GAAI;AACvC,WAAO;AAAA,EACR;AAIA,QAAM,YAAY,MAAM,YACrB,GAAI,MAAM,SAAU,oBACpB;AAEH,SAAO;AAAA,IACN,GAAG;AAAA,IACH;AAAA,EACD;AACD;AAEA,IAAO,qBAAQ;AAAA,EACd,MAAM;AAAA,EACN;AAAA,EACA;AAAA,EACA,eAAe,CAAE,OAAQ;AAAA,EACzB,WAAY,MAAO;AAClB,WAAO,gBAAiB,MAAM,aAAa,IAAK;AAAA,EACjD;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -155,13 +155,12 @@ function FitTextControl({
|
|
|
155
155
|
setAttributes,
|
|
156
156
|
name,
|
|
157
157
|
fontSize,
|
|
158
|
-
style
|
|
159
|
-
warning
|
|
158
|
+
style
|
|
160
159
|
}) {
|
|
161
160
|
if (!hasBlockSupport(name, FIT_TEXT_SUPPORT_KEY)) {
|
|
162
161
|
return null;
|
|
163
162
|
}
|
|
164
|
-
return /* @__PURE__ */ jsx(
|
|
163
|
+
return /* @__PURE__ */ jsx(
|
|
165
164
|
ToolsPanelItem,
|
|
166
165
|
{
|
|
167
166
|
hasValue: () => fitText,
|
|
@@ -169,40 +168,37 @@ function FitTextControl({
|
|
|
169
168
|
onDeselect: () => setAttributes({ fitText: void 0 }),
|
|
170
169
|
resetAllFilter: () => ({ fitText: void 0 }),
|
|
171
170
|
panelId: clientId,
|
|
172
|
-
children:
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
if (
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
typography
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
};
|
|
193
|
-
}
|
|
171
|
+
children: /* @__PURE__ */ jsx(
|
|
172
|
+
ToggleControl,
|
|
173
|
+
{
|
|
174
|
+
label: __("Fit text"),
|
|
175
|
+
checked: fitText,
|
|
176
|
+
onChange: () => {
|
|
177
|
+
const newFitText = !fitText || void 0;
|
|
178
|
+
const updates = { fitText: newFitText };
|
|
179
|
+
if (newFitText) {
|
|
180
|
+
if (fontSize) {
|
|
181
|
+
updates.fontSize = void 0;
|
|
182
|
+
}
|
|
183
|
+
if (style?.typography?.fontSize) {
|
|
184
|
+
updates.style = {
|
|
185
|
+
...style,
|
|
186
|
+
typography: {
|
|
187
|
+
...style?.typography,
|
|
188
|
+
fontSize: void 0
|
|
189
|
+
}
|
|
190
|
+
};
|
|
194
191
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
]
|
|
192
|
+
}
|
|
193
|
+
setAttributes(updates);
|
|
194
|
+
},
|
|
195
|
+
help: fitText ? __("Text will resize to fit its container.") : __(
|
|
196
|
+
"The text will resize to fit its container, resetting other font size settings."
|
|
197
|
+
)
|
|
198
|
+
}
|
|
199
|
+
)
|
|
204
200
|
}
|
|
205
|
-
)
|
|
201
|
+
);
|
|
206
202
|
}
|
|
207
203
|
function addSaveProps(props, blockType, attributes) {
|
|
208
204
|
if (!hasBlockSupport(blockType, FIT_TEXT_SUPPORT_KEY)) {
|
|
@@ -234,9 +230,12 @@ addFilter(
|
|
|
234
230
|
var hasFitTextSupport = (blockNameOrType) => {
|
|
235
231
|
return hasBlockSupport(blockNameOrType, FIT_TEXT_SUPPORT_KEY);
|
|
236
232
|
};
|
|
237
|
-
function
|
|
233
|
+
function FitTextFontSize({ fitText, name, clientId, isSelected }) {
|
|
238
234
|
const { fontSize } = useFitText({ fitText, name, clientId });
|
|
239
|
-
|
|
235
|
+
if (isSelected && fontSize && fontSize < MIN_FONT_SIZE_FOR_WARNING) {
|
|
236
|
+
return /* @__PURE__ */ jsx(InspectorControls, { group: "typography", children: /* @__PURE__ */ jsx(FitTextSizeWarning, {}) });
|
|
237
|
+
}
|
|
238
|
+
return null;
|
|
240
239
|
}
|
|
241
240
|
var addFitTextControl = createHigherOrderComponent((BlockEdit) => {
|
|
242
241
|
return function AddFitTextControl(props) {
|
|
@@ -248,27 +247,7 @@ var addFitTextControl = createHigherOrderComponent((BlockEdit) => {
|
|
|
248
247
|
}
|
|
249
248
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
250
249
|
/* @__PURE__ */ jsx(BlockEdit, { ...props }),
|
|
251
|
-
|
|
252
|
-
WithFitTextFontSize,
|
|
253
|
-
{
|
|
254
|
-
fitText,
|
|
255
|
-
name,
|
|
256
|
-
clientId,
|
|
257
|
-
children: (fontSize) => isSelected && /* @__PURE__ */ jsx(
|
|
258
|
-
FitTextControl,
|
|
259
|
-
{
|
|
260
|
-
clientId,
|
|
261
|
-
fitText,
|
|
262
|
-
setAttributes,
|
|
263
|
-
name,
|
|
264
|
-
fontSize: attributes.fontSize,
|
|
265
|
-
style: attributes.style,
|
|
266
|
-
warning: fontSize < MIN_FONT_SIZE_FOR_WARNING && /* @__PURE__ */ jsx(FitTextSizeWarning, {})
|
|
267
|
-
}
|
|
268
|
-
)
|
|
269
|
-
}
|
|
270
|
-
),
|
|
271
|
-
!fitText && isSelected && /* @__PURE__ */ jsx(
|
|
250
|
+
/* @__PURE__ */ jsx(InspectorControls, { group: "typography", children: /* @__PURE__ */ jsx(
|
|
272
251
|
FitTextControl,
|
|
273
252
|
{
|
|
274
253
|
clientId,
|
|
@@ -278,6 +257,15 @@ var addFitTextControl = createHigherOrderComponent((BlockEdit) => {
|
|
|
278
257
|
fontSize: attributes.fontSize,
|
|
279
258
|
style: attributes.style
|
|
280
259
|
}
|
|
260
|
+
) }),
|
|
261
|
+
fitText && /* @__PURE__ */ jsx(
|
|
262
|
+
FitTextFontSize,
|
|
263
|
+
{
|
|
264
|
+
fitText,
|
|
265
|
+
name,
|
|
266
|
+
clientId,
|
|
267
|
+
isSelected
|
|
268
|
+
}
|
|
281
269
|
)
|
|
282
270
|
] });
|
|
283
271
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/fit-text.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { useEffect, useCallback, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tToggleControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\nconst EMPTY_OBJECT = {};\nconst MIN_FONT_SIZE_FOR_WARNING = 12;\n\n/**\n * Internal dependencies\n */\nimport { optimizeFitText } from '../utils/fit-text-utils';\nimport { store as blockEditorStore } from '../store';\nimport { useBlockElement } from '../components/block-list/use-block-props/use-block-refs';\nimport InspectorControls from '../components/inspector-controls';\nimport FitTextSizeWarning from '../components/fit-text-size-warning';\n\nexport const FIT_TEXT_SUPPORT_KEY = 'typography.fitText';\n\n/**\n * Filters registered block settings, extending attributes to include\n * the `fitText` attribute.\n *\n * @param {Object} settings Original block settings.\n * @return {Object} Filtered block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBlockSupport( settings, FIT_TEXT_SUPPORT_KEY ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition.\n\tif ( settings.attributes?.fitText ) {\n\t\treturn settings;\n\t}\n\n\t// Add fitText attribute.\n\treturn {\n\t\t...settings,\n\t\tattributes: {\n\t\t\t...settings.attributes,\n\t\t\tfitText: {\n\t\t\t\ttype: 'boolean',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Custom hook to handle fit text functionality in the editor.\n *\n * @param {Object} props Component props.\n * @param {?boolean} props.fitText Fit text attribute.\n * @param {string} props.name Block name.\n * @param {string} props.clientId Block client ID.\n */\nfunction useFitText( { fitText, name, clientId } ) {\n\tconst [ fontSize, setFontSize ] = useState( null );\n\tconst hasFitTextSupport = hasBlockSupport( name, FIT_TEXT_SUPPORT_KEY );\n\tconst blockElement = useBlockElement( clientId );\n\n\t// Monitor block attribute changes, parent changes, and block mode.\n\t// Any attribute or parent change may change the available space.\n\t// Block mode is needed to disable fit text when in HTML editing mode.\n\tconst { blockAttributes, parentId, blockMode } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId || ! hasFitTextSupport || ! fitText ) {\n\t\t\t\treturn EMPTY_OBJECT;\n\t\t\t}\n\t\t\tconst _blockMode =\n\t\t\t\tselect( blockEditorStore ).getBlockMode( clientId );\n\t\t\tif ( _blockMode === 'html' ) {\n\t\t\t\treturn { blockMode: _blockMode };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tblockAttributes:\n\t\t\t\t\tselect( blockEditorStore ).getBlockAttributes( clientId ),\n\t\t\t\tparentId:\n\t\t\t\t\tselect( blockEditorStore ).getBlockRootClientId( clientId ),\n\t\t\t\tblockMode: _blockMode,\n\t\t\t};\n\t\t},\n\t\t[ clientId, hasFitTextSupport, fitText ]\n\t);\n\n\tconst applyFitText = useCallback( () => {\n\t\tif ( ! blockElement || ! hasFitTextSupport || ! fitText ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Get or create style element with unique ID\n\t\tconst styleId = `fit-text-${ clientId }`;\n\t\tlet styleElement = blockElement.ownerDocument.getElementById( styleId );\n\t\tif ( ! styleElement ) {\n\t\t\tstyleElement = blockElement.ownerDocument.createElement( 'style' );\n\t\t\tstyleElement.id = styleId;\n\t\t\tblockElement.ownerDocument.head.appendChild( styleElement );\n\t\t}\n\n\t\tconst blockSelector = `#block-${ clientId }`;\n\n\t\tconst applyFontSizeStyle = ( size ) => {\n\t\t\tif ( size === 0 ) {\n\t\t\t\tstyleElement.textContent = '';\n\t\t\t} else {\n\t\t\t\tstyleElement.textContent = `${ blockSelector } { font-size: ${ size }px !important; }`;\n\t\t\t}\n\t\t};\n\n\t\tconst optimalSize = optimizeFitText( blockElement, applyFontSizeStyle );\n\t\tsetFontSize( optimalSize );\n\t}, [ blockElement, clientId, hasFitTextSupport, fitText ] );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\t! fitText ||\n\t\t\t! blockElement ||\n\t\t\t! clientId ||\n\t\t\t! hasFitTextSupport ||\n\t\t\tblockMode === 'html'\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Store current element value for cleanup\n\t\tconst currentElement = blockElement;\n\t\tconst previousVisibility = currentElement.style.visibility;\n\n\t\t// Store IDs for cleanup\n\t\tlet hideFrameId = null;\n\t\tlet calculateFrameId = null;\n\t\tlet showTimeoutId = null;\n\n\t\t// We are hiding the element doing the calculation of fit text\n\t\t// and then showing it again to avoid the user noticing a flash of potentially\n\t\t// big fitText while the binary search is happening.\n\t\thideFrameId = window.requestAnimationFrame( () => {\n\t\t\tcurrentElement.style.visibility = 'hidden';\n\t\t\t// Wait for browser to render the hidden state\n\t\t\tcalculateFrameId = window.requestAnimationFrame( () => {\n\t\t\t\tapplyFitText();\n\n\t\t\t\t// Using a timeout instead of requestAnimationFrame, because\n\t\t\t\t// with requestAnimationFrame a flash of very high size\n\t\t\t\t// can still occur although rare.\n\t\t\t\tshowTimeoutId = setTimeout( () => {\n\t\t\t\t\tcurrentElement.style.visibility = previousVisibility;\n\t\t\t\t}, 10 );\n\t\t\t} );\n\t\t} );\n\n\t\t// Watch for size changes\n\t\tlet resizeObserver;\n\t\tif ( window.ResizeObserver && currentElement.parentElement ) {\n\t\t\tresizeObserver = new window.ResizeObserver( applyFitText );\n\t\t\tresizeObserver.observe( currentElement.parentElement );\n\t\t\tresizeObserver.observe( currentElement );\n\t\t}\n\n\t\t// Cleanup function\n\t\treturn () => {\n\t\t\t// Cancel pending async operations\n\t\t\tif ( hideFrameId !== null ) {\n\t\t\t\twindow.cancelAnimationFrame( hideFrameId );\n\t\t\t}\n\t\t\tif ( calculateFrameId !== null ) {\n\t\t\t\twindow.cancelAnimationFrame( calculateFrameId );\n\t\t\t}\n\t\t\tif ( showTimeoutId !== null ) {\n\t\t\t\tclearTimeout( showTimeoutId );\n\t\t\t}\n\n\t\t\tif ( resizeObserver ) {\n\t\t\t\tresizeObserver.disconnect();\n\t\t\t}\n\n\t\t\tconst styleId = `fit-text-${ clientId }`;\n\t\t\tconst styleElement =\n\t\t\t\tcurrentElement.ownerDocument.getElementById( styleId );\n\t\t\tif ( styleElement ) {\n\t\t\t\tstyleElement.remove();\n\t\t\t}\n\t\t};\n\t}, [\n\t\tfitText,\n\t\tclientId,\n\t\tparentId,\n\t\tapplyFitText,\n\t\tblockElement,\n\t\thasFitTextSupport,\n\t\tblockMode,\n\t] );\n\n\t// Trigger fit text recalculation when content changes\n\tuseEffect( () => {\n\t\tif (\n\t\t\tfitText &&\n\t\t\tblockElement &&\n\t\t\thasFitTextSupport &&\n\t\t\tblockMode !== 'html'\n\t\t) {\n\t\t\t// Wait for next frame to ensure DOM has updated after content changes\n\t\t\tconst frameId = window.requestAnimationFrame( () => {\n\t\t\t\tif ( blockElement ) {\n\t\t\t\t\tapplyFitText();\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\treturn () => window.cancelAnimationFrame( frameId );\n\t\t}\n\t}, [\n\t\tblockAttributes,\n\t\tfitText,\n\t\tapplyFitText,\n\t\tblockElement,\n\t\thasFitTextSupport,\n\t\tblockMode,\n\t] );\n\n\treturn { fontSize };\n}\n\n/**\n * Fit text control component for the typography panel.\n *\n * @param {Object} props Component props.\n * @param {string} props.clientId Block client ID.\n * @param {Function} props.setAttributes Function to set block attributes.\n * @param {string} props.name Block name.\n * @param {boolean} props.fitText Whether fit text is enabled.\n * @param {string} props.fontSize Font size slug.\n * @param {Object} props.style Block style object.\n * @param {React.JSX.Element} props.warning Warning component to display.\n */\nexport function FitTextControl( {\n\tclientId,\n\tfitText = false,\n\tsetAttributes,\n\tname,\n\tfontSize,\n\tstyle,\n\twarning,\n} ) {\n\tif ( ! hasBlockSupport( name, FIT_TEXT_SUPPORT_KEY ) ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<InspectorControls group=\"typography\">\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => fitText }\n\t\t\t\tlabel={ __( 'Fit text' ) }\n\t\t\t\tonDeselect={ () => setAttributes( { fitText: undefined } ) }\n\t\t\t\tresetAllFilter={ () => ( { fitText: undefined } ) }\n\t\t\t\tpanelId={ clientId }\n\t\t\t>\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Fit text' ) }\n\t\t\t\t\tchecked={ fitText }\n\t\t\t\t\tonChange={ () => {\n\t\t\t\t\t\tconst newFitText = ! fitText || undefined;\n\t\t\t\t\t\tconst updates = { fitText: newFitText };\n\n\t\t\t\t\t\t// When enabling fit text, clear font size if it has a value\n\t\t\t\t\t\tif ( newFitText ) {\n\t\t\t\t\t\t\tif ( fontSize ) {\n\t\t\t\t\t\t\t\tupdates.fontSize = undefined;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif ( style?.typography?.fontSize ) {\n\t\t\t\t\t\t\t\tupdates.style = {\n\t\t\t\t\t\t\t\t\t...style,\n\t\t\t\t\t\t\t\t\ttypography: {\n\t\t\t\t\t\t\t\t\t\t...style?.typography,\n\t\t\t\t\t\t\t\t\t\tfontSize: undefined,\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\n\t\t\t\t\t\tsetAttributes( updates );\n\t\t\t\t\t} }\n\t\t\t\t\thelp={\n\t\t\t\t\t\tfitText\n\t\t\t\t\t\t\t? __( 'Text will resize to fit its container.' )\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'The text will resize to fit its container, resetting other font size settings.'\n\t\t\t\t\t\t\t )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t{ warning }\n\t\t\t</ToolsPanelItem>\n\t\t</InspectorControls>\n\t);\n}\n\n/**\n * Override props applied to the block element on save.\n *\n * @param {Object} props Additional props applied to the block element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Block attributes.\n * @return {Object} Filtered props applied to the block element.\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif ( ! hasBlockSupport( blockType, FIT_TEXT_SUPPORT_KEY ) ) {\n\t\treturn props;\n\t}\n\n\tconst { fitText } = attributes;\n\n\tif ( ! fitText ) {\n\t\treturn props;\n\t}\n\n\t// Add CSS class for frontend detection and styling\n\tconst className = props.className\n\t\t? `${ props.className } has-fit-text`\n\t\t: 'has-fit-text';\n\n\treturn {\n\t\t...props,\n\t\tclassName,\n\t};\n}\n\n/**\n * Override props applied to the block element in the editor.\n *\n * @param {Object} props Component props including block attributes.\n * @param {string} props.name Block name.\n * @param {boolean} props.fitText Whether fit text is enabled.\n * @return {Object} Filtered props applied to the block element.\n */\nfunction useBlockProps( { name, fitText } ) {\n\tif ( fitText && hasBlockSupport( name, FIT_TEXT_SUPPORT_KEY ) ) {\n\t\treturn {\n\t\t\tclassName: 'has-fit-text',\n\t\t};\n\t}\n\treturn {};\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/fit-text/addAttribute',\n\taddAttributes\n);\n\nconst hasFitTextSupport = ( blockNameOrType ) => {\n\treturn hasBlockSupport( blockNameOrType, FIT_TEXT_SUPPORT_KEY );\n};\n\n/*\n * Helper to encapsulate calls to the relatively expensive `useFitText` hook.\n * Used in `addFitTextControl` so that the hook is only called when a block's\n * `fitText` attribute is set.\n */\nfunction WithFitTextFontSize( { fitText, name, clientId, children } ) {\n\tconst { fontSize } = useFitText( { fitText, name, clientId } );\n\treturn children( fontSize );\n}\n\n/*\n * Fit-text requires that layout calculations be done even when a block is not\n * currently selected. Therefore, the regular hooking approach using an\n * exported `edit` method is not enough, and we must use this HoC with the\n * `editor.BlockEdit` filter.\n */\nconst addFitTextControl = createHigherOrderComponent( ( BlockEdit ) => {\n\treturn function AddFitTextControl( props ) {\n\t\tconst { name, attributes, clientId, isSelected, setAttributes } = props;\n\t\tconst { fitText } = attributes;\n\t\tconst supportsFitText = hasBlockSupport( name, FIT_TEXT_SUPPORT_KEY );\n\t\tif ( ! supportsFitText ) {\n\t\t\treturn <BlockEdit { ...props } />;\n\t\t}\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t{ fitText && (\n\t\t\t\t\t<WithFitTextFontSize\n\t\t\t\t\t\tfitText={ fitText }\n\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ( fontSize ) =>\n\t\t\t\t\t\t\tisSelected && (\n\t\t\t\t\t\t\t\t<FitTextControl\n\t\t\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\t\t\tfitText={ fitText }\n\t\t\t\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\t\t\t\tfontSize={ attributes.fontSize }\n\t\t\t\t\t\t\t\t\tstyle={ attributes.style }\n\t\t\t\t\t\t\t\t\twarning={\n\t\t\t\t\t\t\t\t\t\tfontSize <\n\t\t\t\t\t\t\t\t\t\t\tMIN_FONT_SIZE_FOR_WARNING && (\n\t\t\t\t\t\t\t\t\t\t\t<FitTextSizeWarning />\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/>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t</WithFitTextFontSize>\n\t\t\t\t) }\n\t\t\t\t{ ! fitText && isSelected && (\n\t\t\t\t\t<FitTextControl\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tfitText={ fitText }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\tfontSize={ attributes.fontSize }\n\t\t\t\t\t\tstyle={ attributes.style }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t};\n}, 'addFitTextControl' );\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/fit-text/add-fit-text-control',\n\taddFitTextControl\n);\n\nexport default {\n\tuseBlockProps,\n\taddSaveProps,\n\tattributeKeys: [ 'fitText', 'fontSize', 'style' ],\n\thasSupport: hasFitTextSupport,\n\tedit: () => null,\n};\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAChC,SAAS,WAAW,aAAa,gBAAgB;AACjD,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA,gCAAgC;AAAA,OAC1B;AACP,SAAS,kCAAkC;AAQ3C,SAAS,uBAAuB;AAChC,SAAS,SAAS,wBAAwB;AAC1C,SAAS,uBAAuB;AAChC,OAAO,uBAAuB;AAC9B,OAAO,wBAAwB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { useEffect, useCallback, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tToggleControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\nconst EMPTY_OBJECT = {};\nconst MIN_FONT_SIZE_FOR_WARNING = 12;\n\n/**\n * Internal dependencies\n */\nimport { optimizeFitText } from '../utils/fit-text-utils';\nimport { store as blockEditorStore } from '../store';\nimport { useBlockElement } from '../components/block-list/use-block-props/use-block-refs';\nimport InspectorControls from '../components/inspector-controls';\nimport FitTextSizeWarning from '../components/fit-text-size-warning';\n\nexport const FIT_TEXT_SUPPORT_KEY = 'typography.fitText';\n\n/**\n * Filters registered block settings, extending attributes to include\n * the `fitText` attribute.\n *\n * @param {Object} settings Original block settings.\n * @return {Object} Filtered block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBlockSupport( settings, FIT_TEXT_SUPPORT_KEY ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition.\n\tif ( settings.attributes?.fitText ) {\n\t\treturn settings;\n\t}\n\n\t// Add fitText attribute.\n\treturn {\n\t\t...settings,\n\t\tattributes: {\n\t\t\t...settings.attributes,\n\t\t\tfitText: {\n\t\t\t\ttype: 'boolean',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Custom hook to handle fit text functionality in the editor.\n *\n * @param {Object} props Component props.\n * @param {?boolean} props.fitText Fit text attribute.\n * @param {string} props.name Block name.\n * @param {string} props.clientId Block client ID.\n */\nfunction useFitText( { fitText, name, clientId } ) {\n\tconst [ fontSize, setFontSize ] = useState( null );\n\tconst hasFitTextSupport = hasBlockSupport( name, FIT_TEXT_SUPPORT_KEY );\n\tconst blockElement = useBlockElement( clientId );\n\n\t// Monitor block attribute changes, parent changes, and block mode.\n\t// Any attribute or parent change may change the available space.\n\t// Block mode is needed to disable fit text when in HTML editing mode.\n\tconst { blockAttributes, parentId, blockMode } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId || ! hasFitTextSupport || ! fitText ) {\n\t\t\t\treturn EMPTY_OBJECT;\n\t\t\t}\n\t\t\tconst _blockMode =\n\t\t\t\tselect( blockEditorStore ).getBlockMode( clientId );\n\t\t\tif ( _blockMode === 'html' ) {\n\t\t\t\treturn { blockMode: _blockMode };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tblockAttributes:\n\t\t\t\t\tselect( blockEditorStore ).getBlockAttributes( clientId ),\n\t\t\t\tparentId:\n\t\t\t\t\tselect( blockEditorStore ).getBlockRootClientId( clientId ),\n\t\t\t\tblockMode: _blockMode,\n\t\t\t};\n\t\t},\n\t\t[ clientId, hasFitTextSupport, fitText ]\n\t);\n\n\tconst applyFitText = useCallback( () => {\n\t\tif ( ! blockElement || ! hasFitTextSupport || ! fitText ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Get or create style element with unique ID\n\t\tconst styleId = `fit-text-${ clientId }`;\n\t\tlet styleElement = blockElement.ownerDocument.getElementById( styleId );\n\t\tif ( ! styleElement ) {\n\t\t\tstyleElement = blockElement.ownerDocument.createElement( 'style' );\n\t\t\tstyleElement.id = styleId;\n\t\t\tblockElement.ownerDocument.head.appendChild( styleElement );\n\t\t}\n\n\t\tconst blockSelector = `#block-${ clientId }`;\n\n\t\tconst applyFontSizeStyle = ( size ) => {\n\t\t\tif ( size === 0 ) {\n\t\t\t\tstyleElement.textContent = '';\n\t\t\t} else {\n\t\t\t\tstyleElement.textContent = `${ blockSelector } { font-size: ${ size }px !important; }`;\n\t\t\t}\n\t\t};\n\n\t\tconst optimalSize = optimizeFitText( blockElement, applyFontSizeStyle );\n\t\tsetFontSize( optimalSize );\n\t}, [ blockElement, clientId, hasFitTextSupport, fitText ] );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\t! fitText ||\n\t\t\t! blockElement ||\n\t\t\t! clientId ||\n\t\t\t! hasFitTextSupport ||\n\t\t\tblockMode === 'html'\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Store current element value for cleanup\n\t\tconst currentElement = blockElement;\n\t\tconst previousVisibility = currentElement.style.visibility;\n\n\t\t// Store IDs for cleanup\n\t\tlet hideFrameId = null;\n\t\tlet calculateFrameId = null;\n\t\tlet showTimeoutId = null;\n\n\t\t// We are hiding the element doing the calculation of fit text\n\t\t// and then showing it again to avoid the user noticing a flash of potentially\n\t\t// big fitText while the binary search is happening.\n\t\thideFrameId = window.requestAnimationFrame( () => {\n\t\t\tcurrentElement.style.visibility = 'hidden';\n\t\t\t// Wait for browser to render the hidden state\n\t\t\tcalculateFrameId = window.requestAnimationFrame( () => {\n\t\t\t\tapplyFitText();\n\n\t\t\t\t// Using a timeout instead of requestAnimationFrame, because\n\t\t\t\t// with requestAnimationFrame a flash of very high size\n\t\t\t\t// can still occur although rare.\n\t\t\t\tshowTimeoutId = setTimeout( () => {\n\t\t\t\t\tcurrentElement.style.visibility = previousVisibility;\n\t\t\t\t}, 10 );\n\t\t\t} );\n\t\t} );\n\n\t\t// Watch for size changes\n\t\tlet resizeObserver;\n\t\tif ( window.ResizeObserver && currentElement.parentElement ) {\n\t\t\tresizeObserver = new window.ResizeObserver( applyFitText );\n\t\t\tresizeObserver.observe( currentElement.parentElement );\n\t\t\tresizeObserver.observe( currentElement );\n\t\t}\n\n\t\t// Cleanup function\n\t\treturn () => {\n\t\t\t// Cancel pending async operations\n\t\t\tif ( hideFrameId !== null ) {\n\t\t\t\twindow.cancelAnimationFrame( hideFrameId );\n\t\t\t}\n\t\t\tif ( calculateFrameId !== null ) {\n\t\t\t\twindow.cancelAnimationFrame( calculateFrameId );\n\t\t\t}\n\t\t\tif ( showTimeoutId !== null ) {\n\t\t\t\tclearTimeout( showTimeoutId );\n\t\t\t}\n\n\t\t\tif ( resizeObserver ) {\n\t\t\t\tresizeObserver.disconnect();\n\t\t\t}\n\n\t\t\tconst styleId = `fit-text-${ clientId }`;\n\t\t\tconst styleElement =\n\t\t\t\tcurrentElement.ownerDocument.getElementById( styleId );\n\t\t\tif ( styleElement ) {\n\t\t\t\tstyleElement.remove();\n\t\t\t}\n\t\t};\n\t}, [\n\t\tfitText,\n\t\tclientId,\n\t\tparentId,\n\t\tapplyFitText,\n\t\tblockElement,\n\t\thasFitTextSupport,\n\t\tblockMode,\n\t] );\n\n\t// Trigger fit text recalculation when content changes\n\tuseEffect( () => {\n\t\tif (\n\t\t\tfitText &&\n\t\t\tblockElement &&\n\t\t\thasFitTextSupport &&\n\t\t\tblockMode !== 'html'\n\t\t) {\n\t\t\t// Wait for next frame to ensure DOM has updated after content changes\n\t\t\tconst frameId = window.requestAnimationFrame( () => {\n\t\t\t\tif ( blockElement ) {\n\t\t\t\t\tapplyFitText();\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\treturn () => window.cancelAnimationFrame( frameId );\n\t\t}\n\t}, [\n\t\tblockAttributes,\n\t\tfitText,\n\t\tapplyFitText,\n\t\tblockElement,\n\t\thasFitTextSupport,\n\t\tblockMode,\n\t] );\n\n\treturn { fontSize };\n}\n\n/**\n * Fit text control component for the typography panel.\n *\n * @param {Object} props Component props.\n * @param {string} props.clientId Block client ID.\n * @param {Function} props.setAttributes Function to set block attributes.\n * @param {string} props.name Block name.\n * @param {boolean} props.fitText Whether fit text is enabled.\n * @param {string} props.fontSize Font size slug.\n * @param {Object} props.style Block style object.\n */\nexport function FitTextControl( {\n\tclientId,\n\tfitText = false,\n\tsetAttributes,\n\tname,\n\tfontSize,\n\tstyle,\n} ) {\n\tif ( ! hasBlockSupport( name, FIT_TEXT_SUPPORT_KEY ) ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\thasValue={ () => fitText }\n\t\t\tlabel={ __( 'Fit text' ) }\n\t\t\tonDeselect={ () => setAttributes( { fitText: undefined } ) }\n\t\t\tresetAllFilter={ () => ( { fitText: undefined } ) }\n\t\t\tpanelId={ clientId }\n\t\t>\n\t\t\t<ToggleControl\n\t\t\t\tlabel={ __( 'Fit text' ) }\n\t\t\t\tchecked={ fitText }\n\t\t\t\tonChange={ () => {\n\t\t\t\t\tconst newFitText = ! fitText || undefined;\n\t\t\t\t\tconst updates = { fitText: newFitText };\n\n\t\t\t\t\t// When enabling fit text, clear font size if it has a value\n\t\t\t\t\tif ( newFitText ) {\n\t\t\t\t\t\tif ( fontSize ) {\n\t\t\t\t\t\t\tupdates.fontSize = undefined;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( style?.typography?.fontSize ) {\n\t\t\t\t\t\t\tupdates.style = {\n\t\t\t\t\t\t\t\t...style,\n\t\t\t\t\t\t\t\ttypography: {\n\t\t\t\t\t\t\t\t\t...style?.typography,\n\t\t\t\t\t\t\t\t\tfontSize: undefined,\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}\n\n\t\t\t\t\tsetAttributes( updates );\n\t\t\t\t} }\n\t\t\t\thelp={\n\t\t\t\t\tfitText\n\t\t\t\t\t\t? __( 'Text will resize to fit its container.' )\n\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t'The text will resize to fit its container, resetting other font size settings.'\n\t\t\t\t\t\t )\n\t\t\t\t}\n\t\t\t/>\n\t\t</ToolsPanelItem>\n\t);\n}\n\n/**\n * Override props applied to the block element on save.\n *\n * @param {Object} props Additional props applied to the block element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Block attributes.\n * @return {Object} Filtered props applied to the block element.\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif ( ! hasBlockSupport( blockType, FIT_TEXT_SUPPORT_KEY ) ) {\n\t\treturn props;\n\t}\n\n\tconst { fitText } = attributes;\n\n\tif ( ! fitText ) {\n\t\treturn props;\n\t}\n\n\t// Add CSS class for frontend detection and styling\n\tconst className = props.className\n\t\t? `${ props.className } has-fit-text`\n\t\t: 'has-fit-text';\n\n\treturn {\n\t\t...props,\n\t\tclassName,\n\t};\n}\n\n/**\n * Override props applied to the block element in the editor.\n *\n * @param {Object} props Component props including block attributes.\n * @param {string} props.name Block name.\n * @param {boolean} props.fitText Whether fit text is enabled.\n * @return {Object} Filtered props applied to the block element.\n */\nfunction useBlockProps( { name, fitText } ) {\n\tif ( fitText && hasBlockSupport( name, FIT_TEXT_SUPPORT_KEY ) ) {\n\t\treturn {\n\t\t\tclassName: 'has-fit-text',\n\t\t};\n\t}\n\treturn {};\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/fit-text/addAttribute',\n\taddAttributes\n);\n\nconst hasFitTextSupport = ( blockNameOrType ) => {\n\treturn hasBlockSupport( blockNameOrType, FIT_TEXT_SUPPORT_KEY );\n};\n\n/**\n * Component that handles the fit text font size and displays a warning\n * if the fit text font size is below a minimum threshold.\n *\n * @param {Object} props Component props.\n * @param {boolean} props.fitText Whether fit text is enabled.\n * @param {string} props.name Block name.\n * @param {string} props.clientId Block client ID.\n * @param {boolean} props.isSelected Whether the block is selected.\n * @return {Element|null} Warning component or null.\n */\nfunction FitTextFontSize( { fitText, name, clientId, isSelected } ) {\n\tconst { fontSize } = useFitText( { fitText, name, clientId } );\n\tif ( isSelected && fontSize && fontSize < MIN_FONT_SIZE_FOR_WARNING ) {\n\t\treturn (\n\t\t\t<InspectorControls group=\"typography\">\n\t\t\t\t<FitTextSizeWarning />\n\t\t\t</InspectorControls>\n\t\t);\n\t}\n\treturn null;\n}\n\n/*\n * Fit-text requires that layout calculations be done even when a block is not\n * currently selected. Therefore, the regular hooking approach using an\n * exported `edit` method is not enough, and we must use this HoC with the\n * `editor.BlockEdit` filter.\n */\nconst addFitTextControl = createHigherOrderComponent( ( BlockEdit ) => {\n\treturn function AddFitTextControl( props ) {\n\t\tconst { name, attributes, clientId, isSelected, setAttributes } = props;\n\t\tconst { fitText } = attributes;\n\t\tconst supportsFitText = hasBlockSupport( name, FIT_TEXT_SUPPORT_KEY );\n\t\tif ( ! supportsFitText ) {\n\t\t\treturn <BlockEdit { ...props } />;\n\t\t}\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t<InspectorControls group=\"typography\">\n\t\t\t\t\t<FitTextControl\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tfitText={ fitText }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\tfontSize={ attributes.fontSize }\n\t\t\t\t\t\tstyle={ attributes.style }\n\t\t\t\t\t/>\n\t\t\t\t</InspectorControls>\n\t\t\t\t{ fitText && (\n\t\t\t\t\t<FitTextFontSize\n\t\t\t\t\t\tfitText={ fitText }\n\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t};\n}, 'addFitTextControl' );\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/fit-text/add-fit-text-control',\n\taddFitTextControl\n);\n\nexport default {\n\tuseBlockProps,\n\taddSaveProps,\n\tattributeKeys: [ 'fitText', 'fontSize', 'style' ],\n\thasSupport: hasFitTextSupport,\n\tedit: () => null,\n};\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAChC,SAAS,WAAW,aAAa,gBAAgB;AACjD,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA,gCAAgC;AAAA,OAC1B;AACP,SAAS,kCAAkC;AAQ3C,SAAS,uBAAuB;AAChC,SAAS,SAAS,wBAAwB;AAC1C,SAAS,uBAAuB;AAChC,OAAO,uBAAuB;AAC9B,OAAO,wBAAwB;AA6O5B,SAoIA,UApIA,KAoIA,YApIA;AAvPH,IAAM,eAAe,CAAC;AACtB,IAAM,4BAA4B;AAW3B,IAAM,uBAAuB;AASpC,SAAS,cAAe,UAAW;AAClC,MAAK,CAAE,gBAAiB,UAAU,oBAAqB,GAAI;AAC1D,WAAO;AAAA,EACR;AAGA,MAAK,SAAS,YAAY,SAAU;AACnC,WAAO;AAAA,EACR;AAGA,SAAO;AAAA,IACN,GAAG;AAAA,IACH,YAAY;AAAA,MACX,GAAG,SAAS;AAAA,MACZ,SAAS;AAAA,QACR,MAAM;AAAA,MACP;AAAA,IACD;AAAA,EACD;AACD;AAUA,SAAS,WAAY,EAAE,SAAS,MAA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,MACpB,GACD;AAAA,MACE,WACD;AAAA,QAAC;AAAA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA;AAAA,MACD;AAAA,OAEF;AAAA,EAEF;AACD,GAAG,mBAAoB;AAEvB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;AAEA,IAAO,mBAAQ;AAAA,EACd;AAAA,EACA;AAAA,EACA,eAAe,CAAE,WAAW,YAAY,OAAQ;AAAA,EAChD,YAAY;AAAA,EACZ,MAAM,MAAM;AACb;",
|
|
6
6
|
"names": ["hasFitTextSupport"]
|
|
7
7
|
}
|
|
@@ -144,6 +144,7 @@ function useBlockSettings(name, parentLayout) {
|
|
|
144
144
|
const [
|
|
145
145
|
backgroundImage,
|
|
146
146
|
backgroundSize,
|
|
147
|
+
gradient,
|
|
147
148
|
customFontFamilies,
|
|
148
149
|
defaultFontFamilies,
|
|
149
150
|
themeFontFamilies,
|
|
@@ -206,6 +207,7 @@ function useBlockSettings(name, parentLayout) {
|
|
|
206
207
|
] = useSettings(
|
|
207
208
|
"background.backgroundImage",
|
|
208
209
|
"background.backgroundSize",
|
|
210
|
+
"background.gradient",
|
|
209
211
|
"typography.fontFamilies.custom",
|
|
210
212
|
"typography.fontFamilies.default",
|
|
211
213
|
"typography.fontFamilies.theme",
|
|
@@ -270,7 +272,8 @@ function useBlockSettings(name, parentLayout) {
|
|
|
270
272
|
return {
|
|
271
273
|
background: {
|
|
272
274
|
backgroundImage,
|
|
273
|
-
backgroundSize
|
|
275
|
+
backgroundSize,
|
|
276
|
+
gradient
|
|
274
277
|
},
|
|
275
278
|
color: {
|
|
276
279
|
palette: {
|
|
@@ -358,6 +361,7 @@ function useBlockSettings(name, parentLayout) {
|
|
|
358
361
|
}, [
|
|
359
362
|
backgroundImage,
|
|
360
363
|
backgroundSize,
|
|
364
|
+
gradient,
|
|
361
365
|
customFontFamilies,
|
|
362
366
|
defaultFontFamilies,
|
|
363
367
|
themeFontFamilies,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/utils.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { memo, useMemo, useEffect, useId, useState } from '@wordpress/element';\nimport { useDispatch, useRegistry } from '@wordpress/data';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseBlockEditContext,\n\tmayDisplayControlsKey,\n\tmayDisplayParentControlsKey,\n\tmayDisplayPatternEditingControlsKey,\n} from '../components/block-edit/context';\nimport { useSettings } from '../components';\nimport { useSettingsForBlockElement } from '../components/global-styles/hooks';\nimport { getValueFromObjectPath, setImmutably } from '../utils/object';\nimport { store as blockEditorStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\n/**\n * Removed falsy values from nested object.\n *\n * @param {*} object\n * @return {*} Object cleaned from falsy values\n */\nexport const cleanEmptyObject = ( object ) => {\n\tif (\n\t\tobject === null ||\n\t\ttypeof object !== 'object' ||\n\t\tArray.isArray( object )\n\t) {\n\t\treturn object;\n\t}\n\n\tconst cleanedNestedObjects = Object.entries( object )\n\t\t.map( ( [ key, value ] ) => [ key, cleanEmptyObject( value ) ] )\n\t\t.filter( ( [ , value ] ) => value !== undefined );\n\treturn ! cleanedNestedObjects.length\n\t\t? undefined\n\t\t: Object.fromEntries( cleanedNestedObjects );\n};\n\nexport function transformStyles(\n\tactiveSupports,\n\tmigrationPaths,\n\tresult,\n\tsource,\n\tindex,\n\tresults\n) {\n\t// If there are no active supports return early.\n\tif (\n\t\tObject.values( activeSupports ?? {} ).every(\n\t\t\t( isActive ) => ! isActive\n\t\t)\n\t) {\n\t\treturn result;\n\t}\n\t// If the condition verifies we are probably in the presence of a wrapping transform\n\t// e.g: nesting paragraphs in a group or columns and in that case the styles should not be transformed.\n\tif ( results.length === 1 && result.innerBlocks.length === source.length ) {\n\t\treturn result;\n\t}\n\t// For cases where we have a transform from one block to multiple blocks\n\t// or multiple blocks to one block we apply the styles of the first source block\n\t// to the result(s).\n\tlet referenceBlockAttributes = source[ 0 ]?.attributes;\n\t// If we are in presence of transform between more than one block in the source\n\t// that has more than one block in the result\n\t// we apply the styles on source N to the result N,\n\t// if source N does not exists we do nothing.\n\tif ( results.length > 1 && source.length > 1 ) {\n\t\tif ( source[ index ] ) {\n\t\t\treferenceBlockAttributes = source[ index ]?.attributes;\n\t\t} else {\n\t\t\treturn result;\n\t\t}\n\t}\n\tlet returnBlock = result;\n\tObject.entries( activeSupports ).forEach( ( [ support, isActive ] ) => {\n\t\tif ( isActive ) {\n\t\t\tmigrationPaths[ support ].forEach( ( path ) => {\n\t\t\t\tconst styleValue = getValueFromObjectPath(\n\t\t\t\t\treferenceBlockAttributes,\n\t\t\t\t\tpath\n\t\t\t\t);\n\t\t\t\tif ( styleValue ) {\n\t\t\t\t\treturnBlock = {\n\t\t\t\t\t\t...returnBlock,\n\t\t\t\t\t\tattributes: setImmutably(\n\t\t\t\t\t\t\treturnBlock.attributes,\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tstyleValue\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\treturn returnBlock;\n}\n\n/**\n * Check whether serialization of specific block support feature or set should\n * be skipped.\n *\n * @param {string|Object} blockNameOrType Block name or block type object.\n * @param {string} featureSet Name of block support feature set.\n * @param {string} feature Name of the individual feature to check.\n *\n * @return {boolean} Whether serialization should occur.\n */\nexport function shouldSkipSerialization(\n\tblockNameOrType,\n\tfeatureSet,\n\tfeature\n) {\n\tconst support = getBlockSupport( blockNameOrType, featureSet );\n\tconst skipSerialization = support?.__experimentalSkipSerialization;\n\n\tif ( Array.isArray( skipSerialization ) ) {\n\t\treturn skipSerialization.includes( feature );\n\t}\n\n\treturn skipSerialization;\n}\n\nconst pendingStyleOverrides = new WeakMap();\n\n/**\n * Override a block editor settings style. Leave the ID blank to create a new\n * style.\n *\n * @param {Object} override Override object.\n * @param {?string} override.id Id of the style override, leave blank to create\n * a new style.\n * @param {string} override.css CSS to apply.\n */\nexport function useStyleOverride( { id, css } ) {\n\treturn usePrivateStyleOverride( { id, css } );\n}\n\nexport function usePrivateStyleOverride( {\n\tid,\n\tcss,\n\tassets,\n\t__unstableType,\n\tvariation,\n\tclientId,\n} = {} ) {\n\tconst { setStyleOverride, deleteStyleOverride } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\tconst registry = useRegistry();\n\tconst fallbackId = useId();\n\tuseEffect( () => {\n\t\t// Unmount if there is CSS and assets are empty.\n\t\tif ( ! css && ! assets ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst _id = id || fallbackId;\n\t\tconst override = {\n\t\t\tid,\n\t\t\tcss,\n\t\t\tassets,\n\t\t\t__unstableType,\n\t\t\tvariation,\n\t\t\tclientId,\n\t\t};\n\t\t// Batch updates to style overrides to avoid triggering cascading renders\n\t\t// for each style override block included in a tree and optimize initial render.\n\t\tif ( ! pendingStyleOverrides.get( registry ) ) {\n\t\t\tpendingStyleOverrides.set( registry, [] );\n\t\t}\n\t\tpendingStyleOverrides.get( registry ).push( [ _id, override ] );\n\t\twindow.queueMicrotask( () => {\n\t\t\tif ( pendingStyleOverrides.get( registry )?.length ) {\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tpendingStyleOverrides.get( registry ).forEach( ( args ) => {\n\t\t\t\t\t\tsetStyleOverride( ...args );\n\t\t\t\t\t} );\n\t\t\t\t\tpendingStyleOverrides.set( registry, [] );\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\n\t\treturn () => {\n\t\t\tconst isPending = pendingStyleOverrides\n\t\t\t\t.get( registry )\n\t\t\t\t?.find( ( [ currentId ] ) => currentId === _id );\n\t\t\tif ( isPending ) {\n\t\t\t\tpendingStyleOverrides.set(\n\t\t\t\t\tregistry,\n\t\t\t\t\tpendingStyleOverrides\n\t\t\t\t\t\t.get( registry )\n\t\t\t\t\t\t.filter( ( [ currentId ] ) => currentId !== _id )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tdeleteStyleOverride( _id );\n\t\t\t}\n\t\t};\n\t}, [\n\t\tid,\n\t\tcss,\n\t\tclientId,\n\t\tassets,\n\t\t__unstableType,\n\t\tfallbackId,\n\t\tsetStyleOverride,\n\t\tdeleteStyleOverride,\n\t\tregistry,\n\t\tvariation,\n\t] );\n}\n\n/**\n * Based on the block and its context, returns an object of all the block settings.\n * This object can be passed as a prop to all the Styles UI components\n * (TypographyPanel, DimensionsPanel...).\n *\n * @param {string} name Block name.\n * @param {*} parentLayout Parent layout.\n *\n * @return {Object} Settings object.\n */\nexport function useBlockSettings( name, parentLayout ) {\n\tconst [\n\t\tbackgroundImage,\n\t\tbackgroundSize,\n\t\tcustomFontFamilies,\n\t\tdefaultFontFamilies,\n\t\tthemeFontFamilies,\n\t\tdefaultFontSizesEnabled,\n\t\tcustomFontSizes,\n\t\tdefaultFontSizes,\n\t\tthemeFontSizes,\n\t\tcustomFontSize,\n\t\tfontStyle,\n\t\tfontWeight,\n\t\tlineHeight,\n\t\ttextAlign,\n\t\ttextColumns,\n\t\ttextDecoration,\n\t\ttextIndent,\n\t\twritingMode,\n\t\ttextTransform,\n\t\tletterSpacing,\n\t\tpadding,\n\t\tmargin,\n\t\tblockGap,\n\t\tdefaultSpacingSizesEnabled,\n\t\tcustomSpacingSize,\n\t\tuserSpacingSizes,\n\t\tdefaultSpacingSizes,\n\t\tthemeSpacingSizes,\n\t\tunits,\n\t\taspectRatio,\n\t\theight,\n\t\tminHeight,\n\t\twidth,\n\t\tdimensionSizes,\n\t\tlayout,\n\t\tborderColor,\n\t\tborderRadius,\n\t\tborderStyle,\n\t\tborderWidth,\n\t\tborderRadiusSizes,\n\t\tcustomColorsEnabled,\n\t\tcustomColors,\n\t\tcustomDuotone,\n\t\tthemeColors,\n\t\tdefaultColors,\n\t\tdefaultPalette,\n\t\tdefaultDuotone,\n\t\tuserDuotonePalette,\n\t\tthemeDuotonePalette,\n\t\tdefaultDuotonePalette,\n\t\tuserGradientPalette,\n\t\tthemeGradientPalette,\n\t\tdefaultGradientPalette,\n\t\tdefaultGradients,\n\t\tareCustomGradientsEnabled,\n\t\tisBackgroundEnabled,\n\t\tisLinkEnabled,\n\t\tisTextEnabled,\n\t\tisHeadingEnabled,\n\t\tisButtonEnabled,\n\t\tshadow,\n\t] = useSettings(\n\t\t'background.backgroundImage',\n\t\t'background.backgroundSize',\n\t\t'typography.fontFamilies.custom',\n\t\t'typography.fontFamilies.default',\n\t\t'typography.fontFamilies.theme',\n\t\t'typography.defaultFontSizes',\n\t\t'typography.fontSizes.custom',\n\t\t'typography.fontSizes.default',\n\t\t'typography.fontSizes.theme',\n\t\t'typography.customFontSize',\n\t\t'typography.fontStyle',\n\t\t'typography.fontWeight',\n\t\t'typography.lineHeight',\n\t\t'typography.textAlign',\n\t\t'typography.textColumns',\n\t\t'typography.textDecoration',\n\t\t'typography.textIndent',\n\t\t'typography.writingMode',\n\t\t'typography.textTransform',\n\t\t'typography.letterSpacing',\n\t\t'spacing.padding',\n\t\t'spacing.margin',\n\t\t'spacing.blockGap',\n\t\t'spacing.defaultSpacingSizes',\n\t\t'spacing.customSpacingSize',\n\t\t'spacing.spacingSizes.custom',\n\t\t'spacing.spacingSizes.default',\n\t\t'spacing.spacingSizes.theme',\n\t\t'spacing.units',\n\t\t'dimensions.aspectRatio',\n\t\t'dimensions.height',\n\t\t'dimensions.minHeight',\n\t\t'dimensions.width',\n\t\t'dimensions.dimensionSizes',\n\t\t'layout',\n\t\t'border.color',\n\t\t'border.radius',\n\t\t'border.style',\n\t\t'border.width',\n\t\t'border.radiusSizes',\n\t\t'color.custom',\n\t\t'color.palette.custom',\n\t\t'color.customDuotone',\n\t\t'color.palette.theme',\n\t\t'color.palette.default',\n\t\t'color.defaultPalette',\n\t\t'color.defaultDuotone',\n\t\t'color.duotone.custom',\n\t\t'color.duotone.theme',\n\t\t'color.duotone.default',\n\t\t'color.gradients.custom',\n\t\t'color.gradients.theme',\n\t\t'color.gradients.default',\n\t\t'color.defaultGradients',\n\t\t'color.customGradient',\n\t\t'color.background',\n\t\t'color.link',\n\t\t'color.text',\n\t\t'color.heading',\n\t\t'color.button',\n\t\t'shadow'\n\t);\n\n\tconst rawSettings = useMemo( () => {\n\t\treturn {\n\t\t\tbackground: {\n\t\t\t\tbackgroundImage,\n\t\t\t\tbackgroundSize,\n\t\t\t},\n\t\t\tcolor: {\n\t\t\t\tpalette: {\n\t\t\t\t\tcustom: customColors,\n\t\t\t\t\ttheme: themeColors,\n\t\t\t\t\tdefault: defaultColors,\n\t\t\t\t},\n\t\t\t\tgradients: {\n\t\t\t\t\tcustom: userGradientPalette,\n\t\t\t\t\ttheme: themeGradientPalette,\n\t\t\t\t\tdefault: defaultGradientPalette,\n\t\t\t\t},\n\t\t\t\tduotone: {\n\t\t\t\t\tcustom: userDuotonePalette,\n\t\t\t\t\ttheme: themeDuotonePalette,\n\t\t\t\t\tdefault: defaultDuotonePalette,\n\t\t\t\t},\n\t\t\t\tdefaultGradients,\n\t\t\t\tdefaultPalette,\n\t\t\t\tdefaultDuotone,\n\t\t\t\tcustom: customColorsEnabled,\n\t\t\t\tcustomGradient: areCustomGradientsEnabled,\n\t\t\t\tcustomDuotone,\n\t\t\t\tbackground: isBackgroundEnabled,\n\t\t\t\tlink: isLinkEnabled,\n\t\t\t\theading: isHeadingEnabled,\n\t\t\t\tbutton: isButtonEnabled,\n\t\t\t\ttext: isTextEnabled,\n\t\t\t},\n\t\t\ttypography: {\n\t\t\t\tfontFamilies: {\n\t\t\t\t\tcustom: customFontFamilies,\n\t\t\t\t\tdefault: defaultFontFamilies,\n\t\t\t\t\ttheme: themeFontFamilies,\n\t\t\t\t},\n\t\t\t\tfontSizes: {\n\t\t\t\t\tcustom: customFontSizes,\n\t\t\t\t\tdefault: defaultFontSizes,\n\t\t\t\t\ttheme: themeFontSizes,\n\t\t\t\t},\n\t\t\t\tcustomFontSize,\n\t\t\t\tdefaultFontSizes: defaultFontSizesEnabled,\n\t\t\t\tfontStyle,\n\t\t\t\tfontWeight,\n\t\t\t\tlineHeight,\n\t\t\t\ttextAlign,\n\t\t\t\ttextColumns,\n\t\t\t\ttextDecoration,\n\t\t\t\ttextIndent,\n\t\t\t\ttextTransform,\n\t\t\t\tletterSpacing,\n\t\t\t\twritingMode,\n\t\t\t},\n\t\t\tspacing: {\n\t\t\t\tspacingSizes: {\n\t\t\t\t\tcustom: userSpacingSizes,\n\t\t\t\t\tdefault: defaultSpacingSizes,\n\t\t\t\t\ttheme: themeSpacingSizes,\n\t\t\t\t},\n\t\t\t\tcustomSpacingSize,\n\t\t\t\tdefaultSpacingSizes: defaultSpacingSizesEnabled,\n\t\t\t\tpadding,\n\t\t\t\tmargin,\n\t\t\t\tblockGap,\n\t\t\t\tunits,\n\t\t\t},\n\t\t\tborder: {\n\t\t\t\tcolor: borderColor,\n\t\t\t\tradius: borderRadius,\n\t\t\t\tstyle: borderStyle,\n\t\t\t\twidth: borderWidth,\n\t\t\t\tradiusSizes: borderRadiusSizes,\n\t\t\t},\n\t\t\tdimensions: {\n\t\t\t\taspectRatio,\n\t\t\t\theight,\n\t\t\t\tminHeight,\n\t\t\t\twidth,\n\t\t\t\tdimensionSizes,\n\t\t\t},\n\t\t\tlayout,\n\t\t\tparentLayout,\n\t\t\tshadow,\n\t\t};\n\t}, [\n\t\tbackgroundImage,\n\t\tbackgroundSize,\n\t\tcustomFontFamilies,\n\t\tdefaultFontFamilies,\n\t\tthemeFontFamilies,\n\t\tdefaultFontSizesEnabled,\n\t\tcustomFontSizes,\n\t\tdefaultFontSizes,\n\t\tthemeFontSizes,\n\t\tcustomFontSize,\n\t\tfontStyle,\n\t\tfontWeight,\n\t\tlineHeight,\n\t\ttextAlign,\n\t\ttextColumns,\n\t\ttextDecoration,\n\t\ttextIndent,\n\t\ttextTransform,\n\t\tletterSpacing,\n\t\twritingMode,\n\t\tpadding,\n\t\tmargin,\n\t\tblockGap,\n\t\tdefaultSpacingSizesEnabled,\n\t\tcustomSpacingSize,\n\t\tuserSpacingSizes,\n\t\tdefaultSpacingSizes,\n\t\tthemeSpacingSizes,\n\t\tunits,\n\t\taspectRatio,\n\t\theight,\n\t\tminHeight,\n\t\twidth,\n\t\tdimensionSizes,\n\t\tlayout,\n\t\tparentLayout,\n\t\tborderColor,\n\t\tborderRadius,\n\t\tborderStyle,\n\t\tborderWidth,\n\t\tborderRadiusSizes,\n\t\tcustomColorsEnabled,\n\t\tcustomColors,\n\t\tcustomDuotone,\n\t\tthemeColors,\n\t\tdefaultColors,\n\t\tdefaultPalette,\n\t\tdefaultDuotone,\n\t\tuserDuotonePalette,\n\t\tthemeDuotonePalette,\n\t\tdefaultDuotonePalette,\n\t\tuserGradientPalette,\n\t\tthemeGradientPalette,\n\t\tdefaultGradientPalette,\n\t\tdefaultGradients,\n\t\tareCustomGradientsEnabled,\n\t\tisBackgroundEnabled,\n\t\tisLinkEnabled,\n\t\tisTextEnabled,\n\t\tisHeadingEnabled,\n\t\tisButtonEnabled,\n\t\tshadow,\n\t] );\n\n\treturn useSettingsForBlockElement( rawSettings, name );\n}\n\nexport function createBlockEditFilter( features ) {\n\t// We don't want block controls to re-render when typing inside a block.\n\t// `memo` will prevent re-renders unless props change, so only pass the\n\t// needed props and not the whole attributes object.\n\tfeatures = features.map( ( settings ) => {\n\t\treturn { ...settings, Edit: memo( settings.edit ) };\n\t} );\n\tconst withBlockEditHooks = createHigherOrderComponent(\n\t\t( OriginalBlockEdit ) =>\n\t\t\tfunction WithBlockEditHooks( props ) {\n\t\t\t\tconst context = useBlockEditContext();\n\t\t\t\t// CAUTION: code added before this line will be executed for all\n\t\t\t\t// blocks, not just those that support the feature! Code added\n\t\t\t\t// above this line should be carefully evaluated for its impact on\n\t\t\t\t// performance.\n\t\t\t\treturn [\n\t\t\t\t\t...features.map( ( feature, i ) => {\n\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\tEdit,\n\t\t\t\t\t\t\thasSupport,\n\t\t\t\t\t\t\tattributeKeys = [],\n\t\t\t\t\t\t\tshareWithChildBlocks,\n\t\t\t\t\t\t\tsupportsPatternEditing,\n\t\t\t\t\t\t} = feature;\n\t\t\t\t\t\tconst shouldDisplayControls =\n\t\t\t\t\t\t\t( supportsPatternEditing &&\n\t\t\t\t\t\t\t\tcontext[\n\t\t\t\t\t\t\t\t\tmayDisplayPatternEditingControlsKey\n\t\t\t\t\t\t\t\t] ) ||\n\t\t\t\t\t\t\tcontext[ mayDisplayControlsKey ] ||\n\t\t\t\t\t\t\t( context[ mayDisplayParentControlsKey ] &&\n\t\t\t\t\t\t\t\tshareWithChildBlocks );\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t! shouldDisplayControls ||\n\t\t\t\t\t\t\t! hasSupport( props.name )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst neededProps = {};\n\t\t\t\t\t\tfor ( const key of attributeKeys ) {\n\t\t\t\t\t\t\tif ( props.attributes[ key ] ) {\n\t\t\t\t\t\t\t\tneededProps[ key ] = props.attributes[ key ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<Edit\n\t\t\t\t\t\t\t\t// We can use the index because the array length\n\t\t\t\t\t\t\t\t// is fixed per page load right now.\n\t\t\t\t\t\t\t\tkey={ i }\n\t\t\t\t\t\t\t\tname={ props.name }\n\t\t\t\t\t\t\t\tisSelected={ props.isSelected }\n\t\t\t\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\t\t\t\tsetAttributes={ props.setAttributes }\n\t\t\t\t\t\t\t\t__unstableParentLayout={\n\t\t\t\t\t\t\t\t\tprops.__unstableParentLayout\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t// This component is pure, so only pass needed\n\t\t\t\t\t\t\t\t// props!!!\n\t\t\t\t\t\t\t\t{ ...neededProps }\n\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<OriginalBlockEdit key=\"edit\" { ...props } />,\n\t\t\t\t];\n\t\t\t},\n\t\t'withBlockEditHooks'\n\t);\n\taddFilter( 'editor.BlockEdit', 'core/editor/hooks', withBlockEditHooks );\n}\n\nfunction BlockProps( {\n\tindex,\n\tuseBlockProps: hook,\n\tsetAllWrapperProps,\n\t...props\n} ) {\n\tconst wrapperProps = hook( props );\n\tconst setWrapperProps = ( next ) =>\n\t\tsetAllWrapperProps( ( prev ) => {\n\t\t\tconst nextAll = [ ...prev ];\n\t\t\tnextAll[ index ] = next;\n\t\t\treturn nextAll;\n\t\t} );\n\t// Setting state after every render is fine because this component is\n\t// pure and will only re-render when needed props change.\n\tuseEffect( () => {\n\t\t// We could shallow compare the props, but since this component only\n\t\t// changes when needed attributes change, the benefit is probably small.\n\t\tsetWrapperProps( wrapperProps );\n\t\treturn () => {\n\t\t\tsetWrapperProps( undefined );\n\t\t};\n\t} );\n\treturn null;\n}\n\nconst BlockPropsPure = memo( BlockProps );\n\nexport function createBlockListBlockFilter( features ) {\n\tconst withBlockListBlockHooks = createHigherOrderComponent(\n\t\t( BlockListBlock ) =>\n\t\t\tfunction WithBlockListBlockHooks( props ) {\n\t\t\t\tconst [ allWrapperProps, setAllWrapperProps ] = useState(\n\t\t\t\t\tArray( features.length ).fill( undefined )\n\t\t\t\t);\n\t\t\t\treturn [\n\t\t\t\t\t...features.map( ( feature, i ) => {\n\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\thasSupport,\n\t\t\t\t\t\t\tattributeKeys = [],\n\t\t\t\t\t\t\tuseBlockProps,\n\t\t\t\t\t\t\tisMatch,\n\t\t\t\t\t\t} = feature;\n\n\t\t\t\t\t\tconst neededProps = {};\n\t\t\t\t\t\tfor ( const key of attributeKeys ) {\n\t\t\t\t\t\t\tif ( props.attributes[ key ] ) {\n\t\t\t\t\t\t\t\tneededProps[ key ] = props.attributes[ key ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t// Skip rendering if none of the needed attributes are\n\t\t\t\t\t\t\t// set.\n\t\t\t\t\t\t\t! Object.keys( neededProps ).length ||\n\t\t\t\t\t\t\t! hasSupport( props.name ) ||\n\t\t\t\t\t\t\t( isMatch && ! isMatch( neededProps ) )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<BlockPropsPure\n\t\t\t\t\t\t\t\t// We can use the index because the array length\n\t\t\t\t\t\t\t\t// is fixed per page load right now.\n\t\t\t\t\t\t\t\tkey={ i }\n\t\t\t\t\t\t\t\tindex={ i }\n\t\t\t\t\t\t\t\tuseBlockProps={ useBlockProps }\n\t\t\t\t\t\t\t\t// This component is pure, so we must pass a stable\n\t\t\t\t\t\t\t\t// function reference.\n\t\t\t\t\t\t\t\tsetAllWrapperProps={ setAllWrapperProps }\n\t\t\t\t\t\t\t\tname={ props.name }\n\t\t\t\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\t\t\t\t// This component is pure, so only pass needed\n\t\t\t\t\t\t\t\t// props!!!\n\t\t\t\t\t\t\t\t{ ...neededProps }\n\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<BlockListBlock\n\t\t\t\t\t\tkey=\"edit\"\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\twrapperProps={ allWrapperProps\n\t\t\t\t\t\t\t.filter( Boolean )\n\t\t\t\t\t\t\t.reduce( ( acc, wrapperProps ) => {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t\t\t\t...wrapperProps,\n\t\t\t\t\t\t\t\t\tclassName: clsx(\n\t\t\t\t\t\t\t\t\t\tacc.className,\n\t\t\t\t\t\t\t\t\t\twrapperProps.className\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t\t\t\t...acc.style,\n\t\t\t\t\t\t\t\t\t\t...wrapperProps.style,\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}, props.wrapperProps || {} ) }\n\t\t\t\t\t/>,\n\t\t\t\t];\n\t\t\t},\n\t\t'withBlockListBlockHooks'\n\t);\n\taddFilter(\n\t\t'editor.BlockListBlock',\n\t\t'core/editor/hooks',\n\t\twithBlockListBlockHooks\n\t);\n}\n\nexport function createBlockSaveFilter( features ) {\n\tfunction extraPropsFromHooks( props, name, attributes ) {\n\t\treturn features.reduce( ( accu, feature ) => {\n\t\t\tconst { hasSupport, attributeKeys = [], addSaveProps } = feature;\n\n\t\t\tconst neededAttributes = {};\n\t\t\tfor ( const key of attributeKeys ) {\n\t\t\t\tif ( attributes[ key ] ) {\n\t\t\t\t\tneededAttributes[ key ] = attributes[ key ];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t// Skip rendering if none of the needed attributes are\n\t\t\t\t// set.\n\t\t\t\t! Object.keys( neededAttributes ).length ||\n\t\t\t\t! hasSupport( name )\n\t\t\t) {\n\t\t\t\treturn accu;\n\t\t\t}\n\n\t\t\treturn addSaveProps( accu, name, neededAttributes );\n\t\t}, props );\n\t}\n\taddFilter(\n\t\t'blocks.getSaveContent.extraProps',\n\t\t'core/editor/hooks',\n\t\textraPropsFromHooks,\n\t\t0\n\t);\n\taddFilter(\n\t\t'blocks.getSaveContent.extraProps',\n\t\t'core/editor/hooks',\n\t\t( props ) => {\n\t\t\t// Previously we had a filter deleting the className if it was an empty\n\t\t\t// string. That filter is no longer running, so now we need to delete it\n\t\t\t// here.\n\t\t\tif ( props.hasOwnProperty( 'className' ) && ! props.className ) {\n\t\t\t\tdelete props.className;\n\t\t\t}\n\n\t\t\treturn props;\n\t\t}\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,uBAAuB;AAChC,SAAS,MAAM,SAAS,WAAW,OAAO,gBAAgB;AAC1D,SAAS,aAAa,mBAAmB;AACzC,SAAS,kCAAkC;AAC3C,SAAS,iBAAiB;AAK1B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,mBAAmB;AAC5B,SAAS,kCAAkC;AAC3C,SAAS,wBAAwB,oBAAoB;AACrD,SAAS,SAAS,wBAAwB;AAC1C,SAAS,cAAc;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { memo, useMemo, useEffect, useId, useState } from '@wordpress/element';\nimport { useDispatch, useRegistry } from '@wordpress/data';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseBlockEditContext,\n\tmayDisplayControlsKey,\n\tmayDisplayParentControlsKey,\n\tmayDisplayPatternEditingControlsKey,\n} from '../components/block-edit/context';\nimport { useSettings } from '../components';\nimport { useSettingsForBlockElement } from '../components/global-styles/hooks';\nimport { getValueFromObjectPath, setImmutably } from '../utils/object';\nimport { store as blockEditorStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\n/**\n * Removed falsy values from nested object.\n *\n * @param {*} object\n * @return {*} Object cleaned from falsy values\n */\nexport const cleanEmptyObject = ( object ) => {\n\tif (\n\t\tobject === null ||\n\t\ttypeof object !== 'object' ||\n\t\tArray.isArray( object )\n\t) {\n\t\treturn object;\n\t}\n\n\tconst cleanedNestedObjects = Object.entries( object )\n\t\t.map( ( [ key, value ] ) => [ key, cleanEmptyObject( value ) ] )\n\t\t.filter( ( [ , value ] ) => value !== undefined );\n\treturn ! cleanedNestedObjects.length\n\t\t? undefined\n\t\t: Object.fromEntries( cleanedNestedObjects );\n};\n\nexport function transformStyles(\n\tactiveSupports,\n\tmigrationPaths,\n\tresult,\n\tsource,\n\tindex,\n\tresults\n) {\n\t// If there are no active supports return early.\n\tif (\n\t\tObject.values( activeSupports ?? {} ).every(\n\t\t\t( isActive ) => ! isActive\n\t\t)\n\t) {\n\t\treturn result;\n\t}\n\t// If the condition verifies we are probably in the presence of a wrapping transform\n\t// e.g: nesting paragraphs in a group or columns and in that case the styles should not be transformed.\n\tif ( results.length === 1 && result.innerBlocks.length === source.length ) {\n\t\treturn result;\n\t}\n\t// For cases where we have a transform from one block to multiple blocks\n\t// or multiple blocks to one block we apply the styles of the first source block\n\t// to the result(s).\n\tlet referenceBlockAttributes = source[ 0 ]?.attributes;\n\t// If we are in presence of transform between more than one block in the source\n\t// that has more than one block in the result\n\t// we apply the styles on source N to the result N,\n\t// if source N does not exists we do nothing.\n\tif ( results.length > 1 && source.length > 1 ) {\n\t\tif ( source[ index ] ) {\n\t\t\treferenceBlockAttributes = source[ index ]?.attributes;\n\t\t} else {\n\t\t\treturn result;\n\t\t}\n\t}\n\tlet returnBlock = result;\n\tObject.entries( activeSupports ).forEach( ( [ support, isActive ] ) => {\n\t\tif ( isActive ) {\n\t\t\tmigrationPaths[ support ].forEach( ( path ) => {\n\t\t\t\tconst styleValue = getValueFromObjectPath(\n\t\t\t\t\treferenceBlockAttributes,\n\t\t\t\t\tpath\n\t\t\t\t);\n\t\t\t\tif ( styleValue ) {\n\t\t\t\t\treturnBlock = {\n\t\t\t\t\t\t...returnBlock,\n\t\t\t\t\t\tattributes: setImmutably(\n\t\t\t\t\t\t\treturnBlock.attributes,\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tstyleValue\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\treturn returnBlock;\n}\n\n/**\n * Check whether serialization of specific block support feature or set should\n * be skipped.\n *\n * @param {string|Object} blockNameOrType Block name or block type object.\n * @param {string} featureSet Name of block support feature set.\n * @param {string} feature Name of the individual feature to check.\n *\n * @return {boolean} Whether serialization should occur.\n */\nexport function shouldSkipSerialization(\n\tblockNameOrType,\n\tfeatureSet,\n\tfeature\n) {\n\tconst support = getBlockSupport( blockNameOrType, featureSet );\n\tconst skipSerialization = support?.__experimentalSkipSerialization;\n\n\tif ( Array.isArray( skipSerialization ) ) {\n\t\treturn skipSerialization.includes( feature );\n\t}\n\n\treturn skipSerialization;\n}\n\nconst pendingStyleOverrides = new WeakMap();\n\n/**\n * Override a block editor settings style. Leave the ID blank to create a new\n * style.\n *\n * @param {Object} override Override object.\n * @param {?string} override.id Id of the style override, leave blank to create\n * a new style.\n * @param {string} override.css CSS to apply.\n */\nexport function useStyleOverride( { id, css } ) {\n\treturn usePrivateStyleOverride( { id, css } );\n}\n\nexport function usePrivateStyleOverride( {\n\tid,\n\tcss,\n\tassets,\n\t__unstableType,\n\tvariation,\n\tclientId,\n} = {} ) {\n\tconst { setStyleOverride, deleteStyleOverride } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\tconst registry = useRegistry();\n\tconst fallbackId = useId();\n\tuseEffect( () => {\n\t\t// Unmount if there is CSS and assets are empty.\n\t\tif ( ! css && ! assets ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst _id = id || fallbackId;\n\t\tconst override = {\n\t\t\tid,\n\t\t\tcss,\n\t\t\tassets,\n\t\t\t__unstableType,\n\t\t\tvariation,\n\t\t\tclientId,\n\t\t};\n\t\t// Batch updates to style overrides to avoid triggering cascading renders\n\t\t// for each style override block included in a tree and optimize initial render.\n\t\tif ( ! pendingStyleOverrides.get( registry ) ) {\n\t\t\tpendingStyleOverrides.set( registry, [] );\n\t\t}\n\t\tpendingStyleOverrides.get( registry ).push( [ _id, override ] );\n\t\twindow.queueMicrotask( () => {\n\t\t\tif ( pendingStyleOverrides.get( registry )?.length ) {\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tpendingStyleOverrides.get( registry ).forEach( ( args ) => {\n\t\t\t\t\t\tsetStyleOverride( ...args );\n\t\t\t\t\t} );\n\t\t\t\t\tpendingStyleOverrides.set( registry, [] );\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\n\t\treturn () => {\n\t\t\tconst isPending = pendingStyleOverrides\n\t\t\t\t.get( registry )\n\t\t\t\t?.find( ( [ currentId ] ) => currentId === _id );\n\t\t\tif ( isPending ) {\n\t\t\t\tpendingStyleOverrides.set(\n\t\t\t\t\tregistry,\n\t\t\t\t\tpendingStyleOverrides\n\t\t\t\t\t\t.get( registry )\n\t\t\t\t\t\t.filter( ( [ currentId ] ) => currentId !== _id )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tdeleteStyleOverride( _id );\n\t\t\t}\n\t\t};\n\t}, [\n\t\tid,\n\t\tcss,\n\t\tclientId,\n\t\tassets,\n\t\t__unstableType,\n\t\tfallbackId,\n\t\tsetStyleOverride,\n\t\tdeleteStyleOverride,\n\t\tregistry,\n\t\tvariation,\n\t] );\n}\n\n/**\n * Based on the block and its context, returns an object of all the block settings.\n * This object can be passed as a prop to all the Styles UI components\n * (TypographyPanel, DimensionsPanel...).\n *\n * @param {string} name Block name.\n * @param {*} parentLayout Parent layout.\n *\n * @return {Object} Settings object.\n */\nexport function useBlockSettings( name, parentLayout ) {\n\tconst [\n\t\tbackgroundImage,\n\t\tbackgroundSize,\n\t\tgradient,\n\t\tcustomFontFamilies,\n\t\tdefaultFontFamilies,\n\t\tthemeFontFamilies,\n\t\tdefaultFontSizesEnabled,\n\t\tcustomFontSizes,\n\t\tdefaultFontSizes,\n\t\tthemeFontSizes,\n\t\tcustomFontSize,\n\t\tfontStyle,\n\t\tfontWeight,\n\t\tlineHeight,\n\t\ttextAlign,\n\t\ttextColumns,\n\t\ttextDecoration,\n\t\ttextIndent,\n\t\twritingMode,\n\t\ttextTransform,\n\t\tletterSpacing,\n\t\tpadding,\n\t\tmargin,\n\t\tblockGap,\n\t\tdefaultSpacingSizesEnabled,\n\t\tcustomSpacingSize,\n\t\tuserSpacingSizes,\n\t\tdefaultSpacingSizes,\n\t\tthemeSpacingSizes,\n\t\tunits,\n\t\taspectRatio,\n\t\theight,\n\t\tminHeight,\n\t\twidth,\n\t\tdimensionSizes,\n\t\tlayout,\n\t\tborderColor,\n\t\tborderRadius,\n\t\tborderStyle,\n\t\tborderWidth,\n\t\tborderRadiusSizes,\n\t\tcustomColorsEnabled,\n\t\tcustomColors,\n\t\tcustomDuotone,\n\t\tthemeColors,\n\t\tdefaultColors,\n\t\tdefaultPalette,\n\t\tdefaultDuotone,\n\t\tuserDuotonePalette,\n\t\tthemeDuotonePalette,\n\t\tdefaultDuotonePalette,\n\t\tuserGradientPalette,\n\t\tthemeGradientPalette,\n\t\tdefaultGradientPalette,\n\t\tdefaultGradients,\n\t\tareCustomGradientsEnabled,\n\t\tisBackgroundEnabled,\n\t\tisLinkEnabled,\n\t\tisTextEnabled,\n\t\tisHeadingEnabled,\n\t\tisButtonEnabled,\n\t\tshadow,\n\t] = useSettings(\n\t\t'background.backgroundImage',\n\t\t'background.backgroundSize',\n\t\t'background.gradient',\n\t\t'typography.fontFamilies.custom',\n\t\t'typography.fontFamilies.default',\n\t\t'typography.fontFamilies.theme',\n\t\t'typography.defaultFontSizes',\n\t\t'typography.fontSizes.custom',\n\t\t'typography.fontSizes.default',\n\t\t'typography.fontSizes.theme',\n\t\t'typography.customFontSize',\n\t\t'typography.fontStyle',\n\t\t'typography.fontWeight',\n\t\t'typography.lineHeight',\n\t\t'typography.textAlign',\n\t\t'typography.textColumns',\n\t\t'typography.textDecoration',\n\t\t'typography.textIndent',\n\t\t'typography.writingMode',\n\t\t'typography.textTransform',\n\t\t'typography.letterSpacing',\n\t\t'spacing.padding',\n\t\t'spacing.margin',\n\t\t'spacing.blockGap',\n\t\t'spacing.defaultSpacingSizes',\n\t\t'spacing.customSpacingSize',\n\t\t'spacing.spacingSizes.custom',\n\t\t'spacing.spacingSizes.default',\n\t\t'spacing.spacingSizes.theme',\n\t\t'spacing.units',\n\t\t'dimensions.aspectRatio',\n\t\t'dimensions.height',\n\t\t'dimensions.minHeight',\n\t\t'dimensions.width',\n\t\t'dimensions.dimensionSizes',\n\t\t'layout',\n\t\t'border.color',\n\t\t'border.radius',\n\t\t'border.style',\n\t\t'border.width',\n\t\t'border.radiusSizes',\n\t\t'color.custom',\n\t\t'color.palette.custom',\n\t\t'color.customDuotone',\n\t\t'color.palette.theme',\n\t\t'color.palette.default',\n\t\t'color.defaultPalette',\n\t\t'color.defaultDuotone',\n\t\t'color.duotone.custom',\n\t\t'color.duotone.theme',\n\t\t'color.duotone.default',\n\t\t'color.gradients.custom',\n\t\t'color.gradients.theme',\n\t\t'color.gradients.default',\n\t\t'color.defaultGradients',\n\t\t'color.customGradient',\n\t\t'color.background',\n\t\t'color.link',\n\t\t'color.text',\n\t\t'color.heading',\n\t\t'color.button',\n\t\t'shadow'\n\t);\n\n\tconst rawSettings = useMemo( () => {\n\t\treturn {\n\t\t\tbackground: {\n\t\t\t\tbackgroundImage,\n\t\t\t\tbackgroundSize,\n\t\t\t\tgradient,\n\t\t\t},\n\t\t\tcolor: {\n\t\t\t\tpalette: {\n\t\t\t\t\tcustom: customColors,\n\t\t\t\t\ttheme: themeColors,\n\t\t\t\t\tdefault: defaultColors,\n\t\t\t\t},\n\t\t\t\tgradients: {\n\t\t\t\t\tcustom: userGradientPalette,\n\t\t\t\t\ttheme: themeGradientPalette,\n\t\t\t\t\tdefault: defaultGradientPalette,\n\t\t\t\t},\n\t\t\t\tduotone: {\n\t\t\t\t\tcustom: userDuotonePalette,\n\t\t\t\t\ttheme: themeDuotonePalette,\n\t\t\t\t\tdefault: defaultDuotonePalette,\n\t\t\t\t},\n\t\t\t\tdefaultGradients,\n\t\t\t\tdefaultPalette,\n\t\t\t\tdefaultDuotone,\n\t\t\t\tcustom: customColorsEnabled,\n\t\t\t\tcustomGradient: areCustomGradientsEnabled,\n\t\t\t\tcustomDuotone,\n\t\t\t\tbackground: isBackgroundEnabled,\n\t\t\t\tlink: isLinkEnabled,\n\t\t\t\theading: isHeadingEnabled,\n\t\t\t\tbutton: isButtonEnabled,\n\t\t\t\ttext: isTextEnabled,\n\t\t\t},\n\t\t\ttypography: {\n\t\t\t\tfontFamilies: {\n\t\t\t\t\tcustom: customFontFamilies,\n\t\t\t\t\tdefault: defaultFontFamilies,\n\t\t\t\t\ttheme: themeFontFamilies,\n\t\t\t\t},\n\t\t\t\tfontSizes: {\n\t\t\t\t\tcustom: customFontSizes,\n\t\t\t\t\tdefault: defaultFontSizes,\n\t\t\t\t\ttheme: themeFontSizes,\n\t\t\t\t},\n\t\t\t\tcustomFontSize,\n\t\t\t\tdefaultFontSizes: defaultFontSizesEnabled,\n\t\t\t\tfontStyle,\n\t\t\t\tfontWeight,\n\t\t\t\tlineHeight,\n\t\t\t\ttextAlign,\n\t\t\t\ttextColumns,\n\t\t\t\ttextDecoration,\n\t\t\t\ttextIndent,\n\t\t\t\ttextTransform,\n\t\t\t\tletterSpacing,\n\t\t\t\twritingMode,\n\t\t\t},\n\t\t\tspacing: {\n\t\t\t\tspacingSizes: {\n\t\t\t\t\tcustom: userSpacingSizes,\n\t\t\t\t\tdefault: defaultSpacingSizes,\n\t\t\t\t\ttheme: themeSpacingSizes,\n\t\t\t\t},\n\t\t\t\tcustomSpacingSize,\n\t\t\t\tdefaultSpacingSizes: defaultSpacingSizesEnabled,\n\t\t\t\tpadding,\n\t\t\t\tmargin,\n\t\t\t\tblockGap,\n\t\t\t\tunits,\n\t\t\t},\n\t\t\tborder: {\n\t\t\t\tcolor: borderColor,\n\t\t\t\tradius: borderRadius,\n\t\t\t\tstyle: borderStyle,\n\t\t\t\twidth: borderWidth,\n\t\t\t\tradiusSizes: borderRadiusSizes,\n\t\t\t},\n\t\t\tdimensions: {\n\t\t\t\taspectRatio,\n\t\t\t\theight,\n\t\t\t\tminHeight,\n\t\t\t\twidth,\n\t\t\t\tdimensionSizes,\n\t\t\t},\n\t\t\tlayout,\n\t\t\tparentLayout,\n\t\t\tshadow,\n\t\t};\n\t}, [\n\t\tbackgroundImage,\n\t\tbackgroundSize,\n\t\tgradient,\n\t\tcustomFontFamilies,\n\t\tdefaultFontFamilies,\n\t\tthemeFontFamilies,\n\t\tdefaultFontSizesEnabled,\n\t\tcustomFontSizes,\n\t\tdefaultFontSizes,\n\t\tthemeFontSizes,\n\t\tcustomFontSize,\n\t\tfontStyle,\n\t\tfontWeight,\n\t\tlineHeight,\n\t\ttextAlign,\n\t\ttextColumns,\n\t\ttextDecoration,\n\t\ttextIndent,\n\t\ttextTransform,\n\t\tletterSpacing,\n\t\twritingMode,\n\t\tpadding,\n\t\tmargin,\n\t\tblockGap,\n\t\tdefaultSpacingSizesEnabled,\n\t\tcustomSpacingSize,\n\t\tuserSpacingSizes,\n\t\tdefaultSpacingSizes,\n\t\tthemeSpacingSizes,\n\t\tunits,\n\t\taspectRatio,\n\t\theight,\n\t\tminHeight,\n\t\twidth,\n\t\tdimensionSizes,\n\t\tlayout,\n\t\tparentLayout,\n\t\tborderColor,\n\t\tborderRadius,\n\t\tborderStyle,\n\t\tborderWidth,\n\t\tborderRadiusSizes,\n\t\tcustomColorsEnabled,\n\t\tcustomColors,\n\t\tcustomDuotone,\n\t\tthemeColors,\n\t\tdefaultColors,\n\t\tdefaultPalette,\n\t\tdefaultDuotone,\n\t\tuserDuotonePalette,\n\t\tthemeDuotonePalette,\n\t\tdefaultDuotonePalette,\n\t\tuserGradientPalette,\n\t\tthemeGradientPalette,\n\t\tdefaultGradientPalette,\n\t\tdefaultGradients,\n\t\tareCustomGradientsEnabled,\n\t\tisBackgroundEnabled,\n\t\tisLinkEnabled,\n\t\tisTextEnabled,\n\t\tisHeadingEnabled,\n\t\tisButtonEnabled,\n\t\tshadow,\n\t] );\n\n\treturn useSettingsForBlockElement( rawSettings, name );\n}\n\nexport function createBlockEditFilter( features ) {\n\t// We don't want block controls to re-render when typing inside a block.\n\t// `memo` will prevent re-renders unless props change, so only pass the\n\t// needed props and not the whole attributes object.\n\tfeatures = features.map( ( settings ) => {\n\t\treturn { ...settings, Edit: memo( settings.edit ) };\n\t} );\n\tconst withBlockEditHooks = createHigherOrderComponent(\n\t\t( OriginalBlockEdit ) =>\n\t\t\tfunction WithBlockEditHooks( props ) {\n\t\t\t\tconst context = useBlockEditContext();\n\t\t\t\t// CAUTION: code added before this line will be executed for all\n\t\t\t\t// blocks, not just those that support the feature! Code added\n\t\t\t\t// above this line should be carefully evaluated for its impact on\n\t\t\t\t// performance.\n\t\t\t\treturn [\n\t\t\t\t\t...features.map( ( feature, i ) => {\n\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\tEdit,\n\t\t\t\t\t\t\thasSupport,\n\t\t\t\t\t\t\tattributeKeys = [],\n\t\t\t\t\t\t\tshareWithChildBlocks,\n\t\t\t\t\t\t\tsupportsPatternEditing,\n\t\t\t\t\t\t} = feature;\n\t\t\t\t\t\tconst shouldDisplayControls =\n\t\t\t\t\t\t\t( supportsPatternEditing &&\n\t\t\t\t\t\t\t\tcontext[\n\t\t\t\t\t\t\t\t\tmayDisplayPatternEditingControlsKey\n\t\t\t\t\t\t\t\t] ) ||\n\t\t\t\t\t\t\tcontext[ mayDisplayControlsKey ] ||\n\t\t\t\t\t\t\t( context[ mayDisplayParentControlsKey ] &&\n\t\t\t\t\t\t\t\tshareWithChildBlocks );\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t! shouldDisplayControls ||\n\t\t\t\t\t\t\t! hasSupport( props.name )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst neededProps = {};\n\t\t\t\t\t\tfor ( const key of attributeKeys ) {\n\t\t\t\t\t\t\tif ( props.attributes[ key ] ) {\n\t\t\t\t\t\t\t\tneededProps[ key ] = props.attributes[ key ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<Edit\n\t\t\t\t\t\t\t\t// We can use the index because the array length\n\t\t\t\t\t\t\t\t// is fixed per page load right now.\n\t\t\t\t\t\t\t\tkey={ i }\n\t\t\t\t\t\t\t\tname={ props.name }\n\t\t\t\t\t\t\t\tisSelected={ props.isSelected }\n\t\t\t\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\t\t\t\tsetAttributes={ props.setAttributes }\n\t\t\t\t\t\t\t\t__unstableParentLayout={\n\t\t\t\t\t\t\t\t\tprops.__unstableParentLayout\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t// This component is pure, so only pass needed\n\t\t\t\t\t\t\t\t// props!!!\n\t\t\t\t\t\t\t\t{ ...neededProps }\n\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<OriginalBlockEdit key=\"edit\" { ...props } />,\n\t\t\t\t];\n\t\t\t},\n\t\t'withBlockEditHooks'\n\t);\n\taddFilter( 'editor.BlockEdit', 'core/editor/hooks', withBlockEditHooks );\n}\n\nfunction BlockProps( {\n\tindex,\n\tuseBlockProps: hook,\n\tsetAllWrapperProps,\n\t...props\n} ) {\n\tconst wrapperProps = hook( props );\n\tconst setWrapperProps = ( next ) =>\n\t\tsetAllWrapperProps( ( prev ) => {\n\t\t\tconst nextAll = [ ...prev ];\n\t\t\tnextAll[ index ] = next;\n\t\t\treturn nextAll;\n\t\t} );\n\t// Setting state after every render is fine because this component is\n\t// pure and will only re-render when needed props change.\n\tuseEffect( () => {\n\t\t// We could shallow compare the props, but since this component only\n\t\t// changes when needed attributes change, the benefit is probably small.\n\t\tsetWrapperProps( wrapperProps );\n\t\treturn () => {\n\t\t\tsetWrapperProps( undefined );\n\t\t};\n\t} );\n\treturn null;\n}\n\nconst BlockPropsPure = memo( BlockProps );\n\nexport function createBlockListBlockFilter( features ) {\n\tconst withBlockListBlockHooks = createHigherOrderComponent(\n\t\t( BlockListBlock ) =>\n\t\t\tfunction WithBlockListBlockHooks( props ) {\n\t\t\t\tconst [ allWrapperProps, setAllWrapperProps ] = useState(\n\t\t\t\t\tArray( features.length ).fill( undefined )\n\t\t\t\t);\n\t\t\t\treturn [\n\t\t\t\t\t...features.map( ( feature, i ) => {\n\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\thasSupport,\n\t\t\t\t\t\t\tattributeKeys = [],\n\t\t\t\t\t\t\tuseBlockProps,\n\t\t\t\t\t\t\tisMatch,\n\t\t\t\t\t\t} = feature;\n\n\t\t\t\t\t\tconst neededProps = {};\n\t\t\t\t\t\tfor ( const key of attributeKeys ) {\n\t\t\t\t\t\t\tif ( props.attributes[ key ] ) {\n\t\t\t\t\t\t\t\tneededProps[ key ] = props.attributes[ key ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t// Skip rendering if none of the needed attributes are\n\t\t\t\t\t\t\t// set.\n\t\t\t\t\t\t\t! Object.keys( neededProps ).length ||\n\t\t\t\t\t\t\t! hasSupport( props.name ) ||\n\t\t\t\t\t\t\t( isMatch && ! isMatch( neededProps ) )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<BlockPropsPure\n\t\t\t\t\t\t\t\t// We can use the index because the array length\n\t\t\t\t\t\t\t\t// is fixed per page load right now.\n\t\t\t\t\t\t\t\tkey={ i }\n\t\t\t\t\t\t\t\tindex={ i }\n\t\t\t\t\t\t\t\tuseBlockProps={ useBlockProps }\n\t\t\t\t\t\t\t\t// This component is pure, so we must pass a stable\n\t\t\t\t\t\t\t\t// function reference.\n\t\t\t\t\t\t\t\tsetAllWrapperProps={ setAllWrapperProps }\n\t\t\t\t\t\t\t\tname={ props.name }\n\t\t\t\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\t\t\t\t// This component is pure, so only pass needed\n\t\t\t\t\t\t\t\t// props!!!\n\t\t\t\t\t\t\t\t{ ...neededProps }\n\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<BlockListBlock\n\t\t\t\t\t\tkey=\"edit\"\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\twrapperProps={ allWrapperProps\n\t\t\t\t\t\t\t.filter( Boolean )\n\t\t\t\t\t\t\t.reduce( ( acc, wrapperProps ) => {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t\t\t\t...wrapperProps,\n\t\t\t\t\t\t\t\t\tclassName: clsx(\n\t\t\t\t\t\t\t\t\t\tacc.className,\n\t\t\t\t\t\t\t\t\t\twrapperProps.className\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t\t\t\t...acc.style,\n\t\t\t\t\t\t\t\t\t\t...wrapperProps.style,\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}, props.wrapperProps || {} ) }\n\t\t\t\t\t/>,\n\t\t\t\t];\n\t\t\t},\n\t\t'withBlockListBlockHooks'\n\t);\n\taddFilter(\n\t\t'editor.BlockListBlock',\n\t\t'core/editor/hooks',\n\t\twithBlockListBlockHooks\n\t);\n}\n\nexport function createBlockSaveFilter( features ) {\n\tfunction extraPropsFromHooks( props, name, attributes ) {\n\t\treturn features.reduce( ( accu, feature ) => {\n\t\t\tconst { hasSupport, attributeKeys = [], addSaveProps } = feature;\n\n\t\t\tconst neededAttributes = {};\n\t\t\tfor ( const key of attributeKeys ) {\n\t\t\t\tif ( attributes[ key ] ) {\n\t\t\t\t\tneededAttributes[ key ] = attributes[ key ];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t// Skip rendering if none of the needed attributes are\n\t\t\t\t// set.\n\t\t\t\t! Object.keys( neededAttributes ).length ||\n\t\t\t\t! hasSupport( name )\n\t\t\t) {\n\t\t\t\treturn accu;\n\t\t\t}\n\n\t\t\treturn addSaveProps( accu, name, neededAttributes );\n\t\t}, props );\n\t}\n\taddFilter(\n\t\t'blocks.getSaveContent.extraProps',\n\t\t'core/editor/hooks',\n\t\textraPropsFromHooks,\n\t\t0\n\t);\n\taddFilter(\n\t\t'blocks.getSaveContent.extraProps',\n\t\t'core/editor/hooks',\n\t\t( props ) => {\n\t\t\t// Previously we had a filter deleting the className if it was an empty\n\t\t\t// string. That filter is no longer running, so now we need to delete it\n\t\t\t// here.\n\t\t\tif ( props.hasOwnProperty( 'className' ) && ! props.className ) {\n\t\t\t\tdelete props.className;\n\t\t\t}\n\n\t\t\treturn props;\n\t\t}\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,uBAAuB;AAChC,SAAS,MAAM,SAAS,WAAW,OAAO,gBAAgB;AAC1D,SAAS,aAAa,mBAAmB;AACzC,SAAS,kCAAkC;AAC3C,SAAS,iBAAiB;AAK1B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,mBAAmB;AAC5B,SAAS,kCAAkC;AAC3C,SAAS,wBAAwB,oBAAoB;AACrD,SAAS,SAAS,wBAAwB;AAC1C,SAAS,cAAc;AAiiBhB;AAzhBA,IAAM,mBAAmB,CAAE,WAAY;AAC7C,MACC,WAAW,QACX,OAAO,WAAW,YAClB,MAAM,QAAS,MAAO,GACrB;AACD,WAAO;AAAA,EACR;AAEA,QAAM,uBAAuB,OAAO,QAAS,MAAO,EAClD,IAAK,CAAE,CAAE,KAAK,KAAM,MAAO,CAAE,KAAK,iBAAkB,KAAM,CAAE,CAAE,EAC9D,OAAQ,CAAE,CAAE,EAAE,KAAM,MAAO,UAAU,MAAU;AACjD,SAAO,CAAE,qBAAqB,SAC3B,SACA,OAAO,YAAa,oBAAqB;AAC7C;AAEO,SAAS,gBACf,gBACA,gBAC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AE;AACH;AAYO,SAAS,iBAAkB,MAAM,cAAe;AACtD,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAA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