@wordpress/block-editor 11.4.0 → 11.6.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 (400) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/build/components/block-inspector/index.js +11 -10
  3. package/build/components/block-inspector/index.js.map +1 -1
  4. package/build/components/block-inspector/useBlockInspectorAnimationSettings.js +46 -0
  5. package/build/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
  6. package/build/components/block-list/block-invalid-warning.js +63 -80
  7. package/build/components/block-list/block-invalid-warning.js.map +1 -1
  8. package/build/components/block-lock/modal.js +1 -0
  9. package/build/components/block-lock/modal.js.map +1 -1
  10. package/build/components/block-settings-menu/block-settings-dropdown.js +2 -2
  11. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  12. package/build/components/block-settings-menu-controls/index.js +1 -1
  13. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  14. package/build/components/block-styles/index.js +2 -1
  15. package/build/components/block-styles/index.js.map +1 -1
  16. package/build/components/block-switcher/block-transformations-menu.native.js +1 -0
  17. package/build/components/block-switcher/block-transformations-menu.native.js.map +1 -1
  18. package/build/components/child-layout-control/index.js +107 -0
  19. package/build/components/child-layout-control/index.js.map +1 -0
  20. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
  21. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  22. package/build/components/date-format-picker/index.js +3 -3
  23. package/build/components/date-format-picker/index.js.map +1 -1
  24. package/build/components/global-styles/border-panel.js +306 -0
  25. package/build/components/global-styles/border-panel.js.map +1 -0
  26. package/build/components/global-styles/dimensions-panel.js +594 -0
  27. package/build/components/global-styles/dimensions-panel.js.map +1 -0
  28. package/build/components/global-styles/hooks.js +127 -37
  29. package/build/components/global-styles/hooks.js.map +1 -1
  30. package/build/components/global-styles/index.js +36 -2
  31. package/build/components/global-styles/index.js.map +1 -1
  32. package/build/components/global-styles/typography-panel.js +87 -27
  33. package/build/components/global-styles/typography-panel.js.map +1 -1
  34. package/build/components/global-styles/use-global-styles-output.js +21 -14
  35. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  36. package/build/components/global-styles/utils.js +2 -0
  37. package/build/components/global-styles/utils.js.map +1 -1
  38. package/build/components/index.native.js +23 -0
  39. package/build/components/index.native.js.map +1 -1
  40. package/build/components/inserter/index.js +29 -17
  41. package/build/components/inserter/index.js.map +1 -1
  42. package/build/components/inserter/media-tab/hooks.js +10 -11
  43. package/build/components/inserter/media-tab/hooks.js.map +1 -1
  44. package/build/components/inserter/media-tab/media-list.js +5 -108
  45. package/build/components/inserter/media-tab/media-list.js.map +1 -1
  46. package/build/components/inserter/media-tab/media-preview.js +242 -0
  47. package/build/components/inserter/media-tab/media-preview.js.map +1 -0
  48. package/build/components/inserter/menu.js +1 -1
  49. package/build/components/inserter/menu.js.map +1 -1
  50. package/build/components/inserter/quick-inserter.js +4 -2
  51. package/build/components/inserter/quick-inserter.js.map +1 -1
  52. package/build/components/inserter/search-results.js +10 -3
  53. package/build/components/inserter/search-results.js.map +1 -1
  54. package/build/components/inserter/tabs.js +1 -1
  55. package/build/components/inserter/tabs.js.map +1 -1
  56. package/build/components/inspector-controls/block-support-tools-panel.js +1 -1
  57. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  58. package/build/components/inspector-controls/fill.js +38 -9
  59. package/build/components/inspector-controls/fill.js.map +1 -1
  60. package/build/components/link-control/index.js +1 -1
  61. package/build/components/link-control/index.js.map +1 -1
  62. package/build/components/link-control/search-item.js +5 -2
  63. package/build/components/link-control/search-item.js.map +1 -1
  64. package/build/components/link-control/settings-drawer.js +1 -1
  65. package/build/components/link-control/settings-drawer.js.map +1 -1
  66. package/build/components/link-control/settings.js +1 -0
  67. package/build/components/link-control/settings.js.map +1 -1
  68. package/build/components/list-view/block.js +17 -3
  69. package/build/components/list-view/block.js.map +1 -1
  70. package/build/components/list-view/branch.js +2 -2
  71. package/build/components/list-view/branch.js.map +1 -1
  72. package/build/components/list-view/expander.js +2 -1
  73. package/build/components/list-view/expander.js.map +1 -1
  74. package/build/components/list-view/leaf.js +10 -6
  75. package/build/components/list-view/leaf.js.map +1 -1
  76. package/build/components/list-view/use-block-selection.js +1 -2
  77. package/build/components/list-view/use-block-selection.js.map +1 -1
  78. package/build/components/list-view/use-list-view-scroll-into-view.js +51 -0
  79. package/build/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
  80. package/build/components/off-canvas-editor/appender.js +33 -13
  81. package/build/components/off-canvas-editor/appender.js.map +1 -1
  82. package/build/components/off-canvas-editor/branch.js +6 -3
  83. package/build/components/off-canvas-editor/branch.js.map +1 -1
  84. package/build/components/off-canvas-editor/index.js +8 -2
  85. package/build/components/off-canvas-editor/index.js.map +1 -1
  86. package/build/components/off-canvas-editor/leaf-more-menu.js +34 -4
  87. package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
  88. package/build/components/provider/use-block-sync.js +17 -3
  89. package/build/components/provider/use-block-sync.js.map +1 -1
  90. package/build/components/responsive-block-control/index.js +1 -0
  91. package/build/components/responsive-block-control/index.js.map +1 -1
  92. package/build/components/rich-text/format-toolbar-container.js +0 -3
  93. package/build/components/rich-text/format-toolbar-container.js.map +1 -1
  94. package/build/components/rich-text/index.js +9 -43
  95. package/build/components/rich-text/index.js.map +1 -1
  96. package/build/components/rich-text/use-delete.js +73 -0
  97. package/build/components/rich-text/use-delete.js.map +1 -0
  98. package/build/components/rich-text/use-input-rules.js +14 -6
  99. package/build/components/rich-text/use-input-rules.js.map +1 -1
  100. package/build/components/writing-flow/use-selection-observer.js +4 -1
  101. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  102. package/build/hooks/align.js +3 -1
  103. package/build/hooks/align.js.map +1 -1
  104. package/build/hooks/border.js +91 -240
  105. package/build/hooks/border.js.map +1 -1
  106. package/build/hooks/custom-class-name.js +4 -4
  107. package/build/hooks/custom-class-name.js.map +1 -1
  108. package/build/hooks/custom-class-name.native.js +3 -4
  109. package/build/hooks/custom-class-name.native.js.map +1 -1
  110. package/build/hooks/dimensions.js +72 -190
  111. package/build/hooks/dimensions.js.map +1 -1
  112. package/build/hooks/duotone.js +94 -25
  113. package/build/hooks/duotone.js.map +1 -1
  114. package/build/hooks/gap.js +0 -202
  115. package/build/hooks/gap.js.map +1 -1
  116. package/build/hooks/layout.js +33 -27
  117. package/build/hooks/layout.js.map +1 -1
  118. package/build/hooks/margin.js +7 -163
  119. package/build/hooks/margin.js.map +1 -1
  120. package/build/hooks/padding.js +7 -163
  121. package/build/hooks/padding.js.map +1 -1
  122. package/build/hooks/supports.js +7 -1
  123. package/build/hooks/supports.js.map +1 -1
  124. package/build/hooks/typography.js +52 -66
  125. package/build/hooks/typography.js.map +1 -1
  126. package/build/hooks/utils.js +101 -0
  127. package/build/hooks/utils.js.map +1 -1
  128. package/build/layouts/constrained.js +6 -2
  129. package/build/layouts/constrained.js.map +1 -1
  130. package/build/layouts/flex.js +1 -0
  131. package/build/layouts/flex.js.map +1 -1
  132. package/build/private-apis.js +4 -1
  133. package/build/private-apis.js.map +1 -1
  134. package/build/store/actions.js +28 -14
  135. package/build/store/actions.js.map +1 -1
  136. package/build/store/defaults.js +28 -1
  137. package/build/store/defaults.js.map +1 -1
  138. package/build/store/reducer.js +53 -47
  139. package/build/store/reducer.js.map +1 -1
  140. package/build/store/selectors.js +24 -4
  141. package/build/store/selectors.js.map +1 -1
  142. package/build/utils/parse-css-unit-to-px.js +49 -10
  143. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  144. package/build-module/components/block-inspector/index.js +9 -9
  145. package/build-module/components/block-inspector/index.js.map +1 -1
  146. package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js +37 -0
  147. package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
  148. package/build-module/components/block-list/block-invalid-warning.js +66 -78
  149. package/build-module/components/block-list/block-invalid-warning.js.map +1 -1
  150. package/build-module/components/block-lock/modal.js +1 -0
  151. package/build-module/components/block-lock/modal.js.map +1 -1
  152. package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
  153. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  154. package/build-module/components/block-settings-menu-controls/index.js +1 -1
  155. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  156. package/build-module/components/block-styles/index.js +2 -1
  157. package/build-module/components/block-styles/index.js.map +1 -1
  158. package/build-module/components/block-switcher/block-transformations-menu.native.js +1 -0
  159. package/build-module/components/block-switcher/block-transformations-menu.native.js.map +1 -1
  160. package/build-module/components/child-layout-control/index.js +98 -0
  161. package/build-module/components/child-layout-control/index.js.map +1 -0
  162. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
  163. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  164. package/build-module/components/date-format-picker/index.js +4 -4
  165. package/build-module/components/date-format-picker/index.js.map +1 -1
  166. package/build-module/components/global-styles/border-panel.js +291 -0
  167. package/build-module/components/global-styles/border-panel.js.map +1 -0
  168. package/build-module/components/global-styles/dimensions-panel.js +574 -0
  169. package/build-module/components/global-styles/dimensions-panel.js.map +1 -0
  170. package/build-module/components/global-styles/hooks.js +123 -34
  171. package/build-module/components/global-styles/hooks.js.map +1 -1
  172. package/build-module/components/global-styles/index.js +3 -1
  173. package/build-module/components/global-styles/index.js.map +1 -1
  174. package/build-module/components/global-styles/typography-panel.js +88 -27
  175. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  176. package/build-module/components/global-styles/use-global-styles-output.js +21 -14
  177. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  178. package/build-module/components/global-styles/utils.js +2 -0
  179. package/build-module/components/global-styles/utils.js.map +1 -1
  180. package/build-module/components/index.native.js +2 -1
  181. package/build-module/components/index.native.js.map +1 -1
  182. package/build-module/components/inserter/index.js +28 -16
  183. package/build-module/components/inserter/index.js.map +1 -1
  184. package/build-module/components/inserter/media-tab/hooks.js +10 -11
  185. package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
  186. package/build-module/components/inserter/media-tab/media-list.js +6 -105
  187. package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
  188. package/build-module/components/inserter/media-tab/media-preview.js +222 -0
  189. package/build-module/components/inserter/media-tab/media-preview.js.map +1 -0
  190. package/build-module/components/inserter/menu.js +1 -1
  191. package/build-module/components/inserter/menu.js.map +1 -1
  192. package/build-module/components/inserter/quick-inserter.js +4 -2
  193. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  194. package/build-module/components/inserter/search-results.js +10 -3
  195. package/build-module/components/inserter/search-results.js.map +1 -1
  196. package/build-module/components/inserter/tabs.js +1 -1
  197. package/build-module/components/inserter/tabs.js.map +1 -1
  198. package/build-module/components/inspector-controls/block-support-tools-panel.js +1 -1
  199. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  200. package/build-module/components/inspector-controls/fill.js +39 -9
  201. package/build-module/components/inspector-controls/fill.js.map +1 -1
  202. package/build-module/components/link-control/index.js +1 -1
  203. package/build-module/components/link-control/index.js.map +1 -1
  204. package/build-module/components/link-control/search-item.js +4 -2
  205. package/build-module/components/link-control/search-item.js.map +1 -1
  206. package/build-module/components/link-control/settings-drawer.js +1 -1
  207. package/build-module/components/link-control/settings-drawer.js.map +1 -1
  208. package/build-module/components/link-control/settings.js +1 -0
  209. package/build-module/components/link-control/settings.js.map +1 -1
  210. package/build-module/components/list-view/block.js +16 -3
  211. package/build-module/components/list-view/block.js.map +1 -1
  212. package/build-module/components/list-view/branch.js +2 -2
  213. package/build-module/components/list-view/branch.js.map +1 -1
  214. package/build-module/components/list-view/expander.js +2 -1
  215. package/build-module/components/list-view/expander.js.map +1 -1
  216. package/build-module/components/list-view/leaf.js +8 -4
  217. package/build-module/components/list-view/leaf.js.map +1 -1
  218. package/build-module/components/list-view/use-block-selection.js +1 -2
  219. package/build-module/components/list-view/use-block-selection.js.map +1 -1
  220. package/build-module/components/list-view/use-list-view-scroll-into-view.js +42 -0
  221. package/build-module/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
  222. package/build-module/components/off-canvas-editor/appender.js +33 -14
  223. package/build-module/components/off-canvas-editor/appender.js.map +1 -1
  224. package/build-module/components/off-canvas-editor/branch.js +6 -3
  225. package/build-module/components/off-canvas-editor/branch.js.map +1 -1
  226. package/build-module/components/off-canvas-editor/index.js +8 -2
  227. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  228. package/build-module/components/off-canvas-editor/leaf-more-menu.js +36 -7
  229. package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
  230. package/build-module/components/provider/use-block-sync.js +17 -3
  231. package/build-module/components/provider/use-block-sync.js.map +1 -1
  232. package/build-module/components/responsive-block-control/index.js +1 -0
  233. package/build-module/components/responsive-block-control/index.js.map +1 -1
  234. package/build-module/components/rich-text/format-toolbar-container.js +0 -3
  235. package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
  236. package/build-module/components/rich-text/index.js +9 -43
  237. package/build-module/components/rich-text/index.js.map +1 -1
  238. package/build-module/components/rich-text/use-delete.js +62 -0
  239. package/build-module/components/rich-text/use-delete.js.map +1 -0
  240. package/build-module/components/rich-text/use-input-rules.js +14 -6
  241. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  242. package/build-module/components/writing-flow/use-selection-observer.js +4 -1
  243. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  244. package/build-module/hooks/align.js +3 -1
  245. package/build-module/hooks/align.js.map +1 -1
  246. package/build-module/hooks/border.js +93 -240
  247. package/build-module/hooks/border.js.map +1 -1
  248. package/build-module/hooks/custom-class-name.js +4 -4
  249. package/build-module/hooks/custom-class-name.js.map +1 -1
  250. package/build-module/hooks/custom-class-name.native.js +3 -4
  251. package/build-module/hooks/custom-class-name.native.js.map +1 -1
  252. package/build-module/hooks/dimensions.js +75 -187
  253. package/build-module/hooks/dimensions.js.map +1 -1
  254. package/build-module/hooks/duotone.js +86 -24
  255. package/build-module/hooks/duotone.js.map +1 -1
  256. package/build-module/hooks/gap.js +0 -183
  257. package/build-module/hooks/gap.js.map +1 -1
  258. package/build-module/hooks/layout.js +33 -27
  259. package/build-module/hooks/layout.js.map +1 -1
  260. package/build-module/hooks/margin.js +4 -143
  261. package/build-module/hooks/margin.js.map +1 -1
  262. package/build-module/hooks/padding.js +4 -143
  263. package/build-module/hooks/padding.js.map +1 -1
  264. package/build-module/hooks/supports.js +7 -1
  265. package/build-module/hooks/supports.js.map +1 -1
  266. package/build-module/hooks/typography.js +54 -66
  267. package/build-module/hooks/typography.js.map +1 -1
  268. package/build-module/hooks/utils.js +96 -0
  269. package/build-module/hooks/utils.js.map +1 -1
  270. package/build-module/layouts/constrained.js +6 -2
  271. package/build-module/layouts/constrained.js.map +1 -1
  272. package/build-module/layouts/flex.js +1 -0
  273. package/build-module/layouts/flex.js.map +1 -1
  274. package/build-module/private-apis.js +3 -1
  275. package/build-module/private-apis.js.map +1 -1
  276. package/build-module/store/actions.js +28 -14
  277. package/build-module/store/actions.js.map +1 -1
  278. package/build-module/store/defaults.js +28 -1
  279. package/build-module/store/defaults.js.map +1 -1
  280. package/build-module/store/reducer.js +53 -45
  281. package/build-module/store/reducer.js.map +1 -1
  282. package/build-module/store/selectors.js +22 -4
  283. package/build-module/store/selectors.js.map +1 -1
  284. package/build-module/utils/parse-css-unit-to-px.js +49 -10
  285. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  286. package/build-style/style-rtl.css +39 -27
  287. package/build-style/style.css +39 -27
  288. package/package.json +31 -31
  289. package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +24 -24
  290. package/src/components/block-inspector/index.js +11 -14
  291. package/src/components/block-inspector/style.scss +3 -0
  292. package/src/components/block-inspector/useBlockInspectorAnimationSettings.js +53 -0
  293. package/src/components/block-list/block-invalid-warning.js +72 -64
  294. package/src/components/block-lock/modal.js +1 -0
  295. package/src/components/block-lock/style.scss +0 -9
  296. package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +20 -20
  297. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +35 -17
  298. package/src/components/block-preview/test/index.js +0 -2
  299. package/src/components/block-settings-menu/block-settings-dropdown.js +4 -1
  300. package/src/components/block-settings-menu-controls/index.js +2 -1
  301. package/src/components/block-styles/index.js +5 -1
  302. package/src/components/block-styles/style.scss +2 -2
  303. package/src/components/block-switcher/block-transformations-menu.native.js +1 -0
  304. package/src/components/child-layout-control/index.js +106 -0
  305. package/src/components/color-palette/test/__snapshots__/control.js.snap +17 -15
  306. package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +48 -38
  307. package/src/components/date-format-picker/index.js +6 -8
  308. package/src/components/date-format-picker/style.scss +0 -5
  309. package/src/components/global-styles/border-panel.js +285 -0
  310. package/src/components/global-styles/dimensions-panel.js +627 -0
  311. package/src/components/global-styles/hooks.js +160 -44
  312. package/src/components/global-styles/index.js +7 -1
  313. package/src/components/global-styles/test/use-global-styles-output.js +1 -1
  314. package/src/components/global-styles/typography-panel.js +81 -9
  315. package/src/components/global-styles/use-global-styles-output.js +17 -16
  316. package/src/components/global-styles/utils.js +2 -0
  317. package/src/components/index.native.js +5 -0
  318. package/src/components/inner-blocks/test/__snapshots__/index.js.snap +1 -1
  319. package/src/components/inserter/index.js +30 -11
  320. package/src/components/inserter/media-tab/hooks.js +9 -8
  321. package/src/components/inserter/media-tab/media-list.js +3 -122
  322. package/src/components/inserter/media-tab/media-preview.js +268 -0
  323. package/src/components/inserter/menu.js +0 -1
  324. package/src/components/inserter/quick-inserter.js +2 -0
  325. package/src/components/inserter/search-results.js +7 -1
  326. package/src/components/inserter/style.scss +25 -0
  327. package/src/components/inserter/tabs.js +1 -9
  328. package/src/components/inserter/test/__snapshots__/index.native.js.snap +15 -15
  329. package/src/components/inspector-controls/block-support-tools-panel.js +0 -1
  330. package/src/components/inspector-controls/fill.js +32 -8
  331. package/src/components/link-control/index.js +1 -1
  332. package/src/components/link-control/search-item.js +3 -1
  333. package/src/components/link-control/settings-drawer.js +2 -1
  334. package/src/components/link-control/settings.js +1 -0
  335. package/src/components/link-control/style.scss +18 -12
  336. package/src/components/link-control/test/index.js +3 -5
  337. package/src/components/list-view/block.js +19 -1
  338. package/src/components/list-view/branch.js +1 -2
  339. package/src/components/list-view/expander.js +1 -0
  340. package/src/components/list-view/leaf.js +43 -29
  341. package/src/components/list-view/use-block-selection.js +0 -2
  342. package/src/components/list-view/use-list-view-scroll-into-view.js +48 -0
  343. package/src/components/media-replace-flow/style.scss +7 -9
  344. package/src/components/off-canvas-editor/appender.js +44 -21
  345. package/src/components/off-canvas-editor/branch.js +4 -1
  346. package/src/components/off-canvas-editor/index.js +7 -1
  347. package/src/components/off-canvas-editor/leaf-more-menu.js +57 -15
  348. package/src/components/provider/use-block-sync.js +21 -4
  349. package/src/components/responsive-block-control/index.js +1 -0
  350. package/src/components/rich-text/format-toolbar-container.js +1 -7
  351. package/src/components/rich-text/index.js +8 -44
  352. package/src/components/rich-text/use-delete.js +59 -0
  353. package/src/components/rich-text/use-input-rules.js +13 -5
  354. package/src/components/spacing-sizes-control/style.scss +1 -1
  355. package/src/components/url-popover/stories/index.js +1 -0
  356. package/src/components/url-popover/test/index.js +0 -2
  357. package/src/components/writing-flow/use-selection-observer.js +5 -1
  358. package/src/hooks/align.js +1 -1
  359. package/src/hooks/border.js +94 -225
  360. package/src/hooks/custom-class-name.js +4 -4
  361. package/src/hooks/custom-class-name.native.js +3 -4
  362. package/src/hooks/dimensions.js +85 -269
  363. package/src/hooks/duotone.js +100 -30
  364. package/src/hooks/gap.js +0 -208
  365. package/src/hooks/layout.js +38 -22
  366. package/src/hooks/margin.js +1 -164
  367. package/src/hooks/padding.js +1 -163
  368. package/src/hooks/supports.js +6 -0
  369. package/src/hooks/test/__snapshots__/align.native.js.snap +24 -24
  370. package/src/hooks/test/duotone.js +102 -0
  371. package/src/hooks/test/style.js +2 -1
  372. package/src/hooks/test/use-typography-props.js +2 -0
  373. package/src/hooks/typography.js +68 -88
  374. package/src/hooks/utils.js +126 -0
  375. package/src/layouts/constrained.js +23 -17
  376. package/src/layouts/flex.js +1 -0
  377. package/src/private-apis.js +2 -0
  378. package/src/store/actions.js +16 -6
  379. package/src/store/defaults.js +14 -1
  380. package/src/store/reducer.js +68 -43
  381. package/src/store/selectors.js +28 -4
  382. package/src/store/test/actions.js +4 -2
  383. package/src/utils/parse-css-unit-to-px.js +48 -13
  384. package/src/utils/test/parse-css-unit-to-px.js +13 -2
  385. package/tsconfig.tsbuildinfo +1 -1
  386. package/build/hooks/border-radius.js +0 -100
  387. package/build/hooks/border-radius.js.map +0 -1
  388. package/build/hooks/child-layout.js +0 -213
  389. package/build/hooks/child-layout.js.map +0 -1
  390. package/build/hooks/min-height.js +0 -139
  391. package/build/hooks/min-height.js.map +0 -1
  392. package/build-module/hooks/border-radius.js +0 -84
  393. package/build-module/hooks/border-radius.js.map +0 -1
  394. package/build-module/hooks/child-layout.js +0 -193
  395. package/build-module/hooks/child-layout.js.map +0 -1
  396. package/build-module/hooks/min-height.js +0 -116
  397. package/build-module/hooks/min-height.js.map +0 -1
  398. package/src/hooks/border-radius.js +0 -70
  399. package/src/hooks/child-layout.js +0 -195
  400. package/src/hooks/min-height.js +0 -104
@@ -20,6 +20,11 @@ const FONT_STYLE_SUPPORT_KEY = 'typography.__experimentalFontStyle';
20
20
  * Key within block settings' support array indicating support for font weight.
21
21
  */
22
22
  const FONT_WEIGHT_SUPPORT_KEY = 'typography.__experimentalFontWeight';
23
+ /**
24
+ * Key within block settings' supports array indicating support for text
25
+ * columns e.g. settings found in `block.json`.
26
+ */
27
+ const TEXT_COLUMNS_SUPPORT_KEY = 'typography.textColumns';
23
28
  /**
24
29
  * Key within block settings' supports array indicating support for text
25
30
  * decorations e.g. settings found in `block.json`.
@@ -42,6 +47,7 @@ const TYPOGRAPHY_SUPPORT_KEYS = [
42
47
  FONT_STYLE_SUPPORT_KEY,
43
48
  FONT_WEIGHT_SUPPORT_KEY,
44
49
  FONT_FAMILY_SUPPORT_KEY,
50
+ TEXT_COLUMNS_SUPPORT_KEY,
45
51
  TEXT_DECORATION_SUPPORT_KEY,
46
52
  TEXT_TRANSFORM_SUPPORT_KEY,
47
53
  LETTER_SPACING_SUPPORT_KEY,
@@ -1,73 +1,73 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`Align options for group block sets Full width option 1`] = `
4
- "<!-- wp:group {\\"align\\":\\"full\\",\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
5
- <div class=\\"wp-block-group alignfull\\"></div>
4
+ "<!-- wp:group {"align":"full","layout":{"type":"constrained"}} -->
5
+ <div class="wp-block-group alignfull"></div>
6
6
  <!-- /wp:group -->"
7
7
  `;
8
8
 
9
9
  exports[`Align options for group block sets None option 1`] = `
10
- "<!-- wp:group {\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
11
- <div class=\\"wp-block-group\\"></div>
10
+ "<!-- wp:group {"layout":{"type":"constrained"}} -->
11
+ <div class="wp-block-group"></div>
12
12
  <!-- /wp:group -->"
13
13
  `;
14
14
 
15
15
  exports[`Align options for group block sets Wide width option 1`] = `
16
- "<!-- wp:group {\\"align\\":\\"wide\\",\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
17
- <div class=\\"wp-block-group alignwide\\"></div>
16
+ "<!-- wp:group {"align":"wide","layout":{"type":"constrained"}} -->
17
+ <div class="wp-block-group alignwide"></div>
18
18
  <!-- /wp:group -->"
19
19
  `;
20
20
 
21
21
  exports[`Align options for media block sets Align center option 1`] = `
22
- "<!-- wp:image {\\"align\\":\\"center\\",\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
23
- <figure class=\\"wp-block-image aligncenter size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
22
+ "<!-- wp:image {"align":"center","id":1,"sizeSlug":"large","linkDestination":"none"} -->
23
+ <figure class="wp-block-image aligncenter size-large"><img src="https://test-site.files.wordpress.com/local-image-1.jpeg" alt="" class="wp-image-1"/></figure>
24
24
  <!-- /wp:image -->"
25
25
  `;
26
26
 
27
27
  exports[`Align options for media block sets Align left option 1`] = `
28
- "<!-- wp:image {\\"align\\":\\"left\\",\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
29
- <figure class=\\"wp-block-image alignleft size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
28
+ "<!-- wp:image {"align":"left","id":1,"sizeSlug":"large","linkDestination":"none"} -->
29
+ <figure class="wp-block-image alignleft size-large"><img src="https://test-site.files.wordpress.com/local-image-1.jpeg" alt="" class="wp-image-1"/></figure>
30
30
  <!-- /wp:image -->"
31
31
  `;
32
32
 
33
33
  exports[`Align options for media block sets Align right option 1`] = `
34
- "<!-- wp:image {\\"align\\":\\"right\\",\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
35
- <figure class=\\"wp-block-image alignright size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
34
+ "<!-- wp:image {"align":"right","id":1,"sizeSlug":"large","linkDestination":"none"} -->
35
+ <figure class="wp-block-image alignright size-large"><img src="https://test-site.files.wordpress.com/local-image-1.jpeg" alt="" class="wp-image-1"/></figure>
36
36
  <!-- /wp:image -->"
37
37
  `;
38
38
 
39
39
  exports[`Align options for media block sets Full width option 1`] = `
40
- "<!-- wp:image {\\"align\\":\\"full\\",\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
41
- <figure class=\\"wp-block-image alignfull size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
40
+ "<!-- wp:image {"align":"full","id":1,"sizeSlug":"large","linkDestination":"none"} -->
41
+ <figure class="wp-block-image alignfull size-large"><img src="https://test-site.files.wordpress.com/local-image-1.jpeg" alt="" class="wp-image-1"/></figure>
42
42
  <!-- /wp:image -->"
43
43
  `;
44
44
 
45
45
  exports[`Align options for media block sets None option 1`] = `
46
- "<!-- wp:image {\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
47
- <figure class=\\"wp-block-image size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
46
+ "<!-- wp:image {"id":1,"sizeSlug":"large","linkDestination":"none"} -->
47
+ <figure class="wp-block-image size-large"><img src="https://test-site.files.wordpress.com/local-image-1.jpeg" alt="" class="wp-image-1"/></figure>
48
48
  <!-- /wp:image -->"
49
49
  `;
50
50
 
51
51
  exports[`Align options for media block sets Wide width option 1`] = `
52
- "<!-- wp:image {\\"align\\":\\"wide\\",\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
53
- <figure class=\\"wp-block-image alignwide size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
52
+ "<!-- wp:image {"align":"wide","id":1,"sizeSlug":"large","linkDestination":"none"} -->
53
+ <figure class="wp-block-image alignwide size-large"><img src="https://test-site.files.wordpress.com/local-image-1.jpeg" alt="" class="wp-image-1"/></figure>
54
54
  <!-- /wp:image -->"
55
55
  `;
56
56
 
57
57
  exports[`Align options for text block sets Align text center option 1`] = `
58
- "<!-- wp:paragraph {\\"align\\":\\"center\\"} -->
59
- <p class=\\"has-text-align-center\\"></p>
58
+ "<!-- wp:paragraph {"align":"center"} -->
59
+ <p class="has-text-align-center"></p>
60
60
  <!-- /wp:paragraph -->"
61
61
  `;
62
62
 
63
63
  exports[`Align options for text block sets Align text left option 1`] = `
64
- "<!-- wp:paragraph {\\"align\\":\\"left\\"} -->
65
- <p class=\\"has-text-align-left\\"></p>
64
+ "<!-- wp:paragraph {"align":"left"} -->
65
+ <p class="has-text-align-left"></p>
66
66
  <!-- /wp:paragraph -->"
67
67
  `;
68
68
 
69
69
  exports[`Align options for text block sets Align text right option 1`] = `
70
- "<!-- wp:paragraph {\\"align\\":\\"right\\"} -->
71
- <p class=\\"has-text-align-right\\"></p>
70
+ "<!-- wp:paragraph {"align":"right"} -->
71
+ <p class="has-text-align-right"></p>
72
72
  <!-- /wp:paragraph -->"
73
73
  `;
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import {
5
+ getColorsFromDuotonePreset,
6
+ getDuotonePresetFromColors,
7
+ } from '../duotone';
8
+
9
+ describe( 'Duotone utilities', () => {
10
+ const duotonePalette = [
11
+ {
12
+ name: 'Dark grayscale',
13
+ colors: [ '#000000', '#7f7f7f' ],
14
+ slug: 'dark-grayscale',
15
+ },
16
+ {
17
+ name: 'Grayscale',
18
+ colors: [ '#000000', '#ffffff' ],
19
+ slug: 'grayscale',
20
+ },
21
+ {
22
+ name: 'Purple and yellow',
23
+ colors: [ '#8c00b7', '#fcff41' ],
24
+ slug: 'purple-yellow',
25
+ },
26
+ ];
27
+ describe( 'getColorsFromDuotonePreset', () => {
28
+ it( 'should return undefined if no arguments are provided', () => {
29
+ expect( getColorsFromDuotonePreset() ).toBeUndefined();
30
+ } );
31
+
32
+ it( 'should return undefined if no duotone preset is provided', () => {
33
+ expect(
34
+ getColorsFromDuotonePreset( undefined, duotonePalette )
35
+ ).toBeUndefined();
36
+ } );
37
+
38
+ it( 'should return undefined if a non-existent preset is provided', () => {
39
+ expect(
40
+ getColorsFromDuotonePreset(
41
+ `var:preset|duotone|does-not-exist`,
42
+ duotonePalette
43
+ )
44
+ ).toBeUndefined();
45
+ } );
46
+
47
+ it( 'should return the colors from the preset if found', () => {
48
+ expect(
49
+ getColorsFromDuotonePreset(
50
+ `var:preset|duotone|${ duotonePalette[ 2 ].slug }`,
51
+ duotonePalette
52
+ )
53
+ ).toEqual( duotonePalette[ 2 ].colors );
54
+ } );
55
+ } );
56
+
57
+ describe( 'getDuotonePresetFromColors', () => {
58
+ it( 'should return undefined if no arguments are provided', () => {
59
+ expect( getDuotonePresetFromColors() ).toBeUndefined();
60
+ } );
61
+
62
+ it( 'should return undefined if no colors are provided', () => {
63
+ expect(
64
+ getDuotonePresetFromColors( undefined, duotonePalette )
65
+ ).toBeUndefined();
66
+ } );
67
+
68
+ it( 'should return undefined if provided colors is not of valid type', () => {
69
+ const notAnArrayOfColorStrings = 'purple-yellow';
70
+ expect(
71
+ getDuotonePresetFromColors(
72
+ notAnArrayOfColorStrings,
73
+ duotonePalette
74
+ )
75
+ ).toBeUndefined();
76
+ } );
77
+
78
+ it( 'should return undefined if no duotone palette is provided', () => {
79
+ expect(
80
+ getDuotonePresetFromColors( [ '#8c00b7', '#fcff41' ] )
81
+ ).toBeUndefined();
82
+ } );
83
+
84
+ it( 'should return undefined if the provided colors do not match any preset', () => {
85
+ expect(
86
+ getDuotonePresetFromColors(
87
+ [ '#000000', '#000000' ],
88
+ duotonePalette
89
+ )
90
+ ).toBeUndefined();
91
+ } );
92
+
93
+ it( 'should return the slug of the preset if found', () => {
94
+ expect(
95
+ getDuotonePresetFromColors(
96
+ duotonePalette[ 2 ].colors,
97
+ duotonePalette
98
+ )
99
+ ).toEqual( `var:preset|duotone|${ duotonePalette[ 2 ].slug }` );
100
+ } );
101
+ } );
102
+ } );
@@ -21,7 +21,7 @@ describe( 'getInlineStyles', () => {
21
21
  expect(
22
22
  getInlineStyles( {
23
23
  color: { text: 'red', background: 'black' },
24
- typography: { lineHeight: 1.5, fontSize: 10 },
24
+ typography: { lineHeight: 1.5, fontSize: 10, textColumns: 2 },
25
25
  border: {
26
26
  radius: '10px',
27
27
  width: '1em',
@@ -44,6 +44,7 @@ describe( 'getInlineStyles', () => {
44
44
  borderStyle: 'dotted',
45
45
  borderWidth: '1em',
46
46
  color: 'red',
47
+ columnCount: 2,
47
48
  lineHeight: 1.5,
48
49
  fontSize: 10,
49
50
  marginBottom: '15px',
@@ -12,6 +12,7 @@ describe( 'getTypographyClassesAndStyles', () => {
12
12
  typography: {
13
13
  letterSpacing: '22px',
14
14
  fontSize: '2rem',
15
+ textColumns: 3,
15
16
  textTransform: 'uppercase',
16
17
  },
17
18
  },
@@ -19,6 +20,7 @@ describe( 'getTypographyClassesAndStyles', () => {
19
20
  expect( getTypographyClassesAndStyles( attributes ) ).toEqual( {
20
21
  className: 'has-tofu-font-family has-large-font-size',
21
22
  style: {
23
+ columnCount: 3,
22
24
  letterSpacing: '22px',
23
25
  fontSize: '2rem',
24
26
  textTransform: 'uppercase',
@@ -2,7 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';
5
- import { useMemo } from '@wordpress/element';
5
+ import { useMemo, useCallback } from '@wordpress/element';
6
6
 
7
7
  /**
8
8
  * Internal dependencies
@@ -16,12 +16,7 @@ import {
16
16
  import { LINE_HEIGHT_SUPPORT_KEY } from './line-height';
17
17
  import { FONT_FAMILY_SUPPORT_KEY } from './font-family';
18
18
  import { FONT_SIZE_SUPPORT_KEY } from './font-size';
19
- import { useSetting } from '../components';
20
- import { cleanEmptyObject } from './utils';
21
- import {
22
- overrideSettingsWithSupports,
23
- useSupportedStyles,
24
- } from '../components/global-styles/hooks';
19
+ import { cleanEmptyObject, useBlockSettings } from './utils';
25
20
 
26
21
  function omit( object, keys ) {
27
22
  return Object.fromEntries(
@@ -32,6 +27,7 @@ function omit( object, keys ) {
32
27
  const LETTER_SPACING_SUPPORT_KEY = 'typography.__experimentalLetterSpacing';
33
28
  const TEXT_TRANSFORM_SUPPORT_KEY = 'typography.__experimentalTextTransform';
34
29
  const TEXT_DECORATION_SUPPORT_KEY = 'typography.__experimentalTextDecoration';
30
+ const TEXT_COLUMNS_SUPPORT_KEY = 'typography.textColumns';
35
31
  const FONT_STYLE_SUPPORT_KEY = 'typography.__experimentalFontStyle';
36
32
  const FONT_WEIGHT_SUPPORT_KEY = 'typography.__experimentalFontWeight';
37
33
  export const TYPOGRAPHY_SUPPORT_KEY = 'typography';
@@ -41,60 +37,71 @@ export const TYPOGRAPHY_SUPPORT_KEYS = [
41
37
  FONT_STYLE_SUPPORT_KEY,
42
38
  FONT_WEIGHT_SUPPORT_KEY,
43
39
  FONT_FAMILY_SUPPORT_KEY,
40
+ TEXT_COLUMNS_SUPPORT_KEY,
44
41
  TEXT_DECORATION_SUPPORT_KEY,
45
42
  TEXT_TRANSFORM_SUPPORT_KEY,
46
43
  LETTER_SPACING_SUPPORT_KEY,
47
44
  ];
48
45
 
49
- function TypographyInspectorControl( { children } ) {
50
- return (
51
- <InspectorControls group="typography">{ children }</InspectorControls>
52
- );
46
+ function styleToAttributes( style ) {
47
+ const updatedStyle = { ...omit( style, [ 'fontFamily' ] ) };
48
+ const fontSizeValue = style?.typography?.fontSize;
49
+ const fontFamilyValue = style?.typography?.fontFamily;
50
+ const fontSizeSlug = fontSizeValue?.startsWith( 'var:preset|font-size|' )
51
+ ? fontSizeValue.substring( 'var:preset|font-size|'.length )
52
+ : undefined;
53
+ const fontFamilySlug = fontFamilyValue?.startsWith(
54
+ 'var:preset|font-family|'
55
+ )
56
+ ? fontFamilyValue.substring( 'var:preset|font-family|'.length )
57
+ : undefined;
58
+ updatedStyle.typography = {
59
+ ...omit( updatedStyle.typography, [ 'fontFamily' ] ),
60
+ fontSize: fontSizeSlug ? undefined : fontSizeValue,
61
+ };
62
+ return {
63
+ style: cleanEmptyObject( updatedStyle ),
64
+ fontFamily: fontFamilySlug,
65
+ fontSize: fontSizeSlug,
66
+ };
67
+ }
68
+
69
+ function attributesToStyle( attributes ) {
70
+ return {
71
+ ...attributes.style,
72
+ typography: {
73
+ ...attributes.style?.typography,
74
+ fontFamily: attributes.fontFamily
75
+ ? 'var:preset|font-family|' + attributes.fontFamily
76
+ : undefined,
77
+ fontSize: attributes.fontSize
78
+ ? 'var:preset|font-size|' + attributes.fontSize
79
+ : attributes.style?.typography?.fontSize,
80
+ },
81
+ };
53
82
  }
54
83
 
55
- function useBlockSettings( name ) {
56
- const fontFamilies = useSetting( 'typography.fontFamilies' );
57
- const fontSizes = useSetting( 'typography.fontSizes' );
58
- const customFontSize = useSetting( 'typography.customFontSize' );
59
- const fontStyle = useSetting( 'typography.fontStyle' );
60
- const fontWeight = useSetting( 'typography.fontWeight' );
61
- const lineHeight = useSetting( 'typography.lineHeight' );
62
- const textDecoration = useSetting( 'typography.textDecoration' );
63
- const textTransform = useSetting( 'typography.textTransform' );
64
- const letterSpacing = useSetting( 'typography.letterSpacing' );
65
- const supports = useSupportedStyles( name, null );
84
+ function TypographyInspectorControl( { children, resetAllFilter } ) {
85
+ const attributesResetAllFilter = useCallback(
86
+ ( attributes ) => {
87
+ const existingStyle = attributesToStyle( attributes );
88
+ const updatedStyle = resetAllFilter( existingStyle );
89
+ return {
90
+ ...attributes,
91
+ ...styleToAttributes( updatedStyle ),
92
+ };
93
+ },
94
+ [ resetAllFilter ]
95
+ );
66
96
 
67
- return useMemo( () => {
68
- const rawSettings = {
69
- typography: {
70
- fontFamilies: {
71
- custom: fontFamilies,
72
- },
73
- fontSizes: {
74
- custom: fontSizes,
75
- },
76
- customFontSize,
77
- fontStyle,
78
- fontWeight,
79
- lineHeight,
80
- textDecoration,
81
- textTransform,
82
- letterSpacing,
83
- },
84
- };
85
- return overrideSettingsWithSupports( rawSettings, supports );
86
- }, [
87
- fontFamilies,
88
- fontSizes,
89
- customFontSize,
90
- fontStyle,
91
- fontWeight,
92
- lineHeight,
93
- textDecoration,
94
- textTransform,
95
- letterSpacing,
96
- supports,
97
- ] );
97
+ return (
98
+ <InspectorControls
99
+ group="typography"
100
+ resetAllFilter={ attributesResetAllFilter }
101
+ >
102
+ { children }
103
+ </InspectorControls>
104
+ );
98
105
  }
99
106
 
100
107
  export function TypographyPanel( {
@@ -102,47 +109,20 @@ export function TypographyPanel( {
102
109
  name,
103
110
  attributes,
104
111
  setAttributes,
112
+ __unstableParentLayout,
105
113
  } ) {
106
- const settings = useBlockSettings( name );
114
+ const settings = useBlockSettings( name, __unstableParentLayout );
107
115
  const isEnabled = useHasTypographyPanel( settings );
108
116
  const value = useMemo( () => {
109
- return {
110
- ...attributes.style,
111
- typography: {
112
- ...attributes.style?.typography,
113
- fontFamily: attributes.fontFamily
114
- ? 'var:preset|font-family|' + attributes.fontFamily
115
- : undefined,
116
- fontSize: attributes.fontSize
117
- ? 'var:preset|font-size|' + attributes.fontSize
118
- : attributes.style?.typography?.fontSize,
119
- },
120
- };
117
+ return attributesToStyle( {
118
+ style: attributes.style,
119
+ fontFamily: attributes.fontFamily,
120
+ fontSize: attributes.fontSize,
121
+ } );
121
122
  }, [ attributes.style, attributes.fontSize, attributes.fontFamily ] );
122
123
 
123
124
  const onChange = ( newStyle ) => {
124
- const updatedStyle = { ...omit( newStyle, [ 'fontFamily' ] ) };
125
- const fontSizeValue = newStyle?.typography?.fontSize;
126
- const fontFamilyValue = newStyle?.typography?.fontFamily;
127
- const fontSizeSlug = fontSizeValue?.startsWith(
128
- 'var:preset|font-size|'
129
- )
130
- ? fontSizeValue.substring( 'var:preset|font-size|'.length )
131
- : undefined;
132
- const fontFamilySlug = fontFamilyValue?.startsWith(
133
- 'var:preset|font-family|'
134
- )
135
- ? fontFamilyValue.substring( 'var:preset|font-family|'.length )
136
- : undefined;
137
- updatedStyle.typography = {
138
- ...omit( updatedStyle.typography, [ 'fontFamily' ] ),
139
- fontSize: fontSizeSlug ? undefined : fontSizeValue,
140
- };
141
- setAttributes( {
142
- style: cleanEmptyObject( updatedStyle ),
143
- fontFamily: fontFamilySlug,
144
- fontSize: fontSizeSlug,
145
- } );
125
+ setAttributes( styleToAttributes( newStyle ) );
146
126
  };
147
127
 
148
128
  if ( ! isEnabled ) {
@@ -7,6 +7,13 @@ import { isEmpty, mapValues, get } from 'lodash';
7
7
  * WordPress dependencies
8
8
  */
9
9
  import { getBlockSupport } from '@wordpress/blocks';
10
+ import { useMemo } from '@wordpress/element';
11
+
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+ import { useSetting } from '../components';
16
+ import { useSettingsForBlockElement } from '../components/global-styles/hooks';
10
17
 
11
18
  /**
12
19
  * Removed falsy values from nested object.
@@ -177,3 +184,122 @@ export function shouldSkipSerialization( blockType, featureSet, feature ) {
177
184
 
178
185
  return skipSerialization;
179
186
  }
187
+
188
+ /**
189
+ * Based on the block and its context, returns an object of all the block settings.
190
+ * This object can be passed as a prop to all the Styles UI components
191
+ * (TypographyPanel, DimensionsPanel...).
192
+ *
193
+ * @param {string} name Block name.
194
+ * @param {*} parentLayout Parent layout.
195
+ *
196
+ * @return {Object} Settings object.
197
+ */
198
+ export function useBlockSettings( name, parentLayout ) {
199
+ const fontFamilies = useSetting( 'typography.fontFamilies' );
200
+ const fontSizes = useSetting( 'typography.fontSizes' );
201
+ const customFontSize = useSetting( 'typography.customFontSize' );
202
+ const fontStyle = useSetting( 'typography.fontStyle' );
203
+ const fontWeight = useSetting( 'typography.fontWeight' );
204
+ const lineHeight = useSetting( 'typography.lineHeight' );
205
+ const textColumns = useSetting( 'typography.textColumns' );
206
+ const textDecoration = useSetting( 'typography.textDecoration' );
207
+ const textTransform = useSetting( 'typography.textTransform' );
208
+ const letterSpacing = useSetting( 'typography.letterSpacing' );
209
+ const padding = useSetting( 'spacing.padding' );
210
+ const margin = useSetting( 'spacing.margin' );
211
+ const blockGap = useSetting( 'spacing.blockGap' );
212
+ const spacingSizes = useSetting( 'spacing.spacingSizes' );
213
+ const units = useSetting( 'spacing.units' );
214
+ const minHeight = useSetting( 'dimensions.minHeight' );
215
+ const layout = useSetting( 'layout' );
216
+ const borderColor = useSetting( 'border.color' );
217
+ const borderRadius = useSetting( 'border.radius' );
218
+ const borderStyle = useSetting( 'border.style' );
219
+ const borderWidth = useSetting( 'border.width' );
220
+ const customColorsEnabled = useSetting( 'color.custom' );
221
+ const customColors = useSetting( 'color.palette.custom' );
222
+ const themeColors = useSetting( 'color.palette.theme' );
223
+ const defaultColors = useSetting( 'color.palette.default' );
224
+ const defaultPalette = useSetting( 'color.defaultPalette' );
225
+
226
+ const rawSettings = useMemo( () => {
227
+ return {
228
+ color: {
229
+ palette: {
230
+ custom: customColors,
231
+ theme: themeColors,
232
+ default: defaultColors,
233
+ },
234
+ defaultPalette,
235
+ custom: customColorsEnabled,
236
+ },
237
+ typography: {
238
+ fontFamilies: {
239
+ custom: fontFamilies,
240
+ },
241
+ fontSizes: {
242
+ custom: fontSizes,
243
+ },
244
+ customFontSize,
245
+ fontStyle,
246
+ fontWeight,
247
+ lineHeight,
248
+ textColumns,
249
+ textDecoration,
250
+ textTransform,
251
+ letterSpacing,
252
+ },
253
+ spacing: {
254
+ spacingSizes: {
255
+ custom: spacingSizes,
256
+ },
257
+ padding,
258
+ margin,
259
+ blockGap,
260
+ units,
261
+ },
262
+ border: {
263
+ color: borderColor,
264
+ radius: borderRadius,
265
+ style: borderStyle,
266
+ width: borderWidth,
267
+ },
268
+ dimensions: {
269
+ minHeight,
270
+ },
271
+ layout,
272
+ parentLayout,
273
+ };
274
+ }, [
275
+ fontFamilies,
276
+ fontSizes,
277
+ customFontSize,
278
+ fontStyle,
279
+ fontWeight,
280
+ lineHeight,
281
+ textColumns,
282
+ textDecoration,
283
+ textTransform,
284
+ letterSpacing,
285
+ padding,
286
+ margin,
287
+ blockGap,
288
+ spacingSizes,
289
+ units,
290
+ minHeight,
291
+ layout,
292
+ parentLayout,
293
+ borderColor,
294
+ borderRadius,
295
+ borderStyle,
296
+ borderWidth,
297
+ customColorsEnabled,
298
+ customColors,
299
+ themeColors,
300
+ defaultColors,
301
+ defaultPalette,
302
+ ] );
303
+
304
+ return useSettingsForBlockElement( rawSettings, name );
305
+ }
@@ -32,8 +32,10 @@ export default {
32
32
  inspectorControls: function DefaultLayoutInspectorControls( {
33
33
  layout,
34
34
  onChange,
35
+ layoutBlockSupport = {},
35
36
  } ) {
36
37
  const { wideSize, contentSize, justifyContent = 'center' } = layout;
38
+ const { allowJustification = true } = layoutBlockSupport;
37
39
  const onJustificationChange = ( value ) => {
38
40
  onChange( {
39
41
  ...layout,
@@ -117,23 +119,27 @@ export default {
117
119
  'Customize the width for all elements that are assigned to the center or wide columns.'
118
120
  ) }
119
121
  </p>
120
- <ToggleGroupControl
121
- __nextHasNoMarginBottom
122
- label={ __( 'Justification' ) }
123
- value={ justifyContent }
124
- onChange={ onJustificationChange }
125
- >
126
- { justificationOptions.map( ( { value, icon, label } ) => {
127
- return (
128
- <ToggleGroupControlOptionIcon
129
- key={ value }
130
- value={ value }
131
- icon={ icon }
132
- label={ label }
133
- />
134
- );
135
- } ) }
136
- </ToggleGroupControl>
122
+ { allowJustification && (
123
+ <ToggleGroupControl
124
+ __nextHasNoMarginBottom
125
+ label={ __( 'Justification' ) }
126
+ value={ justifyContent }
127
+ onChange={ onJustificationChange }
128
+ >
129
+ { justificationOptions.map(
130
+ ( { value, icon, label } ) => {
131
+ return (
132
+ <ToggleGroupControlOptionIcon
133
+ key={ value }
134
+ value={ value }
135
+ icon={ icon }
136
+ label={ label }
137
+ />
138
+ );
139
+ }
140
+ ) }
141
+ </ToggleGroupControl>
142
+ ) }
137
143
  </>
138
144
  );
139
145
  },
@@ -347,6 +347,7 @@ function FlexWrapControl( { layout, onChange } ) {
347
347
  const { flexWrap = 'wrap' } = layout;
348
348
  return (
349
349
  <ToggleControl
350
+ __nextHasNoMarginBottom
350
351
  label={ __( 'Allow to wrap to multiple lines' ) }
351
352
  onChange={ ( value ) => {
352
353
  onChange( {