@wordpress/block-editor 13.3.0 → 14.0.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 (554) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +11 -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 +3 -1
  10. package/build/components/block-breadcrumb/index.js.map +1 -1
  11. package/build/components/block-draggable/index.js +2 -2
  12. package/build/components/block-draggable/index.js.map +1 -1
  13. package/build/components/block-inspector/index.js +6 -3
  14. package/build/components/block-inspector/index.js.map +1 -1
  15. package/build/components/block-list/use-block-props/index.js +3 -1
  16. package/build/components/block-list/use-block-props/index.js.map +1 -1
  17. package/build/components/block-list/use-block-props/use-block-refs.js +26 -27
  18. package/build/components/block-list/use-block-props/use-block-refs.js.map +1 -1
  19. package/build/components/block-list/use-block-props/use-is-hovered.js +25 -9
  20. package/build/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
  21. package/build/components/block-list/use-in-between-inserter.js +3 -2
  22. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  23. package/build/components/block-lock/modal.js +2 -0
  24. package/build/components/block-lock/modal.js.map +1 -1
  25. package/build/components/block-mover/index.js +1 -2
  26. package/build/components/block-mover/index.js.map +1 -1
  27. package/build/components/block-popover/cover.js +1 -1
  28. package/build/components/block-popover/cover.js.map +1 -1
  29. package/build/components/block-popover/inbetween.js +2 -2
  30. package/build/components/block-popover/inbetween.js.map +1 -1
  31. package/build/components/block-popover/index.js +2 -2
  32. package/build/components/block-popover/index.js.map +1 -1
  33. package/build/components/block-removal-warning-modal/index.js +2 -0
  34. package/build/components/block-removal-warning-modal/index.js.map +1 -1
  35. package/build/components/block-switcher/index.js +1 -1
  36. package/build/components/block-switcher/index.js.map +1 -1
  37. package/build/components/block-switcher/pattern-transformations-menu.js +11 -12
  38. package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  39. package/build/components/block-switcher/preview-block-popover.js +20 -17
  40. package/build/components/block-switcher/preview-block-popover.js.map +1 -1
  41. package/build/components/block-toolbar/shuffle.js +5 -2
  42. package/build/components/block-toolbar/shuffle.js.map +1 -1
  43. package/build/components/block-tools/block-selection-button.js +1 -2
  44. package/build/components/block-tools/block-selection-button.js.map +1 -1
  45. package/build/components/block-tools/index.js +1 -1
  46. package/build/components/block-tools/index.js.map +1 -1
  47. package/build/components/block-tools/use-block-toolbar-popover-props.js +1 -1
  48. package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  49. package/build/components/block-tools/use-show-block-tools.js +7 -8
  50. package/build/components/block-tools/use-show-block-tools.js.map +1 -1
  51. package/build/components/block-tools/zoom-out-mode-inserter-button.js +45 -0
  52. package/build/components/block-tools/zoom-out-mode-inserter-button.js.map +1 -0
  53. package/build/components/block-tools/zoom-out-mode-inserters.js +35 -36
  54. package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  55. package/build/components/block-tools/zoom-out-popover.js +2 -1
  56. package/build/components/block-tools/zoom-out-popover.js.map +1 -1
  57. package/build/components/block-tools/zoom-out-toolbar.js +1 -2
  58. package/build/components/block-tools/zoom-out-toolbar.js.map +1 -1
  59. package/build/components/child-layout-control/index.js +3 -1
  60. package/build/components/child-layout-control/index.js.map +1 -1
  61. package/build/components/date-format-picker/index.js +2 -11
  62. package/build/components/date-format-picker/index.js.map +1 -1
  63. package/build/components/default-block-appender/index.js +7 -4
  64. package/build/components/default-block-appender/index.js.map +1 -1
  65. package/build/components/dimensions-tool/scale-tool.js +1 -0
  66. package/build/components/dimensions-tool/scale-tool.js.map +1 -1
  67. package/build/components/font-appearance-control/index.js +2 -7
  68. package/build/components/font-appearance-control/index.js.map +1 -1
  69. package/build/components/font-family/index.js +12 -0
  70. package/build/components/font-family/index.js.map +1 -1
  71. package/build/components/global-styles/background-panel.js +63 -52
  72. package/build/components/global-styles/background-panel.js.map +1 -1
  73. package/build/components/global-styles/hooks.js +5 -1
  74. package/build/components/global-styles/hooks.js.map +1 -1
  75. package/build/components/global-styles/image-settings-panel.js +1 -0
  76. package/build/components/global-styles/image-settings-panel.js.map +1 -1
  77. package/build/components/global-styles/theme-file-uri-utils.js +0 -59
  78. package/build/components/global-styles/theme-file-uri-utils.js.map +1 -1
  79. package/build/components/global-styles/typography-panel.js +26 -44
  80. package/build/components/global-styles/typography-panel.js.map +1 -1
  81. package/build/components/global-styles/typography-utils.js +78 -7
  82. package/build/components/global-styles/typography-utils.js.map +1 -1
  83. package/build/components/global-styles/use-global-styles-output.js +82 -44
  84. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  85. package/build/components/global-styles/utils.js +96 -0
  86. package/build/components/global-styles/utils.js.map +1 -1
  87. package/build/components/grid/grid-item-movers.js +93 -44
  88. package/build/components/grid/grid-item-movers.js.map +1 -1
  89. package/build/components/grid/grid-item-resizer.js +14 -15
  90. package/build/components/grid/grid-item-resizer.js.map +1 -1
  91. package/build/components/grid/grid-visualizer.js +2 -2
  92. package/build/components/grid/grid-visualizer.js.map +1 -1
  93. package/build/components/grid/use-grid-layout-sync.js +93 -45
  94. package/build/components/grid/use-grid-layout-sync.js.map +1 -1
  95. package/build/components/iframe/index.js +4 -8
  96. package/build/components/iframe/index.js.map +1 -1
  97. package/build/components/index.js +1 -9
  98. package/build/components/index.js.map +1 -1
  99. package/build/components/inner-blocks/index.js +1 -1
  100. package/build/components/inner-blocks/index.js.map +1 -1
  101. package/build/components/inserter/block-patterns-tab/patterns-filter.js +20 -23
  102. package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
  103. package/build/components/inserter/category-tabs/index.js +29 -2
  104. package/build/components/inserter/category-tabs/index.js.map +1 -1
  105. package/build/components/inserter/media-tab/media-panel.js +1 -0
  106. package/build/components/inserter/media-tab/media-panel.js.map +1 -1
  107. package/build/components/inserter/menu.js +3 -3
  108. package/build/components/inserter/menu.js.map +1 -1
  109. package/build/components/inserter/preview-panel.js +20 -3
  110. package/build/components/inserter/preview-panel.js.map +1 -1
  111. package/build/components/inserter-draggable-blocks/index.js +10 -3
  112. package/build/components/inserter-draggable-blocks/index.js.map +1 -1
  113. package/build/components/inspector-controls-tabs/settings-tab.js +1 -2
  114. package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -1
  115. package/build/components/line-height-control/index.js +0 -15
  116. package/build/components/line-height-control/index.js.map +1 -1
  117. package/build/components/link-control/search-input.js +0 -1
  118. package/build/components/link-control/search-input.js.map +1 -1
  119. package/build/components/list-view/block-select-button.js +2 -6
  120. package/build/components/list-view/block-select-button.js.map +1 -1
  121. package/build/components/list-view/block.js +2 -2
  122. package/build/components/list-view/block.js.map +1 -1
  123. package/build/components/list-view/utils.js +3 -1
  124. package/build/components/list-view/utils.js.map +1 -1
  125. package/build/components/media-replace-flow/index.js +3 -1
  126. package/build/components/media-replace-flow/index.js.map +1 -1
  127. package/build/components/resolution-tool/index.js +1 -0
  128. package/build/components/resolution-tool/index.js.map +1 -1
  129. package/build/components/rich-text/format-toolbar/index.js +1 -1
  130. package/build/components/rich-text/format-toolbar/index.js.map +1 -1
  131. package/build/components/rich-text/index.js +1 -1
  132. package/build/components/rich-text/index.js.map +1 -1
  133. package/build/components/skip-to-selected-block/index.js +4 -2
  134. package/build/components/skip-to-selected-block/index.js.map +1 -1
  135. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +8 -8
  136. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  137. package/build/components/url-input/button.js +0 -1
  138. package/build/components/url-input/button.js.map +1 -1
  139. package/build/components/url-input/index.js +1 -11
  140. package/build/components/url-input/index.js.map +1 -1
  141. package/build/components/url-popover/image-url-input-ui.js +3 -3
  142. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  143. package/build/components/url-popover/link-editor.js +0 -1
  144. package/build/components/url-popover/link-editor.js.map +1 -1
  145. package/build/components/use-block-drop-zone/index.js +30 -4
  146. package/build/components/use-block-drop-zone/index.js.map +1 -1
  147. package/build/components/use-on-block-drop/index.js +3 -6
  148. package/build/components/use-on-block-drop/index.js.map +1 -1
  149. package/build/components/use-resize-canvas/index.js +1 -3
  150. package/build/components/use-resize-canvas/index.js.map +1 -1
  151. package/build/components/use-settings/index.js +2 -1
  152. package/build/components/use-settings/index.js.map +1 -1
  153. package/build/hooks/block-bindings.js +248 -36
  154. package/build/hooks/block-bindings.js.map +1 -1
  155. package/build/hooks/block-hooks.js +1 -0
  156. package/build/hooks/block-hooks.js.map +1 -1
  157. package/build/hooks/block-style-variation.js +2 -2
  158. package/build/hooks/block-style-variation.js.map +1 -1
  159. package/build/hooks/contrast-checker.js +6 -6
  160. package/build/hooks/contrast-checker.js.map +1 -1
  161. package/build/hooks/duotone.js +3 -3
  162. package/build/hooks/duotone.js.map +1 -1
  163. package/build/hooks/grid-visualizer.js +5 -8
  164. package/build/hooks/grid-visualizer.js.map +1 -1
  165. package/build/hooks/index.js +7 -1
  166. package/build/hooks/index.js.map +1 -1
  167. package/build/hooks/layout-child.js +9 -2
  168. package/build/hooks/layout-child.js.map +1 -1
  169. package/build/hooks/line-height.js +0 -1
  170. package/build/hooks/line-height.js.map +1 -1
  171. package/build/hooks/position.js +3 -7
  172. package/build/hooks/position.js.map +1 -1
  173. package/build/hooks/spacing-visualizer.js +1 -1
  174. package/build/hooks/spacing-visualizer.js.map +1 -1
  175. package/build/hooks/use-bindings-attributes.js +85 -50
  176. package/build/hooks/use-bindings-attributes.js.map +1 -1
  177. package/build/hooks/use-zoom-out.js +1 -1
  178. package/build/hooks/use-zoom-out.js.map +1 -1
  179. package/build/hooks/utils.js +20 -0
  180. package/build/hooks/utils.js.map +1 -1
  181. package/build/index.js +7 -0
  182. package/build/index.js.map +1 -1
  183. package/build/layouts/constrained.js +6 -2
  184. package/build/layouts/constrained.js.map +1 -1
  185. package/build/layouts/grid.js +2 -0
  186. package/build/layouts/grid.js.map +1 -1
  187. package/build/private-apis.js +0 -4
  188. package/build/private-apis.js.map +1 -1
  189. package/build/store/actions.js +27 -2
  190. package/build/store/actions.js.map +1 -1
  191. package/build/store/reducer.js +19 -1
  192. package/build/store/reducer.js.map +1 -1
  193. package/build/store/selectors.js +17 -5
  194. package/build/store/selectors.js.map +1 -1
  195. package/build/utils/get-editor-region.js +1 -1
  196. package/build/utils/get-editor-region.js.map +1 -1
  197. package/build/utils/get-px-from-css-unit.js +1 -1
  198. package/build/utils/get-px-from-css-unit.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 +4 -2
  206. package/build-module/components/block-breadcrumb/index.js.map +1 -1
  207. package/build-module/components/block-draggable/index.js +3 -3
  208. package/build-module/components/block-draggable/index.js.map +1 -1
  209. package/build-module/components/block-inspector/index.js +6 -3
  210. package/build-module/components/block-inspector/index.js.map +1 -1
  211. package/build-module/components/block-list/use-block-props/index.js +3 -1
  212. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  213. package/build-module/components/block-list/use-block-props/use-block-refs.js +27 -30
  214. package/build-module/components/block-list/use-block-props/use-block-refs.js.map +1 -1
  215. package/build-module/components/block-list/use-block-props/use-is-hovered.js +26 -9
  216. package/build-module/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
  217. package/build-module/components/block-list/use-in-between-inserter.js +3 -2
  218. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  219. package/build-module/components/block-lock/modal.js +2 -0
  220. package/build-module/components/block-lock/modal.js.map +1 -1
  221. package/build-module/components/block-mover/index.js +1 -2
  222. package/build-module/components/block-mover/index.js.map +1 -1
  223. package/build-module/components/block-popover/cover.js +1 -1
  224. package/build-module/components/block-popover/cover.js.map +1 -1
  225. package/build-module/components/block-popover/inbetween.js +1 -1
  226. package/build-module/components/block-popover/inbetween.js.map +1 -1
  227. package/build-module/components/block-popover/index.js +1 -1
  228. package/build-module/components/block-popover/index.js.map +1 -1
  229. package/build-module/components/block-removal-warning-modal/index.js +2 -0
  230. package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
  231. package/build-module/components/block-switcher/index.js +1 -1
  232. package/build-module/components/block-switcher/index.js.map +1 -1
  233. package/build-module/components/block-switcher/pattern-transformations-menu.js +12 -13
  234. package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  235. package/build-module/components/block-switcher/preview-block-popover.js +20 -17
  236. package/build-module/components/block-switcher/preview-block-popover.js.map +1 -1
  237. package/build-module/components/block-toolbar/shuffle.js +5 -2
  238. package/build-module/components/block-toolbar/shuffle.js.map +1 -1
  239. package/build-module/components/block-tools/block-selection-button.js +1 -2
  240. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  241. package/build-module/components/block-tools/index.js +1 -1
  242. package/build-module/components/block-tools/index.js.map +1 -1
  243. package/build-module/components/block-tools/use-block-toolbar-popover-props.js +1 -1
  244. package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  245. package/build-module/components/block-tools/use-show-block-tools.js +7 -8
  246. package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
  247. package/build-module/components/block-tools/zoom-out-mode-inserter-button.js +37 -0
  248. package/build-module/components/block-tools/zoom-out-mode-inserter-button.js.map +1 -0
  249. package/build-module/components/block-tools/zoom-out-mode-inserters.js +37 -38
  250. package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  251. package/build-module/components/block-tools/zoom-out-popover.js +2 -1
  252. package/build-module/components/block-tools/zoom-out-popover.js.map +1 -1
  253. package/build-module/components/block-tools/zoom-out-toolbar.js +1 -2
  254. package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -1
  255. package/build-module/components/child-layout-control/index.js +3 -1
  256. package/build-module/components/child-layout-control/index.js.map +1 -1
  257. package/build-module/components/date-format-picker/index.js +4 -12
  258. package/build-module/components/date-format-picker/index.js.map +1 -1
  259. package/build-module/components/default-block-appender/index.js +7 -4
  260. package/build-module/components/default-block-appender/index.js.map +1 -1
  261. package/build-module/components/dimensions-tool/scale-tool.js +1 -0
  262. package/build-module/components/dimensions-tool/scale-tool.js.map +1 -1
  263. package/build-module/components/font-appearance-control/index.js +3 -6
  264. package/build-module/components/font-appearance-control/index.js.map +1 -1
  265. package/build-module/components/font-family/index.js +11 -0
  266. package/build-module/components/font-family/index.js.map +1 -1
  267. package/build-module/components/global-styles/background-panel.js +63 -52
  268. package/build-module/components/global-styles/background-panel.js.map +1 -1
  269. package/build-module/components/global-styles/hooks.js +5 -1
  270. package/build-module/components/global-styles/hooks.js.map +1 -1
  271. package/build-module/components/global-styles/image-settings-panel.js +1 -0
  272. package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
  273. package/build-module/components/global-styles/theme-file-uri-utils.js +0 -58
  274. package/build-module/components/global-styles/theme-file-uri-utils.js.map +1 -1
  275. package/build-module/components/global-styles/typography-panel.js +27 -45
  276. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  277. package/build-module/components/global-styles/typography-utils.js +76 -7
  278. package/build-module/components/global-styles/typography-utils.js.map +1 -1
  279. package/build-module/components/global-styles/use-global-styles-output.js +81 -43
  280. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  281. package/build-module/components/global-styles/utils.js +92 -0
  282. package/build-module/components/global-styles/utils.js.map +1 -1
  283. package/build-module/components/grid/grid-item-movers.js +96 -46
  284. package/build-module/components/grid/grid-item-movers.js.map +1 -1
  285. package/build-module/components/grid/grid-item-resizer.js +14 -15
  286. package/build-module/components/grid/grid-item-resizer.js.map +1 -1
  287. package/build-module/components/grid/grid-visualizer.js +2 -2
  288. package/build-module/components/grid/grid-visualizer.js.map +1 -1
  289. package/build-module/components/grid/use-grid-layout-sync.js +94 -46
  290. package/build-module/components/grid/use-grid-layout-sync.js.map +1 -1
  291. package/build-module/components/iframe/index.js +4 -8
  292. package/build-module/components/iframe/index.js.map +1 -1
  293. package/build-module/components/index.js +0 -5
  294. package/build-module/components/index.js.map +1 -1
  295. package/build-module/components/inner-blocks/index.js +1 -1
  296. package/build-module/components/inner-blocks/index.js.map +1 -1
  297. package/build-module/components/inserter/block-patterns-tab/patterns-filter.js +20 -23
  298. package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
  299. package/build-module/components/inserter/category-tabs/index.js +30 -3
  300. package/build-module/components/inserter/category-tabs/index.js.map +1 -1
  301. package/build-module/components/inserter/media-tab/media-panel.js +1 -0
  302. package/build-module/components/inserter/media-tab/media-panel.js.map +1 -1
  303. package/build-module/components/inserter/menu.js +3 -3
  304. package/build-module/components/inserter/menu.js.map +1 -1
  305. package/build-module/components/inserter/preview-panel.js +20 -3
  306. package/build-module/components/inserter/preview-panel.js.map +1 -1
  307. package/build-module/components/inserter-draggable-blocks/index.js +10 -3
  308. package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
  309. package/build-module/components/inspector-controls-tabs/settings-tab.js +1 -2
  310. package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -1
  311. package/build-module/components/line-height-control/index.js +0 -14
  312. package/build-module/components/line-height-control/index.js.map +1 -1
  313. package/build-module/components/link-control/search-input.js +0 -1
  314. package/build-module/components/link-control/search-input.js.map +1 -1
  315. package/build-module/components/list-view/block-select-button.js +3 -7
  316. package/build-module/components/list-view/block-select-button.js.map +1 -1
  317. package/build-module/components/list-view/block.js +2 -2
  318. package/build-module/components/list-view/block.js.map +1 -1
  319. package/build-module/components/list-view/utils.js +3 -1
  320. package/build-module/components/list-view/utils.js.map +1 -1
  321. package/build-module/components/media-replace-flow/index.js +3 -1
  322. package/build-module/components/media-replace-flow/index.js.map +1 -1
  323. package/build-module/components/resolution-tool/index.js +1 -0
  324. package/build-module/components/resolution-tool/index.js.map +1 -1
  325. package/build-module/components/rich-text/format-toolbar/index.js +1 -1
  326. package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
  327. package/build-module/components/rich-text/index.js +1 -1
  328. package/build-module/components/rich-text/index.js.map +1 -1
  329. package/build-module/components/skip-to-selected-block/index.js +5 -3
  330. package/build-module/components/skip-to-selected-block/index.js.map +1 -1
  331. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +8 -8
  332. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  333. package/build-module/components/url-input/button.js +0 -1
  334. package/build-module/components/url-input/button.js.map +1 -1
  335. package/build-module/components/url-input/index.js +1 -11
  336. package/build-module/components/url-input/index.js.map +1 -1
  337. package/build-module/components/url-popover/image-url-input-ui.js +3 -3
  338. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  339. package/build-module/components/url-popover/link-editor.js +0 -1
  340. package/build-module/components/url-popover/link-editor.js.map +1 -1
  341. package/build-module/components/use-block-drop-zone/index.js +30 -4
  342. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  343. package/build-module/components/use-on-block-drop/index.js +3 -6
  344. package/build-module/components/use-on-block-drop/index.js.map +1 -1
  345. package/build-module/components/use-resize-canvas/index.js +1 -3
  346. package/build-module/components/use-resize-canvas/index.js.map +1 -1
  347. package/build-module/components/use-settings/index.js +2 -1
  348. package/build-module/components/use-settings/index.js.map +1 -1
  349. package/build-module/hooks/block-bindings.js +253 -40
  350. package/build-module/hooks/block-bindings.js.map +1 -1
  351. package/build-module/hooks/block-hooks.js +1 -0
  352. package/build-module/hooks/block-hooks.js.map +1 -1
  353. package/build-module/hooks/block-style-variation.js +3 -3
  354. package/build-module/hooks/block-style-variation.js.map +1 -1
  355. package/build-module/hooks/contrast-checker.js +7 -7
  356. package/build-module/hooks/contrast-checker.js.map +1 -1
  357. package/build-module/hooks/duotone.js +4 -4
  358. package/build-module/hooks/duotone.js.map +1 -1
  359. package/build-module/hooks/grid-visualizer.js +5 -8
  360. package/build-module/hooks/grid-visualizer.js.map +1 -1
  361. package/build-module/hooks/index.js +2 -1
  362. package/build-module/hooks/index.js.map +1 -1
  363. package/build-module/hooks/layout-child.js +9 -2
  364. package/build-module/hooks/layout-child.js.map +1 -1
  365. package/build-module/hooks/line-height.js +0 -1
  366. package/build-module/hooks/line-height.js.map +1 -1
  367. package/build-module/hooks/position.js +3 -7
  368. package/build-module/hooks/position.js.map +1 -1
  369. package/build-module/hooks/spacing-visualizer.js +1 -1
  370. package/build-module/hooks/spacing-visualizer.js.map +1 -1
  371. package/build-module/hooks/use-bindings-attributes.js +84 -51
  372. package/build-module/hooks/use-bindings-attributes.js.map +1 -1
  373. package/build-module/hooks/use-zoom-out.js +1 -1
  374. package/build-module/hooks/use-zoom-out.js.map +1 -1
  375. package/build-module/hooks/utils.js +19 -0
  376. package/build-module/hooks/utils.js.map +1 -1
  377. package/build-module/index.js +1 -1
  378. package/build-module/index.js.map +1 -1
  379. package/build-module/layouts/constrained.js +6 -2
  380. package/build-module/layouts/constrained.js.map +1 -1
  381. package/build-module/layouts/grid.js +2 -0
  382. package/build-module/layouts/grid.js.map +1 -1
  383. package/build-module/private-apis.js +1 -5
  384. package/build-module/private-apis.js.map +1 -1
  385. package/build-module/store/actions.js +24 -1
  386. package/build-module/store/actions.js.map +1 -1
  387. package/build-module/store/reducer.js +18 -1
  388. package/build-module/store/reducer.js.map +1 -1
  389. package/build-module/store/selectors.js +14 -4
  390. package/build-module/store/selectors.js.map +1 -1
  391. package/build-module/utils/get-editor-region.js +1 -1
  392. package/build-module/utils/get-editor-region.js.map +1 -1
  393. package/build-module/utils/get-px-from-css-unit.js +1 -1
  394. package/build-module/utils/get-px-from-css-unit.js.map +1 -1
  395. package/build-style/content-rtl.css +11 -18
  396. package/build-style/content.css +11 -18
  397. package/build-style/default-editor-styles-rtl.css +3 -0
  398. package/build-style/default-editor-styles.css +3 -0
  399. package/build-style/style-rtl.css +242 -136
  400. package/build-style/style.css +242 -136
  401. package/build-types/components/block-context/index.d.ts +2 -2
  402. package/build-types/components/block-context/index.d.ts.map +1 -1
  403. package/build-types/utils/dom.d.ts.map +1 -1
  404. package/package.json +31 -31
  405. package/src/autocompleters/style.scss +4 -0
  406. package/src/components/alignment-control/ui.js +2 -2
  407. package/src/components/block-alignment-control/ui.js +1 -1
  408. package/src/components/block-alignment-control/ui.native.js +1 -1
  409. package/src/components/block-breadcrumb/index.js +4 -2
  410. package/src/components/block-canvas/style.scss +1 -0
  411. package/src/components/block-context/README.md +4 -4
  412. package/src/components/block-draggable/index.js +3 -3
  413. package/src/components/block-inspector/index.js +8 -4
  414. package/src/components/block-list/content.scss +2 -16
  415. package/src/components/block-list/use-block-props/index.js +1 -1
  416. package/src/components/block-list/use-block-props/use-block-refs.js +30 -30
  417. package/src/components/block-list/use-block-props/use-is-hovered.js +26 -11
  418. package/src/components/block-list/use-in-between-inserter.js +5 -1
  419. package/src/components/block-lock/modal.js +10 -2
  420. package/src/components/block-lock/style.scss +4 -8
  421. package/src/components/block-mover/index.js +5 -2
  422. package/src/components/block-patterns-paging/style.scss +0 -23
  423. package/src/components/block-popover/cover.js +1 -1
  424. package/src/components/block-popover/inbetween.js +1 -1
  425. package/src/components/block-popover/index.js +1 -1
  426. package/src/components/block-removal-warning-modal/index.js +10 -2
  427. package/src/components/block-switcher/index.js +1 -1
  428. package/src/components/block-switcher/pattern-transformations-menu.js +17 -15
  429. package/src/components/block-switcher/preview-block-popover.js +20 -14
  430. package/src/components/block-switcher/style.scss +8 -17
  431. package/src/components/block-toolbar/shuffle.js +8 -1
  432. package/src/components/block-tools/block-selection-button.js +1 -2
  433. package/src/components/block-tools/index.js +5 -6
  434. package/src/components/block-tools/style.scss +8 -0
  435. package/src/components/block-tools/use-block-toolbar-popover-props.js +1 -1
  436. package/src/components/block-tools/use-show-block-tools.js +12 -9
  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 +48 -42
  439. package/src/components/block-tools/zoom-out-popover.js +1 -0
  440. package/src/components/block-tools/zoom-out-toolbar.js +1 -2
  441. package/src/components/button-block-appender/content.scss +1 -1
  442. package/src/components/child-layout-control/index.js +2 -0
  443. package/src/components/color-palette/test/__snapshots__/control.js.snap +2 -2
  444. package/src/components/colors-gradients/test/control.js +3 -2
  445. package/src/components/date-format-picker/index.js +2 -11
  446. package/src/components/default-block-appender/index.js +11 -4
  447. package/src/components/dimensions-tool/scale-tool.js +1 -0
  448. package/src/components/font-appearance-control/index.js +1 -5
  449. package/src/components/font-family/README.md +8 -0
  450. package/src/components/font-family/index.js +16 -0
  451. package/src/components/font-family/stories/index.story.js +54 -0
  452. package/src/components/global-styles/background-panel.js +90 -62
  453. package/src/components/global-styles/hooks.js +5 -1
  454. package/src/components/global-styles/image-settings-panel.js +1 -0
  455. package/src/components/global-styles/style.scss +11 -9
  456. package/src/components/global-styles/test/theme-file-uri-utils.js +1 -26
  457. package/src/components/global-styles/test/typography-utils.js +325 -0
  458. package/src/components/global-styles/test/use-global-styles-output.js +52 -5
  459. package/src/components/global-styles/test/utils.js +120 -0
  460. package/src/components/global-styles/theme-file-uri-utils.js +0 -59
  461. package/src/components/global-styles/typography-panel.js +36 -45
  462. package/src/components/global-styles/typography-utils.js +103 -7
  463. package/src/components/global-styles/use-global-styles-output.js +89 -50
  464. package/src/components/global-styles/utils.js +112 -0
  465. package/src/components/grid/grid-item-movers.js +141 -69
  466. package/src/components/grid/grid-item-resizer.js +11 -17
  467. package/src/components/grid/grid-visualizer.js +2 -2
  468. package/src/components/grid/style.scss +164 -0
  469. package/src/components/grid/use-grid-layout-sync.js +133 -40
  470. package/src/components/iframe/content.scss +3 -3
  471. package/src/components/iframe/index.js +3 -7
  472. package/src/components/index.js +0 -5
  473. package/src/components/inner-blocks/index.js +4 -1
  474. package/src/components/inserter/block-patterns-tab/patterns-filter.js +40 -44
  475. package/src/components/inserter/category-tabs/index.js +35 -2
  476. package/src/components/inserter/media-tab/media-panel.js +1 -0
  477. package/src/components/inserter/menu.js +3 -3
  478. package/src/components/inserter/preview-panel.js +27 -4
  479. package/src/components/inserter/style.scss +66 -47
  480. package/src/components/inserter-draggable-blocks/index.js +11 -3
  481. package/src/components/inspector-controls/README.md +5 -0
  482. package/src/components/inspector-controls-tabs/settings-tab.js +0 -2
  483. package/src/components/inspector-controls-tabs/style.scss +0 -21
  484. package/src/components/line-height-control/README.md +0 -8
  485. package/src/components/line-height-control/index.js +1 -21
  486. package/src/components/line-height-control/stories/index.story.js +0 -1
  487. package/src/components/line-height-control/test/index.js +1 -7
  488. package/src/components/link-control/search-input.js +0 -1
  489. package/src/components/list-view/block-select-button.js +3 -13
  490. package/src/components/list-view/block.js +10 -3
  491. package/src/components/list-view/style.scss +2 -1
  492. package/src/components/list-view/utils.js +13 -2
  493. package/src/components/media-replace-flow/README.md +7 -0
  494. package/src/components/media-replace-flow/index.js +3 -1
  495. package/src/components/resolution-tool/index.js +1 -0
  496. package/src/components/responsive-block-control/test/index.js +5 -1
  497. package/src/components/rich-text/format-toolbar/index.js +1 -1
  498. package/src/components/rich-text/index.js +1 -1
  499. package/src/components/skip-to-selected-block/index.js +5 -3
  500. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +6 -7
  501. package/src/components/tabbed-sidebar/style.scss +1 -19
  502. package/src/components/url-input/README.md +0 -5
  503. package/src/components/url-input/button.js +0 -1
  504. package/src/components/url-input/index.js +1 -15
  505. package/src/components/url-popover/image-url-input-ui.js +3 -3
  506. package/src/components/url-popover/link-editor.js +0 -1
  507. package/src/components/url-popover/style.scss +1 -0
  508. package/src/components/use-block-drop-zone/index.js +66 -14
  509. package/src/components/use-on-block-drop/index.js +1 -9
  510. package/src/components/use-resize-canvas/index.js +1 -3
  511. package/src/components/use-settings/index.js +2 -1
  512. package/src/hooks/block-bindings.js +303 -52
  513. package/src/hooks/block-bindings.scss +13 -2
  514. package/src/hooks/block-hooks.js +1 -0
  515. package/src/hooks/block-hooks.scss +1 -0
  516. package/src/hooks/block-style-variation.js +3 -3
  517. package/src/hooks/contrast-checker.js +7 -7
  518. package/src/hooks/duotone.js +4 -4
  519. package/src/hooks/grid-visualizer.js +5 -7
  520. package/src/hooks/index.js +2 -1
  521. package/src/hooks/layout-child.js +12 -3
  522. package/src/hooks/line-height.js +0 -1
  523. package/src/hooks/position.js +3 -13
  524. package/src/hooks/spacing-visualizer.js +1 -1
  525. package/src/hooks/use-bindings-attributes.js +93 -59
  526. package/src/hooks/use-editor-wrapper-styles.native.scss +1 -0
  527. package/src/hooks/use-zoom-out.js +1 -1
  528. package/src/hooks/utils.js +14 -1
  529. package/src/index.js +1 -0
  530. package/src/layouts/constrained.js +10 -2
  531. package/src/layouts/grid.js +2 -0
  532. package/src/private-apis.js +1 -8
  533. package/src/store/actions.js +28 -5
  534. package/src/store/reducer.js +18 -0
  535. package/src/store/selectors.js +14 -4
  536. package/src/style.scss +1 -1
  537. package/src/utils/get-editor-region.js +1 -1
  538. package/src/utils/get-px-from-css-unit.js +1 -1
  539. package/tsconfig.tsbuildinfo +1 -1
  540. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +0 -30
  541. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +0 -1
  542. package/build/components/inserter/reusable-block-rename-hint.js +0 -71
  543. package/build/components/inserter/reusable-block-rename-hint.js.map +0 -1
  544. package/build/components/inspector-controls-tabs/settings-tab-hint.js +0 -53
  545. package/build/components/inspector-controls-tabs/settings-tab-hint.js.map +0 -1
  546. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +0 -23
  547. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +0 -1
  548. package/build-module/components/inserter/reusable-block-rename-hint.js +0 -64
  549. package/build-module/components/inserter/reusable-block-rename-hint.js.map +0 -1
  550. package/build-module/components/inspector-controls-tabs/settings-tab-hint.js +0 -47
  551. package/build-module/components/inspector-controls-tabs/settings-tab-hint.js.map +0 -1
  552. package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +0 -25
  553. package/src/components/inserter/reusable-block-rename-hint.js +0 -69
  554. package/src/components/inspector-controls-tabs/settings-tab-hint.js +0 -52
@@ -25,9 +25,8 @@ import { getValueFromVariable, useToolsPanelDropdownMenuProps } from './utils';
25
25
  import { setImmutably } from '../../utils/object';
26
26
  import {
27
27
  getMergedFontFamiliesAndFontFamilyFaces,
28
- findNearestFontWeight,
28
+ findNearestStyleAndWeight,
29
29
  } from './typography-utils';
30
- import { getFontStylesAndWeights } from '../../utils/get-font-styles-and-weights';
31
30
 
32
31
  const MIN_TEXT_COLUMNS = 1;
33
32
  const MAX_TEXT_COLUMNS = 6;
@@ -236,57 +235,50 @@ export default function TypographyPanel( {
236
235
  const hasFontWeights = settings?.typography?.fontWeight;
237
236
  const fontStyle = decodeValue( inheritedValue?.typography?.fontStyle );
238
237
  const fontWeight = decodeValue( inheritedValue?.typography?.fontWeight );
239
- const setFontAppearance = ( {
240
- fontStyle: newFontStyle,
241
- fontWeight: newFontWeight,
242
- } ) => {
243
- onChange( {
244
- ...value,
245
- typography: {
246
- ...value?.typography,
247
- fontStyle: newFontStyle || undefined,
248
- fontWeight: newFontWeight || undefined,
249
- },
250
- } );
251
- };
238
+ const { nearestFontStyle, nearestFontWeight } = findNearestStyleAndWeight(
239
+ fontFamilyFaces,
240
+ fontStyle,
241
+ fontWeight
242
+ );
243
+ const setFontAppearance = useCallback(
244
+ ( { fontStyle: newFontStyle, fontWeight: newFontWeight } ) => {
245
+ // Only update the font style and weight if they have changed.
246
+ if ( newFontStyle !== fontStyle || newFontWeight !== fontWeight ) {
247
+ onChange( {
248
+ ...value,
249
+ typography: {
250
+ ...value?.typography,
251
+ fontStyle: newFontStyle || undefined,
252
+ fontWeight: newFontWeight || undefined,
253
+ },
254
+ } );
255
+ }
256
+ },
257
+ [ fontStyle, fontWeight, onChange, value ]
258
+ );
252
259
  const hasFontAppearance = () =>
253
260
  !! value?.typography?.fontStyle || !! value?.typography?.fontWeight;
254
- const resetFontAppearance = () => {
261
+ const resetFontAppearance = useCallback( () => {
255
262
  setFontAppearance( {} );
256
- };
263
+ }, [ setFontAppearance ] );
257
264
 
258
- // Check if previous font style and weight values are available in the new font family
265
+ // Check if previous font style and weight values are available in the new font family.
259
266
  useEffect( () => {
260
- const { fontStyles, fontWeights, isSystemFont } =
261
- getFontStylesAndWeights( fontFamilyFaces );
262
- const hasFontStyle = fontStyles?.some(
263
- ( { value: fs } ) => fs === fontStyle
264
- );
265
- const hasFontWeight = fontWeights?.some(
266
- ( { value: fw } ) => fw === fontWeight
267
- );
268
-
269
- // Try to set nearest available font weight
270
- if ( ! hasFontWeight && fontWeight ) {
267
+ if ( nearestFontStyle && nearestFontWeight ) {
271
268
  setFontAppearance( {
272
- fontStyle,
273
- fontWeight: findNearestFontWeight( fontWeights, fontWeight ),
269
+ fontStyle: nearestFontStyle,
270
+ fontWeight: nearestFontWeight,
274
271
  } );
275
- }
276
-
277
- // Set the same weight and style values if the font family is a system font or if both are the same
278
- if ( isSystemFont || ( hasFontStyle && hasFontWeight ) ) {
279
- setFontAppearance( {
280
- fontStyle,
281
- fontWeight,
282
- } );
283
- }
284
-
285
- // Reset font appearance if the font family does not have the selected font style
286
- if ( ! hasFontStyle ) {
272
+ } else {
273
+ // Reset font appearance if there are no available styles or weights.
287
274
  resetFontAppearance();
288
275
  }
289
- }, [ fontFamily ] );
276
+ }, [
277
+ nearestFontStyle,
278
+ nearestFontWeight,
279
+ resetFontAppearance,
280
+ setFontAppearance,
281
+ ] );
290
282
 
291
283
  // Line Height
292
284
  const hasLineHeightEnabled = useHasLineHeightControl( settings );
@@ -482,7 +474,6 @@ export default function TypographyPanel( {
482
474
  panelId={ panelId }
483
475
  >
484
476
  <LineHeightControl
485
- __nextHasNoMarginBottom
486
477
  __unstableInputWidth="auto"
487
478
  value={ lineHeight }
488
479
  onChange={ setLineHeight }
@@ -11,6 +11,7 @@ import {
11
11
  getComputedFluidTypographyValue,
12
12
  getTypographyValueAndUnit,
13
13
  } from '../font-sizes/fluid-utils';
14
+ import { getFontStylesAndWeights } from '../../utils/get-font-styles-and-weights';
14
15
 
15
16
  /**
16
17
  * @typedef {Object} FluidPreset
@@ -127,9 +128,9 @@ export function getFluidTypographyOptionsFromSettings( settings ) {
127
128
  * Returns an object of merged font families and the font faces from the selected font family
128
129
  * based on the theme.json settings object and the currently selected font family.
129
130
  *
130
- * @param {Object} settings Theme.json settings
131
- * @param {string} selectedFontFamily Decoded font family string
132
- * @return {Object} Merged font families and font faces from the selected font family
131
+ * @param {Object} settings Theme.json settings.
132
+ * @param {string} selectedFontFamily Decoded font family string.
133
+ * @return {Object} Merged font families and font faces from the selected font family.
133
134
  */
134
135
  export function getMergedFontFamiliesAndFontFamilyFaces(
135
136
  settings,
@@ -153,11 +154,10 @@ export function getMergedFontFamiliesAndFontFamilyFaces(
153
154
  * Returns the nearest font weight value from the available font weight list based on the new font weight.
154
155
  * The nearest font weight is the one with the smallest difference from the new font weight.
155
156
  *
156
- * @param {Array} availableFontWeights Array of available font weights
157
- * @param {string} newFontWeightValue New font weight value
158
- * @return {string} Nearest font weight
157
+ * @param {Array} availableFontWeights Array of available font weights.
158
+ * @param {string} newFontWeightValue New font weight value.
159
+ * @return {string} Nearest font weight.
159
160
  */
160
-
161
161
  export function findNearestFontWeight(
162
162
  availableFontWeights,
163
163
  newFontWeightValue
@@ -185,3 +185,99 @@ export function findNearestFontWeight(
185
185
 
186
186
  return nearestFontWeight;
187
187
  }
188
+
189
+ /**
190
+ * Returns the nearest font style based on the new font style.
191
+ * Defaults to an empty string if the new font style is not valid or available.
192
+ *
193
+ * @param {Array} availableFontStyles Array of available font weights.
194
+ * @param {string} newFontStyleValue New font style value.
195
+ * @return {string} Nearest font style or an empty string.
196
+ */
197
+ export function findNearestFontStyle( availableFontStyles, newFontStyleValue ) {
198
+ if ( typeof newFontStyleValue !== 'string' || ! newFontStyleValue ) {
199
+ return '';
200
+ }
201
+
202
+ const validStyles = [ 'normal', 'italic', 'oblique' ];
203
+ if ( ! validStyles.includes( newFontStyleValue ) ) {
204
+ return '';
205
+ }
206
+
207
+ if (
208
+ ! availableFontStyles ||
209
+ availableFontStyles.length === 0 ||
210
+ availableFontStyles.find(
211
+ ( style ) => style.value === newFontStyleValue
212
+ )
213
+ ) {
214
+ return newFontStyleValue;
215
+ }
216
+
217
+ if (
218
+ newFontStyleValue === 'oblique' &&
219
+ ! availableFontStyles.find( ( style ) => style.value === 'oblique' )
220
+ ) {
221
+ return 'italic';
222
+ }
223
+
224
+ return '';
225
+ }
226
+
227
+ /**
228
+ * Returns the nearest font style and weight based on the available font family faces and the new font style and weight.
229
+ *
230
+ * @param {Array} fontFamilyFaces Array of available font family faces.
231
+ * @param {string} fontStyle New font style. Defaults to previous value.
232
+ * @param {string} fontWeight New font weight. Defaults to previous value.
233
+ * @return {Object} Nearest font style and font weight.
234
+ */
235
+ export function findNearestStyleAndWeight(
236
+ fontFamilyFaces,
237
+ fontStyle,
238
+ fontWeight
239
+ ) {
240
+ let nearestFontStyle = fontStyle;
241
+ let nearestFontWeight = fontWeight;
242
+
243
+ const { fontStyles, fontWeights, combinedStyleAndWeightOptions } =
244
+ getFontStylesAndWeights( fontFamilyFaces );
245
+
246
+ // Check if the new font style and weight are available in the font family faces.
247
+ const hasFontStyle = fontStyles?.some(
248
+ ( { value: fs } ) => fs === fontStyle
249
+ );
250
+ const hasFontWeight = fontWeights?.some(
251
+ ( { value: fw } ) => fw === fontWeight
252
+ );
253
+
254
+ if ( ! hasFontStyle ) {
255
+ /*
256
+ * Default to italic if oblique is not available.
257
+ * Or find the nearest font style based on the nearest font weight.
258
+ */
259
+ nearestFontStyle = fontStyle
260
+ ? findNearestFontStyle( fontStyles, fontStyle )
261
+ : combinedStyleAndWeightOptions?.find(
262
+ ( option ) =>
263
+ option.style.fontWeight ===
264
+ findNearestFontWeight( fontWeights, fontWeight )
265
+ )?.style?.fontStyle;
266
+ }
267
+
268
+ if ( ! hasFontWeight ) {
269
+ /*
270
+ * Find the nearest font weight based on available weights.
271
+ * Or find the nearest font weight based on the nearest font style.
272
+ */
273
+ nearestFontWeight = fontWeight
274
+ ? findNearestFontWeight( fontWeights, fontWeight )
275
+ : combinedStyleAndWeightOptions?.find(
276
+ ( option ) =>
277
+ option.style.fontStyle ===
278
+ ( nearestFontStyle || fontStyle )
279
+ )?.style?.fontWeight;
280
+ }
281
+
282
+ return { nearestFontStyle, nearestFontWeight };
283
+ }
@@ -24,6 +24,8 @@ import {
24
24
  scopeFeatureSelectors,
25
25
  appendToSelector,
26
26
  getBlockStyleVariationSelector,
27
+ compileStyleValue,
28
+ getResolvedValue,
27
29
  } from './utils';
28
30
  import { getBlockCSSSelector } from './get-block-css-selector';
29
31
  import { getTypographyFontSizeValue } from './typography-utils';
@@ -36,7 +38,12 @@ import { store as blockEditorStore } from '../../store';
36
38
  import { LAYOUT_DEFINITIONS } from '../../layouts/definitions';
37
39
  import { getValueFromObjectPath, setImmutably } from '../../utils/object';
38
40
  import { unlock } from '../../lock-unlock';
39
- import { setThemeFileUris } from './theme-file-uri-utils';
41
+
42
+ // Elements that rely on class names in their selectors.
43
+ const ELEMENT_CLASS_NAMES = {
44
+ button: 'wp-element-button',
45
+ caption: 'wp-element-caption',
46
+ };
40
47
 
41
48
  // List of block support features that can have their related styles
42
49
  // generated under their own feature level selector rather than the block's.
@@ -48,21 +55,6 @@ const BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = {
48
55
  };
49
56
  const { kebabCase } = unlock( componentsPrivateApis );
50
57
 
51
- function compileStyleValue( uncompiledValue ) {
52
- const VARIABLE_REFERENCE_PREFIX = 'var:';
53
- const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';
54
- const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';
55
-
56
- if ( uncompiledValue?.startsWith?.( VARIABLE_REFERENCE_PREFIX ) ) {
57
- const variable = uncompiledValue
58
- .slice( VARIABLE_REFERENCE_PREFIX.length )
59
- .split( VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE )
60
- .join( VARIABLE_PATH_SEPARATOR_TOKEN_STYLE );
61
- return `var(--wp--${ variable })`;
62
- }
63
- return uncompiledValue;
64
- }
65
-
66
58
  /**
67
59
  * Transform given preset tree into a set of style declarations.
68
60
  *
@@ -389,21 +381,40 @@ export function getStylesDeclarations(
389
381
  );
390
382
 
391
383
  /*
392
- * Set background defaults.
393
- * Applies to all background styles except the top-level site background.
384
+ * Preprocess background image values.
385
+ *
386
+ * Note: As we absorb more and more styles into the engine, we could simplify this function.
387
+ * A refactor is for the style engine to handle ref resolution (and possibly defaults)
388
+ * via a public util used internally and externally. Theme.json tree and defaults could be passed
389
+ * as options.
394
390
  */
395
- if ( ! isRoot && !! blockStyles.background ) {
396
- blockStyles = {
397
- ...blockStyles,
398
- background: {
399
- ...blockStyles.background,
400
- ...setBackgroundStyleDefaults( blockStyles.background ),
401
- },
402
- };
391
+ if ( !! blockStyles.background ) {
392
+ /*
393
+ * Resolve dynamic values before they are compiled by the style engine,
394
+ * which doesn't (yet) resolve dynamic values.
395
+ */
396
+ if ( blockStyles.background?.backgroundImage ) {
397
+ blockStyles.background.backgroundImage = getResolvedValue(
398
+ blockStyles.background.backgroundImage,
399
+ tree
400
+ );
401
+ }
402
+
403
+ /*
404
+ * Set default values for block background styles.
405
+ * Top-level styles are an exception as they are applied to the body.
406
+ */
407
+ if ( ! isRoot && !! blockStyles.background?.backgroundImage?.id ) {
408
+ blockStyles = {
409
+ ...blockStyles,
410
+ background: {
411
+ ...blockStyles.background,
412
+ ...setBackgroundStyleDefaults( blockStyles.background ),
413
+ },
414
+ };
415
+ }
403
416
  }
404
417
 
405
- // The goal is to move everything to server side generated engine styles
406
- // This is temporary as we absorb more and more styles into the engine.
407
418
  const extraRules = getCSSRules( blockStyles );
408
419
  extraRules.forEach( ( rule ) => {
409
420
  // Don't output padding properties if padding variables are set or if we're not editing a full template.
@@ -418,18 +429,7 @@ export function getStylesDeclarations(
418
429
  ? rule.key
419
430
  : kebabCase( rule.key );
420
431
 
421
- let ruleValue = rule.value;
422
- if ( typeof ruleValue !== 'string' && ruleValue?.ref ) {
423
- const refPath = ruleValue.ref.split( '.' );
424
- ruleValue = compileStyleValue(
425
- getValueFromObjectPath( tree, refPath )
426
- );
427
- // Presence of another ref indicates a reference to another dynamic value.
428
- // Pointing to another dynamic value is not supported.
429
- if ( ! ruleValue || ruleValue?.ref ) {
430
- return;
431
- }
432
- }
432
+ let ruleValue = getResolvedValue( rule.value, tree, null );
433
433
 
434
434
  // Calculate fluid typography rules where available.
435
435
  if ( cssProperty === 'font-size' ) {
@@ -643,6 +643,9 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
643
643
  nodes.push( {
644
644
  styles,
645
645
  selector: ROOT_BLOCK_SELECTOR,
646
+ // Root selector (body) styles should not be wrapped in `:root where()` to keep
647
+ // specificity at (0,0,1) and maintain backwards compatibility.
648
+ skipSelectorWrapper: true,
646
649
  } );
647
650
  }
648
651
 
@@ -651,6 +654,9 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
651
654
  nodes.push( {
652
655
  styles: tree.styles?.elements?.[ name ],
653
656
  selector,
657
+ // Top level elements that don't use a class name should not receive the
658
+ // `:root :where()` wrapper to maintain backwards compatibility.
659
+ skipSelectorWrapper: ! ELEMENT_CLASS_NAMES[ name ],
654
660
  } );
655
661
  }
656
662
  } );
@@ -957,6 +963,7 @@ export const toStyles = (
957
963
  hasLayoutSupport,
958
964
  featureSelectors,
959
965
  styleVariationSelectors,
966
+ skipSelectorWrapper,
960
967
  } ) => {
961
968
  // Process styles for block support features with custom feature level
962
969
  // CSS selectors set.
@@ -1015,7 +1022,10 @@ export const toStyles = (
1015
1022
  disableRootPadding
1016
1023
  );
1017
1024
  if ( styleDeclarations?.length ) {
1018
- ruleset += `:root :where(${ selector }){${ styleDeclarations.join(
1025
+ const generalSelector = skipSelectorWrapper
1026
+ ? selector
1027
+ : `:root :where(${ selector })`;
1028
+ ruleset += `${ generalSelector }{${ styleDeclarations.join(
1019
1029
  ';'
1020
1030
  ) };}`;
1021
1031
  }
@@ -1109,7 +1119,11 @@ export const toStyles = (
1109
1119
  .map( ( sel ) => sel + pseudoKey )
1110
1120
  .join( ',' );
1111
1121
 
1112
- const pseudoRule = `${ _selector }{${ pseudoDeclarations.join(
1122
+ // As pseudo classes such as :hover, :focus etc. have class-level
1123
+ // specificity, they must use the `:root :where()` wrapper. This.
1124
+ // caps the specificity at `0-1-0` to allow proper nesting of variations
1125
+ // and block type element styles.
1126
+ const pseudoRule = `:root :where(${ _selector }){${ pseudoDeclarations.join(
1113
1127
  ';'
1114
1128
  ) };}`;
1115
1129
 
@@ -1307,9 +1321,17 @@ function updateConfigWithSeparator( config ) {
1307
1321
  export function processCSSNesting( css, blockSelector ) {
1308
1322
  let processedCSS = '';
1309
1323
 
1324
+ if ( ! css || css.trim() === '' ) {
1325
+ return processedCSS;
1326
+ }
1327
+
1310
1328
  // Split CSS nested rules.
1311
1329
  const parts = css.split( '&' );
1312
1330
  parts.forEach( ( part ) => {
1331
+ if ( ! part || part.trim() === '' ) {
1332
+ return;
1333
+ }
1334
+
1313
1335
  const isRootCss = ! part.includes( '{' );
1314
1336
  if ( isRootCss ) {
1315
1337
  // If the part doesn't contain braces, it applies to the root level.
@@ -1322,11 +1344,32 @@ export function processCSSNesting( css, blockSelector ) {
1322
1344
  }
1323
1345
 
1324
1346
  const [ nestedSelector, cssValue ] = splittedPart;
1325
- const combinedSelector = nestedSelector.startsWith( ' ' )
1326
- ? scopeSelector( blockSelector, nestedSelector )
1327
- : appendToSelector( blockSelector, nestedSelector );
1328
1347
 
1329
- processedCSS += `:root :where(${ combinedSelector }){${ cssValue.trim() }}`;
1348
+ // Handle pseudo elements such as ::before, ::after, etc. Regex will also
1349
+ // capture any leading combinator such as >, +, or ~, as well as spaces.
1350
+ // This allows pseudo elements as descendants e.g. `.parent ::before`.
1351
+ const matches = nestedSelector.match( /([>+~\s]*::[a-zA-Z-]+)/ );
1352
+ const pseudoPart = matches ? matches[ 1 ] : '';
1353
+ const withoutPseudoElement = matches
1354
+ ? nestedSelector.replace( pseudoPart, '' ).trim()
1355
+ : nestedSelector.trim();
1356
+
1357
+ let combinedSelector;
1358
+ if ( withoutPseudoElement === '' ) {
1359
+ // Only contained a pseudo element to use the block selector to form
1360
+ // the final `:root :where()` selector.
1361
+ combinedSelector = blockSelector;
1362
+ } else {
1363
+ // If the nested selector is a descendant of the block scope it with the
1364
+ // block selector. Otherwise append it to the block selector.
1365
+ combinedSelector = nestedSelector.startsWith( ' ' )
1366
+ ? scopeSelector( blockSelector, withoutPseudoElement )
1367
+ : appendToSelector( blockSelector, withoutPseudoElement );
1368
+ }
1369
+
1370
+ // Build final rule, re-adding any pseudo element outside the `:where()`
1371
+ // to maintain valid CSS selector.
1372
+ processedCSS += `:root :where(${ combinedSelector })${ pseudoPart }{${ cssValue.trim() }}`;
1330
1373
  }
1331
1374
  } );
1332
1375
  return processedCSS;
@@ -1349,10 +1392,6 @@ export function useGlobalStylesOutputWithConfig(
1349
1392
  disableRootPadding
1350
1393
  ) {
1351
1394
  const [ blockGap ] = useGlobalSetting( 'spacing.blockGap' );
1352
- mergedConfig = setThemeFileUris(
1353
- mergedConfig,
1354
- mergedConfig?._links?.[ 'wp:theme-file' ]
1355
- );
1356
1395
  const hasBlockGapSupport = blockGap !== null;
1357
1396
  const hasFallbackGapSupport = ! hasBlockGapSupport; // This setting isn't useful yet: it exists as a placeholder for a future explicit fallback styles support.
1358
1397
  const disableLayoutStyles = useSelect( ( select ) => {
@@ -525,3 +525,115 @@ export function getBlockStyleVariationSelector( variation, blockSelector ) {
525
525
 
526
526
  return result.join( ',' );
527
527
  }
528
+
529
+ /**
530
+ * Converts style preset values `var:` to CSS custom var values.
531
+ * TODO: Export and use the style engine util: getCSSVarFromStyleValue().
532
+ *
533
+ * Example:
534
+ *
535
+ * compileStyleValue( 'var:preset|color|primary' ) // returns 'var(--wp--color-primary)'
536
+ *
537
+ * @param {string} uncompiledValue A block style value.
538
+ * @return {string} The compiled, or original value.
539
+ */
540
+ export function compileStyleValue( uncompiledValue ) {
541
+ const VARIABLE_REFERENCE_PREFIX = 'var:';
542
+ if (
543
+ 'string' === typeof uncompiledValue &&
544
+ uncompiledValue?.startsWith?.( VARIABLE_REFERENCE_PREFIX )
545
+ ) {
546
+ const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';
547
+ const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';
548
+ const variable = uncompiledValue
549
+ .slice( VARIABLE_REFERENCE_PREFIX.length )
550
+ .split( VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE )
551
+ .join( VARIABLE_PATH_SEPARATOR_TOKEN_STYLE );
552
+ return `var(--wp--${ variable })`;
553
+ }
554
+ return uncompiledValue;
555
+ }
556
+
557
+ /**
558
+ * Looks up a theme file URI based on a relative path.
559
+ *
560
+ * @param {string} file A relative path.
561
+ * @param {Array<Object>} themeFileURIs A collection of absolute theme file URIs and their corresponding file paths.
562
+ * @return {string} A resolved theme file URI, if one is found in the themeFileURIs collection.
563
+ */
564
+ export function getResolvedThemeFilePath( file, themeFileURIs ) {
565
+ if ( ! file || ! themeFileURIs || ! Array.isArray( themeFileURIs ) ) {
566
+ return file;
567
+ }
568
+
569
+ const uri = themeFileURIs.find(
570
+ ( themeFileUri ) => themeFileUri?.name === file
571
+ );
572
+
573
+ if ( ! uri?.href ) {
574
+ return file;
575
+ }
576
+
577
+ return uri?.href;
578
+ }
579
+
580
+ /**
581
+ * Resolves ref values in theme JSON.
582
+ *
583
+ * @param {Object|string} ruleValue A block style value that may contain a reference to a theme.json value.
584
+ * @param {Object} tree A theme.json object.
585
+ * @return {*} The resolved value or incoming ruleValue.
586
+ */
587
+ export function getResolvedRefValue( ruleValue, tree ) {
588
+ if ( ! ruleValue || ! tree ) {
589
+ return ruleValue;
590
+ }
591
+
592
+ if ( typeof ruleValue !== 'string' && ruleValue?.ref ) {
593
+ const refPath = ruleValue.ref.split( '.' );
594
+ const resolvedRuleValue = compileStyleValue(
595
+ getValueFromObjectPath( tree, refPath )
596
+ );
597
+
598
+ /*
599
+ * Presence of another ref indicates a reference to another dynamic value.
600
+ * Pointing to another dynamic value is not supported.
601
+ */
602
+ if ( resolvedRuleValue?.ref ) {
603
+ return undefined;
604
+ }
605
+
606
+ if ( ! resolvedRuleValue ) {
607
+ return ruleValue;
608
+ }
609
+
610
+ return resolvedRuleValue;
611
+ }
612
+ return ruleValue;
613
+ }
614
+
615
+ /**
616
+ * Resolves ref and relative path values in theme JSON.
617
+ *
618
+ * @param {Object|string} ruleValue A block style value that may contain a reference to a theme.json value.
619
+ * @param {Object} tree A theme.json object.
620
+ * @return {*} The resolved value or incoming ruleValue.
621
+ */
622
+ export function getResolvedValue( ruleValue, tree ) {
623
+ if ( ! ruleValue || ! tree ) {
624
+ return ruleValue;
625
+ }
626
+
627
+ // Resolve ref values.
628
+ const resolvedValue = getResolvedRefValue( ruleValue, tree );
629
+
630
+ // Resolve relative paths.
631
+ if ( resolvedValue?.url ) {
632
+ resolvedValue.url = getResolvedThemeFilePath(
633
+ resolvedValue.url,
634
+ tree?._links?.[ 'wp:theme-file' ]
635
+ );
636
+ }
637
+
638
+ return resolvedValue;
639
+ }