@wordpress/block-editor 8.3.1 → 8.5.1

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 (475) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +56 -18
  3. package/build/components/alignment-control/index.js +13 -6
  4. package/build/components/alignment-control/index.js.map +1 -1
  5. package/build/components/block-alignment-control/index.js +13 -6
  6. package/build/components/block-alignment-control/index.js.map +1 -1
  7. package/build/components/block-content-overlay/index.js +13 -4
  8. package/build/components/block-content-overlay/index.js.map +1 -1
  9. package/build/components/block-draggable/index.js +2 -3
  10. package/build/components/block-draggable/index.js.map +1 -1
  11. package/build/components/block-icon/index.js +4 -0
  12. package/build/components/block-icon/index.js.map +1 -1
  13. package/build/components/block-inspector/index.js +6 -1
  14. package/build/components/block-inspector/index.js.map +1 -1
  15. package/build/components/block-list/block-html.js +4 -1
  16. package/build/components/block-list/block-html.js.map +1 -1
  17. package/build/components/block-list/block.js +4 -1
  18. package/build/components/block-list/block.js.map +1 -1
  19. package/build/components/block-list/use-block-props/index.js +1 -6
  20. package/build/components/block-list/use-block-props/index.js.map +1 -1
  21. package/build/components/block-list/use-block-props/use-focus-first-element.js +22 -6
  22. package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  23. package/build/components/block-list/use-block-props/use-focus-handler.js +7 -1
  24. package/build/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
  25. package/build/components/block-list-appender/index.js +6 -1
  26. package/build/components/block-list-appender/index.js.map +1 -1
  27. package/build/components/block-lock/index.js +40 -0
  28. package/build/components/block-lock/index.js.map +1 -0
  29. package/build/components/block-lock/menu-item.js +52 -0
  30. package/build/components/block-lock/menu-item.js.map +1 -0
  31. package/build/components/block-lock/modal.js +155 -0
  32. package/build/components/block-lock/modal.js.map +1 -0
  33. package/build/components/block-lock/toolbar.js +65 -0
  34. package/build/components/block-lock/toolbar.js.map +1 -0
  35. package/build/components/block-lock/use-block-lock.js +53 -0
  36. package/build/components/block-lock/use-block-lock.js.map +1 -0
  37. package/build/components/block-mover/index.js +4 -0
  38. package/build/components/block-mover/index.js.map +1 -1
  39. package/build/components/block-pattern-setup/index.js +37 -22
  40. package/build/components/block-pattern-setup/index.js.map +1 -1
  41. package/build/components/block-pattern-setup/setup-toolbar.js +1 -1
  42. package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  43. package/build/components/block-preview/auto.js +6 -3
  44. package/build/components/block-preview/auto.js.map +1 -1
  45. package/build/components/block-preview/index.js +4 -2
  46. package/build/components/block-preview/index.js.map +1 -1
  47. package/build/components/block-settings-menu/block-settings-dropdown.js +75 -10
  48. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  49. package/build/components/block-settings-menu-controls/index.js +19 -9
  50. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  51. package/build/components/block-switcher/index.js +8 -3
  52. package/build/components/block-switcher/index.js.map +1 -1
  53. package/build/components/block-title/index.js +2 -2
  54. package/build/components/block-title/index.js.map +1 -1
  55. package/build/components/block-title/use-block-display-title.js +8 -6
  56. package/build/components/block-title/use-block-display-title.js.map +1 -1
  57. package/build/components/block-toolbar/block-name-context.js +17 -0
  58. package/build/components/block-toolbar/block-name-context.js.map +1 -0
  59. package/build/components/block-toolbar/block-toolbar-last-item.js +20 -0
  60. package/build/components/block-toolbar/block-toolbar-last-item.js.map +1 -0
  61. package/build/components/block-toolbar/index.js +24 -5
  62. package/build/components/block-toolbar/index.js.map +1 -1
  63. package/build/components/block-tools/index.js +0 -16
  64. package/build/components/block-tools/index.js.map +1 -1
  65. package/build/components/block-variation-transforms/index.js +92 -47
  66. package/build/components/block-variation-transforms/index.js.map +1 -1
  67. package/build/components/block-vertical-alignment-control/index.js +13 -6
  68. package/build/components/block-vertical-alignment-control/index.js.map +1 -1
  69. package/build/components/border-radius-control/index.js +0 -1
  70. package/build/components/border-radius-control/index.js.map +1 -1
  71. package/build/components/border-radius-control/utils.js +1 -1
  72. package/build/components/border-radius-control/utils.js.map +1 -1
  73. package/build/components/colors-gradients/control.js +3 -1
  74. package/build/components/colors-gradients/control.js.map +1 -1
  75. package/build/components/contrast-checker/index.js +4 -0
  76. package/build/components/contrast-checker/index.js.map +1 -1
  77. package/build/components/convert-to-group-buttons/index.js +8 -0
  78. package/build/components/convert-to-group-buttons/index.js.map +1 -1
  79. package/build/components/convert-to-group-buttons/toolbar.js +105 -0
  80. package/build/components/convert-to-group-buttons/toolbar.js.map +1 -0
  81. package/build/components/copy-handler/index.js +4 -0
  82. package/build/components/copy-handler/index.js.map +1 -1
  83. package/build/components/date-format-picker/index.js +132 -0
  84. package/build/components/date-format-picker/index.js.map +1 -0
  85. package/build/components/font-sizes/font-size-picker.js +4 -0
  86. package/build/components/font-sizes/font-size-picker.js.map +1 -1
  87. package/build/components/iframe/index.js +6 -9
  88. package/build/components/iframe/index.js.map +1 -1
  89. package/build/components/index.js +27 -0
  90. package/build/components/index.js.map +1 -1
  91. package/build/components/justify-content-control/index.js +13 -6
  92. package/build/components/justify-content-control/index.js.map +1 -1
  93. package/build/components/keyboard-shortcuts/index.js +1 -1
  94. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  95. package/build/components/line-height-control/index.js +15 -6
  96. package/build/components/line-height-control/index.js.map +1 -1
  97. package/build/components/list-view/block-select-button.js +18 -23
  98. package/build/components/list-view/block-select-button.js.map +1 -1
  99. package/build/components/list-view/block.js +38 -13
  100. package/build/components/list-view/block.js.map +1 -1
  101. package/build/components/list-view/branch.js +16 -13
  102. package/build/components/list-view/branch.js.map +1 -1
  103. package/build/components/list-view/index.js +7 -1
  104. package/build/components/list-view/index.js.map +1 -1
  105. package/build/components/list-view/use-block-selection.js +9 -2
  106. package/build/components/list-view/use-block-selection.js.map +1 -1
  107. package/build/components/media-replace-flow/index.js +4 -0
  108. package/build/components/media-replace-flow/index.js.map +1 -1
  109. package/build/components/multi-selection-inspector/index.js +1 -1
  110. package/build/components/multi-selection-inspector/index.js.map +1 -1
  111. package/build/components/rich-text/index.js +27 -5
  112. package/build/components/rich-text/index.js.map +1 -1
  113. package/build/components/rich-text/index.native.js +13 -9
  114. package/build/components/rich-text/index.native.js.map +1 -1
  115. package/build/components/rich-text/split-value.js +12 -2
  116. package/build/components/rich-text/split-value.js.map +1 -1
  117. package/build/components/rich-text/use-firefox-compat.js +49 -0
  118. package/build/components/rich-text/use-firefox-compat.js.map +1 -0
  119. package/build/components/rich-text/use-input-rules.js +34 -2
  120. package/build/components/rich-text/use-input-rules.js.map +1 -1
  121. package/build/components/skip-to-selected-block/index.js +4 -0
  122. package/build/components/skip-to-selected-block/index.js.map +1 -1
  123. package/build/components/url-popover/image-url-input-ui.js +11 -27
  124. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  125. package/build/components/writing-flow/index.js +9 -1
  126. package/build/components/writing-flow/index.js.map +1 -1
  127. package/build/components/writing-flow/use-arrow-nav.js +3 -44
  128. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  129. package/build/components/writing-flow/use-click-selection.js +68 -0
  130. package/build/components/writing-flow/use-click-selection.js.map +1 -0
  131. package/build/components/writing-flow/use-drag-selection.js +134 -0
  132. package/build/components/writing-flow/use-drag-selection.js.map +1 -0
  133. package/build/components/writing-flow/use-input.js +116 -0
  134. package/build/components/writing-flow/use-input.js.map +1 -0
  135. package/build/components/writing-flow/use-multi-selection.js +18 -38
  136. package/build/components/writing-flow/use-multi-selection.js.map +1 -1
  137. package/build/components/writing-flow/use-selection-observer.js +161 -0
  138. package/build/components/writing-flow/use-selection-observer.js.map +1 -0
  139. package/build/components/writing-flow/use-tab-nav.js +1 -8
  140. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  141. package/build/hooks/anchor.js +7 -6
  142. package/build/hooks/anchor.js.map +1 -1
  143. package/build/hooks/border-color.js +3 -3
  144. package/build/hooks/border-color.js.map +1 -1
  145. package/build/hooks/border.js +0 -14
  146. package/build/hooks/border.js.map +1 -1
  147. package/build/hooks/color.js +20 -17
  148. package/build/hooks/color.js.map +1 -1
  149. package/build/hooks/font-family.js +5 -1
  150. package/build/hooks/font-family.js.map +1 -1
  151. package/build/hooks/font-size.js +4 -2
  152. package/build/hooks/font-size.js.map +1 -1
  153. package/build/hooks/gap.js +77 -5
  154. package/build/hooks/gap.js.map +1 -1
  155. package/build/hooks/layout.js +7 -2
  156. package/build/hooks/layout.js.map +1 -1
  157. package/build/hooks/style.js +34 -3
  158. package/build/hooks/style.js.map +1 -1
  159. package/build/hooks/utils.js +29 -0
  160. package/build/hooks/utils.js.map +1 -1
  161. package/build/layouts/flex.js +82 -15
  162. package/build/layouts/flex.js.map +1 -1
  163. package/build/layouts/flow.js +22 -13
  164. package/build/layouts/flow.js.map +1 -1
  165. package/build/store/actions.js +297 -51
  166. package/build/store/actions.js.map +1 -1
  167. package/build/store/defaults.js +5 -1
  168. package/build/store/defaults.js.map +1 -1
  169. package/build/store/reducer.js +25 -13
  170. package/build/store/reducer.js.map +1 -1
  171. package/build/store/selectors.js +197 -23
  172. package/build/store/selectors.js.map +1 -1
  173. package/build/utils/dom.js +2 -1
  174. package/build/utils/dom.js.map +1 -1
  175. package/build-module/components/alignment-control/index.js +12 -4
  176. package/build-module/components/alignment-control/index.js.map +1 -1
  177. package/build-module/components/block-alignment-control/index.js +12 -4
  178. package/build-module/components/block-alignment-control/index.js.map +1 -1
  179. package/build-module/components/block-content-overlay/index.js +13 -4
  180. package/build-module/components/block-content-overlay/index.js.map +1 -1
  181. package/build-module/components/block-draggable/index.js +2 -3
  182. package/build-module/components/block-draggable/index.js.map +1 -1
  183. package/build-module/components/block-icon/index.js +4 -0
  184. package/build-module/components/block-icon/index.js.map +1 -1
  185. package/build-module/components/block-inspector/index.js +6 -1
  186. package/build-module/components/block-inspector/index.js.map +1 -1
  187. package/build-module/components/block-list/block-html.js +5 -2
  188. package/build-module/components/block-list/block-html.js.map +1 -1
  189. package/build-module/components/block-list/block.js +5 -2
  190. package/build-module/components/block-list/block.js.map +1 -1
  191. package/build-module/components/block-list/use-block-props/index.js +1 -4
  192. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  193. package/build-module/components/block-list/use-block-props/use-focus-first-element.js +22 -6
  194. package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  195. package/build-module/components/block-list/use-block-props/use-focus-handler.js +7 -1
  196. package/build-module/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
  197. package/build-module/components/block-list-appender/index.js +6 -1
  198. package/build-module/components/block-list-appender/index.js.map +1 -1
  199. package/build-module/components/block-lock/index.js +5 -0
  200. package/build-module/components/block-lock/index.js.map +1 -0
  201. package/build-module/components/block-lock/menu-item.js +39 -0
  202. package/build-module/components/block-lock/menu-item.js.map +1 -0
  203. package/build-module/components/block-lock/modal.js +138 -0
  204. package/build-module/components/block-lock/modal.js.map +1 -0
  205. package/build-module/components/block-lock/toolbar.js +51 -0
  206. package/build-module/components/block-lock/toolbar.js.map +1 -0
  207. package/build-module/components/block-lock/use-block-lock.js +44 -0
  208. package/build-module/components/block-lock/use-block-lock.js.map +1 -0
  209. package/build-module/components/block-mover/index.js +4 -0
  210. package/build-module/components/block-mover/index.js.map +1 -1
  211. package/build-module/components/block-pattern-setup/index.js +39 -24
  212. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  213. package/build-module/components/block-pattern-setup/setup-toolbar.js +1 -1
  214. package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  215. package/build-module/components/block-preview/auto.js +6 -3
  216. package/build-module/components/block-preview/auto.js.map +1 -1
  217. package/build-module/components/block-preview/index.js +4 -2
  218. package/build-module/components/block-preview/index.js.map +1 -1
  219. package/build-module/components/block-settings-menu/block-settings-dropdown.js +75 -12
  220. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  221. package/build-module/components/block-settings-menu-controls/index.js +18 -9
  222. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  223. package/build-module/components/block-switcher/index.js +9 -4
  224. package/build-module/components/block-switcher/index.js.map +1 -1
  225. package/build-module/components/block-title/index.js +2 -2
  226. package/build-module/components/block-title/index.js.map +1 -1
  227. package/build-module/components/block-title/use-block-display-title.js +8 -6
  228. package/build-module/components/block-title/use-block-display-title.js.map +1 -1
  229. package/build-module/components/block-toolbar/block-name-context.js +9 -0
  230. package/build-module/components/block-toolbar/block-name-context.js.map +1 -0
  231. package/build-module/components/block-toolbar/block-toolbar-last-item.js +11 -0
  232. package/build-module/components/block-toolbar/block-toolbar-last-item.js.map +1 -0
  233. package/build-module/components/block-toolbar/index.js +19 -4
  234. package/build-module/components/block-toolbar/index.js.map +1 -1
  235. package/build-module/components/block-tools/index.js +0 -16
  236. package/build-module/components/block-tools/index.js.map +1 -1
  237. package/build-module/components/block-variation-transforms/index.js +95 -49
  238. package/build-module/components/block-variation-transforms/index.js.map +1 -1
  239. package/build-module/components/block-vertical-alignment-control/index.js +12 -4
  240. package/build-module/components/block-vertical-alignment-control/index.js.map +1 -1
  241. package/build-module/components/border-radius-control/index.js +0 -1
  242. package/build-module/components/border-radius-control/index.js.map +1 -1
  243. package/build-module/components/border-radius-control/utils.js +1 -1
  244. package/build-module/components/border-radius-control/utils.js.map +1 -1
  245. package/build-module/components/colors-gradients/control.js +3 -1
  246. package/build-module/components/colors-gradients/control.js.map +1 -1
  247. package/build-module/components/contrast-checker/index.js +4 -0
  248. package/build-module/components/contrast-checker/index.js.map +1 -1
  249. package/build-module/components/convert-to-group-buttons/index.js +2 -1
  250. package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
  251. package/build-module/components/convert-to-group-buttons/toolbar.js +90 -0
  252. package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -0
  253. package/build-module/components/copy-handler/index.js +4 -0
  254. package/build-module/components/copy-handler/index.js.map +1 -1
  255. package/build-module/components/date-format-picker/index.js +122 -0
  256. package/build-module/components/date-format-picker/index.js.map +1 -0
  257. package/build-module/components/font-sizes/font-size-picker.js +4 -0
  258. package/build-module/components/font-sizes/font-size-picker.js.map +1 -1
  259. package/build-module/components/iframe/index.js +6 -9
  260. package/build-module/components/iframe/index.js.map +1 -1
  261. package/build-module/components/index.js +3 -0
  262. package/build-module/components/index.js.map +1 -1
  263. package/build-module/components/justify-content-control/index.js +12 -4
  264. package/build-module/components/justify-content-control/index.js.map +1 -1
  265. package/build-module/components/keyboard-shortcuts/index.js +1 -1
  266. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  267. package/build-module/components/line-height-control/index.js +14 -5
  268. package/build-module/components/line-height-control/index.js.map +1 -1
  269. package/build-module/components/list-view/block-select-button.js +19 -23
  270. package/build-module/components/list-view/block-select-button.js.map +1 -1
  271. package/build-module/components/list-view/block.js +36 -13
  272. package/build-module/components/list-view/block.js.map +1 -1
  273. package/build-module/components/list-view/branch.js +16 -13
  274. package/build-module/components/list-view/branch.js.map +1 -1
  275. package/build-module/components/list-view/index.js +7 -1
  276. package/build-module/components/list-view/index.js.map +1 -1
  277. package/build-module/components/list-view/use-block-selection.js +10 -3
  278. package/build-module/components/list-view/use-block-selection.js.map +1 -1
  279. package/build-module/components/media-replace-flow/index.js +4 -0
  280. package/build-module/components/media-replace-flow/index.js.map +1 -1
  281. package/build-module/components/multi-selection-inspector/index.js +2 -2
  282. package/build-module/components/multi-selection-inspector/index.js.map +1 -1
  283. package/build-module/components/rich-text/index.js +26 -5
  284. package/build-module/components/rich-text/index.js.map +1 -1
  285. package/build-module/components/rich-text/index.native.js +13 -9
  286. package/build-module/components/rich-text/index.native.js.map +1 -1
  287. package/build-module/components/rich-text/split-value.js +12 -2
  288. package/build-module/components/rich-text/split-value.js.map +1 -1
  289. package/build-module/components/rich-text/use-firefox-compat.js +39 -0
  290. package/build-module/components/rich-text/use-firefox-compat.js.map +1 -0
  291. package/build-module/components/rich-text/use-input-rules.js +35 -4
  292. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  293. package/build-module/components/skip-to-selected-block/index.js +4 -0
  294. package/build-module/components/skip-to-selected-block/index.js.map +1 -1
  295. package/build-module/components/url-popover/image-url-input-ui.js +12 -28
  296. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  297. package/build-module/components/writing-flow/index.js +5 -1
  298. package/build-module/components/writing-flow/index.js.map +1 -1
  299. package/build-module/components/writing-flow/use-arrow-nav.js +4 -45
  300. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  301. package/build-module/components/writing-flow/use-click-selection.js +57 -0
  302. package/build-module/components/writing-flow/use-click-selection.js.map +1 -0
  303. package/build-module/components/writing-flow/use-drag-selection.js +124 -0
  304. package/build-module/components/writing-flow/use-drag-selection.js.map +1 -0
  305. package/build-module/components/writing-flow/use-input.js +104 -0
  306. package/build-module/components/writing-flow/use-input.js.map +1 -0
  307. package/build-module/components/writing-flow/use-multi-selection.js +18 -37
  308. package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
  309. package/build-module/components/writing-flow/use-selection-observer.js +150 -0
  310. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -0
  311. package/build-module/components/writing-flow/use-tab-nav.js +1 -9
  312. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  313. package/build-module/hooks/anchor.js +7 -6
  314. package/build-module/hooks/anchor.js.map +1 -1
  315. package/build-module/hooks/border-color.js +5 -5
  316. package/build-module/hooks/border-color.js.map +1 -1
  317. package/build-module/hooks/border.js +0 -12
  318. package/build-module/hooks/border.js.map +1 -1
  319. package/build-module/hooks/color.js +19 -18
  320. package/build-module/hooks/color.js.map +1 -1
  321. package/build-module/hooks/font-family.js +3 -1
  322. package/build-module/hooks/font-family.js.map +1 -1
  323. package/build-module/hooks/font-size.js +4 -3
  324. package/build-module/hooks/font-size.js.map +1 -1
  325. package/build-module/hooks/gap.js +75 -7
  326. package/build-module/hooks/gap.js.map +1 -1
  327. package/build-module/hooks/layout.js +7 -2
  328. package/build-module/hooks/layout.js.map +1 -1
  329. package/build-module/hooks/style.js +33 -3
  330. package/build-module/hooks/style.js.map +1 -1
  331. package/build-module/hooks/utils.js +26 -0
  332. package/build-module/hooks/utils.js.map +1 -1
  333. package/build-module/layouts/flex.js +81 -16
  334. package/build-module/layouts/flex.js.map +1 -1
  335. package/build-module/layouts/flow.js +20 -13
  336. package/build-module/layouts/flow.js.map +1 -1
  337. package/build-module/store/actions.js +286 -49
  338. package/build-module/store/actions.js.map +1 -1
  339. package/build-module/store/defaults.js +5 -1
  340. package/build-module/store/defaults.js.map +1 -1
  341. package/build-module/store/reducer.js +25 -13
  342. package/build-module/store/reducer.js.map +1 -1
  343. package/build-module/store/selectors.js +186 -22
  344. package/build-module/store/selectors.js.map +1 -1
  345. package/build-module/utils/dom.js +2 -1
  346. package/build-module/utils/dom.js.map +1 -1
  347. package/build-style/style-rtl.css +248 -49
  348. package/build-style/style.css +248 -49
  349. package/build-types/utils/dom.d.ts.map +1 -1
  350. package/package.json +28 -27
  351. package/src/components/alignment-control/index.js +9 -4
  352. package/src/components/block-alignment-control/index.js +9 -4
  353. package/src/components/block-content-overlay/index.js +19 -2
  354. package/src/components/block-draggable/index.js +2 -5
  355. package/src/components/block-icon/index.js +3 -0
  356. package/src/components/block-inspector/index.js +4 -0
  357. package/src/components/block-list/block-html.js +8 -4
  358. package/src/components/block-list/block.js +5 -1
  359. package/src/components/block-list/style.scss +4 -5
  360. package/src/components/block-list/use-block-props/index.js +0 -5
  361. package/src/components/block-list/use-block-props/use-focus-first-element.js +27 -6
  362. package/src/components/block-list/use-block-props/use-focus-handler.js +8 -0
  363. package/src/components/block-list-appender/index.js +5 -0
  364. package/src/components/block-lock/index.js +4 -0
  365. package/src/components/block-lock/menu-item.js +39 -0
  366. package/src/components/block-lock/modal.js +194 -0
  367. package/src/components/block-lock/style.scss +70 -0
  368. package/src/components/block-lock/toolbar.js +51 -0
  369. package/src/components/block-lock/use-block-lock.js +49 -0
  370. package/src/components/block-mover/index.js +3 -0
  371. package/src/components/block-mover/style.scss +4 -0
  372. package/src/components/block-pattern-setup/index.js +84 -59
  373. package/src/components/block-pattern-setup/setup-toolbar.js +3 -1
  374. package/src/components/block-pattern-setup/style.scss +32 -26
  375. package/src/components/block-preview/auto.js +10 -1
  376. package/src/components/block-preview/index.js +2 -0
  377. package/src/components/block-settings-menu/block-settings-dropdown.js +109 -9
  378. package/src/components/block-settings-menu-controls/index.js +33 -12
  379. package/src/components/block-switcher/index.js +15 -3
  380. package/src/components/block-switcher/style.scss +15 -4
  381. package/src/components/block-switcher/test/__snapshots__/index.js.snap +15 -13
  382. package/src/components/block-switcher/test/index.js +2 -2
  383. package/src/components/block-title/README.md +6 -1
  384. package/src/components/block-title/index.js +2 -2
  385. package/src/components/block-title/test/index.js +43 -1
  386. package/src/components/block-title/use-block-display-title.js +10 -7
  387. package/src/components/block-toolbar/block-name-context.js +8 -0
  388. package/src/components/block-toolbar/block-toolbar-last-item.js +12 -0
  389. package/src/components/block-toolbar/index.js +24 -2
  390. package/src/components/block-toolbar/style.scss +10 -0
  391. package/src/components/block-tools/index.js +0 -19
  392. package/src/components/block-tools/style.scss +27 -0
  393. package/src/components/block-variation-transforms/index.js +105 -36
  394. package/src/components/block-variation-transforms/style.scss +1 -1
  395. package/src/components/block-vertical-alignment-control/index.js +9 -4
  396. package/src/components/border-radius-control/index.js +0 -1
  397. package/src/components/border-radius-control/test/utils.js +4 -0
  398. package/src/components/border-radius-control/utils.js +2 -1
  399. package/src/components/button-block-appender/style.scss +5 -1
  400. package/src/components/color-palette/test/__snapshots__/control.js.snap +70 -4
  401. package/src/components/colors-gradients/control.js +1 -1
  402. package/src/components/colors-gradients/style.scss +6 -0
  403. package/src/components/contrast-checker/index.js +3 -0
  404. package/src/components/convert-to-group-buttons/index.js +6 -1
  405. package/src/components/convert-to-group-buttons/toolbar.js +87 -0
  406. package/src/components/copy-handler/index.js +3 -0
  407. package/src/components/date-format-picker/README.md +58 -0
  408. package/src/components/date-format-picker/index.js +161 -0
  409. package/src/components/date-format-picker/style.scss +31 -0
  410. package/src/components/font-sizes/font-size-picker.js +3 -0
  411. package/src/components/iframe/index.js +5 -7
  412. package/src/components/index.js +3 -0
  413. package/src/components/justify-content-control/index.js +9 -4
  414. package/src/components/keyboard-shortcuts/index.js +1 -1
  415. package/src/components/line-height-control/index.js +11 -6
  416. package/src/components/link-control/README.md +1 -1
  417. package/src/components/list-view/block-select-button.js +14 -31
  418. package/src/components/list-view/block.js +55 -13
  419. package/src/components/list-view/branch.js +37 -15
  420. package/src/components/list-view/index.js +6 -0
  421. package/src/components/list-view/style.scss +56 -14
  422. package/src/components/list-view/use-block-selection.js +15 -2
  423. package/src/components/media-placeholder/README.md +8 -0
  424. package/src/components/media-replace-flow/index.js +3 -0
  425. package/src/components/multi-selection-inspector/index.js +2 -2
  426. package/src/components/rich-text/index.js +25 -2
  427. package/src/components/rich-text/index.native.js +24 -8
  428. package/src/components/rich-text/split-value.js +5 -1
  429. package/src/components/rich-text/use-firefox-compat.js +39 -0
  430. package/src/components/rich-text/use-input-rules.js +40 -3
  431. package/src/components/skip-to-selected-block/index.js +3 -0
  432. package/src/components/url-input/style.scss +3 -2
  433. package/src/components/url-popover/image-url-input-ui.js +16 -29
  434. package/src/components/writing-flow/index.js +8 -0
  435. package/src/components/writing-flow/readme.md +28 -0
  436. package/src/components/writing-flow/use-arrow-nav.js +4 -53
  437. package/src/components/writing-flow/use-click-selection.js +65 -0
  438. package/src/components/writing-flow/use-drag-selection.js +126 -0
  439. package/src/components/writing-flow/use-input.js +112 -0
  440. package/src/components/writing-flow/use-multi-selection.js +13 -36
  441. package/src/components/writing-flow/use-selection-observer.js +153 -0
  442. package/src/components/writing-flow/use-tab-nav.js +1 -11
  443. package/src/hooks/anchor.js +8 -6
  444. package/src/hooks/border-color.js +5 -5
  445. package/src/hooks/border.js +0 -13
  446. package/src/hooks/color.js +51 -24
  447. package/src/hooks/font-family.js +5 -2
  448. package/src/hooks/font-size.js +10 -7
  449. package/src/hooks/gap.js +91 -12
  450. package/src/hooks/layout.js +11 -1
  451. package/src/hooks/style.js +40 -4
  452. package/src/hooks/test/gap.js +66 -0
  453. package/src/hooks/test/style.js +94 -0
  454. package/src/hooks/test/utils.js +1 -1
  455. package/src/hooks/utils.js +26 -0
  456. package/src/layouts/flex.js +93 -6
  457. package/src/layouts/flow.js +28 -12
  458. package/src/store/actions.js +349 -32
  459. package/src/store/defaults.js +7 -1
  460. package/src/store/reducer.js +25 -10
  461. package/src/store/selectors.js +229 -27
  462. package/src/store/test/selectors.js +305 -5
  463. package/src/style.scss +2 -0
  464. package/src/utils/dom.js +2 -1
  465. package/tsconfig.tsbuildinfo +1 -1
  466. package/build/components/block-list/use-block-props/use-multi-selection.js +0 -205
  467. package/build/components/block-list/use-block-props/use-multi-selection.js.map +0 -1
  468. package/build/components/block-list/use-block-props/use-scroll-into-view.js +0 -77
  469. package/build/components/block-list/use-block-props/use-scroll-into-view.js.map +0 -1
  470. package/build-module/components/block-list/use-block-props/use-multi-selection.js +0 -192
  471. package/build-module/components/block-list/use-block-props/use-multi-selection.js.map +0 -1
  472. package/build-module/components/block-list/use-block-props/use-scroll-into-view.js +0 -63
  473. package/build-module/components/block-list/use-block-props/use-scroll-into-view.js.map +0 -1
  474. package/src/components/block-list/use-block-props/use-multi-selection.js +0 -227
  475. package/src/components/block-list/use-block-props/use-scroll-into-view.js +0 -73
@@ -0,0 +1,153 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useSelect, useDispatch } from '@wordpress/data';
5
+ import { useRefEffect } from '@wordpress/compose';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { store as blockEditorStore } from '../../store';
11
+ import { getBlockClientId } from '../../utils/dom';
12
+
13
+ /**
14
+ * Extract the selection start node from the selection. When the anchor node is
15
+ * not a text node, the selection offset is the index of a child node.
16
+ *
17
+ * @param {Selection} selection The selection.
18
+ *
19
+ * @return {Element} The selection start node.
20
+ */
21
+ function extractSelectionStartNode( selection ) {
22
+ const { anchorNode, anchorOffset } = selection;
23
+
24
+ if ( anchorNode.nodeType === anchorNode.TEXT_NODE ) {
25
+ return anchorNode;
26
+ }
27
+
28
+ return anchorNode.childNodes[ anchorOffset ];
29
+ }
30
+
31
+ /**
32
+ * Extract the selection end node from the selection. When the focus node is not
33
+ * a text node, the selection offset is the index of a child node. The selection
34
+ * reaches up to but excluding that child node.
35
+ *
36
+ * @param {Selection} selection The selection.
37
+ *
38
+ * @return {Element} The selection start node.
39
+ */
40
+ function extractSelectionEndNode( selection ) {
41
+ const { focusNode, focusOffset } = selection;
42
+
43
+ if ( focusNode.nodeType === focusNode.TEXT_NODE ) {
44
+ return focusNode;
45
+ }
46
+
47
+ return focusNode.childNodes[ focusOffset - 1 ];
48
+ }
49
+
50
+ function findDepth( a, b ) {
51
+ let depth = 0;
52
+
53
+ while ( a[ depth ] === b[ depth ] ) {
54
+ depth++;
55
+ }
56
+
57
+ return depth;
58
+ }
59
+
60
+ /**
61
+ * Sets the `contenteditable` wrapper element to `value`.
62
+ *
63
+ * @param {HTMLElement} node Block element.
64
+ * @param {boolean} value `contentEditable` value (true or false)
65
+ */
66
+ function setContentEditableWrapper( node, value ) {
67
+ node.contentEditable = value;
68
+ // Firefox doesn't automatically move focus.
69
+ if ( value ) node.focus();
70
+ }
71
+
72
+ /**
73
+ * Sets a multi-selection based on the native selection across blocks.
74
+ */
75
+ export default function useSelectionObserver() {
76
+ const { multiSelect, selectBlock, selectionChange } = useDispatch(
77
+ blockEditorStore
78
+ );
79
+ const { getBlockParents } = useSelect( blockEditorStore );
80
+ return useRefEffect(
81
+ ( node ) => {
82
+ const { ownerDocument } = node;
83
+ const { defaultView } = ownerDocument;
84
+
85
+ function onSelectionChange() {
86
+ const selection = defaultView.getSelection();
87
+
88
+ // If no selection is found, end multi selection and disable the
89
+ // contentEditable wrapper.
90
+ if ( ! selection.rangeCount || selection.isCollapsed ) {
91
+ setContentEditableWrapper( node, false );
92
+ return;
93
+ }
94
+
95
+ const clientId = getBlockClientId(
96
+ extractSelectionStartNode( selection )
97
+ );
98
+ const endClientId = getBlockClientId(
99
+ extractSelectionEndNode( selection )
100
+ );
101
+ const isSingularSelection = clientId === endClientId;
102
+
103
+ if ( isSingularSelection ) {
104
+ selectBlock( clientId );
105
+ } else {
106
+ const startPath = [
107
+ ...getBlockParents( clientId ),
108
+ clientId,
109
+ ];
110
+ const endPath = [
111
+ ...getBlockParents( endClientId ),
112
+ endClientId,
113
+ ];
114
+ const depth = findDepth( startPath, endPath );
115
+
116
+ multiSelect( startPath[ depth ], endPath[ depth ] );
117
+ }
118
+ }
119
+
120
+ function addListeners() {
121
+ ownerDocument.addEventListener(
122
+ 'selectionchange',
123
+ onSelectionChange
124
+ );
125
+ defaultView.addEventListener( 'mouseup', onSelectionChange );
126
+ }
127
+
128
+ function removeListeners() {
129
+ ownerDocument.removeEventListener(
130
+ 'selectionchange',
131
+ onSelectionChange
132
+ );
133
+ defaultView.removeEventListener( 'mouseup', onSelectionChange );
134
+ }
135
+
136
+ function resetListeners() {
137
+ removeListeners();
138
+ addListeners();
139
+ }
140
+
141
+ addListeners();
142
+ // We must allow rich text to set selection first. This ensures that
143
+ // our `selectionchange` listener is always reset to be called after
144
+ // the rich text one.
145
+ node.addEventListener( 'focusin', resetListeners );
146
+ return () => {
147
+ removeListeners();
148
+ node.removeEventListener( 'focusin', resetListeners );
149
+ };
150
+ },
151
+ [ multiSelect, selectBlock, selectionChange, getBlockParents ]
152
+ );
153
+ }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { focus } from '@wordpress/dom';
4
+ import { focus, isFormElement } from '@wordpress/dom';
5
5
  import { TAB, ESCAPE } from '@wordpress/keycodes';
6
6
  import { useSelect, useDispatch } from '@wordpress/data';
7
7
  import { useRefEffect, useMergeRefs } from '@wordpress/compose';
@@ -12,16 +12,6 @@ import { useRef } from '@wordpress/element';
12
12
  */
13
13
  import { store as blockEditorStore } from '../../store';
14
14
 
15
- function isFormElement( element ) {
16
- const { tagName } = element;
17
- return (
18
- tagName === 'INPUT' ||
19
- tagName === 'BUTTON' ||
20
- tagName === 'SELECT' ||
21
- tagName === 'TEXTAREA'
22
- );
23
- }
24
-
25
15
  export default function useTabNav() {
26
16
  const container = useRef();
27
17
  const focusCaptureBeforeRef = useRef();
@@ -25,6 +25,13 @@ import { InspectorControls } from '../components';
25
25
  */
26
26
  const ANCHOR_REGEX = /[\s#]/g;
27
27
 
28
+ const ANCHOR_SCHEMA = {
29
+ type: 'string',
30
+ source: 'attribute',
31
+ attribute: 'id',
32
+ selector: '*',
33
+ };
34
+
28
35
  /**
29
36
  * Filters registered block settings, extending attributes with anchor using ID
30
37
  * of the first node.
@@ -42,12 +49,7 @@ export function addAttribute( settings ) {
42
49
  // Gracefully handle if settings.attributes is undefined.
43
50
  settings.attributes = {
44
51
  ...settings.attributes,
45
- anchor: {
46
- type: 'string',
47
- source: 'attribute',
48
- attribute: 'id',
49
- selector: '*',
50
- },
52
+ anchor: ANCHOR_SCHEMA,
51
53
  };
52
54
  }
53
55
 
@@ -23,11 +23,11 @@ import {
23
23
  } from '../components/colors';
24
24
  import useSetting from '../components/use-setting';
25
25
  import {
26
+ BORDER_SUPPORT_KEY,
26
27
  hasBorderSupport,
27
28
  removeBorderAttribute,
28
- shouldSkipSerialization,
29
29
  } from './border';
30
- import { cleanEmptyObject } from './utils';
30
+ import { cleanEmptyObject, shouldSkipSerialization } from './utils';
31
31
 
32
32
  // Defining empty array here instead of inline avoids unnecessary re-renders of
33
33
  // color control.
@@ -200,7 +200,7 @@ function addAttributes( settings ) {
200
200
  function addSaveProps( props, blockType, attributes ) {
201
201
  if (
202
202
  ! hasBorderSupport( blockType, 'color' ) ||
203
- shouldSkipSerialization( blockType )
203
+ shouldSkipSerialization( blockType, BORDER_SUPPORT_KEY, 'color' )
204
204
  ) {
205
205
  return props;
206
206
  }
@@ -231,7 +231,7 @@ function addSaveProps( props, blockType, attributes ) {
231
231
  function addEditProps( settings ) {
232
232
  if (
233
233
  ! hasBorderSupport( settings, 'color' ) ||
234
- shouldSkipSerialization( settings )
234
+ shouldSkipSerialization( settings, BORDER_SUPPORT_KEY, 'color' )
235
235
  ) {
236
236
  return settings;
237
237
  }
@@ -266,7 +266,7 @@ export const withBorderColorPaletteStyles = createHigherOrderComponent(
266
266
 
267
267
  if (
268
268
  ! hasBorderSupport( name, 'color' ) ||
269
- shouldSkipSerialization( name )
269
+ shouldSkipSerialization( name, BORDER_SUPPORT_KEY, 'color' )
270
270
  ) {
271
271
  return <BlockListBlock { ...props } />;
272
272
  }
@@ -171,19 +171,6 @@ export function hasBorderSupport( blockName, feature = 'any' ) {
171
171
  return !! support?.[ feature ];
172
172
  }
173
173
 
174
- /**
175
- * Check whether serialization of border classes and styles should be skipped.
176
- *
177
- * @param {string|Object} blockType Block name or block type object.
178
- *
179
- * @return {boolean} Whether serialization of border properties should occur.
180
- */
181
- export function shouldSkipSerialization( blockType ) {
182
- const support = getBlockSupport( blockType, BORDER_SUPPORT_KEY );
183
-
184
- return support?.__experimentalSkipSerialization;
185
- }
186
-
187
174
  /**
188
175
  * Returns a new style object where the specified border attribute has been
189
176
  * removed.
@@ -26,7 +26,12 @@ import {
26
26
  getGradientValueBySlug,
27
27
  getGradientSlugByValue,
28
28
  } from '../components/gradients';
29
- import { cleanEmptyObject, transformStyles, immutableSet } from './utils';
29
+ import {
30
+ cleanEmptyObject,
31
+ transformStyles,
32
+ immutableSet,
33
+ shouldSkipSerialization,
34
+ } from './utils';
30
35
  import ColorPanel from './color-panel';
31
36
  import useSetting from '../components/use-setting';
32
37
 
@@ -43,12 +48,6 @@ const hasColorSupport = ( blockType ) => {
43
48
  );
44
49
  };
45
50
 
46
- const shouldSkipSerialization = ( blockType ) => {
47
- const colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );
48
-
49
- return colorSupport?.__experimentalSkipSerialization;
50
- };
51
-
52
51
  const hasLinkColorSupport = ( blockType ) => {
53
52
  if ( Platform.OS !== 'web' ) {
54
53
  return false;
@@ -248,7 +247,7 @@ function addAttributes( settings ) {
248
247
  export function addSaveProps( props, blockType, attributes ) {
249
248
  if (
250
249
  ! hasColorSupport( blockType ) ||
251
- shouldSkipSerialization( blockType )
250
+ shouldSkipSerialization( blockType, COLOR_SUPPORT_KEY )
252
251
  ) {
253
252
  return props;
254
253
  }
@@ -258,12 +257,31 @@ export function addSaveProps( props, blockType, attributes ) {
258
257
  // I'd have preferred to avoid the "style" attribute usage here
259
258
  const { backgroundColor, textColor, gradient, style } = attributes;
260
259
 
261
- const backgroundClass = getColorClassName(
262
- 'background-color',
263
- backgroundColor
264
- );
265
- const gradientClass = __experimentalGetGradientClass( gradient );
266
- const textClass = getColorClassName( 'color', textColor );
260
+ const shouldSerialize = ( feature ) =>
261
+ ! shouldSkipSerialization( blockType, COLOR_SUPPORT_KEY, feature );
262
+
263
+ // Primary color classes must come before the `has-text-color`,
264
+ // `has-background` and `has-link-color` classes to maintain backwards
265
+ // compatibility and avoid block invalidations.
266
+ const textClass = shouldSerialize( 'text' )
267
+ ? getColorClassName( 'color', textColor )
268
+ : undefined;
269
+
270
+ const gradientClass = shouldSerialize( 'gradients' )
271
+ ? __experimentalGetGradientClass( gradient )
272
+ : undefined;
273
+
274
+ const backgroundClass = shouldSerialize( 'background' )
275
+ ? getColorClassName( 'background-color', backgroundColor )
276
+ : undefined;
277
+
278
+ const serializeHasBackground =
279
+ shouldSerialize( 'background' ) || shouldSerialize( 'gradients' );
280
+ const hasBackground =
281
+ backgroundColor ||
282
+ style?.color?.background ||
283
+ ( hasGradient && ( gradient || style?.color?.gradient ) );
284
+
267
285
  const newClassName = classnames(
268
286
  props.className,
269
287
  textClass,
@@ -273,12 +291,12 @@ export function addSaveProps( props, blockType, attributes ) {
273
291
  [ backgroundClass ]:
274
292
  ( ! hasGradient || ! style?.color?.gradient ) &&
275
293
  !! backgroundClass,
276
- 'has-text-color': textColor || style?.color?.text,
277
- 'has-background':
278
- backgroundColor ||
279
- style?.color?.background ||
280
- ( hasGradient && ( gradient || style?.color?.gradient ) ),
281
- 'has-link-color': style?.elements?.link?.color,
294
+ 'has-text-color':
295
+ shouldSerialize( 'text' ) &&
296
+ ( textColor || style?.color?.text ),
297
+ 'has-background': serializeHasBackground && hasBackground,
298
+ 'has-link-color':
299
+ shouldSerialize( 'link' ) && style?.elements?.link?.color,
282
300
  }
283
301
  );
284
302
  props.className = newClassName ? newClassName : undefined;
@@ -297,7 +315,7 @@ export function addSaveProps( props, blockType, attributes ) {
297
315
  export function addEditProps( settings ) {
298
316
  if (
299
317
  ! hasColorSupport( settings ) ||
300
- shouldSkipSerialization( settings )
318
+ shouldSkipSerialization( settings, COLOR_SUPPORT_KEY )
301
319
  ) {
302
320
  return settings;
303
321
  }
@@ -589,18 +607,27 @@ export const withColorPaletteStyles = createHigherOrderComponent(
589
607
  ],
590
608
  [ userPalette, themePalette, defaultPalette ]
591
609
  );
592
- if ( ! hasColorSupport( name ) || shouldSkipSerialization( name ) ) {
610
+ if (
611
+ ! hasColorSupport( name ) ||
612
+ shouldSkipSerialization( name, COLOR_SUPPORT_KEY )
613
+ ) {
593
614
  return <BlockListBlock { ...props } />;
594
615
  }
595
616
  const extraStyles = {};
596
617
 
597
- if ( textColor ) {
618
+ if (
619
+ textColor &&
620
+ ! shouldSkipSerialization( name, COLOR_SUPPORT_KEY, 'text' )
621
+ ) {
598
622
  extraStyles.color = getColorObjectByAttributeValues(
599
623
  colors,
600
624
  textColor
601
625
  )?.color;
602
626
  }
603
- if ( backgroundColor ) {
627
+ if (
628
+ backgroundColor &&
629
+ ! shouldSkipSerialization( name, COLOR_SUPPORT_KEY, 'background' )
630
+ ) {
604
631
  extraStyles.backgroundColor = getColorObjectByAttributeValues(
605
632
  colors,
606
633
  backgroundColor
@@ -15,6 +15,8 @@ import TokenList from '@wordpress/token-list';
15
15
  */
16
16
  import useSetting from '../components/use-setting';
17
17
  import FontFamilyControl from '../components/font-family';
18
+ import { shouldSkipSerialization } from './utils';
19
+ import { TYPOGRAPHY_SUPPORT_KEY } from './typography';
18
20
 
19
21
  export const FONT_FAMILY_SUPPORT_KEY = 'typography.__experimentalFontFamily';
20
22
 
@@ -56,9 +58,10 @@ function addSaveProps( props, blockType, attributes ) {
56
58
  }
57
59
 
58
60
  if (
59
- hasBlockSupport(
61
+ shouldSkipSerialization(
60
62
  blockType,
61
- 'typography.__experimentalSkipSerialization'
63
+ TYPOGRAPHY_SUPPORT_KEY,
64
+ 'fontFamily'
62
65
  )
63
66
  ) {
64
67
  return props;
@@ -15,7 +15,12 @@ import {
15
15
  getFontSizeObjectByValue,
16
16
  FontSizePicker,
17
17
  } from '../components/font-sizes';
18
- import { cleanEmptyObject, transformStyles } from './utils';
18
+ import { TYPOGRAPHY_SUPPORT_KEY } from './typography';
19
+ import {
20
+ cleanEmptyObject,
21
+ transformStyles,
22
+ shouldSkipSerialization,
23
+ } from './utils';
19
24
  import useSetting from '../components/use-setting';
20
25
 
21
26
  export const FONT_SIZE_SUPPORT_KEY = 'typography.fontSize';
@@ -60,10 +65,7 @@ function addSaveProps( props, blockType, attributes ) {
60
65
  }
61
66
 
62
67
  if (
63
- hasBlockSupport(
64
- blockType,
65
- 'typography.__experimentalSkipSerialization'
66
- )
68
+ shouldSkipSerialization( blockType, TYPOGRAPHY_SUPPORT_KEY, 'fontSize' )
67
69
  ) {
68
70
  return props;
69
71
  }
@@ -223,9 +225,10 @@ const withFontSizeInlineStyles = createHigherOrderComponent(
223
225
  // and does have a class to extract the font size from.
224
226
  if (
225
227
  ! hasBlockSupport( blockName, FONT_SIZE_SUPPORT_KEY ) ||
226
- hasBlockSupport(
228
+ shouldSkipSerialization(
227
229
  blockName,
228
- 'typography.__experimentalSkipSerialization'
230
+ TYPOGRAPHY_SUPPORT_KEY,
231
+ 'fontSize'
229
232
  ) ||
230
233
  ! fontSize ||
231
234
  style?.typography?.fontSize
package/src/hooks/gap.js CHANGED
@@ -6,6 +6,7 @@ import { Platform } from '@wordpress/element';
6
6
  import { getBlockSupport } from '@wordpress/blocks';
7
7
  import {
8
8
  __experimentalUseCustomUnits as useCustomUnits,
9
+ __experimentalBoxControl as BoxControl,
9
10
  __experimentalUnitControl as UnitControl,
10
11
  } from '@wordpress/components';
11
12
 
@@ -14,14 +15,14 @@ import {
14
15
  */
15
16
  import { __unstableUseBlockRef as useBlockRef } from '../components/block-list/use-block-props/use-block-refs';
16
17
  import useSetting from '../components/use-setting';
17
- import { SPACING_SUPPORT_KEY } from './dimensions';
18
+ import { AXIAL_SIDES, SPACING_SUPPORT_KEY, useCustomSides } from './dimensions';
18
19
  import { cleanEmptyObject } from './utils';
19
20
 
20
21
  /**
21
22
  * Determines if there is gap support.
22
23
  *
23
24
  * @param {string|Object} blockType Block name or Block Type object.
24
- * @return {boolean} Whether there is support.
25
+ * @return {boolean} Whether there is support.
25
26
  */
26
27
  export function hasGapSupport( blockType ) {
27
28
  const support = getBlockSupport( blockType, SPACING_SUPPORT_KEY );
@@ -38,6 +39,47 @@ export function hasGapValue( props ) {
38
39
  return props.attributes.style?.spacing?.blockGap !== undefined;
39
40
  }
40
41
 
42
+ /**
43
+ * Returns a BoxControl object value from a given blockGap style value.
44
+ * The string check is for backwards compatibility before Gutenberg supported
45
+ * split gap values (row and column) and the value was a string n + unit.
46
+ *
47
+ * @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.
48
+ * @return {Object|null} A value to pass to the BoxControl component.
49
+ */
50
+ export function getGapBoxControlValueFromStyle( blockGapValue ) {
51
+ if ( ! blockGapValue ) {
52
+ return null;
53
+ }
54
+
55
+ const isValueString = typeof blockGapValue === 'string';
56
+ return {
57
+ top: isValueString ? blockGapValue : blockGapValue?.top,
58
+ left: isValueString ? blockGapValue : blockGapValue?.left,
59
+ };
60
+ }
61
+
62
+ /**
63
+ * Returns a CSS value for the `gap` property from a given blockGap style.
64
+ *
65
+ * @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.
66
+ * @param {string?} defaultValue A default gap value.
67
+ * @return {string|null} The concatenated gap value (row and column).
68
+ */
69
+ export function getGapCSSValue( blockGapValue, defaultValue = '0' ) {
70
+ const blockGapBoxControlValue = getGapBoxControlValueFromStyle(
71
+ blockGapValue
72
+ );
73
+ if ( ! blockGapBoxControlValue ) {
74
+ return null;
75
+ }
76
+
77
+ const row = blockGapBoxControlValue?.top || defaultValue;
78
+ const column = blockGapBoxControlValue?.left || defaultValue;
79
+
80
+ return row === column ? row : `${ row } ${ column }`;
81
+ }
82
+
41
83
  /**
42
84
  * Resets the gap block support attribute. This can be used when disabling
43
85
  * the gap support controls for a block via a progressive discovery panel.
@@ -82,6 +124,7 @@ export function GapEdit( props ) {
82
124
  const {
83
125
  clientId,
84
126
  attributes: { style },
127
+ name: blockName,
85
128
  setAttributes,
86
129
  } = props;
87
130
 
@@ -94,19 +137,29 @@ export function GapEdit( props ) {
94
137
  'vw',
95
138
  ],
96
139
  } );
97
-
140
+ const sides = useCustomSides( blockName, 'blockGap' );
98
141
  const ref = useBlockRef( clientId );
99
142
 
100
143
  if ( useIsGapDisabled( props ) ) {
101
144
  return null;
102
145
  }
103
146
 
147
+ const splitOnAxis =
148
+ sides && sides.some( ( side ) => AXIAL_SIDES.includes( side ) );
149
+
104
150
  const onChange = ( next ) => {
151
+ let blockGap = next;
152
+
153
+ // If splitOnAxis activated we need to return a BoxControl object to the BoxControl component.
154
+ if ( !! next && splitOnAxis ) {
155
+ blockGap = { ...getGapBoxControlValueFromStyle( next ) };
156
+ }
157
+
105
158
  const newStyle = {
106
159
  ...style,
107
160
  spacing: {
108
161
  ...style?.spacing,
109
- blockGap: next,
162
+ blockGap,
110
163
  },
111
164
  };
112
165
 
@@ -128,17 +181,43 @@ export function GapEdit( props ) {
128
181
  }
129
182
  };
130
183
 
184
+ const gapValue = getGapBoxControlValueFromStyle( style?.spacing?.blockGap );
185
+
186
+ // The BoxControl component expects a full complement of side values.
187
+ // Gap row and column values translate to top/bottom and left/right respectively.
188
+ const boxControlGapValue = splitOnAxis
189
+ ? {
190
+ ...gapValue,
191
+ right: gapValue?.left,
192
+ bottom: gapValue?.top,
193
+ }
194
+ : gapValue?.top;
195
+
131
196
  return Platform.select( {
132
197
  web: (
133
198
  <>
134
- <UnitControl
135
- label={ __( 'Block spacing' ) }
136
- __unstableInputWidth="80px"
137
- min={ 0 }
138
- onChange={ onChange }
139
- units={ units }
140
- value={ style?.spacing?.blockGap }
141
- />
199
+ { splitOnAxis ? (
200
+ <BoxControl
201
+ label={ __( 'Block spacing' ) }
202
+ min={ 0 }
203
+ onChange={ onChange }
204
+ units={ units }
205
+ sides={ sides }
206
+ values={ boxControlGapValue }
207
+ allowReset={ false }
208
+ splitOnAxis={ splitOnAxis }
209
+ />
210
+ ) : (
211
+ <UnitControl
212
+ label={ __( 'Block spacing' ) }
213
+ __unstableInputWidth="80px"
214
+ min={ 0 }
215
+ onChange={ onChange }
216
+ units={ units }
217
+ // Default to `row` for combined values.
218
+ value={ boxControlGapValue }
219
+ />
220
+ ) }
142
221
  </>
143
222
  ),
144
223
  native: null,
@@ -56,6 +56,15 @@ function LayoutPanel( { setAttributes, attributes, name: blockName } ) {
56
56
  return null;
57
57
  }
58
58
 
59
+ // Only show the inherit toggle if it's supported,
60
+ // a default theme layout is set (e.g. one that provides `contentSize` and/or `wideSize` values),
61
+ // and that the default / flow layout type is in use, as this is the only one that supports inheritance.
62
+ const showInheritToggle = !! (
63
+ allowInheriting &&
64
+ !! defaultThemeLayout &&
65
+ ( ! layout?.type || layout?.type === 'default' || layout?.inherit )
66
+ );
67
+
59
68
  const usedLayout = layout || defaultBlockLayout || {};
60
69
  const { inherit = false, type = 'default' } = usedLayout;
61
70
  /**
@@ -77,7 +86,7 @@ function LayoutPanel( { setAttributes, attributes, name: blockName } ) {
77
86
  <>
78
87
  <InspectorControls>
79
88
  <PanelBody title={ __( 'Layout' ) }>
80
- { allowInheriting && !! defaultThemeLayout && (
89
+ { showInheritToggle && (
81
90
  <ToggleControl
82
91
  label={ __( 'Inherit default layout' ) }
83
92
  checked={ !! inherit }
@@ -213,6 +222,7 @@ export const withLayoutStyles = createHigherOrderComponent(
213
222
  element &&
214
223
  createPortal(
215
224
  <LayoutStyle
225
+ blockName={ name }
216
226
  selector={ `.wp-container-${ id }` }
217
227
  layout={ usedLayout }
218
228
  style={ attributes?.style }