@wordpress/block-editor 16.2.0 → 17.0.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 (328) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/build/components/block-inspector/index.cjs +9 -6
  3. package/build/components/block-inspector/index.cjs.map +2 -2
  4. package/build/components/block-keyboard-shortcuts/index.cjs +201 -0
  5. package/build/components/block-keyboard-shortcuts/index.cjs.map +7 -0
  6. package/build/components/block-list/block.cjs +10 -3
  7. package/build/components/block-list/block.cjs.map +2 -2
  8. package/build/components/block-list/index.cjs +6 -1
  9. package/build/components/block-list/index.cjs.map +2 -2
  10. package/build/components/block-list/use-block-props/use-focus-first-element.cjs +4 -0
  11. package/build/components/block-list/use-block-props/use-focus-first-element.cjs.map +2 -2
  12. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs +6 -7
  13. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs.map +2 -2
  14. package/build/components/block-parent-selector/index.cjs +98 -29
  15. package/build/components/block-parent-selector/index.cjs.map +3 -3
  16. package/build/components/block-popover/inbetween.cjs +2 -2
  17. package/build/components/block-popover/inbetween.cjs.map +2 -2
  18. package/build/components/block-preview/index.cjs +0 -4
  19. package/build/components/block-preview/index.cjs.map +2 -2
  20. package/build/components/block-styles/index.cjs +77 -33
  21. package/build/components/block-styles/index.cjs.map +3 -3
  22. package/build/components/block-visibility/constants.cjs.map +2 -2
  23. package/build/components/child-layout-control/index.cjs.map +2 -2
  24. package/build/components/colors/with-colors.cjs +55 -71
  25. package/build/components/colors/with-colors.cjs.map +2 -2
  26. package/build/components/dimensions-tool/aspect-ratio-tool.cjs +4 -2
  27. package/build/components/dimensions-tool/aspect-ratio-tool.cjs.map +2 -2
  28. package/build/components/dimensions-tool/index.cjs +18 -16
  29. package/build/components/dimensions-tool/index.cjs.map +2 -2
  30. package/build/components/dimensions-tool/utils.cjs +61 -0
  31. package/build/components/dimensions-tool/utils.cjs.map +7 -0
  32. package/build/components/duotone-control/index.cjs +2 -0
  33. package/build/components/duotone-control/index.cjs.map +2 -2
  34. package/build/components/global-styles/advanced-panel.cjs.map +3 -3
  35. package/build/components/global-styles/border-panel.cjs +2 -5
  36. package/build/components/global-styles/border-panel.cjs.map +2 -2
  37. package/build/components/global-styles/color-panel.cjs +14 -2
  38. package/build/components/global-styles/color-panel.cjs.map +2 -2
  39. package/build/components/global-styles/dimensions-panel.cjs +9 -5
  40. package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
  41. package/build/components/global-styles/filters-panel.cjs +12 -8
  42. package/build/components/global-styles/filters-panel.cjs.map +2 -2
  43. package/build/components/global-styles/shadow-panel-components.cjs +16 -11
  44. package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
  45. package/build/components/global-styles/utils.cjs +9 -0
  46. package/build/components/global-styles/utils.cjs.map +2 -2
  47. package/build/components/inner-blocks/index.cjs +5 -3
  48. package/build/components/inner-blocks/index.cjs.map +2 -2
  49. package/build/components/inserter/block-patterns-explorer/index.cjs +39 -22
  50. package/build/components/inserter/block-patterns-explorer/index.cjs.map +2 -2
  51. package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.cjs +21 -55
  52. package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.cjs.map +2 -2
  53. package/build/components/inserter/block-patterns-explorer/pattern-list.cjs +19 -44
  54. package/build/components/inserter/block-patterns-explorer/pattern-list.cjs.map +3 -3
  55. package/build/components/inserter/hooks/use-insertion-point.cjs +4 -4
  56. package/build/components/inserter/hooks/use-insertion-point.cjs.map +2 -2
  57. package/build/components/inserter/menu.cjs +18 -7
  58. package/build/components/inserter/menu.cjs.map +2 -2
  59. package/build/components/inserter/quick-inserter.cjs +30 -27
  60. package/build/components/inserter/quick-inserter.cjs.map +2 -2
  61. package/build/components/inspector-controls-tabs/styles-tab.cjs +1 -1
  62. package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
  63. package/build/components/list-view/index.cjs +31 -5
  64. package/build/components/list-view/index.cjs.map +3 -3
  65. package/build/components/list-view/utils.cjs +13 -1
  66. package/build/components/list-view/utils.cjs.map +2 -2
  67. package/build/components/media-placeholder/index.cjs +1 -1
  68. package/build/components/media-placeholder/index.cjs.map +3 -3
  69. package/build/components/provider/index.cjs +5 -1
  70. package/build/components/provider/index.cjs.map +3 -3
  71. package/build/components/publish-date-time-picker/index.cjs +3 -2
  72. package/build/components/publish-date-time-picker/index.cjs.map +2 -2
  73. package/build/components/rich-text/event-listeners/enter.cjs +46 -39
  74. package/build/components/rich-text/event-listeners/enter.cjs.map +2 -2
  75. package/build/components/rich-text/index.cjs +7 -5
  76. package/build/components/rich-text/index.cjs.map +2 -2
  77. package/build/components/rich-text/multiline.cjs +105 -70
  78. package/build/components/rich-text/multiline.cjs.map +3 -3
  79. package/build/components/url-input/index.cjs.map +2 -2
  80. package/build/components/writing-flow/use-input.cjs +65 -13
  81. package/build/components/writing-flow/use-input.cjs.map +3 -3
  82. package/build/hooks/border.cjs +25 -3
  83. package/build/hooks/border.cjs.map +2 -2
  84. package/build/hooks/dimensions.cjs +9 -2
  85. package/build/hooks/dimensions.cjs.map +2 -2
  86. package/build/hooks/duotone.cjs +4 -3
  87. package/build/hooks/duotone.cjs.map +2 -2
  88. package/build/hooks/gap.cjs +8 -2
  89. package/build/hooks/gap.cjs.map +2 -2
  90. package/build/hooks/layout-child.cjs +35 -13
  91. package/build/hooks/layout-child.cjs.map +2 -2
  92. package/build/hooks/layout.cjs +23 -1
  93. package/build/hooks/layout.cjs.map +2 -2
  94. package/build/hooks/states.cjs +7 -4
  95. package/build/hooks/states.cjs.map +2 -2
  96. package/build/layouts/constrained.cjs +8 -1
  97. package/build/layouts/constrained.cjs.map +2 -2
  98. package/build/layouts/flex.cjs +9 -0
  99. package/build/layouts/flex.cjs.map +2 -2
  100. package/build/layouts/flow.cjs +4 -1
  101. package/build/layouts/flow.cjs.map +2 -2
  102. package/build/layouts/grid.cjs +5 -1
  103. package/build/layouts/grid.cjs.map +2 -2
  104. package/build/private-apis.cjs +3 -1
  105. package/build/private-apis.cjs.map +2 -2
  106. package/build/store/actions.cjs +1 -1
  107. package/build/store/actions.cjs.map +2 -2
  108. package/build-module/components/block-inspector/index.mjs +9 -6
  109. package/build-module/components/block-inspector/index.mjs.map +2 -2
  110. package/build-module/components/block-keyboard-shortcuts/index.mjs +173 -0
  111. package/build-module/components/block-keyboard-shortcuts/index.mjs.map +7 -0
  112. package/build-module/components/block-list/block.mjs +10 -3
  113. package/build-module/components/block-list/block.mjs.map +2 -2
  114. package/build-module/components/block-list/index.mjs +6 -1
  115. package/build-module/components/block-list/index.mjs.map +2 -2
  116. package/build-module/components/block-list/use-block-props/use-focus-first-element.mjs +4 -0
  117. package/build-module/components/block-list/use-block-props/use-focus-first-element.mjs.map +2 -2
  118. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs +6 -7
  119. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs.map +2 -2
  120. package/build-module/components/block-parent-selector/index.mjs +101 -32
  121. package/build-module/components/block-parent-selector/index.mjs.map +2 -2
  122. package/build-module/components/block-popover/inbetween.mjs +2 -2
  123. package/build-module/components/block-popover/inbetween.mjs.map +2 -2
  124. package/build-module/components/block-preview/index.mjs +0 -4
  125. package/build-module/components/block-preview/index.mjs.map +2 -2
  126. package/build-module/components/block-styles/index.mjs +79 -35
  127. package/build-module/components/block-styles/index.mjs.map +2 -2
  128. package/build-module/components/block-visibility/constants.mjs.map +2 -2
  129. package/build-module/components/child-layout-control/index.mjs +5 -5
  130. package/build-module/components/child-layout-control/index.mjs.map +1 -1
  131. package/build-module/components/colors/with-colors.mjs +56 -72
  132. package/build-module/components/colors/with-colors.mjs.map +2 -2
  133. package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs +4 -2
  134. package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs.map +2 -2
  135. package/build-module/components/dimensions-tool/index.mjs +19 -17
  136. package/build-module/components/dimensions-tool/index.mjs.map +2 -2
  137. package/build-module/components/dimensions-tool/utils.mjs +35 -0
  138. package/build-module/components/dimensions-tool/utils.mjs.map +7 -0
  139. package/build-module/components/duotone-control/index.mjs +2 -0
  140. package/build-module/components/duotone-control/index.mjs.map +2 -2
  141. package/build-module/components/global-styles/advanced-panel.mjs +5 -2
  142. package/build-module/components/global-styles/advanced-panel.mjs.map +2 -2
  143. package/build-module/components/global-styles/border-panel.mjs +2 -5
  144. package/build-module/components/global-styles/border-panel.mjs.map +2 -2
  145. package/build-module/components/global-styles/color-panel.mjs +14 -2
  146. package/build-module/components/global-styles/color-panel.mjs.map +2 -2
  147. package/build-module/components/global-styles/dimensions-panel.mjs +9 -5
  148. package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
  149. package/build-module/components/global-styles/filters-panel.mjs +16 -9
  150. package/build-module/components/global-styles/filters-panel.mjs.map +2 -2
  151. package/build-module/components/global-styles/shadow-panel-components.mjs +16 -11
  152. package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
  153. package/build-module/components/global-styles/utils.mjs +8 -0
  154. package/build-module/components/global-styles/utils.mjs.map +2 -2
  155. package/build-module/components/inner-blocks/index.mjs +5 -3
  156. package/build-module/components/inner-blocks/index.mjs.map +2 -2
  157. package/build-module/components/inserter/block-patterns-explorer/index.mjs +39 -22
  158. package/build-module/components/inserter/block-patterns-explorer/index.mjs.map +2 -2
  159. package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.mjs +22 -56
  160. package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.mjs.map +2 -2
  161. package/build-module/components/inserter/block-patterns-explorer/pattern-list.mjs +20 -45
  162. package/build-module/components/inserter/block-patterns-explorer/pattern-list.mjs.map +2 -2
  163. package/build-module/components/inserter/hooks/use-insertion-point.mjs +4 -4
  164. package/build-module/components/inserter/hooks/use-insertion-point.mjs.map +2 -2
  165. package/build-module/components/inserter/menu.mjs +19 -8
  166. package/build-module/components/inserter/menu.mjs.map +2 -2
  167. package/build-module/components/inserter/quick-inserter.mjs +30 -27
  168. package/build-module/components/inserter/quick-inserter.mjs.map +2 -2
  169. package/build-module/components/inspector-controls-tabs/styles-tab.mjs +1 -1
  170. package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
  171. package/build-module/components/list-view/index.mjs +32 -5
  172. package/build-module/components/list-view/index.mjs.map +3 -3
  173. package/build-module/components/list-view/utils.mjs +13 -1
  174. package/build-module/components/list-view/utils.mjs.map +2 -2
  175. package/build-module/components/media-placeholder/index.mjs +3 -3
  176. package/build-module/components/media-placeholder/index.mjs.map +2 -2
  177. package/build-module/components/provider/index.mjs +6 -2
  178. package/build-module/components/provider/index.mjs.map +2 -2
  179. package/build-module/components/publish-date-time-picker/index.mjs +3 -2
  180. package/build-module/components/publish-date-time-picker/index.mjs.map +2 -2
  181. package/build-module/components/rich-text/event-listeners/enter.mjs +46 -39
  182. package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
  183. package/build-module/components/rich-text/index.mjs +7 -5
  184. package/build-module/components/rich-text/index.mjs.map +2 -2
  185. package/build-module/components/rich-text/multiline.mjs +112 -72
  186. package/build-module/components/rich-text/multiline.mjs.map +2 -2
  187. package/build-module/components/url-input/index.mjs +2 -2
  188. package/build-module/components/url-input/index.mjs.map +1 -1
  189. package/build-module/components/writing-flow/use-input.mjs +66 -14
  190. package/build-module/components/writing-flow/use-input.mjs.map +3 -3
  191. package/build-module/hooks/border.mjs +26 -8
  192. package/build-module/hooks/border.mjs.map +2 -2
  193. package/build-module/hooks/dimensions.mjs +9 -2
  194. package/build-module/hooks/dimensions.mjs.map +2 -2
  195. package/build-module/hooks/duotone.mjs +8 -4
  196. package/build-module/hooks/duotone.mjs.map +2 -2
  197. package/build-module/hooks/gap.mjs +6 -1
  198. package/build-module/hooks/gap.mjs.map +2 -2
  199. package/build-module/hooks/layout-child.mjs +36 -13
  200. package/build-module/hooks/layout-child.mjs.map +2 -2
  201. package/build-module/hooks/layout.mjs +22 -1
  202. package/build-module/hooks/layout.mjs.map +2 -2
  203. package/build-module/hooks/states.mjs +8 -5
  204. package/build-module/hooks/states.mjs.map +2 -2
  205. package/build-module/layouts/constrained.mjs +8 -1
  206. package/build-module/layouts/constrained.mjs.map +2 -2
  207. package/build-module/layouts/flex.mjs +9 -0
  208. package/build-module/layouts/flex.mjs.map +2 -2
  209. package/build-module/layouts/flow.mjs +4 -1
  210. package/build-module/layouts/flow.mjs.map +2 -2
  211. package/build-module/layouts/grid.mjs +5 -1
  212. package/build-module/layouts/grid.mjs.map +2 -2
  213. package/build-module/private-apis.mjs +3 -1
  214. package/build-module/private-apis.mjs.map +2 -2
  215. package/build-module/store/actions.mjs +1 -1
  216. package/build-module/store/actions.mjs.map +2 -2
  217. package/build-style/style-rtl.css +108 -71
  218. package/build-style/style.css +108 -71
  219. package/build-types/components/block-visibility/constants.d.ts +4 -3
  220. package/build-types/components/block-visibility/constants.d.ts.map +1 -1
  221. package/package.json +43 -43
  222. package/src/components/background-image-control/README.md +122 -0
  223. package/src/components/block-edit-visually-button/README.md +39 -0
  224. package/src/components/block-editing-mode/README.md +72 -0
  225. package/src/components/block-inspector/index.js +6 -6
  226. package/src/components/block-keyboard-shortcuts/index.js +256 -0
  227. package/src/components/block-list/block.js +7 -0
  228. package/src/components/block-list/index.js +7 -1
  229. package/src/components/block-list/use-block-props/use-focus-first-element.js +5 -0
  230. package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +6 -8
  231. package/src/components/block-parent-selector/index.js +111 -30
  232. package/src/components/block-popover/README.md +10 -3
  233. package/src/components/block-popover/inbetween.js +8 -2
  234. package/src/components/block-popover/stories/index.story.jsx +143 -0
  235. package/src/components/block-preview/index.js +0 -2
  236. package/src/components/block-styles/index.js +95 -43
  237. package/src/components/block-styles/style.scss +5 -34
  238. package/src/components/block-tools/style.scss +94 -0
  239. package/src/components/block-visibility/constants.ts +4 -3
  240. package/src/components/child-layout-control/index.js +5 -5
  241. package/src/components/color-palette/test/__snapshots__/control.js.snap +3 -29
  242. package/src/components/colors/test/with-colors.js +6 -7
  243. package/src/components/colors/with-colors.js +79 -105
  244. package/src/components/dimensions-tool/aspect-ratio-tool.js +16 -4
  245. package/src/components/dimensions-tool/index.js +34 -22
  246. package/src/components/dimensions-tool/test/index.js +166 -2
  247. package/src/components/dimensions-tool/test/utils.js +51 -0
  248. package/src/components/dimensions-tool/utils.js +67 -0
  249. package/src/components/duotone-control/index.js +2 -0
  250. package/src/components/duotone-control/test/index.js +100 -0
  251. package/src/components/global-styles/advanced-panel.js +5 -2
  252. package/src/components/global-styles/border-panel.js +11 -9
  253. package/src/components/global-styles/color-panel.js +13 -1
  254. package/src/components/global-styles/dimensions-panel.js +17 -5
  255. package/src/components/global-styles/filters-panel.js +24 -10
  256. package/src/components/global-styles/shadow-panel-components.js +38 -11
  257. package/src/components/global-styles/test/border-panel.js +230 -0
  258. package/src/components/global-styles/test/color-panel.js +24 -0
  259. package/src/components/global-styles/test/dimensions-panel.js +98 -7
  260. package/src/components/global-styles/test/filters-panel.js +84 -0
  261. package/src/components/global-styles/test/utils.js +30 -0
  262. package/src/components/global-styles/utils.js +23 -0
  263. package/src/components/inner-blocks/index.js +11 -2
  264. package/src/components/inner-blocks/stories/index.story.jsx +246 -0
  265. package/src/components/inserter/block-patterns-explorer/index.js +24 -11
  266. package/src/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +18 -56
  267. package/src/components/inserter/block-patterns-explorer/pattern-list.js +22 -47
  268. package/src/components/inserter/hooks/use-insertion-point.js +9 -4
  269. package/src/components/inserter/menu.js +23 -10
  270. package/src/components/inserter/quick-inserter.js +15 -13
  271. package/src/components/inserter/style.scss +44 -62
  272. package/src/components/inspector-controls-tabs/README.md +92 -0
  273. package/src/components/inspector-controls-tabs/styles-tab.js +1 -1
  274. package/src/components/link-control/test/index.js +5 -0
  275. package/src/components/list-view/index.js +50 -7
  276. package/src/components/list-view/utils.js +16 -1
  277. package/src/components/media-placeholder/index.js +9 -4
  278. package/src/components/plain-text/stories/index.story.jsx +3 -0
  279. package/src/components/provider/index.js +7 -1
  280. package/src/components/publish-date-time-picker/README.md +10 -0
  281. package/src/components/publish-date-time-picker/index.js +17 -14
  282. package/src/components/rich-text/event-listeners/enter.js +58 -45
  283. package/src/components/rich-text/index.js +9 -4
  284. package/src/components/rich-text/multiline.js +126 -86
  285. package/src/components/url-input/index.js +2 -2
  286. package/src/components/url-input/test/fixtures/validated-input-control-deprecation.js +27 -0
  287. package/src/components/url-input/test/index.js +5 -0
  288. package/src/components/url-popover/README.md +7 -0
  289. package/src/components/url-popover/stories/index.story.jsx +133 -47
  290. package/src/components/writing-flow/use-input.js +105 -15
  291. package/src/hooks/border.js +27 -8
  292. package/src/hooks/dimensions.js +8 -1
  293. package/src/hooks/duotone.js +23 -7
  294. package/src/hooks/gap.js +16 -0
  295. package/src/hooks/layout-child.js +41 -9
  296. package/src/hooks/layout.js +117 -71
  297. package/src/hooks/states.js +8 -5
  298. package/src/hooks/test/gap.js +31 -1
  299. package/src/hooks/test/layout-child.js +60 -1
  300. package/src/hooks/test/layout.js +27 -0
  301. package/src/layouts/constrained.js +9 -1
  302. package/src/layouts/flex.js +15 -0
  303. package/src/layouts/flow.js +4 -1
  304. package/src/layouts/grid.js +9 -1
  305. package/src/layouts/test/constrained.js +26 -0
  306. package/src/layouts/test/flow.js +26 -0
  307. package/src/layouts/test/grid.js +46 -0
  308. package/src/private-apis.js +2 -0
  309. package/src/store/actions.js +14 -1
  310. package/build/components/floating-toolbar/nav-up-icon.cjs +0 -52
  311. package/build/components/floating-toolbar/nav-up-icon.cjs.map +0 -7
  312. package/build/components/gradients/with-gradient.cjs +0 -36
  313. package/build/components/gradients/with-gradient.cjs.map +0 -7
  314. package/build/components/inserter-button/sparkles.cjs +0 -36
  315. package/build/components/inserter-button/sparkles.cjs.map +0 -7
  316. package/build-module/components/floating-toolbar/nav-up-icon.mjs +0 -31
  317. package/build-module/components/floating-toolbar/nav-up-icon.mjs.map +0 -7
  318. package/build-module/components/gradients/with-gradient.mjs +0 -11
  319. package/build-module/components/gradients/with-gradient.mjs.map +0 -7
  320. package/build-module/components/inserter-button/sparkles.mjs +0 -15
  321. package/build-module/components/inserter-button/sparkles.mjs.map +0 -7
  322. package/build-style/default-editor-styles-rtl.css +0 -68
  323. package/build-style/default-editor-styles.css +0 -68
  324. package/src/components/floating-toolbar/nav-up-icon.js +0 -22
  325. package/src/components/gradients/with-gradient.js +0 -9
  326. package/src/components/inserter-button/README.md +0 -62
  327. package/src/components/inserter-button/sparkles.js +0 -12
  328. package/src/default-editor-styles.scss +0 -25
@@ -0,0 +1,246 @@
1
+ import {
2
+ createBlock,
3
+ getBlockType,
4
+ registerBlockType,
5
+ } from '@wordpress/blocks';
6
+ import { createContext, useContext, useMemo } from '@wordpress/element';
7
+ import InnerBlocks from '../';
8
+ import BlockList from '../../block-list';
9
+ import { useBlockProps } from '../../block-list/use-block-props';
10
+ import { ExperimentalBlockEditorProvider } from '../../provider';
11
+
12
+ // `InnerBlocks` only renders within a block, so the story args are passed down
13
+ // to the block type registered below through a context rather than rendered by
14
+ // the story directly.
15
+ const ArgsContext = createContext( {} );
16
+
17
+ const CONTAINER_BLOCK = 'storybook/inner-blocks-container';
18
+ const TEXT_BLOCK = 'storybook/example-text';
19
+ const MEDIA_BLOCK = 'storybook/example-media';
20
+ const CHILD_BLOCKS = [
21
+ [ TEXT_BLOCK, 'Example Text', 'text' ],
22
+ [ MEDIA_BLOCK, 'Example Media', 'media' ],
23
+ ];
24
+
25
+ // The inner blocks appender is only rendered while the block holding the inner
26
+ // blocks is selected, so the container is selected from the start and its
27
+ // client ID is hardcoded instead of using the generated one.
28
+ const CONTAINER_CLIENT_ID = 'inner-blocks-container';
29
+ const SELECTION = {
30
+ selectionStart: { clientId: CONTAINER_CLIENT_ID },
31
+ selectionEnd: { clientId: CONTAINER_CLIENT_ID },
32
+ };
33
+
34
+ function ContainerEdit() {
35
+ const args = useContext( ArgsContext );
36
+ const blockProps = useBlockProps();
37
+
38
+ return (
39
+ <div { ...blockProps }>
40
+ <InnerBlocks { ...args } />
41
+ </div>
42
+ );
43
+ }
44
+
45
+ function ChildEdit( { name } ) {
46
+ const blockProps = useBlockProps();
47
+ const { title } = getBlockType( name );
48
+
49
+ return <p { ...blockProps }>{ title }</p>;
50
+ }
51
+
52
+ // Minimal block types, so that the story doesn't depend on the block library.
53
+ // They are registered when the story renders rather than when this file loads,
54
+ // so that they don't leak into the registry shared with the other stories.
55
+ function useContainerBlock() {
56
+ return useMemo( () => {
57
+ CHILD_BLOCKS.forEach( ( [ name, title, category ] ) => {
58
+ if ( ! getBlockType( name ) ) {
59
+ registerBlockType( name, {
60
+ apiVersion: 3,
61
+ title,
62
+ category,
63
+ edit: ChildEdit,
64
+ save: () => null,
65
+ } );
66
+ }
67
+ } );
68
+
69
+ if ( ! getBlockType( CONTAINER_BLOCK ) ) {
70
+ registerBlockType( CONTAINER_BLOCK, {
71
+ apiVersion: 3,
72
+ title: 'Example Container',
73
+ category: 'design',
74
+ // The container is only meant to host the inner blocks area,
75
+ // so it is kept out of the inserter itself.
76
+ supports: { inserter: false },
77
+ edit: ContainerEdit,
78
+ save: () => null,
79
+ } );
80
+ }
81
+
82
+ return [
83
+ {
84
+ ...createBlock( CONTAINER_BLOCK ),
85
+ clientId: CONTAINER_CLIENT_ID,
86
+ },
87
+ ];
88
+ }, [] );
89
+ }
90
+
91
+ // Marks out the inner blocks area, so that it is easier to tell which part of
92
+ // the block list the props apply to.
93
+ const storyStyles = `
94
+ .inner-blocks-story .wp-block[data-type="${ CONTAINER_BLOCK }"] {
95
+ border: 1px dashed #949494;
96
+ padding: 16px;
97
+ }
98
+ `;
99
+
100
+ // The rendered story is a block editor hosting the example block below, so the
101
+ // generated snippet would only show that scaffolding. This is how a block
102
+ // renders the inner blocks area that the controls act on instead.
103
+ const sourceCode = `registerBlockType( 'my-plugin/my-block', {
104
+ edit() {
105
+ const blockProps = useBlockProps();
106
+
107
+ return (
108
+ <div { ...blockProps }>
109
+ <InnerBlocks
110
+ allowedBlocks={ [ 'core/image', 'core/paragraph' ] }
111
+ orientation="vertical"
112
+ renderAppender={ InnerBlocks.ButtonBlockAppender }
113
+ />
114
+ </div>
115
+ );
116
+ },
117
+
118
+ save() {
119
+ const blockProps = useBlockProps.save();
120
+
121
+ return (
122
+ <div { ...blockProps }>
123
+ <InnerBlocks.Content />
124
+ </div>
125
+ );
126
+ },
127
+ } );`;
128
+
129
+ const meta = {
130
+ title: 'BlockEditor/InnerBlocks',
131
+ component: InnerBlocks,
132
+ parameters: {
133
+ docs: {
134
+ canvas: { sourceState: 'shown' },
135
+ description: {
136
+ component:
137
+ 'InnerBlocks is a component which allows a single block to have multiple blocks as children. It is rendered by a block `edit` implementation, and pairs with `InnerBlocks.Content` in the `save` implementation, which is replaced by the content of the nested blocks.',
138
+ },
139
+ source: { code: sourceCode },
140
+ },
141
+ },
142
+ argTypes: {
143
+ allowedBlocks: {
144
+ control: { type: 'select' },
145
+ options: [ 'all', 'none', 'text block only' ],
146
+ mapping: {
147
+ all: true,
148
+ none: false,
149
+ 'text block only': [ TEXT_BLOCK ],
150
+ },
151
+ description:
152
+ 'The block types that can be inserted. `true` allows every block type, `false` allows none, and an array limits insertion to the listed block types.',
153
+ table: {
154
+ type: { summary: 'boolean | string[]' },
155
+ defaultValue: { summary: 'true' },
156
+ },
157
+ },
158
+ orientation: {
159
+ control: { type: 'select' },
160
+ options: [ 'vertical', 'horizontal' ],
161
+ description:
162
+ 'Whether inner blocks are shown horizontally or vertically. It does not style the inner blocks, but it orients the block movers and makes drag and drop behave accordingly.',
163
+ table: {
164
+ type: { summary: "'horizontal' | 'vertical'" },
165
+ defaultValue: { summary: "'vertical'" },
166
+ },
167
+ },
168
+ templateLock: {
169
+ control: { type: 'select' },
170
+ options: [ false, 'all', 'insert', 'contentOnly' ],
171
+ description:
172
+ "Locks the inner blocks area. `'all'` prevents all operations, `'insert'` prevents inserting and removing blocks but allows moving them, `'contentOnly'` prevents all operations and cannot be overridden by children, and `false` opts out of a lock applied by a parent. When unset, the lock of the parent inner blocks area is used.",
173
+ table: {
174
+ type: { summary: "boolean | 'all' | 'insert' | 'contentOnly'" },
175
+ },
176
+ },
177
+ renderAppender: {
178
+ control: { type: 'select' },
179
+ options: [ 'default', 'button', 'none' ],
180
+ mapping: {
181
+ default: undefined,
182
+ button: InnerBlocks.ButtonBlockAppender,
183
+ none: false,
184
+ },
185
+ description:
186
+ 'The component shown as the trailing appender of the inner blocks list. `InnerBlocks.ButtonBlockAppender` and `InnerBlocks.DefaultBlockAppender` are exposed for convenience, and any valid component can be passed. `false` renders no appender, and when unset the default appender is shown.',
187
+ table: {
188
+ type: { summary: 'Component | false' },
189
+ },
190
+ },
191
+ defaultBlock: {
192
+ control: { type: 'object' },
193
+ description:
194
+ 'The block type inserted by default, in the form `{ name, attributes }`.',
195
+ table: {
196
+ type: { summary: 'Object' },
197
+ },
198
+ },
199
+ directInsert: {
200
+ control: { type: 'boolean' },
201
+ description:
202
+ 'Whether the appender inserts `defaultBlock` directly, skipping the inserter dropdown and any registered inserter variations of that block type.',
203
+ table: {
204
+ type: { summary: 'boolean' },
205
+ },
206
+ },
207
+ prioritizedInserterBlocks: {
208
+ control: { type: 'object' },
209
+ description:
210
+ 'The block types shown first in the block inserter, as an array of `{blockName}/{variationName}` strings, where the variation name is optional.',
211
+ table: {
212
+ type: { summary: 'string[]' },
213
+ },
214
+ },
215
+ placeholder: {
216
+ control: false,
217
+ description:
218
+ 'An element rendered in front of the appender, which can be used to represent an example state before any block is inserted.',
219
+ table: {
220
+ type: { summary: 'Element' },
221
+ },
222
+ },
223
+ },
224
+ };
225
+
226
+ export default meta;
227
+
228
+ export const Default = {
229
+ render: function Template( args ) {
230
+ const blocks = useContainerBlock();
231
+
232
+ return (
233
+ <ArgsContext.Provider value={ args }>
234
+ <ExperimentalBlockEditorProvider
235
+ value={ blocks }
236
+ selection={ SELECTION }
237
+ >
238
+ <style>{ storyStyles }</style>
239
+ <div className="inner-blocks-story">
240
+ <BlockList />
241
+ </div>
242
+ </ExperimentalBlockEditorProvider>
243
+ </ArgsContext.Provider>
244
+ );
245
+ },
246
+ };
@@ -1,4 +1,5 @@
1
1
  import { Modal } from '@wordpress/components';
2
+ import { Tabs } from '@wordpress/ui';
2
3
  import { useState } from '@wordpress/element';
3
4
  import { __ } from '@wordpress/i18n';
4
5
  import PatternExplorerSidebar from './pattern-explorer-sidebar';
@@ -14,22 +15,34 @@ function PatternsExplorer( { initialCategory, rootClientId, onModalClose } ) {
14
15
  const patternCategories = usePatternCategories( rootClientId );
15
16
 
16
17
  return (
17
- <div className="block-editor-block-patterns-explorer">
18
+ <Tabs.Root
19
+ className="block-editor-block-patterns-explorer"
20
+ orientation="vertical"
21
+ value={ selectedCategory }
22
+ onValueChange={ setSelectedCategory }
23
+ >
18
24
  <PatternExplorerSidebar
19
- selectedCategory={ selectedCategory }
20
25
  patternCategories={ patternCategories }
21
- onClickCategory={ setSelectedCategory }
22
26
  searchValue={ searchValue }
23
27
  setSearchValue={ setSearchValue }
24
28
  />
25
- <PatternList
26
- searchValue={ searchValue }
27
- selectedCategory={ selectedCategory }
28
- patternCategories={ patternCategories }
29
- rootClientId={ rootClientId }
30
- onModalClose={ onModalClose }
31
- />
32
- </div>
29
+ { patternCategories.map( ( { name } ) => (
30
+ <Tabs.Panel
31
+ key={ name }
32
+ value={ name }
33
+ tabIndex={ -1 }
34
+ className="block-editor-block-patterns-explorer__panel"
35
+ >
36
+ <PatternList
37
+ searchValue={ searchValue }
38
+ selectedCategory={ name }
39
+ patternCategories={ patternCategories }
40
+ rootClientId={ rootClientId }
41
+ onModalClose={ onModalClose }
42
+ />
43
+ </Tabs.Panel>
44
+ ) ) }
45
+ </Tabs.Root>
33
46
  );
34
47
  }
35
48
 
@@ -1,70 +1,32 @@
1
- import { Button, SearchControl } from '@wordpress/components';
1
+ import { SearchControl } from '@wordpress/components';
2
+ import { Stack, Tabs } from '@wordpress/ui';
2
3
  import { __ } from '@wordpress/i18n';
3
4
 
4
- function PatternCategoriesList( {
5
- selectedCategory,
5
+ function PatternExplorerSidebar( {
6
6
  patternCategories,
7
- onClickCategory,
7
+ searchValue,
8
+ setSearchValue,
8
9
  } ) {
9
- const baseClassName = 'block-editor-block-patterns-explorer__sidebar';
10
- return (
11
- <div className={ `${ baseClassName }__categories-list` }>
12
- { patternCategories.map( ( { name, label } ) => {
13
- return (
14
- <Button
15
- __next40pxDefaultSize
16
- key={ name }
17
- label={ label }
18
- className={ `${ baseClassName }__categories-list__item` }
19
- isPressed={ selectedCategory === name }
20
- onClick={ () => {
21
- onClickCategory( name );
22
- } }
23
- >
24
- { label }
25
- </Button>
26
- );
27
- } ) }
28
- </div>
29
- );
30
- }
31
-
32
- function PatternsExplorerSearch( { searchValue, setSearchValue } ) {
33
- const baseClassName = 'block-editor-block-patterns-explorer__search';
34
10
  return (
35
- <div className={ baseClassName }>
11
+ <Stack
12
+ direction="column"
13
+ gap="lg"
14
+ className="block-editor-block-patterns-explorer__sidebar"
15
+ >
36
16
  <SearchControl
37
17
  onChange={ setSearchValue }
38
18
  value={ searchValue }
39
19
  label={ __( 'Search' ) }
40
20
  placeholder={ __( 'Search' ) }
41
21
  />
42
- </div>
43
- );
44
- }
45
-
46
- function PatternExplorerSidebar( {
47
- selectedCategory,
48
- patternCategories,
49
- onClickCategory,
50
- searchValue,
51
- setSearchValue,
52
- } ) {
53
- const baseClassName = 'block-editor-block-patterns-explorer__sidebar';
54
- return (
55
- <div className={ baseClassName }>
56
- <PatternsExplorerSearch
57
- searchValue={ searchValue }
58
- setSearchValue={ setSearchValue }
59
- />
60
- { ! searchValue && (
61
- <PatternCategoriesList
62
- selectedCategory={ selectedCategory }
63
- patternCategories={ patternCategories }
64
- onClickCategory={ onClickCategory }
65
- />
66
- ) }
67
- </div>
22
+ <Tabs.List>
23
+ { patternCategories.map( ( { name, label } ) => (
24
+ <Tabs.Tab key={ name } value={ name }>
25
+ { label }
26
+ </Tabs.Tab>
27
+ ) ) }
28
+ </Tabs.List>
29
+ </Stack>
68
30
  );
69
31
  }
70
32
 
@@ -1,12 +1,11 @@
1
1
  import { useMemo, useEffect, useRef, useState } from '@wordpress/element';
2
- import { _n, sprintf } from '@wordpress/i18n';
2
+ import { __, _n, sprintf } from '@wordpress/i18n';
3
3
  import { useDebounce } from '@wordpress/compose';
4
- import { __experimentalHeading as Heading } from '@wordpress/components';
4
+ import { Text } from '@wordpress/ui';
5
5
  import { speak } from '@wordpress/a11y';
6
6
  import BlockPatternsList from '../../block-patterns-list';
7
7
  import useInsertionPoint from '../hooks/use-insertion-point';
8
8
  import usePatternsState from '../hooks/use-patterns-state';
9
- import InserterListbox from '../../inserter-listbox';
10
9
  import { searchItems } from '../search-items';
11
10
  import BlockPatternsPaging from '../../block-patterns-paging';
12
11
  import usePatternsPaging from '../hooks/use-patterns-paging';
@@ -17,30 +16,6 @@ import {
17
16
  starterPatternsCategory,
18
17
  } from '../block-patterns-tab/utils';
19
18
 
20
- function PatternsListHeader( { filterValue, filteredBlockPatternsLength } ) {
21
- if ( ! filterValue ) {
22
- return null;
23
- }
24
-
25
- return (
26
- <Heading
27
- level={ 2 }
28
- lineHeight="48px"
29
- className="block-editor-block-patterns-explorer__search-results-count"
30
- >
31
- { sprintf(
32
- /* translators: %d: number of patterns. */
33
- _n(
34
- '%d pattern found',
35
- '%d patterns found',
36
- filteredBlockPatternsLength
37
- ),
38
- filteredBlockPatternsLength
39
- ) }
40
- </Heading>
41
- );
42
- }
43
-
44
19
  function PatternList( {
45
20
  searchValue,
46
21
  selectedCategory,
@@ -143,26 +118,26 @@ function PatternList( {
143
118
  className="block-editor-block-patterns-explorer__list"
144
119
  ref={ container }
145
120
  >
146
- <PatternsListHeader
147
- filterValue={ searchValue }
148
- filteredBlockPatternsLength={ filteredBlockPatterns.length }
149
- />
150
-
151
- <InserterListbox>
152
- { hasItems && (
153
- <>
154
- <BlockPatternsList
155
- blockPatterns={ pagingProps.categoryPatterns }
156
- onClickPattern={ ( pattern, blocks ) => {
157
- onClickPattern( pattern, blocks );
158
- onModalClose();
159
- } }
160
- isDraggable={ false }
161
- />
162
- <BlockPatternsPaging { ...pagingProps } />
163
- </>
164
- ) }
165
- </InserterListbox>
121
+ { hasItems ? (
122
+ <>
123
+ <BlockPatternsList
124
+ blockPatterns={ pagingProps.categoryPatterns }
125
+ onClickPattern={ ( pattern, blocks ) => {
126
+ onClickPattern( pattern, blocks );
127
+ onModalClose();
128
+ } }
129
+ isDraggable={ false }
130
+ />
131
+ <BlockPatternsPaging { ...pagingProps } />
132
+ </>
133
+ ) : (
134
+ <Text
135
+ render={ <p /> }
136
+ className="block-editor-block-patterns-explorer__no-results"
137
+ >
138
+ { __( 'No results found.' ) }
139
+ </Text>
140
+ ) }
166
141
  </div>
167
142
  );
168
143
  }
@@ -67,7 +67,7 @@ function useInsertionPoint( {
67
67
  const {
68
68
  getSelectedBlock,
69
69
  getClosestAllowedInsertionPoint,
70
- isBlockInsertionPointVisible,
70
+ getBlockInsertionPoint,
71
71
  } = unlock( useSelect( blockEditorStore ) );
72
72
  const { destinationRootClientId, destinationIndex } = useSelect(
73
73
  ( select ) => {
@@ -201,7 +201,7 @@ function useInsertionPoint( {
201
201
 
202
202
  const onToggleInsertionPoint = useCallback(
203
203
  ( item ) => {
204
- if ( item && ! isBlockInsertionPointVisible() ) {
204
+ if ( item ) {
205
205
  const allowedDestinationRootClientId =
206
206
  getClosestAllowedInsertionPoint(
207
207
  item.name,
@@ -218,13 +218,18 @@ function useInsertionPoint( {
218
218
  } )
219
219
  );
220
220
  }
221
- } else {
221
+ } else if ( ! getBlockInsertionPoint()?.__unstableWithInserter ) {
222
+ // The insertion cue is shared state. The in-between inserter
223
+ // marks its own cue with `__unstableWithInserter` and mounts an
224
+ // inserter inside that cue's popover, so hiding that cue here
225
+ // would unmount a UI this inserter does not own.
226
+ // See https://github.com/WordPress/gutenberg/issues/72297.
222
227
  hideInsertionPoint();
223
228
  }
224
229
  },
225
230
  [
226
231
  getClosestAllowedInsertionPoint,
227
- isBlockInsertionPointVisible,
232
+ getBlockInsertionPoint,
228
233
  showInsertionPoint,
229
234
  hideInsertionPoint,
230
235
  destinationRootClientId,
@@ -12,7 +12,7 @@ import { SearchControl, Popover } from '@wordpress/components';
12
12
  import { VisuallyHidden } from '@wordpress/ui';
13
13
  import { __ } from '@wordpress/i18n';
14
14
  import { useDebouncedInput, useViewportMatch } from '@wordpress/compose';
15
- import { useSelect } from '@wordpress/data';
15
+ import { useDispatch, useSelect } from '@wordpress/data';
16
16
  import Tips from './tips';
17
17
  import InserterPreviewPanel from './preview-panel';
18
18
  import BlockTypesTab from './block-types-tab';
@@ -96,10 +96,14 @@ function InserterMenu(
96
96
  insertionIndex: __experimentalInsertionIndex,
97
97
  shouldFocusBlock,
98
98
  } );
99
+ const { hideInsertionPoint } = useDispatch( blockEditorStore );
99
100
  const blockTypesTabRef = useRef();
100
101
 
101
102
  const onInsert = useCallback(
102
103
  ( blocks, meta, shouldForceFocusBlock, _rootClientId ) => {
104
+ // The cue points at a position that no longer exists once the
105
+ // blocks are inserted, so clear it regardless of what showed it.
106
+ hideInsertionPoint();
103
107
  onInsertBlocks(
104
108
  blocks,
105
109
  meta,
@@ -122,17 +126,24 @@ function InserterMenu(
122
126
  }
123
127
  } );
124
128
  },
125
- [ onInsertBlocks, maybeCloseInserter, onSelect, ref, shouldFocusBlock ]
129
+ [
130
+ hideInsertionPoint,
131
+ onInsertBlocks,
132
+ maybeCloseInserter,
133
+ onSelect,
134
+ ref,
135
+ shouldFocusBlock,
136
+ ]
126
137
  );
127
138
 
128
139
  const onInsertPattern = useCallback(
129
140
  ( blocks, patternName, ...args ) => {
130
- onToggleInsertionPoint( false );
141
+ hideInsertionPoint();
131
142
  onInsertBlocks( blocks, { patternName }, ...args );
132
143
  onSelect();
133
144
  maybeCloseInserter();
134
145
  },
135
- [ onInsertBlocks, maybeCloseInserter, onSelect, onToggleInsertionPoint ]
146
+ [ hideInsertionPoint, onInsertBlocks, maybeCloseInserter, onSelect ]
136
147
  );
137
148
 
138
149
  const onHover = useCallback(
@@ -333,13 +344,15 @@ function InserterMenu(
333
344
  // Focus first active tab, if any
334
345
  const tabsRef = useRef();
335
346
  useLayoutEffect( () => {
336
- if ( tabsRef.current ) {
337
- window.requestAnimationFrame( () => {
338
- tabsRef.current
339
- .querySelector( '[role="tab"][aria-selected="true"]' )
340
- ?.focus();
341
- } );
347
+ if ( ! tabsRef.current ) {
348
+ return;
342
349
  }
350
+ const frame = window.requestAnimationFrame( () => {
351
+ tabsRef.current
352
+ ?.querySelector( '[role="tab"][aria-selected="true"]' )
353
+ ?.focus();
354
+ } );
355
+ return () => window.cancelAnimationFrame( frame );
343
356
  }, [] );
344
357
 
345
358
  return (
@@ -103,20 +103,22 @@ export default function QuickInserter( {
103
103
  selectBlockOnInsert={ selectBlockOnInsert }
104
104
  isQuick
105
105
  />
106
+ { setInserterIsOpened && (
107
+ <div className="block-editor-inserter__quick-inserter-expand">
108
+ <Button
109
+ className="block-editor-inserter__quick-inserter-expand-toggle"
110
+ __next40pxDefaultSize
111
+ variant="secondary"
112
+ onClick={ onBrowseAll }
113
+ aria-label={ __(
114
+ 'Browse all. This will open the main inserter panel in the editor toolbar.'
115
+ ) }
116
+ >
117
+ { __( 'Browse all' ) }
118
+ </Button>
119
+ </div>
120
+ ) }
106
121
  </div>
107
-
108
- { setInserterIsOpened && (
109
- <Button
110
- __next40pxDefaultSize
111
- className="block-editor-inserter__quick-inserter-expand"
112
- onClick={ onBrowseAll }
113
- aria-label={ __(
114
- 'Browse all. This will open the main inserter panel in the editor toolbar.'
115
- ) }
116
- >
117
- { __( 'Browse all' ) }
118
- </Button>
119
- ) }
120
122
  </div>
121
123
  );
122
124
  }