@wordpress/block-editor 11.5.0 → 11.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-list/block-invalid-warning.js +63 -80
  3. package/build/components/block-list/block-invalid-warning.js.map +1 -1
  4. package/build/components/block-settings-menu-controls/index.js +1 -1
  5. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  6. package/build/components/block-switcher/block-transformations-menu.native.js +1 -0
  7. package/build/components/block-switcher/block-transformations-menu.native.js.map +1 -1
  8. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
  9. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  10. package/build/components/global-styles/border-panel.js +306 -0
  11. package/build/components/global-styles/border-panel.js.map +1 -0
  12. package/build/components/global-styles/hooks.js +57 -3
  13. package/build/components/global-styles/hooks.js.map +1 -1
  14. package/build/components/global-styles/index.js +20 -0
  15. package/build/components/global-styles/index.js.map +1 -1
  16. package/build/components/global-styles/typography-panel.js +62 -15
  17. package/build/components/global-styles/typography-panel.js.map +1 -1
  18. package/build/components/global-styles/use-global-styles-output.js +20 -13
  19. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  20. package/build/components/inserter/index.js +29 -17
  21. package/build/components/inserter/index.js.map +1 -1
  22. package/build/components/inserter/menu.js +1 -1
  23. package/build/components/inserter/menu.js.map +1 -1
  24. package/build/components/inserter/quick-inserter.js +4 -2
  25. package/build/components/inserter/quick-inserter.js.map +1 -1
  26. package/build/components/inserter/search-results.js +10 -3
  27. package/build/components/inserter/search-results.js.map +1 -1
  28. package/build/components/inserter/tabs.js +1 -1
  29. package/build/components/inserter/tabs.js.map +1 -1
  30. package/build/components/link-control/index.js +1 -1
  31. package/build/components/link-control/index.js.map +1 -1
  32. package/build/components/link-control/search-item.js +5 -2
  33. package/build/components/link-control/search-item.js.map +1 -1
  34. package/build/components/list-view/use-block-selection.js +1 -2
  35. package/build/components/list-view/use-block-selection.js.map +1 -1
  36. package/build/components/off-canvas-editor/appender.js +28 -3
  37. package/build/components/off-canvas-editor/appender.js.map +1 -1
  38. package/build/components/off-canvas-editor/branch.js +5 -3
  39. package/build/components/off-canvas-editor/branch.js.map +1 -1
  40. package/build/components/off-canvas-editor/index.js +9 -7
  41. package/build/components/off-canvas-editor/index.js.map +1 -1
  42. package/build/components/off-canvas-editor/link-ui.js +0 -1
  43. package/build/components/off-canvas-editor/link-ui.js.map +1 -1
  44. package/build/components/provider/use-block-sync.js +17 -3
  45. package/build/components/provider/use-block-sync.js.map +1 -1
  46. package/build/components/rich-text/format-toolbar-container.js +0 -3
  47. package/build/components/rich-text/format-toolbar-container.js.map +1 -1
  48. package/build/hooks/border.js +91 -240
  49. package/build/hooks/border.js.map +1 -1
  50. package/build/hooks/custom-class-name.js +4 -4
  51. package/build/hooks/custom-class-name.js.map +1 -1
  52. package/build/hooks/custom-class-name.native.js +3 -4
  53. package/build/hooks/custom-class-name.native.js.map +1 -1
  54. package/build/hooks/layout.js +19 -22
  55. package/build/hooks/layout.js.map +1 -1
  56. package/build/hooks/supports.js +7 -1
  57. package/build/hooks/supports.js.map +1 -1
  58. package/build/hooks/typography.js +2 -1
  59. package/build/hooks/typography.js.map +1 -1
  60. package/build/hooks/utils.js +27 -1
  61. package/build/hooks/utils.js.map +1 -1
  62. package/build/layouts/constrained.js +6 -2
  63. package/build/layouts/constrained.js.map +1 -1
  64. package/build/private-apis.js +4 -1
  65. package/build/private-apis.js.map +1 -1
  66. package/build/store/actions.js +10 -8
  67. package/build/store/actions.js.map +1 -1
  68. package/build/store/selectors.js +19 -3
  69. package/build/store/selectors.js.map +1 -1
  70. package/build/utils/parse-css-unit-to-px.js +15 -9
  71. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  72. package/build-module/components/block-list/block-invalid-warning.js +66 -78
  73. package/build-module/components/block-list/block-invalid-warning.js.map +1 -1
  74. package/build-module/components/block-settings-menu-controls/index.js +1 -1
  75. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  76. package/build-module/components/block-switcher/block-transformations-menu.native.js +1 -0
  77. package/build-module/components/block-switcher/block-transformations-menu.native.js.map +1 -1
  78. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
  79. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  80. package/build-module/components/global-styles/border-panel.js +291 -0
  81. package/build-module/components/global-styles/border-panel.js.map +1 -0
  82. package/build-module/components/global-styles/hooks.js +54 -3
  83. package/build-module/components/global-styles/hooks.js.map +1 -1
  84. package/build-module/components/global-styles/index.js +2 -1
  85. package/build-module/components/global-styles/index.js.map +1 -1
  86. package/build-module/components/global-styles/typography-panel.js +62 -16
  87. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  88. package/build-module/components/global-styles/use-global-styles-output.js +20 -13
  89. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  90. package/build-module/components/inserter/index.js +28 -16
  91. package/build-module/components/inserter/index.js.map +1 -1
  92. package/build-module/components/inserter/menu.js +1 -1
  93. package/build-module/components/inserter/menu.js.map +1 -1
  94. package/build-module/components/inserter/quick-inserter.js +4 -2
  95. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  96. package/build-module/components/inserter/search-results.js +10 -3
  97. package/build-module/components/inserter/search-results.js.map +1 -1
  98. package/build-module/components/inserter/tabs.js +1 -1
  99. package/build-module/components/inserter/tabs.js.map +1 -1
  100. package/build-module/components/link-control/index.js +1 -1
  101. package/build-module/components/link-control/index.js.map +1 -1
  102. package/build-module/components/link-control/search-item.js +4 -2
  103. package/build-module/components/link-control/search-item.js.map +1 -1
  104. package/build-module/components/list-view/use-block-selection.js +1 -2
  105. package/build-module/components/list-view/use-block-selection.js.map +1 -1
  106. package/build-module/components/off-canvas-editor/appender.js +28 -4
  107. package/build-module/components/off-canvas-editor/appender.js.map +1 -1
  108. package/build-module/components/off-canvas-editor/branch.js +5 -3
  109. package/build-module/components/off-canvas-editor/branch.js.map +1 -1
  110. package/build-module/components/off-canvas-editor/index.js +9 -7
  111. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  112. package/build-module/components/off-canvas-editor/link-ui.js +0 -1
  113. package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
  114. package/build-module/components/provider/use-block-sync.js +17 -3
  115. package/build-module/components/provider/use-block-sync.js.map +1 -1
  116. package/build-module/components/rich-text/format-toolbar-container.js +0 -3
  117. package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
  118. package/build-module/hooks/border.js +93 -240
  119. package/build-module/hooks/border.js.map +1 -1
  120. package/build-module/hooks/custom-class-name.js +4 -4
  121. package/build-module/hooks/custom-class-name.js.map +1 -1
  122. package/build-module/hooks/custom-class-name.native.js +3 -4
  123. package/build-module/hooks/custom-class-name.native.js.map +1 -1
  124. package/build-module/hooks/layout.js +19 -22
  125. package/build-module/hooks/layout.js.map +1 -1
  126. package/build-module/hooks/supports.js +7 -1
  127. package/build-module/hooks/supports.js.map +1 -1
  128. package/build-module/hooks/typography.js +2 -1
  129. package/build-module/hooks/typography.js.map +1 -1
  130. package/build-module/hooks/utils.js +27 -1
  131. package/build-module/hooks/utils.js.map +1 -1
  132. package/build-module/layouts/constrained.js +6 -2
  133. package/build-module/layouts/constrained.js.map +1 -1
  134. package/build-module/private-apis.js +3 -1
  135. package/build-module/private-apis.js.map +1 -1
  136. package/build-module/store/actions.js +10 -8
  137. package/build-module/store/actions.js.map +1 -1
  138. package/build-module/store/selectors.js +17 -3
  139. package/build-module/store/selectors.js.map +1 -1
  140. package/build-module/utils/parse-css-unit-to-px.js +15 -9
  141. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  142. package/build-style/style-rtl.css +6 -6
  143. package/build-style/style.css +6 -6
  144. package/package.json +31 -31
  145. package/src/components/block-inspector/style.scss +3 -0
  146. package/src/components/block-list/block-invalid-warning.js +72 -64
  147. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +20 -2
  148. package/src/components/block-preview/test/index.js +0 -2
  149. package/src/components/block-settings-menu-controls/index.js +2 -1
  150. package/src/components/block-styles/style.scss +2 -2
  151. package/src/components/block-switcher/block-transformations-menu.native.js +1 -0
  152. package/src/components/color-palette/test/__snapshots__/control.js.snap +16 -14
  153. package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +48 -38
  154. package/src/components/global-styles/border-panel.js +285 -0
  155. package/src/components/global-styles/hooks.js +74 -1
  156. package/src/components/global-styles/index.js +2 -0
  157. package/src/components/global-styles/test/use-global-styles-output.js +1 -1
  158. package/src/components/global-styles/typography-panel.js +48 -1
  159. package/src/components/global-styles/use-global-styles-output.js +13 -13
  160. package/src/components/inserter/index.js +30 -11
  161. package/src/components/inserter/menu.js +0 -1
  162. package/src/components/inserter/quick-inserter.js +2 -0
  163. package/src/components/inserter/search-results.js +7 -1
  164. package/src/components/inserter/style.scss +3 -0
  165. package/src/components/inserter/tabs.js +1 -9
  166. package/src/components/link-control/index.js +1 -1
  167. package/src/components/link-control/search-item.js +3 -1
  168. package/src/components/link-control/style.scss +0 -4
  169. package/src/components/link-control/test/index.js +0 -2
  170. package/src/components/list-view/use-block-selection.js +0 -2
  171. package/src/components/off-canvas-editor/appender.js +31 -5
  172. package/src/components/off-canvas-editor/branch.js +3 -1
  173. package/src/components/off-canvas-editor/index.js +7 -7
  174. package/src/components/off-canvas-editor/link-ui.js +0 -1
  175. package/src/components/provider/use-block-sync.js +21 -4
  176. package/src/components/rich-text/format-toolbar-container.js +1 -7
  177. package/src/components/url-popover/test/index.js +0 -2
  178. package/src/hooks/border.js +94 -225
  179. package/src/hooks/custom-class-name.js +4 -4
  180. package/src/hooks/custom-class-name.native.js +3 -4
  181. package/src/hooks/layout.js +19 -16
  182. package/src/hooks/supports.js +6 -0
  183. package/src/hooks/test/style.js +2 -1
  184. package/src/hooks/test/use-typography-props.js +2 -0
  185. package/src/hooks/typography.js +2 -0
  186. package/src/hooks/utils.js +36 -0
  187. package/src/layouts/constrained.js +23 -17
  188. package/src/private-apis.js +2 -0
  189. package/src/store/actions.js +10 -8
  190. package/src/store/selectors.js +20 -3
  191. package/src/utils/parse-css-unit-to-px.js +14 -9
  192. package/src/utils/test/parse-css-unit-to-px.js +1 -2
  193. package/tsconfig.tsbuildinfo +1 -1
  194. package/build/hooks/border-radius.js +0 -100
  195. package/build/hooks/border-radius.js.map +0 -1
  196. package/build-module/hooks/border-radius.js +0 -84
  197. package/build-module/hooks/border-radius.js.map +0 -1
  198. package/src/hooks/border-radius.js +0 -70
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/global-styles/use-global-styles-output.js"],"names":["get","isEmpty","kebabCase","set","__EXPERIMENTAL_STYLE_PROPERTY","STYLE_PROPERTY","__EXPERIMENTAL_ELEMENTS","ELEMENTS","getBlockTypes","store","blocksStore","useSelect","useContext","useMemo","getCSSRules","PRESET_METADATA","ROOT_BLOCK_SELECTOR","scopeSelector","getTypographyFontSizeValue","GlobalStylesContext","useGlobalSetting","PresetDuotoneFilter","getGapCSSValue","blockEditorStore","BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS","__experimentalBorder","color","spacing","typography","compileStyleValue","uncompiledValue","VARIABLE_REFERENCE_PREFIX","VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE","VARIABLE_PATH_SEPARATOR_TOKEN_STYLE","startsWith","variable","slice","length","split","join","getPresetsDeclarations","blockPresets","mergedSettings","reduce","declarations","path","valueKey","valueFunc","cssVarInfix","presetByOrigin","forEach","origin","value","push","slug","getPresetsClasses","blockSelector","classes","classSuffix","propertyName","classSelectorToUse","selectorToUse","map","selector","getPresetsSvgFilters","filter","metadata","at","flatMap","preset","flattenTree","input","prefix","token","result","Object","keys","key","newKey","replace","newLeaf","newPrefix","concatFeatureVariationSelectorString","featureSelector","styleVariationSelector","featureSelectors","combinedSelectors","trim","getStylesDeclarations","blockStyles","useRootPaddingAlign","tree","isRoot","output","entries","properties","useEngine","rootOnly","pathToValue","styleValue","entry","name","prop","cssProperty","extraRules","rule","ruleValue","ref","refPath","size","settings","getLayoutStyles","style","hasBlockGapSupport","hasFallbackGapSupport","fallbackGapValue","ruleset","gapValue","blockGap","layout","definitions","values","className","spacingStyles","spacingStyle","rules","cssValue","combinedSelector","validDisplayModes","displayMode","baseStyles","includes","baseStyle","getNodesWithStyles","blockSelectors","nodes","styles","pickStyleKeys","treeToPickFrom","fromEntries","elements","blocks","blockName","node","variations","variation","duotoneSelector","hasLayoutSupport","styleVariationSelectors","elementName","sel","elementSelectors","elementSelector","getNodesWithSettings","pickPresets","presets","custom","blockCustom","toCustomProperties","customProps","toStyles","disableLayoutStyles","nodesWithStyles","nodesWithSettings","useRootPaddingAwareAlignments","contentSize","wideSize","featureName","featureStyles","featureDeclarations","styleVariationName","styleVariationDeclarations","duotoneStyles","duotoneDeclarations","pseudoSelectorStyles","pseudoKey","pseudoStyle","pseudoDeclarations","_selector","pseudoRule","toSvgFilters","getBlockSelectors","blockTypes","getBlockStyles","blockType","supports","__experimentalSelector","__experimentalDuotone","__experimentalLayout","__experimentalDefault","blockStyleVariations","featureKey","undefined","updateConfigWithSeparator","config","needsSeparatorStyleUpdate","background","text","border","processCSSNesting","css","processedCSS","parts","part","useGlobalStylesOutput","merged","mergedConfig","select","getSettings","customProperties","globalStyles","filters","stylesheets","isGlobalStyles"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,EAAcC,OAAd,EAAuBC,SAAvB,EAAkCC,GAAlC,QAA6C,QAA7C;AAEA;AACA;AACA;;AACA,SACCC,6BAA6B,IAAIC,cADlC,EAECC,uBAAuB,IAAIC,QAF5B,EAGCC,aAHD,EAICC,KAAK,IAAIC,WAJV,QAKO,mBALP;AAMA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,UAAT,EAAqBC,OAArB,QAAoC,oBAApC;AACA,SAASC,WAAT,QAA4B,yBAA5B;AAEA;AACA;AACA;;AACA,SAASC,eAAT,EAA0BC,mBA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AG,EAAES,gBADN;AAECI,MAAAA,cAAc,EAAE;AAFjB,KADmB,EAKnB;AACCb,MAAAA,GAAG,EAAEU,YADN;AAECG,MAAAA,cAAc,EAAE;AAFjB,KALmB,EASnB;AACA;AACCb,MAAAA,GAAG,2BAAEM,YAAY,CAACtE,MAAb,CAAoBgE,GAAtB,yEAA6B,EADjC;AAECa,MAAAA,cAAc,EAAE;AAFjB,KAVmB,CAApB,CAxBqB,CAwCrB;AACA;AACA;;AACA7M,IAAAA,aAAa,GAAG0C,OAAhB,CAA2BsI,SAAF,IAAiB;AAAA;;AACzC,oCAAKsB,YAAY,CAACtE,MAAb,CAAoBK,MAApB,CAA4B2C,SAAS,CAACnF,IAAtC,CAAL,mDAAK,uBAA8CmG,GAAnD,EAAyD;AAAA;;AACxD,cAAMzI,QAAQ,GAAGuE,cAAc,CAAEkD,SAAS,CAACnF,IAAZ,CAAd,CAAiCtC,QAAlD;AACAqJ,QAAAA,WAAW,CAAC/J,IAAZ,CAAkB;AACjBmJ,UAAAA,GAAG,EAAED,iBAAiB,2BACrBO,YAAY,CAACtE,MAAb,CAAoBK,MAApB,CAA4B2C,SAAS,CAACnF,IAAtC,CADqB,2DACrB,uBAA8CmG,GADzB,EAErBzI,QAFqB,CADL;AAKjBsJ,UAAAA,cAAc,EAAE;AALC,SAAlB;AAOA;AACD,KAXD;AAaA,WAAO,CAAED,WAAF,EAAeN,YAAY,CAAChG,QAA5B,EAAsCqG,OAAtC,CAAP;AACA,GAzDa,EAyDX,CACFlG,kBADE,EAEFC,qBAFE,EAGF4F,YAHE,EAIF7C,mBAJE,CAzDW,CAAd;AA+DA","sourcesContent":["/**\n * External dependencies\n */\nimport { get, isEmpty, kebabCase, set } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY,\n\t__EXPERIMENTAL_ELEMENTS as ELEMENTS,\n\tgetBlockTypes,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { useContext, useMemo } from '@wordpress/element';\nimport { getCSSRules } from '@wordpress/style-engine';\n\n/**\n * Internal dependencies\n */\nimport { PRESET_METADATA, ROOT_BLOCK_SELECTOR, scopeSelector } from './utils';\nimport { getTypographyFontSizeValue } from './typography-utils';\nimport { GlobalStylesContext } from './context';\nimport { useGlobalSetting } from './hooks';\nimport { PresetDuotoneFilter } from '../duotone/components';\nimport { getGapCSSValue } from '../../hooks/gap';\nimport { store as blockEditorStore } from '../../store';\n\n// List of block support features that can have their related styles\n// generated under their own feature level selector rather than the block's.\nconst BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = {\n\t__experimentalBorder: 'border',\n\tcolor: 'color',\n\tspacing: 'spacing',\n\ttypography: 'typography',\n};\n\nfunction compileStyleValue( uncompiledValue ) {\n\tconst VARIABLE_REFERENCE_PREFIX = 'var:';\n\tconst VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';\n\tconst VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';\n\n\tif ( uncompiledValue?.startsWith?.( VARIABLE_REFERENCE_PREFIX ) ) {\n\t\tconst variable = uncompiledValue\n\t\t\t.slice( VARIABLE_REFERENCE_PREFIX.length )\n\t\t\t.split( VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE )\n\t\t\t.join( VARIABLE_PATH_SEPARATOR_TOKEN_STYLE );\n\t\treturn `var(--wp--${ variable })`;\n\t}\n\treturn uncompiledValue;\n}\n\n/**\n * Transform given preset tree into a set of style declarations.\n *\n * @param {Object} blockPresets\n * @param {Object} mergedSettings Merged theme.json settings.\n *\n * @return {Array<Object>} An array of style declarations.\n */\nfunction getPresetsDeclarations( blockPresets = {}, mergedSettings ) {\n\treturn PRESET_METADATA.reduce(\n\t\t( declarations, { path, valueKey, valueFunc, cssVarInfix } ) => {\n\t\t\tconst presetByOrigin = get( blockPresets, path, [] );\n\t\t\t[ 'default', 'theme', 'custom' ].forEach( ( origin ) => {\n\t\t\t\tif ( presetByOrigin[ origin ] ) {\n\t\t\t\t\tpresetByOrigin[ origin ].forEach( ( value ) => {\n\t\t\t\t\t\tif ( valueKey && ! valueFunc ) {\n\t\t\t\t\t\t\tdeclarations.push(\n\t\t\t\t\t\t\t\t`--wp--preset--${ cssVarInfix }--${ kebabCase(\n\t\t\t\t\t\t\t\t\tvalue.slug\n\t\t\t\t\t\t\t\t) }: ${ value[ valueKey ] }`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\tvalueFunc &&\n\t\t\t\t\t\t\ttypeof valueFunc === 'function'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tdeclarations.push(\n\t\t\t\t\t\t\t\t`--wp--preset--${ cssVarInfix }--${ kebabCase(\n\t\t\t\t\t\t\t\t\tvalue.slug\n\t\t\t\t\t\t\t\t) }: ${ valueFunc( value, mergedSettings ) }`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\treturn declarations;\n\t\t},\n\t\t[]\n\t);\n}\n\n/**\n * Transform given preset tree into a set of preset class declarations.\n *\n * @param {string} blockSelector\n * @param {Object} blockPresets\n * @return {string} CSS declarations for the preset classes.\n */\nfunction getPresetsClasses( blockSelector, blockPresets = {} ) {\n\treturn PRESET_METADATA.reduce(\n\t\t( declarations, { path, cssVarInfix, classes } ) => {\n\t\t\tif ( ! classes ) {\n\t\t\t\treturn declarations;\n\t\t\t}\n\n\t\t\tconst presetByOrigin = get( blockPresets, path, [] );\n\t\t\t[ 'default', 'theme', 'custom' ].forEach( ( origin ) => {\n\t\t\t\tif ( presetByOrigin[ origin ] ) {\n\t\t\t\t\tpresetByOrigin[ origin ].forEach( ( { slug } ) => {\n\t\t\t\t\t\tclasses.forEach( ( { classSuffix, propertyName } ) => {\n\t\t\t\t\t\t\tconst classSelectorToUse = `.has-${ kebabCase(\n\t\t\t\t\t\t\t\tslug\n\t\t\t\t\t\t\t) }-${ classSuffix }`;\n\t\t\t\t\t\t\tconst selectorToUse = blockSelector\n\t\t\t\t\t\t\t\t.split( ',' ) // Selector can be \"h1, h2, h3\"\n\t\t\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\t\t\t( selector ) =>\n\t\t\t\t\t\t\t\t\t\t`${ selector }${ classSelectorToUse }`\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t.join( ',' );\n\t\t\t\t\t\t\tconst value = `var(--wp--preset--${ cssVarInfix }--${ kebabCase(\n\t\t\t\t\t\t\t\tslug\n\t\t\t\t\t\t\t) })`;\n\t\t\t\t\t\t\tdeclarations += `${ selectorToUse }{${ propertyName }: ${ value } !important;}`;\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\t\t\treturn declarations;\n\t\t},\n\t\t''\n\t);\n}\n\nfunction getPresetsSvgFilters( blockPresets = {} ) {\n\treturn PRESET_METADATA.filter(\n\t\t// Duotone are the only type of filters for now.\n\t\t( metadata ) => metadata.path.at( -1 ) === 'duotone'\n\t).flatMap( ( metadata ) => {\n\t\tconst presetByOrigin = get( blockPresets, metadata.path, {} );\n\t\treturn [ 'default', 'theme' ]\n\t\t\t.filter( ( origin ) => presetByOrigin[ origin ] )\n\t\t\t.flatMap( ( origin ) =>\n\t\t\t\tpresetByOrigin[ origin ].map( ( preset ) => (\n\t\t\t\t\t<PresetDuotoneFilter\n\t\t\t\t\t\tpreset={ preset }\n\t\t\t\t\t\tkey={ preset.slug }\n\t\t\t\t\t/>\n\t\t\t\t) )\n\t\t\t);\n\t} );\n}\n\nfunction flattenTree( input = {}, prefix, token ) {\n\tlet result = [];\n\tObject.keys( input ).forEach( ( key ) => {\n\t\tconst newKey = prefix + kebabCase( key.replace( '/', '-' ) );\n\t\tconst newLeaf = input[ key ];\n\n\t\tif ( newLeaf instanceof Object ) {\n\t\t\tconst newPrefix = newKey + token;\n\t\t\tresult = [ ...result, ...flattenTree( newLeaf, newPrefix, token ) ];\n\t\t} else {\n\t\t\tresult.push( `${ newKey }: ${ newLeaf }` );\n\t\t}\n\t} );\n\treturn result;\n}\n\n/**\n * Gets variation selector string from feature selector.\n *\n * @param {string} featureSelector The feature selector.\n *\n * @param {string} styleVariationSelector The style variation selector.\n * @return {string} Combined selector string.\n *\n */\nfunction concatFeatureVariationSelectorString(\n\tfeatureSelector,\n\tstyleVariationSelector\n) {\n\tconst featureSelectors = featureSelector.split( ',' );\n\tconst combinedSelectors = [];\n\tfeatureSelectors.forEach( ( selector ) => {\n\t\tcombinedSelectors.push(\n\t\t\t`${ styleVariationSelector.trim() }${ selector.trim() }`\n\t\t);\n\t} );\n\treturn combinedSelectors.join( ', ' );\n}\n\n/**\n * Transform given style tree into a set of style declarations.\n *\n * @param {Object} blockStyles Block styles.\n *\n * @param {string} selector The selector these declarations should attach to.\n *\n * @param {boolean} useRootPaddingAlign Whether to use CSS custom properties in root selector.\n *\n * @param {Object} tree A theme.json tree containing layout definitions.\n *\n * @return {Array} An array of style declarations.\n */\nexport function getStylesDeclarations(\n\tblockStyles = {},\n\tselector = '',\n\tuseRootPaddingAlign,\n\ttree = {}\n) {\n\tconst isRoot = ROOT_BLOCK_SELECTOR === selector;\n\tconst output = Object.entries( STYLE_PROPERTY ).reduce(\n\t\t(\n\t\t\tdeclarations,\n\t\t\t[ key, { value, properties, useEngine, rootOnly } ]\n\t\t) => {\n\t\t\tif ( rootOnly && ! isRoot ) {\n\t\t\t\treturn declarations;\n\t\t\t}\n\t\t\tconst pathToValue = value;\n\t\t\tif ( pathToValue[ 0 ] === 'elements' || useEngine ) {\n\t\t\t\treturn declarations;\n\t\t\t}\n\n\t\t\tconst styleValue = get( blockStyles, pathToValue );\n\n\t\t\t// Root-level padding styles don't currently support strings with CSS shorthand values.\n\t\t\t// This may change: https://github.com/WordPress/gutenberg/issues/40132.\n\t\t\tif (\n\t\t\t\tkey === '--wp--style--root--padding' &&\n\t\t\t\t( typeof styleValue === 'string' || ! useRootPaddingAlign )\n\t\t\t) {\n\t\t\t\treturn declarations;\n\t\t\t}\n\n\t\t\tif ( !! properties && typeof styleValue !== 'string' ) {\n\t\t\t\tObject.entries( properties ).forEach( ( entry ) => {\n\t\t\t\t\tconst [ name, prop ] = entry;\n\n\t\t\t\t\tif ( ! get( styleValue, [ prop ], false ) ) {\n\t\t\t\t\t\t// Do not create a declaration\n\t\t\t\t\t\t// for sub-properties that don't have any value.\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst cssProperty = name.startsWith( '--' )\n\t\t\t\t\t\t? name\n\t\t\t\t\t\t: kebabCase( name );\n\t\t\t\t\tdeclarations.push(\n\t\t\t\t\t\t`${ cssProperty }: ${ compileStyleValue(\n\t\t\t\t\t\t\tget( styleValue, [ prop ] )\n\t\t\t\t\t\t) }`\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t} else if ( get( blockStyles, pathToValue, false ) ) {\n\t\t\t\tconst cssProperty = key.startsWith( '--' )\n\t\t\t\t\t? key\n\t\t\t\t\t: kebabCase( key );\n\t\t\t\tdeclarations.push(\n\t\t\t\t\t`${ cssProperty }: ${ compileStyleValue(\n\t\t\t\t\t\tget( blockStyles, pathToValue )\n\t\t\t\t\t) }`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn declarations;\n\t\t},\n\t\t[]\n\t);\n\n\t// The goal is to move everything to server side generated engine styles\n\t// This is temporary as we absorb more and more styles into the engine.\n\tconst extraRules = getCSSRules( blockStyles );\n\textraRules.forEach( ( rule ) => {\n\t\t// Don't output padding properties if padding variables are set.\n\t\tif (\n\t\t\tisRoot &&\n\t\t\tuseRootPaddingAlign &&\n\t\t\trule.key.startsWith( 'padding' )\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst cssProperty = rule.key.startsWith( '--' )\n\t\t\t? rule.key\n\t\t\t: kebabCase( rule.key );\n\n\t\tlet ruleValue = rule.value;\n\t\tif ( typeof ruleValue !== 'string' && ruleValue?.ref ) {\n\t\t\tconst refPath = ruleValue.ref.split( '.' );\n\t\t\truleValue = get( tree, refPath );\n\t\t\t// Presence of another ref indicates a reference to another dynamic value.\n\t\t\t// Pointing to another dynamic value is not supported.\n\t\t\tif ( ! ruleValue || !! ruleValue?.ref ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// Calculate fluid typography rules where available.\n\t\tif ( cssProperty === 'font-size' ) {\n\t\t\t/*\n\t\t\t * getTypographyFontSizeValue() will check\n\t\t\t * if fluid typography has been activated and also\n\t\t\t * whether the incoming value can be converted to a fluid value.\n\t\t\t * Values that already have a \"clamp()\" function will not pass the test,\n\t\t\t * and therefore the original $value will be returned.\n\t\t\t */\n\t\t\truleValue = getTypographyFontSizeValue(\n\t\t\t\t{ size: ruleValue },\n\t\t\t\ttree?.settings?.typography\n\t\t\t);\n\t\t}\n\n\t\toutput.push( `${ cssProperty }: ${ ruleValue }` );\n\t} );\n\n\treturn output;\n}\n\n/**\n * Get generated CSS for layout styles by looking up layout definitions provided\n * in theme.json, and outputting common layout styles, and specific blockGap values.\n *\n * @param {Object} props\n * @param {Object} props.tree A theme.json tree containing layout definitions.\n * @param {Object} props.style A style object containing spacing values.\n * @param {string} props.selector Selector used to group together layout styling rules.\n * @param {boolean} props.hasBlockGapSupport Whether or not the theme opts-in to blockGap support.\n * @param {boolean} props.hasFallbackGapSupport Whether or not the theme allows fallback gap styles.\n * @param {?string} props.fallbackGapValue An optional fallback gap value if no real gap value is available.\n * @return {string} Generated CSS rules for the layout styles.\n */\nexport function getLayoutStyles( {\n\ttree,\n\tstyle,\n\tselector,\n\thasBlockGapSupport,\n\thasFallbackGapSupport,\n\tfallbackGapValue,\n} ) {\n\tlet ruleset = '';\n\tlet gapValue = hasBlockGapSupport\n\t\t? getGapCSSValue( style?.spacing?.blockGap )\n\t\t: '';\n\n\t// Ensure a fallback gap value for the root layout definitions,\n\t// and use a fallback value if one is provided for the current block.\n\tif ( hasFallbackGapSupport ) {\n\t\tif ( selector === ROOT_BLOCK_SELECTOR ) {\n\t\t\tgapValue = ! gapValue ? '0.5em' : gapValue;\n\t\t} else if ( ! hasBlockGapSupport && fallbackGapValue ) {\n\t\t\tgapValue = fallbackGapValue;\n\t\t}\n\t}\n\n\tif ( gapValue && tree?.settings?.layout?.definitions ) {\n\t\tObject.values( tree.settings.layout.definitions ).forEach(\n\t\t\t( { className, name, spacingStyles } ) => {\n\t\t\t\t// Allow outputting fallback gap styles for flex layout type when block gap support isn't available.\n\t\t\t\tif ( ! hasBlockGapSupport && 'flex' !== name ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( spacingStyles?.length ) {\n\t\t\t\t\tspacingStyles.forEach( ( spacingStyle ) => {\n\t\t\t\t\t\tconst declarations = [];\n\n\t\t\t\t\t\tif ( spacingStyle.rules ) {\n\t\t\t\t\t\t\tObject.entries( spacingStyle.rules ).forEach(\n\t\t\t\t\t\t\t\t( [ cssProperty, cssValue ] ) => {\n\t\t\t\t\t\t\t\t\tdeclarations.push(\n\t\t\t\t\t\t\t\t\t\t`${ cssProperty }: ${\n\t\t\t\t\t\t\t\t\t\t\tcssValue ? cssValue : gapValue\n\t\t\t\t\t\t\t\t\t\t}`\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( declarations.length ) {\n\t\t\t\t\t\t\tlet combinedSelector = '';\n\n\t\t\t\t\t\t\tif ( ! hasBlockGapSupport ) {\n\t\t\t\t\t\t\t\t// For fallback gap styles, use lower specificity, to ensure styles do not unintentionally override theme styles.\n\t\t\t\t\t\t\t\tcombinedSelector =\n\t\t\t\t\t\t\t\t\tselector === ROOT_BLOCK_SELECTOR\n\t\t\t\t\t\t\t\t\t\t? `:where(.${ className }${\n\t\t\t\t\t\t\t\t\t\t\t\tspacingStyle?.selector || ''\n\t\t\t\t\t\t\t\t\t\t })`\n\t\t\t\t\t\t\t\t\t\t: `:where(${ selector }.${ className }${\n\t\t\t\t\t\t\t\t\t\t\t\tspacingStyle?.selector || ''\n\t\t\t\t\t\t\t\t\t\t })`;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcombinedSelector =\n\t\t\t\t\t\t\t\t\tselector === ROOT_BLOCK_SELECTOR\n\t\t\t\t\t\t\t\t\t\t? `${ selector } .${ className }${\n\t\t\t\t\t\t\t\t\t\t\t\tspacingStyle?.selector || ''\n\t\t\t\t\t\t\t\t\t\t }`\n\t\t\t\t\t\t\t\t\t\t: `${ selector }.${ className }${\n\t\t\t\t\t\t\t\t\t\t\t\tspacingStyle?.selector || ''\n\t\t\t\t\t\t\t\t\t\t }`;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\truleset += `${ combinedSelector } { ${ declarations.join(\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\t\t\t\t}\n\t\t\t}\n\t\t);\n\t\t// For backwards compatibility, ensure the legacy block gap CSS variable is still available.\n\t\tif ( selector === ROOT_BLOCK_SELECTOR && hasBlockGapSupport ) {\n\t\t\truleset += `${ selector } { --wp--style--block-gap: ${ gapValue }; }`;\n\t\t}\n\t}\n\n\t// Output base styles\n\tif (\n\t\tselector === ROOT_BLOCK_SELECTOR &&\n\t\ttree?.settings?.layout?.definitions\n\t) {\n\t\tconst validDisplayModes = [ 'block', 'flex', 'grid' ];\n\t\tObject.values( tree.settings.layout.definitions ).forEach(\n\t\t\t( { className, displayMode, baseStyles } ) => {\n\t\t\t\tif (\n\t\t\t\t\tdisplayMode &&\n\t\t\t\t\tvalidDisplayModes.includes( displayMode )\n\t\t\t\t) {\n\t\t\t\t\truleset += `${ selector } .${ className } { display:${ displayMode }; }`;\n\t\t\t\t}\n\n\t\t\t\tif ( baseStyles?.length ) {\n\t\t\t\t\tbaseStyles.forEach( ( baseStyle ) => {\n\t\t\t\t\t\tconst declarations = [];\n\n\t\t\t\t\t\tif ( baseStyle.rules ) {\n\t\t\t\t\t\t\tObject.entries( baseStyle.rules ).forEach(\n\t\t\t\t\t\t\t\t( [ cssProperty, cssValue ] ) => {\n\t\t\t\t\t\t\t\t\tdeclarations.push(\n\t\t\t\t\t\t\t\t\t\t`${ cssProperty }: ${ cssValue }`\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( declarations.length ) {\n\t\t\t\t\t\t\tconst combinedSelector = `${ selector } .${ className }${\n\t\t\t\t\t\t\t\tbaseStyle?.selector || ''\n\t\t\t\t\t\t\t}`;\n\t\t\t\t\t\t\truleset += `${ combinedSelector } { ${ declarations.join(\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\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\treturn ruleset;\n}\n\nexport const getNodesWithStyles = ( tree, blockSelectors ) => {\n\tconst nodes = [];\n\n\tif ( ! tree?.styles ) {\n\t\treturn nodes;\n\t}\n\n\tconst pickStyleKeys = ( treeToPickFrom ) =>\n\t\tObject.fromEntries(\n\t\t\tObject.entries( treeToPickFrom ?? {} ).filter( ( [ key ] ) =>\n\t\t\t\t[\n\t\t\t\t\t'border',\n\t\t\t\t\t'color',\n\t\t\t\t\t'dimensions',\n\t\t\t\t\t'spacing',\n\t\t\t\t\t'typography',\n\t\t\t\t\t'filter',\n\t\t\t\t\t'outline',\n\t\t\t\t\t'shadow',\n\t\t\t\t].includes( key )\n\t\t\t)\n\t\t);\n\n\t// Top-level.\n\tconst styles = pickStyleKeys( tree.styles );\n\tif ( !! styles ) {\n\t\tnodes.push( {\n\t\t\tstyles,\n\t\t\tselector: ROOT_BLOCK_SELECTOR,\n\t\t} );\n\t}\n\n\tObject.entries( ELEMENTS ).forEach( ( [ name, selector ] ) => {\n\t\tif ( !! tree.styles?.elements[ name ] ) {\n\t\t\tnodes.push( {\n\t\t\t\tstyles: tree.styles?.elements[ name ],\n\t\t\t\tselector,\n\t\t\t} );\n\t\t}\n\t} );\n\n\t// Iterate over blocks: they can have styles & elements.\n\tObject.entries( tree.styles?.blocks ?? {} ).forEach(\n\t\t( [ blockName, node ] ) => {\n\t\t\tconst blockStyles = pickStyleKeys( node );\n\n\t\t\tif ( node?.variations ) {\n\t\t\t\tconst variations = {};\n\t\t\t\tObject.keys( node.variations ).forEach( ( variation ) => {\n\t\t\t\t\tvariations[ variation ] = pickStyleKeys(\n\t\t\t\t\t\tnode.variations[ variation ]\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t\tblockStyles.variations = variations;\n\t\t\t}\n\t\t\tif (\n\t\t\t\t!! blockStyles &&\n\t\t\t\t!! blockSelectors?.[ blockName ]?.selector\n\t\t\t) {\n\t\t\t\tnodes.push( {\n\t\t\t\t\tduotoneSelector:\n\t\t\t\t\t\tblockSelectors[ blockName ].duotoneSelector,\n\t\t\t\t\tfallbackGapValue:\n\t\t\t\t\t\tblockSelectors[ blockName ].fallbackGapValue,\n\t\t\t\t\thasLayoutSupport:\n\t\t\t\t\t\tblockSelectors[ blockName ].hasLayoutSupport,\n\t\t\t\t\tselector: blockSelectors[ blockName ].selector,\n\t\t\t\t\tstyles: blockStyles,\n\t\t\t\t\tfeatureSelectors:\n\t\t\t\t\t\tblockSelectors[ blockName ].featureSelectors,\n\t\t\t\t\tstyleVariationSelectors:\n\t\t\t\t\t\tblockSelectors[ blockName ].styleVariationSelectors,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tObject.entries( node?.elements ?? {} ).forEach(\n\t\t\t\t( [ elementName, value ] ) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\t!! value &&\n\t\t\t\t\t\t!! blockSelectors?.[ blockName ] &&\n\t\t\t\t\t\t!! ELEMENTS?.[ elementName ]\n\t\t\t\t\t) {\n\t\t\t\t\t\tnodes.push( {\n\t\t\t\t\t\t\tstyles: value,\n\t\t\t\t\t\t\tselector: blockSelectors[ blockName ].selector\n\t\t\t\t\t\t\t\t.split( ',' )\n\t\t\t\t\t\t\t\t.map( ( sel ) => {\n\t\t\t\t\t\t\t\t\tconst elementSelectors =\n\t\t\t\t\t\t\t\t\t\tELEMENTS[ elementName ].split( ',' );\n\t\t\t\t\t\t\t\t\treturn elementSelectors.map(\n\t\t\t\t\t\t\t\t\t\t( elementSelector ) =>\n\t\t\t\t\t\t\t\t\t\t\tsel + ' ' + elementSelector\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\t.join( ',' ),\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n\n\treturn nodes;\n};\n\nexport const getNodesWithSettings = ( tree, blockSelectors ) => {\n\tconst nodes = [];\n\n\tif ( ! tree?.settings ) {\n\t\treturn nodes;\n\t}\n\n\tconst pickPresets = ( treeToPickFrom ) => {\n\t\tconst presets = {};\n\t\tPRESET_METADATA.forEach( ( { path } ) => {\n\t\t\tconst value = get( treeToPickFrom, path, false );\n\t\t\tif ( value !== false ) {\n\t\t\t\tset( presets, path, value );\n\t\t\t}\n\t\t} );\n\t\treturn presets;\n\t};\n\n\t// Top-level.\n\tconst presets = pickPresets( tree.settings );\n\tconst custom = tree.settings?.custom;\n\tif ( ! isEmpty( presets ) || !! custom ) {\n\t\tnodes.push( {\n\t\t\tpresets,\n\t\t\tcustom,\n\t\t\tselector: ROOT_BLOCK_SELECTOR,\n\t\t} );\n\t}\n\n\t// Blocks.\n\tObject.entries( tree.settings?.blocks ?? {} ).forEach(\n\t\t( [ blockName, node ] ) => {\n\t\t\tconst blockPresets = pickPresets( node );\n\t\t\tconst blockCustom = node.custom;\n\t\t\tif ( ! isEmpty( blockPresets ) || !! blockCustom ) {\n\t\t\t\tnodes.push( {\n\t\t\t\t\tpresets: blockPresets,\n\t\t\t\t\tcustom: blockCustom,\n\t\t\t\t\tselector: blockSelectors[ blockName ].selector,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t);\n\n\treturn nodes;\n};\n\nexport const toCustomProperties = ( tree, blockSelectors ) => {\n\tconst settings = getNodesWithSettings( tree, blockSelectors );\n\tlet ruleset = '';\n\tsettings.forEach( ( { presets, custom, selector } ) => {\n\t\tconst declarations = getPresetsDeclarations( presets, tree?.settings );\n\t\tconst customProps = flattenTree( custom, '--wp--custom--', '--' );\n\t\tif ( customProps.length > 0 ) {\n\t\t\tdeclarations.push( ...customProps );\n\t\t}\n\n\t\tif ( declarations.length > 0 ) {\n\t\t\truleset = ruleset + `${ selector }{${ declarations.join( ';' ) };}`;\n\t\t}\n\t} );\n\n\treturn ruleset;\n};\n\nexport const toStyles = (\n\ttree,\n\tblockSelectors,\n\thasBlockGapSupport,\n\thasFallbackGapSupport,\n\tdisableLayoutStyles = false\n) => {\n\tconst nodesWithStyles = getNodesWithStyles( tree, blockSelectors );\n\tconst nodesWithSettings = getNodesWithSettings( tree, blockSelectors );\n\tconst useRootPaddingAlign = tree?.settings?.useRootPaddingAwareAlignments;\n\tconst { contentSize, wideSize } = tree?.settings?.layout || {};\n\n\t/*\n\t * Reset default browser margin on the root body element.\n\t * This is set on the root selector **before** generating the ruleset\n\t * from the `theme.json`. This is to ensure that if the `theme.json` declares\n\t * `margin` in its `spacing` declaration for the `body` element then these\n\t * user-generated values take precedence in the CSS cascade.\n\t * @link https://github.com/WordPress/gutenberg/issues/36147.\n\t */\n\tlet ruleset = 'body {margin: 0;';\n\n\tif ( contentSize ) {\n\t\truleset += ` --wp--style--global--content-size: ${ contentSize };`;\n\t}\n\n\tif ( wideSize ) {\n\t\truleset += ` --wp--style--global--wide-size: ${ wideSize };`;\n\t}\n\n\tif ( useRootPaddingAlign ) {\n\t\t/*\n\t\t * These rules reproduce the ones from https://github.com/WordPress/gutenberg/blob/79103f124925d1f457f627e154f52a56228ed5ad/lib/class-wp-theme-json-gutenberg.php#L2508\n\t\t * almost exactly, but for the selectors that target block wrappers in the front end. This code only runs in the editor, so it doesn't need those selectors.\n\t\t */\n\t\truleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) }\n\t\t\t.has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }\n\t\t\t.has-global-padding :where(.has-global-padding) { padding-right: 0; padding-left: 0; }\n\t\t\t.has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }\n\t\t\t.has-global-padding :where(.has-global-padding) > .alignfull { margin-right: 0; margin-left: 0; }\n\t\t\t.has-global-padding > .alignfull:where(:not(.has-global-padding)) > :where(.wp-block:not(.alignfull),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }\n\t\t\t.has-global-padding :where(.has-global-padding) > .alignfull:where(:not(.has-global-padding)) > :where(.wp-block:not(.alignfull),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: 0; padding-left: 0;`;\n\t}\n\n\truleset += '}';\n\n\tnodesWithStyles.forEach(\n\t\t( {\n\t\t\tselector,\n\t\t\tduotoneSelector,\n\t\t\tstyles,\n\t\t\tfallbackGapValue,\n\t\t\thasLayoutSupport,\n\t\t\tfeatureSelectors,\n\t\t\tstyleVariationSelectors,\n\t\t} ) => {\n\t\t\t// Process styles for block support features with custom feature level\n\t\t\t// CSS selectors set.\n\t\t\tif ( featureSelectors ) {\n\t\t\t\tObject.entries( featureSelectors ).forEach(\n\t\t\t\t\t( [ featureName, featureSelector ] ) => {\n\t\t\t\t\t\tif ( styles?.[ featureName ] ) {\n\t\t\t\t\t\t\tconst featureStyles = {\n\t\t\t\t\t\t\t\t[ featureName ]: styles[ featureName ],\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tconst featureDeclarations =\n\t\t\t\t\t\t\t\tgetStylesDeclarations( featureStyles );\n\t\t\t\t\t\t\tdelete styles[ featureName ];\n\n\t\t\t\t\t\t\tif ( !! featureDeclarations.length ) {\n\t\t\t\t\t\t\t\truleset =\n\t\t\t\t\t\t\t\t\truleset +\n\t\t\t\t\t\t\t\t\t`${ featureSelector }{${ featureDeclarations.join(\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}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif ( styleVariationSelectors ) {\n\t\t\t\tObject.entries( styleVariationSelectors ).forEach(\n\t\t\t\t\t( [ styleVariationName, styleVariationSelector ] ) => {\n\t\t\t\t\t\tif ( styles?.variations?.[ styleVariationName ] ) {\n\t\t\t\t\t\t\t// If the block uses any custom selectors for block support, add those first.\n\t\t\t\t\t\t\tif ( featureSelectors ) {\n\t\t\t\t\t\t\t\tObject.entries( featureSelectors ).forEach(\n\t\t\t\t\t\t\t\t\t( [ featureName, featureSelector ] ) => {\n\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\tstyles?.variations?.[\n\t\t\t\t\t\t\t\t\t\t\t\tstyleVariationName\n\t\t\t\t\t\t\t\t\t\t\t]?.[ featureName ]\n\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\tconst featureStyles = {\n\t\t\t\t\t\t\t\t\t\t\t\t[ featureName ]:\n\t\t\t\t\t\t\t\t\t\t\t\t\tstyles.variations[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tstyleVariationName\n\t\t\t\t\t\t\t\t\t\t\t\t\t][ featureName ],\n\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t\tconst featureDeclarations =\n\t\t\t\t\t\t\t\t\t\t\t\tgetStylesDeclarations(\n\t\t\t\t\t\t\t\t\t\t\t\t\tfeatureStyles\n\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\tdelete styles.variations[\n\t\t\t\t\t\t\t\t\t\t\t\tstyleVariationName\n\t\t\t\t\t\t\t\t\t\t\t][ featureName ];\n\n\t\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t\t!! featureDeclarations.length\n\t\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\t\truleset =\n\t\t\t\t\t\t\t\t\t\t\t\t\truleset +\n\t\t\t\t\t\t\t\t\t\t\t\t\t`${ concatFeatureVariationSelectorString(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tfeatureSelector,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tstyleVariationSelector\n\t\t\t\t\t\t\t\t\t\t\t\t\t) }{${ featureDeclarations.join(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t';'\n\t\t\t\t\t\t\t\t\t\t\t\t\t) } }`;\n\t\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}\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Otherwise add regular selectors.\n\t\t\t\t\t\t\tconst styleVariationDeclarations =\n\t\t\t\t\t\t\t\tgetStylesDeclarations(\n\t\t\t\t\t\t\t\t\tstyles?.variations?.[ styleVariationName ],\n\t\t\t\t\t\t\t\t\tstyleVariationSelector,\n\t\t\t\t\t\t\t\t\tuseRootPaddingAlign,\n\t\t\t\t\t\t\t\t\ttree\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif ( !! styleVariationDeclarations.length ) {\n\t\t\t\t\t\t\t\truleset =\n\t\t\t\t\t\t\t\t\truleset +\n\t\t\t\t\t\t\t\t\t`${ styleVariationSelector }{${ styleVariationDeclarations.join(\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}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst duotoneStyles = {};\n\t\t\tif ( styles?.filter ) {\n\t\t\t\tduotoneStyles.filter = styles.filter;\n\t\t\t\tdelete styles.filter;\n\t\t\t}\n\n\t\t\t// Process duotone styles (they use color.__experimentalDuotone selector).\n\t\t\tif ( duotoneSelector ) {\n\t\t\t\tconst duotoneDeclarations =\n\t\t\t\t\tgetStylesDeclarations( duotoneStyles );\n\t\t\t\tif ( duotoneDeclarations.length > 0 ) {\n\t\t\t\t\truleset =\n\t\t\t\t\t\truleset +\n\t\t\t\t\t\t`${ scopeSelector(\n\t\t\t\t\t\t\tselector,\n\t\t\t\t\t\t\tduotoneSelector\n\t\t\t\t\t\t) }{${ duotoneDeclarations.join( ';' ) };}`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Process blockGap and layout styles.\n\t\t\tif (\n\t\t\t\t! disableLayoutStyles &&\n\t\t\t\t( ROOT_BLOCK_SELECTOR === selector || hasLayoutSupport )\n\t\t\t) {\n\t\t\t\truleset += getLayoutStyles( {\n\t\t\t\t\ttree,\n\t\t\t\t\tstyle: styles,\n\t\t\t\t\tselector,\n\t\t\t\t\thasBlockGapSupport,\n\t\t\t\t\thasFallbackGapSupport,\n\t\t\t\t\tfallbackGapValue,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\t// Process the remaining block styles (they use either normal block class or __experimentalSelector).\n\t\t\tconst declarations = getStylesDeclarations(\n\t\t\t\tstyles,\n\t\t\t\tselector,\n\t\t\t\tuseRootPaddingAlign,\n\t\t\t\ttree\n\t\t\t);\n\t\t\tif ( declarations?.length ) {\n\t\t\t\truleset =\n\t\t\t\t\truleset + `${ selector }{${ declarations.join( ';' ) };}`;\n\t\t\t}\n\n\t\t\t// Check for pseudo selector in `styles` and handle separately.\n\t\t\tconst pseudoSelectorStyles = Object.entries( styles ).filter(\n\t\t\t\t( [ key ] ) => key.startsWith( ':' )\n\t\t\t);\n\n\t\t\tif ( pseudoSelectorStyles?.length ) {\n\t\t\t\tpseudoSelectorStyles.forEach(\n\t\t\t\t\t( [ pseudoKey, pseudoStyle ] ) => {\n\t\t\t\t\t\tconst pseudoDeclarations =\n\t\t\t\t\t\t\tgetStylesDeclarations( pseudoStyle );\n\n\t\t\t\t\t\tif ( ! pseudoDeclarations?.length ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// `selector` maybe provided in a form\n\t\t\t\t\t\t// where block level selectors have sub element\n\t\t\t\t\t\t// selectors appended to them as a comma separated\n\t\t\t\t\t\t// string.\n\t\t\t\t\t\t// e.g. `h1 a,h2 a,h3 a,h4 a,h5 a,h6 a`;\n\t\t\t\t\t\t// Split and append pseudo selector to create\n\t\t\t\t\t\t// the proper rules to target the elements.\n\t\t\t\t\t\tconst _selector = selector\n\t\t\t\t\t\t\t.split( ',' )\n\t\t\t\t\t\t\t.map( ( sel ) => sel + pseudoKey )\n\t\t\t\t\t\t\t.join( ',' );\n\n\t\t\t\t\t\tconst pseudoRule = `${ _selector }{${ pseudoDeclarations.join(\n\t\t\t\t\t\t\t';'\n\t\t\t\t\t\t) };}`;\n\n\t\t\t\t\t\truleset = ruleset + pseudoRule;\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t);\n\n\t/* Add alignment / layout styles */\n\truleset =\n\t\truleset +\n\t\t'.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }';\n\truleset =\n\t\truleset +\n\t\t'.wp-site-blocks > .alignright { float: right; margin-left: 2em; }';\n\truleset =\n\t\truleset +\n\t\t'.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }';\n\n\tif ( hasBlockGapSupport ) {\n\t\t// Use fallback of `0.5em` just in case, however if there is blockGap support, there should nearly always be a real value.\n\t\tconst gapValue =\n\t\t\tgetGapCSSValue( tree?.styles?.spacing?.blockGap ) || '0.5em';\n\t\truleset =\n\t\t\truleset +\n\t\t\t'.wp-site-blocks > * { margin-block-start: 0; margin-block-end: 0; }';\n\t\truleset =\n\t\t\truleset +\n\t\t\t`.wp-site-blocks > * + * { margin-block-start: ${ gapValue }; }`;\n\t}\n\n\tnodesWithSettings.forEach( ( { selector, presets } ) => {\n\t\tif ( ROOT_BLOCK_SELECTOR === selector ) {\n\t\t\t// Do not add extra specificity for top-level classes.\n\t\t\tselector = '';\n\t\t}\n\n\t\tconst classes = getPresetsClasses( selector, presets );\n\t\tif ( ! isEmpty( classes ) ) {\n\t\t\truleset = ruleset + classes;\n\t\t}\n\t} );\n\n\treturn ruleset;\n};\n\nexport function toSvgFilters( tree, blockSelectors ) {\n\tconst nodesWithSettings = getNodesWithSettings( tree, blockSelectors );\n\treturn nodesWithSettings.flatMap( ( { presets } ) => {\n\t\treturn getPresetsSvgFilters( presets );\n\t} );\n}\n\nexport const getBlockSelectors = ( blockTypes, getBlockStyles ) => {\n\tconst result = {};\n\tblockTypes.forEach( ( blockType ) => {\n\t\tconst name = blockType.name;\n\t\tconst selector =\n\t\t\tblockType?.supports?.__experimentalSelector ??\n\t\t\t'.wp-block-' + name.replace( 'core/', '' ).replace( '/', '-' );\n\t\tconst duotoneSelector =\n\t\t\tblockType?.supports?.color?.__experimentalDuotone ?? null;\n\t\tconst hasLayoutSupport = !! blockType?.supports?.__experimentalLayout;\n\t\tconst fallbackGapValue =\n\t\t\tblockType?.supports?.spacing?.blockGap?.__experimentalDefault;\n\n\t\tconst blockStyleVariations = getBlockStyles( name );\n\t\tconst styleVariationSelectors = {};\n\t\tif ( blockStyleVariations?.length ) {\n\t\t\tblockStyleVariations.forEach( ( variation ) => {\n\t\t\t\tconst styleVariationSelector = `.is-style-${ variation.name }${ selector }`;\n\t\t\t\tstyleVariationSelectors[ variation.name ] =\n\t\t\t\t\tstyleVariationSelector;\n\t\t\t} );\n\t\t}\n\t\t// For each block support feature add any custom selectors.\n\t\tconst featureSelectors = {};\n\t\tObject.entries( BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS ).forEach(\n\t\t\t( [ featureKey, featureName ] ) => {\n\t\t\t\tconst featureSelector =\n\t\t\t\t\tblockType?.supports?.[ featureKey ]?.__experimentalSelector;\n\n\t\t\t\tif ( featureSelector ) {\n\t\t\t\t\tfeatureSelectors[ featureName ] = scopeSelector(\n\t\t\t\t\t\tselector,\n\t\t\t\t\t\tfeatureSelector\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\tresult[ name ] = {\n\t\t\tduotoneSelector,\n\t\t\tfallbackGapValue,\n\t\t\tfeatureSelectors: Object.keys( featureSelectors ).length\n\t\t\t\t? featureSelectors\n\t\t\t\t: undefined,\n\t\t\thasLayoutSupport,\n\t\t\tname,\n\t\t\tselector,\n\t\t\tstyleVariationSelectors: Object.keys( styleVariationSelectors )\n\t\t\t\t.length\n\t\t\t\t? styleVariationSelectors\n\t\t\t\t: undefined,\n\t\t};\n\t} );\n\n\treturn result;\n};\n\n/**\n * If there is a separator block whose color is defined in theme.json via background,\n * update the separator color to the same value by using border color.\n *\n * @param {Object} config Theme.json configuration file object.\n * @return {Object} configTheme.json configuration file object updated.\n */\nfunction updateConfigWithSeparator( config ) {\n\tconst needsSeparatorStyleUpdate =\n\t\tconfig.styles?.blocks[ 'core/separator' ] &&\n\t\tconfig.styles?.blocks[ 'core/separator' ].color?.background &&\n\t\t! config.styles?.blocks[ 'core/separator' ].color?.text &&\n\t\t! config.styles?.blocks[ 'core/separator' ].border?.color;\n\tif ( needsSeparatorStyleUpdate ) {\n\t\treturn {\n\t\t\t...config,\n\t\t\tstyles: {\n\t\t\t\t...config.styles,\n\t\t\t\tblocks: {\n\t\t\t\t\t...config.styles.blocks,\n\t\t\t\t\t'core/separator': {\n\t\t\t\t\t\t...config.styles.blocks[ 'core/separator' ],\n\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t...config.styles.blocks[ 'core/separator' ].color,\n\t\t\t\t\t\t\ttext: config.styles?.blocks[ 'core/separator' ]\n\t\t\t\t\t\t\t\t.color.background,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\treturn config;\n}\n\nconst processCSSNesting = ( css, blockSelector ) => {\n\tlet processedCSS = '';\n\n\t// Split CSS nested rules.\n\tconst parts = css.split( '&' );\n\tparts.forEach( ( part ) => {\n\t\tprocessedCSS += ! part.includes( '{' )\n\t\t\t? blockSelector + '{' + part + '}' // If the part doesn't contain braces, it applies to the root level.\n\t\t\t: blockSelector + part; // Prepend the selector, which effectively replaces the \"&\" character.\n\t} );\n\treturn processedCSS;\n};\n\nexport function useGlobalStylesOutput() {\n\tlet { merged: mergedConfig } = useContext( GlobalStylesContext );\n\n\tconst [ blockGap ] = useGlobalSetting( 'spacing.blockGap' );\n\tconst hasBlockGapSupport = blockGap !== null;\n\tconst hasFallbackGapSupport = ! hasBlockGapSupport; // This setting isn't useful yet: it exists as a placeholder for a future explicit fallback styles support.\n\tconst disableLayoutStyles = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn !! getSettings().disableLayoutStyles;\n\t} );\n\n\tconst getBlockStyles = useSelect( ( select ) => {\n\t\treturn select( blocksStore ).getBlockStyles;\n\t}, [] );\n\n\treturn useMemo( () => {\n\t\tif ( ! mergedConfig?.styles || ! mergedConfig?.settings ) {\n\t\t\treturn [];\n\t\t}\n\t\tmergedConfig = updateConfigWithSeparator( mergedConfig );\n\n\t\tconst blockSelectors = getBlockSelectors(\n\t\t\tgetBlockTypes(),\n\t\t\tgetBlockStyles\n\t\t);\n\n\t\tconst customProperties = toCustomProperties(\n\t\t\tmergedConfig,\n\t\t\tblockSelectors\n\t\t);\n\t\tconst globalStyles = toStyles(\n\t\t\tmergedConfig,\n\t\t\tblockSelectors,\n\t\t\thasBlockGapSupport,\n\t\t\thasFallbackGapSupport,\n\t\t\tdisableLayoutStyles\n\t\t);\n\n\t\tconst filters = toSvgFilters( mergedConfig, blockSelectors );\n\t\tconst stylesheets = [\n\t\t\t{\n\t\t\t\tcss: customProperties,\n\t\t\t\tisGlobalStyles: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tcss: globalStyles,\n\t\t\t\tisGlobalStyles: true,\n\t\t\t},\n\t\t\t// Load custom CSS in own stylesheet so that any invalid CSS entered in the input won't break all the global styles in the editor.\n\t\t\t{\n\t\t\t\tcss: mergedConfig.styles.css ?? '',\n\t\t\t\tisGlobalStyles: true,\n\t\t\t},\n\t\t];\n\n\t\t// Loop through the blocks to check if there are custom CSS values.\n\t\t// If there are, get the block selector and push the selector together with\n\t\t// the CSS value to the 'stylesheets' array.\n\t\tgetBlockTypes().forEach( ( blockType ) => {\n\t\t\tif ( mergedConfig.styles.blocks[ blockType.name ]?.css ) {\n\t\t\t\tconst selector = blockSelectors[ blockType.name ].selector;\n\t\t\t\tstylesheets.push( {\n\t\t\t\t\tcss: processCSSNesting(\n\t\t\t\t\t\tmergedConfig.styles.blocks[ blockType.name ]?.css,\n\t\t\t\t\t\tselector\n\t\t\t\t\t),\n\t\t\t\t\tisGlobalStyles: true,\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\n\t\treturn [ stylesheets, mergedConfig.settings, filters ];\n\t}, [\n\t\thasBlockGapSupport,\n\t\thasFallbackGapSupport,\n\t\tmergedConfig,\n\t\tdisableLayoutStyles,\n\t] );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/global-styles/use-global-styles-output.js"],"names":["get","isEmpty","kebabCase","set","__EXPERIMENTAL_STYLE_PROPERTY","STYLE_PROPERTY","__EXPERIMENTAL_ELEMENTS","ELEMENTS","getBlockTypes","store","blocksStore","useSelect","useContext","useMemo","getCSSRules","PRESET_METADATA","ROOT_BLOCK_SELECTOR","scopeSelector","getTypographyFontSizeValue","GlobalStylesContext","useGlobalSetting","PresetDuotoneFilter","getGapCSSValue","blockEditorStore","BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS","__experimentalBorder","color","spacing","typography","compileStyleValue","uncompiledValue","VARIABLE_REFERENCE_PREFIX","VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE","VARIABLE_PATH_SEPARATOR_TOKEN_STYLE","startsWith","variable","slice","length","split","join","getPresetsDeclarations","blockPresets","mergedSettings","reduce","declarations","path","valueKey","valueFunc","cssVarInfix","presetByOrigin","forEach","origin","value","push","slug","getPresetsClasses","blockSelector","classes","classSuffix","propertyName","classSelectorToUse","selectorToUse","map","selector","getPresetsSvgFilters","filter","metadata","at","flatMap","preset","flattenTree","input","prefix","token","result","Object","keys","key","newKey","replace","newLeaf","newPrefix","concatFeatureVariationSelectorString","featureSelector","styleVariationSelector","featureSelectors","combinedSelectors","trim","getStylesDeclarations","blockStyles","useRootPaddingAlign","tree","isRoot","output","entries","properties","useEngine","rootOnly","pathToValue","styleValue","entry","name","prop","cssProperty","extraRules","rule","ruleValue","ref","refPath","size","settings","getLayoutStyles","style","hasBlockGapSupport","hasFallbackGapSupport","fallbackGapValue","ruleset","gapValue","blockGap","layout","definitions","values","className","spacingStyles","spacingStyle","rules","cssValue","combinedSelector","validDisplayModes","displayMode","baseStyles","includes","baseStyle","getNodesWithStyles","blockSelectors","nodes","styles","pickStyleKeys","treeToPickFrom","fromEntries","elements","blocks","blockName","node","variations","variation","duotoneSelector","hasLayoutSupport","styleVariationSelectors","elementName","sel","elementSelectors","elementSelector","getNodesWithSettings","pickPresets","presets","custom","blockCustom","toCustomProperties","customProps","toStyles","disableLayoutStyles","nodesWithStyles","nodesWithSettings","useRootPaddingAwareAlignments","contentSize","wideSize","featureName","featureStyles","featureDeclarations","styleVariationName","styleVariationDeclarations","duotoneStyles","duotoneDeclarations","pseudoSelectorStyles","pseudoKey","pseudoStyle","pseudoDeclarations","_selector","pseudoRule","toSvgFilters","getBlockSelectors","blockTypes","getBlockStyles","blockType","supports","__experimentalSelector","__experimentalDuotone","__experimentalLayout","__experimentalDefault","blockStyleVariations","featureKey","undefined","updateConfigWithSeparator","config","needsSeparatorStyleUpdate","background","text","border","processCSSNesting","css","processedCSS","parts","part","useGlobalStylesOutput","merged","mergedConfig","select","getSettings","customProperties","globalStyles","filters","stylesheets","isGlobalStyles"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,EAAcC,OAAd,EAAuBC,SAAvB,EAAkCC,GAAlC,QAA6C,QAA7C;AAEA;AACA;AACA;;AACA,SACCC,6BAA6B,IAAIC,cADlC,EAECC,uBAAuB,IAAIC,QAF5B,EAGCC,aAHD,EAICC,KAAK,IAAIC,WAJV,QAKO,mBALP;AAMA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,UAAT,EAAqBC,OAArB,QAAoC,oBAApC;AACA,SAASC,WAAT,QAA4B,yBAA5B;AAEA;AACA;AACA;;AACA,SAASC,eAAT,EAA0BC,mBAA1B,EAA+CC,aAA/C,QAAoE,SAApE;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SAASC,mBAAT,QAAoC,WAApC;AACA,SAASC,gBAAT,QAAiC,SAAjC;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,SAASC,cAAT,QAA+B,iBAA/B;AACA,SAASb,KAAK,IAAIc,gBAAlB,QAA0C,aAA1C,C,CAEA;AACA;;AACA,MAAMC,qCAAqC,GAAG;AAC7CC,EAAAA,oBAAoB,EAAE,QADuB;AAE7CC,EAAAA,KAAK,EAAE,OAFsC;AAG7CC,EAAAA,OAAO,EAAE,SAHoC;AAI7CC,EAAAA,UAAU,EAAE;AAJiC,CAA9C;;AAOA,SAASC,iBAAT,CAA4BC,eAA5B,EAA8C;AAAA;;AAC7C,QAAMC,yBAAyB,GAAG,MAAlC;AACA,QAAMC,uCAAuC,GAAG,GAAhD;AACA,QAAMC,mCAAmC,GAAG,IAA5C;;AAEA,MAAKH,eAAL,aAAKA,eAAL,wCAAKA,eAAe,CAAEI,UAAtB,kDAAK,2BAAAJ,eAAe,EAAgBC,yBAAhB,CAApB,EAAkE;AACjE,UAAMI,QAAQ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AqJ,QAAAA,WAAW,CAAC/J,IAAZ,CAAkB;AACjBmJ,UAAAA,GAAG,EAAED,iBAAiB,2BACrBO,YAAY,CAACtE,MAAb,CAAoBK,MAApB,CAA4B2C,SAAS,CAACnF,IAAtC,CADqB,2DACrB,uBAA8CmG,GADzB,EAErBzI,QAFqB,CADL;AAKjBsJ,UAAAA,cAAc,EAAE;AALC,SAAlB;AAOA;AACD,KAXD;AAaA,WAAO,CAAED,WAAF,EAAeN,YAAY,CAAChG,QAA5B,EAAsCqG,OAAtC,CAAP;AACA,GAzDa,EAyDX,CACFlG,kBADE,EAEFC,qBAFE,EAGF4F,YAHE,EAIF7C,mBAJE,CAzDW,CAAd;AA+DA","sourcesContent":["/**\n * External dependencies\n */\nimport { get, isEmpty, kebabCase, set } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY,\n\t__EXPERIMENTAL_ELEMENTS as ELEMENTS,\n\tgetBlockTypes,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { useContext, useMemo } from '@wordpress/element';\nimport { getCSSRules } from '@wordpress/style-engine';\n\n/**\n * Internal dependencies\n */\nimport { PRESET_METADATA, ROOT_BLOCK_SELECTOR, scopeSelector } from './utils';\nimport { getTypographyFontSizeValue } from './typography-utils';\nimport { GlobalStylesContext } from './context';\nimport { useGlobalSetting } from './hooks';\nimport { PresetDuotoneFilter } from '../duotone/components';\nimport { getGapCSSValue } from '../../hooks/gap';\nimport { store as blockEditorStore } from '../../store';\n\n// List of block support features that can have their related styles\n// generated under their own feature level selector rather than the block's.\nconst BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = {\n\t__experimentalBorder: 'border',\n\tcolor: 'color',\n\tspacing: 'spacing',\n\ttypography: 'typography',\n};\n\nfunction compileStyleValue( uncompiledValue ) {\n\tconst VARIABLE_REFERENCE_PREFIX = 'var:';\n\tconst VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';\n\tconst VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';\n\n\tif ( uncompiledValue?.startsWith?.( VARIABLE_REFERENCE_PREFIX ) ) {\n\t\tconst variable = uncompiledValue\n\t\t\t.slice( VARIABLE_REFERENCE_PREFIX.length )\n\t\t\t.split( VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE )\n\t\t\t.join( VARIABLE_PATH_SEPARATOR_TOKEN_STYLE );\n\t\treturn `var(--wp--${ variable })`;\n\t}\n\treturn uncompiledValue;\n}\n\n/**\n * Transform given preset tree into a set of style declarations.\n *\n * @param {Object} blockPresets\n * @param {Object} mergedSettings Merged theme.json settings.\n *\n * @return {Array<Object>} An array of style declarations.\n */\nfunction getPresetsDeclarations( blockPresets = {}, mergedSettings ) {\n\treturn PRESET_METADATA.reduce(\n\t\t( declarations, { path, valueKey, valueFunc, cssVarInfix } ) => {\n\t\t\tconst presetByOrigin = get( blockPresets, path, [] );\n\t\t\t[ 'default', 'theme', 'custom' ].forEach( ( origin ) => {\n\t\t\t\tif ( presetByOrigin[ origin ] ) {\n\t\t\t\t\tpresetByOrigin[ origin ].forEach( ( value ) => {\n\t\t\t\t\t\tif ( valueKey && ! valueFunc ) {\n\t\t\t\t\t\t\tdeclarations.push(\n\t\t\t\t\t\t\t\t`--wp--preset--${ cssVarInfix }--${ kebabCase(\n\t\t\t\t\t\t\t\t\tvalue.slug\n\t\t\t\t\t\t\t\t) }: ${ value[ valueKey ] }`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\tvalueFunc &&\n\t\t\t\t\t\t\ttypeof valueFunc === 'function'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tdeclarations.push(\n\t\t\t\t\t\t\t\t`--wp--preset--${ cssVarInfix }--${ kebabCase(\n\t\t\t\t\t\t\t\t\tvalue.slug\n\t\t\t\t\t\t\t\t) }: ${ valueFunc( value, mergedSettings ) }`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\treturn declarations;\n\t\t},\n\t\t[]\n\t);\n}\n\n/**\n * Transform given preset tree into a set of preset class declarations.\n *\n * @param {?string} blockSelector\n * @param {Object} blockPresets\n * @return {string} CSS declarations for the preset classes.\n */\nfunction getPresetsClasses( blockSelector = '*', blockPresets = {} ) {\n\treturn PRESET_METADATA.reduce(\n\t\t( declarations, { path, cssVarInfix, classes } ) => {\n\t\t\tif ( ! classes ) {\n\t\t\t\treturn declarations;\n\t\t\t}\n\n\t\t\tconst presetByOrigin = get( blockPresets, path, [] );\n\t\t\t[ 'default', 'theme', 'custom' ].forEach( ( origin ) => {\n\t\t\t\tif ( presetByOrigin[ origin ] ) {\n\t\t\t\t\tpresetByOrigin[ origin ].forEach( ( { slug } ) => {\n\t\t\t\t\t\tclasses.forEach( ( { classSuffix, propertyName } ) => {\n\t\t\t\t\t\t\tconst classSelectorToUse = `.has-${ kebabCase(\n\t\t\t\t\t\t\t\tslug\n\t\t\t\t\t\t\t) }-${ classSuffix }`;\n\t\t\t\t\t\t\tconst selectorToUse = blockSelector\n\t\t\t\t\t\t\t\t.split( ',' ) // Selector can be \"h1, h2, h3\"\n\t\t\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\t\t\t( selector ) =>\n\t\t\t\t\t\t\t\t\t\t`${ selector }${ classSelectorToUse }`\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t.join( ',' );\n\t\t\t\t\t\t\tconst value = `var(--wp--preset--${ cssVarInfix }--${ kebabCase(\n\t\t\t\t\t\t\t\tslug\n\t\t\t\t\t\t\t) })`;\n\t\t\t\t\t\t\tdeclarations += `${ selectorToUse }{${ propertyName }: ${ value } !important;}`;\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\t\t\treturn declarations;\n\t\t},\n\t\t''\n\t);\n}\n\nfunction getPresetsSvgFilters( blockPresets = {} ) {\n\treturn PRESET_METADATA.filter(\n\t\t// Duotone are the only type of filters for now.\n\t\t( metadata ) => metadata.path.at( -1 ) === 'duotone'\n\t).flatMap( ( metadata ) => {\n\t\tconst presetByOrigin = get( blockPresets, metadata.path, {} );\n\t\treturn [ 'default', 'theme' ]\n\t\t\t.filter( ( origin ) => presetByOrigin[ origin ] )\n\t\t\t.flatMap( ( origin ) =>\n\t\t\t\tpresetByOrigin[ origin ].map( ( preset ) => (\n\t\t\t\t\t<PresetDuotoneFilter\n\t\t\t\t\t\tpreset={ preset }\n\t\t\t\t\t\tkey={ preset.slug }\n\t\t\t\t\t/>\n\t\t\t\t) )\n\t\t\t);\n\t} );\n}\n\nfunction flattenTree( input = {}, prefix, token ) {\n\tlet result = [];\n\tObject.keys( input ).forEach( ( key ) => {\n\t\tconst newKey = prefix + kebabCase( key.replace( '/', '-' ) );\n\t\tconst newLeaf = input[ key ];\n\n\t\tif ( newLeaf instanceof Object ) {\n\t\t\tconst newPrefix = newKey + token;\n\t\t\tresult = [ ...result, ...flattenTree( newLeaf, newPrefix, token ) ];\n\t\t} else {\n\t\t\tresult.push( `${ newKey }: ${ newLeaf }` );\n\t\t}\n\t} );\n\treturn result;\n}\n\n/**\n * Gets variation selector string from feature selector.\n *\n * @param {string} featureSelector The feature selector.\n *\n * @param {string} styleVariationSelector The style variation selector.\n * @return {string} Combined selector string.\n *\n */\nfunction concatFeatureVariationSelectorString(\n\tfeatureSelector,\n\tstyleVariationSelector\n) {\n\tconst featureSelectors = featureSelector.split( ',' );\n\tconst combinedSelectors = [];\n\tfeatureSelectors.forEach( ( selector ) => {\n\t\tcombinedSelectors.push(\n\t\t\t`${ styleVariationSelector.trim() }${ selector.trim() }`\n\t\t);\n\t} );\n\treturn combinedSelectors.join( ', ' );\n}\n\n/**\n * Transform given style tree into a set of style declarations.\n *\n * @param {Object} blockStyles Block styles.\n *\n * @param {string} selector The selector these declarations should attach to.\n *\n * @param {boolean} useRootPaddingAlign Whether to use CSS custom properties in root selector.\n *\n * @param {Object} tree A theme.json tree containing layout definitions.\n *\n * @return {Array} An array of style declarations.\n */\nexport function getStylesDeclarations(\n\tblockStyles = {},\n\tselector = '',\n\tuseRootPaddingAlign,\n\ttree = {}\n) {\n\tconst isRoot = ROOT_BLOCK_SELECTOR === selector;\n\tconst output = Object.entries( STYLE_PROPERTY ).reduce(\n\t\t(\n\t\t\tdeclarations,\n\t\t\t[ key, { value, properties, useEngine, rootOnly } ]\n\t\t) => {\n\t\t\tif ( rootOnly && ! isRoot ) {\n\t\t\t\treturn declarations;\n\t\t\t}\n\t\t\tconst pathToValue = value;\n\t\t\tif ( pathToValue[ 0 ] === 'elements' || useEngine ) {\n\t\t\t\treturn declarations;\n\t\t\t}\n\n\t\t\tconst styleValue = get( blockStyles, pathToValue );\n\n\t\t\t// Root-level padding styles don't currently support strings with CSS shorthand values.\n\t\t\t// This may change: https://github.com/WordPress/gutenberg/issues/40132.\n\t\t\tif (\n\t\t\t\tkey === '--wp--style--root--padding' &&\n\t\t\t\t( typeof styleValue === 'string' || ! useRootPaddingAlign )\n\t\t\t) {\n\t\t\t\treturn declarations;\n\t\t\t}\n\n\t\t\tif ( !! properties && typeof styleValue !== 'string' ) {\n\t\t\t\tObject.entries( properties ).forEach( ( entry ) => {\n\t\t\t\t\tconst [ name, prop ] = entry;\n\n\t\t\t\t\tif ( ! get( styleValue, [ prop ], false ) ) {\n\t\t\t\t\t\t// Do not create a declaration\n\t\t\t\t\t\t// for sub-properties that don't have any value.\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst cssProperty = name.startsWith( '--' )\n\t\t\t\t\t\t? name\n\t\t\t\t\t\t: kebabCase( name );\n\t\t\t\t\tdeclarations.push(\n\t\t\t\t\t\t`${ cssProperty }: ${ compileStyleValue(\n\t\t\t\t\t\t\tget( styleValue, [ prop ] )\n\t\t\t\t\t\t) }`\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t} else if ( get( blockStyles, pathToValue, false ) ) {\n\t\t\t\tconst cssProperty = key.startsWith( '--' )\n\t\t\t\t\t? key\n\t\t\t\t\t: kebabCase( key );\n\t\t\t\tdeclarations.push(\n\t\t\t\t\t`${ cssProperty }: ${ compileStyleValue(\n\t\t\t\t\t\tget( blockStyles, pathToValue )\n\t\t\t\t\t) }`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn declarations;\n\t\t},\n\t\t[]\n\t);\n\n\t// The goal is to move everything to server side generated engine styles\n\t// This is temporary as we absorb more and more styles into the engine.\n\tconst extraRules = getCSSRules( blockStyles );\n\textraRules.forEach( ( rule ) => {\n\t\t// Don't output padding properties if padding variables are set.\n\t\tif (\n\t\t\tisRoot &&\n\t\t\tuseRootPaddingAlign &&\n\t\t\trule.key.startsWith( 'padding' )\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst cssProperty = rule.key.startsWith( '--' )\n\t\t\t? rule.key\n\t\t\t: kebabCase( rule.key );\n\n\t\tlet ruleValue = rule.value;\n\t\tif ( typeof ruleValue !== 'string' && ruleValue?.ref ) {\n\t\t\tconst refPath = ruleValue.ref.split( '.' );\n\t\t\truleValue = get( tree, refPath );\n\t\t\t// Presence of another ref indicates a reference to another dynamic value.\n\t\t\t// Pointing to another dynamic value is not supported.\n\t\t\tif ( ! ruleValue || !! ruleValue?.ref ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// Calculate fluid typography rules where available.\n\t\tif ( cssProperty === 'font-size' ) {\n\t\t\t/*\n\t\t\t * getTypographyFontSizeValue() will check\n\t\t\t * if fluid typography has been activated and also\n\t\t\t * whether the incoming value can be converted to a fluid value.\n\t\t\t * Values that already have a \"clamp()\" function will not pass the test,\n\t\t\t * and therefore the original $value will be returned.\n\t\t\t */\n\t\t\truleValue = getTypographyFontSizeValue(\n\t\t\t\t{ size: ruleValue },\n\t\t\t\ttree?.settings?.typography\n\t\t\t);\n\t\t}\n\n\t\toutput.push( `${ cssProperty }: ${ ruleValue }` );\n\t} );\n\n\treturn output;\n}\n\n/**\n * Get generated CSS for layout styles by looking up layout definitions provided\n * in theme.json, and outputting common layout styles, and specific blockGap values.\n *\n * @param {Object} props\n * @param {Object} props.tree A theme.json tree containing layout definitions.\n * @param {Object} props.style A style object containing spacing values.\n * @param {string} props.selector Selector used to group together layout styling rules.\n * @param {boolean} props.hasBlockGapSupport Whether or not the theme opts-in to blockGap support.\n * @param {boolean} props.hasFallbackGapSupport Whether or not the theme allows fallback gap styles.\n * @param {?string} props.fallbackGapValue An optional fallback gap value if no real gap value is available.\n * @return {string} Generated CSS rules for the layout styles.\n */\nexport function getLayoutStyles( {\n\ttree,\n\tstyle,\n\tselector,\n\thasBlockGapSupport,\n\thasFallbackGapSupport,\n\tfallbackGapValue,\n} ) {\n\tlet ruleset = '';\n\tlet gapValue = hasBlockGapSupport\n\t\t? getGapCSSValue( style?.spacing?.blockGap )\n\t\t: '';\n\n\t// Ensure a fallback gap value for the root layout definitions,\n\t// and use a fallback value if one is provided for the current block.\n\tif ( hasFallbackGapSupport ) {\n\t\tif ( selector === ROOT_BLOCK_SELECTOR ) {\n\t\t\tgapValue = ! gapValue ? '0.5em' : gapValue;\n\t\t} else if ( ! hasBlockGapSupport && fallbackGapValue ) {\n\t\t\tgapValue = fallbackGapValue;\n\t\t}\n\t}\n\n\tif ( gapValue && tree?.settings?.layout?.definitions ) {\n\t\tObject.values( tree.settings.layout.definitions ).forEach(\n\t\t\t( { className, name, spacingStyles } ) => {\n\t\t\t\t// Allow outputting fallback gap styles for flex layout type when block gap support isn't available.\n\t\t\t\tif ( ! hasBlockGapSupport && 'flex' !== name ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( spacingStyles?.length ) {\n\t\t\t\t\tspacingStyles.forEach( ( spacingStyle ) => {\n\t\t\t\t\t\tconst declarations = [];\n\n\t\t\t\t\t\tif ( spacingStyle.rules ) {\n\t\t\t\t\t\t\tObject.entries( spacingStyle.rules ).forEach(\n\t\t\t\t\t\t\t\t( [ cssProperty, cssValue ] ) => {\n\t\t\t\t\t\t\t\t\tdeclarations.push(\n\t\t\t\t\t\t\t\t\t\t`${ cssProperty }: ${\n\t\t\t\t\t\t\t\t\t\t\tcssValue ? cssValue : gapValue\n\t\t\t\t\t\t\t\t\t\t}`\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( declarations.length ) {\n\t\t\t\t\t\t\tlet combinedSelector = '';\n\n\t\t\t\t\t\t\tif ( ! hasBlockGapSupport ) {\n\t\t\t\t\t\t\t\t// For fallback gap styles, use lower specificity, to ensure styles do not unintentionally override theme styles.\n\t\t\t\t\t\t\t\tcombinedSelector =\n\t\t\t\t\t\t\t\t\tselector === ROOT_BLOCK_SELECTOR\n\t\t\t\t\t\t\t\t\t\t? `:where(.${ className }${\n\t\t\t\t\t\t\t\t\t\t\t\tspacingStyle?.selector || ''\n\t\t\t\t\t\t\t\t\t\t })`\n\t\t\t\t\t\t\t\t\t\t: `:where(${ selector }.${ className }${\n\t\t\t\t\t\t\t\t\t\t\t\tspacingStyle?.selector || ''\n\t\t\t\t\t\t\t\t\t\t })`;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcombinedSelector =\n\t\t\t\t\t\t\t\t\tselector === ROOT_BLOCK_SELECTOR\n\t\t\t\t\t\t\t\t\t\t? `${ selector } .${ className }${\n\t\t\t\t\t\t\t\t\t\t\t\tspacingStyle?.selector || ''\n\t\t\t\t\t\t\t\t\t\t }`\n\t\t\t\t\t\t\t\t\t\t: `${ selector }-${ className }${ selector }-${ className }${\n\t\t\t\t\t\t\t\t\t\t\t\tspacingStyle?.selector || ''\n\t\t\t\t\t\t\t\t\t\t }`;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\truleset += `${ combinedSelector } { ${ declarations.join(\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\t\t\t\t}\n\t\t\t}\n\t\t);\n\t\t// For backwards compatibility, ensure the legacy block gap CSS variable is still available.\n\t\tif ( selector === ROOT_BLOCK_SELECTOR && hasBlockGapSupport ) {\n\t\t\truleset += `${ selector } { --wp--style--block-gap: ${ gapValue }; }`;\n\t\t}\n\t}\n\n\t// Output base styles\n\tif (\n\t\tselector === ROOT_BLOCK_SELECTOR &&\n\t\ttree?.settings?.layout?.definitions\n\t) {\n\t\tconst validDisplayModes = [ 'block', 'flex', 'grid' ];\n\t\tObject.values( tree.settings.layout.definitions ).forEach(\n\t\t\t( { className, displayMode, baseStyles } ) => {\n\t\t\t\tif (\n\t\t\t\t\tdisplayMode &&\n\t\t\t\t\tvalidDisplayModes.includes( displayMode )\n\t\t\t\t) {\n\t\t\t\t\truleset += `${ selector } .${ className } { display:${ displayMode }; }`;\n\t\t\t\t}\n\n\t\t\t\tif ( baseStyles?.length ) {\n\t\t\t\t\tbaseStyles.forEach( ( baseStyle ) => {\n\t\t\t\t\t\tconst declarations = [];\n\n\t\t\t\t\t\tif ( baseStyle.rules ) {\n\t\t\t\t\t\t\tObject.entries( baseStyle.rules ).forEach(\n\t\t\t\t\t\t\t\t( [ cssProperty, cssValue ] ) => {\n\t\t\t\t\t\t\t\t\tdeclarations.push(\n\t\t\t\t\t\t\t\t\t\t`${ cssProperty }: ${ cssValue }`\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( declarations.length ) {\n\t\t\t\t\t\t\tconst combinedSelector = `${ selector } .${ className }${\n\t\t\t\t\t\t\t\tbaseStyle?.selector || ''\n\t\t\t\t\t\t\t}`;\n\t\t\t\t\t\t\truleset += `${ combinedSelector } { ${ declarations.join(\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\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\treturn ruleset;\n}\n\nexport const getNodesWithStyles = ( tree, blockSelectors ) => {\n\tconst nodes = [];\n\n\tif ( ! tree?.styles ) {\n\t\treturn nodes;\n\t}\n\n\tconst pickStyleKeys = ( treeToPickFrom ) =>\n\t\tObject.fromEntries(\n\t\t\tObject.entries( treeToPickFrom ?? {} ).filter( ( [ key ] ) =>\n\t\t\t\t[\n\t\t\t\t\t'border',\n\t\t\t\t\t'color',\n\t\t\t\t\t'dimensions',\n\t\t\t\t\t'spacing',\n\t\t\t\t\t'typography',\n\t\t\t\t\t'filter',\n\t\t\t\t\t'outline',\n\t\t\t\t\t'shadow',\n\t\t\t\t].includes( key )\n\t\t\t)\n\t\t);\n\n\t// Top-level.\n\tconst styles = pickStyleKeys( tree.styles );\n\tif ( !! styles ) {\n\t\tnodes.push( {\n\t\t\tstyles,\n\t\t\tselector: ROOT_BLOCK_SELECTOR,\n\t\t} );\n\t}\n\n\tObject.entries( ELEMENTS ).forEach( ( [ name, selector ] ) => {\n\t\tif ( !! tree.styles?.elements?.[ name ] ) {\n\t\t\tnodes.push( {\n\t\t\t\tstyles: tree.styles?.elements?.[ name ],\n\t\t\t\tselector,\n\t\t\t} );\n\t\t}\n\t} );\n\n\t// Iterate over blocks: they can have styles & elements.\n\tObject.entries( tree.styles?.blocks ?? {} ).forEach(\n\t\t( [ blockName, node ] ) => {\n\t\t\tconst blockStyles = pickStyleKeys( node );\n\n\t\t\tif ( node?.variations ) {\n\t\t\t\tconst variations = {};\n\t\t\t\tObject.keys( node.variations ).forEach( ( variation ) => {\n\t\t\t\t\tvariations[ variation ] = pickStyleKeys(\n\t\t\t\t\t\tnode.variations[ variation ]\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t\tblockStyles.variations = variations;\n\t\t\t}\n\t\t\tif (\n\t\t\t\t!! blockStyles &&\n\t\t\t\t!! blockSelectors?.[ blockName ]?.selector\n\t\t\t) {\n\t\t\t\tnodes.push( {\n\t\t\t\t\tduotoneSelector:\n\t\t\t\t\t\tblockSelectors[ blockName ].duotoneSelector,\n\t\t\t\t\tfallbackGapValue:\n\t\t\t\t\t\tblockSelectors[ blockName ].fallbackGapValue,\n\t\t\t\t\thasLayoutSupport:\n\t\t\t\t\t\tblockSelectors[ blockName ].hasLayoutSupport,\n\t\t\t\t\tselector: blockSelectors[ blockName ]?.selector,\n\t\t\t\t\tstyles: blockStyles,\n\t\t\t\t\tfeatureSelectors:\n\t\t\t\t\t\tblockSelectors[ blockName ].featureSelectors,\n\t\t\t\t\tstyleVariationSelectors:\n\t\t\t\t\t\tblockSelectors[ blockName ].styleVariationSelectors,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tObject.entries( node?.elements ?? {} ).forEach(\n\t\t\t\t( [ elementName, value ] ) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\t!! value &&\n\t\t\t\t\t\t!! blockSelectors?.[ blockName ] &&\n\t\t\t\t\t\t!! ELEMENTS?.[ elementName ]\n\t\t\t\t\t) {\n\t\t\t\t\t\tnodes.push( {\n\t\t\t\t\t\t\tstyles: value,\n\t\t\t\t\t\t\tselector: blockSelectors[ blockName ]?.selector\n\t\t\t\t\t\t\t\t.split( ',' )\n\t\t\t\t\t\t\t\t.map( ( sel ) => {\n\t\t\t\t\t\t\t\t\tconst elementSelectors =\n\t\t\t\t\t\t\t\t\t\tELEMENTS[ elementName ].split( ',' );\n\t\t\t\t\t\t\t\t\treturn elementSelectors.map(\n\t\t\t\t\t\t\t\t\t\t( elementSelector ) =>\n\t\t\t\t\t\t\t\t\t\t\tsel + ' ' + elementSelector\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\t.join( ',' ),\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n\n\treturn nodes;\n};\n\nexport const getNodesWithSettings = ( tree, blockSelectors ) => {\n\tconst nodes = [];\n\n\tif ( ! tree?.settings ) {\n\t\treturn nodes;\n\t}\n\n\tconst pickPresets = ( treeToPickFrom ) => {\n\t\tconst presets = {};\n\t\tPRESET_METADATA.forEach( ( { path } ) => {\n\t\t\tconst value = get( treeToPickFrom, path, false );\n\t\t\tif ( value !== false ) {\n\t\t\t\tset( presets, path, value );\n\t\t\t}\n\t\t} );\n\t\treturn presets;\n\t};\n\n\t// Top-level.\n\tconst presets = pickPresets( tree.settings );\n\tconst custom = tree.settings?.custom;\n\tif ( ! isEmpty( presets ) || !! custom ) {\n\t\tnodes.push( {\n\t\t\tpresets,\n\t\t\tcustom,\n\t\t\tselector: ROOT_BLOCK_SELECTOR,\n\t\t} );\n\t}\n\n\t// Blocks.\n\tObject.entries( tree.settings?.blocks ?? {} ).forEach(\n\t\t( [ blockName, node ] ) => {\n\t\t\tconst blockPresets = pickPresets( node );\n\t\t\tconst blockCustom = node.custom;\n\t\t\tif ( ! isEmpty( blockPresets ) || !! blockCustom ) {\n\t\t\t\tnodes.push( {\n\t\t\t\t\tpresets: blockPresets,\n\t\t\t\t\tcustom: blockCustom,\n\t\t\t\t\tselector: blockSelectors[ blockName ]?.selector,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t);\n\n\treturn nodes;\n};\n\nexport const toCustomProperties = ( tree, blockSelectors ) => {\n\tconst settings = getNodesWithSettings( tree, blockSelectors );\n\tlet ruleset = '';\n\tsettings.forEach( ( { presets, custom, selector } ) => {\n\t\tconst declarations = getPresetsDeclarations( presets, tree?.settings );\n\t\tconst customProps = flattenTree( custom, '--wp--custom--', '--' );\n\t\tif ( customProps.length > 0 ) {\n\t\t\tdeclarations.push( ...customProps );\n\t\t}\n\n\t\tif ( declarations.length > 0 ) {\n\t\t\truleset = ruleset + `${ selector }{${ declarations.join( ';' ) };}`;\n\t\t}\n\t} );\n\n\treturn ruleset;\n};\n\nexport const toStyles = (\n\ttree,\n\tblockSelectors,\n\thasBlockGapSupport,\n\thasFallbackGapSupport,\n\tdisableLayoutStyles = false\n) => {\n\tconst nodesWithStyles = getNodesWithStyles( tree, blockSelectors );\n\tconst nodesWithSettings = getNodesWithSettings( tree, blockSelectors );\n\tconst useRootPaddingAlign = tree?.settings?.useRootPaddingAwareAlignments;\n\tconst { contentSize, wideSize } = tree?.settings?.layout || {};\n\n\t/*\n\t * Reset default browser margin on the root body element.\n\t * This is set on the root selector **before** generating the ruleset\n\t * from the `theme.json`. This is to ensure that if the `theme.json` declares\n\t * `margin` in its `spacing` declaration for the `body` element then these\n\t * user-generated values take precedence in the CSS cascade.\n\t * @link https://github.com/WordPress/gutenberg/issues/36147.\n\t */\n\tlet ruleset = 'body {margin: 0;';\n\n\tif ( contentSize ) {\n\t\truleset += ` --wp--style--global--content-size: ${ contentSize };`;\n\t}\n\n\tif ( wideSize ) {\n\t\truleset += ` --wp--style--global--wide-size: ${ wideSize };`;\n\t}\n\n\tif ( useRootPaddingAlign ) {\n\t\t/*\n\t\t * These rules reproduce the ones from https://github.com/WordPress/gutenberg/blob/79103f124925d1f457f627e154f52a56228ed5ad/lib/class-wp-theme-json-gutenberg.php#L2508\n\t\t * almost exactly, but for the selectors that target block wrappers in the front end. This code only runs in the editor, so it doesn't need those selectors.\n\t\t */\n\t\truleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) }\n\t\t\t.has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }\n\t\t\t.has-global-padding :where(.has-global-padding) { padding-right: 0; padding-left: 0; }\n\t\t\t.has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }\n\t\t\t.has-global-padding :where(.has-global-padding) > .alignfull { margin-right: 0; margin-left: 0; }\n\t\t\t.has-global-padding > .alignfull:where(:not(.has-global-padding)) > :where(.wp-block:not(.alignfull),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }\n\t\t\t.has-global-padding :where(.has-global-padding) > .alignfull:where(:not(.has-global-padding)) > :where(.wp-block:not(.alignfull),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: 0; padding-left: 0;`;\n\t}\n\n\truleset += '}';\n\n\tnodesWithStyles.forEach(\n\t\t( {\n\t\t\tselector,\n\t\t\tduotoneSelector,\n\t\t\tstyles,\n\t\t\tfallbackGapValue,\n\t\t\thasLayoutSupport,\n\t\t\tfeatureSelectors,\n\t\t\tstyleVariationSelectors,\n\t\t} ) => {\n\t\t\t// Process styles for block support features with custom feature level\n\t\t\t// CSS selectors set.\n\t\t\tif ( featureSelectors ) {\n\t\t\t\tObject.entries( featureSelectors ).forEach(\n\t\t\t\t\t( [ featureName, featureSelector ] ) => {\n\t\t\t\t\t\tif ( styles?.[ featureName ] ) {\n\t\t\t\t\t\t\tconst featureStyles = {\n\t\t\t\t\t\t\t\t[ featureName ]: styles[ featureName ],\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tconst featureDeclarations =\n\t\t\t\t\t\t\t\tgetStylesDeclarations( featureStyles );\n\t\t\t\t\t\t\tdelete styles[ featureName ];\n\n\t\t\t\t\t\t\tif ( !! featureDeclarations.length ) {\n\t\t\t\t\t\t\t\truleset =\n\t\t\t\t\t\t\t\t\truleset +\n\t\t\t\t\t\t\t\t\t`${ featureSelector }{${ featureDeclarations.join(\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}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif ( styleVariationSelectors ) {\n\t\t\t\tObject.entries( styleVariationSelectors ).forEach(\n\t\t\t\t\t( [ styleVariationName, styleVariationSelector ] ) => {\n\t\t\t\t\t\tif ( styles?.variations?.[ styleVariationName ] ) {\n\t\t\t\t\t\t\t// If the block uses any custom selectors for block support, add those first.\n\t\t\t\t\t\t\tif ( featureSelectors ) {\n\t\t\t\t\t\t\t\tObject.entries( featureSelectors ).forEach(\n\t\t\t\t\t\t\t\t\t( [ featureName, featureSelector ] ) => {\n\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\tstyles?.variations?.[\n\t\t\t\t\t\t\t\t\t\t\t\tstyleVariationName\n\t\t\t\t\t\t\t\t\t\t\t]?.[ featureName ]\n\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\tconst featureStyles = {\n\t\t\t\t\t\t\t\t\t\t\t\t[ featureName ]:\n\t\t\t\t\t\t\t\t\t\t\t\t\tstyles.variations[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tstyleVariationName\n\t\t\t\t\t\t\t\t\t\t\t\t\t][ featureName ],\n\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t\tconst featureDeclarations =\n\t\t\t\t\t\t\t\t\t\t\t\tgetStylesDeclarations(\n\t\t\t\t\t\t\t\t\t\t\t\t\tfeatureStyles\n\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\tdelete styles.variations[\n\t\t\t\t\t\t\t\t\t\t\t\tstyleVariationName\n\t\t\t\t\t\t\t\t\t\t\t][ featureName ];\n\n\t\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t\t!! featureDeclarations.length\n\t\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\t\truleset =\n\t\t\t\t\t\t\t\t\t\t\t\t\truleset +\n\t\t\t\t\t\t\t\t\t\t\t\t\t`${ concatFeatureVariationSelectorString(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tfeatureSelector,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tstyleVariationSelector\n\t\t\t\t\t\t\t\t\t\t\t\t\t) }{${ featureDeclarations.join(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t';'\n\t\t\t\t\t\t\t\t\t\t\t\t\t) } }`;\n\t\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}\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Otherwise add regular selectors.\n\t\t\t\t\t\t\tconst styleVariationDeclarations =\n\t\t\t\t\t\t\t\tgetStylesDeclarations(\n\t\t\t\t\t\t\t\t\tstyles?.variations?.[ styleVariationName ],\n\t\t\t\t\t\t\t\t\tstyleVariationSelector,\n\t\t\t\t\t\t\t\t\tuseRootPaddingAlign,\n\t\t\t\t\t\t\t\t\ttree\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif ( !! styleVariationDeclarations.length ) {\n\t\t\t\t\t\t\t\truleset =\n\t\t\t\t\t\t\t\t\truleset +\n\t\t\t\t\t\t\t\t\t`${ styleVariationSelector }{${ styleVariationDeclarations.join(\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}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst duotoneStyles = {};\n\t\t\tif ( styles?.filter ) {\n\t\t\t\tduotoneStyles.filter = styles.filter;\n\t\t\t\tdelete styles.filter;\n\t\t\t}\n\n\t\t\t// Process duotone styles (they use color.__experimentalDuotone selector).\n\t\t\tif ( duotoneSelector ) {\n\t\t\t\tconst duotoneDeclarations =\n\t\t\t\t\tgetStylesDeclarations( duotoneStyles );\n\t\t\t\tif ( duotoneDeclarations.length > 0 ) {\n\t\t\t\t\truleset =\n\t\t\t\t\t\truleset +\n\t\t\t\t\t\t`${ scopeSelector(\n\t\t\t\t\t\t\tselector,\n\t\t\t\t\t\t\tduotoneSelector\n\t\t\t\t\t\t) }{${ duotoneDeclarations.join( ';' ) };}`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Process blockGap and layout styles.\n\t\t\tif (\n\t\t\t\t! disableLayoutStyles &&\n\t\t\t\t( ROOT_BLOCK_SELECTOR === selector || hasLayoutSupport )\n\t\t\t) {\n\t\t\t\truleset += getLayoutStyles( {\n\t\t\t\t\ttree,\n\t\t\t\t\tstyle: styles,\n\t\t\t\t\tselector,\n\t\t\t\t\thasBlockGapSupport,\n\t\t\t\t\thasFallbackGapSupport,\n\t\t\t\t\tfallbackGapValue,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\t// Process the remaining block styles (they use either normal block class or __experimentalSelector).\n\t\t\tconst declarations = getStylesDeclarations(\n\t\t\t\tstyles,\n\t\t\t\tselector,\n\t\t\t\tuseRootPaddingAlign,\n\t\t\t\ttree\n\t\t\t);\n\t\t\tif ( declarations?.length ) {\n\t\t\t\truleset =\n\t\t\t\t\truleset + `${ selector }{${ declarations.join( ';' ) };}`;\n\t\t\t}\n\n\t\t\t// Check for pseudo selector in `styles` and handle separately.\n\t\t\tconst pseudoSelectorStyles = Object.entries( styles ).filter(\n\t\t\t\t( [ key ] ) => key.startsWith( ':' )\n\t\t\t);\n\n\t\t\tif ( pseudoSelectorStyles?.length ) {\n\t\t\t\tpseudoSelectorStyles.forEach(\n\t\t\t\t\t( [ pseudoKey, pseudoStyle ] ) => {\n\t\t\t\t\t\tconst pseudoDeclarations =\n\t\t\t\t\t\t\tgetStylesDeclarations( pseudoStyle );\n\n\t\t\t\t\t\tif ( ! pseudoDeclarations?.length ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// `selector` maybe provided in a form\n\t\t\t\t\t\t// where block level selectors have sub element\n\t\t\t\t\t\t// selectors appended to them as a comma separated\n\t\t\t\t\t\t// string.\n\t\t\t\t\t\t// e.g. `h1 a,h2 a,h3 a,h4 a,h5 a,h6 a`;\n\t\t\t\t\t\t// Split and append pseudo selector to create\n\t\t\t\t\t\t// the proper rules to target the elements.\n\t\t\t\t\t\tconst _selector = selector\n\t\t\t\t\t\t\t.split( ',' )\n\t\t\t\t\t\t\t.map( ( sel ) => sel + pseudoKey )\n\t\t\t\t\t\t\t.join( ',' );\n\n\t\t\t\t\t\tconst pseudoRule = `${ _selector }{${ pseudoDeclarations.join(\n\t\t\t\t\t\t\t';'\n\t\t\t\t\t\t) };}`;\n\n\t\t\t\t\t\truleset = ruleset + pseudoRule;\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t);\n\n\t/* Add alignment / layout styles */\n\truleset =\n\t\truleset +\n\t\t'.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }';\n\truleset =\n\t\truleset +\n\t\t'.wp-site-blocks > .alignright { float: right; margin-left: 2em; }';\n\truleset =\n\t\truleset +\n\t\t'.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }';\n\n\tif ( hasBlockGapSupport ) {\n\t\t// Use fallback of `0.5em` just in case, however if there is blockGap support, there should nearly always be a real value.\n\t\tconst gapValue =\n\t\t\tgetGapCSSValue( tree?.styles?.spacing?.blockGap ) || '0.5em';\n\t\truleset =\n\t\t\truleset +\n\t\t\t'.wp-site-blocks > * { margin-block-start: 0; margin-block-end: 0; }';\n\t\truleset =\n\t\t\truleset +\n\t\t\t`.wp-site-blocks > * + * { margin-block-start: ${ gapValue }; }`;\n\t}\n\n\tnodesWithSettings.forEach( ( { selector, presets } ) => {\n\t\tif ( ROOT_BLOCK_SELECTOR === selector ) {\n\t\t\t// Do not add extra specificity for top-level classes.\n\t\t\tselector = '';\n\t\t}\n\n\t\tconst classes = getPresetsClasses( selector, presets );\n\t\tif ( ! isEmpty( classes ) ) {\n\t\t\truleset = ruleset + classes;\n\t\t}\n\t} );\n\n\treturn ruleset;\n};\n\nexport function toSvgFilters( tree, blockSelectors ) {\n\tconst nodesWithSettings = getNodesWithSettings( tree, blockSelectors );\n\treturn nodesWithSettings.flatMap( ( { presets } ) => {\n\t\treturn getPresetsSvgFilters( presets );\n\t} );\n}\n\nexport const getBlockSelectors = ( blockTypes, getBlockStyles ) => {\n\tconst result = {};\n\tblockTypes.forEach( ( blockType ) => {\n\t\tconst name = blockType.name;\n\t\tconst selector =\n\t\t\tblockType?.supports?.__experimentalSelector ??\n\t\t\t'.wp-block-' + name.replace( 'core/', '' ).replace( '/', '-' );\n\t\tconst duotoneSelector =\n\t\t\tblockType?.supports?.color?.__experimentalDuotone ?? null;\n\t\tconst hasLayoutSupport = !! blockType?.supports?.__experimentalLayout;\n\t\tconst fallbackGapValue =\n\t\t\tblockType?.supports?.spacing?.blockGap?.__experimentalDefault;\n\n\t\tconst blockStyleVariations = getBlockStyles( name );\n\t\tconst styleVariationSelectors = {};\n\t\tif ( blockStyleVariations?.length ) {\n\t\t\tblockStyleVariations.forEach( ( variation ) => {\n\t\t\t\tconst styleVariationSelector = `.is-style-${ variation.name }${ selector }`;\n\t\t\t\tstyleVariationSelectors[ variation.name ] =\n\t\t\t\t\tstyleVariationSelector;\n\t\t\t} );\n\t\t}\n\t\t// For each block support feature add any custom selectors.\n\t\tconst featureSelectors = {};\n\t\tObject.entries( BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS ).forEach(\n\t\t\t( [ featureKey, featureName ] ) => {\n\t\t\t\tconst featureSelector =\n\t\t\t\t\tblockType?.supports?.[ featureKey ]?.__experimentalSelector;\n\n\t\t\t\tif ( featureSelector ) {\n\t\t\t\t\tfeatureSelectors[ featureName ] = scopeSelector(\n\t\t\t\t\t\tselector,\n\t\t\t\t\t\tfeatureSelector\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\tresult[ name ] = {\n\t\t\tduotoneSelector,\n\t\t\tfallbackGapValue,\n\t\t\tfeatureSelectors: Object.keys( featureSelectors ).length\n\t\t\t\t? featureSelectors\n\t\t\t\t: undefined,\n\t\t\thasLayoutSupport,\n\t\t\tname,\n\t\t\tselector,\n\t\t\tstyleVariationSelectors: Object.keys( styleVariationSelectors )\n\t\t\t\t.length\n\t\t\t\t? styleVariationSelectors\n\t\t\t\t: undefined,\n\t\t};\n\t} );\n\n\treturn result;\n};\n\n/**\n * If there is a separator block whose color is defined in theme.json via background,\n * update the separator color to the same value by using border color.\n *\n * @param {Object} config Theme.json configuration file object.\n * @return {Object} configTheme.json configuration file object updated.\n */\nfunction updateConfigWithSeparator( config ) {\n\tconst needsSeparatorStyleUpdate =\n\t\tconfig.styles?.blocks?.[ 'core/separator' ] &&\n\t\tconfig.styles?.blocks?.[ 'core/separator' ].color?.background &&\n\t\t! config.styles?.blocks?.[ 'core/separator' ].color?.text &&\n\t\t! config.styles?.blocks?.[ 'core/separator' ].border?.color;\n\tif ( needsSeparatorStyleUpdate ) {\n\t\treturn {\n\t\t\t...config,\n\t\t\tstyles: {\n\t\t\t\t...config.styles,\n\t\t\t\tblocks: {\n\t\t\t\t\t...config.styles.blocks,\n\t\t\t\t\t'core/separator': {\n\t\t\t\t\t\t...config.styles.blocks[ 'core/separator' ],\n\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t...config.styles.blocks[ 'core/separator' ].color,\n\t\t\t\t\t\t\ttext: config.styles?.blocks[ 'core/separator' ]\n\t\t\t\t\t\t\t\t.color.background,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\treturn config;\n}\n\nconst processCSSNesting = ( css, blockSelector ) => {\n\tlet processedCSS = '';\n\n\t// Split CSS nested rules.\n\tconst parts = css.split( '&' );\n\tparts.forEach( ( part ) => {\n\t\tprocessedCSS += ! part.includes( '{' )\n\t\t\t? blockSelector + '{' + part + '}' // If the part doesn't contain braces, it applies to the root level.\n\t\t\t: blockSelector + part; // Prepend the selector, which effectively replaces the \"&\" character.\n\t} );\n\treturn processedCSS;\n};\n\nexport function useGlobalStylesOutput() {\n\tlet { merged: mergedConfig } = useContext( GlobalStylesContext );\n\n\tconst [ blockGap ] = useGlobalSetting( 'spacing.blockGap' );\n\tconst hasBlockGapSupport = blockGap !== null;\n\tconst hasFallbackGapSupport = ! hasBlockGapSupport; // This setting isn't useful yet: it exists as a placeholder for a future explicit fallback styles support.\n\tconst disableLayoutStyles = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn !! getSettings().disableLayoutStyles;\n\t} );\n\n\tconst getBlockStyles = useSelect( ( select ) => {\n\t\treturn select( blocksStore ).getBlockStyles;\n\t}, [] );\n\n\treturn useMemo( () => {\n\t\tif ( ! mergedConfig?.styles || ! mergedConfig?.settings ) {\n\t\t\treturn [];\n\t\t}\n\t\tmergedConfig = updateConfigWithSeparator( mergedConfig );\n\n\t\tconst blockSelectors = getBlockSelectors(\n\t\t\tgetBlockTypes(),\n\t\t\tgetBlockStyles\n\t\t);\n\n\t\tconst customProperties = toCustomProperties(\n\t\t\tmergedConfig,\n\t\t\tblockSelectors\n\t\t);\n\t\tconst globalStyles = toStyles(\n\t\t\tmergedConfig,\n\t\t\tblockSelectors,\n\t\t\thasBlockGapSupport,\n\t\t\thasFallbackGapSupport,\n\t\t\tdisableLayoutStyles\n\t\t);\n\n\t\tconst filters = toSvgFilters( mergedConfig, blockSelectors );\n\t\tconst stylesheets = [\n\t\t\t{\n\t\t\t\tcss: customProperties,\n\t\t\t\tisGlobalStyles: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tcss: globalStyles,\n\t\t\t\tisGlobalStyles: true,\n\t\t\t},\n\t\t\t// Load custom CSS in own stylesheet so that any invalid CSS entered in the input won't break all the global styles in the editor.\n\t\t\t{\n\t\t\t\tcss: mergedConfig.styles.css ?? '',\n\t\t\t\tisGlobalStyles: true,\n\t\t\t},\n\t\t];\n\n\t\t// Loop through the blocks to check if there are custom CSS values.\n\t\t// If there are, get the block selector and push the selector together with\n\t\t// the CSS value to the 'stylesheets' array.\n\t\tgetBlockTypes().forEach( ( blockType ) => {\n\t\t\tif ( mergedConfig.styles.blocks[ blockType.name ]?.css ) {\n\t\t\t\tconst selector = blockSelectors[ blockType.name ].selector;\n\t\t\t\tstylesheets.push( {\n\t\t\t\t\tcss: processCSSNesting(\n\t\t\t\t\t\tmergedConfig.styles.blocks[ blockType.name ]?.css,\n\t\t\t\t\t\tselector\n\t\t\t\t\t),\n\t\t\t\t\tisGlobalStyles: true,\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\n\t\treturn [ stylesheets, mergedConfig.settings, filters ];\n\t}, [\n\t\thasBlockGapSupport,\n\t\thasFallbackGapSupport,\n\t\tmergedConfig,\n\t\tdisableLayoutStyles,\n\t] );\n}\n"]}
@@ -12,7 +12,7 @@ import classnames from 'classnames';
12
12
  import { speak } from '@wordpress/a11y';
13
13
  import { __, _x, sprintf } from '@wordpress/i18n';
14
14
  import { Dropdown, Button } from '@wordpress/components';
15
- import { Component } from '@wordpress/element';
15
+ import { forwardRef, Component } from '@wordpress/element';
16
16
  import { withDispatch, withSelect } from '@wordpress/data';
17
17
  import { compose, ifCondition } from '@wordpress/compose';
18
18
  import { createBlock, store as blocksStore } from '@wordpress/blocks';
@@ -35,21 +35,23 @@ const defaultRenderToggle = _ref => {
35
35
  toggleProps = {},
36
36
  prioritizePatterns
37
37
  } = _ref;
38
- let label;
38
+ const {
39
+ as: Wrapper = Button,
40
+ label: labelProp,
41
+ onClick,
42
+ ...rest
43
+ } = toggleProps;
44
+ let label = labelProp;
39
45
 
40
- if (hasSingleBlockType) {
46
+ if (!label && hasSingleBlockType) {
41
47
  label = sprintf( // translators: %s: the name of the block when there is only one
42
48
  _x('Add %s', 'directly add the only allowed block'), blockTitle);
43
- } else if (prioritizePatterns) {
49
+ } else if (!label && prioritizePatterns) {
44
50
  label = __('Add pattern');
45
- } else {
51
+ } else if (!label) {
46
52
  label = _x('Add block', 'Generic label for block inserter button');
47
- }
53
+ } // Handle both onClick functions from the toggle and the parent component.
48
54
 
49
- const {
50
- onClick,
51
- ...rest
52
- } = toggleProps; // Handle both onClick functions from the toggle and the parent component.
53
55
 
54
56
  function handleClick(event) {
55
57
  if (onToggle) {
@@ -61,7 +63,7 @@ const defaultRenderToggle = _ref => {
61
63
  }
62
64
  }
63
65
 
64
- return createElement(Button, _extends({
66
+ return createElement(Wrapper, _extends({
65
67
  icon: plus,
66
68
  label: label,
67
69
  tooltipPosition: "bottom",
@@ -73,7 +75,7 @@ const defaultRenderToggle = _ref => {
73
75
  }, rest));
74
76
  };
75
77
 
76
- class Inserter extends Component {
78
+ class PrivateInserter extends Component {
77
79
  constructor() {
78
80
  super(...arguments);
79
81
  this.onToggle = this.onToggle.bind(this);
@@ -153,7 +155,8 @@ class Inserter extends Component {
153
155
  __experimentalIsQuick: isQuick,
154
156
  prioritizePatterns,
155
157
  onSelectOrClose,
156
- selectBlockOnInsert
158
+ selectBlockOnInsert,
159
+ orderInitialBlockItems
157
160
  } = this.props;
158
161
 
159
162
  if (isQuick) {
@@ -171,7 +174,8 @@ class Inserter extends Component {
171
174
  clientId: clientId,
172
175
  isAppender: isAppender,
173
176
  prioritizePatterns: prioritizePatterns,
174
- selectBlockOnInsert: selectBlockOnInsert
177
+ selectBlockOnInsert: selectBlockOnInsert,
178
+ orderInitialBlockItems: orderInitialBlockItems
175
179
  });
176
180
  }
177
181
 
@@ -222,7 +226,7 @@ class Inserter extends Component {
222
226
 
223
227
  }
224
228
 
225
- export default compose([withSelect((select, _ref4) => {
229
+ export const ComposedPrivateInserter = compose([withSelect((select, _ref4) => {
226
230
  var _getBlockVariations;
227
231
 
228
232
  let {
@@ -394,5 +398,13 @@ ifCondition(_ref6 => {
394
398
  clientId
395
399
  } = _ref6;
396
400
  return hasItems || !isAppender && !rootClientId && !clientId;
397
- })])(Inserter);
401
+ })])(PrivateInserter);
402
+ const Inserter = forwardRef((props, ref) => {
403
+ return createElement(ComposedPrivateInserter, _extends({
404
+ ref: ref
405
+ }, props, {
406
+ orderInitialBlockItems: undefined
407
+ }));
408
+ });
409
+ export default Inserter;
398
410
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/inserter/index.js"],"names":["classnames","speak","__","_x","sprintf","Dropdown","Button","Component","withDispatch","withSelect","compose","ifCondition","createBlock","store","blocksStore","plus","InserterMenu","QuickInserter","blockEditorStore","defaultRenderToggle","onToggle","disabled","isOpen","blockTitle","hasSingleBlockType","toggleProps","prioritizePatterns","label","onClick","rest","handleClick","event","Inserter","constructor","arguments","bind","renderToggle","renderContent","props","directInsertBlock","hasItems","onClose","rootClientId","clientId","isAppender","showInserterHelpPanel","__experimentalIsQuick","isQuick","onSelectOrClose","selectBlockOnInsert","blocks","firstBlock","Array","isArray","length","render","position","insertOnlyAllowedBlock","select","shouldDirectInsert","getBlockRootClientId","hasInserterItems","getAllowedBlocks","__experimentalGetDirectInsertBlock","getSettings","getBlockVariations","undefined","allowedBlocks","settings","name","allowedBlockType","title","__experimentalPreferPatternsOnRoot","dispatch","ownProps","getAdjacentBlockAttributes","attributesToCopy","getBlock","getPreviousBlockClientId","result","adjacentAttributes","parentBlock","innerBlocks","lastInnerBlock","attributes","currentBlock","previousBlock","forEach","attribute","hasOwnProperty","getInsertionIndex","getBlockIndex","getBlockSelectionEnd","getBlockOrder","end","insertBlock","blockToInsert","newAttributes","message"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,KAAT,QAAsB,iBAAtB;AACA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AACA,SAASC,QAAT,EAAmBC,MAAnB,QAAiC,uBAAjC;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,YAAT,EAAuBC,UAAvB,QAAyC,iBAAzC;AACA,SAASC,OAAT,EAAkBC,WAAlB,QAAqC,oBAArC;AACA,SAASC,WAAT,EAAsBC,KAAK,IAAIC,WAA/B,QAAkD,mBAAlD;AACA,SAASC,IAAT,QAAqB,kBAArB;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,QAAzB;AACA,OAAOC,aAAP,MAA0B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,CAAX;;AAOA,UAAKD,eAAL,EAAuB;AAAA;;AACtBA,QAAAA,eAAe,CAAE;AAChBL,UAAAA,QAAQ,oBAAEqD,aAAF,mDAAE,eAAerD;AADT,SAAF,CAAf;AAGA;;AAED,YAAMuD,OAAO,GAAG9F,OAAO,EACtB;AACAF,MAAAA,EAAE,CAAE,gBAAF,CAFoB,EAGtBoE,gBAAgB,CAACC,KAHK,CAAvB;AAKAtE,MAAAA,KAAK,CAAEiG,OAAF,CAAL;AACA;;AA5IK,GAAP;AA8IA,CA/IW,CA/CW,EA+LvB;AACA;AACAvF,WAAW,CACV;AAAA,MAAE;AAAE6B,IAAAA,QAAF;AAAYI,IAAAA,UAAZ;AAAwBF,IAAAA,YAAxB;AAAsCC,IAAAA;AAAtC,GAAF;AAAA,SACCH,QAAQ,IAAM,CAAEI,UAAF,IAAgB,CAAEF,YAAlB,IAAkC,CAAEC,QADnD;AAAA,CADU,CAjMY,CAAF,CAAP,CAqMVX,QArMU,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { Dropdown, Button } from '@wordpress/components';\nimport { Component } from '@wordpress/element';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose, ifCondition } from '@wordpress/compose';\nimport { createBlock, store as blocksStore } from '@wordpress/blocks';\nimport { plus } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport InserterMenu from './menu';\nimport QuickInserter from './quick-inserter';\nimport { store as blockEditorStore } from '../../store';\n\nconst defaultRenderToggle = ( {\n\tonToggle,\n\tdisabled,\n\tisOpen,\n\tblockTitle,\n\thasSingleBlockType,\n\ttoggleProps = {},\n\tprioritizePatterns,\n} ) => {\n\tlet label;\n\tif ( hasSingleBlockType ) {\n\t\tlabel = sprintf(\n\t\t\t// translators: %s: the name of the block when there is only one\n\t\t\t_x( 'Add %s', 'directly add the only allowed block' ),\n\t\t\tblockTitle\n\t\t);\n\t} else if ( prioritizePatterns ) {\n\t\tlabel = __( 'Add pattern' );\n\t} else {\n\t\tlabel = _x( 'Add block', 'Generic label for block inserter button' );\n\t}\n\n\tconst { onClick, ...rest } = toggleProps;\n\n\t// Handle both onClick functions from the toggle and the parent component.\n\tfunction handleClick( event ) {\n\t\tif ( onToggle ) {\n\t\t\tonToggle( event );\n\t\t}\n\t\tif ( onClick ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\treturn (\n\t\t<Button\n\t\t\ticon={ plus }\n\t\t\tlabel={ label }\n\t\t\ttooltipPosition=\"bottom\"\n\t\t\tonClick={ handleClick }\n\t\t\tclassName=\"block-editor-inserter__toggle\"\n\t\t\taria-haspopup={ ! hasSingleBlockType ? 'true' : false }\n\t\t\taria-expanded={ ! hasSingleBlockType ? isOpen : false }\n\t\t\tdisabled={ disabled }\n\t\t\t{ ...rest }\n\t\t/>\n\t);\n};\n\nclass Inserter extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.onToggle = this.onToggle.bind( this );\n\t\tthis.renderToggle = this.renderToggle.bind( this );\n\t\tthis.renderContent = this.renderContent.bind( this );\n\t}\n\n\tonToggle( isOpen ) {\n\t\tconst { onToggle } = this.props;\n\n\t\t// Surface toggle callback to parent component.\n\t\tif ( onToggle ) {\n\t\t\tonToggle( isOpen );\n\t\t}\n\t}\n\n\t/**\n\t * Render callback to display Dropdown toggle element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onToggle Callback to invoke when toggle is\n\t * pressed.\n\t * @param {boolean} options.isOpen Whether dropdown is currently open.\n\t *\n\t * @return {WPElement} Dropdown toggle element.\n\t */\n\trenderToggle( { onToggle, isOpen } ) {\n\t\tconst {\n\t\t\tdisabled,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\tdirectInsertBlock,\n\t\t\ttoggleProps,\n\t\t\thasItems,\n\t\t\trenderToggle = defaultRenderToggle,\n\t\t\tprioritizePatterns,\n\t\t} = this.props;\n\n\t\treturn renderToggle( {\n\t\t\tonToggle,\n\t\t\tisOpen,\n\t\t\tdisabled: disabled || ! hasItems,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\tdirectInsertBlock,\n\t\t\ttoggleProps,\n\t\t\tprioritizePatterns,\n\t\t} );\n\t}\n\n\t/**\n\t * Render callback to display Dropdown content element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onClose Callback to invoke when dropdown is\n\t * closed.\n\t *\n\t * @return {WPElement} Dropdown content element.\n\t */\n\trenderContent( { onClose } ) {\n\t\tconst {\n\t\t\trootClientId,\n\t\t\tclientId,\n\t\t\tisAppender,\n\t\t\tshowInserterHelpPanel,\n\n\t\t\t// This prop is experimental to give some time for the quick inserter to mature\n\t\t\t// Feel free to make them stable after a few releases.\n\t\t\t__experimentalIsQuick: isQuick,\n\t\t\tprioritizePatterns,\n\t\t\tonSelectOrClose,\n\t\t\tselectBlockOnInsert,\n\t\t} = this.props;\n\n\t\tif ( isQuick ) {\n\t\t\treturn (\n\t\t\t\t<QuickInserter\n\t\t\t\t\tonSelect={ ( blocks ) => {\n\t\t\t\t\t\tconst firstBlock =\n\t\t\t\t\t\t\tArray.isArray( blocks ) && blocks?.length\n\t\t\t\t\t\t\t\t? blocks[ 0 ]\n\t\t\t\t\t\t\t\t: blocks;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tonSelectOrClose &&\n\t\t\t\t\t\t\ttypeof onSelectOrClose === 'function'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tonSelectOrClose( firstBlock );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisAppender={ isAppender }\n\t\t\t\t\tprioritizePatterns={ prioritizePatterns }\n\t\t\t\t\tselectBlockOnInsert={ selectBlockOnInsert }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<InserterMenu\n\t\t\t\tonSelect={ () => {\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tisAppender={ isAppender }\n\t\t\t\tshowInserterHelpPanel={ showInserterHelpPanel }\n\t\t\t\tprioritizePatterns={ prioritizePatterns }\n\t\t\t/>\n\t\t);\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tposition,\n\t\t\thasSingleBlockType,\n\t\t\tdirectInsertBlock,\n\t\t\tinsertOnlyAllowedBlock,\n\t\t\t__experimentalIsQuick: isQuick,\n\t\t\tonSelectOrClose,\n\t\t} = this.props;\n\n\t\tif ( hasSingleBlockType || directInsertBlock ) {\n\t\t\treturn this.renderToggle( { onToggle: insertOnlyAllowedBlock } );\n\t\t}\n\n\t\treturn (\n\t\t\t<Dropdown\n\t\t\t\tclassName=\"block-editor-inserter\"\n\t\t\t\tcontentClassName={ classnames(\n\t\t\t\t\t'block-editor-inserter__popover',\n\t\t\t\t\t{ 'is-quick': isQuick }\n\t\t\t\t) }\n\t\t\t\tpopoverProps={ { position } }\n\t\t\t\tonToggle={ this.onToggle }\n\t\t\t\texpandOnMobile\n\t\t\t\theaderTitle={ __( 'Add a block' ) }\n\t\t\t\trenderToggle={ this.renderToggle }\n\t\t\t\trenderContent={ this.renderContent }\n\t\t\t\tonClose={ onSelectOrClose }\n\t\t\t/>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect(\n\t\t( select, { clientId, rootClientId, shouldDirectInsert = true } ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\thasInserterItems,\n\t\t\t\tgetAllowedBlocks,\n\t\t\t\t__experimentalGetDirectInsertBlock,\n\t\t\t\tgetSettings,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst { getBlockVariations } = select( blocksStore );\n\n\t\t\trootClientId =\n\t\t\t\trootClientId || getBlockRootClientId( clientId ) || undefined;\n\n\t\t\tconst allowedBlocks = getAllowedBlocks( rootClientId );\n\n\t\t\tconst directInsertBlock =\n\t\t\t\tshouldDirectInsert &&\n\t\t\t\t__experimentalGetDirectInsertBlock( rootClientId );\n\n\t\t\tconst settings = getSettings();\n\n\t\t\tconst hasSingleBlockType =\n\t\t\t\tallowedBlocks?.length === 1 &&\n\t\t\t\tgetBlockVariations( allowedBlocks[ 0 ].name, 'inserter' )\n\t\t\t\t\t?.length === 0;\n\n\t\t\tlet allowedBlockType = false;\n\t\t\tif ( hasSingleBlockType ) {\n\t\t\t\tallowedBlockType = allowedBlocks[ 0 ];\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\thasItems: hasInserterItems( rootClientId ),\n\t\t\t\thasSingleBlockType,\n\t\t\t\tblockTitle: allowedBlockType ? allowedBlockType.title : '',\n\t\t\t\tallowedBlockType,\n\t\t\t\tdirectInsertBlock,\n\t\t\t\trootClientId,\n\t\t\t\tprioritizePatterns:\n\t\t\t\t\tsettings.__experimentalPreferPatternsOnRoot &&\n\t\t\t\t\t! rootClientId,\n\t\t\t};\n\t\t}\n\t),\n\twithDispatch( ( dispatch, ownProps, { select } ) => {\n\t\treturn {\n\t\t\tinsertOnlyAllowedBlock() {\n\t\t\t\tconst {\n\t\t\t\t\trootClientId,\n\t\t\t\t\tclientId,\n\t\t\t\t\tisAppender,\n\t\t\t\t\thasSingleBlockType,\n\t\t\t\t\tallowedBlockType,\n\t\t\t\t\tdirectInsertBlock,\n\t\t\t\t\tonSelectOrClose,\n\t\t\t\t\tselectBlockOnInsert,\n\t\t\t\t} = ownProps;\n\n\t\t\t\tif ( ! hasSingleBlockType && ! directInsertBlock ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tfunction getAdjacentBlockAttributes( attributesToCopy ) {\n\t\t\t\t\tconst { getBlock, getPreviousBlockClientId } =\n\t\t\t\t\t\tselect( blockEditorStore );\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t! attributesToCopy ||\n\t\t\t\t\t\t( ! clientId && ! rootClientId )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn {};\n\t\t\t\t\t}\n\n\t\t\t\t\tconst result = {};\n\t\t\t\t\tlet adjacentAttributes = {};\n\n\t\t\t\t\t// If there is no clientId, then attempt to get attributes\n\t\t\t\t\t// from the last block within innerBlocks of the root block.\n\t\t\t\t\tif ( ! clientId ) {\n\t\t\t\t\t\tconst parentBlock = getBlock( rootClientId );\n\n\t\t\t\t\t\tif ( parentBlock?.innerBlocks?.length ) {\n\t\t\t\t\t\t\tconst lastInnerBlock =\n\t\t\t\t\t\t\t\tparentBlock.innerBlocks[\n\t\t\t\t\t\t\t\t\tparentBlock.innerBlocks.length - 1\n\t\t\t\t\t\t\t\t];\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tdirectInsertBlock &&\n\t\t\t\t\t\t\t\tdirectInsertBlock?.name === lastInnerBlock.name\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tadjacentAttributes = lastInnerBlock.attributes;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Otherwise, attempt to get attributes from the\n\t\t\t\t\t\t// previous block relative to the current clientId.\n\t\t\t\t\t\tconst currentBlock = getBlock( clientId );\n\t\t\t\t\t\tconst previousBlock = getBlock(\n\t\t\t\t\t\t\tgetPreviousBlockClientId( clientId )\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif ( currentBlock?.name === previousBlock?.name ) {\n\t\t\t\t\t\t\tadjacentAttributes =\n\t\t\t\t\t\t\t\tpreviousBlock?.attributes || {};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Copy over only those attributes flagged to be copied.\n\t\t\t\t\tattributesToCopy.forEach( ( attribute ) => {\n\t\t\t\t\t\tif ( adjacentAttributes.hasOwnProperty( attribute ) ) {\n\t\t\t\t\t\t\tresult[ attribute ] =\n\t\t\t\t\t\t\t\tadjacentAttributes[ attribute ];\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\tfunction getInsertionIndex() {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tgetBlockIndex,\n\t\t\t\t\t\tgetBlockSelectionEnd,\n\t\t\t\t\t\tgetBlockOrder,\n\t\t\t\t\t\tgetBlockRootClientId,\n\t\t\t\t\t} = select( blockEditorStore );\n\n\t\t\t\t\t// If the clientId is defined, we insert at the position of the block.\n\t\t\t\t\tif ( clientId ) {\n\t\t\t\t\t\treturn getBlockIndex( clientId );\n\t\t\t\t\t}\n\n\t\t\t\t\t// If there a selected block, we insert after the selected block.\n\t\t\t\t\tconst end = getBlockSelectionEnd();\n\t\t\t\t\tif (\n\t\t\t\t\t\t! isAppender &&\n\t\t\t\t\t\tend &&\n\t\t\t\t\t\tgetBlockRootClientId( end ) === rootClientId\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn getBlockIndex( end ) + 1;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Otherwise, we insert at the end of the current rootClientId.\n\t\t\t\t\treturn getBlockOrder( rootClientId ).length;\n\t\t\t\t}\n\n\t\t\t\tconst { insertBlock } = dispatch( blockEditorStore );\n\n\t\t\t\tlet blockToInsert;\n\n\t\t\t\t// Attempt to augment the directInsertBlock with attributes from an adjacent block.\n\t\t\t\t// This ensures styling from nearby blocks is preserved in the newly inserted block.\n\t\t\t\t// See: https://github.com/WordPress/gutenberg/issues/37904\n\t\t\t\tif ( directInsertBlock ) {\n\t\t\t\t\tconst newAttributes = getAdjacentBlockAttributes(\n\t\t\t\t\t\tdirectInsertBlock.attributesToCopy\n\t\t\t\t\t);\n\n\t\t\t\t\tblockToInsert = createBlock( directInsertBlock.name, {\n\t\t\t\t\t\t...( directInsertBlock.attributes || {} ),\n\t\t\t\t\t\t...newAttributes,\n\t\t\t\t\t} );\n\t\t\t\t} else {\n\t\t\t\t\tblockToInsert = createBlock( allowedBlockType.name );\n\t\t\t\t}\n\n\t\t\t\tinsertBlock(\n\t\t\t\t\tblockToInsert,\n\t\t\t\t\tgetInsertionIndex(),\n\t\t\t\t\trootClientId,\n\t\t\t\t\tselectBlockOnInsert\n\t\t\t\t);\n\n\t\t\t\tif ( onSelectOrClose ) {\n\t\t\t\t\tonSelectOrClose( {\n\t\t\t\t\t\tclientId: blockToInsert?.clientId,\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\tconst message = sprintf(\n\t\t\t\t\t// translators: %s: the name of the block that has been added\n\t\t\t\t\t__( '%s block added' ),\n\t\t\t\t\tallowedBlockType.title\n\t\t\t\t);\n\t\t\t\tspeak( message );\n\t\t\t},\n\t\t};\n\t} ),\n\t// The global inserter should always be visible, we are using ( ! isAppender && ! rootClientId && ! clientId ) as\n\t// a way to detect the global Inserter.\n\tifCondition(\n\t\t( { hasItems, isAppender, rootClientId, clientId } ) =>\n\t\t\thasItems || ( ! isAppender && ! rootClientId && ! clientId )\n\t),\n] )( Inserter );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/inserter/index.js"],"names":["classnames","speak","__","_x","sprintf","Dropdown","Button","forwardRef","Component","withDispatch","withSelect","compose","ifCondition","createBlock","store","blocksStore","plus","InserterMenu","QuickInserter","blockEditorStore","defaultRenderToggle","onToggle","disabled","isOpen","blockTitle","hasSingleBlockType","toggleProps","prioritizePatterns","as","Wrapper","label","labelProp","onClick","rest","handleClick","event","PrivateInserter","constructor","arguments","bind","renderToggle","renderContent","props","directInsertBlock","hasItems","onClose","rootClientId","clientId","isAppender","showInserterHelpPanel","__experimentalIsQuick","isQuick","onSelectOrClose","selectBlockOnInsert","orderInitialBlockItems","blocks","firstBlock","Array","isArray","length","render","position","insertOnlyAllowedBlock","ComposedPrivateInserter","select","shouldDirectInsert","getBlockRootClientId","hasInserterItems","getAllowedBlocks","__experimentalGetDirectInsertBlock","getSettings","getBlockVariations","undefined","allowedBlocks","settings","name","allowedBlockType","title","__experimentalPreferPatternsOnRoot","dispatch","ownProps","getAdjacentBlockAttributes","attributesToCopy","getBlock","getPreviousBlockClientId","result","adjacentAttributes","parentBlock","innerBlocks","lastInnerBlock","attributes","currentBlock","previousBlock","forEach","attribute","hasOwnProperty","getInsertionIndex","getBlockIndex","getBlockSelectionEnd","getBlockOrder","end","insertBlock","blockToInsert","newAttributes","message","Inserter","ref"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,KAAT,QAAsB,iBAAtB;AACA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AACA,SAASC,QAAT,EAAmBC,MAAnB,QAAiC,uBAAjC;AACA,SAASC,UAAT,EAAqBC,SAArB,QAAsC,oBAAtC;AACA,SAASC,YAAT,EAAuBC,UAAvB,QAAyC,iBAAzC;AACA,SAASC,OAAT,EAAkBC,WAAlB,QAAqC,oBAArC;AACA,SAASC,WAAT,EAAsBC,KAAK,IAAIC,WAA/B,QAAkD,mBAAlD;AACA,SAASC,IAAT,QAAqB,kBAArB;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,QAAzB;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,SAASJ,KAAK,IAAIK,gBAAlB,QAA0C,aAA1C;;AAEA,MAAMC,mBAAmB,GAAG,QAQrB;AAAA,MARuB;AAC7BC,IAAAA,QAD6B;AAE7BC,IAAAA,QAF6B;AAG7BC,IAAAA,MAH6B;AAI7BC,IAAAA,UAJ6B;AAK7BC,IAAAA,kBAL6B;AAM7BC,IAAAA,WAAW,GAAG,EANe;AAO7BC,IAAAA;AAP6B,GAQvB;AACN,QAAM;AACLC,IAAAA,EAAE,EAAEC,OAAO,GAAGvB,MADT;AAELwB,IAAAA,KAAK,EAAEC,SAFF;AAGLC,IAAAA,OAHK;AAIL,OAAGC;AAJE,MAKFP,WALJ;AAOA,MAAII,KAA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EACtB;AACAF,MAAAA,EAAE,CAAE,gBAAF,CAFoB,EAGtB0E,gBAAgB,CAACC,KAHK,CAAvB;AAKA5E,MAAAA,KAAK,CAAEuG,OAAF,CAAL;AACA;;AA5IK,GAAP;AA8IA,CA/IW,CA/CmC,EA+L/C;AACA;AACA5F,WAAW,CACV;AAAA,MAAE;AAAEgC,IAAAA,QAAF;AAAYI,IAAAA,UAAZ;AAAwBF,IAAAA,YAAxB;AAAsCC,IAAAA;AAAtC,GAAF;AAAA,SACCH,QAAQ,IAAM,CAAEI,UAAF,IAAgB,CAAEF,YAAlB,IAAkC,CAAEC,QADnD;AAAA,CADU,CAjMoC,CAAF,CAAP,CAqMlCX,eArMkC,CAAhC;AAuMP,MAAMqE,QAAQ,GAAGlG,UAAU,CAAE,CAAEmC,KAAF,EAASgE,GAAT,KAAkB;AAC9C,SACC,cAAC,uBAAD;AACC,IAAA,GAAG,EAAGA;AADP,KAEMhE,KAFN;AAGC,IAAA,sBAAsB,EAAG8B;AAH1B,KADD;AAOA,CAR0B,CAA3B;AAUA,eAAeiC,QAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { Dropdown, Button } from '@wordpress/components';\nimport { forwardRef, Component } from '@wordpress/element';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose, ifCondition } from '@wordpress/compose';\nimport { createBlock, store as blocksStore } from '@wordpress/blocks';\nimport { plus } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport InserterMenu from './menu';\nimport QuickInserter from './quick-inserter';\nimport { store as blockEditorStore } from '../../store';\n\nconst defaultRenderToggle = ( {\n\tonToggle,\n\tdisabled,\n\tisOpen,\n\tblockTitle,\n\thasSingleBlockType,\n\ttoggleProps = {},\n\tprioritizePatterns,\n} ) => {\n\tconst {\n\t\tas: Wrapper = Button,\n\t\tlabel: labelProp,\n\t\tonClick,\n\t\t...rest\n\t} = toggleProps;\n\n\tlet label = labelProp;\n\tif ( ! label && hasSingleBlockType ) {\n\t\tlabel = sprintf(\n\t\t\t// translators: %s: the name of the block when there is only one\n\t\t\t_x( 'Add %s', 'directly add the only allowed block' ),\n\t\t\tblockTitle\n\t\t);\n\t} else if ( ! label && prioritizePatterns ) {\n\t\tlabel = __( 'Add pattern' );\n\t} else if ( ! label ) {\n\t\tlabel = _x( 'Add block', 'Generic label for block inserter button' );\n\t}\n\n\t// Handle both onClick functions from the toggle and the parent component.\n\tfunction handleClick( event ) {\n\t\tif ( onToggle ) {\n\t\t\tonToggle( event );\n\t\t}\n\t\tif ( onClick ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\treturn (\n\t\t<Wrapper\n\t\t\ticon={ plus }\n\t\t\tlabel={ label }\n\t\t\ttooltipPosition=\"bottom\"\n\t\t\tonClick={ handleClick }\n\t\t\tclassName=\"block-editor-inserter__toggle\"\n\t\t\taria-haspopup={ ! hasSingleBlockType ? 'true' : false }\n\t\t\taria-expanded={ ! hasSingleBlockType ? isOpen : false }\n\t\t\tdisabled={ disabled }\n\t\t\t{ ...rest }\n\t\t/>\n\t);\n};\n\nclass PrivateInserter extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.onToggle = this.onToggle.bind( this );\n\t\tthis.renderToggle = this.renderToggle.bind( this );\n\t\tthis.renderContent = this.renderContent.bind( this );\n\t}\n\n\tonToggle( isOpen ) {\n\t\tconst { onToggle } = this.props;\n\n\t\t// Surface toggle callback to parent component.\n\t\tif ( onToggle ) {\n\t\t\tonToggle( isOpen );\n\t\t}\n\t}\n\n\t/**\n\t * Render callback to display Dropdown toggle element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onToggle Callback to invoke when toggle is\n\t * pressed.\n\t * @param {boolean} options.isOpen Whether dropdown is currently open.\n\t *\n\t * @return {WPElement} Dropdown toggle element.\n\t */\n\trenderToggle( { onToggle, isOpen } ) {\n\t\tconst {\n\t\t\tdisabled,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\tdirectInsertBlock,\n\t\t\ttoggleProps,\n\t\t\thasItems,\n\t\t\trenderToggle = defaultRenderToggle,\n\t\t\tprioritizePatterns,\n\t\t} = this.props;\n\n\t\treturn renderToggle( {\n\t\t\tonToggle,\n\t\t\tisOpen,\n\t\t\tdisabled: disabled || ! hasItems,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\tdirectInsertBlock,\n\t\t\ttoggleProps,\n\t\t\tprioritizePatterns,\n\t\t} );\n\t}\n\n\t/**\n\t * Render callback to display Dropdown content element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onClose Callback to invoke when dropdown is\n\t * closed.\n\t *\n\t * @return {WPElement} Dropdown content element.\n\t */\n\trenderContent( { onClose } ) {\n\t\tconst {\n\t\t\trootClientId,\n\t\t\tclientId,\n\t\t\tisAppender,\n\t\t\tshowInserterHelpPanel,\n\n\t\t\t// This prop is experimental to give some time for the quick inserter to mature\n\t\t\t// Feel free to make them stable after a few releases.\n\t\t\t__experimentalIsQuick: isQuick,\n\t\t\tprioritizePatterns,\n\t\t\tonSelectOrClose,\n\t\t\tselectBlockOnInsert,\n\t\t\torderInitialBlockItems,\n\t\t} = this.props;\n\n\t\tif ( isQuick ) {\n\t\t\treturn (\n\t\t\t\t<QuickInserter\n\t\t\t\t\tonSelect={ ( blocks ) => {\n\t\t\t\t\t\tconst firstBlock =\n\t\t\t\t\t\t\tArray.isArray( blocks ) && blocks?.length\n\t\t\t\t\t\t\t\t? blocks[ 0 ]\n\t\t\t\t\t\t\t\t: blocks;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tonSelectOrClose &&\n\t\t\t\t\t\t\ttypeof onSelectOrClose === 'function'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tonSelectOrClose( firstBlock );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisAppender={ isAppender }\n\t\t\t\t\tprioritizePatterns={ prioritizePatterns }\n\t\t\t\t\tselectBlockOnInsert={ selectBlockOnInsert }\n\t\t\t\t\torderInitialBlockItems={ orderInitialBlockItems }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<InserterMenu\n\t\t\t\tonSelect={ () => {\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tisAppender={ isAppender }\n\t\t\t\tshowInserterHelpPanel={ showInserterHelpPanel }\n\t\t\t\tprioritizePatterns={ prioritizePatterns }\n\t\t\t/>\n\t\t);\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tposition,\n\t\t\thasSingleBlockType,\n\t\t\tdirectInsertBlock,\n\t\t\tinsertOnlyAllowedBlock,\n\t\t\t__experimentalIsQuick: isQuick,\n\t\t\tonSelectOrClose,\n\t\t} = this.props;\n\n\t\tif ( hasSingleBlockType || directInsertBlock ) {\n\t\t\treturn this.renderToggle( { onToggle: insertOnlyAllowedBlock } );\n\t\t}\n\n\t\treturn (\n\t\t\t<Dropdown\n\t\t\t\tclassName=\"block-editor-inserter\"\n\t\t\t\tcontentClassName={ classnames(\n\t\t\t\t\t'block-editor-inserter__popover',\n\t\t\t\t\t{ 'is-quick': isQuick }\n\t\t\t\t) }\n\t\t\t\tpopoverProps={ { position } }\n\t\t\t\tonToggle={ this.onToggle }\n\t\t\t\texpandOnMobile\n\t\t\t\theaderTitle={ __( 'Add a block' ) }\n\t\t\t\trenderToggle={ this.renderToggle }\n\t\t\t\trenderContent={ this.renderContent }\n\t\t\t\tonClose={ onSelectOrClose }\n\t\t\t/>\n\t\t);\n\t}\n}\n\nexport const ComposedPrivateInserter = compose( [\n\twithSelect(\n\t\t( select, { clientId, rootClientId, shouldDirectInsert = true } ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\thasInserterItems,\n\t\t\t\tgetAllowedBlocks,\n\t\t\t\t__experimentalGetDirectInsertBlock,\n\t\t\t\tgetSettings,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst { getBlockVariations } = select( blocksStore );\n\n\t\t\trootClientId =\n\t\t\t\trootClientId || getBlockRootClientId( clientId ) || undefined;\n\n\t\t\tconst allowedBlocks = getAllowedBlocks( rootClientId );\n\n\t\t\tconst directInsertBlock =\n\t\t\t\tshouldDirectInsert &&\n\t\t\t\t__experimentalGetDirectInsertBlock( rootClientId );\n\n\t\t\tconst settings = getSettings();\n\n\t\t\tconst hasSingleBlockType =\n\t\t\t\tallowedBlocks?.length === 1 &&\n\t\t\t\tgetBlockVariations( allowedBlocks[ 0 ].name, 'inserter' )\n\t\t\t\t\t?.length === 0;\n\n\t\t\tlet allowedBlockType = false;\n\t\t\tif ( hasSingleBlockType ) {\n\t\t\t\tallowedBlockType = allowedBlocks[ 0 ];\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\thasItems: hasInserterItems( rootClientId ),\n\t\t\t\thasSingleBlockType,\n\t\t\t\tblockTitle: allowedBlockType ? allowedBlockType.title : '',\n\t\t\t\tallowedBlockType,\n\t\t\t\tdirectInsertBlock,\n\t\t\t\trootClientId,\n\t\t\t\tprioritizePatterns:\n\t\t\t\t\tsettings.__experimentalPreferPatternsOnRoot &&\n\t\t\t\t\t! rootClientId,\n\t\t\t};\n\t\t}\n\t),\n\twithDispatch( ( dispatch, ownProps, { select } ) => {\n\t\treturn {\n\t\t\tinsertOnlyAllowedBlock() {\n\t\t\t\tconst {\n\t\t\t\t\trootClientId,\n\t\t\t\t\tclientId,\n\t\t\t\t\tisAppender,\n\t\t\t\t\thasSingleBlockType,\n\t\t\t\t\tallowedBlockType,\n\t\t\t\t\tdirectInsertBlock,\n\t\t\t\t\tonSelectOrClose,\n\t\t\t\t\tselectBlockOnInsert,\n\t\t\t\t} = ownProps;\n\n\t\t\t\tif ( ! hasSingleBlockType && ! directInsertBlock ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tfunction getAdjacentBlockAttributes( attributesToCopy ) {\n\t\t\t\t\tconst { getBlock, getPreviousBlockClientId } =\n\t\t\t\t\t\tselect( blockEditorStore );\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t! attributesToCopy ||\n\t\t\t\t\t\t( ! clientId && ! rootClientId )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn {};\n\t\t\t\t\t}\n\n\t\t\t\t\tconst result = {};\n\t\t\t\t\tlet adjacentAttributes = {};\n\n\t\t\t\t\t// If there is no clientId, then attempt to get attributes\n\t\t\t\t\t// from the last block within innerBlocks of the root block.\n\t\t\t\t\tif ( ! clientId ) {\n\t\t\t\t\t\tconst parentBlock = getBlock( rootClientId );\n\n\t\t\t\t\t\tif ( parentBlock?.innerBlocks?.length ) {\n\t\t\t\t\t\t\tconst lastInnerBlock =\n\t\t\t\t\t\t\t\tparentBlock.innerBlocks[\n\t\t\t\t\t\t\t\t\tparentBlock.innerBlocks.length - 1\n\t\t\t\t\t\t\t\t];\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tdirectInsertBlock &&\n\t\t\t\t\t\t\t\tdirectInsertBlock?.name === lastInnerBlock.name\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tadjacentAttributes = lastInnerBlock.attributes;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Otherwise, attempt to get attributes from the\n\t\t\t\t\t\t// previous block relative to the current clientId.\n\t\t\t\t\t\tconst currentBlock = getBlock( clientId );\n\t\t\t\t\t\tconst previousBlock = getBlock(\n\t\t\t\t\t\t\tgetPreviousBlockClientId( clientId )\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif ( currentBlock?.name === previousBlock?.name ) {\n\t\t\t\t\t\t\tadjacentAttributes =\n\t\t\t\t\t\t\t\tpreviousBlock?.attributes || {};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Copy over only those attributes flagged to be copied.\n\t\t\t\t\tattributesToCopy.forEach( ( attribute ) => {\n\t\t\t\t\t\tif ( adjacentAttributes.hasOwnProperty( attribute ) ) {\n\t\t\t\t\t\t\tresult[ attribute ] =\n\t\t\t\t\t\t\t\tadjacentAttributes[ attribute ];\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\tfunction getInsertionIndex() {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tgetBlockIndex,\n\t\t\t\t\t\tgetBlockSelectionEnd,\n\t\t\t\t\t\tgetBlockOrder,\n\t\t\t\t\t\tgetBlockRootClientId,\n\t\t\t\t\t} = select( blockEditorStore );\n\n\t\t\t\t\t// If the clientId is defined, we insert at the position of the block.\n\t\t\t\t\tif ( clientId ) {\n\t\t\t\t\t\treturn getBlockIndex( clientId );\n\t\t\t\t\t}\n\n\t\t\t\t\t// If there a selected block, we insert after the selected block.\n\t\t\t\t\tconst end = getBlockSelectionEnd();\n\t\t\t\t\tif (\n\t\t\t\t\t\t! isAppender &&\n\t\t\t\t\t\tend &&\n\t\t\t\t\t\tgetBlockRootClientId( end ) === rootClientId\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn getBlockIndex( end ) + 1;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Otherwise, we insert at the end of the current rootClientId.\n\t\t\t\t\treturn getBlockOrder( rootClientId ).length;\n\t\t\t\t}\n\n\t\t\t\tconst { insertBlock } = dispatch( blockEditorStore );\n\n\t\t\t\tlet blockToInsert;\n\n\t\t\t\t// Attempt to augment the directInsertBlock with attributes from an adjacent block.\n\t\t\t\t// This ensures styling from nearby blocks is preserved in the newly inserted block.\n\t\t\t\t// See: https://github.com/WordPress/gutenberg/issues/37904\n\t\t\t\tif ( directInsertBlock ) {\n\t\t\t\t\tconst newAttributes = getAdjacentBlockAttributes(\n\t\t\t\t\t\tdirectInsertBlock.attributesToCopy\n\t\t\t\t\t);\n\n\t\t\t\t\tblockToInsert = createBlock( directInsertBlock.name, {\n\t\t\t\t\t\t...( directInsertBlock.attributes || {} ),\n\t\t\t\t\t\t...newAttributes,\n\t\t\t\t\t} );\n\t\t\t\t} else {\n\t\t\t\t\tblockToInsert = createBlock( allowedBlockType.name );\n\t\t\t\t}\n\n\t\t\t\tinsertBlock(\n\t\t\t\t\tblockToInsert,\n\t\t\t\t\tgetInsertionIndex(),\n\t\t\t\t\trootClientId,\n\t\t\t\t\tselectBlockOnInsert\n\t\t\t\t);\n\n\t\t\t\tif ( onSelectOrClose ) {\n\t\t\t\t\tonSelectOrClose( {\n\t\t\t\t\t\tclientId: blockToInsert?.clientId,\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\tconst message = sprintf(\n\t\t\t\t\t// translators: %s: the name of the block that has been added\n\t\t\t\t\t__( '%s block added' ),\n\t\t\t\t\tallowedBlockType.title\n\t\t\t\t);\n\t\t\t\tspeak( message );\n\t\t\t},\n\t\t};\n\t} ),\n\t// The global inserter should always be visible, we are using ( ! isAppender && ! rootClientId && ! clientId ) as\n\t// a way to detect the global Inserter.\n\tifCondition(\n\t\t( { hasItems, isAppender, rootClientId, clientId } ) =>\n\t\t\thasItems || ( ! isAppender && ! rootClientId && ! clientId )\n\t),\n] )( PrivateInserter );\n\nconst Inserter = forwardRef( ( props, ref ) => {\n\treturn (\n\t\t<ComposedPrivateInserter\n\t\t\tref={ ref }\n\t\t\t{ ...props }\n\t\t\torderInitialBlockItems={ undefined }\n\t\t/>\n\t);\n} );\n\nexport default Inserter;\n"]}
@@ -107,7 +107,7 @@ function InserterMenu(_ref, ref) {
107
107
  className: "block-editor-inserter__tips"
108
108
  }, createElement(VisuallyHidden, {
109
109
  as: "h2"
110
- }, __('A tip for using the block editor')), createElement(Tips, null))), [destinationRootClientId, onInsert, onHover, delayedFilterValue, showMostUsedBlocks, showInserterHelpPanel]);
110
+ }, __('A tip for using the block editor')), createElement(Tips, null))), [destinationRootClientId, onInsert, onHover, showMostUsedBlocks, showInserterHelpPanel]);
111
111
  const patternsTab = useMemo(() => createElement(BlockPatternsTabs, {
112
112
  rootClientId: destinationRootClientId,
113
113
  onInsert: onInsertPattern,