@wordpress/block-editor 11.2.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 (660) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +28 -4
  3. package/build/components/alignment-control/ui.js +1 -1
  4. package/build/components/alignment-control/ui.js.map +1 -1
  5. package/build/components/autocomplete/index.js +2 -7
  6. package/build/components/autocomplete/index.js.map +1 -1
  7. package/build/components/block-alignment-matrix-control/index.js +2 -2
  8. package/build/components/block-alignment-matrix-control/index.js.map +1 -1
  9. package/build/components/block-card/index.js +2 -4
  10. package/build/components/block-card/index.js.map +1 -1
  11. package/build/components/block-edit/index.js +8 -0
  12. package/build/components/block-edit/index.js.map +1 -1
  13. package/build/components/block-inspector/index.js +15 -14
  14. package/build/components/block-inspector/index.js.map +1 -1
  15. package/build/components/block-list/use-in-between-inserter.js +5 -0
  16. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  17. package/build/components/block-lock/modal.js +0 -1
  18. package/build/components/block-lock/modal.js.map +1 -1
  19. package/build/components/block-mover/mover-description.js +2 -2
  20. package/build/components/block-mover/mover-description.js.map +1 -1
  21. package/build/components/block-navigation/dropdown.js +3 -1
  22. package/build/components/block-navigation/dropdown.js.map +1 -1
  23. package/build/components/block-pattern-setup/index.js +1 -1
  24. package/build/components/block-pattern-setup/index.js.map +1 -1
  25. package/build/components/block-pattern-setup/use-patterns-setup.js +2 -2
  26. package/build/components/block-pattern-setup/use-patterns-setup.js.map +1 -1
  27. package/build/components/block-patterns-list/index.js +31 -3
  28. package/build/components/block-patterns-list/index.js.map +1 -1
  29. package/build/components/block-preview/auto.js +9 -11
  30. package/build/components/block-preview/auto.js.map +1 -1
  31. package/build/components/block-preview/index.js +32 -8
  32. package/build/components/block-preview/index.js.map +1 -1
  33. package/build/components/block-selection-clearer/index.js +1 -1
  34. package/build/components/block-selection-clearer/index.js.map +1 -1
  35. package/build/components/block-settings/container.native.js +7 -33
  36. package/build/components/block-settings/container.native.js.map +1 -1
  37. package/build/components/block-settings-menu/block-settings-dropdown.js +12 -6
  38. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  39. package/build/components/block-settings-menu-controls/index.js +2 -8
  40. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  41. package/build/components/block-switcher/utils.js +1 -1
  42. package/build/components/block-switcher/utils.js.map +1 -1
  43. package/build/components/block-tools/selected-block-popover.js +55 -47
  44. package/build/components/block-tools/selected-block-popover.js.map +1 -1
  45. package/build/components/block-vertical-alignment-control/icons.js +15 -1
  46. package/build/components/block-vertical-alignment-control/icons.js.map +1 -1
  47. package/build/components/block-vertical-alignment-control/ui.js +9 -4
  48. package/build/components/block-vertical-alignment-control/ui.js.map +1 -1
  49. package/build/components/color-style-selector/index.js +3 -1
  50. package/build/components/color-style-selector/index.js.map +1 -1
  51. package/build/components/date-format-picker/index.js +3 -4
  52. package/build/components/date-format-picker/index.js.map +1 -1
  53. package/build/components/font-family/index.js +1 -7
  54. package/build/components/font-family/index.js.map +1 -1
  55. package/build/components/font-sizes/fluid-utils.js +1 -1
  56. package/build/components/font-sizes/fluid-utils.js.map +1 -1
  57. package/build/components/font-sizes/utils.js +1 -1
  58. package/build/components/font-sizes/utils.js.map +1 -1
  59. package/build/components/global-styles/context.js +22 -0
  60. package/build/components/global-styles/context.js.map +1 -0
  61. package/build/components/global-styles/hooks.js +142 -0
  62. package/build/components/global-styles/hooks.js.map +1 -0
  63. package/build/components/global-styles/index.js +42 -0
  64. package/build/components/global-styles/index.js.map +1 -0
  65. package/build/components/global-styles/typography-utils.js +92 -0
  66. package/build/components/global-styles/typography-utils.js.map +1 -0
  67. package/build/components/global-styles/use-global-styles-output.js +974 -0
  68. package/build/components/global-styles/use-global-styles-output.js.map +1 -0
  69. package/build/components/global-styles/utils.js +340 -0
  70. package/build/components/global-styles/utils.js.map +1 -0
  71. package/build/components/height-control/index.js +13 -1
  72. package/build/components/height-control/index.js.map +1 -1
  73. package/build/components/image-editor/constants.js +1 -1
  74. package/build/components/image-editor/constants.js.map +1 -1
  75. package/build/components/image-editor/context.js +1 -2
  76. package/build/components/image-editor/context.js.map +1 -1
  77. package/build/components/image-editor/cropper.js +3 -1
  78. package/build/components/image-editor/cropper.js.map +1 -1
  79. package/build/components/image-editor/index.js +13 -9
  80. package/build/components/image-editor/index.js.map +1 -1
  81. package/build/components/image-editor/use-transform-image.js +11 -35
  82. package/build/components/image-editor/use-transform-image.js.map +1 -1
  83. package/build/components/image-size-control/index.js +1 -7
  84. package/build/components/image-size-control/index.js.map +1 -1
  85. package/build/components/index.js +8 -24
  86. package/build/components/index.js.map +1 -1
  87. package/build/components/inner-blocks/index.js +22 -32
  88. package/build/components/inner-blocks/index.js.map +1 -1
  89. package/build/components/inner-blocks/index.native.js +8 -23
  90. package/build/components/inner-blocks/index.native.js.map +1 -1
  91. package/build/components/inner-blocks/use-block-context.js +53 -0
  92. package/build/components/inner-blocks/use-block-context.js.map +1 -0
  93. package/build/components/inserter/block-patterns-explorer/explorer.js +0 -1
  94. package/build/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
  95. package/build/components/inserter/block-patterns-tab.js +7 -1
  96. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  97. package/build/components/inserter/block-types-tab.js +2 -2
  98. package/build/components/inserter/block-types-tab.js.map +1 -1
  99. package/build/components/inserter/hooks/use-patterns-state.js +1 -7
  100. package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
  101. package/build/components/inserter/index.js +5 -4
  102. package/build/components/inserter/index.js.map +1 -1
  103. package/build/components/inserter/media-tab/hooks.js +142 -56
  104. package/build/components/inserter/media-tab/hooks.js.map +1 -1
  105. package/build/components/inserter/media-tab/media-list.js +74 -21
  106. package/build/components/inserter/media-tab/media-list.js.map +1 -1
  107. package/build/components/inserter/media-tab/media-panel.js +11 -13
  108. package/build/components/inserter/media-tab/media-panel.js.map +1 -1
  109. package/build/components/inserter/media-tab/media-tab.js +6 -3
  110. package/build/components/inserter/media-tab/media-tab.js.map +1 -1
  111. package/build/components/inserter/media-tab/utils.js +26 -15
  112. package/build/components/inserter/media-tab/utils.js.map +1 -1
  113. package/build/components/inserter/menu.js +1 -0
  114. package/build/components/inserter/menu.js.map +1 -1
  115. package/build/components/inserter/preview-panel.js +5 -3
  116. package/build/components/inserter/preview-panel.js.map +1 -1
  117. package/build/components/inserter/search-results.js +2 -7
  118. package/build/components/inserter/search-results.js.map +1 -1
  119. package/build/components/inserter-list-item/index.js +1 -9
  120. package/build/components/inserter-list-item/index.js.map +1 -1
  121. package/build/components/inspector-controls/fill.js +15 -2
  122. package/build/components/inspector-controls/fill.js.map +1 -1
  123. package/build/components/inspector-controls/fill.native.js +14 -1
  124. package/build/components/inspector-controls/fill.native.js.map +1 -1
  125. package/build/components/inspector-controls/groups.js +4 -0
  126. package/build/components/inspector-controls/groups.js.map +1 -1
  127. package/build/components/inspector-controls/index.js +2 -2
  128. package/build/components/inspector-controls/index.js.map +1 -1
  129. package/build/components/inspector-controls/slot.js +14 -1
  130. package/build/components/inspector-controls/slot.js.map +1 -1
  131. package/build/components/inspector-controls/slot.native.js +14 -1
  132. package/build/components/inspector-controls/slot.native.js.map +1 -1
  133. package/build/components/inspector-controls-tabs/advanced-controls-panel.js +1 -1
  134. package/build/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -1
  135. package/build/components/inspector-controls-tabs/index.js +2 -2
  136. package/build/components/inspector-controls-tabs/index.js.map +1 -1
  137. package/build/components/inspector-controls-tabs/position-controls-panel.js +1 -1
  138. package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
  139. package/build/components/inspector-controls-tabs/styles-tab.js +6 -4
  140. package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  141. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +17 -12
  142. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  143. package/build/components/justify-content-control/ui.js +8 -1
  144. package/build/components/justify-content-control/ui.js.map +1 -1
  145. package/build/components/link-control/index.js +45 -17
  146. package/build/components/link-control/index.js.map +1 -1
  147. package/build/components/list-view/block.js +1 -1
  148. package/build/components/list-view/block.js.map +1 -1
  149. package/build/components/list-view/use-list-view-drop-zone.js +1 -1
  150. package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
  151. package/build/components/media-upload/index.native.js +4 -1
  152. package/build/components/media-upload/index.native.js.map +1 -1
  153. package/build/components/off-canvas-editor/appender.js +50 -3
  154. package/build/components/off-canvas-editor/appender.js.map +1 -1
  155. package/build/components/off-canvas-editor/block-select-button.js +10 -4
  156. package/build/components/off-canvas-editor/block-select-button.js.map +1 -1
  157. package/build/components/off-canvas-editor/block.js +6 -27
  158. package/build/components/off-canvas-editor/block.js.map +1 -1
  159. package/build/components/off-canvas-editor/branch.js +25 -10
  160. package/build/components/off-canvas-editor/branch.js.map +1 -1
  161. package/build/components/off-canvas-editor/index.js +11 -16
  162. package/build/components/off-canvas-editor/index.js.map +1 -1
  163. package/build/components/off-canvas-editor/link-ui.js +2 -2
  164. package/build/components/off-canvas-editor/link-ui.js.map +1 -1
  165. package/build/components/off-canvas-editor/use-list-view-drop-zone.js +1 -1
  166. package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -1
  167. package/build/components/provider/index.js +21 -9
  168. package/build/components/provider/index.js.map +1 -1
  169. package/build/components/provider/index.native.js +5 -6
  170. package/build/components/provider/index.native.js.map +1 -1
  171. package/build/components/rich-text/use-before-input-rules.js +11 -3
  172. package/build/components/rich-text/use-before-input-rules.js.map +1 -1
  173. package/build/components/rich-text/utils.js +1 -1
  174. package/build/components/rich-text/utils.js.map +1 -1
  175. package/build/components/spacing-sizes-control/utils.js +2 -8
  176. package/build/components/spacing-sizes-control/utils.js.map +1 -1
  177. package/build/components/tool-selector/index.js +3 -1
  178. package/build/components/tool-selector/index.js.map +1 -1
  179. package/build/components/url-popover/image-url-input-ui.js +7 -8
  180. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  181. package/build/components/use-block-display-information/index.js +1 -1
  182. package/build/components/use-block-display-information/index.js.map +1 -1
  183. package/build/experiments.js +45 -0
  184. package/build/experiments.js.map +1 -0
  185. package/build/experiments.native.js +40 -0
  186. package/build/experiments.native.js.map +1 -0
  187. package/build/hooks/anchor.js +2 -1
  188. package/build/hooks/anchor.js.map +1 -1
  189. package/build/hooks/border.js +1 -1
  190. package/build/hooks/border.js.map +1 -1
  191. package/build/hooks/child-layout.js +5 -1
  192. package/build/hooks/child-layout.js.map +1 -1
  193. package/build/hooks/color-panel.js +1 -1
  194. package/build/hooks/color-panel.js.map +1 -1
  195. package/build/hooks/color.js +3 -3
  196. package/build/hooks/color.js.map +1 -1
  197. package/build/hooks/custom-class-name.js +2 -1
  198. package/build/hooks/custom-class-name.js.map +1 -1
  199. package/build/hooks/dimensions.js +7 -5
  200. package/build/hooks/dimensions.js.map +1 -1
  201. package/build/hooks/margin.js +1 -0
  202. package/build/hooks/margin.js.map +1 -1
  203. package/build/hooks/padding.js +1 -0
  204. package/build/hooks/padding.js.map +1 -1
  205. package/build/hooks/position.js +34 -15
  206. package/build/hooks/position.js.map +1 -1
  207. package/build/hooks/typography.js +1 -1
  208. package/build/hooks/typography.js.map +1 -1
  209. package/build/hooks/use-color-props.js +3 -3
  210. package/build/hooks/use-color-props.js.map +1 -1
  211. package/build/hooks/utils.js +69 -3
  212. package/build/hooks/utils.js.map +1 -1
  213. package/build/index.js +10 -1
  214. package/build/index.js.map +1 -1
  215. package/build/layouts/constrained.js +3 -0
  216. package/build/layouts/constrained.js.map +1 -1
  217. package/build/layouts/flex.js +59 -9
  218. package/build/layouts/flex.js.map +1 -1
  219. package/build/layouts/flow.js +0 -18
  220. package/build/layouts/flow.js.map +1 -1
  221. package/build/store/actions.js +3 -30
  222. package/build/store/actions.js.map +1 -1
  223. package/build/store/defaults.js +5 -2
  224. package/build/store/defaults.js.map +1 -1
  225. package/build/store/index.js +11 -2
  226. package/build/store/index.js.map +1 -1
  227. package/build/store/private-actions.js +78 -0
  228. package/build/store/private-actions.js.map +1 -0
  229. package/build/store/private-selectors.js +18 -0
  230. package/build/store/private-selectors.js.map +1 -0
  231. package/build/store/reducer.js +1 -1
  232. package/build/store/reducer.js.map +1 -1
  233. package/build/store/selectors.js +60 -34
  234. package/build/store/selectors.js.map +1 -1
  235. package/build/utils/block-variation-transforms.js +1 -1
  236. package/build/utils/block-variation-transforms.js.map +1 -1
  237. package/build/utils/parse-css-unit-to-px.js +1 -1
  238. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  239. package/build/utils/transform-styles/index.js +1 -7
  240. package/build/utils/transform-styles/index.js.map +1 -1
  241. package/build-module/components/alignment-control/ui.js +1 -1
  242. package/build-module/components/alignment-control/ui.js.map +1 -1
  243. package/build-module/components/autocomplete/index.js +2 -6
  244. package/build-module/components/autocomplete/index.js.map +1 -1
  245. package/build-module/components/block-alignment-matrix-control/index.js +2 -2
  246. package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
  247. package/build-module/components/block-card/index.js +2 -4
  248. package/build-module/components/block-card/index.js.map +1 -1
  249. package/build-module/components/block-edit/index.js +7 -0
  250. package/build-module/components/block-edit/index.js.map +1 -1
  251. package/build-module/components/block-inspector/index.js +15 -14
  252. package/build-module/components/block-inspector/index.js.map +1 -1
  253. package/build-module/components/block-list/use-in-between-inserter.js +5 -0
  254. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  255. package/build-module/components/block-lock/modal.js +0 -1
  256. package/build-module/components/block-lock/modal.js.map +1 -1
  257. package/build-module/components/block-mover/mover-description.js +2 -2
  258. package/build-module/components/block-mover/mover-description.js.map +1 -1
  259. package/build-module/components/block-navigation/dropdown.js +3 -1
  260. package/build-module/components/block-navigation/dropdown.js.map +1 -1
  261. package/build-module/components/block-pattern-setup/index.js +1 -1
  262. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  263. package/build-module/components/block-pattern-setup/use-patterns-setup.js +2 -2
  264. package/build-module/components/block-pattern-setup/use-patterns-setup.js.map +1 -1
  265. package/build-module/components/block-patterns-list/index.js +32 -3
  266. package/build-module/components/block-patterns-list/index.js.map +1 -1
  267. package/build-module/components/block-preview/auto.js +9 -11
  268. package/build-module/components/block-preview/auto.js.map +1 -1
  269. package/build-module/components/block-preview/index.js +31 -8
  270. package/build-module/components/block-preview/index.js.map +1 -1
  271. package/build-module/components/block-selection-clearer/index.js +1 -1
  272. package/build-module/components/block-selection-clearer/index.js.map +1 -1
  273. package/build-module/components/block-settings/container.native.js +6 -30
  274. package/build-module/components/block-settings/container.native.js.map +1 -1
  275. package/build-module/components/block-settings-menu/block-settings-dropdown.js +12 -6
  276. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  277. package/build-module/components/block-settings-menu-controls/index.js +2 -7
  278. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  279. package/build-module/components/block-switcher/utils.js +1 -1
  280. package/build-module/components/block-switcher/utils.js.map +1 -1
  281. package/build-module/components/block-tools/selected-block-popover.js +55 -48
  282. package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
  283. package/build-module/components/block-vertical-alignment-control/icons.js +12 -0
  284. package/build-module/components/block-vertical-alignment-control/icons.js.map +1 -1
  285. package/build-module/components/block-vertical-alignment-control/ui.js +10 -5
  286. package/build-module/components/block-vertical-alignment-control/ui.js.map +1 -1
  287. package/build-module/components/color-style-selector/index.js +3 -1
  288. package/build-module/components/color-style-selector/index.js.map +1 -1
  289. package/build-module/components/date-format-picker/index.js +4 -5
  290. package/build-module/components/date-format-picker/index.js.map +1 -1
  291. package/build-module/components/font-family/index.js +1 -6
  292. package/build-module/components/font-family/index.js.map +1 -1
  293. package/build-module/components/font-sizes/fluid-utils.js +1 -1
  294. package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
  295. package/build-module/components/font-sizes/utils.js +1 -1
  296. package/build-module/components/font-sizes/utils.js.map +1 -1
  297. package/build-module/components/global-styles/context.js +12 -0
  298. package/build-module/components/global-styles/context.js.map +1 -0
  299. package/build-module/components/global-styles/hooks.js +121 -0
  300. package/build-module/components/global-styles/hooks.js.map +1 -0
  301. package/build-module/components/global-styles/index.js +4 -0
  302. package/build-module/components/global-styles/index.js.map +1 -0
  303. package/build-module/components/global-styles/typography-utils.js +84 -0
  304. package/build-module/components/global-styles/typography-utils.js.map +1 -0
  305. package/build-module/components/global-styles/use-global-styles-output.js +930 -0
  306. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -0
  307. package/build-module/components/global-styles/utils.js +321 -0
  308. package/build-module/components/global-styles/utils.js.map +1 -0
  309. package/build-module/components/height-control/index.js +14 -1
  310. package/build-module/components/height-control/index.js.map +1 -1
  311. package/build-module/components/image-editor/constants.js +1 -1
  312. package/build-module/components/image-editor/constants.js.map +1 -1
  313. package/build-module/components/image-editor/context.js +1 -2
  314. package/build-module/components/image-editor/context.js.map +1 -1
  315. package/build-module/components/image-editor/cropper.js +3 -1
  316. package/build-module/components/image-editor/cropper.js.map +1 -1
  317. package/build-module/components/image-editor/index.js +13 -3
  318. package/build-module/components/image-editor/index.js.map +1 -1
  319. package/build-module/components/image-editor/use-transform-image.js +12 -37
  320. package/build-module/components/image-editor/use-transform-image.js.map +1 -1
  321. package/build-module/components/image-size-control/index.js +1 -6
  322. package/build-module/components/image-size-control/index.js.map +1 -1
  323. package/build-module/components/index.js +2 -3
  324. package/build-module/components/index.js.map +1 -1
  325. package/build-module/components/inner-blocks/index.js +21 -32
  326. package/build-module/components/inner-blocks/index.js.map +1 -1
  327. package/build-module/components/inner-blocks/index.native.js +9 -22
  328. package/build-module/components/inner-blocks/index.native.js.map +1 -1
  329. package/build-module/components/inner-blocks/use-block-context.js +43 -0
  330. package/build-module/components/inner-blocks/use-block-context.js.map +1 -0
  331. package/build-module/components/inserter/block-patterns-explorer/explorer.js +0 -1
  332. package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
  333. package/build-module/components/inserter/block-patterns-tab.js +7 -1
  334. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  335. package/build-module/components/inserter/block-types-tab.js +3 -3
  336. package/build-module/components/inserter/block-types-tab.js.map +1 -1
  337. package/build-module/components/inserter/hooks/use-patterns-state.js +1 -6
  338. package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
  339. package/build-module/components/inserter/index.js +5 -4
  340. package/build-module/components/inserter/index.js.map +1 -1
  341. package/build-module/components/inserter/media-tab/hooks.js +145 -56
  342. package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
  343. package/build-module/components/inserter/media-tab/media-list.js +74 -24
  344. package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
  345. package/build-module/components/inserter/media-tab/media-panel.js +14 -14
  346. package/build-module/components/inserter/media-tab/media-panel.js.map +1 -1
  347. package/build-module/components/inserter/media-tab/media-tab.js +7 -4
  348. package/build-module/components/inserter/media-tab/media-tab.js.map +1 -1
  349. package/build-module/components/inserter/media-tab/utils.js +27 -15
  350. package/build-module/components/inserter/media-tab/utils.js.map +1 -1
  351. package/build-module/components/inserter/menu.js +1 -0
  352. package/build-module/components/inserter/menu.js.map +1 -1
  353. package/build-module/components/inserter/preview-panel.js +5 -3
  354. package/build-module/components/inserter/preview-panel.js.map +1 -1
  355. package/build-module/components/inserter/search-results.js +2 -6
  356. package/build-module/components/inserter/search-results.js.map +1 -1
  357. package/build-module/components/inserter-list-item/index.js +1 -9
  358. package/build-module/components/inserter-list-item/index.js.map +1 -1
  359. package/build-module/components/inspector-controls/fill.js +14 -2
  360. package/build-module/components/inspector-controls/fill.js.map +1 -1
  361. package/build-module/components/inspector-controls/fill.native.js +13 -1
  362. package/build-module/components/inspector-controls/fill.native.js.map +1 -1
  363. package/build-module/components/inspector-controls/groups.js +4 -0
  364. package/build-module/components/inspector-controls/groups.js.map +1 -1
  365. package/build-module/components/inspector-controls/index.js +2 -2
  366. package/build-module/components/inspector-controls/index.js.map +1 -1
  367. package/build-module/components/inspector-controls/slot.js +13 -1
  368. package/build-module/components/inspector-controls/slot.js.map +1 -1
  369. package/build-module/components/inspector-controls/slot.native.js +13 -1
  370. package/build-module/components/inspector-controls/slot.native.js.map +1 -1
  371. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js +1 -1
  372. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -1
  373. package/build-module/components/inspector-controls-tabs/index.js +2 -2
  374. package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
  375. package/build-module/components/inspector-controls-tabs/position-controls-panel.js +1 -1
  376. package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
  377. package/build-module/components/inspector-controls-tabs/styles-tab.js +6 -4
  378. package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  379. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +17 -12
  380. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  381. package/build-module/components/justify-content-control/ui.js +9 -2
  382. package/build-module/components/justify-content-control/ui.js.map +1 -1
  383. package/build-module/components/link-control/index.js +45 -16
  384. package/build-module/components/link-control/index.js.map +1 -1
  385. package/build-module/components/list-view/block.js +1 -1
  386. package/build-module/components/list-view/block.js.map +1 -1
  387. package/build-module/components/list-view/use-list-view-drop-zone.js +1 -1
  388. package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
  389. package/build-module/components/media-upload/index.native.js +4 -1
  390. package/build-module/components/media-upload/index.native.js.map +1 -1
  391. package/build-module/components/off-canvas-editor/appender.js +47 -4
  392. package/build-module/components/off-canvas-editor/appender.js.map +1 -1
  393. package/build-module/components/off-canvas-editor/block-select-button.js +9 -4
  394. package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -1
  395. package/build-module/components/off-canvas-editor/block.js +6 -25
  396. package/build-module/components/off-canvas-editor/block.js.map +1 -1
  397. package/build-module/components/off-canvas-editor/branch.js +23 -11
  398. package/build-module/components/off-canvas-editor/branch.js.map +1 -1
  399. package/build-module/components/off-canvas-editor/index.js +11 -15
  400. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  401. package/build-module/components/off-canvas-editor/link-ui.js +2 -2
  402. package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
  403. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +1 -1
  404. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -1
  405. package/build-module/components/provider/index.js +16 -9
  406. package/build-module/components/provider/index.js.map +1 -1
  407. package/build-module/components/provider/index.native.js +4 -4
  408. package/build-module/components/provider/index.native.js.map +1 -1
  409. package/build-module/components/rich-text/use-before-input-rules.js +10 -2
  410. package/build-module/components/rich-text/use-before-input-rules.js.map +1 -1
  411. package/build-module/components/rich-text/utils.js +1 -1
  412. package/build-module/components/rich-text/utils.js.map +1 -1
  413. package/build-module/components/spacing-sizes-control/utils.js +2 -7
  414. package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
  415. package/build-module/components/tool-selector/index.js +3 -1
  416. package/build-module/components/tool-selector/index.js.map +1 -1
  417. package/build-module/components/url-popover/image-url-input-ui.js +8 -8
  418. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  419. package/build-module/components/use-block-display-information/index.js +1 -1
  420. package/build-module/components/use-block-display-information/index.js.map +1 -1
  421. package/build-module/experiments.js +25 -0
  422. package/build-module/experiments.js.map +1 -0
  423. package/build-module/experiments.native.js +23 -0
  424. package/build-module/experiments.native.js.map +1 -0
  425. package/build-module/hooks/anchor.js +2 -1
  426. package/build-module/hooks/anchor.js.map +1 -1
  427. package/build-module/hooks/border.js +1 -1
  428. package/build-module/hooks/border.js.map +1 -1
  429. package/build-module/hooks/child-layout.js +5 -1
  430. package/build-module/hooks/child-layout.js.map +1 -1
  431. package/build-module/hooks/color-panel.js +1 -1
  432. package/build-module/hooks/color-panel.js.map +1 -1
  433. package/build-module/hooks/color.js +3 -3
  434. package/build-module/hooks/color.js.map +1 -1
  435. package/build-module/hooks/custom-class-name.js +2 -1
  436. package/build-module/hooks/custom-class-name.js.map +1 -1
  437. package/build-module/hooks/dimensions.js +6 -5
  438. package/build-module/hooks/dimensions.js.map +1 -1
  439. package/build-module/hooks/margin.js +1 -0
  440. package/build-module/hooks/margin.js.map +1 -1
  441. package/build-module/hooks/padding.js +1 -0
  442. package/build-module/hooks/padding.js.map +1 -1
  443. package/build-module/hooks/position.js +31 -14
  444. package/build-module/hooks/position.js.map +1 -1
  445. package/build-module/hooks/typography.js +1 -1
  446. package/build-module/hooks/typography.js.map +1 -1
  447. package/build-module/hooks/use-color-props.js +3 -3
  448. package/build-module/hooks/use-color-props.js.map +1 -1
  449. package/build-module/hooks/utils.js +70 -4
  450. package/build-module/hooks/utils.js.map +1 -1
  451. package/build-module/index.js +1 -0
  452. package/build-module/index.js.map +1 -1
  453. package/build-module/layouts/constrained.js +3 -0
  454. package/build-module/layouts/constrained.js.map +1 -1
  455. package/build-module/layouts/flex.js +60 -10
  456. package/build-module/layouts/flex.js.map +1 -1
  457. package/build-module/layouts/flow.js +0 -18
  458. package/build-module/layouts/flow.js.map +1 -1
  459. package/build-module/store/actions.js +2 -26
  460. package/build-module/store/actions.js.map +1 -1
  461. package/build-module/store/defaults.js +5 -2
  462. package/build-module/store/defaults.js.map +1 -1
  463. package/build-module/store/index.js +8 -2
  464. package/build-module/store/index.js.map +1 -1
  465. package/build-module/store/private-actions.js +66 -0
  466. package/build-module/store/private-actions.js.map +1 -0
  467. package/build-module/store/private-selectors.js +11 -0
  468. package/build-module/store/private-selectors.js.map +1 -0
  469. package/build-module/store/reducer.js +1 -1
  470. package/build-module/store/reducer.js.map +1 -1
  471. package/build-module/store/selectors.js +48 -25
  472. package/build-module/store/selectors.js.map +1 -1
  473. package/build-module/utils/block-variation-transforms.js +1 -1
  474. package/build-module/utils/block-variation-transforms.js.map +1 -1
  475. package/build-module/utils/parse-css-unit-to-px.js +1 -1
  476. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  477. package/build-module/utils/transform-styles/index.js +1 -6
  478. package/build-module/utils/transform-styles/index.js.map +1 -1
  479. package/build-style/content-rtl.css +283 -3
  480. package/build-style/content.css +283 -3
  481. package/build-style/style-rtl.css +105 -221
  482. package/build-style/style.css +105 -221
  483. package/package.json +30 -29
  484. package/src/components/alignment-control/test/__snapshots__/index.js.snap +3 -3
  485. package/src/components/alignment-control/test/index.js +5 -15
  486. package/src/components/alignment-control/ui.js +1 -1
  487. package/src/components/autocomplete/index.js +3 -6
  488. package/src/components/block-alignment-control/test/index.js +3 -11
  489. package/src/components/block-alignment-matrix-control/index.js +1 -2
  490. package/src/components/block-card/index.js +1 -4
  491. package/src/components/block-content-overlay/content.scss +4 -4
  492. package/src/components/block-edit/index.js +15 -1
  493. package/src/components/block-icon/content.scss +31 -0
  494. package/src/components/block-inspector/index.js +13 -17
  495. package/src/components/block-list/use-in-between-inserter.js +5 -0
  496. package/src/components/block-lock/modal.js +0 -1
  497. package/src/components/block-mover/mover-description.js +2 -2
  498. package/src/components/block-mover/stories/index.js +3 -3
  499. package/src/components/block-navigation/dropdown.js +1 -1
  500. package/src/components/block-pattern-setup/index.js +1 -4
  501. package/src/components/block-pattern-setup/use-patterns-setup.js +2 -5
  502. package/src/components/block-patterns-list/index.js +29 -3
  503. package/src/components/block-preview/README.md +9 -9
  504. package/src/components/block-preview/auto.js +9 -11
  505. package/src/components/block-preview/content.scss +23 -0
  506. package/src/components/block-preview/index.js +40 -10
  507. package/src/components/block-preview/style.scss +0 -23
  508. package/src/components/block-selection-clearer/index.js +1 -1
  509. package/src/components/block-selection-clearer/test/index.js +6 -6
  510. package/src/components/block-settings/container.native.js +7 -26
  511. package/src/components/block-settings-menu/block-settings-dropdown.js +13 -5
  512. package/src/components/block-settings-menu-controls/index.js +2 -10
  513. package/src/components/block-switcher/test/index.js +43 -44
  514. package/src/components/block-switcher/utils.js +1 -1
  515. package/src/components/block-tools/selected-block-popover.js +77 -80
  516. package/src/components/block-tools/style.scss +0 -1
  517. package/src/components/block-variation-picker/{style.scss → content.scss} +0 -0
  518. package/src/components/block-vertical-alignment-control/icons.js +12 -0
  519. package/src/components/block-vertical-alignment-control/test/index.js +3 -11
  520. package/src/components/block-vertical-alignment-control/ui.js +16 -6
  521. package/src/components/color-style-selector/index.js +1 -1
  522. package/src/components/colors/test/with-colors.js +2 -8
  523. package/src/components/date-format-picker/index.js +23 -24
  524. package/src/components/date-format-picker/style.scss +0 -6
  525. package/src/components/default-block-appender/content.scss +18 -0
  526. package/src/components/default-block-appender/test/index.js +2 -8
  527. package/src/components/font-family/index.js +1 -6
  528. package/src/components/font-sizes/fluid-utils.js +1 -1
  529. package/src/components/font-sizes/utils.js +1 -1
  530. package/src/components/global-styles/README.md +77 -0
  531. package/src/components/global-styles/context.js +15 -0
  532. package/src/components/global-styles/hooks.js +145 -0
  533. package/src/components/global-styles/index.js +7 -0
  534. package/src/components/global-styles/test/typography-utils.js +393 -0
  535. package/src/components/global-styles/test/use-global-styles-output.js +814 -0
  536. package/src/components/global-styles/test/utils.js +206 -0
  537. package/src/components/global-styles/typography-utils.js +87 -0
  538. package/src/components/global-styles/use-global-styles-output.js +1088 -0
  539. package/src/components/global-styles/utils.js +373 -0
  540. package/src/components/height-control/README.md +55 -0
  541. package/src/components/height-control/index.js +13 -1
  542. package/src/components/image-editor/constants.js +1 -1
  543. package/src/components/image-editor/context.js +5 -9
  544. package/src/components/image-editor/cropper.js +3 -1
  545. package/src/components/image-editor/index.js +13 -4
  546. package/src/components/image-editor/use-transform-image.js +14 -55
  547. package/src/components/image-size-control/index.js +1 -6
  548. package/src/components/index.js +2 -6
  549. package/src/components/inner-blocks/index.js +29 -33
  550. package/src/components/inner-blocks/index.native.js +27 -47
  551. package/src/components/inner-blocks/use-block-context.js +47 -0
  552. package/src/components/inserter/block-patterns-explorer/explorer.js +0 -1
  553. package/src/components/inserter/block-patterns-tab.js +7 -0
  554. package/src/components/inserter/block-types-tab.js +3 -4
  555. package/src/components/inserter/hooks/use-patterns-state.js +1 -6
  556. package/src/components/inserter/index.js +3 -4
  557. package/src/components/inserter/media-tab/hooks.js +167 -65
  558. package/src/components/inserter/media-tab/media-list.js +94 -26
  559. package/src/components/inserter/media-tab/media-panel.js +9 -20
  560. package/src/components/inserter/media-tab/media-tab.js +12 -4
  561. package/src/components/inserter/media-tab/utils.js +20 -10
  562. package/src/components/inserter/menu.js +1 -0
  563. package/src/components/inserter/preview-panel.js +4 -2
  564. package/src/components/inserter/search-results.js +2 -6
  565. package/src/components/inserter/stories/index.js +9 -9
  566. package/src/components/inserter/style.scss +58 -11
  567. package/src/components/inserter-list-item/index.js +0 -7
  568. package/src/components/inspector-controls/README.md +3 -7
  569. package/src/components/inspector-controls/fill.js +15 -1
  570. package/src/components/inspector-controls/fill.native.js +14 -1
  571. package/src/components/inspector-controls/groups.js +3 -0
  572. package/src/components/inspector-controls/index.js +2 -6
  573. package/src/components/inspector-controls/slot.js +14 -1
  574. package/src/components/inspector-controls/slot.native.js +14 -1
  575. package/src/components/inspector-controls-tabs/advanced-controls-panel.js +1 -1
  576. package/src/components/inspector-controls-tabs/index.js +2 -4
  577. package/src/components/inspector-controls-tabs/position-controls-panel.js +1 -1
  578. package/src/components/inspector-controls-tabs/styles-tab.js +5 -7
  579. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +21 -10
  580. package/src/components/justify-content-control/ui.js +9 -0
  581. package/src/components/link-control/index.js +59 -23
  582. package/src/components/link-control/style.scss +7 -24
  583. package/src/components/link-control/test/index.js +134 -5
  584. package/src/components/list-view/block.js +1 -1
  585. package/src/components/list-view/use-list-view-drop-zone.js +1 -1
  586. package/src/components/media-replace-flow/test/index.js +4 -12
  587. package/src/components/media-upload/index.native.js +2 -2
  588. package/src/components/off-canvas-editor/README.md +2 -2
  589. package/src/components/off-canvas-editor/appender.js +93 -37
  590. package/src/components/off-canvas-editor/block-select-button.js +12 -1
  591. package/src/components/off-canvas-editor/block.js +3 -42
  592. package/src/components/off-canvas-editor/branch.js +32 -5
  593. package/src/components/off-canvas-editor/index.js +10 -25
  594. package/src/components/off-canvas-editor/link-ui.js +2 -2
  595. package/src/components/off-canvas-editor/style.scss +5 -1
  596. package/src/components/off-canvas-editor/use-list-view-drop-zone.js +1 -1
  597. package/src/components/provider/index.js +33 -14
  598. package/src/components/provider/index.native.js +4 -3
  599. package/src/components/provider/test/experimental-provider.js +94 -0
  600. package/src/components/provider/test/use-block-sync.js +10 -0
  601. package/src/components/responsive-block-control/test/index.js +1 -5
  602. package/src/components/rich-text/use-before-input-rules.js +10 -2
  603. package/src/components/rich-text/utils.js +1 -1
  604. package/src/components/spacing-sizes-control/utils.js +2 -7
  605. package/src/components/tool-selector/index.js +1 -1
  606. package/src/components/url-input/test/button.js +24 -24
  607. package/src/components/url-popover/image-url-input-ui.js +7 -8
  608. package/src/components/url-popover/style.scss +0 -10
  609. package/src/components/use-block-display-information/index.js +1 -1
  610. package/src/components/warning/{style.scss → content.scss} +0 -0
  611. package/src/components/warning/test/index.js +1 -5
  612. package/src/content.scss +7 -0
  613. package/src/experiments.js +27 -0
  614. package/src/experiments.native.js +25 -0
  615. package/src/hooks/anchor.js +2 -1
  616. package/src/hooks/border.js +1 -1
  617. package/src/hooks/child-layout.js +6 -1
  618. package/src/hooks/color-panel.js +1 -1
  619. package/src/hooks/color.js +3 -3
  620. package/src/hooks/custom-class-name.js +2 -1
  621. package/src/hooks/dimensions.js +6 -6
  622. package/src/hooks/layout.scss +4 -0
  623. package/src/hooks/margin.js +1 -0
  624. package/src/hooks/padding.js +1 -0
  625. package/src/hooks/position.js +52 -36
  626. package/src/hooks/test/align.native.js +1 -1
  627. package/src/hooks/test/utils.js +104 -0
  628. package/src/hooks/typography.js +1 -1
  629. package/src/hooks/use-color-props.js +3 -3
  630. package/src/hooks/utils.js +68 -2
  631. package/src/index.js +1 -0
  632. package/src/layouts/constrained.js +3 -0
  633. package/src/layouts/flex.js +66 -14
  634. package/src/layouts/flow.js +0 -9
  635. package/src/store/actions.js +2 -26
  636. package/src/store/defaults.js +7 -2
  637. package/src/store/index.js +8 -2
  638. package/src/store/private-actions.js +65 -0
  639. package/src/store/private-selectors.js +10 -0
  640. package/src/store/reducer.js +1 -1
  641. package/src/store/selectors.js +103 -52
  642. package/src/store/test/actions.js +0 -18
  643. package/src/store/test/private-actions.js +22 -0
  644. package/src/store/test/private-selectors.js +24 -0
  645. package/src/store/test/selectors.js +52 -30
  646. package/src/style.scss +3 -5
  647. package/src/utils/block-variation-transforms.js +1 -1
  648. package/src/utils/parse-css-unit-to-px.js +3 -1
  649. package/src/utils/test/parse-css-unit-to-px.js +16 -24
  650. package/src/utils/transform-styles/index.js +1 -6
  651. package/build/components/inner-blocks/get-block-context.js +0 -45
  652. package/build/components/inner-blocks/get-block-context.js.map +0 -1
  653. package/build/components/off-canvas-editor/block-edit-button.js +0 -50
  654. package/build/components/off-canvas-editor/block-edit-button.js.map +0 -1
  655. package/build-module/components/inner-blocks/get-block-context.js +0 -37
  656. package/build-module/components/inner-blocks/get-block-context.js.map +0 -1
  657. package/build-module/components/off-canvas-editor/block-edit-button.js +0 -35
  658. package/build-module/components/off-canvas-editor/block-edit-button.js.map +0 -1
  659. package/src/components/inner-blocks/get-block-context.js +0 -39
  660. package/src/components/off-canvas-editor/block-edit-button.js +0 -27
@@ -10,6 +10,7 @@ import { __, sprintf } from '@wordpress/i18n';
10
10
  import { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';
11
11
  import { BaseControl, CustomSelectControl } from '@wordpress/components';
12
12
  import { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';
13
+ import { useSelect } from '@wordpress/data';
13
14
  import {
14
15
  useContext,
15
16
  useMemo,
@@ -25,6 +26,7 @@ import BlockList from '../components/block-list';
25
26
  import useSetting from '../components/use-setting';
26
27
  import InspectorControls from '../components/inspector-controls';
27
28
  import { cleanEmptyObject } from './utils';
29
+ import { store as blockEditorStore } from '../store';
28
30
 
29
31
  const POSITION_SUPPORT_KEY = 'position';
30
32
 
@@ -196,15 +198,16 @@ export function useIsPositionDisabled( { name: blockName } = {} ) {
196
198
  }
197
199
 
198
200
  /*
199
- * Position controls to be rendered in an inspector control panel.
201
+ * Position controls rendered in an inspector control panel.
200
202
  *
201
203
  * @param {Object} props
202
204
  *
203
- * @return {WPElement} Padding edit element.
205
+ * @return {WPElement} Position panel.
204
206
  */
205
- export function PositionEdit( props ) {
207
+ export function PositionPanel( props ) {
206
208
  const {
207
209
  attributes: { style = {} },
210
+ clientId,
208
211
  name: blockName,
209
212
  setAttributes,
210
213
  } = props;
@@ -213,16 +216,32 @@ export function PositionEdit( props ) {
213
216
  const allowSticky = hasStickyPositionSupport( blockName );
214
217
  const value = style?.position?.type;
215
218
 
219
+ const { hasParents } = useSelect(
220
+ ( select ) => {
221
+ const { getBlockParents } = select( blockEditorStore );
222
+ const parents = getBlockParents( clientId );
223
+ return {
224
+ hasParents: parents.length,
225
+ };
226
+ },
227
+ [ clientId ]
228
+ );
229
+
216
230
  const options = useMemo( () => {
217
231
  const availableOptions = [ DEFAULT_OPTION ];
218
- if ( allowSticky || value === STICKY_OPTION.value ) {
232
+ // Only display sticky option if the block has no parents (is at the root of the document),
233
+ // or if the block already has a sticky position value set.
234
+ if (
235
+ ( allowSticky && ! hasParents ) ||
236
+ value === STICKY_OPTION.value
237
+ ) {
219
238
  availableOptions.push( STICKY_OPTION );
220
239
  }
221
240
  if ( allowFixed || value === FIXED_OPTION.value ) {
222
241
  availableOptions.push( FIXED_OPTION );
223
242
  }
224
243
  return availableOptions;
225
- }, [ allowFixed, allowSticky, value ] );
244
+ }, [ allowFixed, allowSticky, hasParents, value ] );
226
245
 
227
246
  const onChangeType = ( next ) => {
228
247
  // For now, use a hard-coded `0px` value for the position.
@@ -251,32 +270,34 @@ export function PositionEdit( props ) {
251
270
  ? options.find( ( option ) => option.value === value ) || DEFAULT_OPTION
252
271
  : DEFAULT_OPTION;
253
272
 
273
+ // Only display position controls if there is at least one option to choose from.
254
274
  return Platform.select( {
255
- web: (
256
- <>
257
- <BaseControl className="block-editor-hooks__position-selection">
258
- <CustomSelectControl
259
- __nextUnconstrainedWidth
260
- __next36pxDefaultSize
261
- className="block-editor-hooks__position-selection__select-control"
262
- label={ __( 'Position' ) }
263
- hideLabelFromVision
264
- describedBy={ sprintf(
265
- // translators: %s: Currently selected font size.
266
- __( 'Currently selected position: %s' ),
267
- selectedOption.name
268
- ) }
269
- options={ options }
270
- value={ selectedOption }
271
- __experimentalShowSelectedHint
272
- onChange={ ( { selectedItem } ) => {
273
- onChangeType( selectedItem.value );
274
- } }
275
- size={ '__unstable-large' }
276
- />
277
- </BaseControl>
278
- </>
279
- ),
275
+ web:
276
+ options.length > 1 ? (
277
+ <InspectorControls group="position">
278
+ <BaseControl className="block-editor-hooks__position-selection">
279
+ <CustomSelectControl
280
+ __nextUnconstrainedWidth
281
+ __next36pxDefaultSize
282
+ className="block-editor-hooks__position-selection__select-control"
283
+ label={ __( 'Position' ) }
284
+ hideLabelFromVision
285
+ describedBy={ sprintf(
286
+ // translators: %s: Currently selected position.
287
+ __( 'Currently selected position: %s' ),
288
+ selectedOption.name
289
+ ) }
290
+ options={ options }
291
+ value={ selectedOption }
292
+ __experimentalShowSelectedHint
293
+ onChange={ ( { selectedItem } ) => {
294
+ onChangeType( selectedItem.value );
295
+ } }
296
+ size={ '__unstable-large' }
297
+ />
298
+ </BaseControl>
299
+ </InspectorControls>
300
+ ) : null,
280
301
  native: null,
281
302
  } );
282
303
  }
@@ -300,12 +321,7 @@ export const withInspectorControls = createHigherOrderComponent(
300
321
 
301
322
  return [
302
323
  showPositionControls && (
303
- <InspectorControls
304
- key="position"
305
- __experimentalGroup="position"
306
- >
307
- <PositionEdit { ...props } />
308
- </InspectorControls>
324
+ <PositionPanel key="position" { ...props } />
309
325
  ),
310
326
  <BlockEdit key="edit" { ...props } />,
311
327
  ];
@@ -83,7 +83,7 @@ describe( 'Align options', () => {
83
83
  expect( paragraphBlock ).toBeVisible();
84
84
 
85
85
  // Open alignments menu
86
- const alignmentButtons = getByLabelText( 'Align' );
86
+ const alignmentButtons = getByLabelText( 'Align text' );
87
87
  fireEvent.press( alignmentButtons );
88
88
 
89
89
  // Select alignment option.
@@ -7,9 +7,113 @@ import { applyFilters } from '@wordpress/hooks';
7
7
  * Internal dependencies
8
8
  */
9
9
  import '../anchor';
10
+ import { immutableSet } from '../utils';
10
11
 
11
12
  const noop = () => {};
12
13
 
14
+ describe( 'immutableSet', () => {
15
+ describe( 'handling falsy values properly', () => {
16
+ it( 'should create a new object if `undefined` is passed', () => {
17
+ const result = immutableSet( undefined, 'test', 1 );
18
+
19
+ expect( result ).toEqual( { test: 1 } );
20
+ } );
21
+
22
+ it( 'should create a new object if `null` is passed', () => {
23
+ const result = immutableSet( null, 'test', 1 );
24
+
25
+ expect( result ).toEqual( { test: 1 } );
26
+ } );
27
+
28
+ it( 'should create a new object if `false` is passed', () => {
29
+ const result = immutableSet( false, 'test', 1 );
30
+
31
+ expect( result ).toEqual( { test: 1 } );
32
+ } );
33
+
34
+ it( 'should create a new object if `0` is passed', () => {
35
+ const result = immutableSet( 0, 'test', 1 );
36
+
37
+ expect( result ).toEqual( { test: 1 } );
38
+ } );
39
+
40
+ it( 'should create a new object if an empty string is passed', () => {
41
+ const result = immutableSet( '', 'test', 1 );
42
+
43
+ expect( result ).toEqual( { test: 1 } );
44
+ } );
45
+
46
+ it( 'should create a new object if a NaN is passed', () => {
47
+ const result = immutableSet( NaN, 'test', 1 );
48
+
49
+ expect( result ).toEqual( { test: 1 } );
50
+ } );
51
+ } );
52
+
53
+ describe( 'manages data assignment properly', () => {
54
+ it( 'assigns value properly when it does not exist', () => {
55
+ const result = immutableSet( {}, 'test', 1 );
56
+
57
+ expect( result ).toEqual( { test: 1 } );
58
+ } );
59
+
60
+ it( 'overrides existing values', () => {
61
+ const result = immutableSet( { test: 1 }, 'test', 2 );
62
+
63
+ expect( result ).toEqual( { test: 2 } );
64
+ } );
65
+
66
+ describe( 'with array notation access', () => {
67
+ it( 'assigns values at deeper levels', () => {
68
+ const result = immutableSet( {}, [ 'foo', 'bar', 'baz' ], 5 );
69
+
70
+ expect( result ).toEqual( { foo: { bar: { baz: 5 } } } );
71
+ } );
72
+
73
+ it( 'overrides existing values at deeper levels', () => {
74
+ const result = immutableSet(
75
+ { foo: { bar: { baz: 1 } } },
76
+ [ 'foo', 'bar', 'baz' ],
77
+ 5
78
+ );
79
+
80
+ expect( result ).toEqual( { foo: { bar: { baz: 5 } } } );
81
+ } );
82
+
83
+ it( 'keeps other properties intact', () => {
84
+ const result = immutableSet(
85
+ { foo: { bar: { baz: 1 } } },
86
+ [ 'foo', 'bar', 'test' ],
87
+ 5
88
+ );
89
+
90
+ expect( result ).toEqual( {
91
+ foo: { bar: { baz: 1, test: 5 } },
92
+ } );
93
+ } );
94
+ } );
95
+ } );
96
+
97
+ describe( 'does not mutate the original object', () => {
98
+ it( 'clones the object at the first level', () => {
99
+ const input = {};
100
+ const result = immutableSet( input, 'test', 1 );
101
+
102
+ expect( result ).not.toBe( input );
103
+ } );
104
+
105
+ it( 'clones the object at deeper levels', () => {
106
+ const input = { foo: { bar: { baz: 1 } } };
107
+ const result = immutableSet( input, [ 'foo', 'bar', 'baz' ], 2 );
108
+
109
+ expect( result ).not.toBe( input );
110
+ expect( result.foo ).not.toBe( input.foo );
111
+ expect( result.foo.bar ).not.toBe( input.foo.bar );
112
+ expect( result.foo.bar.baz ).not.toBe( input.foo.bar.baz );
113
+ } );
114
+ } );
115
+ } );
116
+
13
117
  describe( 'anchor', () => {
14
118
  const blockSettings = {
15
119
  save: noop,
@@ -111,7 +111,7 @@ export function TypographyPanel( props ) {
111
111
  } );
112
112
 
113
113
  return (
114
- <InspectorControls __experimentalGroup="typography">
114
+ <InspectorControls group="typography">
115
115
  { ! isFontFamilyDisabled && (
116
116
  <ToolsPanelItem
117
117
  hasValue={ () => hasFontFamilyValue( props ) }
@@ -92,9 +92,9 @@ export function useColorProps( attributes ) {
92
92
  // Some color settings have a special handling for deprecated flags in `useSetting`,
93
93
  // so we can't unwrap them by doing const { ... } = useSetting('color')
94
94
  // until https://github.com/WordPress/gutenberg/issues/37094 is fixed.
95
- const userPalette = useSetting( 'color.palette.custom' ) || [];
96
- const themePalette = useSetting( 'color.palette.theme' ) || [];
97
- const defaultPalette = useSetting( 'color.palette.default' ) || [];
95
+ const userPalette = useSetting( 'color.palette.custom' );
96
+ const themePalette = useSetting( 'color.palette.theme' );
97
+ const defaultPalette = useSetting( 'color.palette.default' );
98
98
  const gradientsPerOrigin = useSetting( 'color.gradients' ) || EMPTY_OBJECT;
99
99
  const colors = useMemo(
100
100
  () => [
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { isEmpty, mapValues, get, setWith, clone } from 'lodash';
4
+ import { isEmpty, mapValues, get } from 'lodash';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
@@ -30,8 +30,74 @@ export const cleanEmptyObject = ( object ) => {
30
30
  return isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects;
31
31
  };
32
32
 
33
+ /**
34
+ * Converts a path to an array of its fragments.
35
+ * Supports strings, numbers and arrays:
36
+ *
37
+ * 'foo' => [ 'foo' ]
38
+ * 2 => [ '2' ]
39
+ * [ 'foo', 'bar' ] => [ 'foo', 'bar' ]
40
+ *
41
+ * @param {string|number|Array} path Path
42
+ * @return {Array} Normalized path.
43
+ */
44
+ function normalizePath( path ) {
45
+ if ( Array.isArray( path ) ) {
46
+ return path;
47
+ } else if ( typeof path === 'number' ) {
48
+ return [ path.toString() ];
49
+ }
50
+
51
+ return [ path ];
52
+ }
53
+
54
+ /**
55
+ * Clones an object.
56
+ * Non-object values are returned unchanged.
57
+ *
58
+ * @param {*} object Object to clone.
59
+ * @return {*} Cloned object, or original literal non-object value.
60
+ */
61
+ function cloneObject( object ) {
62
+ if ( typeof object === 'object' ) {
63
+ return {
64
+ ...Object.fromEntries(
65
+ Object.entries( object ).map( ( [ key, value ] ) => [
66
+ key,
67
+ cloneObject( value ),
68
+ ] )
69
+ ),
70
+ };
71
+ }
72
+
73
+ return object;
74
+ }
75
+
76
+ /**
77
+ * Perform an immutable set.
78
+ * Handles nullish initial values.
79
+ * Clones all nested objects in the specified object.
80
+ *
81
+ * @param {Object} object Object to set a value in.
82
+ * @param {number|string|Array} path Path in the object to modify.
83
+ * @param {*} value New value to set.
84
+ * @return {Object} Cloned object with the new value set.
85
+ */
33
86
  export function immutableSet( object, path, value ) {
34
- return setWith( object ? clone( object ) : {}, path, value, clone );
87
+ const normalizedPath = normalizePath( path );
88
+ const newObject = object ? cloneObject( object ) : {};
89
+
90
+ normalizedPath.reduce( ( acc, key, i ) => {
91
+ if ( acc[ key ] === undefined ) {
92
+ acc[ key ] = {};
93
+ }
94
+ if ( i === normalizedPath.length - 1 ) {
95
+ acc[ key ] = value;
96
+ }
97
+ return acc[ key ];
98
+ }, newObject );
99
+
100
+ return newObject;
35
101
  }
36
102
 
37
103
  export function transformStyles(
package/src/index.js CHANGED
@@ -20,3 +20,4 @@ export * from './elements';
20
20
  export * from './utils';
21
21
  export { storeConfig, store } from './store';
22
22
  export { SETTINGS_DEFAULTS } from './store/defaults';
23
+ export { experiments } from './experiments';
@@ -71,6 +71,7 @@ export default {
71
71
  <div className="block-editor-hooks__layout-controls">
72
72
  <div className="block-editor-hooks__layout-controls-unit">
73
73
  <UnitControl
74
+ className="block-editor-hooks__layout-controls-unit-input"
74
75
  label={ __( 'Content' ) }
75
76
  labelPosition="top"
76
77
  __unstableInputWidth="80px"
@@ -91,6 +92,7 @@ export default {
91
92
  </div>
92
93
  <div className="block-editor-hooks__layout-controls-unit">
93
94
  <UnitControl
95
+ className="block-editor-hooks__layout-controls-unit-input"
94
96
  label={ __( 'Wide' ) }
95
97
  labelPosition="top"
96
98
  __unstableInputWidth="80px"
@@ -116,6 +118,7 @@ export default {
116
118
  ) }
117
119
  </p>
118
120
  <ToggleGroupControl
121
+ __nextHasNoMarginBottom
119
122
  label={ __( 'Justification' ) }
120
123
  value={ justifyContent }
121
124
  onChange={ onJustificationChange }
@@ -7,6 +7,7 @@ import {
7
7
  justifyCenter,
8
8
  justifyRight,
9
9
  justifySpaceBetween,
10
+ justifyStretch,
10
11
  arrowRight,
11
12
  arrowDown,
12
13
  } from '@wordpress/icons';
@@ -44,12 +45,15 @@ const alignItemsMap = {
44
45
  left: 'flex-start',
45
46
  right: 'flex-end',
46
47
  center: 'center',
48
+ stretch: 'stretch',
47
49
  };
48
50
 
49
51
  const verticalAlignmentMap = {
50
52
  top: 'flex-start',
51
53
  center: 'center',
52
54
  bottom: 'flex-end',
55
+ stretch: 'stretch',
56
+ 'space-between': 'space-between',
53
57
  };
54
58
 
55
59
  const flexWrapOptions = [ 'wrap', 'nowrap' ];
@@ -101,14 +105,13 @@ export default {
101
105
  onChange={ onChange }
102
106
  isToolbar
103
107
  />
104
- { allowVerticalAlignment &&
105
- layout?.orientation !== 'vertical' && (
106
- <FlexLayoutVerticalAlignmentControl
107
- layout={ layout }
108
- onChange={ onChange }
109
- isToolbar
110
- />
111
- ) }
108
+ { allowVerticalAlignment && (
109
+ <FlexLayoutVerticalAlignmentControl
110
+ layout={ layout }
111
+ onChange={ onChange }
112
+ isToolbar
113
+ />
114
+ ) }
112
115
  </BlockControls>
113
116
  );
114
117
  },
@@ -153,6 +156,9 @@ export default {
153
156
  rules.push( `justify-content: ${ justifyContent }` );
154
157
  }
155
158
  } else {
159
+ if ( verticalAlignment ) {
160
+ rules.push( `justify-content: ${ verticalAlignment }` );
161
+ }
156
162
  rules.push( 'flex-direction: column' );
157
163
  rules.push( `align-items: ${ alignItems }` );
158
164
  }
@@ -188,7 +194,14 @@ function FlexLayoutVerticalAlignmentControl( {
188
194
  onChange,
189
195
  isToolbar = false,
190
196
  } ) {
191
- const { verticalAlignment = verticalAlignmentMap.center } = layout;
197
+ const { orientation = 'horizontal' } = layout;
198
+
199
+ const defaultVerticalAlignment =
200
+ orientation === 'horizontal'
201
+ ? verticalAlignmentMap.center
202
+ : verticalAlignmentMap.top;
203
+
204
+ const { verticalAlignment = defaultVerticalAlignment } = layout;
192
205
 
193
206
  const onVerticalAlignmentChange = ( value ) => {
194
207
  onChange( {
@@ -201,6 +214,11 @@ function FlexLayoutVerticalAlignmentControl( {
201
214
  <BlockVerticalAlignmentControl
202
215
  onChange={ onVerticalAlignmentChange }
203
216
  value={ verticalAlignment }
217
+ controls={
218
+ orientation === 'horizontal'
219
+ ? [ 'top', 'center', 'bottom', 'stretch' ]
220
+ : [ 'top', 'center', 'bottom', 'space-between' ]
221
+ }
204
222
  />
205
223
  );
206
224
  }
@@ -255,6 +273,8 @@ function FlexLayoutJustifyContentControl( {
255
273
  const allowedControls = [ 'left', 'center', 'right' ];
256
274
  if ( orientation === 'horizontal' ) {
257
275
  allowedControls.push( 'space-between' );
276
+ } else {
277
+ allowedControls.push( 'stretch' );
258
278
  }
259
279
  if ( isToolbar ) {
260
280
  return (
@@ -293,10 +313,17 @@ function FlexLayoutJustifyContentControl( {
293
313
  icon: justifySpaceBetween,
294
314
  label: __( 'Space between items' ),
295
315
  } );
316
+ } else {
317
+ justificationOptions.push( {
318
+ value: 'stretch',
319
+ icon: justifyStretch,
320
+ label: __( 'Stretch items' ),
321
+ } );
296
322
  }
297
323
 
298
324
  return (
299
325
  <ToggleGroupControl
326
+ __nextHasNoMarginBottom
300
327
  label={ __( 'Justification' ) }
301
328
  value={ justifyContent }
302
329
  onChange={ onJustificationChange }
@@ -333,18 +360,43 @@ function FlexWrapControl( { layout, onChange } ) {
333
360
  }
334
361
 
335
362
  function OrientationControl( { layout, onChange } ) {
336
- const { orientation = 'horizontal' } = layout;
363
+ const {
364
+ orientation = 'horizontal',
365
+ verticalAlignment,
366
+ justifyContent,
367
+ } = layout;
337
368
  return (
338
369
  <ToggleGroupControl
370
+ __nextHasNoMarginBottom
339
371
  className="block-editor-hooks__flex-layout-orientation-controls"
340
372
  label={ __( 'Orientation' ) }
341
373
  value={ orientation }
342
- onChange={ ( value ) =>
343
- onChange( {
374
+ onChange={ ( value ) => {
375
+ // Make sure the vertical alignment and justification are compatible with the new orientation.
376
+ let newVerticalAlignment = verticalAlignment;
377
+ let newJustification = justifyContent;
378
+ if ( value === 'horizontal' ) {
379
+ if ( verticalAlignment === 'space-between' ) {
380
+ newVerticalAlignment = 'center';
381
+ }
382
+ if ( justifyContent === 'stretch' ) {
383
+ newJustification = 'left';
384
+ }
385
+ } else {
386
+ if ( verticalAlignment === 'stretch' ) {
387
+ newVerticalAlignment = 'top';
388
+ }
389
+ if ( justifyContent === 'space-between' ) {
390
+ newJustification = 'left';
391
+ }
392
+ }
393
+ return onChange( {
344
394
  ...layout,
345
395
  orientation: value,
346
- } )
347
- }
396
+ verticalAlignment: newVerticalAlignment,
397
+ justifyContent: newJustification,
398
+ } );
399
+ } }
348
400
  >
349
401
  <ToggleGroupControlOptionIcon
350
402
  icon={ arrowRight }
@@ -67,7 +67,6 @@ export default {
67
67
  info: alignmentInfo[ alignment ],
68
68
  } ) );
69
69
  }
70
- const { contentSize, wideSize } = layout;
71
70
 
72
71
  const alignments = [
73
72
  { name: 'left' },
@@ -75,14 +74,6 @@ export default {
75
74
  { name: 'right' },
76
75
  ];
77
76
 
78
- if ( contentSize ) {
79
- alignments.unshift( { name: 'full' } );
80
- }
81
-
82
- if ( wideSize ) {
83
- alignments.unshift( { name: 'wide', info: alignmentInfo.wide } );
84
- }
85
-
86
77
  alignments.unshift( { name: 'none', info: alignmentInfo.none } );
87
78
 
88
79
  return alignments;
@@ -25,6 +25,7 @@ import {
25
25
  retrieveSelectedAttribute,
26
26
  START_OF_SELECTED_AREA,
27
27
  } from '../utils/selection';
28
+ import { __experimentalUpdateSettings } from './private-actions';
28
29
 
29
30
  /** @typedef {import('../components/use-on-block-drop/types').WPDropOperation} WPDropOperation */
30
31
 
@@ -1263,28 +1264,6 @@ export function toggleBlockMode( clientId ) {
1263
1264
  };
1264
1265
  }
1265
1266
 
1266
- /**
1267
- * Returns an action object used in signalling that the block interface, eg. toolbar, outline, etc. should be hidden.
1268
- *
1269
- * @return {Object} Action object.
1270
- */
1271
- export function __experimentalHideBlockInterface() {
1272
- return {
1273
- type: 'HIDE_BLOCK_INTERFACE',
1274
- };
1275
- }
1276
-
1277
- /**
1278
- * Returns an action object used in signalling that the block interface, eg. toolbar, outline, etc. should be shown.
1279
- *
1280
- * @return {Object} Action object.
1281
- */
1282
- export function __experimentalShowBlockInterface() {
1283
- return {
1284
- type: 'SHOW_BLOCK_INTERFACE',
1285
- };
1286
- }
1287
-
1288
1267
  /**
1289
1268
  * Returns an action object used in signalling that the user has begun to type.
1290
1269
  *
@@ -1442,10 +1421,7 @@ export function updateBlockListSettings( clientId, settings ) {
1442
1421
  * @return {Object} Action object
1443
1422
  */
1444
1423
  export function updateSettings( settings ) {
1445
- return {
1446
- type: 'UPDATE_SETTINGS',
1447
- settings,
1448
- };
1424
+ return __experimentalUpdateSettings( settings, true );
1449
1425
  }
1450
1426
 
1451
1427
  /**
@@ -26,8 +26,9 @@ export const PREFERENCES_DEFAULTS = {
26
26
  * @property {boolean} canLockBlocks Whether the user can manage Block Lock state
27
27
  * @property {boolean} codeEditingEnabled Whether or not the user can switch to the code editor
28
28
  * @property {boolean} generateAnchors Enable/Disable auto anchor generation for Heading blocks
29
+ * @property {boolean} enableOpenverseMediaCategory Enable/Disable the Openverse media category in the inserter.
30
+ * @property {boolean} clearBlockSelection Whether the block editor should clear selection on mousedown when a block is not clicked.
29
31
  * @property {boolean} __experimentalCanUserUseUnfilteredHTML Whether the user should be able to use unfiltered HTML or the HTML should be filtered e.g., to remove elements considered insecure like iframes.
30
- * @property {boolean} __experimentalClearBlockSelection Whether the block editor should clear selection on mousedown when a block is not clicked.
31
32
  * @property {boolean} __experimentalBlockDirectory Whether the user has enabled the Block Directory
32
33
  * @property {Array} __experimentalBlockPatterns Array of objects representing the block patterns
33
34
  * @property {Array} __experimentalBlockPatternCategories Array of objects representing the block pattern categories
@@ -156,8 +157,12 @@ export const SETTINGS_DEFAULTS = {
156
157
  // Allows to disable block locking interface.
157
158
  canLockBlocks: true,
158
159
 
160
+ // Allows to disable Openverse media category in the inserter.
161
+ enableOpenverseMediaCategory: true,
162
+
163
+ clearBlockSelection: true,
164
+
159
165
  __experimentalCanUserUseUnfilteredHTML: false,
160
- __experimentalClearBlockSelection: true,
161
166
  __experimentalBlockDirectory: false,
162
167
  __mobileEnablePageTemplates: false,
163
168
  __experimentalBlockPatterns: [],
@@ -8,8 +8,11 @@ import { createReduxStore, registerStore } from '@wordpress/data';
8
8
  */
9
9
  import reducer from './reducer';
10
10
  import * as selectors from './selectors';
11
+ import * as privateActions from './private-actions';
12
+ import * as privateSelectors from './private-selectors';
11
13
  import * as actions from './actions';
12
14
  import { STORE_NAME } from './constants';
15
+ import { unlock } from '../experiments';
13
16
 
14
17
  /**
15
18
  * Block editor data store configuration.
@@ -32,8 +35,11 @@ export const store = createReduxStore( STORE_NAME, {
32
35
  persist: [ 'preferences' ],
33
36
  } );
34
37
 
35
- // Ideally we'd use register instead of register stores.
36
- registerStore( STORE_NAME, {
38
+ // We will be able to use the `register` function once we switch
39
+ // the "preferences" persistence to use the new preferences package.
40
+ const registeredStore = registerStore( STORE_NAME, {
37
41
  ...storeConfig,
38
42
  persist: [ 'preferences' ],
39
43
  } );
44
+ unlock( registeredStore ).registerPrivateActions( privateActions );
45
+ unlock( registeredStore ).registerPrivateSelectors( privateSelectors );