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