@wordpress/block-editor 13.2.0 → 13.4.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 (538) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +0 -5
  3. package/build/components/alignment-control/ui.js +2 -2
  4. package/build/components/alignment-control/ui.js.map +1 -1
  5. package/build/components/block-alignment-control/ui.js +1 -1
  6. package/build/components/block-alignment-control/ui.js.map +1 -1
  7. package/build/components/block-alignment-control/ui.native.js +1 -1
  8. package/build/components/block-alignment-control/ui.native.js.map +1 -1
  9. package/build/components/block-breadcrumb/index.js +12 -1
  10. package/build/components/block-breadcrumb/index.js.map +1 -1
  11. package/build/components/block-inspector/index.js +6 -3
  12. package/build/components/block-inspector/index.js.map +1 -1
  13. package/build/components/block-list/use-block-props/index.js +3 -1
  14. package/build/components/block-list/use-block-props/index.js.map +1 -1
  15. package/build/components/block-list/use-block-props/use-block-refs.js +9 -2
  16. package/build/components/block-list/use-block-props/use-block-refs.js.map +1 -1
  17. package/build/components/block-list/use-block-props/use-is-hovered.js +25 -9
  18. package/build/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
  19. package/build/components/block-list/use-in-between-inserter.js +3 -2
  20. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  21. package/build/components/block-lock/modal.js +2 -0
  22. package/build/components/block-lock/modal.js.map +1 -1
  23. package/build/components/block-lock/toolbar.js +0 -1
  24. package/build/components/block-lock/toolbar.js.map +1 -1
  25. package/build/components/block-mover/button.js +1 -1
  26. package/build/components/block-mover/button.js.map +1 -1
  27. package/build/components/block-mover/index.js +1 -1
  28. package/build/components/block-mover/index.js.map +1 -1
  29. package/build/components/block-pattern-setup/setup-toolbar.js +2 -2
  30. package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  31. package/build/components/block-patterns-paging/index.js +5 -7
  32. package/build/components/block-patterns-paging/index.js.map +1 -1
  33. package/build/components/block-quick-navigation/index.js +20 -17
  34. package/build/components/block-quick-navigation/index.js.map +1 -1
  35. package/build/components/block-removal-warning-modal/index.js +2 -0
  36. package/build/components/block-removal-warning-modal/index.js.map +1 -1
  37. package/build/components/block-rename/modal.js +4 -12
  38. package/build/components/block-rename/modal.js.map +1 -1
  39. package/build/components/block-switcher/index.js +1 -1
  40. package/build/components/block-switcher/index.js.map +1 -1
  41. package/build/components/block-switcher/pattern-transformations-menu.js +11 -12
  42. package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  43. package/build/components/block-switcher/preview-block-popover.js +20 -17
  44. package/build/components/block-switcher/preview-block-popover.js.map +1 -1
  45. package/build/components/block-toolbar/shuffle.js +6 -2
  46. package/build/components/block-toolbar/shuffle.js.map +1 -1
  47. package/build/components/block-tools/block-selection-button.js +7 -58
  48. package/build/components/block-tools/block-selection-button.js.map +1 -1
  49. package/build/components/block-tools/block-toolbar-breadcrumb.js +9 -2
  50. package/build/components/block-tools/block-toolbar-breadcrumb.js.map +1 -1
  51. package/build/components/block-tools/index.js +14 -1
  52. package/build/components/block-tools/index.js.map +1 -1
  53. package/build/components/block-tools/use-show-block-tools.js +9 -8
  54. package/build/components/block-tools/use-show-block-tools.js.map +1 -1
  55. package/build/components/block-tools/zoom-out-mode-inserter-button.js +45 -0
  56. package/build/components/block-tools/zoom-out-mode-inserter-button.js.map +1 -0
  57. package/build/components/block-tools/zoom-out-mode-inserters.js +29 -28
  58. package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  59. package/build/components/block-tools/zoom-out-popover.js +58 -0
  60. package/build/components/block-tools/zoom-out-popover.js.map +1 -0
  61. package/build/components/block-tools/zoom-out-toolbar.js +138 -0
  62. package/build/components/block-tools/zoom-out-toolbar.js.map +1 -0
  63. package/build/components/button-block-appender/index.js +3 -1
  64. package/build/components/button-block-appender/index.js.map +1 -1
  65. package/build/components/child-layout-control/index.js +26 -18
  66. package/build/components/child-layout-control/index.js.map +1 -1
  67. package/build/components/date-format-picker/index.js +1 -1
  68. package/build/components/date-format-picker/index.js.map +1 -1
  69. package/build/components/default-block-appender/index.js +7 -4
  70. package/build/components/default-block-appender/index.js.map +1 -1
  71. package/build/components/dimensions-tool/index.js +6 -4
  72. package/build/components/dimensions-tool/index.js.map +1 -1
  73. package/build/components/font-appearance-control/index.js +22 -62
  74. package/build/components/font-appearance-control/index.js.map +1 -1
  75. package/build/components/global-styles/background-panel.js +185 -116
  76. package/build/components/global-styles/background-panel.js.map +1 -1
  77. package/build/components/global-styles/border-panel.js +2 -1
  78. package/build/components/global-styles/border-panel.js.map +1 -1
  79. package/build/components/global-styles/color-panel.js +2 -1
  80. package/build/components/global-styles/color-panel.js.map +1 -1
  81. package/build/components/global-styles/dimensions-panel.js +2 -1
  82. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  83. package/build/components/global-styles/filters-panel.js +2 -1
  84. package/build/components/global-styles/filters-panel.js.map +1 -1
  85. package/build/components/global-styles/hooks.js +13 -1
  86. package/build/components/global-styles/hooks.js.map +1 -1
  87. package/build/components/global-styles/image-settings-panel.js +2 -1
  88. package/build/components/global-styles/image-settings-panel.js.map +1 -1
  89. package/build/components/global-styles/typography-panel.js +45 -24
  90. package/build/components/global-styles/typography-panel.js.map +1 -1
  91. package/build/components/global-styles/typography-utils.js +121 -0
  92. package/build/components/global-styles/typography-utils.js.map +1 -1
  93. package/build/components/global-styles/use-global-styles-output.js +47 -13
  94. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  95. package/build/components/global-styles/utils.js +17 -7
  96. package/build/components/global-styles/utils.js.map +1 -1
  97. package/build/components/grid/grid-item-movers.js +90 -48
  98. package/build/components/grid/grid-item-movers.js.map +1 -1
  99. package/build/components/grid/grid-item-resizer.js +2 -2
  100. package/build/components/grid/grid-item-resizer.js.map +1 -1
  101. package/build/components/grid/grid-visualizer.js +117 -37
  102. package/build/components/grid/grid-visualizer.js.map +1 -1
  103. package/build/components/grid/use-grid-layout-sync.js +60 -41
  104. package/build/components/grid/use-grid-layout-sync.js.map +1 -1
  105. package/build/components/index.js +1 -9
  106. package/build/components/index.js.map +1 -1
  107. package/build/components/inner-blocks/index.js +2 -2
  108. package/build/components/inner-blocks/index.js.map +1 -1
  109. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -19
  110. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
  111. package/build/components/inserter/block-patterns-tab/patterns-filter.js +20 -23
  112. package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
  113. package/build/components/inserter/media-tab/media-panel.js +1 -0
  114. package/build/components/inserter/media-tab/media-panel.js.map +1 -1
  115. package/build/components/inserter/menu.js +26 -4
  116. package/build/components/inserter/menu.js.map +1 -1
  117. package/build/components/inserter/preview-panel.js +20 -3
  118. package/build/components/inserter/preview-panel.js.map +1 -1
  119. package/build/components/inserter/quick-inserter.js +2 -1
  120. package/build/components/inserter/quick-inserter.js.map +1 -1
  121. package/build/components/inserter-draggable-blocks/index.js +10 -3
  122. package/build/components/inserter-draggable-blocks/index.js.map +1 -1
  123. package/build/components/inspector-controls/block-support-tools-panel.js +2 -1
  124. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  125. package/build/components/inspector-controls-tabs/settings-tab.js +1 -2
  126. package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -1
  127. package/build/components/link-control/link-preview.js +1 -1
  128. package/build/components/link-control/link-preview.js.map +1 -1
  129. package/build/components/list-view/block-select-button.js +2 -6
  130. package/build/components/list-view/block-select-button.js.map +1 -1
  131. package/build/components/list-view/block.js +2 -2
  132. package/build/components/list-view/block.js.map +1 -1
  133. package/build/components/list-view/utils.js +3 -1
  134. package/build/components/list-view/utils.js.map +1 -1
  135. package/build/components/media-placeholder/index.js +19 -23
  136. package/build/components/media-placeholder/index.js.map +1 -1
  137. package/build/components/navigable-toolbar/index.js +3 -1
  138. package/build/components/navigable-toolbar/index.js.map +1 -1
  139. package/build/components/rich-text/format-toolbar/index.js +1 -1
  140. package/build/components/rich-text/format-toolbar/index.js.map +1 -1
  141. package/build/components/rich-text/index.js +1 -1
  142. package/build/components/rich-text/index.js.map +1 -1
  143. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +9 -3
  144. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  145. package/build/components/tabbed-sidebar/index.js +66 -0
  146. package/build/components/tabbed-sidebar/index.js.map +1 -0
  147. package/build/components/url-popover/image-url-input-ui.js +3 -3
  148. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  149. package/build/components/url-popover/index.js +3 -0
  150. package/build/components/url-popover/index.js.map +1 -1
  151. package/build/hooks/background.js +26 -4
  152. package/build/hooks/background.js.map +1 -1
  153. package/build/hooks/block-hooks.js +11 -17
  154. package/build/hooks/block-hooks.js.map +1 -1
  155. package/build/hooks/block-style-variation.js +169 -4
  156. package/build/hooks/block-style-variation.js.map +1 -1
  157. package/build/hooks/duotone.js +16 -11
  158. package/build/hooks/duotone.js.map +1 -1
  159. package/build/hooks/grid-visualizer.js +62 -0
  160. package/build/hooks/grid-visualizer.js.map +1 -0
  161. package/build/hooks/index.js +15 -2
  162. package/build/hooks/index.js.map +1 -1
  163. package/build/hooks/layout-child.js +47 -23
  164. package/build/hooks/layout-child.js.map +1 -1
  165. package/build/hooks/position.js +4 -15
  166. package/build/hooks/position.js.map +1 -1
  167. package/build/hooks/use-bindings-attributes.js +96 -55
  168. package/build/hooks/use-bindings-attributes.js.map +1 -1
  169. package/build/hooks/utils.js +2 -0
  170. package/build/hooks/utils.js.map +1 -1
  171. package/build/layouts/constrained.js +50 -4
  172. package/build/layouts/constrained.js.map +1 -1
  173. package/build/layouts/grid.js +92 -51
  174. package/build/layouts/grid.js.map +1 -1
  175. package/build/private-apis.js +6 -4
  176. package/build/private-apis.js.map +1 -1
  177. package/build/store/actions.js +18 -1
  178. package/build/store/actions.js.map +1 -1
  179. package/build/store/defaults.js +0 -2
  180. package/build/store/defaults.js.map +1 -1
  181. package/build/store/defaults.native.js +0 -3
  182. package/build/store/defaults.native.js.map +1 -1
  183. package/build/store/private-keys.js +2 -1
  184. package/build/store/private-keys.js.map +1 -1
  185. package/build/store/reducer.js +19 -1
  186. package/build/store/reducer.js.map +1 -1
  187. package/build/store/selectors.js +13 -1
  188. package/build/store/selectors.js.map +1 -1
  189. package/build/utils/format-font-style.js +45 -0
  190. package/build/utils/format-font-style.js.map +1 -0
  191. package/build/utils/format-font-weight.js +68 -0
  192. package/build/utils/format-font-weight.js.map +1 -0
  193. package/build/utils/get-editor-region.js +34 -0
  194. package/build/utils/get-editor-region.js.map +1 -0
  195. package/build/utils/get-font-styles-and-weights.js +167 -0
  196. package/build/utils/get-font-styles-and-weights.js.map +1 -0
  197. package/build/utils/pasting.js +5 -13
  198. package/build/utils/pasting.js.map +1 -1
  199. package/build-module/components/alignment-control/ui.js +2 -2
  200. package/build-module/components/alignment-control/ui.js.map +1 -1
  201. package/build-module/components/block-alignment-control/ui.js +1 -1
  202. package/build-module/components/block-alignment-control/ui.js.map +1 -1
  203. package/build-module/components/block-alignment-control/ui.native.js +1 -1
  204. package/build-module/components/block-alignment-control/ui.native.js.map +1 -1
  205. package/build-module/components/block-breadcrumb/index.js +12 -1
  206. package/build-module/components/block-breadcrumb/index.js.map +1 -1
  207. package/build-module/components/block-inspector/index.js +6 -3
  208. package/build-module/components/block-inspector/index.js.map +1 -1
  209. package/build-module/components/block-list/use-block-props/index.js +3 -1
  210. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  211. package/build-module/components/block-list/use-block-props/use-block-refs.js +11 -4
  212. package/build-module/components/block-list/use-block-props/use-block-refs.js.map +1 -1
  213. package/build-module/components/block-list/use-block-props/use-is-hovered.js +26 -9
  214. package/build-module/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
  215. package/build-module/components/block-list/use-in-between-inserter.js +3 -2
  216. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  217. package/build-module/components/block-lock/modal.js +2 -0
  218. package/build-module/components/block-lock/modal.js.map +1 -1
  219. package/build-module/components/block-lock/toolbar.js +0 -1
  220. package/build-module/components/block-lock/toolbar.js.map +1 -1
  221. package/build-module/components/block-mover/button.js +1 -1
  222. package/build-module/components/block-mover/button.js.map +1 -1
  223. package/build-module/components/block-mover/index.js +1 -1
  224. package/build-module/components/block-mover/index.js.map +1 -1
  225. package/build-module/components/block-pattern-setup/setup-toolbar.js +2 -2
  226. package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  227. package/build-module/components/block-patterns-paging/index.js +5 -7
  228. package/build-module/components/block-patterns-paging/index.js.map +1 -1
  229. package/build-module/components/block-quick-navigation/index.js +20 -17
  230. package/build-module/components/block-quick-navigation/index.js.map +1 -1
  231. package/build-module/components/block-removal-warning-modal/index.js +2 -0
  232. package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
  233. package/build-module/components/block-rename/modal.js +5 -13
  234. package/build-module/components/block-rename/modal.js.map +1 -1
  235. package/build-module/components/block-switcher/index.js +1 -1
  236. package/build-module/components/block-switcher/index.js.map +1 -1
  237. package/build-module/components/block-switcher/pattern-transformations-menu.js +12 -13
  238. package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  239. package/build-module/components/block-switcher/preview-block-popover.js +20 -17
  240. package/build-module/components/block-switcher/preview-block-popover.js.map +1 -1
  241. package/build-module/components/block-toolbar/shuffle.js +6 -2
  242. package/build-module/components/block-toolbar/shuffle.js.map +1 -1
  243. package/build-module/components/block-tools/block-selection-button.js +10 -61
  244. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  245. package/build-module/components/block-tools/block-toolbar-breadcrumb.js +9 -2
  246. package/build-module/components/block-tools/block-toolbar-breadcrumb.js.map +1 -1
  247. package/build-module/components/block-tools/index.js +14 -1
  248. package/build-module/components/block-tools/index.js.map +1 -1
  249. package/build-module/components/block-tools/use-show-block-tools.js +9 -8
  250. package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
  251. package/build-module/components/block-tools/zoom-out-mode-inserter-button.js +37 -0
  252. package/build-module/components/block-tools/zoom-out-mode-inserter-button.js.map +1 -0
  253. package/build-module/components/block-tools/zoom-out-mode-inserters.js +30 -29
  254. package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  255. package/build-module/components/block-tools/zoom-out-popover.js +49 -0
  256. package/build-module/components/block-tools/zoom-out-popover.js.map +1 -0
  257. package/build-module/components/block-tools/zoom-out-toolbar.js +131 -0
  258. package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -0
  259. package/build-module/components/button-block-appender/index.js +3 -1
  260. package/build-module/components/button-block-appender/index.js.map +1 -1
  261. package/build-module/components/child-layout-control/index.js +27 -19
  262. package/build-module/components/child-layout-control/index.js.map +1 -1
  263. package/build-module/components/date-format-picker/index.js +2 -2
  264. package/build-module/components/date-format-picker/index.js.map +1 -1
  265. package/build-module/components/default-block-appender/index.js +7 -4
  266. package/build-module/components/default-block-appender/index.js.map +1 -1
  267. package/build-module/components/dimensions-tool/index.js +6 -4
  268. package/build-module/components/dimensions-tool/index.js.map +1 -1
  269. package/build-module/components/font-appearance-control/index.js +24 -62
  270. package/build-module/components/font-appearance-control/index.js.map +1 -1
  271. package/build-module/components/global-styles/background-panel.js +188 -119
  272. package/build-module/components/global-styles/background-panel.js.map +1 -1
  273. package/build-module/components/global-styles/border-panel.js +3 -2
  274. package/build-module/components/global-styles/border-panel.js.map +1 -1
  275. package/build-module/components/global-styles/color-panel.js +3 -2
  276. package/build-module/components/global-styles/color-panel.js.map +1 -1
  277. package/build-module/components/global-styles/dimensions-panel.js +3 -2
  278. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  279. package/build-module/components/global-styles/filters-panel.js +3 -2
  280. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  281. package/build-module/components/global-styles/hooks.js +13 -1
  282. package/build-module/components/global-styles/hooks.js.map +1 -1
  283. package/build-module/components/global-styles/image-settings-panel.js +3 -2
  284. package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
  285. package/build-module/components/global-styles/typography-panel.js +47 -26
  286. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  287. package/build-module/components/global-styles/typography-utils.js +117 -0
  288. package/build-module/components/global-styles/typography-utils.js.map +1 -1
  289. package/build-module/components/global-styles/use-global-styles-output.js +47 -13
  290. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  291. package/build-module/components/global-styles/utils.js +15 -6
  292. package/build-module/components/global-styles/utils.js.map +1 -1
  293. package/build-module/components/grid/grid-item-movers.js +93 -50
  294. package/build-module/components/grid/grid-item-movers.js.map +1 -1
  295. package/build-module/components/grid/grid-item-resizer.js +2 -2
  296. package/build-module/components/grid/grid-item-resizer.js.map +1 -1
  297. package/build-module/components/grid/grid-visualizer.js +118 -38
  298. package/build-module/components/grid/grid-visualizer.js.map +1 -1
  299. package/build-module/components/grid/use-grid-layout-sync.js +61 -42
  300. package/build-module/components/grid/use-grid-layout-sync.js.map +1 -1
  301. package/build-module/components/index.js +0 -5
  302. package/build-module/components/index.js.map +1 -1
  303. package/build-module/components/inner-blocks/index.js +2 -2
  304. package/build-module/components/inner-blocks/index.js.map +1 -1
  305. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -19
  306. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
  307. package/build-module/components/inserter/block-patterns-tab/patterns-filter.js +20 -23
  308. package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
  309. package/build-module/components/inserter/media-tab/media-panel.js +1 -0
  310. package/build-module/components/inserter/media-tab/media-panel.js.map +1 -1
  311. package/build-module/components/inserter/menu.js +26 -4
  312. package/build-module/components/inserter/menu.js.map +1 -1
  313. package/build-module/components/inserter/preview-panel.js +20 -3
  314. package/build-module/components/inserter/preview-panel.js.map +1 -1
  315. package/build-module/components/inserter/quick-inserter.js +2 -1
  316. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  317. package/build-module/components/inserter-draggable-blocks/index.js +10 -3
  318. package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
  319. package/build-module/components/inspector-controls/block-support-tools-panel.js +3 -2
  320. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  321. package/build-module/components/inspector-controls-tabs/settings-tab.js +1 -2
  322. package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -1
  323. package/build-module/components/link-control/link-preview.js +1 -1
  324. package/build-module/components/link-control/link-preview.js.map +1 -1
  325. package/build-module/components/list-view/block-select-button.js +3 -7
  326. package/build-module/components/list-view/block-select-button.js.map +1 -1
  327. package/build-module/components/list-view/block.js +2 -2
  328. package/build-module/components/list-view/block.js.map +1 -1
  329. package/build-module/components/list-view/utils.js +3 -1
  330. package/build-module/components/list-view/utils.js.map +1 -1
  331. package/build-module/components/media-placeholder/index.js +19 -23
  332. package/build-module/components/media-placeholder/index.js.map +1 -1
  333. package/build-module/components/navigable-toolbar/index.js +3 -1
  334. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  335. package/build-module/components/rich-text/format-toolbar/index.js +1 -1
  336. package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
  337. package/build-module/components/rich-text/index.js +1 -1
  338. package/build-module/components/rich-text/index.js.map +1 -1
  339. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +9 -3
  340. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  341. package/build-module/components/tabbed-sidebar/index.js +60 -0
  342. package/build-module/components/tabbed-sidebar/index.js.map +1 -0
  343. package/build-module/components/url-popover/image-url-input-ui.js +3 -3
  344. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  345. package/build-module/components/url-popover/index.js +3 -0
  346. package/build-module/components/url-popover/index.js.map +1 -1
  347. package/build-module/hooks/background.js +26 -4
  348. package/build-module/hooks/background.js.map +1 -1
  349. package/build-module/hooks/block-hooks.js +11 -17
  350. package/build-module/hooks/block-hooks.js.map +1 -1
  351. package/build-module/hooks/block-style-variation.js +168 -4
  352. package/build-module/hooks/block-style-variation.js.map +1 -1
  353. package/build-module/hooks/duotone.js +16 -11
  354. package/build-module/hooks/duotone.js.map +1 -1
  355. package/build-module/hooks/grid-visualizer.js +61 -0
  356. package/build-module/hooks/grid-visualizer.js.map +1 -0
  357. package/build-module/hooks/index.js +3 -0
  358. package/build-module/hooks/index.js.map +1 -1
  359. package/build-module/hooks/layout-child.js +47 -23
  360. package/build-module/hooks/layout-child.js.map +1 -1
  361. package/build-module/hooks/position.js +4 -15
  362. package/build-module/hooks/position.js.map +1 -1
  363. package/build-module/hooks/use-bindings-attributes.js +96 -56
  364. package/build-module/hooks/use-bindings-attributes.js.map +1 -1
  365. package/build-module/hooks/utils.js +2 -0
  366. package/build-module/hooks/utils.js.map +1 -1
  367. package/build-module/layouts/constrained.js +50 -4
  368. package/build-module/layouts/constrained.js.map +1 -1
  369. package/build-module/layouts/grid.js +92 -51
  370. package/build-module/layouts/grid.js.map +1 -1
  371. package/build-module/private-apis.js +8 -6
  372. package/build-module/private-apis.js.map +1 -1
  373. package/build-module/store/actions.js +15 -0
  374. package/build-module/store/actions.js.map +1 -1
  375. package/build-module/store/defaults.js +0 -2
  376. package/build-module/store/defaults.js.map +1 -1
  377. package/build-module/store/defaults.native.js +0 -3
  378. package/build-module/store/defaults.native.js.map +1 -1
  379. package/build-module/store/private-keys.js +1 -0
  380. package/build-module/store/private-keys.js.map +1 -1
  381. package/build-module/store/reducer.js +18 -1
  382. package/build-module/store/reducer.js.map +1 -1
  383. package/build-module/store/selectors.js +10 -0
  384. package/build-module/store/selectors.js.map +1 -1
  385. package/build-module/utils/format-font-style.js +39 -0
  386. package/build-module/utils/format-font-style.js.map +1 -0
  387. package/build-module/utils/format-font-weight.js +62 -0
  388. package/build-module/utils/format-font-weight.js.map +1 -0
  389. package/build-module/utils/get-editor-region.js +28 -0
  390. package/build-module/utils/get-editor-region.js.map +1 -0
  391. package/build-module/utils/get-font-styles-and-weights.js +160 -0
  392. package/build-module/utils/get-font-styles-and-weights.js.map +1 -0
  393. package/build-module/utils/pasting.js +5 -13
  394. package/build-module/utils/pasting.js.map +1 -1
  395. package/build-style/content-rtl.css +7 -6
  396. package/build-style/content.css +7 -6
  397. package/build-style/style-rtl.css +356 -181
  398. package/build-style/style.css +356 -181
  399. package/build-types/components/block-context/index.d.ts +2 -2
  400. package/build-types/components/block-context/index.d.ts.map +1 -1
  401. package/build-types/utils/dom.d.ts.map +1 -1
  402. package/package.json +32 -32
  403. package/src/components/alignment-control/ui.js +2 -2
  404. package/src/components/block-alignment-control/ui.js +1 -1
  405. package/src/components/block-alignment-control/ui.native.js +1 -1
  406. package/src/components/block-breadcrumb/index.js +16 -1
  407. package/src/components/block-context/README.md +4 -4
  408. package/src/components/block-inspector/index.js +8 -4
  409. package/src/components/block-list/content.scss +2 -16
  410. package/src/components/block-list/use-block-props/index.js +1 -1
  411. package/src/components/block-list/use-block-props/use-block-refs.js +19 -3
  412. package/src/components/block-list/use-block-props/use-is-hovered.js +26 -11
  413. package/src/components/block-list/use-in-between-inserter.js +5 -1
  414. package/src/components/block-lock/modal.js +10 -2
  415. package/src/components/block-lock/style.scss +4 -8
  416. package/src/components/block-lock/toolbar.js +0 -1
  417. package/src/components/block-mover/button.js +1 -1
  418. package/src/components/block-mover/index.js +1 -1
  419. package/src/components/block-pattern-setup/setup-toolbar.js +2 -2
  420. package/src/components/block-patterns-paging/index.js +8 -11
  421. package/src/components/block-patterns-paging/style.scss +0 -5
  422. package/src/components/block-quick-navigation/index.js +21 -28
  423. package/src/components/block-removal-warning-modal/index.js +10 -2
  424. package/src/components/block-rename/modal.js +2 -8
  425. package/src/components/block-switcher/index.js +1 -1
  426. package/src/components/block-switcher/pattern-transformations-menu.js +17 -15
  427. package/src/components/block-switcher/preview-block-popover.js +20 -14
  428. package/src/components/block-switcher/style.scss +8 -17
  429. package/src/components/block-switcher/test/index.js +6 -6
  430. package/src/components/block-toolbar/shuffle.js +9 -1
  431. package/src/components/block-toolbar/style.scss +1 -11
  432. package/src/components/block-tools/block-selection-button.js +11 -83
  433. package/src/components/block-tools/block-toolbar-breadcrumb.js +9 -4
  434. package/src/components/block-tools/index.js +21 -1
  435. package/src/components/block-tools/style.scss +23 -0
  436. package/src/components/block-tools/use-show-block-tools.js +21 -10
  437. package/src/components/block-tools/zoom-out-mode-inserter-button.js +47 -0
  438. package/src/components/block-tools/zoom-out-mode-inserters.js +44 -33
  439. package/src/components/block-tools/zoom-out-popover.js +50 -0
  440. package/src/components/block-tools/zoom-out-toolbar.js +140 -0
  441. package/src/components/button-block-appender/index.js +2 -1
  442. package/src/components/child-layout-control/index.js +41 -23
  443. package/src/components/date-format-picker/index.js +2 -2
  444. package/src/components/date-format-picker/style.scss +0 -9
  445. package/src/components/default-block-appender/index.js +11 -4
  446. package/src/components/dimensions-tool/index.js +97 -89
  447. package/src/components/font-appearance-control/index.js +24 -82
  448. package/src/components/font-appearance-control/style.scss +3 -5
  449. package/src/components/global-styles/background-panel.js +266 -167
  450. package/src/components/global-styles/border-panel.js +3 -2
  451. package/src/components/global-styles/color-panel.js +3 -2
  452. package/src/components/global-styles/dimensions-panel.js +3 -2
  453. package/src/components/global-styles/filters-panel.js +3 -2
  454. package/src/components/global-styles/hooks.js +14 -1
  455. package/src/components/global-styles/image-settings-panel.js +3 -2
  456. package/src/components/global-styles/style.scss +116 -19
  457. package/src/components/global-styles/test/typography-utils.js +594 -0
  458. package/src/components/global-styles/test/use-global-styles-output.js +3 -1
  459. package/src/components/global-styles/typography-panel.js +56 -27
  460. package/src/components/global-styles/typography-utils.js +159 -0
  461. package/src/components/global-styles/use-global-styles-output.js +45 -10
  462. package/src/components/global-styles/utils.js +17 -6
  463. package/src/components/grid/grid-item-movers.js +140 -86
  464. package/src/components/grid/grid-item-resizer.js +3 -2
  465. package/src/components/grid/grid-visualizer.js +172 -55
  466. package/src/components/grid/style.scss +157 -8
  467. package/src/components/grid/use-grid-layout-sync.js +88 -46
  468. package/src/components/iframe/content.scss +2 -1
  469. package/src/components/index.js +0 -5
  470. package/src/components/inner-blocks/index.js +6 -2
  471. package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -16
  472. package/src/components/inserter/block-patterns-tab/patterns-filter.js +40 -44
  473. package/src/components/inserter/media-tab/media-panel.js +1 -0
  474. package/src/components/inserter/menu.js +47 -13
  475. package/src/components/inserter/preview-panel.js +27 -4
  476. package/src/components/inserter/quick-inserter.js +6 -1
  477. package/src/components/inserter/style.scss +58 -92
  478. package/src/components/inserter-draggable-blocks/index.js +11 -3
  479. package/src/components/inspector-controls/block-support-tools-panel.js +3 -3
  480. package/src/components/inspector-controls-tabs/settings-tab.js +0 -2
  481. package/src/components/inspector-controls-tabs/style.scss +0 -21
  482. package/src/components/link-control/link-preview.js +1 -1
  483. package/src/components/list-view/block-select-button.js +3 -13
  484. package/src/components/list-view/block.js +10 -3
  485. package/src/components/list-view/style.scss +2 -1
  486. package/src/components/list-view/utils.js +13 -2
  487. package/src/components/media-placeholder/index.js +22 -32
  488. package/src/components/navigable-toolbar/index.js +3 -1
  489. package/src/components/rich-text/format-toolbar/index.js +1 -1
  490. package/src/components/rich-text/index.js +1 -1
  491. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +9 -2
  492. package/src/components/tabbed-sidebar/README.md +76 -0
  493. package/src/components/tabbed-sidebar/index.js +70 -0
  494. package/src/components/tabbed-sidebar/style.scss +53 -0
  495. package/src/components/url-popover/image-url-input-ui.js +3 -3
  496. package/src/components/url-popover/index.js +3 -0
  497. package/src/components/url-popover/style.scss +1 -0
  498. package/src/hooks/background.js +25 -10
  499. package/src/hooks/block-hooks.js +9 -16
  500. package/src/hooks/block-style-variation.js +202 -3
  501. package/src/hooks/duotone.js +16 -12
  502. package/src/hooks/grid-visualizer.js +62 -0
  503. package/src/hooks/index.js +3 -0
  504. package/src/hooks/layout-child.js +64 -39
  505. package/src/hooks/position.js +3 -20
  506. package/src/hooks/test/get-variation-styles-with-ref-values.js +91 -0
  507. package/src/hooks/use-bindings-attributes.js +107 -63
  508. package/src/hooks/utils.js +2 -0
  509. package/src/layouts/constrained.js +53 -4
  510. package/src/layouts/grid.js +148 -51
  511. package/src/private-apis.js +12 -7
  512. package/src/store/actions.js +15 -0
  513. package/src/store/defaults.js +0 -2
  514. package/src/store/defaults.native.js +0 -3
  515. package/src/store/private-keys.js +1 -0
  516. package/src/store/reducer.js +18 -0
  517. package/src/store/selectors.js +10 -0
  518. package/src/style.scss +1 -1
  519. package/src/utils/format-font-style.js +40 -0
  520. package/src/utils/format-font-weight.js +63 -0
  521. package/src/utils/get-editor-region.js +31 -0
  522. package/src/utils/get-font-styles-and-weights.js +191 -0
  523. package/src/utils/pasting.js +5 -12
  524. package/src/utils/test/format-font-style.js +34 -0
  525. package/src/utils/test/format-font-weight.js +66 -0
  526. package/src/utils/test/get-font-styles-and-weights.js +513 -0
  527. package/tsconfig.tsbuildinfo +1 -1
  528. package/build/components/inserter/reusable-block-rename-hint.js +0 -71
  529. package/build/components/inserter/reusable-block-rename-hint.js.map +0 -1
  530. package/build/components/inspector-controls-tabs/settings-tab-hint.js +0 -53
  531. package/build/components/inspector-controls-tabs/settings-tab-hint.js.map +0 -1
  532. package/build-module/components/inserter/reusable-block-rename-hint.js +0 -64
  533. package/build-module/components/inserter/reusable-block-rename-hint.js.map +0 -1
  534. package/build-module/components/inspector-controls-tabs/settings-tab-hint.js +0 -47
  535. package/build-module/components/inspector-controls-tabs/settings-tab-hint.js.map +0 -1
  536. package/src/components/inserter/reusable-block-rename-hint.js +0 -69
  537. package/src/components/inspector-controls-tabs/settings-tab-hint.js +0 -52
  538. package/src/hooks/position.scss +0 -18
@@ -3,9 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.findNearestFontStyle = findNearestFontStyle;
7
+ exports.findNearestFontWeight = findNearestFontWeight;
8
+ exports.findNearestStyleAndWeight = findNearestStyleAndWeight;
6
9
  exports.getFluidTypographyOptionsFromSettings = getFluidTypographyOptionsFromSettings;
10
+ exports.getMergedFontFamiliesAndFontFamilyFaces = getMergedFontFamiliesAndFontFamilyFaces;
7
11
  exports.getTypographyFontSizeValue = getTypographyFontSizeValue;
8
12
  var _fluidUtils = require("../font-sizes/fluid-utils");
13
+ var _getFontStylesAndWeights = require("../../utils/get-font-styles-and-weights");
9
14
  /**
10
15
  * The fluid utilities must match the backend equivalent.
11
16
  * See: gutenberg_get_typography_font_size_value() in lib/block-supports/typography.php
@@ -106,4 +111,120 @@ function getFluidTypographyOptionsFromSettings(settings) {
106
111
  fluid: typographySettings?.fluid
107
112
  };
108
113
  }
114
+
115
+ /**
116
+ * Returns an object of merged font families and the font faces from the selected font family
117
+ * based on the theme.json settings object and the currently selected font family.
118
+ *
119
+ * @param {Object} settings Theme.json settings.
120
+ * @param {string} selectedFontFamily Decoded font family string.
121
+ * @return {Object} Merged font families and font faces from the selected font family.
122
+ */
123
+ function getMergedFontFamiliesAndFontFamilyFaces(settings, selectedFontFamily) {
124
+ var _fontFamilies$find$fo;
125
+ const fontFamiliesFromSettings = settings?.typography?.fontFamilies;
126
+ const fontFamilies = ['default', 'theme', 'custom'].flatMap(key => {
127
+ var _fontFamiliesFromSett;
128
+ return (_fontFamiliesFromSett = fontFamiliesFromSettings?.[key]) !== null && _fontFamiliesFromSett !== void 0 ? _fontFamiliesFromSett : [];
129
+ });
130
+ const fontFamilyFaces = (_fontFamilies$find$fo = fontFamilies.find(family => family.fontFamily === selectedFontFamily)?.fontFace) !== null && _fontFamilies$find$fo !== void 0 ? _fontFamilies$find$fo : [];
131
+ return {
132
+ fontFamilies,
133
+ fontFamilyFaces
134
+ };
135
+ }
136
+
137
+ /**
138
+ * Returns the nearest font weight value from the available font weight list based on the new font weight.
139
+ * The nearest font weight is the one with the smallest difference from the new font weight.
140
+ *
141
+ * @param {Array} availableFontWeights Array of available font weights.
142
+ * @param {string} newFontWeightValue New font weight value.
143
+ * @return {string} Nearest font weight.
144
+ */
145
+ function findNearestFontWeight(availableFontWeights, newFontWeightValue) {
146
+ if (!newFontWeightValue || typeof newFontWeightValue !== 'string') {
147
+ return '';
148
+ }
149
+ if (!availableFontWeights || availableFontWeights.length === 0) {
150
+ return newFontWeightValue;
151
+ }
152
+ const nearestFontWeight = availableFontWeights?.reduce((nearest, {
153
+ value: fw
154
+ }) => {
155
+ const currentDiff = Math.abs(parseInt(fw) - parseInt(newFontWeightValue));
156
+ const nearestDiff = Math.abs(parseInt(nearest) - parseInt(newFontWeightValue));
157
+ return currentDiff < nearestDiff ? fw : nearest;
158
+ }, availableFontWeights[0]?.value);
159
+ return nearestFontWeight;
160
+ }
161
+
162
+ /**
163
+ * Returns the nearest font style based on the new font style.
164
+ * Defaults to an empty string if the new font style is not valid or available.
165
+ *
166
+ * @param {Array} availableFontStyles Array of available font weights.
167
+ * @param {string} newFontStyleValue New font style value.
168
+ * @return {string} Nearest font style or an empty string.
169
+ */
170
+ function findNearestFontStyle(availableFontStyles, newFontStyleValue) {
171
+ if (typeof newFontStyleValue !== 'string' || !newFontStyleValue) {
172
+ return '';
173
+ }
174
+ const validStyles = ['normal', 'italic', 'oblique'];
175
+ if (!validStyles.includes(newFontStyleValue)) {
176
+ return '';
177
+ }
178
+ if (!availableFontStyles || availableFontStyles.length === 0 || availableFontStyles.find(style => style.value === newFontStyleValue)) {
179
+ return newFontStyleValue;
180
+ }
181
+ if (newFontStyleValue === 'oblique' && !availableFontStyles.find(style => style.value === 'oblique')) {
182
+ return 'italic';
183
+ }
184
+ return '';
185
+ }
186
+
187
+ /**
188
+ * Returns the nearest font style and weight based on the available font family faces and the new font style and weight.
189
+ *
190
+ * @param {Array} fontFamilyFaces Array of available font family faces.
191
+ * @param {string} fontStyle New font style. Defaults to previous value.
192
+ * @param {string} fontWeight New font weight. Defaults to previous value.
193
+ * @return {Object} Nearest font style and font weight.
194
+ */
195
+ function findNearestStyleAndWeight(fontFamilyFaces, fontStyle, fontWeight) {
196
+ let nearestFontStyle = fontStyle;
197
+ let nearestFontWeight = fontWeight;
198
+ const {
199
+ fontStyles,
200
+ fontWeights,
201
+ combinedStyleAndWeightOptions
202
+ } = (0, _getFontStylesAndWeights.getFontStylesAndWeights)(fontFamilyFaces);
203
+
204
+ // Check if the new font style and weight are available in the font family faces.
205
+ const hasFontStyle = fontStyles?.some(({
206
+ value: fs
207
+ }) => fs === fontStyle);
208
+ const hasFontWeight = fontWeights?.some(({
209
+ value: fw
210
+ }) => fw === fontWeight);
211
+ if (!hasFontStyle) {
212
+ /*
213
+ * Default to italic if oblique is not available.
214
+ * Or find the nearest font style based on the nearest font weight.
215
+ */
216
+ nearestFontStyle = fontStyle ? findNearestFontStyle(fontStyles, fontStyle) : combinedStyleAndWeightOptions?.find(option => option.style.fontWeight === findNearestFontWeight(fontWeights, fontWeight))?.style?.fontStyle;
217
+ }
218
+ if (!hasFontWeight) {
219
+ /*
220
+ * Find the nearest font weight based on available weights.
221
+ * Or find the nearest font weight based on the nearest font style.
222
+ */
223
+ nearestFontWeight = fontWeight ? findNearestFontWeight(fontWeights, fontWeight) : combinedStyleAndWeightOptions?.find(option => option.style.fontStyle === (nearestFontStyle || fontStyle))?.style?.fontWeight;
224
+ }
225
+ return {
226
+ nearestFontStyle,
227
+ nearestFontWeight
228
+ };
229
+ }
109
230
  //# sourceMappingURL=typography-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_fluidUtils","require","getTypographyFontSizeValue","preset","settings","size","defaultSize","isFluidTypographyEnabled","typography","fluid","fluidTypographySettings","getFluidTypographyOptionsFromSettings","fluidFontSizeValue","getComputedFluidTypographyValue","minimumFontSize","min","maximumFontSize","max","fontSize","minimumFontSizeLimit","minFontSize","maximumViewportWidth","maxViewportWidth","minimumViewportWidth","minViewportWidth","typographySettings","fluidSettings","Object","keys","length","layoutSettings","layout","defaultMaxViewportWidth","getTypographyValueAndUnit","wideSize"],"sources":["@wordpress/block-editor/src/components/global-styles/typography-utils.js"],"sourcesContent":["/**\n * The fluid utilities must match the backend equivalent.\n * See: gutenberg_get_typography_font_size_value() in lib/block-supports/typography.php\n * ---------------------------------------------------------------\n */\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetComputedFluidTypographyValue,\n\tgetTypographyValueAndUnit,\n} from '../font-sizes/fluid-utils';\n\n/**\n * @typedef {Object} FluidPreset\n * @property {string|undefined} max A maximum font size value.\n * @property {?string|undefined} min A minimum font size value.\n */\n\n/**\n * @typedef {Object} Preset\n * @property {?string|?number} size A default font size.\n * @property {string} name A font size name, displayed in the UI.\n * @property {string} slug A font size slug\n * @property {boolean|FluidPreset|undefined} fluid Specifies the minimum and maximum font size value of a fluid font size.\n */\n\n/**\n * @typedef {Object} TypographySettings\n * @property {?string} minViewportWidth Minimum viewport size from which type will have fluidity. Optional if size is specified.\n * @property {?string} maxViewportWidth Maximum size up to which type will have fluidity. Optional if size is specified.\n * @property {?number} scaleFactor A scale factor to determine how fast a font scales within boundaries. Optional.\n * @property {?number} minFontSizeFactor How much to scale defaultFontSize by to derive minimumFontSize. Optional.\n * @property {?string} minFontSize The smallest a calculated font size may be. Optional.\n */\n\n/**\n * Returns a font-size value based on a given font-size preset.\n * Takes into account fluid typography parameters and attempts to return a css formula depending on available, valid values.\n *\n * @param {Preset} preset\n * @param {Object} settings\n * @param {boolean|TypographySettings} settings.typography.fluid Whether fluid typography is enabled, and, optionally, fluid font size options.\n * @param {Object?} settings.typography.layout Layout options.\n *\n * @return {string|*} A font-size value or the value of preset.size.\n */\nexport function getTypographyFontSizeValue( preset, settings ) {\n\tconst { size: defaultSize } = preset;\n\n\tif ( ! isFluidTypographyEnabled( settings?.typography ) ) {\n\t\treturn defaultSize;\n\t}\n\t/*\n\t * Checks whether a font size has explicitly bypassed fluid calculations.\n\t * Also catches falsy values and 0/'0'.\n\t * Fluid calculations cannot be performed on `0`.\n\t */\n\tif ( ! defaultSize || '0' === defaultSize || false === preset?.fluid ) {\n\t\treturn defaultSize;\n\t}\n\n\tlet fluidTypographySettings =\n\t\tgetFluidTypographyOptionsFromSettings( settings );\n\tfluidTypographySettings =\n\t\ttypeof fluidTypographySettings?.fluid === 'object'\n\t\t\t? fluidTypographySettings?.fluid\n\t\t\t: {};\n\n\tconst fluidFontSizeValue = getComputedFluidTypographyValue( {\n\t\tminimumFontSize: preset?.fluid?.min,\n\t\tmaximumFontSize: preset?.fluid?.max,\n\t\tfontSize: defaultSize,\n\t\tminimumFontSizeLimit: fluidTypographySettings?.minFontSize,\n\t\tmaximumViewportWidth: fluidTypographySettings?.maxViewportWidth,\n\t\tminimumViewportWidth: fluidTypographySettings?.minViewportWidth,\n\t} );\n\n\tif ( !! fluidFontSizeValue ) {\n\t\treturn fluidFontSizeValue;\n\t}\n\n\treturn defaultSize;\n}\n\nfunction isFluidTypographyEnabled( typographySettings ) {\n\tconst fluidSettings = typographySettings?.fluid;\n\treturn (\n\t\ttrue === fluidSettings ||\n\t\t( fluidSettings &&\n\t\t\ttypeof fluidSettings === 'object' &&\n\t\t\tObject.keys( fluidSettings ).length > 0 )\n\t);\n}\n\n/**\n * Returns fluid typography settings from theme.json setting object.\n *\n * @param {Object} settings Theme.json settings\n * @param {Object} settings.typography Theme.json typography settings\n * @param {Object} settings.layout Theme.json layout settings\n * @return {TypographySettings} Fluid typography settings\n */\nexport function getFluidTypographyOptionsFromSettings( settings ) {\n\tconst typographySettings = settings?.typography;\n\tconst layoutSettings = settings?.layout;\n\tconst defaultMaxViewportWidth = getTypographyValueAndUnit(\n\t\tlayoutSettings?.wideSize\n\t)\n\t\t? layoutSettings?.wideSize\n\t\t: null;\n\treturn isFluidTypographyEnabled( typographySettings ) &&\n\t\tdefaultMaxViewportWidth\n\t\t? {\n\t\t\t\tfluid: {\n\t\t\t\t\tmaxViewportWidth: defaultMaxViewportWidth,\n\t\t\t\t\t...typographySettings.fluid,\n\t\t\t\t},\n\t\t }\n\t\t: {\n\t\t\t\tfluid: typographySettings?.fluid,\n\t\t };\n}\n"],"mappings":";;;;;;;AASA,IAAAA,WAAA,GAAAC,OAAA;AATA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;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aAAa,KAAK,QAAQ,IACjCC,MAAM,CAACC,IAAI,CAAEF,aAAc,CAAC,CAACG,MAAM,GAAG,CAAG;AAE5C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASlB,qCAAqCA,CAAEP,QAAQ,EAAG;EACjE,MAAMqB,kBAAkB,GAAGrB,QAAQ,EAAEI,UAAU;EAC/C,MAAMsB,cAAc,GAAG1B,QAAQ,EAAE2B,MAAM;EACvC,MAAMC,uBAAuB,GAAG,IAAAC,qCAAyB,EACxDH,cAAc,EAAEI,QACjB,CAAC,GACEJ,cAAc,EAAEI,QAAQ,GACxB,IAAI;EACP,OAAO3B,wBAAwB,CAAEkB,kBAAmB,CAAC,IACpDO,uBAAuB,GACrB;IACAvB,KAAK,EAAE;MACNa,gBAAgB,EAAEU,uBAAuB;MACzC,GAAGP,kBAAkB,CAAChB;IACvB;EACA,CAAC,GACD;IACAA,KAAK,EAAEgB,kBAAkB,EAAEhB;EAC3B,CAAC;AACL","ignoreList":[]}
1
+ {"version":3,"names":["_fluidUtils","require","_getFontStylesAndWeights","getTypographyFontSizeValue","preset","settings","size","defaultSize","isFluidTypographyEnabled","typography","fluid","fluidTypographySettings","getFluidTypographyOptionsFromSettings","fluidFontSizeValue","getComputedFluidTypographyValue","minimumFontSize","min","maximumFontSize","max","fontSize","minimumFontSizeLimit","minFontSize","maximumViewportWidth","maxViewportWidth","minimumViewportWidth","minViewportWidth","typographySettings","fluidSettings","Object","keys","length","layoutSettings","layout","defaultMaxViewportWidth","getTypographyValueAndUnit","wideSize","getMergedFontFamiliesAndFontFamilyFaces","selectedFontFamily","_fontFamilies$find$fo","fontFamiliesFromSettings","fontFamilies","flatMap","key","_fontFamiliesFromSett","fontFamilyFaces","find","family","fontFamily","fontFace","findNearestFontWeight","availableFontWeights","newFontWeightValue","nearestFontWeight","reduce","nearest","value","fw","currentDiff","Math","abs","parseInt","nearestDiff","findNearestFontStyle","availableFontStyles","newFontStyleValue","validStyles","includes","style","findNearestStyleAndWeight","fontStyle","fontWeight","nearestFontStyle","fontStyles","fontWeights","combinedStyleAndWeightOptions","getFontStylesAndWeights","hasFontStyle","some","fs","hasFontWeight","option"],"sources":["@wordpress/block-editor/src/components/global-styles/typography-utils.js"],"sourcesContent":["/**\n * The fluid utilities must match the backend equivalent.\n * See: gutenberg_get_typography_font_size_value() in lib/block-supports/typography.php\n * ---------------------------------------------------------------\n */\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetComputedFluidTypographyValue,\n\tgetTypographyValueAndUnit,\n} from '../font-sizes/fluid-utils';\nimport { getFontStylesAndWeights } from '../../utils/get-font-styles-and-weights';\n\n/**\n * @typedef {Object} FluidPreset\n * @property {string|undefined} max A maximum font size value.\n * @property {?string|undefined} min A minimum font size value.\n */\n\n/**\n * @typedef {Object} Preset\n * @property {?string|?number} size A default font size.\n * @property {string} name A font size name, displayed in the UI.\n * @property {string} slug A font size slug\n * @property {boolean|FluidPreset|undefined} fluid Specifies the minimum and maximum font size value of a fluid font size.\n */\n\n/**\n * @typedef {Object} TypographySettings\n * @property {?string} minViewportWidth Minimum viewport size from which type will have fluidity. Optional if size is specified.\n * @property {?string} maxViewportWidth Maximum size up to which type will have fluidity. Optional if size is specified.\n * @property {?number} scaleFactor A scale factor to determine how fast a font scales within boundaries. Optional.\n * @property {?number} minFontSizeFactor How much to scale defaultFontSize by to derive minimumFontSize. Optional.\n * @property {?string} minFontSize The smallest a calculated font size may be. Optional.\n */\n\n/**\n * Returns a font-size value based on a given font-size preset.\n * Takes into account fluid typography parameters and attempts to return a css formula depending on available, valid values.\n *\n * @param {Preset} preset\n * @param {Object} settings\n * @param {boolean|TypographySettings} settings.typography.fluid Whether fluid typography is enabled, and, optionally, fluid font size options.\n * @param {Object?} settings.typography.layout Layout options.\n *\n * @return {string|*} A font-size value or the value of preset.size.\n */\nexport function getTypographyFontSizeValue( preset, settings ) {\n\tconst { size: defaultSize } = preset;\n\n\tif ( ! isFluidTypographyEnabled( settings?.typography ) ) {\n\t\treturn defaultSize;\n\t}\n\t/*\n\t * Checks whether a font size has explicitly bypassed fluid calculations.\n\t * Also catches falsy values and 0/'0'.\n\t * Fluid calculations cannot be performed on `0`.\n\t */\n\tif ( ! defaultSize || '0' === defaultSize || false === preset?.fluid ) {\n\t\treturn defaultSize;\n\t}\n\n\tlet fluidTypographySettings =\n\t\tgetFluidTypographyOptionsFromSettings( settings );\n\tfluidTypographySettings =\n\t\ttypeof fluidTypographySettings?.fluid === 'object'\n\t\t\t? fluidTypographySettings?.fluid\n\t\t\t: {};\n\n\tconst fluidFontSizeValue = getComputedFluidTypographyValue( {\n\t\tminimumFontSize: preset?.fluid?.min,\n\t\tmaximumFontSize: preset?.fluid?.max,\n\t\tfontSize: defaultSize,\n\t\tminimumFontSizeLimit: fluidTypographySettings?.minFontSize,\n\t\tmaximumViewportWidth: fluidTypographySettings?.maxViewportWidth,\n\t\tminimumViewportWidth: fluidTypographySettings?.minViewportWidth,\n\t} );\n\n\tif ( !! fluidFontSizeValue ) {\n\t\treturn fluidFontSizeValue;\n\t}\n\n\treturn defaultSize;\n}\n\nfunction isFluidTypographyEnabled( typographySettings ) {\n\tconst fluidSettings = typographySettings?.fluid;\n\treturn (\n\t\ttrue === fluidSettings ||\n\t\t( fluidSettings &&\n\t\t\ttypeof fluidSettings === 'object' &&\n\t\t\tObject.keys( fluidSettings ).length > 0 )\n\t);\n}\n\n/**\n * Returns fluid typography settings from theme.json setting object.\n *\n * @param {Object} settings Theme.json settings\n * @param {Object} settings.typography Theme.json typography settings\n * @param {Object} settings.layout Theme.json layout settings\n * @return {TypographySettings} Fluid typography settings\n */\nexport function getFluidTypographyOptionsFromSettings( settings ) {\n\tconst typographySettings = settings?.typography;\n\tconst layoutSettings = settings?.layout;\n\tconst defaultMaxViewportWidth = getTypographyValueAndUnit(\n\t\tlayoutSettings?.wideSize\n\t)\n\t\t? layoutSettings?.wideSize\n\t\t: null;\n\treturn isFluidTypographyEnabled( typographySettings ) &&\n\t\tdefaultMaxViewportWidth\n\t\t? {\n\t\t\t\tfluid: {\n\t\t\t\t\tmaxViewportWidth: defaultMaxViewportWidth,\n\t\t\t\t\t...typographySettings.fluid,\n\t\t\t\t},\n\t\t }\n\t\t: {\n\t\t\t\tfluid: typographySettings?.fluid,\n\t\t };\n}\n\n/**\n * Returns an object of merged font families and the font faces from the selected font family\n * based on the theme.json settings object and the currently selected font family.\n *\n * @param {Object} settings Theme.json settings.\n * @param {string} selectedFontFamily Decoded font family string.\n * @return {Object} Merged font families and font faces from the selected font family.\n */\nexport function getMergedFontFamiliesAndFontFamilyFaces(\n\tsettings,\n\tselectedFontFamily\n) {\n\tconst fontFamiliesFromSettings = settings?.typography?.fontFamilies;\n\n\tconst fontFamilies = [ 'default', 'theme', 'custom' ].flatMap(\n\t\t( key ) => fontFamiliesFromSettings?.[ key ] ?? []\n\t);\n\n\tconst fontFamilyFaces =\n\t\tfontFamilies.find(\n\t\t\t( family ) => family.fontFamily === selectedFontFamily\n\t\t)?.fontFace ?? [];\n\n\treturn { fontFamilies, fontFamilyFaces };\n}\n\n/**\n * Returns the nearest font weight value from the available font weight list based on the new font weight.\n * The nearest font weight is the one with the smallest difference from the new font weight.\n *\n * @param {Array} availableFontWeights Array of available font weights.\n * @param {string} newFontWeightValue New font weight value.\n * @return {string} Nearest font weight.\n */\nexport function findNearestFontWeight(\n\tavailableFontWeights,\n\tnewFontWeightValue\n) {\n\tif ( ! newFontWeightValue || typeof newFontWeightValue !== 'string' ) {\n\t\treturn '';\n\t}\n\n\tif ( ! availableFontWeights || availableFontWeights.length === 0 ) {\n\t\treturn newFontWeightValue;\n\t}\n\n\tconst nearestFontWeight = availableFontWeights?.reduce(\n\t\t( nearest, { value: fw } ) => {\n\t\t\tconst currentDiff = Math.abs(\n\t\t\t\tparseInt( fw ) - parseInt( newFontWeightValue )\n\t\t\t);\n\t\t\tconst nearestDiff = Math.abs(\n\t\t\t\tparseInt( nearest ) - parseInt( newFontWeightValue )\n\t\t\t);\n\t\t\treturn currentDiff < nearestDiff ? fw : nearest;\n\t\t},\n\t\tavailableFontWeights[ 0 ]?.value\n\t);\n\n\treturn nearestFontWeight;\n}\n\n/**\n * Returns the nearest font style based on the new font style.\n * Defaults to an empty string if the new font style is not valid or available.\n *\n * @param {Array} availableFontStyles Array of available font weights.\n * @param {string} newFontStyleValue New font style value.\n * @return {string} Nearest font style or an empty string.\n */\nexport function findNearestFontStyle( availableFontStyles, newFontStyleValue ) {\n\tif ( typeof newFontStyleValue !== 'string' || ! newFontStyleValue ) {\n\t\treturn '';\n\t}\n\n\tconst validStyles = [ 'normal', 'italic', 'oblique' ];\n\tif ( ! validStyles.includes( newFontStyleValue ) ) {\n\t\treturn '';\n\t}\n\n\tif (\n\t\t! availableFontStyles ||\n\t\tavailableFontStyles.length === 0 ||\n\t\tavailableFontStyles.find(\n\t\t\t( style ) => style.value === newFontStyleValue\n\t\t)\n\t) {\n\t\treturn newFontStyleValue;\n\t}\n\n\tif (\n\t\tnewFontStyleValue === 'oblique' &&\n\t\t! availableFontStyles.find( ( style ) => style.value === 'oblique' )\n\t) {\n\t\treturn 'italic';\n\t}\n\n\treturn '';\n}\n\n/**\n * Returns the nearest font style and weight based on the available font family faces and the new font style and weight.\n *\n * @param {Array} fontFamilyFaces Array of available font family faces.\n * @param {string} fontStyle New font style. Defaults to previous value.\n * @param {string} fontWeight New font weight. Defaults to previous value.\n * @return {Object} Nearest font style and font weight.\n */\nexport function findNearestStyleAndWeight(\n\tfontFamilyFaces,\n\tfontStyle,\n\tfontWeight\n) {\n\tlet nearestFontStyle = fontStyle;\n\tlet nearestFontWeight = fontWeight;\n\n\tconst { fontStyles, fontWeights, combinedStyleAndWeightOptions } =\n\t\tgetFontStylesAndWeights( fontFamilyFaces );\n\n\t// Check if the new font style and weight are available in the font family faces.\n\tconst hasFontStyle = fontStyles?.some(\n\t\t( { value: fs } ) => fs === fontStyle\n\t);\n\tconst hasFontWeight = fontWeights?.some(\n\t\t( { value: fw } ) => fw === fontWeight\n\t);\n\n\tif ( ! hasFontStyle ) {\n\t\t/*\n\t\t * Default to italic if oblique is not available.\n\t\t * Or find the nearest font style based on the nearest font weight.\n\t\t */\n\t\tnearestFontStyle = fontStyle\n\t\t\t? findNearestFontStyle( fontStyles, fontStyle )\n\t\t\t: combinedStyleAndWeightOptions?.find(\n\t\t\t\t\t( option ) =>\n\t\t\t\t\t\toption.style.fontWeight ===\n\t\t\t\t\t\tfindNearestFontWeight( fontWeights, fontWeight )\n\t\t\t )?.style?.fontStyle;\n\t}\n\n\tif ( ! hasFontWeight ) {\n\t\t/*\n\t\t * Find the nearest font weight based on available weights.\n\t\t * Or find the nearest font weight based on the nearest font style.\n\t\t */\n\t\tnearestFontWeight = fontWeight\n\t\t\t? findNearestFontWeight( fontWeights, fontWeight )\n\t\t\t: combinedStyleAndWeightOptions?.find(\n\t\t\t\t\t( option ) =>\n\t\t\t\t\t\toption.style.fontStyle ===\n\t\t\t\t\t\t( nearestFontStyle || fontStyle )\n\t\t\t )?.style?.fontWeight;\n\t}\n\n\treturn { nearestFontStyle, nearestFontWeight };\n}\n"],"mappings":";;;;;;;;;;;AASA,IAAAA,WAAA,GAAAC,OAAA;AAIA,IAAAC,wBAAA,GAAAD,OAAA;AAbA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,0BAA0BA,CAAEC,MAAM,EAAEC,QAAQ,EAAG;EAC9D,MAAM;IAAEC,IAAI,EAAEC;EAAY,CAAC,GAAGH,MAAM;EAEpC,IAAK,CAAEI,wBAAwB,CAAEH,QAAQ,EAAEI,UAAW,CAAC,EAAG;IACzD,OAAOF,WAAW;EACnB;EACA;AACD;AACA;AACA;AACA;EACC,IAAK,CAAEA,WAAW,IAAI,GAAG,KA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S,EACTC,UAAU,EACT;EACD,IAAIC,gBAAgB,GAAGF,SAAS;EAChC,IAAIjB,iBAAiB,GAAGkB,UAAU;EAElC,MAAM;IAAEE,UAAU;IAAEC,WAAW;IAAEC;EAA8B,CAAC,GAC/D,IAAAC,gDAAuB,EAAE/B,eAAgB,CAAC;;EAE3C;EACA,MAAMgC,YAAY,GAAGJ,UAAU,EAAEK,IAAI,CACpC,CAAE;IAAEtB,KAAK,EAAEuB;EAAG,CAAC,KAAMA,EAAE,KAAKT,SAC7B,CAAC;EACD,MAAMU,aAAa,GAAGN,WAAW,EAAEI,IAAI,CACtC,CAAE;IAAEtB,KAAK,EAAEC;EAAG,CAAC,KAAMA,EAAE,KAAKc,UAC7B,CAAC;EAED,IAAK,CAAEM,YAAY,EAAG;IACrB;AACF;AACA;AACA;IACEL,gBAAgB,GAAGF,SAAS,GACzBP,oBAAoB,CAAEU,UAAU,EAAEH,SAAU,CAAC,GAC7CK,6BAA6B,EAAE7B,IAAI,CACjCmC,MAAM,IACPA,MAAM,CAACb,KAAK,CAACG,UAAU,KACvBrB,qBAAqB,CAAEwB,WAAW,EAAEH,UAAW,CAChD,CAAC,EAAEH,KAAK,EAAEE,SAAS;EACvB;EAEA,IAAK,CAAEU,aAAa,EAAG;IACtB;AACF;AACA;AACA;IACE3B,iBAAiB,GAAGkB,UAAU,GAC3BrB,qBAAqB,CAAEwB,WAAW,EAAEH,UAAW,CAAC,GAChDI,6BAA6B,EAAE7B,IAAI,CACjCmC,MAAM,IACPA,MAAM,CAACb,KAAK,CAACE,SAAS,MACpBE,gBAAgB,IAAIF,SAAS,CAChC,CAAC,EAAEF,KAAK,EAAEG,UAAU;EACxB;EAEA,OAAO;IAAEC,gBAAgB;IAAEnB;EAAkB,CAAC;AAC/C","ignoreList":[]}
@@ -24,6 +24,7 @@ var _context = require("./context");
24
24
  var _hooks = require("./hooks");
25
25
  var _utils2 = require("../duotone/utils");
26
26
  var _gap = require("../../hooks/gap");
27
+ var _background = require("../../hooks/background");
27
28
  var _store = require("../../store");
28
29
  var _definitions = require("../../layouts/definitions");
29
30
  var _object = require("../../utils/object");
@@ -37,6 +38,12 @@ var _themeFileUriUtils = require("./theme-file-uri-utils");
37
38
  * Internal dependencies
38
39
  */
39
40
 
41
+ // Elements that rely on class names in their selectors.
42
+ const ELEMENT_CLASS_NAMES = {
43
+ button: 'wp-element-button',
44
+ caption: 'wp-element-caption'
45
+ };
46
+
40
47
  // List of block support features that can have their related styles
41
48
  // generated under their own feature level selector rather than the block's.
42
49
  const BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = {
@@ -292,6 +299,20 @@ function getStylesDeclarations(blockStyles = {}, selector = '', useRootPaddingAl
292
299
  return declarations;
293
300
  }, []);
294
301
 
302
+ /*
303
+ * Set background defaults.
304
+ * Applies to all background styles except the top-level site background.
305
+ */
306
+ if (!isRoot && !!blockStyles.background) {
307
+ blockStyles = {
308
+ ...blockStyles,
309
+ background: {
310
+ ...blockStyles.background,
311
+ ...(0, _background.setBackgroundStyleDefaults)(blockStyles.background)
312
+ }
313
+ };
314
+ }
315
+
295
316
  // The goal is to move everything to server side generated engine styles
296
317
  // This is temporary as we absorb more and more styles into the engine.
297
318
  const extraRules = (0, _styleEngine.getCSSRules)(blockStyles);
@@ -458,14 +479,20 @@ const getNodesWithStyles = (tree, blockSelectors) => {
458
479
  if (styles) {
459
480
  nodes.push({
460
481
  styles,
461
- selector: _utils.ROOT_BLOCK_SELECTOR
482
+ selector: _utils.ROOT_BLOCK_SELECTOR,
483
+ // Root selector (body) styles should not be wrapped in `:root where()` to keep
484
+ // specificity at (0,0,1) and maintain backwards compatibility.
485
+ skipSelectorWrapper: true
462
486
  });
463
487
  }
464
488
  Object.entries(_blocks.__EXPERIMENTAL_ELEMENTS).forEach(([name, selector]) => {
465
489
  if (tree.styles?.elements?.[name]) {
466
490
  nodes.push({
467
491
  styles: tree.styles?.elements?.[name],
468
- selector
492
+ selector,
493
+ // Top level elements that don't use a class name should not receive the
494
+ // `:root :where()` wrapper to maintain backwards compatibility.
495
+ skipSelectorWrapper: !ELEMENT_CLASS_NAMES[name]
469
496
  });
470
497
  }
471
498
  });
@@ -482,7 +509,7 @@ const getNodesWithStyles = (tree, blockSelectors) => {
482
509
  if (variation?.css) {
483
510
  variations[variationName].css = variation.css;
484
511
  }
485
- const variationSelector = blockSelectors[blockName].styleVariationSelectors?.[variationName];
512
+ const variationSelector = blockSelectors[blockName]?.styleVariationSelectors?.[variationName];
486
513
 
487
514
  // Process the variation's inner element styles.
488
515
  // This comes before the inner block styles so the
@@ -500,9 +527,9 @@ const getNodesWithStyles = (tree, blockSelectors) => {
500
527
  // Process the variations inner block type styles.
501
528
  Object.entries((_variation$blocks = variation?.blocks) !== null && _variation$blocks !== void 0 ? _variation$blocks : {}).forEach(([variationBlockName, variationBlockStyles]) => {
502
529
  var _variationBlockStyles;
503
- const variationBlockSelector = (0, _utils.scopeSelector)(variationSelector, blockSelectors[variationBlockName].selector);
504
- const variationDuotoneSelector = (0, _utils.scopeSelector)(variationSelector, blockSelectors[variationBlockName].duotoneSelector);
505
- const variationFeatureSelectors = (0, _utils.scopeFeatureSelectors)(variationSelector, blockSelectors[variationBlockName].featureSelectors);
530
+ const variationBlockSelector = (0, _utils.scopeSelector)(variationSelector, blockSelectors[variationBlockName]?.selector);
531
+ const variationDuotoneSelector = (0, _utils.scopeSelector)(variationSelector, blockSelectors[variationBlockName]?.duotoneSelector);
532
+ const variationFeatureSelectors = (0, _utils.scopeFeatureSelectors)(variationSelector, blockSelectors[variationBlockName]?.featureSelectors);
506
533
  const variationBlockStyleNodes = pickStyleKeys(variationBlockStyles);
507
534
  if (variationBlockStyles?.css) {
508
535
  variationBlockStyleNodes.css = variationBlockStyles.css;
@@ -511,8 +538,8 @@ const getNodesWithStyles = (tree, blockSelectors) => {
511
538
  selector: variationBlockSelector,
512
539
  duotoneSelector: variationDuotoneSelector,
513
540
  featureSelectors: variationFeatureSelectors,
514
- fallbackGapValue: blockSelectors[variationBlockName].fallbackGapValue,
515
- hasLayoutSupport: blockSelectors[variationBlockName].hasLayoutSupport,
541
+ fallbackGapValue: blockSelectors[variationBlockName]?.fallbackGapValue,
542
+ hasLayoutSupport: blockSelectors[variationBlockName]?.hasLayoutSupport,
516
543
  styles: variationBlockStyleNodes
517
544
  });
518
545
 
@@ -668,8 +695,8 @@ const toStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSuppor
668
695
  ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) }
669
696
  .has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
670
697
  .has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }
671
- .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) { padding-right: 0; padding-left: 0; }
672
- .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) > .alignfull { margin-left: 0; margin-right: 0;
698
+ .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) { padding-right: 0; padding-left: 0; }
699
+ .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) > .alignfull { margin-left: 0; margin-right: 0;
673
700
  `;
674
701
  }
675
702
  ruleset += '}';
@@ -682,7 +709,8 @@ const toStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSuppor
682
709
  fallbackGapValue,
683
710
  hasLayoutSupport,
684
711
  featureSelectors,
685
- styleVariationSelectors
712
+ styleVariationSelectors,
713
+ skipSelectorWrapper
686
714
  }) => {
687
715
  // Process styles for block support features with custom feature level
688
716
  // CSS selectors set.
@@ -723,7 +751,8 @@ const toStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSuppor
723
751
  // Process the remaining block styles (they use either normal block class or __experimentalSelector).
724
752
  const styleDeclarations = getStylesDeclarations(styles, selector, useRootPaddingAlign, tree, disableRootPadding);
725
753
  if (styleDeclarations?.length) {
726
- ruleset += `:root :where(${selector}){${styleDeclarations.join(';')};}`;
754
+ const generalSelector = skipSelectorWrapper ? selector : `:root :where(${selector})`;
755
+ ruleset += `${generalSelector}{${styleDeclarations.join(';')};}`;
727
756
  }
728
757
  if (styles?.css) {
729
758
  ruleset += processCSSNesting(styles.css, `:root :where(${selector})`);
@@ -773,7 +802,12 @@ const toStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSuppor
773
802
  // Split and append pseudo selector to create
774
803
  // the proper rules to target the elements.
775
804
  const _selector = selector.split(',').map(sel => sel + pseudoKey).join(',');
776
- const pseudoRule = `${_selector}{${pseudoDeclarations.join(';')};}`;
805
+
806
+ // As pseudo classes such as :hover, :focus etc. have class-level
807
+ // specificity, they must use the `:root :where()` wrapper. This.
808
+ // caps the specificity at `0-1-0` to allow proper nesting of variations
809
+ // and block type element styles.
810
+ const pseudoRule = `:root :where(${_selector}){${pseudoDeclarations.join(';')};}`;
777
811
  ruleset += pseudoRule;
778
812
  });
779
813
  }