@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
@@ -10,7 +10,7 @@ import {
10
10
  } from '@wordpress/blocks';
11
11
  import { store as blockEditorStore } from '../../store';
12
12
  import { setContentEditableWrapper } from './utils';
13
- import { getSelectionEditableElement } from '../../utils/dom';
13
+ import { getBlockClientId, getSelectionEditableElement } from '../../utils/dom';
14
14
 
15
15
  /**
16
16
  * Handles input for selections across blocks.
@@ -28,6 +28,10 @@ export default function useInput() {
28
28
  getSelectionStart,
29
29
  getSelectionEnd,
30
30
  getBlockAttributes,
31
+ getNextBlockClientId,
32
+ getBlockOrder,
33
+ getBlockEditingMode,
34
+ getBlockListSettings,
31
35
  } = useSelect( blockEditorStore );
32
36
  const {
33
37
  replaceBlocks,
@@ -36,6 +40,9 @@ export default function useInput() {
36
40
  __unstableDeleteSelection,
37
41
  __unstableExpandSelection,
38
42
  __unstableMarkAutomaticChange,
43
+ insertAfterBlock,
44
+ insertBlock,
45
+ selectBlock,
39
46
  } = useDispatch( blockEditorStore );
40
47
 
41
48
  return useRefEffect( ( node ) => {
@@ -70,7 +77,7 @@ export default function useInput() {
70
77
 
71
78
  if ( ! hasMultiSelection() ) {
72
79
  if ( event.keyCode === ENTER ) {
73
- if ( event.shiftKey || __unstableIsFullySelected() ) {
80
+ if ( event.shiftKey ) {
74
81
  return;
75
82
  }
76
83
 
@@ -111,26 +118,109 @@ export default function useInput() {
111
118
  }
112
119
  }
113
120
 
114
- if (
115
- ! hasBlockSupport( blockName, 'splitting', false ) &&
116
- ! event.__deprecatedOnSplit
117
- ) {
118
- return;
119
- }
121
+ const rootClientId = getBlockRootClientId( clientId );
122
+ const { activeElement } = event.target.ownerDocument;
120
123
 
121
124
  // Ensure template is not locked.
122
125
  if (
123
- canInsertBlockType(
126
+ ! __unstableIsFullySelected() &&
127
+ ( canInsertBlockType(
124
128
  getDefaultBlockName(),
125
- getBlockRootClientId( clientId )
129
+ rootClientId
126
130
  ) ||
127
- canInsertBlockType(
128
- blockName,
129
- getBlockRootClientId( clientId )
130
- )
131
+ canInsertBlockType( blockName, rootClientId ) ) &&
132
+ ( hasBlockSupport( blockName, 'splitting', false ) ||
133
+ event.__deprecatedOnSplit )
131
134
  ) {
132
- __unstableSplitSelection();
133
135
  event.preventDefault();
136
+ __unstableSplitSelection();
137
+ } else if (
138
+ // Handle Enter only on the block wrapper itself or
139
+ // an editable element within the block, which may be
140
+ // nested within the wrapper (e.g. Site Title). Other
141
+ // focusable elements (an embed's URL field, an
142
+ // appender button) keep their native Enter behavior.
143
+ ( activeElement.getAttribute( 'data-block' ) ===
144
+ clientId ||
145
+ activeElement.isContentEditable ) &&
146
+ getBlockClientId( activeElement ) === clientId
147
+ ) {
148
+ // The default block depends on context: containers
149
+ // such as the gallery define their own default
150
+ // block, which is what insertAfterBlock inserts.
151
+ const { defaultBlock: directInsertBlock } =
152
+ ( rootClientId &&
153
+ getBlockListSettings( rootClientId ) ) ||
154
+ {};
155
+
156
+ if (
157
+ canInsertBlockType(
158
+ directInsertBlock?.name ??
159
+ getDefaultBlockName(),
160
+ rootClientId
161
+ )
162
+ ) {
163
+ event.preventDefault();
164
+ insertAfterBlock( clientId );
165
+ } else {
166
+ // Descend into an empty container by inserting
167
+ // its default block, the same block an appender
168
+ // or ghost would insert.
169
+ if ( ! getBlockOrder( clientId ).length ) {
170
+ const { defaultBlock } =
171
+ getBlockListSettings( clientId ) ?? {};
172
+ const name =
173
+ defaultBlock?.name ?? getDefaultBlockName();
174
+
175
+ if ( canInsertBlockType( name, clientId ) ) {
176
+ event.preventDefault();
177
+ insertBlock(
178
+ createBlock(
179
+ name,
180
+ defaultBlock?.attributes
181
+ ),
182
+ 0,
183
+ clientId
184
+ );
185
+ return;
186
+ }
187
+ }
188
+
189
+ function getNextClientId( id ) {
190
+ let nextClientId = null;
191
+
192
+ while (
193
+ typeof id === 'string' &&
194
+ ! ( nextClientId =
195
+ getNextBlockClientId( id ) )
196
+ ) {
197
+ id = getBlockRootClientId( id );
198
+ }
199
+
200
+ return nextClientId;
201
+ }
202
+
203
+ let nextClientId =
204
+ getBlockOrder( clientId )[ 0 ] ??
205
+ getNextClientId( clientId );
206
+
207
+ while (
208
+ nextClientId &&
209
+ getBlockEditingMode( nextClientId ) ===
210
+ 'disabled'
211
+ ) {
212
+ nextClientId = getNextClientId( nextClientId );
213
+ }
214
+
215
+ if ( nextClientId ) {
216
+ event.preventDefault();
217
+ // An initial position of `true` is an
218
+ // internal sentinel: it focuses the block
219
+ // wrapper instead of a text field within
220
+ // it. See useFocusFirstElement.
221
+ selectBlock( nextClientId, true );
222
+ }
223
+ }
134
224
  }
135
225
  }
136
226
  return;
@@ -8,11 +8,7 @@ import { __ } from '@wordpress/i18n';
8
8
  import { getColorClassName } from '../components/colors';
9
9
  import InspectorControls from '../components/inspector-controls';
10
10
  import useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';
11
- import {
12
- cleanEmptyObject,
13
- shouldSkipSerialization,
14
- useBlockSettings,
15
- } from './utils';
11
+ import { cleanEmptyObject, shouldSkipSerialization } from './utils';
16
12
  import {
17
13
  useHasBorderPanel,
18
14
  useHasBorderPanelControls,
@@ -26,10 +22,13 @@ import {
26
22
  setStyleForState,
27
23
  useBlockStyleState,
28
24
  } from './block-style-state';
25
+ import { unlock } from '../lock-unlock';
29
26
 
30
27
  export const BORDER_SUPPORT_KEY = '__experimentalBorder';
31
28
  export const SHADOW_SUPPORT_KEY = 'shadow';
32
29
 
30
+ const EMPTY_ARRAY = [];
31
+
33
32
  const getColorByProperty = ( colors, property, value ) => {
34
33
  let matchedColor;
35
34
 
@@ -251,14 +250,34 @@ export function hasShadowSupport( blockName ) {
251
250
  }
252
251
 
253
252
  export function useBorderPanelLabel( {
254
- blockName,
253
+ clientId,
255
254
  hasBorderControl,
256
255
  hasShadowControl,
257
256
  } = {} ) {
258
- const settings = useBlockSettings( blockName );
257
+ const [ color, radius, style, width, shadow ] = useSelect(
258
+ ( select ) => {
259
+ if ( ! clientId ) {
260
+ return EMPTY_ARRAY;
261
+ }
262
+ const { getBlockSettings } = unlock( select( blockEditorStore ) );
263
+ return getBlockSettings(
264
+ clientId,
265
+ 'border.color',
266
+ 'border.radius',
267
+ 'border.style',
268
+ 'border.width',
269
+ 'shadow'
270
+ );
271
+ },
272
+ [ clientId ]
273
+ );
274
+ const settings = useMemo(
275
+ () => ( { border: { color, radius, style, width }, shadow } ),
276
+ [ color, radius, style, width, shadow ]
277
+ );
259
278
  const controls = useHasBorderPanelControls( settings );
260
279
 
261
- if ( ! hasBorderControl && ! hasShadowControl && blockName ) {
280
+ if ( ! hasBorderControl && ! hasShadowControl && clientId ) {
262
281
  hasBorderControl =
263
282
  controls?.hasBorderColor ||
264
283
  controls?.hasBorderStyle ||
@@ -19,6 +19,7 @@ import {
19
19
  setStyleForState,
20
20
  useBlockStyleState,
21
21
  } from './block-style-state';
22
+ import { isAxialBlockGapAllowed } from './gap';
22
23
 
23
24
  export const DIMENSIONS_SUPPORT_KEY = 'dimensions';
24
25
  export const SPACING_SUPPORT_KEY = 'spacing';
@@ -68,7 +69,7 @@ export function DimensionsPanel( { clientId, name, setAttributes, settings } ) {
68
69
  const selectedState = useBlockStyleState();
69
70
  const isStateSelected = ! isDefaultBlockStyleState( selectedState );
70
71
  const isEnabled = useHasDimensionsPanel( settings, selectedState );
71
- const { style, className } = useSelect(
72
+ const { style, className, layout } = useSelect(
72
73
  ( select ) => {
73
74
  // Early return to avoid subscription when disabled
74
75
  if ( ! isEnabled ) {
@@ -79,6 +80,7 @@ export function DimensionsPanel( { clientId, name, setAttributes, settings } ) {
79
80
  return {
80
81
  style: attributes.style,
81
82
  className: attributes.className,
83
+ layout: attributes.layout,
82
84
  };
83
85
  },
84
86
  [ clientId, isEnabled ]
@@ -118,6 +120,7 @@ export function DimensionsPanel( { clientId, name, setAttributes, settings } ) {
118
120
  SPACING_SUPPORT_KEY,
119
121
  '__experimentalDefaultControls',
120
122
  ] );
123
+ const { default: defaultLayout } = getBlockSupport( name, 'layout' ) || {};
121
124
  const defaultControls = {
122
125
  // In the block inspector, minHeight and minWidth should not
123
126
  // be shown by default unless the block explicitly opts in.
@@ -133,6 +136,10 @@ export function DimensionsPanel( { clientId, name, setAttributes, settings } ) {
133
136
  as={ DimensionsInspectorControl }
134
137
  panelId={ clientId }
135
138
  settings={ settings }
139
+ allowAxialBlockGap={ isAxialBlockGapAllowed(
140
+ layout,
141
+ defaultLayout
142
+ ) }
136
143
  value={ value }
137
144
  onChange={ onChange }
138
145
  defaultControls={ defaultControls }
@@ -19,7 +19,10 @@ import {
19
19
  __experimentalDuotoneControl as DuotoneControl,
20
20
  useSettings,
21
21
  } from '../components';
22
- import { scopeSelector } from '../components/global-styles/utils';
22
+ import {
23
+ scopeSelector,
24
+ getDuotoneSlugFromPreset,
25
+ } from '../components/global-styles/utils';
23
26
  import {
24
27
  cleanEmptyObject,
25
28
  useBlockSettings,
@@ -141,8 +144,13 @@ function DuotonePanelPure( { style, setAttributes, name, clientId } ) {
141
144
  <>
142
145
  <InspectorControls group="filter">
143
146
  <StylesFiltersPanel
147
+ // The raw value, not the resolved colors. The panel
148
+ // decodes it for display, but needs the preset reference
149
+ // to know which preset is applied: two presets can hold
150
+ // the same pair of colors, and resolving first throws the
151
+ // slug away.
144
152
  value={ {
145
- filter: { duotone: duotonePresetOrColors },
153
+ filter: { duotone: duotoneStyle },
146
154
  } }
147
155
  onChange={ ( newDuotone ) => {
148
156
  const newStyle = {
@@ -166,11 +174,19 @@ function DuotonePanelPure( { style, setAttributes, name, clientId } ) {
166
174
  disableCustomDuotone={ disableCustomDuotone }
167
175
  disableCustomColors={ disableCustomColors }
168
176
  value={ duotonePresetOrColors }
169
- onChange={ ( newDuotone ) => {
170
- const maybePreset = getDuotonePresetFromColors(
171
- newDuotone,
172
- duotonePalette
173
- );
177
+ selectedSlug={ getDuotoneSlugFromPreset( duotoneStyle ) }
178
+ onChange={ ( newDuotone, index, slug ) => {
179
+ // A slug means a preset was picked out of the palette,
180
+ // so it identifies the choice exactly. Matching back by
181
+ // color would resolve to whichever preset holding those
182
+ // colors comes first, which is the wrong one whenever
183
+ // two presets share a pair.
184
+ const maybePreset = slug
185
+ ? `var:preset|duotone|${ slug }`
186
+ : getDuotonePresetFromColors(
187
+ newDuotone,
188
+ duotonePalette
189
+ );
174
190
 
175
191
  const newStyle = {
176
192
  ...style,
package/src/hooks/gap.js CHANGED
@@ -1,5 +1,21 @@
1
1
  import { getSpacingPresetCssVar } from '../components/spacing-sizes-control/utils';
2
2
 
3
+ /**
4
+ * Returns whether the current layout can use separate row and column gaps.
5
+ *
6
+ * @param {?Object} layout The block instance's layout attribute.
7
+ * @param {?Object} defaultLayout The block's default supported layout.
8
+ * @return {boolean} Whether axial block gap controls should be available.
9
+ */
10
+ export function isAxialBlockGapAllowed( layout, defaultLayout ) {
11
+ const usedLayout =
12
+ layout?.inherit || layout?.contentSize || layout?.wideSize
13
+ ? { ...layout, type: 'constrained' }
14
+ : layout || defaultLayout || {};
15
+
16
+ return [ 'flex', 'grid' ].includes( usedLayout?.type );
17
+ }
18
+
3
19
  /**
4
20
  * Returns a BoxControl object value from a given blockGap style value.
5
21
  * The string check is for backwards compatibility before Gutenberg supported
@@ -18,6 +18,8 @@ import { BLOCK_VISIBILITY_VIEWPORTS } from '../components/block-visibility/const
18
18
  import {
19
19
  DEFAULT_BLOCK_STYLE_STATE,
20
20
  getStyleForState,
21
+ hasViewportBlockStyleState,
22
+ setStyleForState,
21
23
  } from './block-style-state';
22
24
 
23
25
  const { getResponsiveMediaQueries } = unlock( globalStylesEnginePrivateApis );
@@ -273,6 +275,40 @@ export function getResponsiveChildLayoutStyles( {
273
275
  .join( '' );
274
276
  }
275
277
 
278
+ /**
279
+ * Merges child layout changes into the active layout style state.
280
+ *
281
+ * @param {Object|undefined} style Block style attributes.
282
+ * @param {Object} layout Child layout changes.
283
+ * @param {Object} selectedState Selected block style state.
284
+ * @return {Object|undefined} Updated block style attributes.
285
+ */
286
+ export function getUpdatedChildLayoutStyle( style, layout, selectedState ) {
287
+ if ( ! hasViewportBlockStyleState( selectedState ) ) {
288
+ return {
289
+ ...style,
290
+ layout: {
291
+ ...style?.layout,
292
+ ...layout,
293
+ },
294
+ };
295
+ }
296
+
297
+ const layoutState = {
298
+ viewport: selectedState.viewport,
299
+ pseudo: DEFAULT_BLOCK_STYLE_STATE.pseudo,
300
+ };
301
+ const stateStyle = getStyleForState( style, layoutState );
302
+
303
+ return setStyleForState( style, layoutState, {
304
+ ...stateStyle,
305
+ layout: {
306
+ ...stateStyle?.layout,
307
+ ...layout,
308
+ },
309
+ } );
310
+ }
311
+
276
312
  function useBlockPropsChildLayoutStyles( { style } ) {
277
313
  const { shouldRenderChildLayoutStyles, viewportSettings } = useSelect(
278
314
  ( select ) => {
@@ -374,6 +410,7 @@ function GridTools( {
374
410
  deviceType,
375
411
  viewportSettings,
376
412
  isChildBlockAGrid,
413
+ selectedState,
377
414
  } = useSelect(
378
415
  ( select ) => {
379
416
  const {
@@ -382,8 +419,8 @@ function GridTools( {
382
419
  getTemplateLock,
383
420
  getBlockAttributes,
384
421
  getSettings,
385
- } = select( blockEditorStore );
386
-
422
+ getSelectedBlockStyleState,
423
+ } = unlock( select( blockEditorStore ) );
387
424
  const _rootClientId = getBlockRootClientId( clientId );
388
425
 
389
426
  if (
@@ -414,6 +451,7 @@ function GridTools( {
414
451
  viewportSettings: settings?.__experimentalFeatures?.viewport,
415
452
  // Check if the selected child block is itself a grid.
416
453
  isChildBlockAGrid: blockAttributes?.layout?.type === 'grid',
454
+ selectedState: getSelectedBlockStyleState( clientId ),
417
455
  };
418
456
  },
419
457
  [ clientId ]
@@ -475,13 +513,7 @@ function GridTools( {
475
513
 
476
514
  function updateLayout( layout ) {
477
515
  setAttributes( {
478
- style: {
479
- ...style,
480
- layout: {
481
- ...style?.layout,
482
- ...layout,
483
- },
484
- },
516
+ style: getUpdatedChildLayoutStyle( style, layout, selectedState ),
485
517
  } );
486
518
  }
487
519
 
@@ -98,6 +98,42 @@ export function getLayoutStateOverrides(
98
98
  } );
99
99
  }
100
100
 
101
+ /**
102
+ * Checks whether the layout panel has any controls to display.
103
+ *
104
+ * @param {Object} options Options.
105
+ * @param {Object} options.layoutType Active layout type.
106
+ * @param {Object} options.constrainedType Constrained layout type.
107
+ * @param {Object} options.layoutBlockSupport Layout support settings.
108
+ * @param {boolean} options.showInheritToggle Whether to show the inherit toggle.
109
+ * @param {boolean} options.showLayoutTypeSwitcher Whether to show the layout type switcher.
110
+ * @param {boolean} options.displayControlsForLegacyLayouts Whether to show legacy layout controls.
111
+ *
112
+ * @return {boolean} Whether the layout panel has controls.
113
+ */
114
+ export function hasLayoutPanelControls( {
115
+ layoutType,
116
+ constrainedType,
117
+ layoutBlockSupport,
118
+ showInheritToggle,
119
+ showLayoutTypeSwitcher,
120
+ displayControlsForLegacyLayouts,
121
+ } ) {
122
+ const hasActiveLayoutControls =
123
+ layoutType?.name !== 'default' &&
124
+ layoutType?.hasInspectorControls( layoutBlockSupport );
125
+ const hasLegacyLayoutControls =
126
+ displayControlsForLegacyLayouts &&
127
+ constrainedType?.hasInspectorControls( layoutBlockSupport );
128
+
129
+ return !! (
130
+ showInheritToggle ||
131
+ showLayoutTypeSwitcher ||
132
+ hasActiveLayoutControls ||
133
+ hasLegacyLayoutControls
134
+ );
135
+ }
136
+
101
137
  function getLayoutContainerValues( layout = {} ) {
102
138
  return Object.fromEntries(
103
139
  Object.entries( layout || {} ).filter(
@@ -453,6 +489,14 @@ function LayoutPanelPure( {
453
489
  isDefaultBlockStyleState( selectedState ) &&
454
490
  ! inherit &&
455
491
  allowSwitching;
492
+ const showLayoutPanel = hasLayoutPanelControls( {
493
+ layoutType,
494
+ constrainedType,
495
+ layoutBlockSupport: blockSupportAndThemeSettings,
496
+ showInheritToggle,
497
+ showLayoutTypeSwitcher,
498
+ displayControlsForLegacyLayouts,
499
+ } );
456
500
 
457
501
  const onChangeLayout = ( newLayout ) => {
458
502
  if ( isViewportLayoutState ) {
@@ -488,79 +532,81 @@ function LayoutPanelPure( {
488
532
 
489
533
  return (
490
534
  <>
491
- <InspectorControls
492
- group="layout"
493
- resetAllFilter={ resetLayoutFilter }
494
- >
495
- { showInheritToggle && (
496
- <ToolsPanelItem
497
- label={ __( 'Use content width' ) }
498
- hasValue={ hasInheritToggleValue }
499
- onDeselect={ resetInheritToggle }
500
- isShownByDefault
501
- panelId={ clientId }
502
- >
503
- <ToggleControl
504
- label={ __( 'Inner blocks use content width' ) }
505
- checked={ isUsingContentWidth() }
506
- onChange={ () =>
507
- onChangeLayout( {
508
- type: isUsingContentWidth()
509
- ? 'default'
510
- : 'constrained',
511
- } )
512
- }
513
- help={
514
- isUsingContentWidth()
515
- ? __(
516
- 'Nested blocks use content width with options for full and wide widths.'
517
- )
518
- : __(
519
- 'Nested blocks will fill the width of this container.'
520
- )
521
- }
535
+ { showLayoutPanel && (
536
+ <InspectorControls
537
+ group="layout"
538
+ resetAllFilter={ resetLayoutFilter }
539
+ >
540
+ { showInheritToggle && (
541
+ <ToolsPanelItem
542
+ label={ __( 'Use content width' ) }
543
+ hasValue={ hasInheritToggleValue }
544
+ onDeselect={ resetInheritToggle }
545
+ isShownByDefault
546
+ panelId={ clientId }
547
+ >
548
+ <ToggleControl
549
+ label={ __( 'Inner blocks use content width' ) }
550
+ checked={ isUsingContentWidth() }
551
+ onChange={ () =>
552
+ onChangeLayout( {
553
+ type: isUsingContentWidth()
554
+ ? 'default'
555
+ : 'constrained',
556
+ } )
557
+ }
558
+ help={
559
+ isUsingContentWidth()
560
+ ? __(
561
+ 'Nested blocks use content width with options for full and wide widths.'
562
+ )
563
+ : __(
564
+ 'Nested blocks will fill the width of this container.'
565
+ )
566
+ }
567
+ />
568
+ </ToolsPanelItem>
569
+ ) }
570
+
571
+ { showLayoutTypeSwitcher && (
572
+ <ToolsPanelItem
573
+ label={ __( 'Layout type' ) }
574
+ hasValue={ hasLayoutTypeValue }
575
+ onDeselect={ resetLayout }
576
+ isShownByDefault
577
+ panelId={ clientId }
578
+ >
579
+ <LayoutTypeSwitcher
580
+ type={ blockLayoutType }
581
+ onChange={ onChangeType }
582
+ />
583
+ </ToolsPanelItem>
584
+ ) }
585
+
586
+ { layoutType && layoutType.name !== 'default' && (
587
+ <layoutType.inspectorControls
588
+ layout={ usedLayout }
589
+ value={ layout }
590
+ onChange={ onChangeLayout }
591
+ layoutBlockSupport={ blockSupportAndThemeSettings }
592
+ resetLayout={ resetLayoutDefaults }
593
+ name={ blockName }
594
+ clientId={ clientId }
522
595
  />
523
- </ToolsPanelItem>
524
- ) }
525
-
526
- { showLayoutTypeSwitcher && (
527
- <ToolsPanelItem
528
- label={ __( 'Layout type' ) }
529
- hasValue={ hasLayoutTypeValue }
530
- onDeselect={ resetLayout }
531
- isShownByDefault
532
- panelId={ clientId }
533
- >
534
- <LayoutTypeSwitcher
535
- type={ blockLayoutType }
536
- onChange={ onChangeType }
596
+ ) }
597
+ { constrainedType && displayControlsForLegacyLayouts && (
598
+ <constrainedType.inspectorControls
599
+ layout={ usedLayout }
600
+ value={ layout }
601
+ onChange={ onChangeLayout }
602
+ layoutBlockSupport={ blockSupportAndThemeSettings }
603
+ resetLayout={ resetLayoutDefaults }
604
+ name={ blockName }
605
+ clientId={ clientId }
537
606
  />
538
- </ToolsPanelItem>
539
- ) }
540
-
541
- { layoutType && layoutType.name !== 'default' && (
542
- <layoutType.inspectorControls
543
- layout={ usedLayout }
544
- value={ layout }
545
- onChange={ onChangeLayout }
546
- layoutBlockSupport={ blockSupportAndThemeSettings }
547
- resetLayout={ resetLayoutDefaults }
548
- name={ blockName }
549
- clientId={ clientId }
550
- />
551
- ) }
552
- { constrainedType && displayControlsForLegacyLayouts && (
553
- <constrainedType.inspectorControls
554
- layout={ usedLayout }
555
- value={ layout }
556
- onChange={ onChangeLayout }
557
- layoutBlockSupport={ blockSupportAndThemeSettings }
558
- resetLayout={ resetLayoutDefaults }
559
- name={ blockName }
560
- clientId={ clientId }
561
- />
562
- ) }
563
- </InspectorControls>
607
+ ) }
608
+ </InspectorControls>
609
+ ) }
564
610
  { ! inherit && layoutType && (
565
611
  <layoutType.toolBarControls
566
612
  layout={ usedLayout }
@@ -1,6 +1,6 @@
1
1
  import { useMemo } from '@wordpress/element';
2
2
  import { privateApis as globalStylesEnginePrivateApis } from '@wordpress/global-styles-engine';
3
- import { __ } from '@wordpress/i18n';
3
+ import { __, _x } from '@wordpress/i18n';
4
4
  import StateControl from '../components/global-styles/state-control';
5
5
  import StateControlBadges from '../components/global-styles/state-control-badges';
6
6
  import { useToolsPanelDropdownMenuProps } from '../components/global-styles/utils';
@@ -10,10 +10,13 @@ import { unlock } from '../lock-unlock';
10
10
  const { getViewportBreakpoints } = unlock( globalStylesEnginePrivateApis );
11
11
 
12
12
  export const PSEUDO_STATE_LABELS = {
13
- ':hover': __( 'Hover' ),
14
- ':focus': __( 'Focus' ),
15
- ':focus-visible': __( 'Focus-visible' ),
16
- ':active': __( 'Active' ),
13
+ ':hover': _x( 'Hover', 'Name for the CSS pseudo-class selector' ),
14
+ ':focus': _x( 'Focus', 'Name for the CSS pseudo-class selector' ),
15
+ ':focus-visible': _x(
16
+ 'Focus-visible',
17
+ 'Name for the CSS pseudo-class selector'
18
+ ),
19
+ ':active': _x( 'Active', 'Name for the CSS pseudo-class selector' ),
17
20
  };
18
21
 
19
22
  export const RESPONSIVE_STATE_LABELS = {