@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
@@ -10,6 +10,7 @@ import { get, set } from 'lodash';
10
10
  import { useContext, useCallback, useMemo } from '@wordpress/element';
11
11
  import { useSelect } from '@wordpress/data';
12
12
  import { store as blocksStore } from '@wordpress/blocks';
13
+ import { _x } from '@wordpress/i18n';
13
14
 
14
15
  /**
15
16
  * Internal dependencies
@@ -55,7 +56,7 @@ const VALID_SETTINGS = [
55
56
  'spacing.margin',
56
57
  'spacing.padding',
57
58
  'spacing.units',
58
- 'typography.fuild',
59
+ 'typography.fluid',
59
60
  'typography.customFontSize',
60
61
  'typography.dropCap',
61
62
  'typography.fontFamilies',
@@ -64,6 +65,7 @@ const VALID_SETTINGS = [
64
65
  'typography.fontWeight',
65
66
  'typography.letterSpacing',
66
67
  'typography.lineHeight',
68
+ 'typography.textColumns',
67
69
  'typography.textDecoration',
68
70
  'typography.textTransform',
69
71
  ];
@@ -177,7 +179,7 @@ export function useGlobalStyle(
177
179
  switch ( source ) {
178
180
  case 'all':
179
181
  rawResult =
180
- // The stlyes.css path is allowed to be empty, so don't revert to base if undefined.
182
+ // The styles.css path is allowed to be empty, so don't revert to base if undefined.
181
183
  finalPath === 'styles.css'
182
184
  ? get( userConfig, finalPath )
183
185
  : get( mergedConfig, finalPath );
@@ -204,62 +206,176 @@ export function useGlobalStyle(
204
206
  return [ result, setStyle ];
205
207
  }
206
208
 
207
- export function useSupportedStyles( name, element ) {
208
- const { supportedPanels } = useSelect(
209
+ /**
210
+ * React hook that overrides a global settings object with block and element specific settings.
211
+ *
212
+ * @param {Object} parentSettings Settings object.
213
+ * @param {blockName?} blockName Block name.
214
+ * @param {element?} element Element name.
215
+ *
216
+ * @return {Object} Merge of settings and supports.
217
+ */
218
+ export function useSettingsForBlockElement(
219
+ parentSettings,
220
+ blockName,
221
+ element
222
+ ) {
223
+ const { supportedStyles, supports } = useSelect(
209
224
  ( select ) => {
210
225
  return {
211
- supportedPanels: unlock(
226
+ supportedStyles: unlock(
212
227
  select( blocksStore )
213
- ).getSupportedStyles( name, element ),
228
+ ).getSupportedStyles( blockName, element ),
229
+ supports:
230
+ select( blocksStore ).getBlockType( blockName )?.supports,
214
231
  };
215
232
  },
216
- [ name, element ]
233
+ [ blockName, element ]
217
234
  );
218
235
 
219
- return supportedPanels;
220
- }
236
+ return useMemo( () => {
237
+ const updatedSettings = { ...parentSettings };
221
238
 
222
- /**
223
- * Given a settings object and a list of supported panels,
224
- * returns a new settings object with the unsupported panels removed.
225
- *
226
- * @param {Object} settings Settings object.
227
- * @param {string[]} supports Supported style panels.
228
- *
229
- * @return {Object} Merge of settings and supports.
230
- */
231
- export function overrideSettingsWithSupports( settings, supports ) {
232
- const updatedSettings = { ...settings };
239
+ if ( ! supportedStyles.includes( 'fontSize' ) ) {
240
+ updatedSettings.typography = {
241
+ ...updatedSettings.typography,
242
+ fontSizes: {},
243
+ customFontSize: false,
244
+ };
245
+ }
233
246
 
234
- if ( ! supports.includes( 'fontSize' ) ) {
235
- updatedSettings.typography = {
236
- ...updatedSettings.typography,
237
- fontSizes: {},
238
- customFontSize: false,
239
- };
240
- }
247
+ if ( ! supportedStyles.includes( 'fontFamily' ) ) {
248
+ updatedSettings.typography = {
249
+ ...updatedSettings.typography,
250
+ fontFamilies: {},
251
+ };
252
+ }
241
253
 
242
- if ( ! supports.includes( 'fontFamily' ) ) {
243
- updatedSettings.typography = {
244
- ...updatedSettings.typography,
245
- fontFamilies: {},
246
- };
247
- }
254
+ [
255
+ 'lineHeight',
256
+ 'fontStyle',
257
+ 'fontWeight',
258
+ 'letterSpacing',
259
+ 'textTransform',
260
+ 'textDecoration',
261
+ ].forEach( ( key ) => {
262
+ if ( ! supportedStyles.includes( key ) ) {
263
+ updatedSettings.typography = {
264
+ ...updatedSettings.typography,
265
+ [ key ]: false,
266
+ };
267
+ }
268
+ } );
248
269
 
249
- [
250
- 'lineHeight',
251
- 'fontStyle',
252
- 'fontWeight',
253
- 'letterSpacing',
254
- 'textTransform',
255
- ].forEach( ( key ) => {
256
- if ( ! supports.includes( key ) ) {
270
+ // The column-count style is named text column to reduce confusion with
271
+ // the columns block and manage expectations from the support.
272
+ // See: https://github.com/WordPress/gutenberg/pull/33587
273
+ if ( ! supportedStyles.includes( 'columnCount' ) ) {
257
274
  updatedSettings.typography = {
258
275
  ...updatedSettings.typography,
259
- [ key ]: false,
276
+ textColumns: false,
277
+ };
278
+ }
279
+
280
+ [ 'contentSize', 'wideSize' ].forEach( ( key ) => {
281
+ if ( ! supportedStyles.includes( key ) ) {
282
+ updatedSettings.layout = {
283
+ ...updatedSettings.layout,
284
+ [ key ]: false,
285
+ };
286
+ }
287
+ } );
288
+
289
+ [ 'padding', 'margin', 'blockGap' ].forEach( ( key ) => {
290
+ if ( ! supportedStyles.includes( key ) ) {
291
+ updatedSettings.spacing = {
292
+ ...updatedSettings.spacing,
293
+ [ key ]: false,
294
+ };
295
+ }
296
+
297
+ const sides = Array.isArray( supports?.spacing?.[ key ] )
298
+ ? supports?.spacing?.[ key ]
299
+ : supports?.spacing?.[ key ]?.sides;
300
+ if ( sides?.length ) {
301
+ updatedSettings.spacing = {
302
+ ...updatedSettings.spacing,
303
+ [ key ]: {
304
+ ...updatedSettings.spacing?.[ key ],
305
+ sides,
306
+ },
307
+ };
308
+ }
309
+ } );
310
+
311
+ if ( ! supportedStyles.includes( 'minHeight' ) ) {
312
+ updatedSettings.dimensions = {
313
+ ...updatedSettings.dimensions,
314
+ minHeight: false,
260
315
  };
261
316
  }
262
- } );
263
317
 
264
- return updatedSettings;
318
+ [ 'radius', 'color', 'style', 'width' ].forEach( ( key ) => {
319
+ if (
320
+ ! supportedStyles.includes(
321
+ 'border' + key.charAt( 0 ).toUpperCase() + key.slice( 1 )
322
+ )
323
+ ) {
324
+ updatedSettings.border = {
325
+ ...updatedSettings.border,
326
+ [ key ]: false,
327
+ };
328
+ }
329
+ } );
330
+
331
+ return updatedSettings;
332
+ }, [ parentSettings, supportedStyles, supports ] );
333
+ }
334
+
335
+ export function useColorsPerOrigin( settings ) {
336
+ const customColors = settings?.color?.palette?.custom;
337
+ const themeColors = settings?.color?.palette?.theme;
338
+ const defaultColors = settings?.color?.palette?.default;
339
+ const shouldDisplayDefaultColors = settings?.color?.defaultPalette;
340
+
341
+ return useMemo( () => {
342
+ const result = [];
343
+ if ( themeColors && themeColors.length ) {
344
+ result.push( {
345
+ name: _x(
346
+ 'Theme',
347
+ 'Indicates this palette comes from the theme.'
348
+ ),
349
+ colors: themeColors,
350
+ } );
351
+ }
352
+ if (
353
+ shouldDisplayDefaultColors &&
354
+ defaultColors &&
355
+ defaultColors.length
356
+ ) {
357
+ result.push( {
358
+ name: _x(
359
+ 'Default',
360
+ 'Indicates this palette comes from WordPress.'
361
+ ),
362
+ colors: defaultColors,
363
+ } );
364
+ }
365
+ if ( customColors && customColors.length ) {
366
+ result.push( {
367
+ name: _x(
368
+ 'Custom',
369
+ 'Indicates this palette is created by the user.'
370
+ ),
371
+ colors: customColors,
372
+ } );
373
+ }
374
+ return result;
375
+ }, [
376
+ customColors,
377
+ themeColors,
378
+ defaultColors,
379
+ shouldDisplayDefaultColors,
380
+ ] );
265
381
  }
@@ -2,7 +2,8 @@ export {
2
2
  useGlobalStylesReset,
3
3
  useGlobalSetting,
4
4
  useGlobalStyle,
5
- overrideSettingsWithSupports,
5
+ useSettingsForBlockElement,
6
+ useColorsPerOrigin,
6
7
  } from './hooks';
7
8
  export { useGlobalStylesOutput } from './use-global-styles-output';
8
9
  export { GlobalStylesContext } from './context';
@@ -10,3 +11,8 @@ export {
10
11
  default as TypographyPanel,
11
12
  useHasTypographyPanel,
12
13
  } from './typography-panel';
14
+ export {
15
+ default as DimensionsPanel,
16
+ useHasDimensionsPanel,
17
+ } from './dimensions-panel';
18
+ export { default as BorderPanel, useHasBorderPanel } from './border-panel';
@@ -644,7 +644,7 @@ describe( 'global styles renderer', () => {
644
644
  } );
645
645
 
646
646
  expect( layoutStyles ).toEqual(
647
- '.wp-block-group.is-layout-flow > * { margin-block-start: 0; margin-block-end: 0; }.wp-block-group.is-layout-flow > * + * { margin-block-start: 12px; margin-block-end: 0; }.wp-block-group.is-layout-flex { gap: 12px; }'
647
+ '.wp-block-group-is-layout-flow.wp-block-group-is-layout-flow > * { margin-block-start: 0; margin-block-end: 0; }.wp-block-group-is-layout-flow.wp-block-group-is-layout-flow > * + * { margin-block-start: 12px; margin-block-end: 0; }.wp-block-group-is-layout-flex.wp-block-group-is-layout-flex { gap: 12px; }'
648
648
  );
649
649
  } );
650
650
 
@@ -3,10 +3,12 @@
3
3
  */
4
4
  import {
5
5
  FontSizePicker,
6
+ __experimentalNumberControl as NumberControl,
6
7
  __experimentalToolsPanel as ToolsPanel,
7
8
  __experimentalToolsPanelItem as ToolsPanelItem,
8
9
  } from '@wordpress/components';
9
10
  import { __ } from '@wordpress/i18n';
11
+ import { useCallback } from '@wordpress/element';
10
12
 
11
13
  /**
12
14
  * Internal dependencies
@@ -19,6 +21,9 @@ import TextTransformControl from '../text-transform-control';
19
21
  import TextDecorationControl from '../text-decoration-control';
20
22
  import { getValueFromVariable } from './utils';
21
23
 
24
+ const MIN_TEXT_COLUMNS = 1;
25
+ const MAX_TEXT_COLUMNS = 6;
26
+
22
27
  export function useHasTypographyPanel( settings ) {
23
28
  const hasFontFamily = useHasFontFamilyControl( settings );
24
29
  const hasLineHeight = useHasLineHeightControl( settings );
@@ -26,6 +31,7 @@ export function useHasTypographyPanel( settings ) {
26
31
  const hasLetterSpacing = useHasLetterSpacingControl( settings );
27
32
  const hasTextTransform = useHasTextTransformControl( settings );
28
33
  const hasTextDecoration = useHasTextDecorationControl( settings );
34
+ const hasTextColumns = useHasTextColumnsControl( settings );
29
35
  const hasFontSize = useHasFontSizeControl( settings );
30
36
 
31
37
  return (
@@ -35,7 +41,8 @@ export function useHasTypographyPanel( settings ) {
35
41
  hasLetterSpacing ||
36
42
  hasTextTransform ||
37
43
  hasFontSize ||
38
- hasTextDecoration
44
+ hasTextDecoration ||
45
+ hasTextColumns
39
46
  );
40
47
  }
41
48
 
@@ -92,8 +99,31 @@ function useHasTextDecorationControl( settings ) {
92
99
  return settings?.typography?.textDecoration;
93
100
  }
94
101
 
95
- function TypographyToolsPanel( { ...props } ) {
96
- return <ToolsPanel label={ __( 'Typography' ) } { ...props } />;
102
+ function useHasTextColumnsControl( settings ) {
103
+ return settings?.typography?.textColumns;
104
+ }
105
+
106
+ function TypographyToolsPanel( {
107
+ resetAllFilter,
108
+ onChange,
109
+ value,
110
+ panelId,
111
+ children,
112
+ } ) {
113
+ const resetAll = () => {
114
+ const updatedValue = resetAllFilter( value );
115
+ onChange( updatedValue );
116
+ };
117
+
118
+ return (
119
+ <ToolsPanel
120
+ label={ __( 'Typography' ) }
121
+ resetAll={ resetAll }
122
+ panelId={ panelId }
123
+ >
124
+ { children }
125
+ </ToolsPanel>
126
+ );
97
127
  }
98
128
 
99
129
  const DEFAULT_CONTROLS = {
@@ -104,6 +134,7 @@ const DEFAULT_CONTROLS = {
104
134
  letterSpacing: true,
105
135
  textTransform: true,
106
136
  textDecoration: true,
137
+ textColumns: true,
107
138
  };
108
139
 
109
140
  export default function TypographyPanel( {
@@ -226,6 +257,21 @@ export default function TypographyPanel( {
226
257
  const hasLetterSpacing = () => !! value?.typography?.letterSpacing;
227
258
  const resetLetterSpacing = () => setLetterSpacing( undefined );
228
259
 
260
+ // Text Columns
261
+ const hasTextColumnsControl = useHasTextColumnsControl( settings );
262
+ const textColumns = decodeValue( inheritedValue?.typography?.textColumns );
263
+ const setTextColumns = ( newValue ) => {
264
+ onChange( {
265
+ ...value,
266
+ typography: {
267
+ ...value?.typography,
268
+ textColumns: newValue,
269
+ },
270
+ } );
271
+ };
272
+ const hasTextColumns = () => !! value?.typography?.textColumns;
273
+ const resetTextColumns = () => setTextColumns( undefined );
274
+
229
275
  // Text Transform
230
276
  const hasTextTransformControl = useHasTextTransformControl( settings );
231
277
  const textTransform = decodeValue(
@@ -260,15 +306,20 @@ export default function TypographyPanel( {
260
306
  const hasTextDecoration = () => !! value?.typography?.textDecoration;
261
307
  const resetTextDecoration = () => setTextDecoration( undefined );
262
308
 
263
- const resetAll = () => {
264
- onChange( {
265
- ...value,
309
+ const resetAllFilter = useCallback( ( previousValue ) => {
310
+ return {
311
+ ...previousValue,
266
312
  typography: {},
267
- } );
268
- };
313
+ };
314
+ }, [] );
269
315
 
270
316
  return (
271
- <Wrapper resetAll={ resetAll }>
317
+ <Wrapper
318
+ resetAllFilter={ resetAllFilter }
319
+ value={ value }
320
+ onChange={ onChange }
321
+ panelId={ panelId }
322
+ >
272
323
  { hasFontFamilyEnabled && (
273
324
  <ToolsPanelItem
274
325
  label={ __( 'Font family' ) }
@@ -363,6 +414,27 @@ export default function TypographyPanel( {
363
414
  />
364
415
  </ToolsPanelItem>
365
416
  ) }
417
+ { hasTextColumnsControl && (
418
+ <ToolsPanelItem
419
+ className="single-column"
420
+ label={ __( 'Text columns' ) }
421
+ hasValue={ hasTextColumns }
422
+ onDeselect={ resetTextColumns }
423
+ isShownByDefault={ defaultControls.textColumns }
424
+ panelId={ panelId }
425
+ >
426
+ <NumberControl
427
+ label={ __( 'Text columns' ) }
428
+ max={ MAX_TEXT_COLUMNS }
429
+ min={ MIN_TEXT_COLUMNS }
430
+ onChange={ setTextColumns }
431
+ size="__unstable-large"
432
+ spinControls="custom"
433
+ value={ textColumns }
434
+ initialPosition={ 1 }
435
+ />
436
+ </ToolsPanelItem>
437
+ ) }
366
438
  { hasTextDecorationControl && (
367
439
  <ToolsPanelItem
368
440
  className="single-column"
@@ -95,11 +95,11 @@ function getPresetsDeclarations( blockPresets = {}, mergedSettings ) {
95
95
  /**
96
96
  * Transform given preset tree into a set of preset class declarations.
97
97
  *
98
- * @param {string} blockSelector
99
- * @param {Object} blockPresets
98
+ * @param {?string} blockSelector
99
+ * @param {Object} blockPresets
100
100
  * @return {string} CSS declarations for the preset classes.
101
101
  */
102
- function getPresetsClasses( blockSelector, blockPresets = {} ) {
102
+ function getPresetsClasses( blockSelector = '*', blockPresets = {} ) {
103
103
  return PRESET_METADATA.reduce(
104
104
  ( declarations, { path, cssVarInfix, classes } ) => {
105
105
  if ( ! classes ) {
@@ -399,7 +399,7 @@ export function getLayoutStyles( {
399
399
  ? `${ selector } .${ className }${
400
400
  spacingStyle?.selector || ''
401
401
  }`
402
- : `${ selector }.${ className }${
402
+ : `${ selector }-${ className }${ selector }-${ className }${
403
403
  spacingStyle?.selector || ''
404
404
  }`;
405
405
  }
@@ -496,9 +496,9 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
496
496
  }
497
497
 
498
498
  Object.entries( ELEMENTS ).forEach( ( [ name, selector ] ) => {
499
- if ( !! tree.styles?.elements[ name ] ) {
499
+ if ( !! tree.styles?.elements?.[ name ] ) {
500
500
  nodes.push( {
501
- styles: tree.styles?.elements[ name ],
501
+ styles: tree.styles?.elements?.[ name ],
502
502
  selector,
503
503
  } );
504
504
  }
@@ -529,7 +529,7 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
529
529
  blockSelectors[ blockName ].fallbackGapValue,
530
530
  hasLayoutSupport:
531
531
  blockSelectors[ blockName ].hasLayoutSupport,
532
- selector: blockSelectors[ blockName ].selector,
532
+ selector: blockSelectors[ blockName ]?.selector,
533
533
  styles: blockStyles,
534
534
  featureSelectors:
535
535
  blockSelectors[ blockName ].featureSelectors,
@@ -547,7 +547,7 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
547
547
  ) {
548
548
  nodes.push( {
549
549
  styles: value,
550
- selector: blockSelectors[ blockName ].selector
550
+ selector: blockSelectors[ blockName ]?.selector
551
551
  .split( ',' )
552
552
  .map( ( sel ) => {
553
553
  const elementSelectors =
@@ -606,7 +606,7 @@ export const getNodesWithSettings = ( tree, blockSelectors ) => {
606
606
  nodes.push( {
607
607
  presets: blockPresets,
608
608
  custom: blockCustom,
609
- selector: blockSelectors[ blockName ].selector,
609
+ selector: blockSelectors[ blockName ]?.selector,
610
610
  } );
611
611
  }
612
612
  }
@@ -790,9 +790,10 @@ export const toStyles = (
790
790
  if ( duotoneDeclarations.length > 0 ) {
791
791
  ruleset =
792
792
  ruleset +
793
- `${ duotoneSelector }{${ duotoneDeclarations.join(
794
- ';'
795
- ) };}`;
793
+ `${ scopeSelector(
794
+ selector,
795
+ duotoneSelector
796
+ ) }{${ duotoneDeclarations.join( ';' ) };}`;
796
797
  }
797
798
  }
798
799
 
@@ -972,10 +973,10 @@ export const getBlockSelectors = ( blockTypes, getBlockStyles ) => {
972
973
  */
973
974
  function updateConfigWithSeparator( config ) {
974
975
  const needsSeparatorStyleUpdate =
975
- config.styles?.blocks[ 'core/separator' ] &&
976
- config.styles?.blocks[ 'core/separator' ].color?.background &&
977
- ! config.styles?.blocks[ 'core/separator' ].color?.text &&
978
- ! config.styles?.blocks[ 'core/separator' ].border?.color;
976
+ config.styles?.blocks?.[ 'core/separator' ] &&
977
+ config.styles?.blocks?.[ 'core/separator' ].color?.background &&
978
+ ! config.styles?.blocks?.[ 'core/separator' ].color?.text &&
979
+ ! config.styles?.blocks?.[ 'core/separator' ].border?.color;
979
980
  if ( needsSeparatorStyleUpdate ) {
980
981
  return {
981
982
  ...config,
@@ -57,6 +57,7 @@ export const PRESET_METADATA = [
57
57
  },
58
58
  {
59
59
  path: [ 'color', 'duotone' ],
60
+ valueKey: 'colors',
60
61
  cssVarInfix: 'duotone',
61
62
  valueFunc: ( { slug } ) => `url( '#wp-duotone-${ slug }' )`,
62
63
  classes: [],
@@ -95,6 +96,7 @@ export const PRESET_METADATA = [
95
96
  export const STYLE_PATH_TO_CSS_VAR_INFIX = {
96
97
  'color.background': 'color',
97
98
  'color.text': 'color',
99
+ 'filter.duotone': 'duotone',
98
100
  'elements.link.color.text': 'color',
99
101
  'elements.link.:hover.color.text': 'color',
100
102
  'elements.link.typography.fontFamily': 'font-family',
@@ -74,6 +74,11 @@ export {
74
74
  } from './block-settings';
75
75
  export { default as VideoPlayer, VIDEO_ASPECT_RATIO } from './video-player';
76
76
 
77
+ export {
78
+ getSpacingPresetCssVar,
79
+ getCustomValueFromPreset,
80
+ isValueSpacingPreset,
81
+ } from './spacing-sizes-control/utils';
77
82
  // Content Related Components.
78
83
  export { default as BlockList } from './block-list';
79
84
  export { default as BlockMover } from './block-mover';
@@ -9,7 +9,7 @@ exports[`InnerBlocks should force serialize for invalid block with inner blocks
9
9
  `;
10
10
 
11
11
  exports[`InnerBlocks should return element as string, with inner blocks 1`] = `
12
- "<div>Bananas<!-- wp:fruit {\\"fruit\\":\\"Apples\\"} -->
12
+ "<div>Bananas<!-- wp:fruit {"fruit":"Apples"} -->
13
13
  <div>Apples</div>
14
14
  <!-- /wp:fruit --></div>"
15
15
  `;
@@ -9,7 +9,7 @@ import classnames from 'classnames';
9
9
  import { speak } from '@wordpress/a11y';
10
10
  import { __, _x, sprintf } from '@wordpress/i18n';
11
11
  import { Dropdown, Button } from '@wordpress/components';
12
- import { Component } from '@wordpress/element';
12
+ import { forwardRef, Component } from '@wordpress/element';
13
13
  import { withDispatch, withSelect } from '@wordpress/data';
14
14
  import { compose, ifCondition } from '@wordpress/compose';
15
15
  import { createBlock, store as blocksStore } from '@wordpress/blocks';
@@ -31,21 +31,26 @@ const defaultRenderToggle = ( {
31
31
  toggleProps = {},
32
32
  prioritizePatterns,
33
33
  } ) => {
34
- let label;
35
- if ( hasSingleBlockType ) {
34
+ const {
35
+ as: Wrapper = Button,
36
+ label: labelProp,
37
+ onClick,
38
+ ...rest
39
+ } = toggleProps;
40
+
41
+ let label = labelProp;
42
+ if ( ! label && hasSingleBlockType ) {
36
43
  label = sprintf(
37
44
  // translators: %s: the name of the block when there is only one
38
45
  _x( 'Add %s', 'directly add the only allowed block' ),
39
46
  blockTitle
40
47
  );
41
- } else if ( prioritizePatterns ) {
48
+ } else if ( ! label && prioritizePatterns ) {
42
49
  label = __( 'Add pattern' );
43
- } else {
50
+ } else if ( ! label ) {
44
51
  label = _x( 'Add block', 'Generic label for block inserter button' );
45
52
  }
46
53
 
47
- const { onClick, ...rest } = toggleProps;
48
-
49
54
  // Handle both onClick functions from the toggle and the parent component.
50
55
  function handleClick( event ) {
51
56
  if ( onToggle ) {
@@ -57,7 +62,7 @@ const defaultRenderToggle = ( {
57
62
  }
58
63
 
59
64
  return (
60
- <Button
65
+ <Wrapper
61
66
  icon={ plus }
62
67
  label={ label }
63
68
  tooltipPosition="bottom"
@@ -71,7 +76,7 @@ const defaultRenderToggle = ( {
71
76
  );
72
77
  };
73
78
 
74
- class Inserter extends Component {
79
+ class PrivateInserter extends Component {
75
80
  constructor() {
76
81
  super( ...arguments );
77
82
 
@@ -145,6 +150,7 @@ class Inserter extends Component {
145
150
  prioritizePatterns,
146
151
  onSelectOrClose,
147
152
  selectBlockOnInsert,
153
+ orderInitialBlockItems,
148
154
  } = this.props;
149
155
 
150
156
  if ( isQuick ) {
@@ -168,6 +174,7 @@ class Inserter extends Component {
168
174
  isAppender={ isAppender }
169
175
  prioritizePatterns={ prioritizePatterns }
170
176
  selectBlockOnInsert={ selectBlockOnInsert }
177
+ orderInitialBlockItems={ orderInitialBlockItems }
171
178
  />
172
179
  );
173
180
  }
@@ -219,7 +226,7 @@ class Inserter extends Component {
219
226
  }
220
227
  }
221
228
 
222
- export default compose( [
229
+ export const ComposedPrivateInserter = compose( [
223
230
  withSelect(
224
231
  ( select, { clientId, rootClientId, shouldDirectInsert = true } ) => {
225
232
  const {
@@ -416,4 +423,16 @@ export default compose( [
416
423
  ( { hasItems, isAppender, rootClientId, clientId } ) =>
417
424
  hasItems || ( ! isAppender && ! rootClientId && ! clientId )
418
425
  ),
419
- ] )( Inserter );
426
+ ] )( PrivateInserter );
427
+
428
+ const Inserter = forwardRef( ( props, ref ) => {
429
+ return (
430
+ <ComposedPrivateInserter
431
+ ref={ ref }
432
+ { ...props }
433
+ orderInitialBlockItems={ undefined }
434
+ />
435
+ );
436
+ } );
437
+
438
+ export default Inserter;