@wordpress/block-editor 12.10.6 → 12.10.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,7 @@ var _data = require("@wordpress/data");
14
14
  var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
15
15
  var _provider = require("../provider");
16
16
  var _auto = _interopRequireDefault(require("./auto"));
17
+ var _editorStyles = _interopRequireDefault(require("../editor-styles"));
17
18
  var _store = require("../../store");
18
19
  var _blockList = require("../block-list");
19
20
  /**
@@ -110,6 +111,8 @@ function useBlockPreview({
110
111
  const originalSettings = (0, _data.useSelect)(select => select(_store.store).getSettings(), []);
111
112
  const settings = (0, _element.useMemo)(() => ({
112
113
  ...originalSettings,
114
+ styles: undefined,
115
+ // Clear styles included by the parent settings, as they are already output by the parent's EditorStyles.
113
116
  __unstableIsPreviewMode: true
114
117
  }), [originalSettings]);
115
118
  const disabledRef = (0, _compose.useDisabled)();
@@ -118,7 +121,7 @@ function useBlockPreview({
118
121
  const children = (0, _element.createElement)(_provider.ExperimentalBlockEditorProvider, {
119
122
  value: renderedBlocks,
120
123
  settings: settings
121
- }, (0, _element.createElement)(_blockList.BlockListItems, {
124
+ }, (0, _element.createElement)(_editorStyles.default, null), (0, _element.createElement)(_blockList.BlockListItems, {
122
125
  renderAppender: false,
123
126
  layout: layout
124
127
  }));
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_classnames","_interopRequireDefault","_compose","_data","_deprecated","_provider","_auto","_store","_blockList","BlockPreview","blocks","viewportWidth","minHeight","additionalStyles","__experimentalMinHeight","__experimentalPadding","deprecated","since","version","alternative","css","originalSettings","useSelect","select","blockEditorStore","getSettings","settings","useMemo","__unstableIsPreviewMode","renderedBlocks","Array","isArray","length","createElement","ExperimentalBlockEditorProvider","value","default","_default","memo","exports","useBlockPreview","props","layout","disabledRef","useDisabled","ref","useMergeRefs","children","BlockListItems","renderAppender","className","classnames"],"sources":["@wordpress/block-editor/src/components/block-preview/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useDisabled, useMergeRefs } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { memo, useMemo } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { ExperimentalBlockEditorProvider } from '../provider';\nimport AutoHeightBlockPreview from './auto';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockListItems } from '../block-list';\n\nexport function BlockPreview( {\n\tblocks,\n\tviewportWidth = 1200,\n\tminHeight,\n\tadditionalStyles = [],\n\t// Deprecated props:\n\t__experimentalMinHeight,\n\t__experimentalPadding,\n} ) {\n\tif ( __experimentalMinHeight ) {\n\t\tminHeight = __experimentalMinHeight;\n\t\tdeprecated( 'The __experimentalMinHeight prop', {\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t\talternative: 'minHeight',\n\t\t} );\n\t}\n\tif ( __experimentalPadding ) {\n\t\tadditionalStyles = [\n\t\t\t...additionalStyles,\n\t\t\t{ css: `body { padding: ${ __experimentalPadding }px; }` },\n\t\t];\n\t\tdeprecated( 'The __experimentalPadding prop of BlockPreview', {\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t\talternative: 'additionalStyles',\n\t\t} );\n\t}\n\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( { ...originalSettings, __unstableIsPreviewMode: true } ),\n\t\t[ originalSettings ]\n\t);\n\tconst renderedBlocks = useMemo(\n\t\t() => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),\n\t\t[ blocks ]\n\t);\n\n\tif ( ! blocks || blocks.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\tvalue={ renderedBlocks }\n\t\t\tsettings={ settings }\n\t\t>\n\t\t\t<AutoHeightBlockPreview\n\t\t\t\tviewportWidth={ viewportWidth }\n\t\t\t\tminHeight={ minHeight }\n\t\t\t\tadditionalStyles={ additionalStyles }\n\t\t\t/>\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n}\n\n/**\n * BlockPreview renders a preview of a block or array of blocks.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-preview/README.md\n *\n * @param {Object} preview options for how the preview should be shown\n * @param {Array|Object} preview.blocks A block instance (object) or an array of blocks to be previewed.\n * @param {number} preview.viewportWidth Width of the preview container in pixels. Controls at what size the blocks will be rendered inside the preview. Default: 700.\n *\n * @return {WPComponent} The component to be rendered.\n */\nexport default memo( BlockPreview );\n\n/**\n * This hook is used to lightly mark an element as a block preview wrapper\n * element. Call this hook and pass the returned props to the element to mark as\n * a block preview wrapper, automatically rendering inner blocks as children. If\n * you define a ref for the element, it is important to pass the ref to this\n * hook, which the hook in turn will pass to the component through the props it\n * returns. Optionally, you can also pass any other props through this hook, and\n * they will be merged and returned.\n *\n * @param {Object} options Preview options.\n * @param {WPBlock[]} options.blocks Block objects.\n * @param {Object} options.props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options.layout Layout settings to be used in the preview.\n */\nexport function useBlockPreview( { blocks, props = {}, layout } ) {\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( { ...originalSettings, __unstableIsPreviewMode: true } ),\n\t\t[ originalSettings ]\n\t);\n\tconst disabledRef = useDisabled();\n\tconst ref = useMergeRefs( [ props.ref, disabledRef ] );\n\tconst renderedBlocks = useMemo(\n\t\t() => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),\n\t\t[ blocks ]\n\t);\n\n\tconst children = (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\tvalue={ renderedBlocks }\n\t\t\tsettings={ settings }\n\t\t>\n\t\t\t<BlockListItems renderAppender={ false } layout={ layout } />\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n\n\treturn {\n\t\t...props,\n\t\tref,\n\t\tclassName: classnames(\n\t\t\tprops.className,\n\t\t\t'block-editor-block-preview__live-content',\n\t\t\t'components-disabled'\n\t\t),\n\t\tchildren: blocks?.length ? children : null,\n\t};\n}\n"],"mappings":";;;;;;;;;AAUA,IAAAA,QAAA,GAAAC,OAAA;AAPA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAEA,IAAAK,WAAA,GAAAH,sBAAA,CAAAF,OAAA;AAKA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAL,sBAAA,CAAAF,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,UAAA,GAAAT,OAAA;AAnBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;;AAMO,SAASU,YAAYA,CAAE;EAC7BC,MAAM;EACNC,aAAa,GAAG,IAAI;EACpBC,SAAS;EACTC,gBAAgB,GAAG,EAAE;EACrB;EACAC,uBAAuB;EACvBC;AACD,CAAC,EAAG;EACH,IAAKD,uBAAuB,EAAG;IAC9BF,SAAS,GAAGE,uBAAuB;IACnC,IAAAE,mBAAU,EAAE,kCAAkC,EAAE;MAC/CC,KAAK,EAAE,KAAK;MACZC,OAAO,EAAE,KAAK;MACdC,WAAW,EAAE;IACd,CAAE,CAAC;EACJ;EACA,IAAKJ,qBAAqB,EAAG;IAC5BF,gBAAgB,GAAG,CAClB,GAAGA,gBAAgB,EACnB;MAAEO,GAAG,EAAG,mBAAmBL,qBAAuB;IAAO,CAAC,CAC1D;IACD,IAAAC,mBAAU,EAAE,gDAAgD,EAAE;MAC7DC,KAAK,EAAE,KAAK;MACZC,OAAO,EAAE,KAAK;MACdC,WAAW,EAAE;IACd,CAAE,CAAC;EACJ;EAEA,MAAME,gBA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AAC,CAACC,WAAW,CAAC,CAAC,EACtD,EACD,CAAC;EACD,MAAMC,QAAQ,GAAG,IAAAC,gBAAO,EACvB,OAAQ;IAAE,GAAGN,gBAAgB;IAAEO,uBAAuB,EAAE;EAAK,CAAC,CAAE,EAChE,CAAEP,gBAAgB,CACnB,CAAC;EACD,MAAMsB,WAAW,GAAG,IAAAC,oBAAW,EAAC,CAAC;EACjC,MAAMC,GAAG,GAAG,IAAAC,qBAAY,EAAE,CAAEL,KAAK,CAACI,GAAG,EAAEF,WAAW,CAAG,CAAC;EACtD,MAAMd,cAAc,GAAG,IAAAF,gBAAO,EAC7B,MAAQG,KAAK,CAACC,OAAO,CAAErB,MAAO,CAAC,GAAGA,MAAM,GAAG,CAAEA,MAAM,CAAI,EACvD,CAAEA,MAAM,CACT,CAAC;EAED,MAAMqC,QAAQ,GACb,IAAAjD,QAAA,CAAAmC,aAAA,EAAC5B,SAAA,CAAA6B,+BAA+B;IAC/BC,KAAK,EAAGN,cAAgB;IACxBH,QAAQ,EAAGA;EAAU,GAErB,IAAA5B,QAAA,CAAAmC,aAAA,EAACzB,UAAA,CAAAwC,cAAc;IAACC,cAAc,EAAG,KAAO;IAACP,MAAM,EAAGA;EAAQ,CAAE,CAC5B,CACjC;EAED,OAAO;IACN,GAAGD,KAAK;IACRI,GAAG;IACHK,SAAS,EAAE,IAAAC,mBAAU,EACpBV,KAAK,CAACS,SAAS,EACf,0CAA0C,EAC1C,qBACD,CAAC;IACDH,QAAQ,EAAErC,MAAM,EAAEsB,MAAM,GAAGe,QAAQ,GAAG;EACvC,CAAC;AACF"}
1
+ {"version":3,"names":["_element","require","_classnames","_interopRequireDefault","_compose","_data","_deprecated","_provider","_auto","_editorStyles","_store","_blockList","BlockPreview","blocks","viewportWidth","minHeight","additionalStyles","__experimentalMinHeight","__experimentalPadding","deprecated","since","version","alternative","css","originalSettings","useSelect","select","blockEditorStore","getSettings","settings","useMemo","__unstableIsPreviewMode","renderedBlocks","Array","isArray","length","createElement","ExperimentalBlockEditorProvider","value","default","_default","memo","exports","useBlockPreview","props","layout","styles","undefined","disabledRef","useDisabled","ref","useMergeRefs","children","BlockListItems","renderAppender","className","classnames"],"sources":["@wordpress/block-editor/src/components/block-preview/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useDisabled, useMergeRefs } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { memo, useMemo } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { ExperimentalBlockEditorProvider } from '../provider';\nimport AutoHeightBlockPreview from './auto';\nimport EditorStyles from '../editor-styles';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockListItems } from '../block-list';\n\nexport function BlockPreview( {\n\tblocks,\n\tviewportWidth = 1200,\n\tminHeight,\n\tadditionalStyles = [],\n\t// Deprecated props:\n\t__experimentalMinHeight,\n\t__experimentalPadding,\n} ) {\n\tif ( __experimentalMinHeight ) {\n\t\tminHeight = __experimentalMinHeight;\n\t\tdeprecated( 'The __experimentalMinHeight prop', {\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t\talternative: 'minHeight',\n\t\t} );\n\t}\n\tif ( __experimentalPadding ) {\n\t\tadditionalStyles = [\n\t\t\t...additionalStyles,\n\t\t\t{ css: `body { padding: ${ __experimentalPadding }px; }` },\n\t\t];\n\t\tdeprecated( 'The __experimentalPadding prop of BlockPreview', {\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t\talternative: 'additionalStyles',\n\t\t} );\n\t}\n\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( { ...originalSettings, __unstableIsPreviewMode: true } ),\n\t\t[ originalSettings ]\n\t);\n\tconst renderedBlocks = useMemo(\n\t\t() => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),\n\t\t[ blocks ]\n\t);\n\n\tif ( ! blocks || blocks.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\tvalue={ renderedBlocks }\n\t\t\tsettings={ settings }\n\t\t>\n\t\t\t<AutoHeightBlockPreview\n\t\t\t\tviewportWidth={ viewportWidth }\n\t\t\t\tminHeight={ minHeight }\n\t\t\t\tadditionalStyles={ additionalStyles }\n\t\t\t/>\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n}\n\n/**\n * BlockPreview renders a preview of a block or array of blocks.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-preview/README.md\n *\n * @param {Object} preview options for how the preview should be shown\n * @param {Array|Object} preview.blocks A block instance (object) or an array of blocks to be previewed.\n * @param {number} preview.viewportWidth Width of the preview container in pixels. Controls at what size the blocks will be rendered inside the preview. Default: 700.\n *\n * @return {WPComponent} The component to be rendered.\n */\nexport default memo( BlockPreview );\n\n/**\n * This hook is used to lightly mark an element as a block preview wrapper\n * element. Call this hook and pass the returned props to the element to mark as\n * a block preview wrapper, automatically rendering inner blocks as children. If\n * you define a ref for the element, it is important to pass the ref to this\n * hook, which the hook in turn will pass to the component through the props it\n * returns. Optionally, you can also pass any other props through this hook, and\n * they will be merged and returned.\n *\n * @param {Object} options Preview options.\n * @param {WPBlock[]} options.blocks Block objects.\n * @param {Object} options.props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options.layout Layout settings to be used in the preview.\n */\nexport function useBlockPreview( { blocks, props = {}, layout } ) {\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( {\n\t\t\t...originalSettings,\n\t\t\tstyles: undefined, // Clear styles included by the parent settings, as they are already output by the parent's EditorStyles.\n\t\t\t__unstableIsPreviewMode: true,\n\t\t} ),\n\t\t[ originalSettings ]\n\t);\n\tconst disabledRef = useDisabled();\n\tconst ref = useMergeRefs( [ props.ref, disabledRef ] );\n\tconst renderedBlocks = useMemo(\n\t\t() => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),\n\t\t[ blocks ]\n\t);\n\n\tconst children = (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\tvalue={ renderedBlocks }\n\t\t\tsettings={ settings }\n\t\t>\n\t\t\t<EditorStyles />\n\t\t\t<BlockListItems renderAppender={ false } layout={ layout } />\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n\n\treturn {\n\t\t...props,\n\t\tref,\n\t\tclassName: classnames(\n\t\t\tprops.className,\n\t\t\t'block-editor-block-preview__live-content',\n\t\t\t'components-disabled'\n\t\t),\n\t\tchildren: blocks?.length ? children : null,\n\t};\n}\n"],"mappings":";;;;;;;;;AAUA,IAAAA,QAAA,GAAAC,OAAA;AAPA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAEA,IAAAK,WAAA,GAAAH,sBAAA,CAAAF,OAAA;AAKA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAL,sBAAA,CAAAF,OAAA;AACA,IAAAQ,aAAA,GAAAN,sBAAA,CAAAF,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,UAAA,GAAAV,OAAA;AApBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;;AAOO,SAASW,YAAYA,CAAE;EAC7BC,MAAM;EACNC,aAAa,GAAG,IAAI;EACpBC,SAAS;EACTC,gBAAgB,GAAG,EAAE;EACrB;EACAC,uBAAuB;EACvBC;AACD,CAAC,EAAG;EACH,IAAKD,uBAAuB,EAAG;IAC9BF,SAAS,GAAGE,uBAAuB;IACnC,IAAAE,mBAAU,EAAE,kCAAkC,EAAE;MAC/CC,KAAK,EAAE,KAAK;MACZC,OAAO,EAAE,KAAK;MACdC,WAAW,EAAE;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ACHK,SAAS,EAAE,IAAAC,mBAAU,EACpBZ,KAAK,CAACW,SAAS,EACf,0CAA0C,EAC1C,qBACD,CAAC;IACDH,QAAQ,EAAEvC,MAAM,EAAEsB,MAAM,GAAGiB,QAAQ,GAAG;EACvC,CAAC;AACF"}
@@ -21,6 +21,7 @@ var _utils2 = require("../components/global-styles/utils");
21
21
  var _utils3 = require("./utils");
22
22
  var _filtersPanel = _interopRequireDefault(require("../components/global-styles/filters-panel"));
23
23
  var _blockEditingMode = require("../components/block-editing-mode");
24
+ var _useBlockRefs = require("../components/block-list/use-block-props/use-block-refs");
24
25
  var _store = require("../store");
25
26
  var _lockUnlock = require("../lock-unlock");
26
27
  /**
@@ -36,6 +37,12 @@ var _lockUnlock = require("../lock-unlock");
36
37
  */
37
38
 
38
39
  const EMPTY_ARRAY = [];
40
+
41
+ // Safari does not always update the duotone filter when the duotone colors
42
+ // are changed. This browser check is later used to force a re-render of the block
43
+ // element to ensure the duotone filter is updated. The check is included at the
44
+ // root of this file as it only needs to be run once per page load.
45
+ const isSafari = window?.navigator.userAgent && window.navigator.userAgent.includes('Safari') && !window.navigator.userAgent.includes('Chrome') && !window.navigator.userAgent.includes('Chromium');
39
46
  (0, _colord.extend)([_names.default]);
40
47
  function useMultiOriginPresets({
41
48
  presetSetting,
@@ -188,6 +195,7 @@ const withDuotoneControls = (0, _compose.createHigherOrderComponent)(BlockEdit =
188
195
  }));
189
196
  }, 'withDuotoneControls');
190
197
  function DuotoneStyles({
198
+ clientId,
191
199
  id: filterId,
192
200
  selector: duotoneSelector,
193
201
  attribute: duotoneAttr
@@ -237,6 +245,7 @@ function DuotoneStyles({
237
245
  setStyleOverride,
238
246
  deleteStyleOverride
239
247
  } = (0, _lockUnlock.unlock)((0, _data.useDispatch)(_store.store));
248
+ const blockElement = (0, _useBlockRefs.__unstableUseBlockElement)(clientId);
240
249
  (0, _element.useEffect)(() => {
241
250
  if (!isValidFilter) return;
242
251
  setStyleOverride(filterId, {
@@ -247,11 +256,28 @@ function DuotoneStyles({
247
256
  assets: colors !== 'unset' ? (0, _utils.getDuotoneFilter)(filterId, colors) : '',
248
257
  __unstableType: 'svgs'
249
258
  });
259
+
260
+ // Safari does not always update the duotone filter when the duotone colors
261
+ // are changed. When using Safari, force the block element to be repainted by
262
+ // the browser to ensure any changes are reflected visually. This logic matches
263
+ // that used on the site frontend in `block-supports/duotone.php`.
264
+ if (blockElement && isSafari) {
265
+ const display = blockElement.style.display;
266
+ // Switch to `inline-block` to force a repaint. In the editor, `inline-block`
267
+ // is used instead of `none` to ensure that scroll position is not affected,
268
+ // as `none` results in the editor scrolling to the top of the block.
269
+ blockElement.style.display = 'inline-block';
270
+ // Simply accessing el.offsetHeight flushes layout and style
271
+ // changes in WebKit without having to wait for setTimeout.
272
+ // eslint-disable-next-line no-unused-expressions
273
+ blockElement.offsetHeight;
274
+ blockElement.style.display = display;
275
+ }
250
276
  return () => {
251
277
  deleteStyleOverride(filterId);
252
278
  deleteStyleOverride(`duotone-${filterId}`);
253
279
  };
254
- }, [isValidFilter, colors, selector, filterId, setStyleOverride, deleteStyleOverride]);
280
+ }, [isValidFilter, blockElement, colors, selector, filterId, setStyleOverride, deleteStyleOverride]);
255
281
  return null;
256
282
  }
257
283
 
@@ -301,6 +327,7 @@ const withDuotoneStyles = (0, _compose.createHigherOrderComponent)(BlockListBloc
301
327
  // above this line should be carefully evaluated for its impact on
302
328
  // performance.
303
329
  return (0, _element.createElement)(_element.Fragment, null, shouldRender && (0, _element.createElement)(DuotoneStyles, {
330
+ clientId: props.clientId,
304
331
  id: filterClass,
305
332
  selector: selector,
306
333
  attribute: attribute
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_classnames","_interopRequireDefault","_colord","_names","_blocks","_compose","_hooks","_data","_components","_utils","_getBlockCssSelector","_utils2","_utils3","_filtersPanel","_blockEditingMode","_store","_lockUnlock","EMPTY_ARRAY","extend","namesPlugin","useMultiOriginPresets","presetSetting","defaultSetting","disableDefault","useSetting","userPresets","themePresets","defaultPresets","useMemo","getColorsFromDuotonePreset","duotone","duotonePalette","preset","find","slug","colors","undefined","getDuotonePresetFromColors","Array","isArray","duotonePreset","every","val","index","DuotonePanel","attributes","setAttributes","name","style","duotoneStyle","color","settings","useBlockSettings","colorPalette","disableCustomColors","disableCustomDuotone","length","duotonePresetOrColors","createElement","Fragment","InspectorControls","group","default","value","filter","onChange","newDuotone","newStyle","BlockControls","__experimentalShareWithChildBlocks","__experimentalDuotoneControl","maybePreset","addDuotoneAttributes","hasBlockSupport","Object","assign","type","withDuotoneControls","createHigherOrderComponent","BlockEdit","props","hasDuotoneSupport","blockEditingMode","useBlockEditingMode","DuotoneStyles","id","filterId","selector","duotoneSelector","attribute","duotoneAttr","isCustom","isPreset","isCSS","selectors","split","selectorsScoped","map","selectorPart","trim","join","isValidFilter","setStyleOverride","deleteStyleOverride","unlock","useDispatch","blockEditorStore","useEffect","css","getDuotoneStylesheet","getDuotoneUnsetStylesheet","__unstableType","assets","getDuotoneFilter","withDuotoneStyles","BlockListBlock","useInstanceId","blockType","getBlockType","duotoneSupport","getBlockSupport","experimentalDuotone","rootSelector","getBlockCSSSelector","scopeSelector","fallback","filterClass","shouldRender","className","classnames","addFilter"],"sources":["@wordpress/block-editor/src/hooks/duotone.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tgetBlockSupport,\n\tgetBlockType,\n\thasBlockSupport,\n} from '@wordpress/blocks';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { useMemo, useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBlockControls,\n\tInspectorControls,\n\t__experimentalDuotoneControl as DuotoneControl,\n\tuseSetting,\n} from '../components';\nimport {\n\tgetDuotoneFilter,\n\tgetDuotoneStylesheet,\n\tgetDuotoneUnsetStylesheet,\n} from '../components/duotone/utils';\nimport { getBlockCSSSelector } from '../components/global-styles/get-block-css-selector';\nimport { scopeSelector } from '../components/global-styles/utils';\nimport { useBlockSettings } from './utils';\nimport { default as StylesFiltersPanel } from '../components/global-styles/filters-panel';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\nimport { store as blockEditorStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\nconst EMPTY_ARRAY = [];\n\nextend( [ namesPlugin ] );\n\nfunction useMultiOriginPresets( { presetSetting, defaultSetting } ) {\n\tconst disableDefault = ! useSetting( defaultSetting );\n\tconst userPresets =\n\t\tuseSetting( `${ presetSetting }.custom` ) || EMPTY_ARRAY;\n\tconst themePresets =\n\t\tuseSetting( `${ presetSetting }.theme` ) || EMPTY_ARRAY;\n\tconst defaultPresets =\n\t\tuseSetting( `${ presetSetting }.default` ) || EMPTY_ARRAY;\n\treturn useMemo(\n\t\t() => [\n\t\t\t...userPresets,\n\t\t\t...themePresets,\n\t\t\t...( disableDefault ? EMPTY_ARRAY : defaultPresets ),\n\t\t],\n\t\t[ disableDefault, userPresets, themePresets, defaultPresets ]\n\t);\n}\n\nexport function getColorsFromDuotonePreset( duotone, duotonePalette ) {\n\tif ( ! duotone ) {\n\t\treturn;\n\t}\n\tconst preset = duotonePalette?.find( ( { slug } ) => {\n\t\treturn duotone === `var:preset|duotone|${ slug }`;\n\t} );\n\n\treturn preset ? preset.colors : undefined;\n}\n\nexport function getDuotonePresetFromColors( colors, duotonePalette ) {\n\tif ( ! colors || ! Array.isArray( colors ) ) {\n\t\treturn;\n\t}\n\n\tconst preset = duotonePalette?.find( ( duotonePreset ) => {\n\t\treturn duotonePreset?.colors?.every(\n\t\t\t( val, index ) => val === colors[ index ]\n\t\t);\n\t} );\n\n\treturn preset ? `var:preset|duotone|${ preset.slug }` : undefined;\n}\n\nfunction DuotonePanel( { attributes, setAttributes, name } ) {\n\tconst style = attributes?.style;\n\tconst duotoneStyle = style?.color?.duotone;\n\tconst settings = useBlockSettings( name );\n\n\tconst duotonePalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.duotone',\n\t\tdefaultSetting: 'color.defaultDuotone',\n\t} );\n\tconst colorPalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.palette',\n\t\tdefaultSetting: 'color.defaultPalette',\n\t} );\n\tconst disableCustomColors = ! useSetting( 'color.custom' );\n\tconst disableCustomDuotone =\n\t\t! useSetting( 'color.customDuotone' ) ||\n\t\t( colorPalette?.length === 0 && disableCustomColors );\n\n\tif ( duotonePalette?.length === 0 && disableCustomDuotone ) {\n\t\treturn null;\n\t}\n\n\tconst duotonePresetOrColors = ! Array.isArray( duotoneStyle )\n\t\t? getColorsFromDuotonePreset( duotoneStyle, duotonePalette )\n\t\t: duotoneStyle;\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls group=\"filter\">\n\t\t\t\t<StylesFiltersPanel\n\t\t\t\t\tvalue={ { filter: { duotone: duotonePresetOrColors } } }\n\t\t\t\t\tonChange={ ( newDuotone ) => {\n\t\t\t\t\t\tconst newStyle = {\n\t\t\t\t\t\t\t...style,\n\t\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t\t...newDuotone?.filter,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\tsetAttributes( { style: newStyle } );\n\t\t\t\t\t} }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t\t<DuotoneControl\n\t\t\t\t\tduotonePalette={ duotonePalette }\n\t\t\t\t\tcolorPalette={ colorPalette }\n\t\t\t\t\tdisableCustomDuotone={ disableCustomDuotone }\n\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\tvalue={ duotonePresetOrColors }\n\t\t\t\t\tonChange={ ( newDuotone ) => {\n\t\t\t\t\t\tconst maybePreset = getDuotonePresetFromColors(\n\t\t\t\t\t\t\tnewDuotone,\n\t\t\t\t\t\t\tduotonePalette\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst newStyle = {\n\t\t\t\t\t\t\t...style,\n\t\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t\t...style?.color,\n\t\t\t\t\t\t\t\tduotone: maybePreset ?? newDuotone, // use preset or fallback to custom colors.\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\tsetAttributes( { style: newStyle } );\n\t\t\t\t\t} }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t</>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * the `duotone` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addDuotoneAttributes( settings ) {\n\t// Previous `color.__experimentalDuotone` support flag is migrated via\n\t// block_type_metadata_settings filter in `lib/block-supports/duotone.php`.\n\tif ( ! hasBlockSupport( settings, 'filter.duotone' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default\n\t// values if needed.\n\tif ( ! settings.attributes.style ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tstyle: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include toolbar controls for duotone if the\n * block supports duotone.\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\t// Previous `color.__experimentalDuotone` support flag is migrated via\n\t\t// block_type_metadata_settings filter in `lib/block-supports/duotone.php`.\n\t\tconst hasDuotoneSupport = hasBlockSupport(\n\t\t\tprops.name,\n\t\t\t'filter.duotone'\n\t\t);\n\n\t\tconst blockEditingMode = useBlockEditingMode();\n\n\t\t// CAUTION: code added before this line will be executed\n\t\t// for all blocks, not just those that support duotone. Code added\n\t\t// above this line should be carefully evaluated for its impact on\n\t\t// performance.\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ hasDuotoneSupport && blockEditingMode === 'default' && (\n\t\t\t\t\t<DuotonePanel { ...props } />\n\t\t\t\t) }\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneControls'\n);\n\nfunction DuotoneStyles( {\n\tid: filterId,\n\tselector: duotoneSelector,\n\tattribute: duotoneAttr,\n} ) {\n\tconst duotonePalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.duotone',\n\t\tdefaultSetting: 'color.defaultDuotone',\n\t} );\n\n\t// Possible values for duotone attribute:\n\t// 1. Array of colors - e.g. ['#000000', '#ffffff'].\n\t// 2. Variable for an existing Duotone preset - e.g. 'var:preset|duotone|green-blue' or 'var(--wp--preset--duotone--green-blue)''\n\t// 3. A CSS string - e.g. 'unset' to remove globally applied duotone.\n\tconst isCustom = Array.isArray( duotoneAttr );\n\tconst duotonePreset = isCustom\n\t\t? undefined\n\t\t: getColorsFromDuotonePreset( duotoneAttr, duotonePalette );\n\tconst isPreset = typeof duotoneAttr === 'string' && duotonePreset;\n\tconst isCSS = typeof duotoneAttr === 'string' && ! isPreset;\n\n\t// Match the structure of WP_Duotone_Gutenberg::render_duotone_support() in PHP.\n\tlet colors = null;\n\tif ( isPreset ) {\n\t\t// Array of colors.\n\t\tcolors = duotonePreset;\n\t} else if ( isCSS ) {\n\t\t// CSS filter property string (e.g. 'unset').\n\t\tcolors = duotoneAttr;\n\t} else if ( isCustom ) {\n\t\t// Array of colors.\n\t\tcolors = duotoneAttr;\n\t}\n\n\t// Build the CSS selectors to which the filter will be applied.\n\tconst selectors = duotoneSelector.split( ',' );\n\n\tconst selectorsScoped = selectors.map( ( selectorPart ) => {\n\t\t// Extra .editor-styles-wrapper specificity is needed in the editor\n\t\t// since we're not using inline styles to apply the filter. We need to\n\t\t// override duotone applied by global styles and theme.json.\n\n\t\t// Assuming the selector part is a subclass selector (not a tag name)\n\t\t// so we can prepend the filter id class. If we want to support elements\n\t\t// such as `img` or namespaces, we'll need to add a case for that here.\n\t\treturn `.${ filterId }${ selectorPart.trim() }`;\n\t} );\n\n\tconst selector = selectorsScoped.join( ', ' );\n\n\tconst isValidFilter = Array.isArray( colors ) || colors === 'unset';\n\n\tconst { setStyleOverride, deleteStyleOverride } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\n\tuseEffect( () => {\n\t\tif ( ! isValidFilter ) return;\n\n\t\tsetStyleOverride( filterId, {\n\t\t\tcss:\n\t\t\t\tcolors !== 'unset'\n\t\t\t\t\t? getDuotoneStylesheet( selector, filterId )\n\t\t\t\t\t: getDuotoneUnsetStylesheet( selector ),\n\t\t\t__unstableType: 'presets',\n\t\t} );\n\t\tsetStyleOverride( `duotone-${ filterId }`, {\n\t\t\tassets:\n\t\t\t\tcolors !== 'unset' ? getDuotoneFilter( filterId, colors ) : '',\n\t\t\t__unstableType: 'svgs',\n\t\t} );\n\n\t\treturn () => {\n\t\t\tdeleteStyleOverride( filterId );\n\t\t\tdeleteStyleOverride( `duotone-${ filterId }` );\n\t\t};\n\t}, [\n\t\tisValidFilter,\n\t\tcolors,\n\t\tselector,\n\t\tfilterId,\n\t\tsetStyleOverride,\n\t\tdeleteStyleOverride,\n\t] );\n\n\treturn null;\n}\n\n/**\n * Override the default block element to include duotone styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst id = useInstanceId( BlockListBlock );\n\n\t\tconst selector = useMemo( () => {\n\t\t\tconst blockType = getBlockType( props.name );\n\n\t\t\tif ( blockType ) {\n\t\t\t\t// Backwards compatibility for `supports.color.__experimentalDuotone`\n\t\t\t\t// is provided via the `block_type_metadata_settings` filter. If\n\t\t\t\t// `supports.filter.duotone` has not been set and the\n\t\t\t\t// experimental property has been, the experimental property\n\t\t\t\t// value is copied into `supports.filter.duotone`.\n\t\t\t\tconst duotoneSupport = getBlockSupport(\n\t\t\t\t\tblockType,\n\t\t\t\t\t'filter.duotone',\n\t\t\t\t\tfalse\n\t\t\t\t);\n\t\t\t\tif ( ! duotoneSupport ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\t// If the experimental duotone support was set, that value is\n\t\t\t\t// to be treated as a selector and requires scoping.\n\t\t\t\tconst experimentalDuotone = getBlockSupport(\n\t\t\t\t\tblockType,\n\t\t\t\t\t'color.__experimentalDuotone',\n\t\t\t\t\tfalse\n\t\t\t\t);\n\t\t\t\tif ( experimentalDuotone ) {\n\t\t\t\t\tconst rootSelector = getBlockCSSSelector( blockType );\n\t\t\t\t\treturn typeof experimentalDuotone === 'string'\n\t\t\t\t\t\t? scopeSelector( rootSelector, experimentalDuotone )\n\t\t\t\t\t\t: rootSelector;\n\t\t\t\t}\n\n\t\t\t\t// Regular filter.duotone support uses filter.duotone selectors with fallbacks.\n\t\t\t\treturn getBlockCSSSelector( blockType, 'filter.duotone', {\n\t\t\t\t\tfallback: true,\n\t\t\t\t} );\n\t\t\t}\n\t\t}, [ props.name ] );\n\n\t\tconst attribute = props?.attributes?.style?.color?.duotone;\n\n\t\tconst filterClass = `wp-duotone-${ id }`;\n\n\t\tconst shouldRender = selector && attribute;\n\n\t\tconst className = shouldRender\n\t\t\t? classnames( props?.className, filterClass )\n\t\t\t: props?.className;\n\n\t\t// CAUTION: code added before this line will be executed\n\t\t// for all blocks, not just those that support duotone. Code added\n\t\t// above this line should be carefully evaluated for its impact on\n\t\t// performance.\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ shouldRender && (\n\t\t\t\t\t<DuotoneStyles\n\t\t\t\t\t\tid={ filterClass }\n\t\t\t\t\t\tselector={ selector }\n\t\t\t\t\t\tattribute={ attribute }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<BlockListBlock { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/duotone/add-attributes',\n\taddDuotoneAttributes\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/duotone/with-editor-controls',\n\twithDuotoneControls\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/duotone/with-styles',\n\twithDuotoneStyles\n);\n"],"mappings":";;;;;;;;AAiBA,IAAAA,QAAA,GAAAC,OAAA;AAdA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAF,sBAAA,CAAAF,OAAA;AAKA,IAAAK,OAAA,GAAAL,OAAA;AAKA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAEA,IAAAQ,KAAA,GAAAR,OAAA;AAKA,IAAAS,WAAA,GAAAT,OAAA;AAMA,IAAAU,MAAA,GAAAV,OAAA;AAKA,IAAAW,oBAAA,GAAAX,OAAA;AACA,IAAAY,OAAA,GAAAZ,OAAA;AACA,IAAAa,OAAA,GAAAb,OAAA;AACA,IAAAc,aAAA,GAAAZ,sBAAA,CAAAF,OAAA;AACA,IAAAe,iBAAA,GAAAf,OAAA;AACA,IAAAgB,MAAA,GAAAhB,OAAA;AACA,IAAAiB,WAAA,GAAAjB,OAAA;AAxCA;AACA;AACA;;AAKA;AACA;AACA;;AAWA;AACA;AACA;;AAoBA,MAAMkB,WAAW,GAAG,EAAE;AAEtB,IAAAC,cAAM,EAAE,CAAEC,cAAW,CAAG,CAAC;AAEzB,SAASC,qBAAqBA,CAAE;EAAEC,aAAa;EAAEC;AAAe,CAAC,EAAG;EACnE,MAAMC,cAAc,GAAG,CAAE,IAAAC,sBAAU,EAAEF,cAAe,CAAC;EACrD,MAAMG,WAAW,GAChB,IAAAD,sBAAU,EAAG,GAAGH,aAAe,SAAS,CAAC,IAAIJ,WAAW;EACzD,MAAMS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AAEnC,UAAU,EAAEG,KAAK,EAAEE,KAAK,EAAEpB,OAAO;EAE1D,MAAMgG,WAAW,GAAI,cAAczC,EAAI,EAAC;EAExC,MAAM0C,YAAY,GAAGxC,QAAQ,IAAIE,SAAS;EAE1C,MAAMuC,SAAS,GAAGD,YAAY,GAC3B,IAAAE,mBAAU,EAAEjD,KAAK,EAAEgD,SAAS,EAAEF,WAAY,CAAC,GAC3C9C,KAAK,EAAEgD,SAAS;;EAEnB;EACA;EACA;EACA;EACA,OACC,IAAAlI,QAAA,CAAA4D,aAAA,EAAA5D,QAAA,CAAA6D,QAAA,QACGoE,YAAY,IACb,IAAAjI,QAAA,CAAA4D,aAAA,EAAC0B,aAAa;IACbC,EAAE,EAAGyC,WAAa;IAClBvC,QAAQ,EAAGA,QAAU;IACrBE,SAAS,EAAGA;EAAW,CACvB,CACD,EACD,IAAA3F,QAAA,CAAA4D,aAAA,EAACyD,cAAc;IAAA,GAAMnC,KAAK;IAAGgD,SAAS,EAAGA;EAAW,CAAE,CACrD,CAAC;AAEL,CAAC,EACD,mBACD,CAAC;AAED,IAAAE,gBAAS,EACR,0BAA0B,EAC1B,oCAAoC,EACpC1D,oBACD,CAAC;AACD,IAAA0D,gBAAS,EACR,kBAAkB,EAClB,0CAA0C,EAC1CrD,mBACD,CAAC;AACD,IAAAqD,gBAAS,EACR,uBAAuB,EACvB,iCAAiC,EACjChB,iBACD,CAAC"}
1
+ {"version":3,"names":["_element","require","_classnames","_interopRequireDefault","_colord","_names","_blocks","_compose","_hooks","_data","_components","_utils","_getBlockCssSelector","_utils2","_utils3","_filtersPanel","_blockEditingMode","_useBlockRefs","_store","_lockUnlock","EMPTY_ARRAY","isSafari","window","navigator","userAgent","includes","extend","namesPlugin","useMultiOriginPresets","presetSetting","defaultSetting","disableDefault","useSetting","userPresets","themePresets","defaultPresets","useMemo","getColorsFromDuotonePreset","duotone","duotonePalette","preset","find","slug","colors","undefined","getDuotonePresetFromColors","Array","isArray","duotonePreset","every","val","index","DuotonePanel","attributes","setAttributes","name","style","duotoneStyle","color","settings","useBlockSettings","colorPalette","disableCustomColors","disableCustomDuotone","length","duotonePresetOrColors","createElement","Fragment","InspectorControls","group","default","value","filter","onChange","newDuotone","newStyle","BlockControls","__experimentalShareWithChildBlocks","__experimentalDuotoneControl","maybePreset","addDuotoneAttributes","hasBlockSupport","Object","assign","type","withDuotoneControls","createHigherOrderComponent","BlockEdit","props","hasDuotoneSupport","blockEditingMode","useBlockEditingMode","DuotoneStyles","clientId","id","filterId","selector","duotoneSelector","attribute","duotoneAttr","isCustom","isPreset","isCSS","selectors","split","selectorsScoped","map","selectorPart","trim","join","isValidFilter","setStyleOverride","deleteStyleOverride","unlock","useDispatch","blockEditorStore","blockElement","useBlockElement","useEffect","css","getDuotoneStylesheet","getDuotoneUnsetStylesheet","__unstableType","assets","getDuotoneFilter","display","offsetHeight","withDuotoneStyles","BlockListBlock","useInstanceId","blockType","getBlockType","duotoneSupport","getBlockSupport","experimentalDuotone","rootSelector","getBlockCSSSelector","scopeSelector","fallback","filterClass","shouldRender","className","classnames","addFilter"],"sources":["@wordpress/block-editor/src/hooks/duotone.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tgetBlockSupport,\n\tgetBlockType,\n\thasBlockSupport,\n} from '@wordpress/blocks';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { useMemo, useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBlockControls,\n\tInspectorControls,\n\t__experimentalDuotoneControl as DuotoneControl,\n\tuseSetting,\n} from '../components';\nimport {\n\tgetDuotoneFilter,\n\tgetDuotoneStylesheet,\n\tgetDuotoneUnsetStylesheet,\n} from '../components/duotone/utils';\nimport { getBlockCSSSelector } from '../components/global-styles/get-block-css-selector';\nimport { scopeSelector } from '../components/global-styles/utils';\nimport { useBlockSettings } from './utils';\nimport { default as StylesFiltersPanel } from '../components/global-styles/filters-panel';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\nimport { __unstableUseBlockElement as useBlockElement } from '../components/block-list/use-block-props/use-block-refs';\nimport { store as blockEditorStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\nconst EMPTY_ARRAY = [];\n\n// Safari does not always update the duotone filter when the duotone colors\n// are changed. This browser check is later used to force a re-render of the block\n// element to ensure the duotone filter is updated. The check is included at the\n// root of this file as it only needs to be run once per page load.\nconst isSafari =\n\twindow?.navigator.userAgent &&\n\twindow.navigator.userAgent.includes( 'Safari' ) &&\n\t! window.navigator.userAgent.includes( 'Chrome' ) &&\n\t! window.navigator.userAgent.includes( 'Chromium' );\n\nextend( [ namesPlugin ] );\n\nfunction useMultiOriginPresets( { presetSetting, defaultSetting } ) {\n\tconst disableDefault = ! useSetting( defaultSetting );\n\tconst userPresets =\n\t\tuseSetting( `${ presetSetting }.custom` ) || EMPTY_ARRAY;\n\tconst themePresets =\n\t\tuseSetting( `${ presetSetting }.theme` ) || EMPTY_ARRAY;\n\tconst defaultPresets =\n\t\tuseSetting( `${ presetSetting }.default` ) || EMPTY_ARRAY;\n\treturn useMemo(\n\t\t() => [\n\t\t\t...userPresets,\n\t\t\t...themePresets,\n\t\t\t...( disableDefault ? EMPTY_ARRAY : defaultPresets ),\n\t\t],\n\t\t[ disableDefault, userPresets, themePresets, defaultPresets ]\n\t);\n}\n\nexport function getColorsFromDuotonePreset( duotone, duotonePalette ) {\n\tif ( ! duotone ) {\n\t\treturn;\n\t}\n\tconst preset = duotonePalette?.find( ( { slug } ) => {\n\t\treturn duotone === `var:preset|duotone|${ slug }`;\n\t} );\n\n\treturn preset ? preset.colors : undefined;\n}\n\nexport function getDuotonePresetFromColors( colors, duotonePalette ) {\n\tif ( ! colors || ! Array.isArray( colors ) ) {\n\t\treturn;\n\t}\n\n\tconst preset = duotonePalette?.find( ( duotonePreset ) => {\n\t\treturn duotonePreset?.colors?.every(\n\t\t\t( val, index ) => val === colors[ index ]\n\t\t);\n\t} );\n\n\treturn preset ? `var:preset|duotone|${ preset.slug }` : undefined;\n}\n\nfunction DuotonePanel( { attributes, setAttributes, name } ) {\n\tconst style = attributes?.style;\n\tconst duotoneStyle = style?.color?.duotone;\n\tconst settings = useBlockSettings( name );\n\n\tconst duotonePalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.duotone',\n\t\tdefaultSetting: 'color.defaultDuotone',\n\t} );\n\tconst colorPalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.palette',\n\t\tdefaultSetting: 'color.defaultPalette',\n\t} );\n\tconst disableCustomColors = ! useSetting( 'color.custom' );\n\tconst disableCustomDuotone =\n\t\t! useSetting( 'color.customDuotone' ) ||\n\t\t( colorPalette?.length === 0 && disableCustomColors );\n\n\tif ( duotonePalette?.length === 0 && disableCustomDuotone ) {\n\t\treturn null;\n\t}\n\n\tconst duotonePresetOrColors = ! Array.isArray( duotoneStyle )\n\t\t? getColorsFromDuotonePreset( duotoneStyle, duotonePalette )\n\t\t: duotoneStyle;\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls group=\"filter\">\n\t\t\t\t<StylesFiltersPanel\n\t\t\t\t\tvalue={ { filter: { duotone: duotonePresetOrColors } } }\n\t\t\t\t\tonChange={ ( newDuotone ) => {\n\t\t\t\t\t\tconst newStyle = {\n\t\t\t\t\t\t\t...style,\n\t\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t\t...newDuotone?.filter,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\tsetAttributes( { style: newStyle } );\n\t\t\t\t\t} }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t\t<DuotoneControl\n\t\t\t\t\tduotonePalette={ duotonePalette }\n\t\t\t\t\tcolorPalette={ colorPalette }\n\t\t\t\t\tdisableCustomDuotone={ disableCustomDuotone }\n\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\tvalue={ duotonePresetOrColors }\n\t\t\t\t\tonChange={ ( newDuotone ) => {\n\t\t\t\t\t\tconst maybePreset = getDuotonePresetFromColors(\n\t\t\t\t\t\t\tnewDuotone,\n\t\t\t\t\t\t\tduotonePalette\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst newStyle = {\n\t\t\t\t\t\t\t...style,\n\t\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t\t...style?.color,\n\t\t\t\t\t\t\t\tduotone: maybePreset ?? newDuotone, // use preset or fallback to custom colors.\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\tsetAttributes( { style: newStyle } );\n\t\t\t\t\t} }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t</>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * the `duotone` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addDuotoneAttributes( settings ) {\n\t// Previous `color.__experimentalDuotone` support flag is migrated via\n\t// block_type_metadata_settings filter in `lib/block-supports/duotone.php`.\n\tif ( ! hasBlockSupport( settings, 'filter.duotone' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default\n\t// values if needed.\n\tif ( ! settings.attributes.style ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tstyle: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include toolbar controls for duotone if the\n * block supports duotone.\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\t// Previous `color.__experimentalDuotone` support flag is migrated via\n\t\t// block_type_metadata_settings filter in `lib/block-supports/duotone.php`.\n\t\tconst hasDuotoneSupport = hasBlockSupport(\n\t\t\tprops.name,\n\t\t\t'filter.duotone'\n\t\t);\n\n\t\tconst blockEditingMode = useBlockEditingMode();\n\n\t\t// CAUTION: code added before this line will be executed\n\t\t// for all blocks, not just those that support duotone. Code added\n\t\t// above this line should be carefully evaluated for its impact on\n\t\t// performance.\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ hasDuotoneSupport && blockEditingMode === 'default' && (\n\t\t\t\t\t<DuotonePanel { ...props } />\n\t\t\t\t) }\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneControls'\n);\n\nfunction DuotoneStyles( {\n\tclientId,\n\tid: filterId,\n\tselector: duotoneSelector,\n\tattribute: duotoneAttr,\n} ) {\n\tconst duotonePalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.duotone',\n\t\tdefaultSetting: 'color.defaultDuotone',\n\t} );\n\n\t// Possible values for duotone attribute:\n\t// 1. Array of colors - e.g. ['#000000', '#ffffff'].\n\t// 2. Variable for an existing Duotone preset - e.g. 'var:preset|duotone|green-blue' or 'var(--wp--preset--duotone--green-blue)''\n\t// 3. A CSS string - e.g. 'unset' to remove globally applied duotone.\n\tconst isCustom = Array.isArray( duotoneAttr );\n\tconst duotonePreset = isCustom\n\t\t? undefined\n\t\t: getColorsFromDuotonePreset( duotoneAttr, duotonePalette );\n\tconst isPreset = typeof duotoneAttr === 'string' && duotonePreset;\n\tconst isCSS = typeof duotoneAttr === 'string' && ! isPreset;\n\n\t// Match the structure of WP_Duotone_Gutenberg::render_duotone_support() in PHP.\n\tlet colors = null;\n\tif ( isPreset ) {\n\t\t// Array of colors.\n\t\tcolors = duotonePreset;\n\t} else if ( isCSS ) {\n\t\t// CSS filter property string (e.g. 'unset').\n\t\tcolors = duotoneAttr;\n\t} else if ( isCustom ) {\n\t\t// Array of colors.\n\t\tcolors = duotoneAttr;\n\t}\n\n\t// Build the CSS selectors to which the filter will be applied.\n\tconst selectors = duotoneSelector.split( ',' );\n\n\tconst selectorsScoped = selectors.map( ( selectorPart ) => {\n\t\t// Extra .editor-styles-wrapper specificity is needed in the editor\n\t\t// since we're not using inline styles to apply the filter. We need to\n\t\t// override duotone applied by global styles and theme.json.\n\n\t\t// Assuming the selector part is a subclass selector (not a tag name)\n\t\t// so we can prepend the filter id class. If we want to support elements\n\t\t// such as `img` or namespaces, we'll need to add a case for that here.\n\t\treturn `.${ filterId }${ selectorPart.trim() }`;\n\t} );\n\n\tconst selector = selectorsScoped.join( ', ' );\n\n\tconst isValidFilter = Array.isArray( colors ) || colors === 'unset';\n\n\tconst { setStyleOverride, deleteStyleOverride } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\n\tconst blockElement = useBlockElement( clientId );\n\n\tuseEffect( () => {\n\t\tif ( ! isValidFilter ) return;\n\n\t\tsetStyleOverride( filterId, {\n\t\t\tcss:\n\t\t\t\tcolors !== 'unset'\n\t\t\t\t\t? getDuotoneStylesheet( selector, filterId )\n\t\t\t\t\t: getDuotoneUnsetStylesheet( selector ),\n\t\t\t__unstableType: 'presets',\n\t\t} );\n\t\tsetStyleOverride( `duotone-${ filterId }`, {\n\t\t\tassets:\n\t\t\t\tcolors !== 'unset' ? getDuotoneFilter( filterId, colors ) : '',\n\t\t\t__unstableType: 'svgs',\n\t\t} );\n\n\t\t// Safari does not always update the duotone filter when the duotone colors\n\t\t// are changed. When using Safari, force the block element to be repainted by\n\t\t// the browser to ensure any changes are reflected visually. This logic matches\n\t\t// that used on the site frontend in `block-supports/duotone.php`.\n\t\tif ( blockElement && isSafari ) {\n\t\t\tconst display = blockElement.style.display;\n\t\t\t// Switch to `inline-block` to force a repaint. In the editor, `inline-block`\n\t\t\t// is used instead of `none` to ensure that scroll position is not affected,\n\t\t\t// as `none` results in the editor scrolling to the top of the block.\n\t\t\tblockElement.style.display = 'inline-block';\n\t\t\t// Simply accessing el.offsetHeight flushes layout and style\n\t\t\t// changes in WebKit without having to wait for setTimeout.\n\t\t\t// eslint-disable-next-line no-unused-expressions\n\t\t\tblockElement.offsetHeight;\n\t\t\tblockElement.style.display = display;\n\t\t}\n\n\t\treturn () => {\n\t\t\tdeleteStyleOverride( filterId );\n\t\t\tdeleteStyleOverride( `duotone-${ filterId }` );\n\t\t};\n\t}, [\n\t\tisValidFilter,\n\t\tblockElement,\n\t\tcolors,\n\t\tselector,\n\t\tfilterId,\n\t\tsetStyleOverride,\n\t\tdeleteStyleOverride,\n\t] );\n\n\treturn null;\n}\n\n/**\n * Override the default block element to include duotone styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst id = useInstanceId( BlockListBlock );\n\n\t\tconst selector = useMemo( () => {\n\t\t\tconst blockType = getBlockType( props.name );\n\n\t\t\tif ( blockType ) {\n\t\t\t\t// Backwards compatibility for `supports.color.__experimentalDuotone`\n\t\t\t\t// is provided via the `block_type_metadata_settings` filter. If\n\t\t\t\t// `supports.filter.duotone` has not been set and the\n\t\t\t\t// experimental property has been, the experimental property\n\t\t\t\t// value is copied into `supports.filter.duotone`.\n\t\t\t\tconst duotoneSupport = getBlockSupport(\n\t\t\t\t\tblockType,\n\t\t\t\t\t'filter.duotone',\n\t\t\t\t\tfalse\n\t\t\t\t);\n\t\t\t\tif ( ! duotoneSupport ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\t// If the experimental duotone support was set, that value is\n\t\t\t\t// to be treated as a selector and requires scoping.\n\t\t\t\tconst experimentalDuotone = getBlockSupport(\n\t\t\t\t\tblockType,\n\t\t\t\t\t'color.__experimentalDuotone',\n\t\t\t\t\tfalse\n\t\t\t\t);\n\t\t\t\tif ( experimentalDuotone ) {\n\t\t\t\t\tconst rootSelector = getBlockCSSSelector( blockType );\n\t\t\t\t\treturn typeof experimentalDuotone === 'string'\n\t\t\t\t\t\t? scopeSelector( rootSelector, experimentalDuotone )\n\t\t\t\t\t\t: rootSelector;\n\t\t\t\t}\n\n\t\t\t\t// Regular filter.duotone support uses filter.duotone selectors with fallbacks.\n\t\t\t\treturn getBlockCSSSelector( blockType, 'filter.duotone', {\n\t\t\t\t\tfallback: true,\n\t\t\t\t} );\n\t\t\t}\n\t\t}, [ props.name ] );\n\n\t\tconst attribute = props?.attributes?.style?.color?.duotone;\n\n\t\tconst filterClass = `wp-duotone-${ id }`;\n\n\t\tconst shouldRender = selector && attribute;\n\n\t\tconst className = shouldRender\n\t\t\t? classnames( props?.className, filterClass )\n\t\t\t: props?.className;\n\n\t\t// CAUTION: code added before this line will be executed\n\t\t// for all blocks, not just those that support duotone. Code added\n\t\t// above this line should be carefully evaluated for its impact on\n\t\t// performance.\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ shouldRender && (\n\t\t\t\t\t<DuotoneStyles\n\t\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\t\tid={ filterClass }\n\t\t\t\t\t\tselector={ selector }\n\t\t\t\t\t\tattribute={ attribute }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<BlockListBlock { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/duotone/add-attributes',\n\taddDuotoneAttributes\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/duotone/with-editor-controls',\n\twithDuotoneControls\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/duotone/with-styles',\n\twithDuotoneStyles\n);\n"],"mappings":";;;;;;;;AAiBA,IAAAA,QAAA,GAAAC,OAAA;AAdA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAF,sBAAA,CAAAF,OAAA;AAKA,I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0, _compose.createHigherOrderComponent)(BlockListBlock
341
341
  } = (0, _lockUnlock.unlock)((0, _data.useDispatch)(_store.store));
342
342
  (0, _element.useEffect)(() => {
343
343
  if (!css) return;
344
- setStyleOverride(id, {
344
+ setStyleOverride(selector, {
345
345
  css
346
346
  });
347
347
  return () => {
348
- deleteStyleOverride(id);
348
+ deleteStyleOverride(selector);
349
349
  };
350
- }, [id, css, setStyleOverride, deleteStyleOverride]);
350
+ }, [selector, css, setStyleOverride, deleteStyleOverride]);
351
351
  return (0, _element.createElement)(BlockListBlock, {
352
352
  ...props,
353
353
  __unstableLayoutClassNames: layoutClassNames
@@ -408,13 +408,13 @@ const withChildLayoutStyles = (0, _compose.createHigherOrderComponent)(BlockList
408
408
  } = (0, _lockUnlock.unlock)((0, _data.useDispatch)(_store.store));
409
409
  (0, _element.useEffect)(() => {
410
410
  if (!css) return;
411
- setStyleOverride(id, {
411
+ setStyleOverride(selector, {
412
412
  css
413
413
  });
414
414
  return () => {
415
- deleteStyleOverride(id);
415
+ deleteStyleOverride(selector);
416
416
  };
417
- }, [id, css, setStyleOverride, deleteStyleOverride]);
417
+ }, [selector, css, setStyleOverride, deleteStyleOverride]);
418
418
  return (0, _element.createElement)(BlockListBlock, {
419
419
  ...props,
420
420
  className: className
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_classnames","_interopRequireDefault","_compose","_hooks","_blocks","_data","_components","_i18n","_store","_components2","_useSetting","_layouts","_blockEditingMode","_definitions","_object","_utils","_lockUnlock","layoutBlockSupportKey","hasLayoutBlockSupport","blockName","hasBlockSupport","useLayoutClasses","blockAttributes","rootPaddingAlignment","useSelect","select","getSettings","blockEditorStore","__experimentalFeatures","useRootPaddingAwareAlignments","layout","default","defaultBlockLayout","getBlockSupport","usedLayout","inherit","contentSize","wideSize","type","layoutClassnames","LAYOUT_DEFINITIONS","className","baseClassName","splitBlockName","split","fullBlockName","pop","join","compoundClassName","push","orientation","kebabCase","justifyContent","flexWrap","useLayoutStyles","selector","style","fullLayoutType","getLayoutType","blockGapSupport","useSetting","hasBlockGapSupport","css","getLayoutStyle","LayoutPanel","setAttributes","attributes","name","settings","useBlockSettings","allowEditing","allowEditingSetting","defaultThemeLayout","themeSupportsLayout","supportsLayout","blockEditingMode","useBlockEditingMode","layoutBlockSupport","allowSwitching","allowInheriting","showInheritToggle","layoutType","constrainedType","displayControlsForLegacyLayouts","hasContentSizeOrLegacySettings","onChangeType","newType","onChangeLayout","newLayout","createElement","Fragment","InspectorControls","PanelBody","title","__","ToggleControl","__nextHasNoMarginBottom","label","checked","onChange","help","LayoutTypeSwitcher","inspectorControls","toolBarControls","ButtonGroup","getLayoutTypes","map","Button","key","isPressed","onClick","addAttribute","_settings$attributes$","withInspectorControls","createHigherOrderComponent","BlockEdit","props","supportLayout","exports","withLayoutStyles","BlockListBlock","blockSupportsLayout","disableLayoutStyles","shouldRenderLayoutStyles","id","useInstanceId","layoutClasses","layoutClassNames","classnames","setStyleOverride","deleteStyleOverride","unlock","useDispatch","useEffect","__unstableLayoutClassNames","withChildLayoutStyles","selfStretch","flexSize","hasChildLayout","shouldRenderChildLayoutStyles","addFilter"],"sources":["@wordpress/block-editor/src/hooks/layout.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\tButtonGroup,\n\tToggleControl,\n\tPanelBody,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { InspectorControls } from '../components';\nimport useSetting from '../components/use-setting';\nimport { getLayoutType, getLayoutTypes } from '../layouts';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\nimport { LAYOUT_DEFINITIONS } from '../layouts/definitions';\nimport { kebabCase } from '../utils/object';\nimport { useBlockSettings } from './utils';\nimport { unlock } from '../lock-unlock';\n\nconst layoutBlockSupportKey = 'layout';\n\nfunction hasLayoutBlockSupport( blockName ) {\n\treturn (\n\t\thasBlockSupport( blockName, 'layout' ) ||\n\t\thasBlockSupport( blockName, '__experimentalLayout' )\n\t);\n}\n\n/**\n * Generates the utility classnames for the given block's layout attributes.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n *\n * @return { Array } Array of CSS classname strings.\n */\nexport function useLayoutClasses( blockAttributes = {}, blockName = '' ) {\n\tconst rootPaddingAlignment = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().__experimentalFeatures\n\t\t\t?.useRootPaddingAwareAlignments;\n\t}, [] );\n\tconst { layout } = blockAttributes;\n\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( blockName, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || defaultBlockLayout || {};\n\n\tconst layoutClassnames = [];\n\n\tif ( LAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className ) {\n\t\tconst baseClassName =\n\t\t\tLAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className;\n\t\tconst splitBlockName = blockName.split( '/' );\n\t\tconst fullBlockName =\n\t\t\tsplitBlockName[ 0 ] === 'core'\n\t\t\t\t? splitBlockName.pop()\n\t\t\t\t: splitBlockName.join( '-' );\n\t\tconst compoundClassName = `wp-block-${ fullBlockName }-${ baseClassName }`;\n\t\tlayoutClassnames.push( baseClassName, compoundClassName );\n\t}\n\n\tif (\n\t\t( usedLayout?.inherit ||\n\t\t\tusedLayout?.contentSize ||\n\t\t\tusedLayout?.type === 'constrained' ) &&\n\t\trootPaddingAlignment\n\t) {\n\t\tlayoutClassnames.push( 'has-global-padding' );\n\t}\n\n\tif ( usedLayout?.orientation ) {\n\t\tlayoutClassnames.push( `is-${ kebabCase( usedLayout.orientation ) }` );\n\t}\n\n\tif ( usedLayout?.justifyContent ) {\n\t\tlayoutClassnames.push(\n\t\t\t`is-content-justification-${ kebabCase(\n\t\t\t\tusedLayout.justifyContent\n\t\t\t) }`\n\t\t);\n\t}\n\n\tif ( usedLayout?.flexWrap && usedLayout.flexWrap === 'nowrap' ) {\n\t\tlayoutClassnames.push( 'is-nowrap' );\n\t}\n\n\treturn layoutClassnames;\n}\n\n/**\n * Generates a CSS rule with the given block's layout styles.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n * @param { string } selector A selector to use in generating the CSS rule.\n *\n * @return { string } CSS rule.\n */\nexport function useLayoutStyles( blockAttributes = {}, blockName, selector ) {\n\tconst { layout = {}, style = {} } = blockAttributes;\n\t// Update type for blocks using legacy layouts.\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || {};\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst blockGapSupport = useSetting( 'spacing.blockGap' );\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\tconst css = fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName,\n\t\tselector,\n\t\tlayout,\n\t\tstyle,\n\t\thasBlockGapSupport,\n\t} );\n\treturn css;\n}\n\nfunction LayoutPanel( { setAttributes, attributes, name: blockName } ) {\n\tconst settings = useBlockSettings( blockName );\n\tconst {\n\t\tlayout: { allowEditing: allowEditingSetting },\n\t} = settings;\n\n\tconst { layout } = attributes;\n\tconst defaultThemeLayout = useSetting( 'layout' );\n\tconst { themeSupportsLayout } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\tthemeSupportsLayout: getSettings().supportsLayout,\n\t\t};\n\t}, [] );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst layoutBlockSupport = getBlockSupport(\n\t\tblockName,\n\t\tlayoutBlockSupportKey,\n\t\t{}\n\t);\n\tconst {\n\t\tallowSwitching,\n\t\tallowEditing = allowEditingSetting ?? true,\n\t\tallowInheriting = true,\n\t\tdefault: defaultBlockLayout,\n\t} = layoutBlockSupport;\n\n\tif ( ! allowEditing ) {\n\t\treturn null;\n\t}\n\n\t// Only show the inherit toggle if it's supported,\n\t// a default theme layout is set (e.g. one that provides `contentSize` and/or `wideSize` values),\n\t// and either the default / flow or the constrained layout type is in use, as the toggle switches from one to the other.\n\tconst showInheritToggle = !! (\n\t\tallowInheriting &&\n\t\t!! defaultThemeLayout &&\n\t\t( ! layout?.type ||\n\t\t\tlayout?.type === 'default' ||\n\t\t\tlayout?.type === 'constrained' ||\n\t\t\tlayout?.inherit )\n\t);\n\n\tconst usedLayout = layout || defaultBlockLayout || {};\n\tconst {\n\t\tinherit = false,\n\t\ttype = 'default',\n\t\tcontentSize = null,\n\t} = usedLayout;\n\t/**\n\t * `themeSupportsLayout` is only relevant to the `default/flow` or\n\t * `constrained` layouts and it should not be taken into account when other\n\t * `layout` types are used.\n\t */\n\tif (\n\t\t( type === 'default' || type === 'constrained' ) &&\n\t\t! themeSupportsLayout\n\t) {\n\t\treturn null;\n\t}\n\tconst layoutType = getLayoutType( type );\n\tconst constrainedType = getLayoutType( 'constrained' );\n\tconst displayControlsForLegacyLayouts =\n\t\t! usedLayout.type && ( contentSize || inherit );\n\tconst hasContentSizeOrLegacySettings = !! inherit || !! contentSize;\n\n\tconst onChangeType = ( newType ) =>\n\t\tsetAttributes( { layout: { type: newType } } );\n\tconst onChangeLayout = ( newLayout ) =>\n\t\tsetAttributes( { layout: newLayout } );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Layout' ) }>\n\t\t\t\t\t{ showInheritToggle && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tclassName=\"block-editor-hooks__toggle-control\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Inner blocks use content width' ) }\n\t\t\t\t\t\t\t\tchecked={\n\t\t\t\t\t\t\t\t\tlayoutType?.name === 'constrained' ||\n\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t\t\t\t\ttype:\n\t\t\t\t\t\t\t\t\t\t\t\tlayoutType?.name ===\n\t\t\t\t\t\t\t\t\t\t\t\t\t'constrained' ||\n\t\t\t\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 'default'\n\t\t\t\t\t\t\t\t\t\t\t\t\t: 'constrained',\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\thelp={\n\t\t\t\t\t\t\t\t\tlayoutType?.name === 'constrained' ||\n\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks use content width with options for full and wide widths.'\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks will fill the width of this container. Toggle to constrain.'\n\t\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) }\n\n\t\t\t\t\t{ ! inherit && allowSwitching && (\n\t\t\t\t\t\t<LayoutTypeSwitcher\n\t\t\t\t\t\t\ttype={ type }\n\t\t\t\t\t\t\tonChange={ onChangeType }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ layoutType && layoutType.name !== 'default' && (\n\t\t\t\t\t\t<layoutType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ constrainedType && displayControlsForLegacyLayouts && (\n\t\t\t\t\t\t<constrainedType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t{ ! inherit && blockEditingMode === 'default' && layoutType && (\n\t\t\t\t<layoutType.toolBarControls\n\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction LayoutTypeSwitcher( { type, onChange } ) {\n\treturn (\n\t\t<ButtonGroup>\n\t\t\t{ getLayoutTypes().map( ( { name, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={ name }\n\t\t\t\t\t\tisPressed={ type === name }\n\t\t\t\t\t\tonClick={ () => onChange( name ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</Button>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ButtonGroup>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include `layout`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( 'type' in ( settings.attributes?.layout ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasLayoutBlockSupport( settings ) ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tlayout: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include layout controls\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withInspectorControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { name: blockName } = props;\n\t\tconst supportLayout = hasLayoutBlockSupport( blockName );\n\n\t\tconst blockEditingMode = useBlockEditingMode();\n\t\treturn [\n\t\t\tsupportLayout && blockEditingMode === 'default' && (\n\t\t\t\t<LayoutPanel key=\"layout\" { ...props } />\n\t\t\t),\n\t\t\t<BlockEdit key=\"edit\" { ...props } />,\n\t\t];\n\t},\n\t'withInspectorControls'\n);\n\n/**\n * Override the default block element to add the layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst blockSupportsLayout = hasLayoutBlockSupport( name );\n\t\tconst disableLayoutStyles = useSelect( ( select ) => {\n\t\t\tconst { getSettings } = select( blockEditorStore );\n\t\t\treturn !! getSettings().disableLayoutStyles;\n\t\t} );\n\t\tconst shouldRenderLayoutStyles =\n\t\t\tblockSupportsLayout && ! disableLayoutStyles;\n\t\tconst id = useInstanceId( BlockListBlock );\n\t\tconst { layout } = attributes;\n\t\tconst { default: defaultBlockLayout } =\n\t\t\tgetBlockSupport( name, layoutBlockSupportKey ) || {};\n\t\tconst usedLayout =\n\t\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t\t: layout || defaultBlockLayout || {};\n\t\tconst layoutClasses = blockSupportsLayout\n\t\t\t? useLayoutClasses( attributes, name )\n\t\t\t: null;\n\t\t// Higher specificity to override defaults from theme.json.\n\t\tconst selector = `.wp-container-${ id }.wp-container-${ id }`;\n\t\tconst blockGapSupport = useSetting( 'spacing.blockGap' );\n\t\tconst hasBlockGapSupport = blockGapSupport !== null;\n\n\t\t// Get CSS string for the current layout type.\n\t\t// The CSS and `style` element is only output if it is not empty.\n\t\tlet css;\n\t\tif ( shouldRenderLayoutStyles ) {\n\t\t\tconst fullLayoutType = getLayoutType(\n\t\t\t\tusedLayout?.type || 'default'\n\t\t\t);\n\t\t\tcss = fullLayoutType?.getLayoutStyle?.( {\n\t\t\t\tblockName: name,\n\t\t\t\tselector,\n\t\t\t\tlayout: usedLayout,\n\t\t\t\tstyle: attributes?.style,\n\t\t\t\thasBlockGapSupport,\n\t\t\t} );\n\t\t}\n\n\t\t// Attach a `wp-container-` id-based class name as well as a layout class name such as `is-layout-flex`.\n\t\tconst layoutClassNames = classnames(\n\t\t\t{\n\t\t\t\t[ `wp-container-${ id }` ]: shouldRenderLayoutStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t\t},\n\t\t\tlayoutClasses\n\t\t);\n\n\t\tconst { setStyleOverride, deleteStyleOverride } = unlock(\n\t\t\tuseDispatch( blockEditorStore )\n\t\t);\n\n\t\tuseEffect( () => {\n\t\t\tif ( ! css ) return;\n\t\t\tsetStyleOverride( id, { css } );\n\t\t\treturn () => {\n\t\t\t\tdeleteStyleOverride( id );\n\t\t\t};\n\t\t}, [ id, css, setStyleOverride, deleteStyleOverride ] );\n\n\t\treturn (\n\t\t\t<BlockListBlock\n\t\t\t\t{ ...props }\n\t\t\t\t__unstableLayoutClassNames={ layoutClassNames }\n\t\t\t/>\n\t\t);\n\t},\n\t'withLayoutStyles'\n);\n\n/**\n * Override the default block element to add the child layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withChildLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { attributes } = props;\n\t\tconst { style: { layout = {} } = {} } = attributes;\n\t\tconst { selfStretch, flexSize } = layout;\n\t\tconst hasChildLayout = selfStretch || flexSize;\n\t\tconst disableLayoutStyles = useSelect( ( select ) => {\n\t\t\tconst { getSettings } = select( blockEditorStore );\n\t\t\treturn !! getSettings().disableLayoutStyles;\n\t\t} );\n\t\tconst shouldRenderChildLayoutStyles =\n\t\t\thasChildLayout && ! disableLayoutStyles;\n\n\t\tconst id = useInstanceId( BlockListBlock );\n\t\tconst selector = `.wp-container-content-${ id }`;\n\n\t\tlet css = '';\n\n\t\tif ( selfStretch === 'fixed' && flexSize ) {\n\t\t\tcss += `${ selector } {\n\t\t\t\tflex-basis: ${ flexSize };\n\t\t\t\tbox-sizing: border-box;\n\t\t\t}`;\n\t\t} else if ( selfStretch === 'fill' ) {\n\t\t\tcss += `${ selector } {\n\t\t\t\tflex-grow: 1;\n\t\t\t}`;\n\t\t}\n\n\t\t// Attach a `wp-container-content` id-based classname.\n\t\tconst className = classnames( props?.className, {\n\t\t\t[ `wp-container-content-${ id }` ]:\n\t\t\t\tshouldRenderChildLayoutStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t} );\n\n\t\tconst { setStyleOverride, deleteStyleOverride } = unlock(\n\t\t\tuseDispatch( blockEditorStore )\n\t\t);\n\n\t\tuseEffect( () => {\n\t\t\tif ( ! css ) return;\n\t\t\tsetStyleOverride( id, { css } );\n\t\t\treturn () => {\n\t\t\t\tdeleteStyleOverride( id );\n\t\t\t};\n\t\t}, [ id, css, setStyleOverride, deleteStyleOverride ] );\n\n\t\treturn <BlockListBlock { ...props } className={ className } />;\n\t},\n\t'withChildLayoutStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/layout/addAttribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-layout-styles',\n\twithLayoutStyles\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-child-layout-styles',\n\twithChildL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AC/Be,6BAA6B,IAAI,CAAC,CAAE7E,GAAG,CAAE;EAC3C,CAAE,CAAC;;EAEH,MAAM;IAAEmE,gBAAgB;IAAEC;EAAoB,CAAC,GAAG,IAAAC,kBAAM,EACvD,IAAAC,iBAAW,EAAEzG,YAAiB,CAC/B,CAAC;EAED,IAAA0G,kBAAS,EAAE,MAAM;IAChB,IAAK,CAAEvE,GAAG,EAAG;IACbmE,gBAAgB,CAAEL,EAAE,EAAE;MAAE9D;IAAI,CAAE,CAAC;IAC/B,OAAO,MAAM;MACZoE,mBAAmB,CAAEN,EAAG,CAAC;IAC1B,CAAC;EACF,CAAC,EAAE,CAAEA,EAAE,EAAE9D,GAAG,EAAEmE,gBAAgB,EAAEC,mBAAmB,CAAG,CAAC;EAEvD,OAAO,IAAApI,QAAA,CAAA2F,aAAA,EAAC+B,cAAc;IAAA,GAAMJ,KAAK;IAAG3E,SAAS,EAAGA;EAAW,CAAE,CAAC;AAC/D,CAAC,EACD,uBACD,CAAC;AAAC6E,OAAA,CAAAiB,qBAAA,GAAAA,qBAAA;AAEF,IAAAK,gBAAS,EACR,0BAA0B,EAC1B,0BAA0B,EAC1B7B,YACD,CAAC;AACD,IAAA6B,gBAAS,EACR,uBAAuB,EACvB,uCAAuC,EACvCrB,gBACD,CAAC;AACD,IAAAqB,gBAAS,EACR,uBAAuB,EACvB,6CAA6C,EAC7CL,qBACD,CAAC;AACD,IAAAK,gBAAS,EACR,kBAAkB,EAClB,4CAA4C,EAC5C3B,qBACD,CAAC"}
1
+ {"version":3,"names":["_element","require","_classnames","_interopRequireDefault","_compose","_hooks","_blocks","_data","_components","_i18n","_store","_components2","_useSetting","_layouts","_blockEditingMode","_definitions","_object","_utils","_lockUnlock","layoutBlockSupportKey","hasLayoutBlockSupport","blockName","hasBlockSupport","useLayoutClasses","blockAttributes","rootPaddingAlignment","useSelect","select","getSettings","blockEditorStore","__experimentalFeatures","useRootPaddingAwareAlignments","layout","default","defaultBlockLayout","getBlockSupport","usedLayout","inherit","contentSize","wideSize","type","layoutClassnames","LAYOUT_DEFINITIONS","className","baseClassName","splitBlockName","split","fullBlockName","pop","join","compoundClassName","push","orientation","kebabCase","justifyContent","flexWrap","useLayoutStyles","selector","style","fullLayoutType","getLayoutType","blockGapSupport","useSetting","hasBlockGapSupport","css","getLayoutStyle","LayoutPanel","setAttributes","attributes","name","settings","useBlockSettings","allowEditing","allowEditingSetting","defaultThemeLayout","themeSupportsLayout","supportsLayout","blockEditingMode","useBlockEditingMode","layoutBlockSupport","allowSwitching","allowInheriting","showInheritToggle","layoutType","constrainedType","displayControlsForLegacyLayouts","hasContentSizeOrLegacySettings","onChangeType","newType","onChangeLayout","newLayout","createElement","Fragment","InspectorControls","PanelBody","title","__","ToggleControl","__nextHasNoMarginBottom","label","checked","onChange","help","LayoutTypeSwitcher","inspectorControls","toolBarControls","ButtonGroup","getLayoutTypes","map","Button","key","isPressed","onClick","addAttribute","_settings$attributes$","withInspectorControls","createHigherOrderComponent","BlockEdit","props","supportLayout","exports","withLayoutStyles","BlockListBlock","blockSupportsLayout","disableLayoutStyles","shouldRenderLayoutStyles","id","useInstanceId","layoutClasses","layoutClassNames","classnames","setStyleOverride","deleteStyleOverride","unlock","useDispatch","useEffect","__unstableLayoutClassNames","withChildLayoutStyles","selfStretch","flexSize","hasChildLayout","shouldRenderChildLayoutStyles","addFilter"],"sources":["@wordpress/block-editor/src/hooks/layout.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\tButtonGroup,\n\tToggleControl,\n\tPanelBody,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { InspectorControls } from '../components';\nimport useSetting from '../components/use-setting';\nimport { getLayoutType, getLayoutTypes } from '../layouts';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\nimport { LAYOUT_DEFINITIONS } from '../layouts/definitions';\nimport { kebabCase } from '../utils/object';\nimport { useBlockSettings } from './utils';\nimport { unlock } from '../lock-unlock';\n\nconst layoutBlockSupportKey = 'layout';\n\nfunction hasLayoutBlockSupport( blockName ) {\n\treturn (\n\t\thasBlockSupport( blockName, 'layout' ) ||\n\t\thasBlockSupport( blockName, '__experimentalLayout' )\n\t);\n}\n\n/**\n * Generates the utility classnames for the given block's layout attributes.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n *\n * @return { Array } Array of CSS classname strings.\n */\nexport function useLayoutClasses( blockAttributes = {}, blockName = '' ) {\n\tconst rootPaddingAlignment = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().__experimentalFeatures\n\t\t\t?.useRootPaddingAwareAlignments;\n\t}, [] );\n\tconst { layout } = blockAttributes;\n\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( blockName, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || defaultBlockLayout || {};\n\n\tconst layoutClassnames = [];\n\n\tif ( LAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className ) {\n\t\tconst baseClassName =\n\t\t\tLAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className;\n\t\tconst splitBlockName = blockName.split( '/' );\n\t\tconst fullBlockName =\n\t\t\tsplitBlockName[ 0 ] === 'core'\n\t\t\t\t? splitBlockName.pop()\n\t\t\t\t: splitBlockName.join( '-' );\n\t\tconst compoundClassName = `wp-block-${ fullBlockName }-${ baseClassName }`;\n\t\tlayoutClassnames.push( baseClassName, compoundClassName );\n\t}\n\n\tif (\n\t\t( usedLayout?.inherit ||\n\t\t\tusedLayout?.contentSize ||\n\t\t\tusedLayout?.type === 'constrained' ) &&\n\t\trootPaddingAlignment\n\t) {\n\t\tlayoutClassnames.push( 'has-global-padding' );\n\t}\n\n\tif ( usedLayout?.orientation ) {\n\t\tlayoutClassnames.push( `is-${ kebabCase( usedLayout.orientation ) }` );\n\t}\n\n\tif ( usedLayout?.justifyContent ) {\n\t\tlayoutClassnames.push(\n\t\t\t`is-content-justification-${ kebabCase(\n\t\t\t\tusedLayout.justifyContent\n\t\t\t) }`\n\t\t);\n\t}\n\n\tif ( usedLayout?.flexWrap && usedLayout.flexWrap === 'nowrap' ) {\n\t\tlayoutClassnames.push( 'is-nowrap' );\n\t}\n\n\treturn layoutClassnames;\n}\n\n/**\n * Generates a CSS rule with the given block's layout styles.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n * @param { string } selector A selector to use in generating the CSS rule.\n *\n * @return { string } CSS rule.\n */\nexport function useLayoutStyles( blockAttributes = {}, blockName, selector ) {\n\tconst { layout = {}, style = {} } = blockAttributes;\n\t// Update type for blocks using legacy layouts.\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || {};\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst blockGapSupport = useSetting( 'spacing.blockGap' );\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\tconst css = fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName,\n\t\tselector,\n\t\tlayout,\n\t\tstyle,\n\t\thasBlockGapSupport,\n\t} );\n\treturn css;\n}\n\nfunction LayoutPanel( { setAttributes, attributes, name: blockName } ) {\n\tconst settings = useBlockSettings( blockName );\n\tconst {\n\t\tlayout: { allowEditing: allowEditingSetting },\n\t} = settings;\n\n\tconst { layout } = attributes;\n\tconst defaultThemeLayout = useSetting( 'layout' );\n\tconst { themeSupportsLayout } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\tthemeSupportsLayout: getSettings().supportsLayout,\n\t\t};\n\t}, [] );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst layoutBlockSupport = getBlockSupport(\n\t\tblockName,\n\t\tlayoutBlockSupportKey,\n\t\t{}\n\t);\n\tconst {\n\t\tallowSwitching,\n\t\tallowEditing = allowEditingSetting ?? true,\n\t\tallowInheriting = true,\n\t\tdefault: defaultBlockLayout,\n\t} = layoutBlockSupport;\n\n\tif ( ! allowEditing ) {\n\t\treturn null;\n\t}\n\n\t// Only show the inherit toggle if it's supported,\n\t// a default theme layout is set (e.g. one that provides `contentSize` and/or `wideSize` values),\n\t// and either the default / flow or the constrained layout type is in use, as the toggle switches from one to the other.\n\tconst showInheritToggle = !! (\n\t\tallowInheriting &&\n\t\t!! defaultThemeLayout &&\n\t\t( ! layout?.type ||\n\t\t\tlayout?.type === 'default' ||\n\t\t\tlayout?.type === 'constrained' ||\n\t\t\tlayout?.inherit )\n\t);\n\n\tconst usedLayout = layout || defaultBlockLayout || {};\n\tconst {\n\t\tinherit = false,\n\t\ttype = 'default',\n\t\tcontentSize = null,\n\t} = usedLayout;\n\t/**\n\t * `themeSupportsLayout` is only relevant to the `default/flow` or\n\t * `constrained` layouts and it should not be taken into account when other\n\t * `layout` types are used.\n\t */\n\tif (\n\t\t( type === 'default' || type === 'constrained' ) &&\n\t\t! themeSupportsLayout\n\t) {\n\t\treturn null;\n\t}\n\tconst layoutType = getLayoutType( type );\n\tconst constrainedType = getLayoutType( 'constrained' );\n\tconst displayControlsForLegacyLayouts =\n\t\t! usedLayout.type && ( contentSize || inherit );\n\tconst hasContentSizeOrLegacySettings = !! inherit || !! contentSize;\n\n\tconst onChangeType = ( newType ) =>\n\t\tsetAttributes( { layout: { type: newType } } );\n\tconst onChangeLayout = ( newLayout ) =>\n\t\tsetAttributes( { layout: newLayout } );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Layout' ) }>\n\t\t\t\t\t{ showInheritToggle && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tclassName=\"block-editor-hooks__toggle-control\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Inner blocks use content width' ) }\n\t\t\t\t\t\t\t\tchecked={\n\t\t\t\t\t\t\t\t\tlayoutType?.name === 'constrained' ||\n\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t\t\t\t\ttype:\n\t\t\t\t\t\t\t\t\t\t\t\tlayoutType?.name ===\n\t\t\t\t\t\t\t\t\t\t\t\t\t'constrained' ||\n\t\t\t\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 'default'\n\t\t\t\t\t\t\t\t\t\t\t\t\t: 'constrained',\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\thelp={\n\t\t\t\t\t\t\t\t\tlayoutType?.name === 'constrained' ||\n\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks use content width with options for full and wide widths.'\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks will fill the width of this container. Toggle to constrain.'\n\t\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) }\n\n\t\t\t\t\t{ ! inherit && allowSwitching && (\n\t\t\t\t\t\t<LayoutTypeSwitcher\n\t\t\t\t\t\t\ttype={ type }\n\t\t\t\t\t\t\tonChange={ onChangeType }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ layoutType && layoutType.name !== 'default' && (\n\t\t\t\t\t\t<layoutType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ constrainedType && displayControlsForLegacyLayouts && (\n\t\t\t\t\t\t<constrainedType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t{ ! inherit && blockEditingMode === 'default' && layoutType && (\n\t\t\t\t<layoutType.toolBarControls\n\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction LayoutTypeSwitcher( { type, onChange } ) {\n\treturn (\n\t\t<ButtonGroup>\n\t\t\t{ getLayoutTypes().map( ( { name, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={ name }\n\t\t\t\t\t\tisPressed={ type === name }\n\t\t\t\t\t\tonClick={ () => onChange( name ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</Button>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ButtonGroup>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include `layout`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( 'type' in ( settings.attributes?.layout ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasLayoutBlockSupport( settings ) ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tlayout: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include layout controls\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withInspectorControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { name: blockName } = props;\n\t\tconst supportLayout = hasLayoutBlockSupport( blockName );\n\n\t\tconst blockEditingMode = useBlockEditingMode();\n\t\treturn [\n\t\t\tsupportLayout && blockEditingMode === 'default' && (\n\t\t\t\t<LayoutPanel key=\"layout\" { ...props } />\n\t\t\t),\n\t\t\t<BlockEdit key=\"edit\" { ...props } />,\n\t\t];\n\t},\n\t'withInspectorControls'\n);\n\n/**\n * Override the default block element to add the layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst blockSupportsLayout = hasLayoutBlockSupport( name );\n\t\tconst disableLayoutStyles = useSelect( ( select ) => {\n\t\t\tconst { getSettings } = select( blockEditorStore );\n\t\t\treturn !! getSettings().disableLayoutStyles;\n\t\t} );\n\t\tconst shouldRenderLayoutStyles =\n\t\t\tblockSupportsLayout && ! disableLayoutStyles;\n\t\tconst id = useInstanceId( BlockListBlock );\n\t\tconst { layout } = attributes;\n\t\tconst { default: defaultBlockLayout } =\n\t\t\tgetBlockSupport( name, layoutBlockSupportKey ) || {};\n\t\tconst usedLayout =\n\t\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t\t: layout || defaultBlockLayout || {};\n\t\tconst layoutClasses = blockSupportsLayout\n\t\t\t? useLayoutClasses( attributes, name )\n\t\t\t: null;\n\t\t// Higher specificity to override defaults from theme.json.\n\t\tconst selector = `.wp-container-${ id }.wp-container-${ id }`;\n\t\tconst blockGapSupport = useSetting( 'spacing.blockGap' );\n\t\tconst hasBlockGapSupport = blockGapSupport !== null;\n\n\t\t// Get CSS string for the current layout type.\n\t\t// The CSS and `style` element is only output if it is not empty.\n\t\tlet css;\n\t\tif ( shouldRenderLayoutStyles ) {\n\t\t\tconst fullLayoutType = getLayoutType(\n\t\t\t\tusedLayout?.type || 'default'\n\t\t\t);\n\t\t\tcss = fullLayoutType?.getLayoutStyle?.( {\n\t\t\t\tblockName: name,\n\t\t\t\tselector,\n\t\t\t\tlayout: usedLayout,\n\t\t\t\tstyle: attributes?.style,\n\t\t\t\thasBlockGapSupport,\n\t\t\t} );\n\t\t}\n\n\t\t// Attach a `wp-container-` id-based class name as well as a layout class name such as `is-layout-flex`.\n\t\tconst layoutClassNames = classnames(\n\t\t\t{\n\t\t\t\t[ `wp-container-${ id }` ]: shouldRenderLayoutStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t\t},\n\t\t\tlayoutClasses\n\t\t);\n\n\t\tconst { setStyleOverride, deleteStyleOverride } = unlock(\n\t\t\tuseDispatch( blockEditorStore )\n\t\t);\n\n\t\tuseEffect( () => {\n\t\t\tif ( ! css ) return;\n\t\t\tsetStyleOverride( selector, { css } );\n\t\t\treturn () => {\n\t\t\t\tdeleteStyleOverride( selector );\n\t\t\t};\n\t\t}, [ selector, css, setStyleOverride, deleteStyleOverride ] );\n\n\t\treturn (\n\t\t\t<BlockListBlock\n\t\t\t\t{ ...props }\n\t\t\t\t__unstableLayoutClassNames={ layoutClassNames }\n\t\t\t/>\n\t\t);\n\t},\n\t'withLayoutStyles'\n);\n\n/**\n * Override the default block element to add the child layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withChildLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { attributes } = props;\n\t\tconst { style: { layout = {} } = {} } = attributes;\n\t\tconst { selfStretch, flexSize } = layout;\n\t\tconst hasChildLayout = selfStretch || flexSize;\n\t\tconst disableLayoutStyles = useSelect( ( select ) => {\n\t\t\tconst { getSettings } = select( blockEditorStore );\n\t\t\treturn !! getSettings().disableLayoutStyles;\n\t\t} );\n\t\tconst shouldRenderChildLayoutStyles =\n\t\t\thasChildLayout && ! disableLayoutStyles;\n\n\t\tconst id = useInstanceId( BlockListBlock );\n\t\tconst selector = `.wp-container-content-${ id }`;\n\n\t\tlet css = '';\n\n\t\tif ( selfStretch === 'fixed' && flexSize ) {\n\t\t\tcss += `${ selector } {\n\t\t\t\tflex-basis: ${ flexSize };\n\t\t\t\tbox-sizing: border-box;\n\t\t\t}`;\n\t\t} else if ( selfStretch === 'fill' ) {\n\t\t\tcss += `${ selector } {\n\t\t\t\tflex-grow: 1;\n\t\t\t}`;\n\t\t}\n\n\t\t// Attach a `wp-container-content` id-based classname.\n\t\tconst className = classnames( props?.className, {\n\t\t\t[ `wp-container-content-${ id }` ]:\n\t\t\t\tshouldRenderChildLayoutStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t} );\n\n\t\tconst { setStyleOverride, deleteStyleOverride } = unlock(\n\t\t\tuseDispatch( blockEditorStore )\n\t\t);\n\n\t\tuseEffect( () => {\n\t\t\tif ( ! css ) return;\n\t\t\tsetStyleOverride( selector, { css } );\n\t\t\treturn () => {\n\t\t\t\tdeleteStyleOverride( selector );\n\t\t\t};\n\t\t}, [ selector, css, setStyleOverride, deleteStyleOverride ] );\n\n\t\treturn <BlockListBlock { ...props } className={ className } />;\n\t},\n\t'withChildLayoutStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/layout/addAttribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-layout-styles',\n\twithLayoutStyles\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-child-layout-styles',\n\twithChildLayoutStyles\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/layout/with-inspector-controls',\n\twithInspectorControls\n);\n"],"mappings":";;;;;;;;;;AAmBA,IAAAA,QAAA,GAAAC,OAAA;AAhBA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AAMA,IAAAQ,KAAA,GAAAR,OAAA;AAMA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,YAAA,GAAAV,OAAA;AACA,IAAAW,WAAA,GAAAT,sBAAA,CAAAF,OAAA;AACA,IAAAY,QAAA,GAAAZ,OAAA;AACA,IAAAa,iBAAA,GAAAb,OAAA;AACA,IAAAc,YAAA,GAAAd,OAAA;AACA,IAAAe,OAAA,GAAAf,OAAA;AACA,IAAAgB,MAAA,GAAAhB,OAAA;AACA,IAAAiB,WAAA,GAAAjB,OAAA;AAhCA;AACA;AACA;;AAGA;AACA;AACA;;AAcA;AACA;AACA;;AAWA,MAAMkB,qBAAqB,GAAG,QAAQ;AAEtC,SAASC,qBAAqBA,CAAEC,SAAS,EAAG;EAC3C,OACC,IAAAC,uBAAe,EAAED,SAAS,EAAE,QAAS,CAAC,IACtC,IAAAC,uBAAe,EAAED,SAAS,EAAE,sBAAuB,CAAC;AAEtD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,gBAAgBA,CAAEC,eAAe,GAAG,CAAC,CAAC,EAAEH,SAAS,GAAG,EAAE,EAAG;EACxE,MAAMI,oBAAoB,GAAG,IAAAC,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AU;AACxB;AACA,KAAK;EACH;;EAEA;EACA,MAAMd,SAAS,GAAG,IAAAuF,mBAAU,EAAEZ,KAAK,EAAE3E,SAAS,EAAE;IAC/C,CAAG,wBAAwBmF,EAAI,EAAC,GAC/Be,6BAA6B,IAAI,CAAC,CAAE7E,GAAG,CAAE;EAC3C,CAAE,CAAC;;EAEH,MAAM;IAAEmE,gBAAgB;IAAEC;EAAoB,CAAC,GAAG,IAAAC,kBAAM,EACvD,IAAAC,iBAAW,EAAEzG,YAAiB,CAC/B,CAAC;EAED,IAAA0G,kBAAS,EAAE,MAAM;IAChB,IAAK,CAAEvE,GAAG,EAAG;IACbmE,gBAAgB,CAAE1E,QAAQ,EAAE;MAAEO;IAAI,CAAE,CAAC;IACrC,OAAO,MAAM;MACZoE,mBAAmB,CAAE3E,QAAS,CAAC;IAChC,CAAC;EACF,CAAC,EAAE,CAAEA,QAAQ,EAAEO,GAAG,EAAEmE,gBAAgB,EAAEC,mBAAmB,CAAG,CAAC;EAE7D,OAAO,IAAApI,QAAA,CAAA2F,aAAA,EAAC+B,cAAc;IAAA,GAAMJ,KAAK;IAAG3E,SAAS,EAAGA;EAAW,CAAE,CAAC;AAC/D,CAAC,EACD,uBACD,CAAC;AAAC6E,OAAA,CAAAiB,qBAAA,GAAAA,qBAAA;AAEF,IAAAK,gBAAS,EACR,0BAA0B,EAC1B,0BAA0B,EAC1B7B,YACD,CAAC;AACD,IAAA6B,gBAAS,EACR,uBAAuB,EACvB,uCAAuC,EACvCrB,gBACD,CAAC;AACD,IAAAqB,gBAAS,EACR,uBAAuB,EACvB,6CAA6C,EAC7CL,qBACD,CAAC;AACD,IAAAK,gBAAS,EACR,kBAAkB,EAClB,4CAA4C,EAC5C3B,qBACD,CAAC"}
@@ -17,6 +17,7 @@ import deprecated from '@wordpress/deprecated';
17
17
  */
18
18
  import { ExperimentalBlockEditorProvider } from '../provider';
19
19
  import AutoHeightBlockPreview from './auto';
20
+ import EditorStyles from '../editor-styles';
20
21
  import { store as blockEditorStore } from '../../store';
21
22
  import { BlockListItems } from '../block-list';
22
23
  export function BlockPreview({
@@ -101,6 +102,8 @@ export function useBlockPreview({
101
102
  const originalSettings = useSelect(select => select(blockEditorStore).getSettings(), []);
102
103
  const settings = useMemo(() => ({
103
104
  ...originalSettings,
105
+ styles: undefined,
106
+ // Clear styles included by the parent settings, as they are already output by the parent's EditorStyles.
104
107
  __unstableIsPreviewMode: true
105
108
  }), [originalSettings]);
106
109
  const disabledRef = useDisabled();
@@ -109,7 +112,7 @@ export function useBlockPreview({
109
112
  const children = createElement(ExperimentalBlockEditorProvider, {
110
113
  value: renderedBlocks,
111
114
  settings: settings
112
- }, createElement(BlockListItems, {
115
+ }, createElement(EditorStyles, null), createElement(BlockListItems, {
113
116
  renderAppender: false,
114
117
  layout: layout
115
118
  }));
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","useDisabled","useMergeRefs","useSelect","memo","useMemo","deprecated","ExperimentalBlockEditorProvider","AutoHeightBlockPreview","store","blockEditorStore","BlockListItems","BlockPreview","blocks","viewportWidth","minHeight","additionalStyles","__experimentalMinHeight","__experimentalPadding","since","version","alternative","css","originalSettings","select","getSettings","settings","__unstableIsPreviewMode","renderedBlocks","Array","isArray","length","createElement","value","useBlockPreview","props","layout","disabledRef","ref","children","renderAppender","className"],"sources":["@wordpress/block-editor/src/components/block-preview/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useDisabled, useMergeRefs } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { memo, useMemo } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { ExperimentalBlockEditorProvider } from '../provider';\nimport AutoHeightBlockPreview from './auto';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockListItems } from '../block-list';\n\nexport function BlockPreview( {\n\tblocks,\n\tviewportWidth = 1200,\n\tminHeight,\n\tadditionalStyles = [],\n\t// Deprecated props:\n\t__experimentalMinHeight,\n\t__experimentalPadding,\n} ) {\n\tif ( __experimentalMinHeight ) {\n\t\tminHeight = __experimentalMinHeight;\n\t\tdeprecated( 'The __experimentalMinHeight prop', {\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t\talternative: 'minHeight',\n\t\t} );\n\t}\n\tif ( __experimentalPadding ) {\n\t\tadditionalStyles = [\n\t\t\t...additionalStyles,\n\t\t\t{ css: `body { padding: ${ __experimentalPadding }px; }` },\n\t\t];\n\t\tdeprecated( 'The __experimentalPadding prop of BlockPreview', {\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t\talternative: 'additionalStyles',\n\t\t} );\n\t}\n\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( { ...originalSettings, __unstableIsPreviewMode: true } ),\n\t\t[ originalSettings ]\n\t);\n\tconst renderedBlocks = useMemo(\n\t\t() => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),\n\t\t[ blocks ]\n\t);\n\n\tif ( ! blocks || blocks.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\tvalue={ renderedBlocks }\n\t\t\tsettings={ settings }\n\t\t>\n\t\t\t<AutoHeightBlockPreview\n\t\t\t\tviewportWidth={ viewportWidth }\n\t\t\t\tminHeight={ minHeight }\n\t\t\t\tadditionalStyles={ additionalStyles }\n\t\t\t/>\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n}\n\n/**\n * BlockPreview renders a preview of a block or array of blocks.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-preview/README.md\n *\n * @param {Object} preview options for how the preview should be shown\n * @param {Array|Object} preview.blocks A block instance (object) or an array of blocks to be previewed.\n * @param {number} preview.viewportWidth Width of the preview container in pixels. Controls at what size the blocks will be rendered inside the preview. Default: 700.\n *\n * @return {WPComponent} The component to be rendered.\n */\nexport default memo( BlockPreview );\n\n/**\n * This hook is used to lightly mark an element as a block preview wrapper\n * element. Call this hook and pass the returned props to the element to mark as\n * a block preview wrapper, automatically rendering inner blocks as children. If\n * you define a ref for the element, it is important to pass the ref to this\n * hook, which the hook in turn will pass to the component through the props it\n * returns. Optionally, you can also pass any other props through this hook, and\n * they will be merged and returned.\n *\n * @param {Object} options Preview options.\n * @param {WPBlock[]} options.blocks Block objects.\n * @param {Object} options.props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options.layout Layout settings to be used in the preview.\n */\nexport function useBlockPreview( { blocks, props = {}, layout } ) {\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( { ...originalSettings, __unstableIsPreviewMode: true } ),\n\t\t[ originalSettings ]\n\t);\n\tconst disabledRef = useDisabled();\n\tconst ref = useMergeRefs( [ props.ref, disabledRef ] );\n\tconst renderedBlocks = useMemo(\n\t\t() => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),\n\t\t[ blocks ]\n\t);\n\n\tconst children = (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\tvalue={ renderedBlocks }\n\t\t\tsettings={ settings }\n\t\t>\n\t\t\t<BlockListItems renderAppender={ false } layout={ layout } />\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n\n\treturn {\n\t\t...props,\n\t\tref,\n\t\tclassName: classnames(\n\t\t\tprops.className,\n\t\t\t'block-editor-block-preview__live-content',\n\t\t\t'components-disabled'\n\t\t),\n\t\tchildren: blocks?.length ? children : null,\n\t};\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,WAAW,EAAEC,YAAY,QAAQ,oBAAoB;AAC9D,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,IAAI,EAAEC,OAAO,QAA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GL,cAAgB;IACxBF,QAAQ,EAAGA;EAAU,GAErBM,aAAA,CAACrB,cAAc;IAAC6B,cAAc,EAAG,KAAO;IAACJ,MAAM,EAAGA;EAAQ,CAAE,CAC5B,CACjC;EAED,OAAO;IACN,GAAGD,KAAK;IACRG,GAAG;IACHG,SAAS,EAAEzC,UAAU,CACpBmC,KAAK,CAACM,SAAS,EACf,0CAA0C,EAC1C,qBACD,CAAC;IACDF,QAAQ,EAAE1B,MAAM,EAAEkB,MAAM,GAAGQ,QAAQ,GAAG;EACvC,CAAC;AACF"}
1
+ {"version":3,"names":["classnames","useDisabled","useMergeRefs","useSelect","memo","useMemo","deprecated","ExperimentalBlockEditorProvider","AutoHeightBlockPreview","EditorStyles","store","blockEditorStore","BlockListItems","BlockPreview","blocks","viewportWidth","minHeight","additionalStyles","__experimentalMinHeight","__experimentalPadding","since","version","alternative","css","originalSettings","select","getSettings","settings","__unstableIsPreviewMode","renderedBlocks","Array","isArray","length","createElement","value","useBlockPreview","props","layout","styles","undefined","disabledRef","ref","children","renderAppender","className"],"sources":["@wordpress/block-editor/src/components/block-preview/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useDisabled, useMergeRefs } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { memo, useMemo } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { ExperimentalBlockEditorProvider } from '../provider';\nimport AutoHeightBlockPreview from './auto';\nimport EditorStyles from '../editor-styles';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockListItems } from '../block-list';\n\nexport function BlockPreview( {\n\tblocks,\n\tviewportWidth = 1200,\n\tminHeight,\n\tadditionalStyles = [],\n\t// Deprecated props:\n\t__experimentalMinHeight,\n\t__experimentalPadding,\n} ) {\n\tif ( __experimentalMinHeight ) {\n\t\tminHeight = __experimentalMinHeight;\n\t\tdeprecated( 'The __experimentalMinHeight prop', {\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t\talternative: 'minHeight',\n\t\t} );\n\t}\n\tif ( __experimentalPadding ) {\n\t\tadditionalStyles = [\n\t\t\t...additionalStyles,\n\t\t\t{ css: `body { padding: ${ __experimentalPadding }px; }` },\n\t\t];\n\t\tdeprecated( 'The __experimentalPadding prop of BlockPreview', {\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t\talternative: 'additionalStyles',\n\t\t} );\n\t}\n\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( { ...originalSettings, __unstableIsPreviewMode: true } ),\n\t\t[ originalSettings ]\n\t);\n\tconst renderedBlocks = useMemo(\n\t\t() => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),\n\t\t[ blocks ]\n\t);\n\n\tif ( ! blocks || blocks.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\tvalue={ renderedBlocks }\n\t\t\tsettings={ settings }\n\t\t>\n\t\t\t<AutoHeightBlockPreview\n\t\t\t\tviewportWidth={ viewportWidth }\n\t\t\t\tminHeight={ minHeight }\n\t\t\t\tadditionalStyles={ additionalStyles }\n\t\t\t/>\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n}\n\n/**\n * BlockPreview renders a preview of a block or array of blocks.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-preview/README.md\n *\n * @param {Object} preview options for how the preview should be shown\n * @param {Array|Object} preview.blocks A block instance (object) or an array of blocks to be previewed.\n * @param {number} preview.viewportWidth Width of the preview container in pixels. Controls at what size the blocks will be rendered inside the preview. Default: 700.\n *\n * @return {WPComponent} The component to be rendered.\n */\nexport default memo( BlockPreview );\n\n/**\n * This hook is used to lightly mark an element as a block preview wrapper\n * element. Call this hook and pass the returned props to the element to mark as\n * a block preview wrapper, automatically rendering inner blocks as children. If\n * you define a ref for the element, it is important to pass the ref to this\n * hook, which the hook in turn will pass to the component through the props it\n * returns. Optionally, you can also pass any other props through this hook, and\n * they will be merged and returned.\n *\n * @param {Object} options Preview options.\n * @param {WPBlock[]} options.blocks Block objects.\n * @param {Object} options.props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options.layout Layout settings to be used in the preview.\n */\nexport function useBlockPreview( { blocks, props = {}, layout } ) {\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( {\n\t\t\t...originalSettings,\n\t\t\tstyles: undefined, // Clear styles included by the parent settings, as they are already output by the parent's EditorStyles.\n\t\t\t__unstableIsPreviewMode: true,\n\t\t} ),\n\t\t[ originalSettings ]\n\t);\n\tconst disabledRef = useDisabled();\n\tconst ref = useMergeRefs( [ props.ref, disabledRef ] );\n\tconst renderedBlocks = useMemo(\n\t\t() => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),\n\t\t[ blocks ]\n\t);\n\n\tconst children = (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\tvalue={ renderedBlocks }\n\t\t\tsettings={ settings }\n\t\t>\n\t\t\t<EditorStyles />\n\t\t\t<BlockListItems renderAppender={ false } layout={ layout } />\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n\n\treturn {\n\t\t...props,\n\t\tref,\n\t\tclassName: classnames(\n\t\t\tprops.className,\n\t\t\t'block-editor-block-preview__live-content',\n\t\t\t'components-disabled'\n\t\t),\n\t\tchildren: blocks?.length ? children : null,\n\t};\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,WAAW,EAAEC,YAAY,QAAQ,oBAAoB;AAC9D,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,IAAI,EAAEC,OAAO,QAAQ,oBAAoB;AAClD,OAAOC,UAAU,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CAAC1B,+BAA+B;IAC/B2B,KAAK,EAAGL,cAAgB;IACxBF,QAAQ,EAAGA;EAAU,GAErBM,aAAA,CAACxB,YAAY,MAAE,CAAC,EAChBwB,aAAA,CAACrB,cAAc;IAAC+B,cAAc,EAAG,KAAO;IAACN,MAAM,EAAGA;EAAQ,CAAE,CAC5B,CACjC;EAED,OAAO;IACN,GAAGD,KAAK;IACRK,GAAG;IACHG,SAAS,EAAE5C,UAAU,CACpBoC,KAAK,CAACQ,SAAS,EACf,0CAA0C,EAC1C,qBACD,CAAC;IACDF,QAAQ,EAAE5B,MAAM,EAAEkB,MAAM,GAAGU,QAAQ,GAAG;EACvC,CAAC;AACF"}
@@ -25,9 +25,16 @@ import { scopeSelector } from '../components/global-styles/utils';
25
25
  import { useBlockSettings } from './utils';
26
26
  import { default as StylesFiltersPanel } from '../components/global-styles/filters-panel';
27
27
  import { useBlockEditingMode } from '../components/block-editing-mode';
28
+ import { __unstableUseBlockElement as useBlockElement } from '../components/block-list/use-block-props/use-block-refs';
28
29
  import { store as blockEditorStore } from '../store';
29
30
  import { unlock } from '../lock-unlock';
30
31
  const EMPTY_ARRAY = [];
32
+
33
+ // Safari does not always update the duotone filter when the duotone colors
34
+ // are changed. This browser check is later used to force a re-render of the block
35
+ // element to ensure the duotone filter is updated. The check is included at the
36
+ // root of this file as it only needs to be run once per page load.
37
+ const isSafari = window?.navigator.userAgent && window.navigator.userAgent.includes('Safari') && !window.navigator.userAgent.includes('Chrome') && !window.navigator.userAgent.includes('Chromium');
31
38
  extend([namesPlugin]);
32
39
  function useMultiOriginPresets({
33
40
  presetSetting,
@@ -180,6 +187,7 @@ const withDuotoneControls = createHigherOrderComponent(BlockEdit => props => {
180
187
  }));
181
188
  }, 'withDuotoneControls');
182
189
  function DuotoneStyles({
190
+ clientId,
183
191
  id: filterId,
184
192
  selector: duotoneSelector,
185
193
  attribute: duotoneAttr
@@ -229,6 +237,7 @@ function DuotoneStyles({
229
237
  setStyleOverride,
230
238
  deleteStyleOverride
231
239
  } = unlock(useDispatch(blockEditorStore));
240
+ const blockElement = useBlockElement(clientId);
232
241
  useEffect(() => {
233
242
  if (!isValidFilter) return;
234
243
  setStyleOverride(filterId, {
@@ -239,11 +248,28 @@ function DuotoneStyles({
239
248
  assets: colors !== 'unset' ? getDuotoneFilter(filterId, colors) : '',
240
249
  __unstableType: 'svgs'
241
250
  });
251
+
252
+ // Safari does not always update the duotone filter when the duotone colors
253
+ // are changed. When using Safari, force the block element to be repainted by
254
+ // the browser to ensure any changes are reflected visually. This logic matches
255
+ // that used on the site frontend in `block-supports/duotone.php`.
256
+ if (blockElement && isSafari) {
257
+ const display = blockElement.style.display;
258
+ // Switch to `inline-block` to force a repaint. In the editor, `inline-block`
259
+ // is used instead of `none` to ensure that scroll position is not affected,
260
+ // as `none` results in the editor scrolling to the top of the block.
261
+ blockElement.style.display = 'inline-block';
262
+ // Simply accessing el.offsetHeight flushes layout and style
263
+ // changes in WebKit without having to wait for setTimeout.
264
+ // eslint-disable-next-line no-unused-expressions
265
+ blockElement.offsetHeight;
266
+ blockElement.style.display = display;
267
+ }
242
268
  return () => {
243
269
  deleteStyleOverride(filterId);
244
270
  deleteStyleOverride(`duotone-${filterId}`);
245
271
  };
246
- }, [isValidFilter, colors, selector, filterId, setStyleOverride, deleteStyleOverride]);
272
+ }, [isValidFilter, blockElement, colors, selector, filterId, setStyleOverride, deleteStyleOverride]);
247
273
  return null;
248
274
  }
249
275
 
@@ -293,6 +319,7 @@ const withDuotoneStyles = createHigherOrderComponent(BlockListBlock => props =>
293
319
  // above this line should be carefully evaluated for its impact on
294
320
  // performance.
295
321
  return createElement(Fragment, null, shouldRender && createElement(DuotoneStyles, {
322
+ clientId: props.clientId,
296
323
  id: filterClass,
297
324
  selector: selector,
298
325
  attribute: attribute
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","extend","namesPlugin","getBlockSupport","getBlockType","hasBlockSupport","createHigherOrderComponent","useInstanceId","addFilter","useMemo","useEffect","useDispatch","BlockControls","InspectorControls","__experimentalDuotoneControl","DuotoneControl","useSetting","getDuotoneFilter","getDuotoneStylesheet","getDuotoneUnsetStylesheet","getBlockCSSSelector","scopeSelector","useBlockSettings","default","StylesFiltersPanel","useBlockEditingMode","store","blockEditorStore","unlock","EMPTY_ARRAY","useMultiOriginPresets","presetSetting","defaultSetting","disableDefault","userPresets","themePresets","defaultPresets","getColorsFromDuotonePreset","duotone","duotonePalette","preset","find","slug","colors","undefined","getDuotonePresetFromColors","Array","isArray","duotonePreset","every","val","index","DuotonePanel","attributes","setAttributes","name","style","duotoneStyle","color","settings","colorPalette","disableCustomColors","disableCustomDuotone","length","duotonePresetOrColors","createElement","Fragment","group","value","filter","onChange","newDuotone","newStyle","__experimentalShareWithChildBlocks","maybePreset","addDuotoneAttributes","Object","assign","type","withDuotoneControls","BlockEdit","props","hasDuotoneSupport","blockEditingMode","DuotoneStyles","id","filterId","selector","duotoneSelector","attribute","duotoneAttr","isCustom","isPreset","isCSS","selectors","split","selectorsScoped","map","selectorPart","trim","join","isValidFilter","setStyleOverride","deleteStyleOverride","css","__unstableType","assets","withDuotoneStyles","BlockListBlock","blockType","duotoneSupport","experimentalDuotone","rootSelector","fallback","filterClass","shouldRender","className"],"sources":["@wordpress/block-editor/src/hooks/duotone.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tgetBlockSupport,\n\tgetBlockType,\n\thasBlockSupport,\n} from '@wordpress/blocks';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { useMemo, useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBlockControls,\n\tInspectorControls,\n\t__experimentalDuotoneControl as DuotoneControl,\n\tuseSetting,\n} from '../components';\nimport {\n\tgetDuotoneFilter,\n\tgetDuotoneStylesheet,\n\tgetDuotoneUnsetStylesheet,\n} from '../components/duotone/utils';\nimport { getBlockCSSSelector } from '../components/global-styles/get-block-css-selector';\nimport { scopeSelector } from '../components/global-styles/utils';\nimport { useBlockSettings } from './utils';\nimport { default as StylesFiltersPanel } from '../components/global-styles/filters-panel';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\nimport { store as blockEditorStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\nconst EMPTY_ARRAY = [];\n\nextend( [ namesPlugin ] );\n\nfunction useMultiOriginPresets( { presetSetting, defaultSetting } ) {\n\tconst disableDefault = ! useSetting( defaultSetting );\n\tconst userPresets =\n\t\tuseSetting( `${ presetSetting }.custom` ) || EMPTY_ARRAY;\n\tconst themePresets =\n\t\tuseSetting( `${ presetSetting }.theme` ) || EMPTY_ARRAY;\n\tconst defaultPresets =\n\t\tuseSetting( `${ presetSetting }.default` ) || EMPTY_ARRAY;\n\treturn useMemo(\n\t\t() => [\n\t\t\t...userPresets,\n\t\t\t...themePresets,\n\t\t\t...( disableDefault ? EMPTY_ARRAY : defaultPresets ),\n\t\t],\n\t\t[ disableDefault, userPresets, themePresets, defaultPresets ]\n\t);\n}\n\nexport function getColorsFromDuotonePreset( duotone, duotonePalette ) {\n\tif ( ! duotone ) {\n\t\treturn;\n\t}\n\tconst preset = duotonePalette?.find( ( { slug } ) => {\n\t\treturn duotone === `var:preset|duotone|${ slug }`;\n\t} );\n\n\treturn preset ? preset.colors : undefined;\n}\n\nexport function getDuotonePresetFromColors( colors, duotonePalette ) {\n\tif ( ! colors || ! Array.isArray( colors ) ) {\n\t\treturn;\n\t}\n\n\tconst preset = duotonePalette?.find( ( duotonePreset ) => {\n\t\treturn duotonePreset?.colors?.every(\n\t\t\t( val, index ) => val === colors[ index ]\n\t\t);\n\t} );\n\n\treturn preset ? `var:preset|duotone|${ preset.slug }` : undefined;\n}\n\nfunction DuotonePanel( { attributes, setAttributes, name } ) {\n\tconst style = attributes?.style;\n\tconst duotoneStyle = style?.color?.duotone;\n\tconst settings = useBlockSettings( name );\n\n\tconst duotonePalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.duotone',\n\t\tdefaultSetting: 'color.defaultDuotone',\n\t} );\n\tconst colorPalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.palette',\n\t\tdefaultSetting: 'color.defaultPalette',\n\t} );\n\tconst disableCustomColors = ! useSetting( 'color.custom' );\n\tconst disableCustomDuotone =\n\t\t! useSetting( 'color.customDuotone' ) ||\n\t\t( colorPalette?.length === 0 && disableCustomColors );\n\n\tif ( duotonePalette?.length === 0 && disableCustomDuotone ) {\n\t\treturn null;\n\t}\n\n\tconst duotonePresetOrColors = ! Array.isArray( duotoneStyle )\n\t\t? getColorsFromDuotonePreset( duotoneStyle, duotonePalette )\n\t\t: duotoneStyle;\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls group=\"filter\">\n\t\t\t\t<StylesFiltersPanel\n\t\t\t\t\tvalue={ { filter: { duotone: duotonePresetOrColors } } }\n\t\t\t\t\tonChange={ ( newDuotone ) => {\n\t\t\t\t\t\tconst newStyle = {\n\t\t\t\t\t\t\t...style,\n\t\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t\t...newDuotone?.filter,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\tsetAttributes( { style: newStyle } );\n\t\t\t\t\t} }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t\t<DuotoneControl\n\t\t\t\t\tduotonePalette={ duotonePalette }\n\t\t\t\t\tcolorPalette={ colorPalette }\n\t\t\t\t\tdisableCustomDuotone={ disableCustomDuotone }\n\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\tvalue={ duotonePresetOrColors }\n\t\t\t\t\tonChange={ ( newDuotone ) => {\n\t\t\t\t\t\tconst maybePreset = getDuotonePresetFromColors(\n\t\t\t\t\t\t\tnewDuotone,\n\t\t\t\t\t\t\tduotonePalette\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst newStyle = {\n\t\t\t\t\t\t\t...style,\n\t\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t\t...style?.color,\n\t\t\t\t\t\t\t\tduotone: maybePreset ?? newDuotone, // use preset or fallback to custom colors.\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\tsetAttributes( { style: newStyle } );\n\t\t\t\t\t} }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t</>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * the `duotone` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addDuotoneAttributes( settings ) {\n\t// Previous `color.__experimentalDuotone` support flag is migrated via\n\t// block_type_metadata_settings filter in `lib/block-supports/duotone.php`.\n\tif ( ! hasBlockSupport( settings, 'filter.duotone' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default\n\t// values if needed.\n\tif ( ! settings.attributes.style ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tstyle: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include toolbar controls for duotone if the\n * block supports duotone.\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\t// Previous `color.__experimentalDuotone` support flag is migrated via\n\t\t// block_type_metadata_settings filter in `lib/block-supports/duotone.php`.\n\t\tconst hasDuotoneSupport = hasBlockSupport(\n\t\t\tprops.name,\n\t\t\t'filter.duotone'\n\t\t);\n\n\t\tconst blockEditingMode = useBlockEditingMode();\n\n\t\t// CAUTION: code added before this line will be executed\n\t\t// for all blocks, not just those that support duotone. Code added\n\t\t// above this line should be carefully evaluated for its impact on\n\t\t// performance.\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ hasDuotoneSupport && blockEditingMode === 'default' && (\n\t\t\t\t\t<DuotonePanel { ...props } />\n\t\t\t\t) }\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneControls'\n);\n\nfunction DuotoneStyles( {\n\tid: filterId,\n\tselector: duotoneSelector,\n\tattribute: duotoneAttr,\n} ) {\n\tconst duotonePalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.duotone',\n\t\tdefaultSetting: 'color.defaultDuotone',\n\t} );\n\n\t// Possible values for duotone attribute:\n\t// 1. Array of colors - e.g. ['#000000', '#ffffff'].\n\t// 2. Variable for an existing Duotone preset - e.g. 'var:preset|duotone|green-blue' or 'var(--wp--preset--duotone--green-blue)''\n\t// 3. A CSS string - e.g. 'unset' to remove globally applied duotone.\n\tconst isCustom = Array.isArray( duotoneAttr );\n\tconst duotonePreset = isCustom\n\t\t? undefined\n\t\t: getColorsFromDuotonePreset( duotoneAttr, duotonePalette );\n\tconst isPreset = typeof duotoneAttr === 'string' && duotonePreset;\n\tconst isCSS = typeof duotoneAttr === 'string' && ! isPreset;\n\n\t// Match the structure of WP_Duotone_Gutenberg::render_duotone_support() in PHP.\n\tlet colors = null;\n\tif ( isPreset ) {\n\t\t// Array of colors.\n\t\tcolors = duotonePreset;\n\t} else if ( isCSS ) {\n\t\t// CSS filter property string (e.g. 'unset').\n\t\tcolors = duotoneAttr;\n\t} else if ( isCustom ) {\n\t\t// Array of colors.\n\t\tcolors = duotoneAttr;\n\t}\n\n\t// Build the CSS selectors to which the filter will be applied.\n\tconst selectors = duotoneSelector.split( ',' );\n\n\tconst selectorsScoped = selectors.map( ( selectorPart ) => {\n\t\t// Extra .editor-styles-wrapper specificity is needed in the editor\n\t\t// since we're not using inline styles to apply the filter. We need to\n\t\t// override duotone applied by global styles and theme.json.\n\n\t\t// Assuming the selector part is a subclass selector (not a tag name)\n\t\t// so we can prepend the filter id class. If we want to support elements\n\t\t// such as `img` or namespaces, we'll need to add a case for that here.\n\t\treturn `.${ filterId }${ selectorPart.trim() }`;\n\t} );\n\n\tconst selector = selectorsScoped.join( ', ' );\n\n\tconst isValidFilter = Array.isArray( colors ) || colors === 'unset';\n\n\tconst { setStyleOverride, deleteStyleOverride } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\n\tuseEffect( () => {\n\t\tif ( ! isValidFilter ) return;\n\n\t\tsetStyleOverride( filterId, {\n\t\t\tcss:\n\t\t\t\tcolors !== 'unset'\n\t\t\t\t\t? getDuotoneStylesheet( selector, filterId )\n\t\t\t\t\t: getDuotoneUnsetStylesheet( selector ),\n\t\t\t__unstableType: 'presets',\n\t\t} );\n\t\tsetStyleOverride( `duotone-${ filterId }`, {\n\t\t\tassets:\n\t\t\t\tcolors !== 'unset' ? getDuotoneFilter( filterId, colors ) : '',\n\t\t\t__unstableType: 'svgs',\n\t\t} );\n\n\t\treturn () => {\n\t\t\tdeleteStyleOverride( filterId );\n\t\t\tdeleteStyleOverride( `duotone-${ filterId }` );\n\t\t};\n\t}, [\n\t\tisValidFilter,\n\t\tcolors,\n\t\tselector,\n\t\tfilterId,\n\t\tsetStyleOverride,\n\t\tdeleteStyleOverride,\n\t] );\n\n\treturn null;\n}\n\n/**\n * Override the default block element to include duotone styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst id = useInstanceId( BlockListBlock );\n\n\t\tconst selector = useMemo( () => {\n\t\t\tconst blockType = getBlockType( props.name );\n\n\t\t\tif ( blockType ) {\n\t\t\t\t// Backwards compatibility for `supports.color.__experimentalDuotone`\n\t\t\t\t// is provided via the `block_type_metadata_settings` filter. If\n\t\t\t\t// `supports.filter.duotone` has not been set and the\n\t\t\t\t// experimental property has been, the experimental property\n\t\t\t\t// value is copied into `supports.filter.duotone`.\n\t\t\t\tconst duotoneSupport = getBlockSupport(\n\t\t\t\t\tblockType,\n\t\t\t\t\t'filter.duotone',\n\t\t\t\t\tfalse\n\t\t\t\t);\n\t\t\t\tif ( ! duotoneSupport ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\t// If the experimental duotone support was set, that value is\n\t\t\t\t// to be treated as a selector and requires scoping.\n\t\t\t\tconst experimentalDuotone = getBlockSupport(\n\t\t\t\t\tblockType,\n\t\t\t\t\t'color.__experimentalDuotone',\n\t\t\t\t\tfalse\n\t\t\t\t);\n\t\t\t\tif ( experimentalDuotone ) {\n\t\t\t\t\tconst rootSelector = getBlockCSSSelector( blockType );\n\t\t\t\t\treturn typeof experimentalDuotone === 'string'\n\t\t\t\t\t\t? scopeSelector( rootSelector, experimentalDuotone )\n\t\t\t\t\t\t: rootSelector;\n\t\t\t\t}\n\n\t\t\t\t// Regular filter.duotone support uses filter.duotone selectors with fallbacks.\n\t\t\t\treturn getBlockCSSSelector( blockType, 'filter.duotone', {\n\t\t\t\t\tfallback: true,\n\t\t\t\t} );\n\t\t\t}\n\t\t}, [ props.name ] );\n\n\t\tconst attribute = props?.attributes?.style?.color?.duotone;\n\n\t\tconst filterClass = `wp-duotone-${ id }`;\n\n\t\tconst shouldRender = selector && attribute;\n\n\t\tconst className = shouldRender\n\t\t\t? classnames( props?.className, filterClass )\n\t\t\t: props?.className;\n\n\t\t// CAUTION: code added before this line will be executed\n\t\t// for all blocks, not just those that support duotone. Code added\n\t\t// above this line should be carefully evaluated for its impact on\n\t\t// performance.\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ shouldRender && (\n\t\t\t\t\t<DuotoneStyles\n\t\t\t\t\t\tid={ filterClass }\n\t\t\t\t\t\tselector={ selector }\n\t\t\t\t\t\tattribute={ attribute }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<BlockListBlock { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/duotone/add-attributes',\n\taddDuotoneAttributes\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/duotone/with-editor-controls',\n\twithDuotoneControls\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/duotone/with-styles',\n\twithDuotoneStyles\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;AACnC,SAASC,MAAM,QAAQ,QAAQ;AAC/B,OAAOC,WAAW,MAAM,sBAAsB;;AAE9C;AACA;AACA;AACA,SACCC,eAAe,EACfC,YAAY,EACZC,eAAe,QACT,mBAAmB;AAC1B,SAASC,0BAA0B,EAAEC,aAAa,QAAQ,oBAAoB;AAC9E,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,OAAO,EAAEC,SAAS,QAAQ,oBAAoB;AACvD,SAASC,WAAW,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA,SACCC,aAAa,EACbC,iBAAiB,EACjBC,4BAA4B,IAAIC,cAAc,EAC9CC,UAAU,QACJ,eAAe;AACtB,SACCC,gBAAgB,EAChBC,oBAAoB,EACpBC,yBAAyB,QACnB,6BAA6B;AACpC,SAASC,mBAAmB,QAAQ,oDAAoD;AACxF,SAASC,aAAa,QAAQ,mCAAmC;AACjE,SAASC,gBAAgB,QAAQ,SAAS;AAC1C,SAASC,OAAO,IAAIC,kBAAkB,QAAQ,2CAA2C;AACzF,SAASC,mBAAmB,QAAQ,kCAAkC;AACtE,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,UAAU;AACpD,SAASC,MAAM,QAAQ,gBAAgB;AAEvC,MAAMC,WAAW,GAAG,EAAE;AAEtB5B,MAAM,CAAE,CAAEC,WAAW,CAAG,CAAC;AAEzB,SAAS4B,qBAAqBA,CAAE;EAAEC,aAAa;EAAEC;AAAe,CAAC,EAAG;EACnE,MAAMC,cAAc,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,CAAC,GAC3CjC,KAAK,EAAEmC,SAAS;;EAEnB;EACA;EACA;EACA;EACA,OACCnD,aAAA,CAAAC,QAAA,QACGiD,YAAY,IACblD,aAAA,CAACmB,aAAa;IACbC,EAAE,EAAG6B,WAAa;IAClB3B,QAAQ,EAAGA,QAAU;IACrBE,SAAS,EAAGA;EAAW,CACvB,CACD,EACDxB,aAAA,CAAC2C,cAAc;IAAA,GAAM3B,KAAK;IAAGmC,SAAS,EAAGA;EAAW,CAAE,CACrD,CAAC;AAEL,CAAC,EACD,mBACD,CAAC;AAED5G,SAAS,CACR,0BAA0B,EAC1B,oCAAoC,EACpCmE,oBACD,CAAC;AACDnE,SAAS,CACR,kBAAkB,EAClB,0CAA0C,EAC1CuE,mBACD,CAAC;AACDvE,SAAS,CACR,uBAAuB,EACvB,iCAAiC,EACjCmG,iBACD,CAAC"}
1
+ {"version":3,"names":["classnames","extend","namesPlugin","getBlockSupport","getBlockType","hasBlockSupport","createHigherOrderComponent","useInstanceId","addFilter","useMemo","useEffect","useDispatch","BlockControls","InspectorControls","__experimentalDuotoneControl","DuotoneControl","useSetting","getDuotoneFilter","getDuotoneStylesheet","getDuotoneUnsetStylesheet","getBlockCSSSelector","scopeSelector","useBlockSettings","default","StylesFiltersPanel","useBlockEditingMode","__unstableUseBlockElement","useBlockElement","store","blockEditorStore","unlock","EMPTY_ARRAY","isSafari","window","navigator","userAgent","includes","useMultiOriginPresets","presetSetting","defaultSetting","disableDefault","userPresets","themePresets","defaultPresets","getColorsFromDuotonePreset","duotone","duotonePalette","preset","find","slug","colors","undefined","getDuotonePresetFromColors","Array","isArray","duotonePreset","every","val","index","DuotonePanel","attributes","setAttributes","name","style","duotoneStyle","color","settings","colorPalette","disableCustomColors","disableCustomDuotone","length","duotonePresetOrColors","createElement","Fragment","group","value","filter","onChange","newDuotone","newStyle","__experimentalShareWithChildBlocks","maybePreset","addDuotoneAttributes","Object","assign","type","withDuotoneControls","BlockEdit","props","hasDuotoneSupport","blockEditingMode","DuotoneStyles","clientId","id","filterId","selector","duotoneSelector","attribute","duotoneAttr","isCustom","isPreset","isCSS","selectors","split","selectorsScoped","map","selectorPart","trim","join","isValidFilter","setStyleOverride","deleteStyleOverride","blockElement","css","__unstableType","assets","display","offsetHeight","withDuotoneStyles","BlockListBlock","blockType","duotoneSupport","experimentalDuotone","rootSelector","fallback","filterClass","shouldRender","className"],"sources":["@wordpress/block-editor/src/hooks/duotone.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tgetBlockSupport,\n\tgetBlockType,\n\thasBlockSupport,\n} from '@wordpress/blocks';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { useMemo, useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBlockControls,\n\tInspectorControls,\n\t__experimentalDuotoneControl as DuotoneControl,\n\tuseSetting,\n} from '../components';\nimport {\n\tgetDuotoneFilter,\n\tgetDuotoneStylesheet,\n\tgetDuotoneUnsetStylesheet,\n} from '../components/duotone/utils';\nimport { getBlockCSSSelector } from '../components/global-styles/get-block-css-selector';\nimport { scopeSelector } from '../components/global-styles/utils';\nimport { useBlockSettings } from './utils';\nimport { default as StylesFiltersPanel } from '../components/global-styles/filters-panel';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\nimport { __unstableUseBlockElement as useBlockElement } from '../components/block-list/use-block-props/use-block-refs';\nimport { store as blockEditorStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\nconst EMPTY_ARRAY = [];\n\n// Safari does not always update the duotone filter when the duotone colors\n// are changed. This browser check is later used to force a re-render of the block\n// element to ensure the duotone filter is updated. The check is included at the\n// root of this file as it only needs to be run once per page load.\nconst isSafari =\n\twindow?.navigator.userAgent &&\n\twindow.navigator.userAgent.includes( 'Safari' ) &&\n\t! window.navigator.userAgent.includes( 'Chrome' ) &&\n\t! window.navigator.userAgent.includes( 'Chromium' );\n\nextend( [ namesPlugin ] );\n\nfunction useMultiOriginPresets( { presetSetting, defaultSetting } ) {\n\tconst disableDefault = ! useSetting( defaultSetting );\n\tconst userPresets =\n\t\tuseSetting( `${ presetSetting }.custom` ) || EMPTY_ARRAY;\n\tconst themePresets =\n\t\tuseSetting( `${ presetSetting }.theme` ) || EMPTY_ARRAY;\n\tconst defaultPresets =\n\t\tuseSetting( `${ presetSetting }.default` ) || EMPTY_ARRAY;\n\treturn useMemo(\n\t\t() => [\n\t\t\t...userPresets,\n\t\t\t...themePresets,\n\t\t\t...( disableDefault ? EMPTY_ARRAY : defaultPresets ),\n\t\t],\n\t\t[ disableDefault, userPresets, themePresets, defaultPresets ]\n\t);\n}\n\nexport function getColorsFromDuotonePreset( duotone, duotonePalette ) {\n\tif ( ! duotone ) {\n\t\treturn;\n\t}\n\tconst preset = duotonePalette?.find( ( { slug } ) => {\n\t\treturn duotone === `var:preset|duotone|${ slug }`;\n\t} );\n\n\treturn preset ? preset.colors : undefined;\n}\n\nexport function getDuotonePresetFromColors( colors, duotonePalette ) {\n\tif ( ! colors || ! Array.isArray( colors ) ) {\n\t\treturn;\n\t}\n\n\tconst preset = duotonePalette?.find( ( duotonePreset ) => {\n\t\treturn duotonePreset?.colors?.every(\n\t\t\t( val, index ) => val === colors[ index ]\n\t\t);\n\t} );\n\n\treturn preset ? `var:preset|duotone|${ preset.slug }` : undefined;\n}\n\nfunction DuotonePanel( { attributes, setAttributes, name } ) {\n\tconst style = attributes?.style;\n\tconst duotoneStyle = style?.color?.duotone;\n\tconst settings = useBlockSettings( name );\n\n\tconst duotonePalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.duotone',\n\t\tdefaultSetting: 'color.defaultDuotone',\n\t} );\n\tconst colorPalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.palette',\n\t\tdefaultSetting: 'color.defaultPalette',\n\t} );\n\tconst disableCustomColors = ! useSetting( 'color.custom' );\n\tconst disableCustomDuotone =\n\t\t! useSetting( 'color.customDuotone' ) ||\n\t\t( colorPalette?.length === 0 && disableCustomColors );\n\n\tif ( duotonePalette?.length === 0 && disableCustomDuotone ) {\n\t\treturn null;\n\t}\n\n\tconst duotonePresetOrColors = ! Array.isArray( duotoneStyle )\n\t\t? getColorsFromDuotonePreset( duotoneStyle, duotonePalette )\n\t\t: duotoneStyle;\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls group=\"filter\">\n\t\t\t\t<StylesFiltersPanel\n\t\t\t\t\tvalue={ { filter: { duotone: duotonePresetOrColors } } }\n\t\t\t\t\tonChange={ ( newDuotone ) => {\n\t\t\t\t\t\tconst newStyle = {\n\t\t\t\t\t\t\t...style,\n\t\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t\t...newDuotone?.filter,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\tsetAttributes( { style: newStyle } );\n\t\t\t\t\t} }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t\t<DuotoneControl\n\t\t\t\t\tduotonePalette={ duotonePalette }\n\t\t\t\t\tcolorPalette={ colorPalette }\n\t\t\t\t\tdisableCustomDuotone={ disableCustomDuotone }\n\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\tvalue={ duotonePresetOrColors }\n\t\t\t\t\tonChange={ ( newDuotone ) => {\n\t\t\t\t\t\tconst maybePreset = getDuotonePresetFromColors(\n\t\t\t\t\t\t\tnewDuotone,\n\t\t\t\t\t\t\tduotonePalette\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst newStyle = {\n\t\t\t\t\t\t\t...style,\n\t\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t\t...style?.color,\n\t\t\t\t\t\t\t\tduotone: maybePreset ?? newDuotone, // use preset or fallback to custom colors.\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\tsetAttributes( { style: newStyle } );\n\t\t\t\t\t} }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t</>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * the `duotone` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addDuotoneAttributes( settings ) {\n\t// Previous `color.__experimentalDuotone` support flag is migrated via\n\t// block_type_metadata_settings filter in `lib/block-supports/duotone.php`.\n\tif ( ! hasBlockSupport( settings, 'filter.duotone' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default\n\t// values if needed.\n\tif ( ! settings.attributes.style ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tstyle: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include toolbar controls for duotone if the\n * block supports duotone.\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\t// Previous `color.__experimentalDuotone` support flag is migrated via\n\t\t// block_type_metadata_settings filter in `lib/block-supports/duotone.php`.\n\t\tconst hasDuotoneSupport = hasBlockSupport(\n\t\t\tprops.name,\n\t\t\t'filter.duotone'\n\t\t);\n\n\t\tconst blockEditingMode = useBlockEditingMode();\n\n\t\t// CAUTION: code added before this line will be executed\n\t\t// for all blocks, not just those that support duotone. Code added\n\t\t// above this line should be carefully evaluated for its impact on\n\t\t// performance.\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ hasDuotoneSupport && blockEditingMode === 'default' && (\n\t\t\t\t\t<DuotonePanel { ...props } />\n\t\t\t\t) }\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneControls'\n);\n\nfunction DuotoneStyles( {\n\tclientId,\n\tid: filterId,\n\tselector: duotoneSelector,\n\tattribute: duotoneAttr,\n} ) {\n\tconst duotonePalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.duotone',\n\t\tdefaultSetting: 'color.defaultDuotone',\n\t} );\n\n\t// Possible values for duotone attribute:\n\t// 1. Array of colors - e.g. ['#000000', '#ffffff'].\n\t// 2. Variable for an existing Duotone preset - e.g. 'var:preset|duotone|green-blue' or 'var(--wp--preset--duotone--green-blue)''\n\t// 3. A CSS string - e.g. 'unset' to remove globally applied duotone.\n\tconst isCustom = Array.isArray( duotoneAttr );\n\tconst duotonePreset = isCustom\n\t\t? undefined\n\t\t: getColorsFromDuotonePreset( duotoneAttr, duotonePalette );\n\tconst isPreset = typeof duotoneAttr === 'string' && duotonePreset;\n\tconst isCSS = typeof duotoneAttr === 'string' && ! isPreset;\n\n\t// Match the structure of WP_Duotone_Gutenberg::render_duotone_support() in PHP.\n\tlet colors = null;\n\tif ( isPreset ) {\n\t\t// Array of colors.\n\t\tcolors = duotonePreset;\n\t} else if ( isCSS ) {\n\t\t// CSS filter property string (e.g. 'unset').\n\t\tcolors = duotoneAttr;\n\t} else if ( isCustom ) {\n\t\t// Array of colors.\n\t\tcolors = duotoneAttr;\n\t}\n\n\t// Build the CSS selectors to which the filter will be applied.\n\tconst selectors = duotoneSelector.split( ',' );\n\n\tconst selectorsScoped = selectors.map( ( selectorPart ) => {\n\t\t// Extra .editor-styles-wrapper specificity is needed in the editor\n\t\t// since we're not using inline styles to apply the filter. We need to\n\t\t// override duotone applied by global styles and theme.json.\n\n\t\t// Assuming the selector part is a subclass selector (not a tag name)\n\t\t// so we can prepend the filter id class. If we want to support elements\n\t\t// such as `img` or namespaces, we'll need to add a case for that here.\n\t\treturn `.${ filterId }${ selectorPart.trim() }`;\n\t} );\n\n\tconst selector = selectorsScoped.join( ', ' );\n\n\tconst isValidFilter = Array.isArray( colors ) || colors === 'unset';\n\n\tconst { setStyleOverride, deleteStyleOverride } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\n\tconst blockElement = useBlockElement( clientId );\n\n\tuseEffect( () => {\n\t\tif ( ! isValidFilter ) return;\n\n\t\tsetStyleOverride( filterId, {\n\t\t\tcss:\n\t\t\t\tcolors !== 'unset'\n\t\t\t\t\t? getDuotoneStylesheet( selector, filterId )\n\t\t\t\t\t: getDuotoneUnsetStylesheet( selector ),\n\t\t\t__unstableType: 'presets',\n\t\t} );\n\t\tsetStyleOverride( `duotone-${ filterId }`, {\n\t\t\tassets:\n\t\t\t\tcolors !== 'unset' ? getDuotoneFilter( filterId, colors ) : '',\n\t\t\t__unstableType: 'svgs',\n\t\t} );\n\n\t\t// Safari does not always update the duotone filter when the duotone colors\n\t\t// are changed. When using Safari, force the block element to be repainted by\n\t\t// the browser to ensure any changes are reflected visually. This logic matches\n\t\t// that used on the site frontend in `block-supports/duotone.php`.\n\t\tif ( blockElement && isSafari ) {\n\t\t\tconst display = blockElement.style.display;\n\t\t\t// Switch to `inline-block` to force a repaint. In the editor, `inline-block`\n\t\t\t// is used instead of `none` to ensure that scroll position is not affected,\n\t\t\t// as `none` results in the editor scrolling to the top of the block.\n\t\t\tblockElement.style.display = 'inline-block';\n\t\t\t// Simply accessing el.offsetHeight flushes layout and style\n\t\t\t// changes in WebKit without having to wait for setTimeout.\n\t\t\t// eslint-disable-next-line no-unused-expressions\n\t\t\tblockElement.offsetHeight;\n\t\t\tblockElement.style.display = display;\n\t\t}\n\n\t\treturn () => {\n\t\t\tdeleteStyleOverride( filterId );\n\t\t\tdeleteStyleOverride( `duotone-${ filterId }` );\n\t\t};\n\t}, [\n\t\tisValidFilter,\n\t\tblockElement,\n\t\tcolors,\n\t\tselector,\n\t\tfilterId,\n\t\tsetStyleOverride,\n\t\tdeleteStyleOverride,\n\t] );\n\n\treturn null;\n}\n\n/**\n * Override the default block element to include duotone styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst id = useInstanceId( BlockListBlock );\n\n\t\tconst selector = useMemo( () => {\n\t\t\tconst blockType = getBlockType( props.name );\n\n\t\t\tif ( blockType ) {\n\t\t\t\t// Backwards compatibility for `supports.color.__experimentalDuotone`\n\t\t\t\t// is provided via the `block_type_metadata_settings` filter. If\n\t\t\t\t// `supports.filter.duotone` has not been set and the\n\t\t\t\t// experimental property has been, the experimental property\n\t\t\t\t// value is copied into `supports.filter.duotone`.\n\t\t\t\tconst duotoneSupport = getBlockSupport(\n\t\t\t\t\tblockType,\n\t\t\t\t\t'filter.duotone',\n\t\t\t\t\tfalse\n\t\t\t\t);\n\t\t\t\tif ( ! duotoneSupport ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\t// If the experimental duotone support was set, that value is\n\t\t\t\t// to be treated as a selector and requires scoping.\n\t\t\t\tconst experimentalDuotone = getBlockSupport(\n\t\t\t\t\tblockType,\n\t\t\t\t\t'color.__experimentalDuotone',\n\t\t\t\t\tfalse\n\t\t\t\t);\n\t\t\t\tif ( experimentalDuotone ) {\n\t\t\t\t\tconst rootSelector = getBlockCSSSelector( blockType );\n\t\t\t\t\treturn typeof experimentalDuotone === 'string'\n\t\t\t\t\t\t? scopeSelector( rootSelector, experimentalDuotone )\n\t\t\t\t\t\t: rootSelector;\n\t\t\t\t}\n\n\t\t\t\t// Regular filter.duotone support uses filter.duotone selectors with fallbacks.\n\t\t\t\treturn getBlockCSSSelector( blockType, 'filter.duotone', {\n\t\t\t\t\tfallback: true,\n\t\t\t\t} );\n\t\t\t}\n\t\t}, [ props.name ] );\n\n\t\tconst attribute = props?.attributes?.style?.color?.duotone;\n\n\t\tconst filterClass = `wp-duotone-${ id }`;\n\n\t\tconst shouldRender = selector && attribute;\n\n\t\tconst className = shouldRender\n\t\t\t? classnames( props?.className, filterClass )\n\t\t\t: props?.className;\n\n\t\t// CAUTION: code added before this line will be executed\n\t\t// for all blocks, not just those that support duotone. Code added\n\t\t// above this line should be carefully evaluated for its impact on\n\t\t// performance.\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ shouldRender && (\n\t\t\t\t\t<DuotoneStyles\n\t\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\t\tid={ filterClass }\n\t\t\t\t\t\tselector={ selector }\n\t\t\t\t\t\tattribute={ attribute }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<BlockListBlock { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/duotone/add-attributes',\n\taddDuotoneAttributes\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/duotone/with-editor-controls',\n\twithDuotoneControls\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/duotone/with-styles',\n\twithDuotoneStyles\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;AACnC,SAASC,MAAM,QAAQ,QAAQ;AAC/B,OAAOC,WAAW,MAAM,sBAAsB;;AAE9C;AACA;AACA;AACA,SACCC,eAAe,EACfC,YAAY,EACZC,eAAe,QACT,mBAAmB;AAC1B,SAASC,0BAA0B,EAAEC,aAAa,QAAQ,oBAAoB;AAC9E,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,OAAO,EAAEC,SAAS,QAAQ,oBAAoB;AACvD,SAASC,WAAW,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA,SACCC,aAAa,EACbC,iBAAiB,EACjBC,4BAA4B,IAAIC,cAAc,EAC9CC,UAAU,QACJ,eAAe;AACtB,SACCC,gBAAgB,EAChBC,oBAAoB,EACpBC,yBAAyB,QACnB,6BAA6B;AACpC,SAASC,mBAAmB,QAAQ,oDAAoD;AACxF,SAASC,aAAa,QAAQ,mCAAmC;AACjE,SAASC,gBAA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,KAAK,CAACI,QAAU;IAC3BC,EAAE,EAAGgC,WAAa;IAClB9B,QAAQ,EAAGA,QAAU;IACrBE,SAAS,EAAGA;EAAW,CACvB,CACD,EACDzB,aAAA,CAAC+C,cAAc;IAAA,GAAM/B,KAAK;IAAGuC,SAAS,EAAGA;EAAW,CAAE,CACrD,CAAC;AAEL,CAAC,EACD,mBACD,CAAC;AAEDvH,SAAS,CACR,0BAA0B,EAC1B,oCAAoC,EACpC0E,oBACD,CAAC;AACD1E,SAAS,CACR,kBAAkB,EAClB,0CAA0C,EAC1C8E,mBACD,CAAC;AACD9E,SAAS,CACR,uBAAuB,EACvB,iCAAiC,EACjC8G,iBACD,CAAC"}
@@ -330,13 +330,13 @@ export const withLayoutStyles = createHigherOrderComponent(BlockListBlock => pro
330
330
  } = unlock(useDispatch(blockEditorStore));
331
331
  useEffect(() => {
332
332
  if (!css) return;
333
- setStyleOverride(id, {
333
+ setStyleOverride(selector, {
334
334
  css
335
335
  });
336
336
  return () => {
337
- deleteStyleOverride(id);
337
+ deleteStyleOverride(selector);
338
338
  };
339
- }, [id, css, setStyleOverride, deleteStyleOverride]);
339
+ }, [selector, css, setStyleOverride, deleteStyleOverride]);
340
340
  return createElement(BlockListBlock, {
341
341
  ...props,
342
342
  __unstableLayoutClassNames: layoutClassNames
@@ -396,13 +396,13 @@ export const withChildLayoutStyles = createHigherOrderComponent(BlockListBlock =
396
396
  } = unlock(useDispatch(blockEditorStore));
397
397
  useEffect(() => {
398
398
  if (!css) return;
399
- setStyleOverride(id, {
399
+ setStyleOverride(selector, {
400
400
  css
401
401
  });
402
402
  return () => {
403
- deleteStyleOverride(id);
403
+ deleteStyleOverride(selector);
404
404
  };
405
- }, [id, css, setStyleOverride, deleteStyleOverride]);
405
+ }, [selector, css, setStyleOverride, deleteStyleOverride]);
406
406
  return createElement(BlockListBlock, {
407
407
  ...props,
408
408
  className: className
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","createHigherOrderComponent","useInstanceId","addFilter","getBlockSupport","hasBlockSupport","useSelect","useDispatch","Button","ButtonGroup","ToggleControl","PanelBody","__","useEffect","store","blockEditorStore","InspectorControls","useSetting","getLayoutType","getLayoutTypes","useBlockEditingMode","LAYOUT_DEFINITIONS","kebabCase","useBlockSettings","unlock","layoutBlockSupportKey","hasLayoutBlockSupport","blockName","useLayoutClasses","blockAttributes","rootPaddingAlignment","select","getSettings","__experimentalFeatures","useRootPaddingAwareAlignments","layout","default","defaultBlockLayout","usedLayout","inherit","contentSize","wideSize","type","layoutClassnames","className","baseClassName","splitBlockName","split","fullBlockName","pop","join","compoundClassName","push","orientation","justifyContent","flexWrap","useLayoutStyles","selector","style","fullLayoutType","blockGapSupport","hasBlockGapSupport","css","getLayoutStyle","LayoutPanel","setAttributes","attributes","name","settings","allowEditing","allowEditingSetting","defaultThemeLayout","themeSupportsLayout","supportsLayout","blockEditingMode","layoutBlockSupport","allowSwitching","allowInheriting","showInheritToggle","layoutType","constrainedType","displayControlsForLegacyLayouts","hasContentSizeOrLegacySettings","onChangeType","newType","onChangeLayout","newLayout","createElement","Fragment","title","__nextHasNoMarginBottom","label","checked","onChange","help","LayoutTypeSwitcher","inspectorControls","toolBarControls","map","key","isPressed","onClick","addAttribute","_settings$attributes$","withInspectorControls","BlockEdit","props","supportLayout","withLayoutStyles","BlockListBlock","blockSupportsLayout","disableLayoutStyles","shouldRenderLayoutStyles","id","layoutClasses","layoutClassNames","setStyleOverride","deleteStyleOverride","__unstableLayoutClassNames","withChildLayoutStyles","selfStretch","flexSize","hasChildLayout","shouldRenderChildLayoutStyles"],"sources":["@wordpress/block-editor/src/hooks/layout.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\tButtonGroup,\n\tToggleControl,\n\tPanelBody,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { InspectorControls } from '../components';\nimport useSetting from '../components/use-setting';\nimport { getLayoutType, getLayoutTypes } from '../layouts';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\nimport { LAYOUT_DEFINITIONS } from '../layouts/definitions';\nimport { kebabCase } from '../utils/object';\nimport { useBlockSettings } from './utils';\nimport { unlock } from '../lock-unlock';\n\nconst layoutBlockSupportKey = 'layout';\n\nfunction hasLayoutBlockSupport( blockName ) {\n\treturn (\n\t\thasBlockSupport( blockName, 'layout' ) ||\n\t\thasBlockSupport( blockName, '__experimentalLayout' )\n\t);\n}\n\n/**\n * Generates the utility classnames for the given block's layout attributes.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n *\n * @return { Array } Array of CSS classname strings.\n */\nexport function useLayoutClasses( blockAttributes = {}, blockName = '' ) {\n\tconst rootPaddingAlignment = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().__experimentalFeatures\n\t\t\t?.useRootPaddingAwareAlignments;\n\t}, [] );\n\tconst { layout } = blockAttributes;\n\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( blockName, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || defaultBlockLayout || {};\n\n\tconst layoutClassnames = [];\n\n\tif ( LAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className ) {\n\t\tconst baseClassName =\n\t\t\tLAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className;\n\t\tconst splitBlockName = blockName.split( '/' );\n\t\tconst fullBlockName =\n\t\t\tsplitBlockName[ 0 ] === 'core'\n\t\t\t\t? splitBlockName.pop()\n\t\t\t\t: splitBlockName.join( '-' );\n\t\tconst compoundClassName = `wp-block-${ fullBlockName }-${ baseClassName }`;\n\t\tlayoutClassnames.push( baseClassName, compoundClassName );\n\t}\n\n\tif (\n\t\t( usedLayout?.inherit ||\n\t\t\tusedLayout?.contentSize ||\n\t\t\tusedLayout?.type === 'constrained' ) &&\n\t\trootPaddingAlignment\n\t) {\n\t\tlayoutClassnames.push( 'has-global-padding' );\n\t}\n\n\tif ( usedLayout?.orientation ) {\n\t\tlayoutClassnames.push( `is-${ kebabCase( usedLayout.orientation ) }` );\n\t}\n\n\tif ( usedLayout?.justifyContent ) {\n\t\tlayoutClassnames.push(\n\t\t\t`is-content-justification-${ kebabCase(\n\t\t\t\tusedLayout.justifyContent\n\t\t\t) }`\n\t\t);\n\t}\n\n\tif ( usedLayout?.flexWrap && usedLayout.flexWrap === 'nowrap' ) {\n\t\tlayoutClassnames.push( 'is-nowrap' );\n\t}\n\n\treturn layoutClassnames;\n}\n\n/**\n * Generates a CSS rule with the given block's layout styles.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n * @param { string } selector A selector to use in generating the CSS rule.\n *\n * @return { string } CSS rule.\n */\nexport function useLayoutStyles( blockAttributes = {}, blockName, selector ) {\n\tconst { layout = {}, style = {} } = blockAttributes;\n\t// Update type for blocks using legacy layouts.\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || {};\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst blockGapSupport = useSetting( 'spacing.blockGap' );\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\tconst css = fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName,\n\t\tselector,\n\t\tlayout,\n\t\tstyle,\n\t\thasBlockGapSupport,\n\t} );\n\treturn css;\n}\n\nfunction LayoutPanel( { setAttributes, attributes, name: blockName } ) {\n\tconst settings = useBlockSettings( blockName );\n\tconst {\n\t\tlayout: { allowEditing: allowEditingSetting },\n\t} = settings;\n\n\tconst { layout } = attributes;\n\tconst defaultThemeLayout = useSetting( 'layout' );\n\tconst { themeSupportsLayout } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\tthemeSupportsLayout: getSettings().supportsLayout,\n\t\t};\n\t}, [] );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst layoutBlockSupport = getBlockSupport(\n\t\tblockName,\n\t\tlayoutBlockSupportKey,\n\t\t{}\n\t);\n\tconst {\n\t\tallowSwitching,\n\t\tallowEditing = allowEditingSetting ?? true,\n\t\tallowInheriting = true,\n\t\tdefault: defaultBlockLayout,\n\t} = layoutBlockSupport;\n\n\tif ( ! allowEditing ) {\n\t\treturn null;\n\t}\n\n\t// Only show the inherit toggle if it's supported,\n\t// a default theme layout is set (e.g. one that provides `contentSize` and/or `wideSize` values),\n\t// and either the default / flow or the constrained layout type is in use, as the toggle switches from one to the other.\n\tconst showInheritToggle = !! (\n\t\tallowInheriting &&\n\t\t!! defaultThemeLayout &&\n\t\t( ! layout?.type ||\n\t\t\tlayout?.type === 'default' ||\n\t\t\tlayout?.type === 'constrained' ||\n\t\t\tlayout?.inherit )\n\t);\n\n\tconst usedLayout = layout || defaultBlockLayout || {};\n\tconst {\n\t\tinherit = false,\n\t\ttype = 'default',\n\t\tcontentSize = null,\n\t} = usedLayout;\n\t/**\n\t * `themeSupportsLayout` is only relevant to the `default/flow` or\n\t * `constrained` layouts and it should not be taken into account when other\n\t * `layout` types are used.\n\t */\n\tif (\n\t\t( type === 'default' || type === 'constrained' ) &&\n\t\t! themeSupportsLayout\n\t) {\n\t\treturn null;\n\t}\n\tconst layoutType = getLayoutType( type );\n\tconst constrainedType = getLayoutType( 'constrained' );\n\tconst displayControlsForLegacyLayouts =\n\t\t! usedLayout.type && ( contentSize || inherit );\n\tconst hasContentSizeOrLegacySettings = !! inherit || !! contentSize;\n\n\tconst onChangeType = ( newType ) =>\n\t\tsetAttributes( { layout: { type: newType } } );\n\tconst onChangeLayout = ( newLayout ) =>\n\t\tsetAttributes( { layout: newLayout } );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Layout' ) }>\n\t\t\t\t\t{ showInheritToggle && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tclassName=\"block-editor-hooks__toggle-control\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Inner blocks use content width' ) }\n\t\t\t\t\t\t\t\tchecked={\n\t\t\t\t\t\t\t\t\tlayoutType?.name === 'constrained' ||\n\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t\t\t\t\ttype:\n\t\t\t\t\t\t\t\t\t\t\t\tlayoutType?.name ===\n\t\t\t\t\t\t\t\t\t\t\t\t\t'constrained' ||\n\t\t\t\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 'default'\n\t\t\t\t\t\t\t\t\t\t\t\t\t: 'constrained',\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\thelp={\n\t\t\t\t\t\t\t\t\tlayoutType?.name === 'constrained' ||\n\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks use content width with options for full and wide widths.'\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks will fill the width of this container. Toggle to constrain.'\n\t\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) }\n\n\t\t\t\t\t{ ! inherit && allowSwitching && (\n\t\t\t\t\t\t<LayoutTypeSwitcher\n\t\t\t\t\t\t\ttype={ type }\n\t\t\t\t\t\t\tonChange={ onChangeType }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ layoutType && layoutType.name !== 'default' && (\n\t\t\t\t\t\t<layoutType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ constrainedType && displayControlsForLegacyLayouts && (\n\t\t\t\t\t\t<constrainedType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t{ ! inherit && blockEditingMode === 'default' && layoutType && (\n\t\t\t\t<layoutType.toolBarControls\n\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction LayoutTypeSwitcher( { type, onChange } ) {\n\treturn (\n\t\t<ButtonGroup>\n\t\t\t{ getLayoutTypes().map( ( { name, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={ name }\n\t\t\t\t\t\tisPressed={ type === name }\n\t\t\t\t\t\tonClick={ () => onChange( name ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</Button>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ButtonGroup>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include `layout`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( 'type' in ( settings.attributes?.layout ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasLayoutBlockSupport( settings ) ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tlayout: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include layout controls\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withInspectorControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { name: blockName } = props;\n\t\tconst supportLayout = hasLayoutBlockSupport( blockName );\n\n\t\tconst blockEditingMode = useBlockEditingMode();\n\t\treturn [\n\t\t\tsupportLayout && blockEditingMode === 'default' && (\n\t\t\t\t<LayoutPanel key=\"layout\" { ...props } />\n\t\t\t),\n\t\t\t<BlockEdit key=\"edit\" { ...props } />,\n\t\t];\n\t},\n\t'withInspectorControls'\n);\n\n/**\n * Override the default block element to add the layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst blockSupportsLayout = hasLayoutBlockSupport( name );\n\t\tconst disableLayoutStyles = useSelect( ( select ) => {\n\t\t\tconst { getSettings } = select( blockEditorStore );\n\t\t\treturn !! getSettings().disableLayoutStyles;\n\t\t} );\n\t\tconst shouldRenderLayoutStyles =\n\t\t\tblockSupportsLayout && ! disableLayoutStyles;\n\t\tconst id = useInstanceId( BlockListBlock );\n\t\tconst { layout } = attributes;\n\t\tconst { default: defaultBlockLayout } =\n\t\t\tgetBlockSupport( name, layoutBlockSupportKey ) || {};\n\t\tconst usedLayout =\n\t\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t\t: layout || defaultBlockLayout || {};\n\t\tconst layoutClasses = blockSupportsLayout\n\t\t\t? useLayoutClasses( attributes, name )\n\t\t\t: null;\n\t\t// Higher specificity to override defaults from theme.json.\n\t\tconst selector = `.wp-container-${ id }.wp-container-${ id }`;\n\t\tconst blockGapSupport = useSetting( 'spacing.blockGap' );\n\t\tconst hasBlockGapSupport = blockGapSupport !== null;\n\n\t\t// Get CSS string for the current layout type.\n\t\t// The CSS and `style` element is only output if it is not empty.\n\t\tlet css;\n\t\tif ( shouldRenderLayoutStyles ) {\n\t\t\tconst fullLayoutType = getLayoutType(\n\t\t\t\tusedLayout?.type || 'default'\n\t\t\t);\n\t\t\tcss = fullLayoutType?.getLayoutStyle?.( {\n\t\t\t\tblockName: name,\n\t\t\t\tselector,\n\t\t\t\tlayout: usedLayout,\n\t\t\t\tstyle: attributes?.style,\n\t\t\t\thasBlockGapSupport,\n\t\t\t} );\n\t\t}\n\n\t\t// Attach a `wp-container-` id-based class name as well as a layout class name such as `is-layout-flex`.\n\t\tconst layoutClassNames = classnames(\n\t\t\t{\n\t\t\t\t[ `wp-container-${ id }` ]: shouldRenderLayoutStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t\t},\n\t\t\tlayoutClasses\n\t\t);\n\n\t\tconst { setStyleOverride, deleteStyleOverride } = unlock(\n\t\t\tuseDispatch( blockEditorStore )\n\t\t);\n\n\t\tuseEffect( () => {\n\t\t\tif ( ! css ) return;\n\t\t\tsetStyleOverride( id, { css } );\n\t\t\treturn () => {\n\t\t\t\tdeleteStyleOverride( id );\n\t\t\t};\n\t\t}, [ id, css, setStyleOverride, deleteStyleOverride ] );\n\n\t\treturn (\n\t\t\t<BlockListBlock\n\t\t\t\t{ ...props }\n\t\t\t\t__unstableLayoutClassNames={ layoutClassNames }\n\t\t\t/>\n\t\t);\n\t},\n\t'withLayoutStyles'\n);\n\n/**\n * Override the default block element to add the child layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withChildLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { attributes } = props;\n\t\tconst { style: { layout = {} } = {} } = attributes;\n\t\tconst { selfStretch, flexSize } = layout;\n\t\tconst hasChildLayout = selfStretch || flexSize;\n\t\tconst disableLayoutStyles = useSelect( ( select ) => {\n\t\t\tconst { getSettings } = select( blockEditorStore );\n\t\t\treturn !! getSettings().disableLayoutStyles;\n\t\t} );\n\t\tconst shouldRenderChildLayoutStyles =\n\t\t\thasChildLayout && ! disableLayoutStyles;\n\n\t\tconst id = useInstanceId( BlockListBlock );\n\t\tconst selector = `.wp-container-content-${ id }`;\n\n\t\tlet css = '';\n\n\t\tif ( selfStretch === 'fixed' && flexSize ) {\n\t\t\tcss += `${ selector } {\n\t\t\t\tflex-basis: ${ flexSize };\n\t\t\t\tbox-sizing: border-box;\n\t\t\t}`;\n\t\t} else if ( selfStretch === 'fill' ) {\n\t\t\tcss += `${ selector } {\n\t\t\t\tflex-grow: 1;\n\t\t\t}`;\n\t\t}\n\n\t\t// Attach a `wp-container-content` id-based classname.\n\t\tconst className = classnames( props?.className, {\n\t\t\t[ `wp-container-content-${ id }` ]:\n\t\t\t\tshouldRenderChildLayoutStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t} );\n\n\t\tconst { setStyleOverride, deleteStyleOverride } = unlock(\n\t\t\tuseDispatch( blockEditorStore )\n\t\t);\n\n\t\tuseEffect( () => {\n\t\t\tif ( ! css ) return;\n\t\t\tsetStyleOverride( id, { css } );\n\t\t\treturn () => {\n\t\t\t\tdeleteStyleOverride( id );\n\t\t\t};\n\t\t}, [ id, css, setStyleOverride, deleteStyleOverride ] );\n\n\t\treturn <BlockListBlock { ...props } className={ className } />;\n\t},\n\t'withChildLayoutStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/layout/addAttribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-layout-styles',\n\twithLayoutStyles\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-child-layout-styles',\n\twithChildLayoutStyles\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/layout/with-inspector-controls',\n\twithInspectorControls\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,0BAA0B,EAAEC,aAAa,QAAQ,oBAAoB;AAC9E,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,eAAe,EAAEC,eAAe,QAAQ,mBAAmB;AACpE,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,MAAM,EACNC,WAAW,EACXC,aAAa,EACbC,SAAS,QACH,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,QAAQ,oBAAoB;;AAE9C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,UAAU;AACpD,SAASC,iBAAiB,QAAQ,eAAe;AACjD,OAAOC,UAAU,MAAM,2BAA2B;AAClD,SAASC,aAAa,EAAEC,cAAc,QAAQ,YAAY;AAC1D,SAASC,mBAAmB,QAAQ,kCAAkC;AACtE,SAASC,kBAAkB,QAAQ,wBAAwB;AAC3D,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,gBAAgB,QAAQ,SAAS;AAC1C,SAASC,MAAM,QAAQ,gBAAgB;AAEvC,MAAMC,qBAAqB,GAAG,QAAQ;AAEtC,SAASC,qBAAqBA,CAAEC,SAAS,EAAG;EAC3C,OACCtB,eAAe,CAAEsB,SAAS,EAAE,QAAS,CAAC,IACtCtB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I,CAAE,CAAC;IAC/B,OAAO,MAAM;MACZuD,mBAAmB,CAAEJ,EAAG,CAAC;IAC1B,CAAC;EACF,CAAC,EAAE,CAAEA,EAAE,EAAEnD,GAAG,EAAEsD,gBAAgB,EAAEC,mBAAmB,CAAG,CAAC;EAEvD,OAAO9B,aAAA,CAACsB,cAAc;IAAA,GAAMH,KAAK;IAAG9D,SAAS,EAAGA;EAAW,CAAE,CAAC;AAC/D,CAAC,EACD,uBACD,CAAC;AAEDzC,SAAS,CACR,0BAA0B,EAC1B,0BAA0B,EAC1BmG,YACD,CAAC;AACDnG,SAAS,CACR,uBAAuB,EACvB,uCAAuC,EACvCyG,gBACD,CAAC;AACDzG,SAAS,CACR,uBAAuB,EACvB,6CAA6C,EAC7CoH,qBACD,CAAC;AACDpH,SAAS,CACR,kBAAkB,EAClB,4CAA4C,EAC5CqG,qBACD,CAAC"}
1
+ {"version":3,"names":["classnames","createHigherOrderComponent","useInstanceId","addFilter","getBlockSupport","hasBlockSupport","useSelect","useDispatch","Button","ButtonGroup","ToggleControl","PanelBody","__","useEffect","store","blockEditorStore","InspectorControls","useSetting","getLayoutType","getLayoutTypes","useBlockEditingMode","LAYOUT_DEFINITIONS","kebabCase","useBlockSettings","unlock","layoutBlockSupportKey","hasLayoutBlockSupport","blockName","useLayoutClasses","blockAttributes","rootPaddingAlignment","select","getSettings","__experimentalFeatures","useRootPaddingAwareAlignments","layout","default","defaultBlockLayout","usedLayout","inherit","contentSize","wideSize","type","layoutClassnames","className","baseClassName","splitBlockName","split","fullBlockName","pop","join","compoundClassName","push","orientation","justifyContent","flexWrap","useLayoutStyles","selector","style","fullLayoutType","blockGapSupport","hasBlockGapSupport","css","getLayoutStyle","LayoutPanel","setAttributes","attributes","name","settings","allowEditing","allowEditingSetting","defaultThemeLayout","themeSupportsLayout","supportsLayout","blockEditingMode","layoutBlockSupport","allowSwitching","allowInheriting","showInheritToggle","layoutType","constrainedType","displayControlsForLegacyLayouts","hasContentSizeOrLegacySettings","onChangeType","newType","onChangeLayout","newLayout","createElement","Fragment","title","__nextHasNoMarginBottom","label","checked","onChange","help","LayoutTypeSwitcher","inspectorControls","toolBarControls","map","key","isPressed","onClick","addAttribute","_settings$attributes$","withInspectorControls","BlockEdit","props","supportLayout","withLayoutStyles","BlockListBlock","blockSupportsLayout","disableLayoutStyles","shouldRenderLayoutStyles","id","layoutClasses","layoutClassNames","setStyleOverride","deleteStyleOverride","__unstableLayoutClassNames","withChildLayoutStyles","selfStretch","flexSize","hasChildLayout","shouldRenderChildLayoutStyles"],"sources":["@wordpress/block-editor/src/hooks/layout.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\tButtonGroup,\n\tToggleControl,\n\tPanelBody,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { InspectorControls } from '../components';\nimport useSetting from '../components/use-setting';\nimport { getLayoutType, getLayoutTypes } from '../layouts';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\nimport { LAYOUT_DEFINITIONS } from '../layouts/definitions';\nimport { kebabCase } from '../utils/object';\nimport { useBlockSettings } from './utils';\nimport { unlock } from '../lock-unlock';\n\nconst layoutBlockSupportKey = 'layout';\n\nfunction hasLayoutBlockSupport( blockName ) {\n\treturn (\n\t\thasBlockSupport( blockName, 'layout' ) ||\n\t\thasBlockSupport( blockName, '__experimentalLayout' )\n\t);\n}\n\n/**\n * Generates the utility classnames for the given block's layout attributes.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n *\n * @return { Array } Array of CSS classname strings.\n */\nexport function useLayoutClasses( blockAttributes = {}, blockName = '' ) {\n\tconst rootPaddingAlignment = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().__experimentalFeatures\n\t\t\t?.useRootPaddingAwareAlignments;\n\t}, [] );\n\tconst { layout } = blockAttributes;\n\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( blockName, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || defaultBlockLayout || {};\n\n\tconst layoutClassnames = [];\n\n\tif ( LAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className ) {\n\t\tconst baseClassName =\n\t\t\tLAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className;\n\t\tconst splitBlockName = blockName.split( '/' );\n\t\tconst fullBlockName =\n\t\t\tsplitBlockName[ 0 ] === 'core'\n\t\t\t\t? splitBlockName.pop()\n\t\t\t\t: splitBlockName.join( '-' );\n\t\tconst compoundClassName = `wp-block-${ fullBlockName }-${ baseClassName }`;\n\t\tlayoutClassnames.push( baseClassName, compoundClassName );\n\t}\n\n\tif (\n\t\t( usedLayout?.inherit ||\n\t\t\tusedLayout?.contentSize ||\n\t\t\tusedLayout?.type === 'constrained' ) &&\n\t\trootPaddingAlignment\n\t) {\n\t\tlayoutClassnames.push( 'has-global-padding' );\n\t}\n\n\tif ( usedLayout?.orientation ) {\n\t\tlayoutClassnames.push( `is-${ kebabCase( usedLayout.orientation ) }` );\n\t}\n\n\tif ( usedLayout?.justifyContent ) {\n\t\tlayoutClassnames.push(\n\t\t\t`is-content-justification-${ kebabCase(\n\t\t\t\tusedLayout.justifyContent\n\t\t\t) }`\n\t\t);\n\t}\n\n\tif ( usedLayout?.flexWrap && usedLayout.flexWrap === 'nowrap' ) {\n\t\tlayoutClassnames.push( 'is-nowrap' );\n\t}\n\n\treturn layoutClassnames;\n}\n\n/**\n * Generates a CSS rule with the given block's layout styles.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n * @param { string } selector A selector to use in generating the CSS rule.\n *\n * @return { string } CSS rule.\n */\nexport function useLayoutStyles( blockAttributes = {}, blockName, selector ) {\n\tconst { layout = {}, style = {} } = blockAttributes;\n\t// Update type for blocks using legacy layouts.\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || {};\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst blockGapSupport = useSetting( 'spacing.blockGap' );\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\tconst css = fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName,\n\t\tselector,\n\t\tlayout,\n\t\tstyle,\n\t\thasBlockGapSupport,\n\t} );\n\treturn css;\n}\n\nfunction LayoutPanel( { setAttributes, attributes, name: blockName } ) {\n\tconst settings = useBlockSettings( blockName );\n\tconst {\n\t\tlayout: { allowEditing: allowEditingSetting },\n\t} = settings;\n\n\tconst { layout } = attributes;\n\tconst defaultThemeLayout = useSetting( 'layout' );\n\tconst { themeSupportsLayout } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\tthemeSupportsLayout: getSettings().supportsLayout,\n\t\t};\n\t}, [] );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst layoutBlockSupport = getBlockSupport(\n\t\tblockName,\n\t\tlayoutBlockSupportKey,\n\t\t{}\n\t);\n\tconst {\n\t\tallowSwitching,\n\t\tallowEditing = allowEditingSetting ?? true,\n\t\tallowInheriting = true,\n\t\tdefault: defaultBlockLayout,\n\t} = layoutBlockSupport;\n\n\tif ( ! allowEditing ) {\n\t\treturn null;\n\t}\n\n\t// Only show the inherit toggle if it's supported,\n\t// a default theme layout is set (e.g. one that provides `contentSize` and/or `wideSize` values),\n\t// and either the default / flow or the constrained layout type is in use, as the toggle switches from one to the other.\n\tconst showInheritToggle = !! (\n\t\tallowInheriting &&\n\t\t!! defaultThemeLayout &&\n\t\t( ! layout?.type ||\n\t\t\tlayout?.type === 'default' ||\n\t\t\tlayout?.type === 'constrained' ||\n\t\t\tlayout?.inherit )\n\t);\n\n\tconst usedLayout = layout || defaultBlockLayout || {};\n\tconst {\n\t\tinherit = false,\n\t\ttype = 'default',\n\t\tcontentSize = null,\n\t} = usedLayout;\n\t/**\n\t * `themeSupportsLayout` is only relevant to the `default/flow` or\n\t * `constrained` layouts and it should not be taken into account when other\n\t * `layout` types are used.\n\t */\n\tif (\n\t\t( type === 'default' || type === 'constrained' ) &&\n\t\t! themeSupportsLayout\n\t) {\n\t\treturn null;\n\t}\n\tconst layoutType = getLayoutType( type );\n\tconst constrainedType = getLayoutType( 'constrained' );\n\tconst displayControlsForLegacyLayouts =\n\t\t! usedLayout.type && ( contentSize || inherit );\n\tconst hasContentSizeOrLegacySettings = !! inherit || !! contentSize;\n\n\tconst onChangeType = ( newType ) =>\n\t\tsetAttributes( { layout: { type: newType } } );\n\tconst onChangeLayout = ( newLayout ) =>\n\t\tsetAttributes( { layout: newLayout } );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Layout' ) }>\n\t\t\t\t\t{ showInheritToggle && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tclassName=\"block-editor-hooks__toggle-control\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Inner blocks use content width' ) }\n\t\t\t\t\t\t\t\tchecked={\n\t\t\t\t\t\t\t\t\tlayoutType?.name === 'constrained' ||\n\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t\t\t\t\ttype:\n\t\t\t\t\t\t\t\t\t\t\t\tlayoutType?.name ===\n\t\t\t\t\t\t\t\t\t\t\t\t\t'constrained' ||\n\t\t\t\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 'default'\n\t\t\t\t\t\t\t\t\t\t\t\t\t: 'constrained',\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\thelp={\n\t\t\t\t\t\t\t\t\tlayoutType?.name === 'constrained' ||\n\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks use content width with options for full and wide widths.'\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks will fill the width of this container. Toggle to constrain.'\n\t\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) }\n\n\t\t\t\t\t{ ! inherit && allowSwitching && (\n\t\t\t\t\t\t<LayoutTypeSwitcher\n\t\t\t\t\t\t\ttype={ type }\n\t\t\t\t\t\t\tonChange={ onChangeType }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ layoutType && layoutType.name !== 'default' && (\n\t\t\t\t\t\t<layoutType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ constrainedType && displayControlsForLegacyLayouts && (\n\t\t\t\t\t\t<constrainedType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t{ ! inherit && blockEditingMode === 'default' && layoutType && (\n\t\t\t\t<layoutType.toolBarControls\n\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction LayoutTypeSwitcher( { type, onChange } ) {\n\treturn (\n\t\t<ButtonGroup>\n\t\t\t{ getLayoutTypes().map( ( { name, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={ name }\n\t\t\t\t\t\tisPressed={ type === name }\n\t\t\t\t\t\tonClick={ () => onChange( name ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</Button>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ButtonGroup>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include `layout`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( 'type' in ( settings.attributes?.layout ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasLayoutBlockSupport( settings ) ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tlayout: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include layout controls\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withInspectorControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { name: blockName } = props;\n\t\tconst supportLayout = hasLayoutBlockSupport( blockName );\n\n\t\tconst blockEditingMode = useBlockEditingMode();\n\t\treturn [\n\t\t\tsupportLayout && blockEditingMode === 'default' && (\n\t\t\t\t<LayoutPanel key=\"layout\" { ...props } />\n\t\t\t),\n\t\t\t<BlockEdit key=\"edit\" { ...props } />,\n\t\t];\n\t},\n\t'withInspectorControls'\n);\n\n/**\n * Override the default block element to add the layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst blockSupportsLayout = hasLayoutBlockSupport( name );\n\t\tconst disableLayoutStyles = useSelect( ( select ) => {\n\t\t\tconst { getSettings } = select( blockEditorStore );\n\t\t\treturn !! getSettings().disableLayoutStyles;\n\t\t} );\n\t\tconst shouldRenderLayoutStyles =\n\t\t\tblockSupportsLayout && ! disableLayoutStyles;\n\t\tconst id = useInstanceId( BlockListBlock );\n\t\tconst { layout } = attributes;\n\t\tconst { default: defaultBlockLayout } =\n\t\t\tgetBlockSupport( name, layoutBlockSupportKey ) || {};\n\t\tconst usedLayout =\n\t\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t\t: layout || defaultBlockLayout || {};\n\t\tconst layoutClasses = blockSupportsLayout\n\t\t\t? useLayoutClasses( attributes, name )\n\t\t\t: null;\n\t\t// Higher specificity to override defaults from theme.json.\n\t\tconst selector = `.wp-container-${ id }.wp-container-${ id }`;\n\t\tconst blockGapSupport = useSetting( 'spacing.blockGap' );\n\t\tconst hasBlockGapSupport = blockGapSupport !== null;\n\n\t\t// Get CSS string for the current layout type.\n\t\t// The CSS and `style` element is only output if it is not empty.\n\t\tlet css;\n\t\tif ( shouldRenderLayoutStyles ) {\n\t\t\tconst fullLayoutType = getLayoutType(\n\t\t\t\tusedLayout?.type || 'default'\n\t\t\t);\n\t\t\tcss = fullLayoutType?.getLayoutStyle?.( {\n\t\t\t\tblockName: name,\n\t\t\t\tselector,\n\t\t\t\tlayout: usedLayout,\n\t\t\t\tstyle: attributes?.style,\n\t\t\t\thasBlockGapSupport,\n\t\t\t} );\n\t\t}\n\n\t\t// Attach a `wp-container-` id-based class name as well as a layout class name such as `is-layout-flex`.\n\t\tconst layoutClassNames = classnames(\n\t\t\t{\n\t\t\t\t[ `wp-container-${ id }` ]: shouldRenderLayoutStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t\t},\n\t\t\tlayoutClasses\n\t\t);\n\n\t\tconst { setStyleOverride, deleteStyleOverride } = unlock(\n\t\t\tuseDispatch( blockEditorStore )\n\t\t);\n\n\t\tuseEffect( () => {\n\t\t\tif ( ! css ) return;\n\t\t\tsetStyleOverride( selector, { css } );\n\t\t\treturn () => {\n\t\t\t\tdeleteStyleOverride( selector );\n\t\t\t};\n\t\t}, [ selector, css, setStyleOverride, deleteStyleOverride ] );\n\n\t\treturn (\n\t\t\t<BlockListBlock\n\t\t\t\t{ ...props }\n\t\t\t\t__unstableLayoutClassNames={ layoutClassNames }\n\t\t\t/>\n\t\t);\n\t},\n\t'withLayoutStyles'\n);\n\n/**\n * Override the default block element to add the child layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withChildLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { attributes } = props;\n\t\tconst { style: { layout = {} } = {} } = attributes;\n\t\tconst { selfStretch, flexSize } = layout;\n\t\tconst hasChildLayout = selfStretch || flexSize;\n\t\tconst disableLayoutStyles = useSelect( ( select ) => {\n\t\t\tconst { getSettings } = select( blockEditorStore );\n\t\t\treturn !! getSettings().disableLayoutStyles;\n\t\t} );\n\t\tconst shouldRenderChildLayoutStyles =\n\t\t\thasChildLayout && ! disableLayoutStyles;\n\n\t\tconst id = useInstanceId( BlockListBlock );\n\t\tconst selector = `.wp-container-content-${ id }`;\n\n\t\tlet css = '';\n\n\t\tif ( selfStretch === 'fixed' && flexSize ) {\n\t\t\tcss += `${ selector } {\n\t\t\t\tflex-basis: ${ flexSize };\n\t\t\t\tbox-sizing: border-box;\n\t\t\t}`;\n\t\t} else if ( selfStretch === 'fill' ) {\n\t\t\tcss += `${ selector } {\n\t\t\t\tflex-grow: 1;\n\t\t\t}`;\n\t\t}\n\n\t\t// Attach a `wp-container-content` id-based classname.\n\t\tconst className = classnames( props?.className, {\n\t\t\t[ `wp-container-content-${ id }` ]:\n\t\t\t\tshouldRenderChildLayoutStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t} );\n\n\t\tconst { setStyleOverride, deleteStyleOverride } = unlock(\n\t\t\tuseDispatch( blockEditorStore )\n\t\t);\n\n\t\tuseEffect( () => {\n\t\t\tif ( ! css ) return;\n\t\t\tsetStyleOverride( selector, { css } );\n\t\t\treturn () => {\n\t\t\t\tdeleteStyleOverride( selector );\n\t\t\t};\n\t\t}, [ selector, css, setStyleOverride, deleteStyleOverride ] );\n\n\t\treturn <BlockListBlock { ...props } className={ className } />;\n\t},\n\t'withChildLayoutStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/layout/addAttribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-layout-styles',\n\twithLayoutStyles\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-child-layout-styles',\n\twithChildLayoutStyles\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/layout/with-inspector-controls',\n\twithInspectorControls\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,0BAA0B,EAAEC,aAAa,QAAQ,oBAAoB;AAC9E,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,eAAe,EAAEC,eAAe,QAAQ,mBAAmB;AACpE,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,MAAM,EACNC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",
3
+ "version": "12.10.8",
4
4
  "description": "Generic block editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -35,36 +35,36 @@
35
35
  "@emotion/react": "^11.7.1",
36
36
  "@emotion/styled": "^11.6.0",
37
37
  "@react-spring/web": "^9.4.5",
38
- "@wordpress/a11y": "^3.42.6",
39
- "@wordpress/api-fetch": "^6.39.6",
40
- "@wordpress/blob": "^3.42.6",
41
- "@wordpress/blocks": "^12.19.6",
42
- "@wordpress/commands": "^0.13.6",
43
- "@wordpress/components": "^25.8.6",
44
- "@wordpress/compose": "^6.19.6",
45
- "@wordpress/data": "^9.12.6",
46
- "@wordpress/date": "^4.42.6",
47
- "@wordpress/deprecated": "^3.42.6",
48
- "@wordpress/dom": "^3.42.6",
49
- "@wordpress/element": "^5.19.6",
50
- "@wordpress/escape-html": "^2.42.6",
51
- "@wordpress/hooks": "^3.42.6",
52
- "@wordpress/html-entities": "^3.42.6",
53
- "@wordpress/i18n": "^4.42.6",
54
- "@wordpress/icons": "^9.33.6",
55
- "@wordpress/is-shallow-equal": "^4.42.6",
56
- "@wordpress/keyboard-shortcuts": "^4.19.6",
57
- "@wordpress/keycodes": "^3.42.6",
58
- "@wordpress/notices": "^4.10.6",
59
- "@wordpress/preferences": "^3.19.6",
60
- "@wordpress/private-apis": "^0.24.6",
61
- "@wordpress/rich-text": "^6.19.6",
62
- "@wordpress/shortcode": "^3.42.6",
63
- "@wordpress/style-engine": "^1.25.6",
64
- "@wordpress/token-list": "^2.42.6",
65
- "@wordpress/url": "^3.43.6",
66
- "@wordpress/warning": "^2.42.6",
67
- "@wordpress/wordcount": "^3.42.6",
38
+ "@wordpress/a11y": "^3.42.8",
39
+ "@wordpress/api-fetch": "^6.39.8",
40
+ "@wordpress/blob": "^3.42.8",
41
+ "@wordpress/blocks": "^12.19.8",
42
+ "@wordpress/commands": "^0.13.8",
43
+ "@wordpress/components": "^25.8.8",
44
+ "@wordpress/compose": "^6.19.8",
45
+ "@wordpress/data": "^9.12.8",
46
+ "@wordpress/date": "^4.42.8",
47
+ "@wordpress/deprecated": "^3.42.8",
48
+ "@wordpress/dom": "^3.42.8",
49
+ "@wordpress/element": "^5.19.8",
50
+ "@wordpress/escape-html": "^2.42.8",
51
+ "@wordpress/hooks": "^3.42.8",
52
+ "@wordpress/html-entities": "^3.42.8",
53
+ "@wordpress/i18n": "^4.42.8",
54
+ "@wordpress/icons": "^9.33.8",
55
+ "@wordpress/is-shallow-equal": "^4.42.8",
56
+ "@wordpress/keyboard-shortcuts": "^4.19.8",
57
+ "@wordpress/keycodes": "^3.42.8",
58
+ "@wordpress/notices": "^4.10.8",
59
+ "@wordpress/preferences": "^3.19.8",
60
+ "@wordpress/private-apis": "^0.24.8",
61
+ "@wordpress/rich-text": "^6.19.8",
62
+ "@wordpress/shortcode": "^3.42.8",
63
+ "@wordpress/style-engine": "^1.25.8",
64
+ "@wordpress/token-list": "^2.42.8",
65
+ "@wordpress/url": "^3.43.8",
66
+ "@wordpress/warning": "^2.42.8",
67
+ "@wordpress/wordcount": "^3.42.8",
68
68
  "change-case": "^4.1.2",
69
69
  "classnames": "^2.3.1",
70
70
  "colord": "^2.7.0",
@@ -86,5 +86,5 @@
86
86
  "publishConfig": {
87
87
  "access": "public"
88
88
  },
89
- "gitHead": "640c80ab0fb4e0e2bce87e33895939f257e674df"
89
+ "gitHead": "9ef7560ce92c4736819b5e767810b9a80d51d030"
90
90
  }
@@ -16,6 +16,7 @@ import deprecated from '@wordpress/deprecated';
16
16
  */
17
17
  import { ExperimentalBlockEditorProvider } from '../provider';
18
18
  import AutoHeightBlockPreview from './auto';
19
+ import EditorStyles from '../editor-styles';
19
20
  import { store as blockEditorStore } from '../../store';
20
21
  import { BlockListItems } from '../block-list';
21
22
 
@@ -113,7 +114,11 @@ export function useBlockPreview( { blocks, props = {}, layout } ) {
113
114
  []
114
115
  );
115
116
  const settings = useMemo(
116
- () => ( { ...originalSettings, __unstableIsPreviewMode: true } ),
117
+ () => ( {
118
+ ...originalSettings,
119
+ styles: undefined, // Clear styles included by the parent settings, as they are already output by the parent's EditorStyles.
120
+ __unstableIsPreviewMode: true,
121
+ } ),
117
122
  [ originalSettings ]
118
123
  );
119
124
  const disabledRef = useDisabled();
@@ -128,6 +133,7 @@ export function useBlockPreview( { blocks, props = {}, layout } ) {
128
133
  value={ renderedBlocks }
129
134
  settings={ settings }
130
135
  >
136
+ <EditorStyles />
131
137
  <BlockListItems renderAppender={ false } layout={ layout } />
132
138
  </ExperimentalBlockEditorProvider>
133
139
  );
@@ -37,11 +37,22 @@ import { scopeSelector } from '../components/global-styles/utils';
37
37
  import { useBlockSettings } from './utils';
38
38
  import { default as StylesFiltersPanel } from '../components/global-styles/filters-panel';
39
39
  import { useBlockEditingMode } from '../components/block-editing-mode';
40
+ import { __unstableUseBlockElement as useBlockElement } from '../components/block-list/use-block-props/use-block-refs';
40
41
  import { store as blockEditorStore } from '../store';
41
42
  import { unlock } from '../lock-unlock';
42
43
 
43
44
  const EMPTY_ARRAY = [];
44
45
 
46
+ // Safari does not always update the duotone filter when the duotone colors
47
+ // are changed. This browser check is later used to force a re-render of the block
48
+ // element to ensure the duotone filter is updated. The check is included at the
49
+ // root of this file as it only needs to be run once per page load.
50
+ const isSafari =
51
+ window?.navigator.userAgent &&
52
+ window.navigator.userAgent.includes( 'Safari' ) &&
53
+ ! window.navigator.userAgent.includes( 'Chrome' ) &&
54
+ ! window.navigator.userAgent.includes( 'Chromium' );
55
+
45
56
  extend( [ namesPlugin ] );
46
57
 
47
58
  function useMultiOriginPresets( { presetSetting, defaultSetting } ) {
@@ -223,6 +234,7 @@ const withDuotoneControls = createHigherOrderComponent(
223
234
  );
224
235
 
225
236
  function DuotoneStyles( {
237
+ clientId,
226
238
  id: filterId,
227
239
  selector: duotoneSelector,
228
240
  attribute: duotoneAttr,
@@ -278,6 +290,8 @@ function DuotoneStyles( {
278
290
  useDispatch( blockEditorStore )
279
291
  );
280
292
 
293
+ const blockElement = useBlockElement( clientId );
294
+
281
295
  useEffect( () => {
282
296
  if ( ! isValidFilter ) return;
283
297
 
@@ -294,12 +308,30 @@ function DuotoneStyles( {
294
308
  __unstableType: 'svgs',
295
309
  } );
296
310
 
311
+ // Safari does not always update the duotone filter when the duotone colors
312
+ // are changed. When using Safari, force the block element to be repainted by
313
+ // the browser to ensure any changes are reflected visually. This logic matches
314
+ // that used on the site frontend in `block-supports/duotone.php`.
315
+ if ( blockElement && isSafari ) {
316
+ const display = blockElement.style.display;
317
+ // Switch to `inline-block` to force a repaint. In the editor, `inline-block`
318
+ // is used instead of `none` to ensure that scroll position is not affected,
319
+ // as `none` results in the editor scrolling to the top of the block.
320
+ blockElement.style.display = 'inline-block';
321
+ // Simply accessing el.offsetHeight flushes layout and style
322
+ // changes in WebKit without having to wait for setTimeout.
323
+ // eslint-disable-next-line no-unused-expressions
324
+ blockElement.offsetHeight;
325
+ blockElement.style.display = display;
326
+ }
327
+
297
328
  return () => {
298
329
  deleteStyleOverride( filterId );
299
330
  deleteStyleOverride( `duotone-${ filterId }` );
300
331
  };
301
332
  }, [
302
333
  isValidFilter,
334
+ blockElement,
303
335
  colors,
304
336
  selector,
305
337
  filterId,
@@ -378,6 +410,7 @@ const withDuotoneStyles = createHigherOrderComponent(
378
410
  <>
379
411
  { shouldRender && (
380
412
  <DuotoneStyles
413
+ clientId={ props.clientId }
381
414
  id={ filterClass }
382
415
  selector={ selector }
383
416
  attribute={ attribute }
@@ -408,11 +408,11 @@ export const withLayoutStyles = createHigherOrderComponent(
408
408
 
409
409
  useEffect( () => {
410
410
  if ( ! css ) return;
411
- setStyleOverride( id, { css } );
411
+ setStyleOverride( selector, { css } );
412
412
  return () => {
413
- deleteStyleOverride( id );
413
+ deleteStyleOverride( selector );
414
414
  };
415
- }, [ id, css, setStyleOverride, deleteStyleOverride ] );
415
+ }, [ selector, css, setStyleOverride, deleteStyleOverride ] );
416
416
 
417
417
  return (
418
418
  <BlockListBlock
@@ -472,11 +472,11 @@ export const withChildLayoutStyles = createHigherOrderComponent(
472
472
 
473
473
  useEffect( () => {
474
474
  if ( ! css ) return;
475
- setStyleOverride( id, { css } );
475
+ setStyleOverride( selector, { css } );
476
476
  return () => {
477
- deleteStyleOverride( id );
477
+ deleteStyleOverride( selector );
478
478
  };
479
- }, [ id, css, setStyleOverride, deleteStyleOverride ] );
479
+ }, [ selector, css, setStyleOverride, deleteStyleOverride ] );
480
480
 
481
481
  return <BlockListBlock { ...props } className={ className } />;
482
482
  },