@wordpress/block-editor 11.1.0 → 11.3.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 (765) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE.md +1 -1
  3. package/README.md +28 -4
  4. package/build/components/alignment-control/ui.js +1 -1
  5. package/build/components/alignment-control/ui.js.map +1 -1
  6. package/build/components/autocomplete/index.js +2 -7
  7. package/build/components/autocomplete/index.js.map +1 -1
  8. package/build/components/block-actions/index.js +9 -0
  9. package/build/components/block-actions/index.js.map +1 -1
  10. package/build/components/block-alignment-matrix-control/index.js +2 -2
  11. package/build/components/block-alignment-matrix-control/index.js.map +1 -1
  12. package/build/components/block-card/index.js +2 -4
  13. package/build/components/block-card/index.js.map +1 -1
  14. package/build/components/block-edit/index.js +8 -0
  15. package/build/components/block-edit/index.js.map +1 -1
  16. package/build/components/block-inspector/index.js +18 -15
  17. package/build/components/block-inspector/index.js.map +1 -1
  18. package/build/components/block-list/use-in-between-inserter.js +5 -0
  19. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  20. package/build/components/block-lock/modal.js +0 -1
  21. package/build/components/block-lock/modal.js.map +1 -1
  22. package/build/components/block-mover/mover-description.js +2 -2
  23. package/build/components/block-mover/mover-description.js.map +1 -1
  24. package/build/components/block-navigation/dropdown.js +3 -1
  25. package/build/components/block-navigation/dropdown.js.map +1 -1
  26. package/build/components/block-pattern-setup/index.js +1 -1
  27. package/build/components/block-pattern-setup/index.js.map +1 -1
  28. package/build/components/block-pattern-setup/use-patterns-setup.js +2 -2
  29. package/build/components/block-pattern-setup/use-patterns-setup.js.map +1 -1
  30. package/build/components/block-patterns-list/index.js +31 -3
  31. package/build/components/block-patterns-list/index.js.map +1 -1
  32. package/build/components/block-preview/auto.js +9 -14
  33. package/build/components/block-preview/auto.js.map +1 -1
  34. package/build/components/block-preview/index.js +32 -8
  35. package/build/components/block-preview/index.js.map +1 -1
  36. package/build/components/block-selection-clearer/index.js +1 -1
  37. package/build/components/block-selection-clearer/index.js.map +1 -1
  38. package/build/components/block-settings/container.native.js +7 -33
  39. package/build/components/block-settings/container.native.js.map +1 -1
  40. package/build/components/block-settings-menu/block-settings-dropdown.js +12 -3
  41. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  42. package/build/components/block-settings-menu-controls/index.js +2 -8
  43. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  44. package/build/components/block-styles/index.js +3 -1
  45. package/build/components/block-styles/index.js.map +1 -1
  46. package/build/components/block-switcher/utils.js +1 -1
  47. package/build/components/block-switcher/utils.js.map +1 -1
  48. package/build/components/block-tools/selected-block-popover.js +55 -47
  49. package/build/components/block-tools/selected-block-popover.js.map +1 -1
  50. package/build/components/block-tools/use-block-toolbar-popover-props.js +43 -10
  51. package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  52. package/build/components/block-vertical-alignment-control/icons.js +15 -1
  53. package/build/components/block-vertical-alignment-control/icons.js.map +1 -1
  54. package/build/components/block-vertical-alignment-control/ui.js +9 -4
  55. package/build/components/block-vertical-alignment-control/ui.js.map +1 -1
  56. package/build/components/color-style-selector/index.js +3 -1
  57. package/build/components/color-style-selector/index.js.map +1 -1
  58. package/build/components/date-format-picker/index.js +3 -4
  59. package/build/components/date-format-picker/index.js.map +1 -1
  60. package/build/components/default-style-picker/index.js +1 -0
  61. package/build/components/default-style-picker/index.js.map +1 -1
  62. package/build/components/font-family/index.js +1 -7
  63. package/build/components/font-family/index.js.map +1 -1
  64. package/build/components/font-sizes/fluid-utils.js +1 -1
  65. package/build/components/font-sizes/fluid-utils.js.map +1 -1
  66. package/build/components/font-sizes/utils.js +1 -1
  67. package/build/components/font-sizes/utils.js.map +1 -1
  68. package/build/components/font-sizes/with-font-sizes.js +5 -8
  69. package/build/components/font-sizes/with-font-sizes.js.map +1 -1
  70. package/build/components/global-styles/context.js +22 -0
  71. package/build/components/global-styles/context.js.map +1 -0
  72. package/build/components/global-styles/hooks.js +142 -0
  73. package/build/components/global-styles/hooks.js.map +1 -0
  74. package/build/components/global-styles/index.js +42 -0
  75. package/build/components/global-styles/index.js.map +1 -0
  76. package/build/components/global-styles/typography-utils.js +92 -0
  77. package/build/components/global-styles/typography-utils.js.map +1 -0
  78. package/build/components/global-styles/use-global-styles-output.js +974 -0
  79. package/build/components/global-styles/use-global-styles-output.js.map +1 -0
  80. package/build/components/global-styles/utils.js +340 -0
  81. package/build/components/global-styles/utils.js.map +1 -0
  82. package/build/components/height-control/index.js +13 -1
  83. package/build/components/height-control/index.js.map +1 -1
  84. package/build/components/iframe/index.js +37 -8
  85. package/build/components/iframe/index.js.map +1 -1
  86. package/build/components/iframe/use-compatibility-styles.js +6 -1
  87. package/build/components/iframe/use-compatibility-styles.js.map +1 -1
  88. package/build/components/image-editor/constants.js +1 -1
  89. package/build/components/image-editor/constants.js.map +1 -1
  90. package/build/components/image-editor/context.js +1 -2
  91. package/build/components/image-editor/context.js.map +1 -1
  92. package/build/components/image-editor/cropper.js +3 -1
  93. package/build/components/image-editor/cropper.js.map +1 -1
  94. package/build/components/image-editor/index.js +13 -9
  95. package/build/components/image-editor/index.js.map +1 -1
  96. package/build/components/image-editor/use-transform-image.js +11 -35
  97. package/build/components/image-editor/use-transform-image.js.map +1 -1
  98. package/build/components/image-size-control/index.js +2 -7
  99. package/build/components/image-size-control/index.js.map +1 -1
  100. package/build/components/index.js +8 -24
  101. package/build/components/index.js.map +1 -1
  102. package/build/components/inner-blocks/index.js +22 -32
  103. package/build/components/inner-blocks/index.js.map +1 -1
  104. package/build/components/inner-blocks/index.native.js +8 -23
  105. package/build/components/inner-blocks/index.native.js.map +1 -1
  106. package/build/components/inner-blocks/use-block-context.js +53 -0
  107. package/build/components/inner-blocks/use-block-context.js.map +1 -0
  108. package/build/components/inserter/block-patterns-explorer/explorer.js +0 -1
  109. package/build/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
  110. package/build/components/inserter/block-patterns-tab.js +11 -5
  111. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  112. package/build/components/inserter/block-types-tab.js +2 -2
  113. package/build/components/inserter/block-types-tab.js.map +1 -1
  114. package/build/components/inserter/hooks/use-patterns-state.js +1 -7
  115. package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
  116. package/build/components/inserter/index.js +8 -6
  117. package/build/components/inserter/index.js.map +1 -1
  118. package/build/components/inserter/media-tab/hooks.js +142 -56
  119. package/build/components/inserter/media-tab/hooks.js.map +1 -1
  120. package/build/components/inserter/media-tab/media-list.js +74 -21
  121. package/build/components/inserter/media-tab/media-list.js.map +1 -1
  122. package/build/components/inserter/media-tab/media-panel.js +11 -13
  123. package/build/components/inserter/media-tab/media-panel.js.map +1 -1
  124. package/build/components/inserter/media-tab/media-tab.js +6 -3
  125. package/build/components/inserter/media-tab/media-tab.js.map +1 -1
  126. package/build/components/inserter/media-tab/utils.js +26 -15
  127. package/build/components/inserter/media-tab/utils.js.map +1 -1
  128. package/build/components/inserter/menu.js +12 -5
  129. package/build/components/inserter/menu.js.map +1 -1
  130. package/build/components/inserter/preview-panel.js +5 -3
  131. package/build/components/inserter/preview-panel.js.map +1 -1
  132. package/build/components/inserter/search-results.js +2 -7
  133. package/build/components/inserter/search-results.js.map +1 -1
  134. package/build/components/inserter-list-item/index.js +1 -9
  135. package/build/components/inserter-list-item/index.js.map +1 -1
  136. package/build/components/inspector-controls/fill.js +15 -2
  137. package/build/components/inspector-controls/fill.js.map +1 -1
  138. package/build/components/inspector-controls/fill.native.js +14 -1
  139. package/build/components/inspector-controls/fill.native.js.map +1 -1
  140. package/build/components/inspector-controls/groups.js +7 -1
  141. package/build/components/inspector-controls/groups.js.map +1 -1
  142. package/build/components/inspector-controls/index.js +2 -2
  143. package/build/components/inspector-controls/index.js.map +1 -1
  144. package/build/components/inspector-controls/slot.js +14 -1
  145. package/build/components/inspector-controls/slot.js.map +1 -1
  146. package/build/components/inspector-controls/slot.native.js +14 -1
  147. package/build/components/inspector-controls/slot.native.js.map +1 -1
  148. package/build/components/inspector-controls-tabs/advanced-controls-panel.js +1 -1
  149. package/build/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -1
  150. package/build/components/inspector-controls-tabs/index.js +2 -2
  151. package/build/components/inspector-controls-tabs/index.js.map +1 -1
  152. package/build/components/inspector-controls-tabs/position-controls-panel.js +46 -0
  153. package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -0
  154. package/build/components/inspector-controls-tabs/settings-tab.js +3 -1
  155. package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -1
  156. package/build/components/inspector-controls-tabs/styles-tab.js +6 -4
  157. package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  158. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +20 -22
  159. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  160. package/build/components/justify-content-control/ui.js +8 -1
  161. package/build/components/justify-content-control/ui.js.map +1 -1
  162. package/build/components/link-control/index.js +45 -17
  163. package/build/components/link-control/index.js.map +1 -1
  164. package/build/components/link-control/search-input.js +1 -0
  165. package/build/components/link-control/search-input.js.map +1 -1
  166. package/build/components/list-view/block.js +1 -1
  167. package/build/components/list-view/block.js.map +1 -1
  168. package/build/components/list-view/use-list-view-drop-zone.js +1 -1
  169. package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
  170. package/build/components/media-upload/index.native.js +4 -1
  171. package/build/components/media-upload/index.native.js.map +1 -1
  172. package/build/components/off-canvas-editor/appender.js +49 -38
  173. package/build/components/off-canvas-editor/appender.js.map +1 -1
  174. package/build/components/off-canvas-editor/block-contents.js +38 -5
  175. package/build/components/off-canvas-editor/block-contents.js.map +1 -1
  176. package/build/components/off-canvas-editor/block-select-button.js +10 -4
  177. package/build/components/off-canvas-editor/block-select-button.js.map +1 -1
  178. package/build/components/off-canvas-editor/block.js +13 -52
  179. package/build/components/off-canvas-editor/block.js.map +1 -1
  180. package/build/components/off-canvas-editor/branch.js +25 -10
  181. package/build/components/off-canvas-editor/branch.js.map +1 -1
  182. package/build/components/off-canvas-editor/index.js +15 -17
  183. package/build/components/off-canvas-editor/index.js.map +1 -1
  184. package/build/components/off-canvas-editor/link-ui.js +2 -2
  185. package/build/components/off-canvas-editor/link-ui.js.map +1 -1
  186. package/build/components/off-canvas-editor/use-list-view-drop-zone.js +1 -1
  187. package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -1
  188. package/build/components/provider/index.js +22 -8
  189. package/build/components/provider/index.js.map +1 -1
  190. package/build/components/provider/index.native.js +5 -6
  191. package/build/components/provider/index.native.js.map +1 -1
  192. package/build/components/rich-text/use-before-input-rules.js +11 -3
  193. package/build/components/rich-text/use-before-input-rules.js.map +1 -1
  194. package/build/components/rich-text/use-enter.js +4 -5
  195. package/build/components/rich-text/use-enter.js.map +1 -1
  196. package/build/components/rich-text/utils.js +1 -1
  197. package/build/components/rich-text/utils.js.map +1 -1
  198. package/build/components/spacing-sizes-control/utils.js +2 -8
  199. package/build/components/spacing-sizes-control/utils.js.map +1 -1
  200. package/build/components/tool-selector/index.js +3 -1
  201. package/build/components/tool-selector/index.js.map +1 -1
  202. package/build/components/url-input/button.js +1 -0
  203. package/build/components/url-input/button.js.map +1 -1
  204. package/build/components/url-input/index.js +15 -1
  205. package/build/components/url-input/index.js.map +1 -1
  206. package/build/components/url-popover/image-url-input-ui.js +7 -8
  207. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  208. package/build/components/url-popover/link-editor.js +1 -0
  209. package/build/components/url-popover/link-editor.js.map +1 -1
  210. package/build/components/use-block-display-information/index.js +1 -1
  211. package/build/components/use-block-display-information/index.js.map +1 -1
  212. package/build/components/use-paste-styles/index.js +188 -0
  213. package/build/components/use-paste-styles/index.js.map +1 -0
  214. package/build/components/writing-flow/use-arrow-nav.js +22 -29
  215. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  216. package/build/experiments.js +45 -0
  217. package/build/experiments.js.map +1 -0
  218. package/build/experiments.native.js +40 -0
  219. package/build/experiments.native.js.map +1 -0
  220. package/build/hooks/anchor.js +2 -1
  221. package/build/hooks/anchor.js.map +1 -1
  222. package/build/hooks/border.js +1 -1
  223. package/build/hooks/border.js.map +1 -1
  224. package/build/hooks/child-layout.js +5 -1
  225. package/build/hooks/child-layout.js.map +1 -1
  226. package/build/hooks/color-panel.js +1 -1
  227. package/build/hooks/color-panel.js.map +1 -1
  228. package/build/hooks/color.js +3 -3
  229. package/build/hooks/color.js.map +1 -1
  230. package/build/hooks/custom-class-name.js +2 -1
  231. package/build/hooks/custom-class-name.js.map +1 -1
  232. package/build/hooks/dimensions.js +7 -5
  233. package/build/hooks/dimensions.js.map +1 -1
  234. package/build/hooks/index.js +2 -0
  235. package/build/hooks/index.js.map +1 -1
  236. package/build/hooks/margin.js +1 -0
  237. package/build/hooks/margin.js.map +1 -1
  238. package/build/hooks/metadata.js +1 -1
  239. package/build/hooks/metadata.js.map +1 -1
  240. package/build/hooks/padding.js +1 -0
  241. package/build/hooks/padding.js.map +1 -1
  242. package/build/hooks/position.js +395 -0
  243. package/build/hooks/position.js.map +1 -0
  244. package/build/hooks/supports.js +328 -0
  245. package/build/hooks/supports.js.map +1 -0
  246. package/build/hooks/typography.js +1 -1
  247. package/build/hooks/typography.js.map +1 -1
  248. package/build/hooks/use-color-props.js +3 -3
  249. package/build/hooks/use-color-props.js.map +1 -1
  250. package/build/hooks/utils.js +69 -3
  251. package/build/hooks/utils.js.map +1 -1
  252. package/build/index.js +10 -1
  253. package/build/index.js.map +1 -1
  254. package/build/layouts/constrained.js +3 -0
  255. package/build/layouts/constrained.js.map +1 -1
  256. package/build/layouts/flex.js +59 -9
  257. package/build/layouts/flex.js.map +1 -1
  258. package/build/layouts/flow.js +0 -18
  259. package/build/layouts/flow.js.map +1 -1
  260. package/build/store/actions.js +3 -30
  261. package/build/store/actions.js.map +1 -1
  262. package/build/store/defaults.js +5 -2
  263. package/build/store/defaults.js.map +1 -1
  264. package/build/store/index.js +11 -2
  265. package/build/store/index.js.map +1 -1
  266. package/build/store/private-actions.js +78 -0
  267. package/build/store/private-actions.js.map +1 -0
  268. package/build/store/private-selectors.js +18 -0
  269. package/build/store/private-selectors.js.map +1 -0
  270. package/build/store/reducer.js +7 -3
  271. package/build/store/reducer.js.map +1 -1
  272. package/build/store/selectors.js +68 -40
  273. package/build/store/selectors.js.map +1 -1
  274. package/build/utils/block-variation-transforms.js +1 -1
  275. package/build/utils/block-variation-transforms.js.map +1 -1
  276. package/build/utils/parse-css-unit-to-px.js +1 -1
  277. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  278. package/build/utils/transform-styles/index.js +1 -7
  279. package/build/utils/transform-styles/index.js.map +1 -1
  280. package/build-module/components/alignment-control/ui.js +1 -1
  281. package/build-module/components/alignment-control/ui.js.map +1 -1
  282. package/build-module/components/autocomplete/index.js +2 -6
  283. package/build-module/components/autocomplete/index.js.map +1 -1
  284. package/build-module/components/block-actions/index.js +6 -0
  285. package/build-module/components/block-actions/index.js.map +1 -1
  286. package/build-module/components/block-alignment-matrix-control/index.js +2 -2
  287. package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
  288. package/build-module/components/block-card/index.js +2 -4
  289. package/build-module/components/block-card/index.js.map +1 -1
  290. package/build-module/components/block-edit/index.js +7 -0
  291. package/build-module/components/block-edit/index.js.map +1 -1
  292. package/build-module/components/block-inspector/index.js +17 -15
  293. package/build-module/components/block-inspector/index.js.map +1 -1
  294. package/build-module/components/block-list/use-in-between-inserter.js +5 -0
  295. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  296. package/build-module/components/block-lock/modal.js +0 -1
  297. package/build-module/components/block-lock/modal.js.map +1 -1
  298. package/build-module/components/block-mover/mover-description.js +2 -2
  299. package/build-module/components/block-mover/mover-description.js.map +1 -1
  300. package/build-module/components/block-navigation/dropdown.js +3 -1
  301. package/build-module/components/block-navigation/dropdown.js.map +1 -1
  302. package/build-module/components/block-pattern-setup/index.js +1 -1
  303. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  304. package/build-module/components/block-pattern-setup/use-patterns-setup.js +2 -2
  305. package/build-module/components/block-pattern-setup/use-patterns-setup.js.map +1 -1
  306. package/build-module/components/block-patterns-list/index.js +32 -3
  307. package/build-module/components/block-patterns-list/index.js.map +1 -1
  308. package/build-module/components/block-preview/auto.js +9 -14
  309. package/build-module/components/block-preview/auto.js.map +1 -1
  310. package/build-module/components/block-preview/index.js +31 -8
  311. package/build-module/components/block-preview/index.js.map +1 -1
  312. package/build-module/components/block-selection-clearer/index.js +1 -1
  313. package/build-module/components/block-selection-clearer/index.js.map +1 -1
  314. package/build-module/components/block-settings/container.native.js +6 -30
  315. package/build-module/components/block-settings/container.native.js.map +1 -1
  316. package/build-module/components/block-settings-menu/block-settings-dropdown.js +12 -3
  317. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  318. package/build-module/components/block-settings-menu-controls/index.js +2 -7
  319. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  320. package/build-module/components/block-styles/index.js +2 -1
  321. package/build-module/components/block-styles/index.js.map +1 -1
  322. package/build-module/components/block-switcher/utils.js +1 -1
  323. package/build-module/components/block-switcher/utils.js.map +1 -1
  324. package/build-module/components/block-tools/selected-block-popover.js +55 -48
  325. package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
  326. package/build-module/components/block-tools/use-block-toolbar-popover-props.js +42 -11
  327. package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  328. package/build-module/components/block-vertical-alignment-control/icons.js +12 -0
  329. package/build-module/components/block-vertical-alignment-control/icons.js.map +1 -1
  330. package/build-module/components/block-vertical-alignment-control/ui.js +10 -5
  331. package/build-module/components/block-vertical-alignment-control/ui.js.map +1 -1
  332. package/build-module/components/color-style-selector/index.js +3 -1
  333. package/build-module/components/color-style-selector/index.js.map +1 -1
  334. package/build-module/components/date-format-picker/index.js +4 -5
  335. package/build-module/components/date-format-picker/index.js.map +1 -1
  336. package/build-module/components/default-style-picker/index.js +1 -0
  337. package/build-module/components/default-style-picker/index.js.map +1 -1
  338. package/build-module/components/font-family/index.js +1 -6
  339. package/build-module/components/font-family/index.js.map +1 -1
  340. package/build-module/components/font-sizes/fluid-utils.js +1 -1
  341. package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
  342. package/build-module/components/font-sizes/utils.js +1 -1
  343. package/build-module/components/font-sizes/utils.js.map +1 -1
  344. package/build-module/components/font-sizes/with-font-sizes.js +5 -7
  345. package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
  346. package/build-module/components/global-styles/context.js +12 -0
  347. package/build-module/components/global-styles/context.js.map +1 -0
  348. package/build-module/components/global-styles/hooks.js +121 -0
  349. package/build-module/components/global-styles/hooks.js.map +1 -0
  350. package/build-module/components/global-styles/index.js +4 -0
  351. package/build-module/components/global-styles/index.js.map +1 -0
  352. package/build-module/components/global-styles/typography-utils.js +84 -0
  353. package/build-module/components/global-styles/typography-utils.js.map +1 -0
  354. package/build-module/components/global-styles/use-global-styles-output.js +930 -0
  355. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -0
  356. package/build-module/components/global-styles/utils.js +321 -0
  357. package/build-module/components/global-styles/utils.js.map +1 -0
  358. package/build-module/components/height-control/index.js +14 -1
  359. package/build-module/components/height-control/index.js.map +1 -1
  360. package/build-module/components/iframe/index.js +36 -9
  361. package/build-module/components/iframe/index.js.map +1 -1
  362. package/build-module/components/iframe/use-compatibility-styles.js +6 -1
  363. package/build-module/components/iframe/use-compatibility-styles.js.map +1 -1
  364. package/build-module/components/image-editor/constants.js +1 -1
  365. package/build-module/components/image-editor/constants.js.map +1 -1
  366. package/build-module/components/image-editor/context.js +1 -2
  367. package/build-module/components/image-editor/context.js.map +1 -1
  368. package/build-module/components/image-editor/cropper.js +3 -1
  369. package/build-module/components/image-editor/cropper.js.map +1 -1
  370. package/build-module/components/image-editor/index.js +13 -3
  371. package/build-module/components/image-editor/index.js.map +1 -1
  372. package/build-module/components/image-editor/use-transform-image.js +12 -37
  373. package/build-module/components/image-editor/use-transform-image.js.map +1 -1
  374. package/build-module/components/image-size-control/index.js +2 -6
  375. package/build-module/components/image-size-control/index.js.map +1 -1
  376. package/build-module/components/index.js +2 -3
  377. package/build-module/components/index.js.map +1 -1
  378. package/build-module/components/inner-blocks/index.js +21 -32
  379. package/build-module/components/inner-blocks/index.js.map +1 -1
  380. package/build-module/components/inner-blocks/index.native.js +9 -22
  381. package/build-module/components/inner-blocks/index.native.js.map +1 -1
  382. package/build-module/components/inner-blocks/use-block-context.js +43 -0
  383. package/build-module/components/inner-blocks/use-block-context.js.map +1 -0
  384. package/build-module/components/inserter/block-patterns-explorer/explorer.js +0 -1
  385. package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
  386. package/build-module/components/inserter/block-patterns-tab.js +11 -5
  387. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  388. package/build-module/components/inserter/block-types-tab.js +3 -3
  389. package/build-module/components/inserter/block-types-tab.js.map +1 -1
  390. package/build-module/components/inserter/hooks/use-patterns-state.js +1 -6
  391. package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
  392. package/build-module/components/inserter/index.js +8 -6
  393. package/build-module/components/inserter/index.js.map +1 -1
  394. package/build-module/components/inserter/media-tab/hooks.js +145 -56
  395. package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
  396. package/build-module/components/inserter/media-tab/media-list.js +74 -24
  397. package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
  398. package/build-module/components/inserter/media-tab/media-panel.js +14 -14
  399. package/build-module/components/inserter/media-tab/media-panel.js.map +1 -1
  400. package/build-module/components/inserter/media-tab/media-tab.js +7 -4
  401. package/build-module/components/inserter/media-tab/media-tab.js.map +1 -1
  402. package/build-module/components/inserter/media-tab/utils.js +27 -15
  403. package/build-module/components/inserter/media-tab/utils.js.map +1 -1
  404. package/build-module/components/inserter/menu.js +12 -5
  405. package/build-module/components/inserter/menu.js.map +1 -1
  406. package/build-module/components/inserter/preview-panel.js +5 -3
  407. package/build-module/components/inserter/preview-panel.js.map +1 -1
  408. package/build-module/components/inserter/search-results.js +2 -6
  409. package/build-module/components/inserter/search-results.js.map +1 -1
  410. package/build-module/components/inserter-list-item/index.js +1 -9
  411. package/build-module/components/inserter-list-item/index.js.map +1 -1
  412. package/build-module/components/inspector-controls/fill.js +14 -2
  413. package/build-module/components/inspector-controls/fill.js.map +1 -1
  414. package/build-module/components/inspector-controls/fill.native.js +13 -1
  415. package/build-module/components/inspector-controls/fill.native.js.map +1 -1
  416. package/build-module/components/inspector-controls/groups.js +7 -1
  417. package/build-module/components/inspector-controls/groups.js.map +1 -1
  418. package/build-module/components/inspector-controls/index.js +2 -2
  419. package/build-module/components/inspector-controls/index.js.map +1 -1
  420. package/build-module/components/inspector-controls/slot.js +13 -1
  421. package/build-module/components/inspector-controls/slot.js.map +1 -1
  422. package/build-module/components/inspector-controls/slot.native.js +13 -1
  423. package/build-module/components/inspector-controls/slot.native.js.map +1 -1
  424. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js +1 -1
  425. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -1
  426. package/build-module/components/inspector-controls-tabs/index.js +2 -2
  427. package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
  428. package/build-module/components/inspector-controls-tabs/position-controls-panel.js +33 -0
  429. package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -0
  430. package/build-module/components/inspector-controls-tabs/settings-tab.js +2 -1
  431. package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -1
  432. package/build-module/components/inspector-controls-tabs/styles-tab.js +6 -4
  433. package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  434. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +20 -22
  435. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  436. package/build-module/components/justify-content-control/ui.js +9 -2
  437. package/build-module/components/justify-content-control/ui.js.map +1 -1
  438. package/build-module/components/link-control/index.js +45 -16
  439. package/build-module/components/link-control/index.js.map +1 -1
  440. package/build-module/components/link-control/search-input.js +1 -0
  441. package/build-module/components/link-control/search-input.js.map +1 -1
  442. package/build-module/components/list-view/block.js +1 -1
  443. package/build-module/components/list-view/block.js.map +1 -1
  444. package/build-module/components/list-view/use-list-view-drop-zone.js +1 -1
  445. package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
  446. package/build-module/components/media-upload/index.native.js +4 -1
  447. package/build-module/components/media-upload/index.native.js.map +1 -1
  448. package/build-module/components/off-canvas-editor/appender.js +46 -36
  449. package/build-module/components/off-canvas-editor/appender.js.map +1 -1
  450. package/build-module/components/off-canvas-editor/block-contents.js +37 -7
  451. package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
  452. package/build-module/components/off-canvas-editor/block-select-button.js +9 -4
  453. package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -1
  454. package/build-module/components/off-canvas-editor/block.js +15 -52
  455. package/build-module/components/off-canvas-editor/block.js.map +1 -1
  456. package/build-module/components/off-canvas-editor/branch.js +23 -11
  457. package/build-module/components/off-canvas-editor/branch.js.map +1 -1
  458. package/build-module/components/off-canvas-editor/index.js +15 -16
  459. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  460. package/build-module/components/off-canvas-editor/link-ui.js +2 -2
  461. package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
  462. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +1 -1
  463. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -1
  464. package/build-module/components/provider/index.js +17 -8
  465. package/build-module/components/provider/index.js.map +1 -1
  466. package/build-module/components/provider/index.native.js +4 -4
  467. package/build-module/components/provider/index.native.js.map +1 -1
  468. package/build-module/components/rich-text/use-before-input-rules.js +10 -2
  469. package/build-module/components/rich-text/use-before-input-rules.js.map +1 -1
  470. package/build-module/components/rich-text/use-enter.js +4 -5
  471. package/build-module/components/rich-text/use-enter.js.map +1 -1
  472. package/build-module/components/rich-text/utils.js +1 -1
  473. package/build-module/components/rich-text/utils.js.map +1 -1
  474. package/build-module/components/spacing-sizes-control/utils.js +2 -7
  475. package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
  476. package/build-module/components/tool-selector/index.js +3 -1
  477. package/build-module/components/tool-selector/index.js.map +1 -1
  478. package/build-module/components/url-input/button.js +1 -0
  479. package/build-module/components/url-input/button.js.map +1 -1
  480. package/build-module/components/url-input/index.js +14 -1
  481. package/build-module/components/url-input/index.js.map +1 -1
  482. package/build-module/components/url-popover/image-url-input-ui.js +8 -8
  483. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  484. package/build-module/components/url-popover/link-editor.js +1 -0
  485. package/build-module/components/url-popover/link-editor.js.map +1 -1
  486. package/build-module/components/use-block-display-information/index.js +1 -1
  487. package/build-module/components/use-block-display-information/index.js.map +1 -1
  488. package/build-module/components/use-paste-styles/index.js +174 -0
  489. package/build-module/components/use-paste-styles/index.js.map +1 -0
  490. package/build-module/components/writing-flow/use-arrow-nav.js +22 -29
  491. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  492. package/build-module/experiments.js +25 -0
  493. package/build-module/experiments.js.map +1 -0
  494. package/build-module/experiments.native.js +23 -0
  495. package/build-module/experiments.native.js.map +1 -0
  496. package/build-module/hooks/anchor.js +2 -1
  497. package/build-module/hooks/anchor.js.map +1 -1
  498. package/build-module/hooks/border.js +1 -1
  499. package/build-module/hooks/border.js.map +1 -1
  500. package/build-module/hooks/child-layout.js +5 -1
  501. package/build-module/hooks/child-layout.js.map +1 -1
  502. package/build-module/hooks/color-panel.js +1 -1
  503. package/build-module/hooks/color-panel.js.map +1 -1
  504. package/build-module/hooks/color.js +3 -3
  505. package/build-module/hooks/color.js.map +1 -1
  506. package/build-module/hooks/custom-class-name.js +2 -1
  507. package/build-module/hooks/custom-class-name.js.map +1 -1
  508. package/build-module/hooks/dimensions.js +6 -5
  509. package/build-module/hooks/dimensions.js.map +1 -1
  510. package/build-module/hooks/index.js +1 -0
  511. package/build-module/hooks/index.js.map +1 -1
  512. package/build-module/hooks/margin.js +1 -0
  513. package/build-module/hooks/margin.js.map +1 -1
  514. package/build-module/hooks/metadata.js +1 -1
  515. package/build-module/hooks/metadata.js.map +1 -1
  516. package/build-module/hooks/padding.js +1 -0
  517. package/build-module/hooks/padding.js.map +1 -1
  518. package/build-module/hooks/position.js +354 -0
  519. package/build-module/hooks/position.js.map +1 -0
  520. package/build-module/hooks/supports.js +257 -0
  521. package/build-module/hooks/supports.js.map +1 -0
  522. package/build-module/hooks/typography.js +1 -1
  523. package/build-module/hooks/typography.js.map +1 -1
  524. package/build-module/hooks/use-color-props.js +3 -3
  525. package/build-module/hooks/use-color-props.js.map +1 -1
  526. package/build-module/hooks/utils.js +70 -4
  527. package/build-module/hooks/utils.js.map +1 -1
  528. package/build-module/index.js +1 -0
  529. package/build-module/index.js.map +1 -1
  530. package/build-module/layouts/constrained.js +3 -0
  531. package/build-module/layouts/constrained.js.map +1 -1
  532. package/build-module/layouts/flex.js +60 -10
  533. package/build-module/layouts/flex.js.map +1 -1
  534. package/build-module/layouts/flow.js +0 -18
  535. package/build-module/layouts/flow.js.map +1 -1
  536. package/build-module/store/actions.js +2 -26
  537. package/build-module/store/actions.js.map +1 -1
  538. package/build-module/store/defaults.js +5 -2
  539. package/build-module/store/defaults.js.map +1 -1
  540. package/build-module/store/index.js +8 -2
  541. package/build-module/store/index.js.map +1 -1
  542. package/build-module/store/private-actions.js +66 -0
  543. package/build-module/store/private-actions.js.map +1 -0
  544. package/build-module/store/private-selectors.js +11 -0
  545. package/build-module/store/private-selectors.js.map +1 -0
  546. package/build-module/store/reducer.js +7 -3
  547. package/build-module/store/reducer.js.map +1 -1
  548. package/build-module/store/selectors.js +55 -30
  549. package/build-module/store/selectors.js.map +1 -1
  550. package/build-module/utils/block-variation-transforms.js +1 -1
  551. package/build-module/utils/block-variation-transforms.js.map +1 -1
  552. package/build-module/utils/parse-css-unit-to-px.js +1 -1
  553. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  554. package/build-module/utils/transform-styles/index.js +1 -6
  555. package/build-module/utils/transform-styles/index.js.map +1 -1
  556. package/build-style/content-rtl.css +340 -3
  557. package/build-style/content.css +340 -3
  558. package/build-style/style-rtl.css +125 -272
  559. package/build-style/style.css +125 -272
  560. package/package.json +30 -29
  561. package/src/components/alignment-control/test/__snapshots__/index.js.snap +3 -3
  562. package/src/components/alignment-control/test/index.js +5 -15
  563. package/src/components/alignment-control/ui.js +1 -1
  564. package/src/components/autocomplete/index.js +3 -6
  565. package/src/components/block-actions/index.js +5 -0
  566. package/src/components/block-alignment-control/test/index.js +3 -11
  567. package/src/components/block-alignment-matrix-control/index.js +1 -2
  568. package/src/components/block-card/index.js +1 -4
  569. package/src/components/block-content-overlay/content.scss +4 -4
  570. package/src/components/block-edit/index.js +15 -1
  571. package/src/components/block-icon/content.scss +31 -0
  572. package/src/components/block-inspector/index.js +15 -17
  573. package/src/components/block-list/use-in-between-inserter.js +5 -0
  574. package/src/components/block-lock/modal.js +0 -1
  575. package/src/components/block-mover/mover-description.js +2 -2
  576. package/src/components/block-mover/stories/index.js +3 -3
  577. package/src/components/block-navigation/dropdown.js +1 -1
  578. package/src/components/block-pattern-setup/index.js +1 -4
  579. package/src/components/block-pattern-setup/use-patterns-setup.js +2 -5
  580. package/src/components/block-patterns-list/index.js +29 -3
  581. package/src/components/block-preview/README.md +9 -9
  582. package/src/components/block-preview/auto.js +10 -14
  583. package/src/components/block-preview/content.scss +23 -0
  584. package/src/components/block-preview/index.js +40 -10
  585. package/src/components/block-preview/style.scss +0 -23
  586. package/src/components/block-selection-clearer/index.js +1 -1
  587. package/src/components/block-selection-clearer/test/index.js +6 -6
  588. package/src/components/block-settings/container.native.js +7 -26
  589. package/src/components/block-settings-menu/block-settings-dropdown.js +14 -2
  590. package/src/components/block-settings-menu-controls/index.js +2 -10
  591. package/src/components/block-styles/index.js +4 -1
  592. package/src/components/block-switcher/test/index.js +43 -44
  593. package/src/components/block-switcher/utils.js +1 -1
  594. package/src/components/block-tools/selected-block-popover.js +77 -80
  595. package/src/components/block-tools/style.scss +0 -1
  596. package/src/components/block-tools/use-block-toolbar-popover-props.js +68 -12
  597. package/src/components/block-variation-picker/{style.scss → content.scss} +0 -0
  598. package/src/components/block-vertical-alignment-control/icons.js +12 -0
  599. package/src/components/block-vertical-alignment-control/test/index.js +3 -11
  600. package/src/components/block-vertical-alignment-control/ui.js +16 -6
  601. package/src/components/button-block-appender/{style.scss → content.scss} +0 -0
  602. package/src/components/color-style-selector/index.js +1 -1
  603. package/src/components/colors/test/with-colors.js +2 -8
  604. package/src/components/date-format-picker/index.js +23 -24
  605. package/src/components/date-format-picker/style.scss +0 -6
  606. package/src/components/default-block-appender/content.scss +18 -0
  607. package/src/components/default-block-appender/test/index.js +2 -8
  608. package/src/components/default-style-picker/index.js +1 -0
  609. package/src/components/font-family/index.js +1 -6
  610. package/src/components/font-sizes/fluid-utils.js +1 -1
  611. package/src/components/font-sizes/utils.js +1 -1
  612. package/src/components/font-sizes/with-font-sizes.js +33 -33
  613. package/src/components/global-styles/README.md +77 -0
  614. package/src/components/global-styles/context.js +15 -0
  615. package/src/components/global-styles/hooks.js +145 -0
  616. package/src/components/global-styles/index.js +7 -0
  617. package/src/components/global-styles/test/typography-utils.js +393 -0
  618. package/src/components/global-styles/test/use-global-styles-output.js +814 -0
  619. package/src/components/global-styles/test/utils.js +206 -0
  620. package/src/components/global-styles/typography-utils.js +87 -0
  621. package/src/components/global-styles/use-global-styles-output.js +1088 -0
  622. package/src/components/global-styles/utils.js +373 -0
  623. package/src/components/height-control/README.md +55 -0
  624. package/src/components/height-control/index.js +13 -1
  625. package/src/components/iframe/index.js +52 -19
  626. package/src/components/iframe/use-compatibility-styles.js +6 -0
  627. package/src/components/image-editor/constants.js +1 -1
  628. package/src/components/image-editor/context.js +5 -9
  629. package/src/components/image-editor/cropper.js +3 -1
  630. package/src/components/image-editor/index.js +13 -4
  631. package/src/components/image-editor/use-transform-image.js +14 -55
  632. package/src/components/image-size-control/index.js +2 -6
  633. package/src/components/index.js +2 -6
  634. package/src/components/inner-blocks/index.js +29 -33
  635. package/src/components/inner-blocks/index.native.js +27 -47
  636. package/src/components/inner-blocks/use-block-context.js +47 -0
  637. package/src/components/inserter/block-patterns-explorer/explorer.js +0 -1
  638. package/src/components/inserter/block-patterns-tab.js +14 -4
  639. package/src/components/inserter/block-types-tab.js +3 -4
  640. package/src/components/inserter/hooks/use-patterns-state.js +1 -6
  641. package/src/components/inserter/index.js +46 -42
  642. package/src/components/inserter/media-tab/hooks.js +167 -65
  643. package/src/components/inserter/media-tab/media-list.js +94 -26
  644. package/src/components/inserter/media-tab/media-panel.js +9 -20
  645. package/src/components/inserter/media-tab/media-tab.js +12 -4
  646. package/src/components/inserter/media-tab/utils.js +20 -10
  647. package/src/components/inserter/menu.js +9 -4
  648. package/src/components/inserter/preview-panel.js +4 -2
  649. package/src/components/inserter/search-results.js +2 -6
  650. package/src/components/inserter/stories/index.js +9 -9
  651. package/src/components/inserter/style.scss +58 -11
  652. package/src/components/inserter/test/__snapshots__/index.native.js.snap +117 -0
  653. package/src/components/inserter/test/index.native.js +255 -1
  654. package/src/components/inserter-list-item/index.js +0 -7
  655. package/src/components/inspector-controls/README.md +3 -7
  656. package/src/components/inspector-controls/fill.js +15 -1
  657. package/src/components/inspector-controls/fill.native.js +14 -1
  658. package/src/components/inspector-controls/groups.js +5 -0
  659. package/src/components/inspector-controls/index.js +2 -6
  660. package/src/components/inspector-controls/slot.js +14 -1
  661. package/src/components/inspector-controls/slot.native.js +14 -1
  662. package/src/components/inspector-controls-tabs/advanced-controls-panel.js +1 -1
  663. package/src/components/inspector-controls-tabs/index.js +2 -4
  664. package/src/components/inspector-controls-tabs/position-controls-panel.js +37 -0
  665. package/src/components/inspector-controls-tabs/settings-tab.js +2 -0
  666. package/src/components/inspector-controls-tabs/style.scss +15 -0
  667. package/src/components/inspector-controls-tabs/styles-tab.js +5 -7
  668. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +24 -18
  669. package/src/components/justify-content-control/ui.js +9 -0
  670. package/src/components/link-control/index.js +59 -23
  671. package/src/components/link-control/search-input.js +1 -0
  672. package/src/components/link-control/style.scss +8 -24
  673. package/src/components/link-control/test/index.js +134 -5
  674. package/src/components/list-view/block.js +1 -1
  675. package/src/components/list-view/style.scss +13 -3
  676. package/src/components/list-view/use-list-view-drop-zone.js +1 -1
  677. package/src/components/media-replace-flow/test/index.js +4 -12
  678. package/src/components/media-upload/index.native.js +2 -2
  679. package/src/components/off-canvas-editor/README.md +2 -2
  680. package/src/components/off-canvas-editor/appender.js +82 -76
  681. package/src/components/off-canvas-editor/block-contents.js +84 -23
  682. package/src/components/off-canvas-editor/block-select-button.js +12 -1
  683. package/src/components/off-canvas-editor/block.js +31 -102
  684. package/src/components/off-canvas-editor/branch.js +32 -5
  685. package/src/components/off-canvas-editor/index.js +19 -24
  686. package/src/components/off-canvas-editor/link-ui.js +2 -2
  687. package/src/components/off-canvas-editor/style.scss +5 -1
  688. package/src/components/off-canvas-editor/use-list-view-drop-zone.js +1 -1
  689. package/src/components/provider/index.js +33 -11
  690. package/src/components/provider/index.native.js +4 -3
  691. package/src/components/provider/test/experimental-provider.js +94 -0
  692. package/src/components/provider/test/use-block-sync.js +10 -0
  693. package/src/components/responsive-block-control/test/index.js +1 -5
  694. package/src/components/rich-text/use-before-input-rules.js +10 -2
  695. package/src/components/rich-text/use-enter.js +4 -4
  696. package/src/components/rich-text/utils.js +1 -1
  697. package/src/components/spacing-sizes-control/utils.js +2 -7
  698. package/src/components/tool-selector/index.js +1 -1
  699. package/src/components/url-input/README.md +5 -0
  700. package/src/components/url-input/button.js +1 -0
  701. package/src/components/url-input/index.js +15 -1
  702. package/src/components/url-input/test/button.js +24 -24
  703. package/src/components/url-popover/image-url-input-ui.js +7 -8
  704. package/src/components/url-popover/link-editor.js +1 -0
  705. package/src/components/url-popover/style.scss +0 -10
  706. package/src/components/use-block-display-information/index.js +1 -1
  707. package/src/components/use-paste-styles/index.js +230 -0
  708. package/src/components/warning/{style.scss → content.scss} +0 -0
  709. package/src/components/warning/test/index.js +1 -5
  710. package/src/components/writing-flow/use-arrow-nav.js +20 -28
  711. package/src/content.scss +8 -0
  712. package/src/experiments.js +27 -0
  713. package/src/experiments.native.js +25 -0
  714. package/src/hooks/anchor.js +2 -1
  715. package/src/hooks/border.js +1 -1
  716. package/src/hooks/child-layout.js +6 -1
  717. package/src/hooks/color-panel.js +1 -1
  718. package/src/hooks/color.js +3 -3
  719. package/src/hooks/custom-class-name.js +2 -1
  720. package/src/hooks/dimensions.js +6 -6
  721. package/src/hooks/index.js +1 -0
  722. package/src/hooks/layout.scss +4 -0
  723. package/src/hooks/margin.js +1 -0
  724. package/src/hooks/metadata.js +1 -2
  725. package/src/hooks/padding.js +1 -0
  726. package/src/hooks/position.js +391 -0
  727. package/src/hooks/position.scss +18 -0
  728. package/src/hooks/supports.js +302 -0
  729. package/src/hooks/test/__snapshots__/align.native.js.snap +73 -0
  730. package/src/hooks/test/align.native.js +133 -0
  731. package/src/hooks/test/utils.js +104 -0
  732. package/src/hooks/typography.js +1 -1
  733. package/src/hooks/use-color-props.js +3 -3
  734. package/src/hooks/utils.js +68 -2
  735. package/src/index.js +1 -0
  736. package/src/layouts/constrained.js +3 -0
  737. package/src/layouts/flex.js +66 -14
  738. package/src/layouts/flow.js +0 -9
  739. package/src/store/actions.js +2 -26
  740. package/src/store/defaults.js +7 -2
  741. package/src/store/index.js +8 -2
  742. package/src/store/private-actions.js +65 -0
  743. package/src/store/private-selectors.js +10 -0
  744. package/src/store/reducer.js +8 -3
  745. package/src/store/selectors.js +108 -57
  746. package/src/store/test/actions.js +0 -18
  747. package/src/store/test/private-actions.js +22 -0
  748. package/src/store/test/private-selectors.js +24 -0
  749. package/src/store/test/reducer.js +45 -3
  750. package/src/store/test/selectors.js +64 -39
  751. package/src/style.scss +5 -6
  752. package/src/utils/block-variation-transforms.js +1 -1
  753. package/src/utils/parse-css-unit-to-px.js +3 -1
  754. package/src/utils/test/parse-css-unit-to-px.js +16 -24
  755. package/src/utils/transform-styles/index.js +1 -6
  756. package/build/components/inner-blocks/get-block-context.js +0 -45
  757. package/build/components/inner-blocks/get-block-context.js.map +0 -1
  758. package/build/components/off-canvas-editor/block-edit-button.js +0 -50
  759. package/build/components/off-canvas-editor/block-edit-button.js.map +0 -1
  760. package/build-module/components/inner-blocks/get-block-context.js +0 -37
  761. package/build-module/components/inner-blocks/get-block-context.js.map +0 -1
  762. package/build-module/components/off-canvas-editor/block-edit-button.js +0 -35
  763. package/build-module/components/off-canvas-editor/block-edit-button.js.map +0 -1
  764. package/src/components/inner-blocks/get-block-context.js +0 -39
  765. package/src/components/off-canvas-editor/block-edit-button.js +0 -27
@@ -0,0 +1,1088 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { get, isEmpty, kebabCase, set } from 'lodash';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import {
10
+ __EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY,
11
+ __EXPERIMENTAL_ELEMENTS as ELEMENTS,
12
+ getBlockTypes,
13
+ store as blocksStore,
14
+ } from '@wordpress/blocks';
15
+ import { useSelect } from '@wordpress/data';
16
+ import { useContext, useMemo } from '@wordpress/element';
17
+ import { getCSSRules } from '@wordpress/style-engine';
18
+
19
+ /**
20
+ * Internal dependencies
21
+ */
22
+ import { PRESET_METADATA, ROOT_BLOCK_SELECTOR, scopeSelector } from './utils';
23
+ import { getTypographyFontSizeValue } from './typography-utils';
24
+ import { GlobalStylesContext } from './context';
25
+ import { useGlobalSetting } from './hooks';
26
+ import { PresetDuotoneFilter } from '../duotone/components';
27
+ import { getGapCSSValue } from '../../hooks/gap';
28
+ import { store as blockEditorStore } from '../../store';
29
+
30
+ // List of block support features that can have their related styles
31
+ // generated under their own feature level selector rather than the block's.
32
+ const BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = {
33
+ __experimentalBorder: 'border',
34
+ color: 'color',
35
+ spacing: 'spacing',
36
+ typography: 'typography',
37
+ };
38
+
39
+ function compileStyleValue( uncompiledValue ) {
40
+ const VARIABLE_REFERENCE_PREFIX = 'var:';
41
+ const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';
42
+ const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';
43
+
44
+ if ( uncompiledValue?.startsWith?.( VARIABLE_REFERENCE_PREFIX ) ) {
45
+ const variable = uncompiledValue
46
+ .slice( VARIABLE_REFERENCE_PREFIX.length )
47
+ .split( VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE )
48
+ .join( VARIABLE_PATH_SEPARATOR_TOKEN_STYLE );
49
+ return `var(--wp--${ variable })`;
50
+ }
51
+ return uncompiledValue;
52
+ }
53
+
54
+ /**
55
+ * Transform given preset tree into a set of style declarations.
56
+ *
57
+ * @param {Object} blockPresets
58
+ * @param {Object} mergedSettings Merged theme.json settings.
59
+ *
60
+ * @return {Array<Object>} An array of style declarations.
61
+ */
62
+ function getPresetsDeclarations( blockPresets = {}, mergedSettings ) {
63
+ return PRESET_METADATA.reduce(
64
+ ( declarations, { path, valueKey, valueFunc, cssVarInfix } ) => {
65
+ const presetByOrigin = get( blockPresets, path, [] );
66
+ [ 'default', 'theme', 'custom' ].forEach( ( origin ) => {
67
+ if ( presetByOrigin[ origin ] ) {
68
+ presetByOrigin[ origin ].forEach( ( value ) => {
69
+ if ( valueKey && ! valueFunc ) {
70
+ declarations.push(
71
+ `--wp--preset--${ cssVarInfix }--${ kebabCase(
72
+ value.slug
73
+ ) }: ${ value[ valueKey ] }`
74
+ );
75
+ } else if (
76
+ valueFunc &&
77
+ typeof valueFunc === 'function'
78
+ ) {
79
+ declarations.push(
80
+ `--wp--preset--${ cssVarInfix }--${ kebabCase(
81
+ value.slug
82
+ ) }: ${ valueFunc( value, mergedSettings ) }`
83
+ );
84
+ }
85
+ } );
86
+ }
87
+ } );
88
+
89
+ return declarations;
90
+ },
91
+ []
92
+ );
93
+ }
94
+
95
+ /**
96
+ * Transform given preset tree into a set of preset class declarations.
97
+ *
98
+ * @param {string} blockSelector
99
+ * @param {Object} blockPresets
100
+ * @return {string} CSS declarations for the preset classes.
101
+ */
102
+ function getPresetsClasses( blockSelector, blockPresets = {} ) {
103
+ return PRESET_METADATA.reduce(
104
+ ( declarations, { path, cssVarInfix, classes } ) => {
105
+ if ( ! classes ) {
106
+ return declarations;
107
+ }
108
+
109
+ const presetByOrigin = get( blockPresets, path, [] );
110
+ [ 'default', 'theme', 'custom' ].forEach( ( origin ) => {
111
+ if ( presetByOrigin[ origin ] ) {
112
+ presetByOrigin[ origin ].forEach( ( { slug } ) => {
113
+ classes.forEach( ( { classSuffix, propertyName } ) => {
114
+ const classSelectorToUse = `.has-${ kebabCase(
115
+ slug
116
+ ) }-${ classSuffix }`;
117
+ const selectorToUse = blockSelector
118
+ .split( ',' ) // Selector can be "h1, h2, h3"
119
+ .map(
120
+ ( selector ) =>
121
+ `${ selector }${ classSelectorToUse }`
122
+ )
123
+ .join( ',' );
124
+ const value = `var(--wp--preset--${ cssVarInfix }--${ kebabCase(
125
+ slug
126
+ ) })`;
127
+ declarations += `${ selectorToUse }{${ propertyName }: ${ value } !important;}`;
128
+ } );
129
+ } );
130
+ }
131
+ } );
132
+ return declarations;
133
+ },
134
+ ''
135
+ );
136
+ }
137
+
138
+ function getPresetsSvgFilters( blockPresets = {} ) {
139
+ return PRESET_METADATA.filter(
140
+ // Duotone are the only type of filters for now.
141
+ ( metadata ) => metadata.path.at( -1 ) === 'duotone'
142
+ ).flatMap( ( metadata ) => {
143
+ const presetByOrigin = get( blockPresets, metadata.path, {} );
144
+ return [ 'default', 'theme' ]
145
+ .filter( ( origin ) => presetByOrigin[ origin ] )
146
+ .flatMap( ( origin ) =>
147
+ presetByOrigin[ origin ].map( ( preset ) => (
148
+ <PresetDuotoneFilter
149
+ preset={ preset }
150
+ key={ preset.slug }
151
+ />
152
+ ) )
153
+ );
154
+ } );
155
+ }
156
+
157
+ function flattenTree( input = {}, prefix, token ) {
158
+ let result = [];
159
+ Object.keys( input ).forEach( ( key ) => {
160
+ const newKey = prefix + kebabCase( key.replace( '/', '-' ) );
161
+ const newLeaf = input[ key ];
162
+
163
+ if ( newLeaf instanceof Object ) {
164
+ const newPrefix = newKey + token;
165
+ result = [ ...result, ...flattenTree( newLeaf, newPrefix, token ) ];
166
+ } else {
167
+ result.push( `${ newKey }: ${ newLeaf }` );
168
+ }
169
+ } );
170
+ return result;
171
+ }
172
+
173
+ /**
174
+ * Gets variation selector string from feature selector.
175
+ *
176
+ * @param {string} featureSelector The feature selector.
177
+ *
178
+ * @param {string} styleVariationSelector The style variation selector.
179
+ * @return {string} Combined selector string.
180
+ *
181
+ */
182
+ function concatFeatureVariationSelectorString(
183
+ featureSelector,
184
+ styleVariationSelector
185
+ ) {
186
+ const featureSelectors = featureSelector.split( ',' );
187
+ const combinedSelectors = [];
188
+ featureSelectors.forEach( ( selector ) => {
189
+ combinedSelectors.push(
190
+ `${ styleVariationSelector.trim() }${ selector.trim() }`
191
+ );
192
+ } );
193
+ return combinedSelectors.join( ', ' );
194
+ }
195
+
196
+ /**
197
+ * Transform given style tree into a set of style declarations.
198
+ *
199
+ * @param {Object} blockStyles Block styles.
200
+ *
201
+ * @param {string} selector The selector these declarations should attach to.
202
+ *
203
+ * @param {boolean} useRootPaddingAlign Whether to use CSS custom properties in root selector.
204
+ *
205
+ * @param {Object} tree A theme.json tree containing layout definitions.
206
+ *
207
+ * @return {Array} An array of style declarations.
208
+ */
209
+ export function getStylesDeclarations(
210
+ blockStyles = {},
211
+ selector = '',
212
+ useRootPaddingAlign,
213
+ tree = {}
214
+ ) {
215
+ const isRoot = ROOT_BLOCK_SELECTOR === selector;
216
+ const output = Object.entries( STYLE_PROPERTY ).reduce(
217
+ (
218
+ declarations,
219
+ [ key, { value, properties, useEngine, rootOnly } ]
220
+ ) => {
221
+ if ( rootOnly && ! isRoot ) {
222
+ return declarations;
223
+ }
224
+ const pathToValue = value;
225
+ if ( pathToValue[ 0 ] === 'elements' || useEngine ) {
226
+ return declarations;
227
+ }
228
+
229
+ const styleValue = get( blockStyles, pathToValue );
230
+
231
+ // Root-level padding styles don't currently support strings with CSS shorthand values.
232
+ // This may change: https://github.com/WordPress/gutenberg/issues/40132.
233
+ if (
234
+ key === '--wp--style--root--padding' &&
235
+ ( typeof styleValue === 'string' || ! useRootPaddingAlign )
236
+ ) {
237
+ return declarations;
238
+ }
239
+
240
+ if ( !! properties && typeof styleValue !== 'string' ) {
241
+ Object.entries( properties ).forEach( ( entry ) => {
242
+ const [ name, prop ] = entry;
243
+
244
+ if ( ! get( styleValue, [ prop ], false ) ) {
245
+ // Do not create a declaration
246
+ // for sub-properties that don't have any value.
247
+ return;
248
+ }
249
+
250
+ const cssProperty = name.startsWith( '--' )
251
+ ? name
252
+ : kebabCase( name );
253
+ declarations.push(
254
+ `${ cssProperty }: ${ compileStyleValue(
255
+ get( styleValue, [ prop ] )
256
+ ) }`
257
+ );
258
+ } );
259
+ } else if ( get( blockStyles, pathToValue, false ) ) {
260
+ const cssProperty = key.startsWith( '--' )
261
+ ? key
262
+ : kebabCase( key );
263
+ declarations.push(
264
+ `${ cssProperty }: ${ compileStyleValue(
265
+ get( blockStyles, pathToValue )
266
+ ) }`
267
+ );
268
+ }
269
+
270
+ return declarations;
271
+ },
272
+ []
273
+ );
274
+
275
+ // The goal is to move everything to server side generated engine styles
276
+ // This is temporary as we absorb more and more styles into the engine.
277
+ const extraRules = getCSSRules( blockStyles );
278
+ extraRules.forEach( ( rule ) => {
279
+ // Don't output padding properties if padding variables are set.
280
+ if (
281
+ isRoot &&
282
+ useRootPaddingAlign &&
283
+ rule.key.startsWith( 'padding' )
284
+ ) {
285
+ return;
286
+ }
287
+ const cssProperty = rule.key.startsWith( '--' )
288
+ ? rule.key
289
+ : kebabCase( rule.key );
290
+
291
+ let ruleValue = rule.value;
292
+ if ( typeof ruleValue !== 'string' && ruleValue?.ref ) {
293
+ const refPath = ruleValue.ref.split( '.' );
294
+ ruleValue = get( tree, refPath );
295
+ // Presence of another ref indicates a reference to another dynamic value.
296
+ // Pointing to another dynamic value is not supported.
297
+ if ( ! ruleValue || !! ruleValue?.ref ) {
298
+ return;
299
+ }
300
+ }
301
+
302
+ // Calculate fluid typography rules where available.
303
+ if ( cssProperty === 'font-size' ) {
304
+ /*
305
+ * getTypographyFontSizeValue() will check
306
+ * if fluid typography has been activated and also
307
+ * whether the incoming value can be converted to a fluid value.
308
+ * Values that already have a "clamp()" function will not pass the test,
309
+ * and therefore the original $value will be returned.
310
+ */
311
+ ruleValue = getTypographyFontSizeValue(
312
+ { size: ruleValue },
313
+ tree?.settings?.typography
314
+ );
315
+ }
316
+
317
+ output.push( `${ cssProperty }: ${ ruleValue }` );
318
+ } );
319
+
320
+ return output;
321
+ }
322
+
323
+ /**
324
+ * Get generated CSS for layout styles by looking up layout definitions provided
325
+ * in theme.json, and outputting common layout styles, and specific blockGap values.
326
+ *
327
+ * @param {Object} props
328
+ * @param {Object} props.tree A theme.json tree containing layout definitions.
329
+ * @param {Object} props.style A style object containing spacing values.
330
+ * @param {string} props.selector Selector used to group together layout styling rules.
331
+ * @param {boolean} props.hasBlockGapSupport Whether or not the theme opts-in to blockGap support.
332
+ * @param {boolean} props.hasFallbackGapSupport Whether or not the theme allows fallback gap styles.
333
+ * @param {?string} props.fallbackGapValue An optional fallback gap value if no real gap value is available.
334
+ * @return {string} Generated CSS rules for the layout styles.
335
+ */
336
+ export function getLayoutStyles( {
337
+ tree,
338
+ style,
339
+ selector,
340
+ hasBlockGapSupport,
341
+ hasFallbackGapSupport,
342
+ fallbackGapValue,
343
+ } ) {
344
+ let ruleset = '';
345
+ let gapValue = hasBlockGapSupport
346
+ ? getGapCSSValue( style?.spacing?.blockGap )
347
+ : '';
348
+
349
+ // Ensure a fallback gap value for the root layout definitions,
350
+ // and use a fallback value if one is provided for the current block.
351
+ if ( hasFallbackGapSupport ) {
352
+ if ( selector === ROOT_BLOCK_SELECTOR ) {
353
+ gapValue = ! gapValue ? '0.5em' : gapValue;
354
+ } else if ( ! hasBlockGapSupport && fallbackGapValue ) {
355
+ gapValue = fallbackGapValue;
356
+ }
357
+ }
358
+
359
+ if ( gapValue && tree?.settings?.layout?.definitions ) {
360
+ Object.values( tree.settings.layout.definitions ).forEach(
361
+ ( { className, name, spacingStyles } ) => {
362
+ // Allow outputting fallback gap styles for flex layout type when block gap support isn't available.
363
+ if ( ! hasBlockGapSupport && 'flex' !== name ) {
364
+ return;
365
+ }
366
+
367
+ if ( spacingStyles?.length ) {
368
+ spacingStyles.forEach( ( spacingStyle ) => {
369
+ const declarations = [];
370
+
371
+ if ( spacingStyle.rules ) {
372
+ Object.entries( spacingStyle.rules ).forEach(
373
+ ( [ cssProperty, cssValue ] ) => {
374
+ declarations.push(
375
+ `${ cssProperty }: ${
376
+ cssValue ? cssValue : gapValue
377
+ }`
378
+ );
379
+ }
380
+ );
381
+ }
382
+
383
+ if ( declarations.length ) {
384
+ let combinedSelector = '';
385
+
386
+ if ( ! hasBlockGapSupport ) {
387
+ // For fallback gap styles, use lower specificity, to ensure styles do not unintentionally override theme styles.
388
+ combinedSelector =
389
+ selector === ROOT_BLOCK_SELECTOR
390
+ ? `:where(.${ className }${
391
+ spacingStyle?.selector || ''
392
+ })`
393
+ : `:where(${ selector }.${ className }${
394
+ spacingStyle?.selector || ''
395
+ })`;
396
+ } else {
397
+ combinedSelector =
398
+ selector === ROOT_BLOCK_SELECTOR
399
+ ? `${ selector } .${ className }${
400
+ spacingStyle?.selector || ''
401
+ }`
402
+ : `${ selector }.${ className }${
403
+ spacingStyle?.selector || ''
404
+ }`;
405
+ }
406
+ ruleset += `${ combinedSelector } { ${ declarations.join(
407
+ '; '
408
+ ) }; }`;
409
+ }
410
+ } );
411
+ }
412
+ }
413
+ );
414
+ // For backwards compatibility, ensure the legacy block gap CSS variable is still available.
415
+ if ( selector === ROOT_BLOCK_SELECTOR && hasBlockGapSupport ) {
416
+ ruleset += `${ selector } { --wp--style--block-gap: ${ gapValue }; }`;
417
+ }
418
+ }
419
+
420
+ // Output base styles
421
+ if (
422
+ selector === ROOT_BLOCK_SELECTOR &&
423
+ tree?.settings?.layout?.definitions
424
+ ) {
425
+ const validDisplayModes = [ 'block', 'flex', 'grid' ];
426
+ Object.values( tree.settings.layout.definitions ).forEach(
427
+ ( { className, displayMode, baseStyles } ) => {
428
+ if (
429
+ displayMode &&
430
+ validDisplayModes.includes( displayMode )
431
+ ) {
432
+ ruleset += `${ selector } .${ className } { display:${ displayMode }; }`;
433
+ }
434
+
435
+ if ( baseStyles?.length ) {
436
+ baseStyles.forEach( ( baseStyle ) => {
437
+ const declarations = [];
438
+
439
+ if ( baseStyle.rules ) {
440
+ Object.entries( baseStyle.rules ).forEach(
441
+ ( [ cssProperty, cssValue ] ) => {
442
+ declarations.push(
443
+ `${ cssProperty }: ${ cssValue }`
444
+ );
445
+ }
446
+ );
447
+ }
448
+
449
+ if ( declarations.length ) {
450
+ const combinedSelector = `${ selector } .${ className }${
451
+ baseStyle?.selector || ''
452
+ }`;
453
+ ruleset += `${ combinedSelector } { ${ declarations.join(
454
+ '; '
455
+ ) }; }`;
456
+ }
457
+ } );
458
+ }
459
+ }
460
+ );
461
+ }
462
+
463
+ return ruleset;
464
+ }
465
+
466
+ export const getNodesWithStyles = ( tree, blockSelectors ) => {
467
+ const nodes = [];
468
+
469
+ if ( ! tree?.styles ) {
470
+ return nodes;
471
+ }
472
+
473
+ const pickStyleKeys = ( treeToPickFrom ) =>
474
+ Object.fromEntries(
475
+ Object.entries( treeToPickFrom ?? {} ).filter( ( [ key ] ) =>
476
+ [
477
+ 'border',
478
+ 'color',
479
+ 'dimensions',
480
+ 'spacing',
481
+ 'typography',
482
+ 'filter',
483
+ 'outline',
484
+ 'shadow',
485
+ ].includes( key )
486
+ )
487
+ );
488
+
489
+ // Top-level.
490
+ const styles = pickStyleKeys( tree.styles );
491
+ if ( !! styles ) {
492
+ nodes.push( {
493
+ styles,
494
+ selector: ROOT_BLOCK_SELECTOR,
495
+ } );
496
+ }
497
+
498
+ Object.entries( ELEMENTS ).forEach( ( [ name, selector ] ) => {
499
+ if ( !! tree.styles?.elements[ name ] ) {
500
+ nodes.push( {
501
+ styles: tree.styles?.elements[ name ],
502
+ selector,
503
+ } );
504
+ }
505
+ } );
506
+
507
+ // Iterate over blocks: they can have styles & elements.
508
+ Object.entries( tree.styles?.blocks ?? {} ).forEach(
509
+ ( [ blockName, node ] ) => {
510
+ const blockStyles = pickStyleKeys( node );
511
+
512
+ if ( node?.variations ) {
513
+ const variations = {};
514
+ Object.keys( node.variations ).forEach( ( variation ) => {
515
+ variations[ variation ] = pickStyleKeys(
516
+ node.variations[ variation ]
517
+ );
518
+ } );
519
+ blockStyles.variations = variations;
520
+ }
521
+ if (
522
+ !! blockStyles &&
523
+ !! blockSelectors?.[ blockName ]?.selector
524
+ ) {
525
+ nodes.push( {
526
+ duotoneSelector:
527
+ blockSelectors[ blockName ].duotoneSelector,
528
+ fallbackGapValue:
529
+ blockSelectors[ blockName ].fallbackGapValue,
530
+ hasLayoutSupport:
531
+ blockSelectors[ blockName ].hasLayoutSupport,
532
+ selector: blockSelectors[ blockName ].selector,
533
+ styles: blockStyles,
534
+ featureSelectors:
535
+ blockSelectors[ blockName ].featureSelectors,
536
+ styleVariationSelectors:
537
+ blockSelectors[ blockName ].styleVariationSelectors,
538
+ } );
539
+ }
540
+
541
+ Object.entries( node?.elements ?? {} ).forEach(
542
+ ( [ elementName, value ] ) => {
543
+ if (
544
+ !! value &&
545
+ !! blockSelectors?.[ blockName ] &&
546
+ !! ELEMENTS?.[ elementName ]
547
+ ) {
548
+ nodes.push( {
549
+ styles: value,
550
+ selector: blockSelectors[ blockName ].selector
551
+ .split( ',' )
552
+ .map( ( sel ) => {
553
+ const elementSelectors =
554
+ ELEMENTS[ elementName ].split( ',' );
555
+ return elementSelectors.map(
556
+ ( elementSelector ) =>
557
+ sel + ' ' + elementSelector
558
+ );
559
+ } )
560
+ .join( ',' ),
561
+ } );
562
+ }
563
+ }
564
+ );
565
+ }
566
+ );
567
+
568
+ return nodes;
569
+ };
570
+
571
+ export const getNodesWithSettings = ( tree, blockSelectors ) => {
572
+ const nodes = [];
573
+
574
+ if ( ! tree?.settings ) {
575
+ return nodes;
576
+ }
577
+
578
+ const pickPresets = ( treeToPickFrom ) => {
579
+ const presets = {};
580
+ PRESET_METADATA.forEach( ( { path } ) => {
581
+ const value = get( treeToPickFrom, path, false );
582
+ if ( value !== false ) {
583
+ set( presets, path, value );
584
+ }
585
+ } );
586
+ return presets;
587
+ };
588
+
589
+ // Top-level.
590
+ const presets = pickPresets( tree.settings );
591
+ const custom = tree.settings?.custom;
592
+ if ( ! isEmpty( presets ) || !! custom ) {
593
+ nodes.push( {
594
+ presets,
595
+ custom,
596
+ selector: ROOT_BLOCK_SELECTOR,
597
+ } );
598
+ }
599
+
600
+ // Blocks.
601
+ Object.entries( tree.settings?.blocks ?? {} ).forEach(
602
+ ( [ blockName, node ] ) => {
603
+ const blockPresets = pickPresets( node );
604
+ const blockCustom = node.custom;
605
+ if ( ! isEmpty( blockPresets ) || !! blockCustom ) {
606
+ nodes.push( {
607
+ presets: blockPresets,
608
+ custom: blockCustom,
609
+ selector: blockSelectors[ blockName ].selector,
610
+ } );
611
+ }
612
+ }
613
+ );
614
+
615
+ return nodes;
616
+ };
617
+
618
+ export const toCustomProperties = ( tree, blockSelectors ) => {
619
+ const settings = getNodesWithSettings( tree, blockSelectors );
620
+ let ruleset = '';
621
+ settings.forEach( ( { presets, custom, selector } ) => {
622
+ const declarations = getPresetsDeclarations( presets, tree?.settings );
623
+ const customProps = flattenTree( custom, '--wp--custom--', '--' );
624
+ if ( customProps.length > 0 ) {
625
+ declarations.push( ...customProps );
626
+ }
627
+
628
+ if ( declarations.length > 0 ) {
629
+ ruleset = ruleset + `${ selector }{${ declarations.join( ';' ) };}`;
630
+ }
631
+ } );
632
+
633
+ return ruleset;
634
+ };
635
+
636
+ export const toStyles = (
637
+ tree,
638
+ blockSelectors,
639
+ hasBlockGapSupport,
640
+ hasFallbackGapSupport,
641
+ disableLayoutStyles = false
642
+ ) => {
643
+ const nodesWithStyles = getNodesWithStyles( tree, blockSelectors );
644
+ const nodesWithSettings = getNodesWithSettings( tree, blockSelectors );
645
+ const useRootPaddingAlign = tree?.settings?.useRootPaddingAwareAlignments;
646
+ const { contentSize, wideSize } = tree?.settings?.layout || {};
647
+
648
+ /*
649
+ * Reset default browser margin on the root body element.
650
+ * This is set on the root selector **before** generating the ruleset
651
+ * from the `theme.json`. This is to ensure that if the `theme.json` declares
652
+ * `margin` in its `spacing` declaration for the `body` element then these
653
+ * user-generated values take precedence in the CSS cascade.
654
+ * @link https://github.com/WordPress/gutenberg/issues/36147.
655
+ */
656
+ let ruleset = 'body {margin: 0;';
657
+
658
+ if ( contentSize ) {
659
+ ruleset += ` --wp--style--global--content-size: ${ contentSize };`;
660
+ }
661
+
662
+ if ( wideSize ) {
663
+ ruleset += ` --wp--style--global--wide-size: ${ wideSize };`;
664
+ }
665
+
666
+ if ( useRootPaddingAlign ) {
667
+ ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) }
668
+ .has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
669
+ .has-global-padding :where(.has-global-padding) { padding-right: 0; padding-left: 0; }
670
+ .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(.has-global-padding) > .alignfull { margin-right: 0; margin-left: 0; }
672
+ .has-global-padding > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
673
+ .has-global-padding :where(.has-global-padding) > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: 0; padding-left: 0;`;
674
+ }
675
+
676
+ ruleset += '}';
677
+
678
+ nodesWithStyles.forEach(
679
+ ( {
680
+ selector,
681
+ duotoneSelector,
682
+ styles,
683
+ fallbackGapValue,
684
+ hasLayoutSupport,
685
+ featureSelectors,
686
+ styleVariationSelectors,
687
+ } ) => {
688
+ // Process styles for block support features with custom feature level
689
+ // CSS selectors set.
690
+ if ( featureSelectors ) {
691
+ Object.entries( featureSelectors ).forEach(
692
+ ( [ featureName, featureSelector ] ) => {
693
+ if ( styles?.[ featureName ] ) {
694
+ const featureStyles = {
695
+ [ featureName ]: styles[ featureName ],
696
+ };
697
+ const featureDeclarations =
698
+ getStylesDeclarations( featureStyles );
699
+ delete styles[ featureName ];
700
+
701
+ if ( !! featureDeclarations.length ) {
702
+ ruleset =
703
+ ruleset +
704
+ `${ featureSelector }{${ featureDeclarations.join(
705
+ ';'
706
+ ) } }`;
707
+ }
708
+ }
709
+ }
710
+ );
711
+ }
712
+
713
+ if ( styleVariationSelectors ) {
714
+ Object.entries( styleVariationSelectors ).forEach(
715
+ ( [ styleVariationName, styleVariationSelector ] ) => {
716
+ if ( styles?.variations?.[ styleVariationName ] ) {
717
+ // If the block uses any custom selectors for block support, add those first.
718
+ if ( featureSelectors ) {
719
+ Object.entries( featureSelectors ).forEach(
720
+ ( [ featureName, featureSelector ] ) => {
721
+ if (
722
+ styles?.variations?.[
723
+ styleVariationName
724
+ ]?.[ featureName ]
725
+ ) {
726
+ const featureStyles = {
727
+ [ featureName ]:
728
+ styles.variations[
729
+ styleVariationName
730
+ ][ featureName ],
731
+ };
732
+ const featureDeclarations =
733
+ getStylesDeclarations(
734
+ featureStyles
735
+ );
736
+ delete styles.variations[
737
+ styleVariationName
738
+ ][ featureName ];
739
+
740
+ if (
741
+ !! featureDeclarations.length
742
+ ) {
743
+ ruleset =
744
+ ruleset +
745
+ `${ concatFeatureVariationSelectorString(
746
+ featureSelector,
747
+ styleVariationSelector
748
+ ) }{${ featureDeclarations.join(
749
+ ';'
750
+ ) } }`;
751
+ }
752
+ }
753
+ }
754
+ );
755
+ }
756
+ // Otherwise add regular selectors.
757
+ const styleVariationDeclarations =
758
+ getStylesDeclarations(
759
+ styles?.variations?.[ styleVariationName ],
760
+ styleVariationSelector,
761
+ useRootPaddingAlign,
762
+ tree
763
+ );
764
+ if ( !! styleVariationDeclarations.length ) {
765
+ ruleset =
766
+ ruleset +
767
+ `${ styleVariationSelector }{${ styleVariationDeclarations.join(
768
+ ';'
769
+ ) }}`;
770
+ }
771
+ }
772
+ }
773
+ );
774
+ }
775
+
776
+ const duotoneStyles = {};
777
+ if ( styles?.filter ) {
778
+ duotoneStyles.filter = styles.filter;
779
+ delete styles.filter;
780
+ }
781
+
782
+ // Process duotone styles (they use color.__experimentalDuotone selector).
783
+ if ( duotoneSelector ) {
784
+ const duotoneDeclarations =
785
+ getStylesDeclarations( duotoneStyles );
786
+ if ( duotoneDeclarations.length > 0 ) {
787
+ ruleset =
788
+ ruleset +
789
+ `${ duotoneSelector }{${ duotoneDeclarations.join(
790
+ ';'
791
+ ) };}`;
792
+ }
793
+ }
794
+
795
+ // Process blockGap and layout styles.
796
+ if (
797
+ ! disableLayoutStyles &&
798
+ ( ROOT_BLOCK_SELECTOR === selector || hasLayoutSupport )
799
+ ) {
800
+ ruleset += getLayoutStyles( {
801
+ tree,
802
+ style: styles,
803
+ selector,
804
+ hasBlockGapSupport,
805
+ hasFallbackGapSupport,
806
+ fallbackGapValue,
807
+ } );
808
+ }
809
+
810
+ // Process the remaining block styles (they use either normal block class or __experimentalSelector).
811
+ const declarations = getStylesDeclarations(
812
+ styles,
813
+ selector,
814
+ useRootPaddingAlign,
815
+ tree
816
+ );
817
+ if ( declarations?.length ) {
818
+ ruleset =
819
+ ruleset + `${ selector }{${ declarations.join( ';' ) };}`;
820
+ }
821
+
822
+ // Check for pseudo selector in `styles` and handle separately.
823
+ const pseudoSelectorStyles = Object.entries( styles ).filter(
824
+ ( [ key ] ) => key.startsWith( ':' )
825
+ );
826
+
827
+ if ( pseudoSelectorStyles?.length ) {
828
+ pseudoSelectorStyles.forEach(
829
+ ( [ pseudoKey, pseudoStyle ] ) => {
830
+ const pseudoDeclarations =
831
+ getStylesDeclarations( pseudoStyle );
832
+
833
+ if ( ! pseudoDeclarations?.length ) {
834
+ return;
835
+ }
836
+
837
+ // `selector` maybe provided in a form
838
+ // where block level selectors have sub element
839
+ // selectors appended to them as a comma separated
840
+ // string.
841
+ // e.g. `h1 a,h2 a,h3 a,h4 a,h5 a,h6 a`;
842
+ // Split and append pseudo selector to create
843
+ // the proper rules to target the elements.
844
+ const _selector = selector
845
+ .split( ',' )
846
+ .map( ( sel ) => sel + pseudoKey )
847
+ .join( ',' );
848
+
849
+ const pseudoRule = `${ _selector }{${ pseudoDeclarations.join(
850
+ ';'
851
+ ) };}`;
852
+
853
+ ruleset = ruleset + pseudoRule;
854
+ }
855
+ );
856
+ }
857
+ }
858
+ );
859
+
860
+ /* Add alignment / layout styles */
861
+ ruleset =
862
+ ruleset +
863
+ '.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }';
864
+ ruleset =
865
+ ruleset +
866
+ '.wp-site-blocks > .alignright { float: right; margin-left: 2em; }';
867
+ ruleset =
868
+ ruleset +
869
+ '.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }';
870
+
871
+ if ( hasBlockGapSupport ) {
872
+ // Use fallback of `0.5em` just in case, however if there is blockGap support, there should nearly always be a real value.
873
+ const gapValue =
874
+ getGapCSSValue( tree?.styles?.spacing?.blockGap ) || '0.5em';
875
+ ruleset =
876
+ ruleset +
877
+ '.wp-site-blocks > * { margin-block-start: 0; margin-block-end: 0; }';
878
+ ruleset =
879
+ ruleset +
880
+ `.wp-site-blocks > * + * { margin-block-start: ${ gapValue }; }`;
881
+ }
882
+
883
+ nodesWithSettings.forEach( ( { selector, presets } ) => {
884
+ if ( ROOT_BLOCK_SELECTOR === selector ) {
885
+ // Do not add extra specificity for top-level classes.
886
+ selector = '';
887
+ }
888
+
889
+ const classes = getPresetsClasses( selector, presets );
890
+ if ( ! isEmpty( classes ) ) {
891
+ ruleset = ruleset + classes;
892
+ }
893
+ } );
894
+
895
+ return ruleset;
896
+ };
897
+
898
+ export function toSvgFilters( tree, blockSelectors ) {
899
+ const nodesWithSettings = getNodesWithSettings( tree, blockSelectors );
900
+ return nodesWithSettings.flatMap( ( { presets } ) => {
901
+ return getPresetsSvgFilters( presets );
902
+ } );
903
+ }
904
+
905
+ export const getBlockSelectors = ( blockTypes, getBlockStyles ) => {
906
+ const result = {};
907
+ blockTypes.forEach( ( blockType ) => {
908
+ const name = blockType.name;
909
+ const selector =
910
+ blockType?.supports?.__experimentalSelector ??
911
+ '.wp-block-' + name.replace( 'core/', '' ).replace( '/', '-' );
912
+ const duotoneSelector =
913
+ blockType?.supports?.color?.__experimentalDuotone ?? null;
914
+ const hasLayoutSupport = !! blockType?.supports?.__experimentalLayout;
915
+ const fallbackGapValue =
916
+ blockType?.supports?.spacing?.blockGap?.__experimentalDefault;
917
+
918
+ const blockStyleVariations = getBlockStyles( name );
919
+ const styleVariationSelectors = {};
920
+ if ( blockStyleVariations?.length ) {
921
+ blockStyleVariations.forEach( ( variation ) => {
922
+ const styleVariationSelector = `.is-style-${ variation.name }${ selector }`;
923
+ styleVariationSelectors[ variation.name ] =
924
+ styleVariationSelector;
925
+ } );
926
+ }
927
+ // For each block support feature add any custom selectors.
928
+ const featureSelectors = {};
929
+ Object.entries( BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS ).forEach(
930
+ ( [ featureKey, featureName ] ) => {
931
+ const featureSelector =
932
+ blockType?.supports?.[ featureKey ]?.__experimentalSelector;
933
+
934
+ if ( featureSelector ) {
935
+ featureSelectors[ featureName ] = scopeSelector(
936
+ selector,
937
+ featureSelector
938
+ );
939
+ }
940
+ }
941
+ );
942
+
943
+ result[ name ] = {
944
+ duotoneSelector,
945
+ fallbackGapValue,
946
+ featureSelectors: Object.keys( featureSelectors ).length
947
+ ? featureSelectors
948
+ : undefined,
949
+ hasLayoutSupport,
950
+ name,
951
+ selector,
952
+ styleVariationSelectors: Object.keys( styleVariationSelectors )
953
+ .length
954
+ ? styleVariationSelectors
955
+ : undefined,
956
+ };
957
+ } );
958
+
959
+ return result;
960
+ };
961
+
962
+ /**
963
+ * If there is a separator block whose color is defined in theme.json via background,
964
+ * update the separator color to the same value by using border color.
965
+ *
966
+ * @param {Object} config Theme.json configuration file object.
967
+ * @return {Object} configTheme.json configuration file object updated.
968
+ */
969
+ function updateConfigWithSeparator( config ) {
970
+ const needsSeparatorStyleUpdate =
971
+ config.styles?.blocks[ 'core/separator' ] &&
972
+ config.styles?.blocks[ 'core/separator' ].color?.background &&
973
+ ! config.styles?.blocks[ 'core/separator' ].color?.text &&
974
+ ! config.styles?.blocks[ 'core/separator' ].border?.color;
975
+ if ( needsSeparatorStyleUpdate ) {
976
+ return {
977
+ ...config,
978
+ styles: {
979
+ ...config.styles,
980
+ blocks: {
981
+ ...config.styles.blocks,
982
+ 'core/separator': {
983
+ ...config.styles.blocks[ 'core/separator' ],
984
+ color: {
985
+ ...config.styles.blocks[ 'core/separator' ].color,
986
+ text: config.styles?.blocks[ 'core/separator' ]
987
+ .color.background,
988
+ },
989
+ },
990
+ },
991
+ },
992
+ };
993
+ }
994
+ return config;
995
+ }
996
+
997
+ const processCSSNesting = ( css, blockSelector ) => {
998
+ let processedCSS = '';
999
+
1000
+ // Split CSS nested rules.
1001
+ const parts = css.split( '&' );
1002
+ parts.forEach( ( part ) => {
1003
+ processedCSS += ! part.includes( '{' )
1004
+ ? blockSelector + '{' + part + '}' // If the part doesn't contain braces, it applies to the root level.
1005
+ : blockSelector + part; // Prepend the selector, which effectively replaces the "&" character.
1006
+ } );
1007
+ return processedCSS;
1008
+ };
1009
+
1010
+ export function useGlobalStylesOutput() {
1011
+ let { merged: mergedConfig } = useContext( GlobalStylesContext );
1012
+
1013
+ const [ blockGap ] = useGlobalSetting( 'spacing.blockGap' );
1014
+ const hasBlockGapSupport = blockGap !== null;
1015
+ const hasFallbackGapSupport = ! hasBlockGapSupport; // This setting isn't useful yet: it exists as a placeholder for a future explicit fallback styles support.
1016
+ const disableLayoutStyles = useSelect( ( select ) => {
1017
+ const { getSettings } = select( blockEditorStore );
1018
+ return !! getSettings().disableLayoutStyles;
1019
+ } );
1020
+
1021
+ const getBlockStyles = useSelect( ( select ) => {
1022
+ return select( blocksStore ).getBlockStyles;
1023
+ }, [] );
1024
+
1025
+ return useMemo( () => {
1026
+ if ( ! mergedConfig?.styles || ! mergedConfig?.settings ) {
1027
+ return [];
1028
+ }
1029
+ mergedConfig = updateConfigWithSeparator( mergedConfig );
1030
+
1031
+ const blockSelectors = getBlockSelectors(
1032
+ getBlockTypes(),
1033
+ getBlockStyles
1034
+ );
1035
+
1036
+ const customProperties = toCustomProperties(
1037
+ mergedConfig,
1038
+ blockSelectors
1039
+ );
1040
+ const globalStyles = toStyles(
1041
+ mergedConfig,
1042
+ blockSelectors,
1043
+ hasBlockGapSupport,
1044
+ hasFallbackGapSupport,
1045
+ disableLayoutStyles
1046
+ );
1047
+
1048
+ const filters = toSvgFilters( mergedConfig, blockSelectors );
1049
+ const stylesheets = [
1050
+ {
1051
+ css: customProperties,
1052
+ isGlobalStyles: true,
1053
+ },
1054
+ {
1055
+ css: globalStyles,
1056
+ isGlobalStyles: true,
1057
+ },
1058
+ // Load custom CSS in own stylesheet so that any invalid CSS entered in the input won't break all the global styles in the editor.
1059
+ {
1060
+ css: mergedConfig.styles.css ?? '',
1061
+ isGlobalStyles: true,
1062
+ },
1063
+ ];
1064
+
1065
+ // Loop through the blocks to check if there are custom CSS values.
1066
+ // If there are, get the block selector and push the selector together with
1067
+ // the CSS value to the 'stylesheets' array.
1068
+ getBlockTypes().forEach( ( blockType ) => {
1069
+ if ( mergedConfig.styles.blocks[ blockType.name ]?.css ) {
1070
+ const selector = blockSelectors[ blockType.name ].selector;
1071
+ stylesheets.push( {
1072
+ css: processCSSNesting(
1073
+ mergedConfig.styles.blocks[ blockType.name ]?.css,
1074
+ selector
1075
+ ),
1076
+ isGlobalStyles: true,
1077
+ } );
1078
+ }
1079
+ } );
1080
+
1081
+ return [ stylesheets, mergedConfig.settings, filters ];
1082
+ }, [
1083
+ hasBlockGapSupport,
1084
+ hasFallbackGapSupport,
1085
+ mergedConfig,
1086
+ disableLayoutStyles,
1087
+ ] );
1088
+ }