@wordpress/block-editor 12.16.0 → 12.16.1-next.79a6196f.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 (650) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +3 -6
  3. package/build/components/block-canvas/index.js +0 -2
  4. package/build/components/block-canvas/index.js.map +1 -1
  5. package/build/components/block-card/index.js +1 -1
  6. package/build/components/block-card/index.js.map +1 -1
  7. package/build/components/block-draggable/draggable-chip.js +6 -1
  8. package/build/components/block-draggable/draggable-chip.js.map +1 -1
  9. package/build/components/block-draggable/index.js +76 -6
  10. package/build/components/block-draggable/index.js.map +1 -1
  11. package/build/components/block-draggable/index.native.js +0 -6
  12. package/build/components/block-draggable/index.native.js.map +1 -1
  13. package/build/components/block-draggable/use-scroll-when-dragging.native.js +1 -1
  14. package/build/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -1
  15. package/build/components/block-editing-mode/index.js +2 -3
  16. package/build/components/block-editing-mode/index.js.map +1 -1
  17. package/build/components/block-inspector/index.js +1 -1
  18. package/build/components/block-inspector/index.js.map +1 -1
  19. package/build/components/block-list/block-list-item-cell.native.js +1 -0
  20. package/build/components/block-list/block-list-item-cell.native.js.map +1 -1
  21. package/build/components/block-list/block.js +245 -102
  22. package/build/components/block-list/block.js.map +1 -1
  23. package/build/components/block-list/block.native.js +46 -20
  24. package/build/components/block-list/block.native.js.map +1 -1
  25. package/build/components/block-list/index.native.js +3 -5
  26. package/build/components/block-list/index.native.js.map +1 -1
  27. package/build/components/block-list/private-block-context.js +14 -0
  28. package/build/components/block-list/private-block-context.js.map +1 -0
  29. package/build/components/block-list/use-block-props/index.js +33 -96
  30. package/build/components/block-list/use-block-props/index.js.map +1 -1
  31. package/build/components/block-list/use-in-between-inserter.js +3 -2
  32. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  33. package/build/components/block-list/use-scroll-upon-insertion.native.js +41 -0
  34. package/build/components/block-list/use-scroll-upon-insertion.native.js.map +1 -0
  35. package/build/components/block-lock/toolbar.js +21 -27
  36. package/build/components/block-lock/toolbar.js.map +1 -1
  37. package/build/components/block-mover/index.js +2 -1
  38. package/build/components/block-mover/index.js.map +1 -1
  39. package/build/components/block-patterns-list/index.js +4 -4
  40. package/build/components/block-patterns-list/index.js.map +1 -1
  41. package/build/components/block-switcher/index.js +4 -4
  42. package/build/components/block-switcher/index.js.map +1 -1
  43. package/build/components/block-toolbar/index.js +1 -2
  44. package/build/components/block-toolbar/index.js.map +1 -1
  45. package/build/components/block-tools/block-toolbar-popover.js +0 -2
  46. package/build/components/block-tools/block-toolbar-popover.js.map +1 -1
  47. package/build/components/block-variation-transforms/index.js +29 -2
  48. package/build/components/block-variation-transforms/index.js.map +1 -1
  49. package/build/components/border-radius-control/linked-button.js +1 -1
  50. package/build/components/border-radius-control/linked-button.js.map +1 -1
  51. package/build/components/colors/utils.js +10 -2
  52. package/build/components/colors/utils.js.map +1 -1
  53. package/build/components/colors/with-colors.js +6 -2
  54. package/build/components/colors/with-colors.js.map +1 -1
  55. package/build/components/font-sizes/utils.js +10 -2
  56. package/build/components/font-sizes/utils.js.map +1 -1
  57. package/build/components/global-styles/border-panel.js +2 -1
  58. package/build/components/global-styles/border-panel.js.map +1 -1
  59. package/build/components/global-styles/color-panel.js +2 -1
  60. package/build/components/global-styles/color-panel.js.map +1 -1
  61. package/build/components/global-styles/dimensions-panel.js +4 -3
  62. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  63. package/build/components/global-styles/effects-panel.js +2 -1
  64. package/build/components/global-styles/effects-panel.js.map +1 -1
  65. package/build/components/global-styles/filters-panel.js +1 -4
  66. package/build/components/global-styles/filters-panel.js.map +1 -1
  67. package/build/components/global-styles/get-global-styles-changes.js +192 -0
  68. package/build/components/global-styles/get-global-styles-changes.js.map +1 -0
  69. package/build/components/global-styles/hooks.js +3 -2
  70. package/build/components/global-styles/hooks.js.map +1 -1
  71. package/build/components/global-styles/image-settings-panel.js +7 -1
  72. package/build/components/global-styles/image-settings-panel.js.map +1 -1
  73. package/build/components/global-styles/index.js +7 -0
  74. package/build/components/global-styles/index.js.map +1 -1
  75. package/build/components/global-styles/typography-panel.js +33 -15
  76. package/build/components/global-styles/typography-panel.js.map +1 -1
  77. package/build/components/global-styles/use-global-styles-output.js +22 -8
  78. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  79. package/build/components/global-styles/utils.js +8 -1
  80. package/build/components/global-styles/utils.js.map +1 -1
  81. package/build/components/height-control/index.js +6 -2
  82. package/build/components/height-control/index.js.map +1 -1
  83. package/build/components/image-size-control/index.js +2 -2
  84. package/build/components/image-size-control/index.js.map +1 -1
  85. package/build/components/index.native.js +6 -5
  86. package/build/components/index.native.js.map +1 -1
  87. package/build/components/inner-blocks/index.js +61 -22
  88. package/build/components/inner-blocks/index.js.map +1 -1
  89. package/build/components/inner-blocks/index.native.js +18 -4
  90. package/build/components/inner-blocks/index.native.js.map +1 -1
  91. package/build/components/inner-blocks/use-inner-block-template-sync.js +5 -6
  92. package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  93. package/build/components/inner-blocks/use-nested-settings-update.js +5 -9
  94. package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  95. package/build/components/inserter/block-patterns-explorer/pattern-list.js +1 -1
  96. package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
  97. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +10 -9
  98. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  99. package/build/components/inserter/block-patterns-tab/patterns-filter.js +10 -10
  100. package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
  101. package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +9 -9
  102. package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
  103. package/build/components/inserter/block-patterns-tab/utils.js +10 -14
  104. package/build/components/inserter/block-patterns-tab/utils.js.map +1 -1
  105. package/build/components/inserter/hooks/use-block-types-state.js +4 -14
  106. package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
  107. package/build/components/inserter/hooks/use-patterns-state.js +1 -1
  108. package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
  109. package/build/components/inserter/index.js +1 -2
  110. package/build/components/inserter/index.js.map +1 -1
  111. package/build/components/inserter/library.js +3 -7
  112. package/build/components/inserter/library.js.map +1 -1
  113. package/build/components/inserter/menu.js +14 -28
  114. package/build/components/inserter/menu.js.map +1 -1
  115. package/build/components/inserter/tabs.js +21 -21
  116. package/build/components/inserter/tabs.js.map +1 -1
  117. package/build/components/inserter-draggable-blocks/index.js +1 -1
  118. package/build/components/inserter-draggable-blocks/index.js.map +1 -1
  119. package/build/components/inserter-list-item/index.js +2 -4
  120. package/build/components/inserter-list-item/index.js.map +1 -1
  121. package/build/components/inspector-controls/block-support-tools-panel.js +3 -1
  122. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  123. package/build/components/inspector-controls-tabs/index.js +34 -23
  124. package/build/components/inspector-controls-tabs/index.js.map +1 -1
  125. package/build/components/list-view/block-select-button.js +4 -0
  126. package/build/components/list-view/block-select-button.js.map +1 -1
  127. package/build/components/list-view/block.js +57 -3
  128. package/build/components/list-view/block.js.map +1 -1
  129. package/build/components/media-upload-progress/constants.js +19 -0
  130. package/build/components/media-upload-progress/constants.js.map +1 -0
  131. package/build/components/media-upload-progress/index.native.js +42 -17
  132. package/build/components/media-upload-progress/index.native.js.map +1 -1
  133. package/build/components/navigable-toolbar/index.js +9 -14
  134. package/build/components/navigable-toolbar/index.js.map +1 -1
  135. package/build/components/plain-text/index.native.js +8 -3
  136. package/build/components/plain-text/index.native.js.map +1 -1
  137. package/build/components/provider/index.js +3 -1
  138. package/build/components/provider/index.js.map +1 -1
  139. package/build/components/provider/use-block-sync.js +7 -1
  140. package/build/components/provider/use-block-sync.js.map +1 -1
  141. package/build/components/rich-text/index.js +17 -7
  142. package/build/components/rich-text/index.js.map +1 -1
  143. package/build/components/rich-text/native/index.native.js +16 -24
  144. package/build/components/rich-text/native/index.native.js.map +1 -1
  145. package/build/components/rich-text/use-input-rules.js +2 -2
  146. package/build/components/rich-text/use-input-rules.js.map +1 -1
  147. package/build/components/rich-text/use-mark-persistent.js +1 -1
  148. package/build/components/rich-text/use-mark-persistent.js.map +1 -1
  149. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
  150. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  151. package/build/components/url-input/index.js +9 -6
  152. package/build/components/url-input/index.js.map +1 -1
  153. package/build/components/use-block-commands/index.js +14 -18
  154. package/build/components/use-block-commands/index.js.map +1 -1
  155. package/build/components/use-block-drop-zone/index.js +51 -22
  156. package/build/components/use-block-drop-zone/index.js.map +1 -1
  157. package/build/components/use-moving-animation/index.js +100 -92
  158. package/build/components/use-moving-animation/index.js.map +1 -1
  159. package/build/components/use-on-block-drop/index.js +8 -11
  160. package/build/components/use-on-block-drop/index.js.map +1 -1
  161. package/build/components/writing-flow/index.js +0 -1
  162. package/build/components/writing-flow/index.js.map +1 -1
  163. package/build/components/writing-flow/use-drag-selection.js +15 -4
  164. package/build/components/writing-flow/use-drag-selection.js.map +1 -1
  165. package/build/components/writing-flow/use-selection-observer.js +73 -27
  166. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  167. package/build/components/writing-flow/use-tab-nav.js +7 -4
  168. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  169. package/build/hooks/align.js +1 -1
  170. package/build/hooks/align.js.map +1 -1
  171. package/build/hooks/anchor.js +1 -1
  172. package/build/hooks/anchor.js.map +1 -1
  173. package/build/hooks/aria-label.js +9 -1
  174. package/build/hooks/aria-label.js.map +1 -1
  175. package/build/hooks/background.js +185 -20
  176. package/build/hooks/background.js.map +1 -1
  177. package/build/hooks/border.js +5 -10
  178. package/build/hooks/border.js.map +1 -1
  179. package/build/hooks/color.js +13 -11
  180. package/build/hooks/color.js.map +1 -1
  181. package/build/hooks/custom-class-name.js +1 -1
  182. package/build/hooks/custom-class-name.js.map +1 -1
  183. package/build/hooks/custom-class-name.native.js +9 -1
  184. package/build/hooks/custom-class-name.native.js.map +1 -1
  185. package/build/hooks/dimensions.js +4 -9
  186. package/build/hooks/dimensions.js.map +1 -1
  187. package/build/hooks/font-family.js +7 -3
  188. package/build/hooks/font-family.js.map +1 -1
  189. package/build/hooks/font-size.js +1 -1
  190. package/build/hooks/font-size.js.map +1 -1
  191. package/build/hooks/index.js +4 -4
  192. package/build/hooks/index.js.map +1 -1
  193. package/build/hooks/index.native.js +5 -3
  194. package/build/hooks/index.native.js.map +1 -1
  195. package/build/hooks/layout.js +10 -4
  196. package/build/hooks/layout.js.map +1 -1
  197. package/build/hooks/style.js +1 -1
  198. package/build/hooks/style.js.map +1 -1
  199. package/build/hooks/typography.js +4 -9
  200. package/build/hooks/typography.js.map +1 -1
  201. package/build/hooks/typography.native.js +43 -18
  202. package/build/hooks/typography.native.js.map +1 -1
  203. package/build/hooks/use-typography-props.js +10 -2
  204. package/build/hooks/use-typography-props.js.map +1 -1
  205. package/build/hooks/utils.js +48 -5
  206. package/build/hooks/utils.js.map +1 -1
  207. package/build/private-apis.js +2 -4
  208. package/build/private-apis.js.map +1 -1
  209. package/build/private-apis.native.js +0 -2
  210. package/build/private-apis.native.js.map +1 -1
  211. package/build/store/actions.js +0 -16
  212. package/build/store/actions.js.map +1 -1
  213. package/build/store/private-actions.js +51 -5
  214. package/build/store/private-actions.js.map +1 -1
  215. package/build/store/private-selectors.js +12 -0
  216. package/build/store/private-selectors.js.map +1 -1
  217. package/build/store/reducer.js +14 -6
  218. package/build/store/reducer.js.map +1 -1
  219. package/build/store/selectors.js +1 -13
  220. package/build/store/selectors.js.map +1 -1
  221. package/build/store/undo-ignore.js +12 -0
  222. package/build/store/undo-ignore.js.map +1 -0
  223. package/build/store/utils.js +1 -1
  224. package/build/store/utils.js.map +1 -1
  225. package/build/utils/get-px-from-css-unit.js +16 -0
  226. package/build/utils/get-px-from-css-unit.js.map +1 -0
  227. package/build/utils/index.js +2 -2
  228. package/build/utils/index.js.map +1 -1
  229. package/build/utils/object.js +17 -38
  230. package/build/utils/object.js.map +1 -1
  231. package/build/utils/use-can-block-toolbar-be-focused.js +46 -0
  232. package/build/utils/use-can-block-toolbar-be-focused.js.map +1 -0
  233. package/build-module/components/block-canvas/index.js +0 -2
  234. package/build-module/components/block-canvas/index.js.map +1 -1
  235. package/build-module/components/block-card/index.js +1 -1
  236. package/build-module/components/block-card/index.js.map +1 -1
  237. package/build-module/components/block-draggable/draggable-chip.js +6 -1
  238. package/build-module/components/block-draggable/draggable-chip.js.map +1 -1
  239. package/build-module/components/block-draggable/index.js +76 -6
  240. package/build-module/components/block-draggable/index.js.map +1 -1
  241. package/build-module/components/block-draggable/index.native.js +1 -7
  242. package/build-module/components/block-draggable/index.native.js.map +1 -1
  243. package/build-module/components/block-draggable/use-scroll-when-dragging.native.js +1 -1
  244. package/build-module/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -1
  245. package/build-module/components/block-editing-mode/index.js +3 -4
  246. package/build-module/components/block-editing-mode/index.js.map +1 -1
  247. package/build-module/components/block-inspector/index.js +1 -1
  248. package/build-module/components/block-inspector/index.js.map +1 -1
  249. package/build-module/components/block-list/block-list-item-cell.native.js +1 -0
  250. package/build-module/components/block-list/block-list-item-cell.native.js.map +1 -1
  251. package/build-module/components/block-list/block.js +249 -106
  252. package/build-module/components/block-list/block.js.map +1 -1
  253. package/build-module/components/block-list/block.native.js +48 -22
  254. package/build-module/components/block-list/block.native.js.map +1 -1
  255. package/build-module/components/block-list/index.native.js +3 -5
  256. package/build-module/components/block-list/index.native.js.map +1 -1
  257. package/build-module/components/block-list/private-block-context.js +6 -0
  258. package/build-module/components/block-list/private-block-context.js.map +1 -0
  259. package/build-module/components/block-list/use-block-props/index.js +34 -97
  260. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  261. package/build-module/components/block-list/use-in-between-inserter.js +3 -2
  262. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  263. package/build-module/components/block-list/use-scroll-upon-insertion.native.js +33 -0
  264. package/build-module/components/block-list/use-scroll-upon-insertion.native.js.map +1 -0
  265. package/build-module/components/block-lock/toolbar.js +22 -28
  266. package/build-module/components/block-lock/toolbar.js.map +1 -1
  267. package/build-module/components/block-mover/index.js +2 -1
  268. package/build-module/components/block-mover/index.js.map +1 -1
  269. package/build-module/components/block-patterns-list/index.js +5 -5
  270. package/build-module/components/block-patterns-list/index.js.map +1 -1
  271. package/build-module/components/block-switcher/index.js +4 -4
  272. package/build-module/components/block-switcher/index.js.map +1 -1
  273. package/build-module/components/block-toolbar/index.js +1 -2
  274. package/build-module/components/block-toolbar/index.js.map +1 -1
  275. package/build-module/components/block-tools/block-toolbar-popover.js +0 -2
  276. package/build-module/components/block-tools/block-toolbar-popover.js.map +1 -1
  277. package/build-module/components/block-variation-transforms/index.js +30 -3
  278. package/build-module/components/block-variation-transforms/index.js.map +1 -1
  279. package/build-module/components/border-radius-control/linked-button.js +1 -1
  280. package/build-module/components/border-radius-control/linked-button.js.map +1 -1
  281. package/build-module/components/colors/utils.js +9 -1
  282. package/build-module/components/colors/utils.js.map +1 -1
  283. package/build-module/components/colors/with-colors.js +5 -1
  284. package/build-module/components/colors/with-colors.js.map +1 -1
  285. package/build-module/components/font-sizes/utils.js +9 -1
  286. package/build-module/components/font-sizes/utils.js.map +1 -1
  287. package/build-module/components/global-styles/border-panel.js +3 -2
  288. package/build-module/components/global-styles/border-panel.js.map +1 -1
  289. package/build-module/components/global-styles/color-panel.js +3 -2
  290. package/build-module/components/global-styles/color-panel.js.map +1 -1
  291. package/build-module/components/global-styles/dimensions-panel.js +5 -4
  292. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  293. package/build-module/components/global-styles/effects-panel.js +3 -2
  294. package/build-module/components/global-styles/effects-panel.js.map +1 -1
  295. package/build-module/components/global-styles/filters-panel.js +2 -5
  296. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  297. package/build-module/components/global-styles/get-global-styles-changes.js +184 -0
  298. package/build-module/components/global-styles/get-global-styles-changes.js.map +1 -0
  299. package/build-module/components/global-styles/hooks.js +3 -2
  300. package/build-module/components/global-styles/hooks.js.map +1 -1
  301. package/build-module/components/global-styles/image-settings-panel.js +7 -1
  302. package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
  303. package/build-module/components/global-styles/index.js +1 -0
  304. package/build-module/components/global-styles/index.js.map +1 -1
  305. package/build-module/components/global-styles/typography-panel.js +35 -17
  306. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  307. package/build-module/components/global-styles/use-global-styles-output.js +15 -1
  308. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  309. package/build-module/components/global-styles/utils.js +7 -0
  310. package/build-module/components/global-styles/utils.js.map +1 -1
  311. package/build-module/components/height-control/index.js +6 -2
  312. package/build-module/components/height-control/index.js.map +1 -1
  313. package/build-module/components/image-size-control/index.js +2 -2
  314. package/build-module/components/image-size-control/index.js.map +1 -1
  315. package/build-module/components/index.native.js +2 -1
  316. package/build-module/components/index.native.js.map +1 -1
  317. package/build-module/components/inner-blocks/index.js +62 -23
  318. package/build-module/components/inner-blocks/index.js.map +1 -1
  319. package/build-module/components/inner-blocks/index.native.js +18 -4
  320. package/build-module/components/inner-blocks/index.native.js.map +1 -1
  321. package/build-module/components/inner-blocks/use-inner-block-template-sync.js +5 -6
  322. package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  323. package/build-module/components/inner-blocks/use-nested-settings-update.js +6 -10
  324. package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  325. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
  326. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
  327. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +11 -10
  328. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  329. package/build-module/components/inserter/block-patterns-tab/patterns-filter.js +11 -11
  330. package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
  331. package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +11 -11
  332. package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
  333. package/build-module/components/inserter/block-patterns-tab/utils.js +7 -11
  334. package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -1
  335. package/build-module/components/inserter/hooks/use-block-types-state.js +4 -14
  336. package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
  337. package/build-module/components/inserter/hooks/use-patterns-state.js +2 -2
  338. package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
  339. package/build-module/components/inserter/index.js +1 -2
  340. package/build-module/components/inserter/index.js.map +1 -1
  341. package/build-module/components/inserter/library.js +3 -7
  342. package/build-module/components/inserter/library.js.map +1 -1
  343. package/build-module/components/inserter/menu.js +14 -28
  344. package/build-module/components/inserter/menu.js.map +1 -1
  345. package/build-module/components/inserter/tabs.js +22 -22
  346. package/build-module/components/inserter/tabs.js.map +1 -1
  347. package/build-module/components/inserter-draggable-blocks/index.js +2 -2
  348. package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
  349. package/build-module/components/inserter-list-item/index.js +2 -4
  350. package/build-module/components/inserter-list-item/index.js.map +1 -1
  351. package/build-module/components/inspector-controls/block-support-tools-panel.js +3 -1
  352. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  353. package/build-module/components/inspector-controls-tabs/index.js +35 -24
  354. package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
  355. package/build-module/components/list-view/block-select-button.js +4 -0
  356. package/build-module/components/list-view/block-select-button.js.map +1 -1
  357. package/build-module/components/list-view/block.js +58 -4
  358. package/build-module/components/list-view/block.js.map +1 -1
  359. package/build-module/components/media-upload-progress/constants.js +7 -0
  360. package/build-module/components/media-upload-progress/constants.js.map +1 -0
  361. package/build-module/components/media-upload-progress/index.native.js +37 -8
  362. package/build-module/components/media-upload-progress/index.native.js.map +1 -1
  363. package/build-module/components/navigable-toolbar/index.js +9 -14
  364. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  365. package/build-module/components/plain-text/index.native.js +6 -1
  366. package/build-module/components/plain-text/index.native.js.map +1 -1
  367. package/build-module/components/provider/index.js +3 -1
  368. package/build-module/components/provider/index.js.map +1 -1
  369. package/build-module/components/provider/use-block-sync.js +7 -1
  370. package/build-module/components/provider/use-block-sync.js.map +1 -1
  371. package/build-module/components/rich-text/index.js +17 -7
  372. package/build-module/components/rich-text/index.js.map +1 -1
  373. package/build-module/components/rich-text/native/index.native.js +16 -23
  374. package/build-module/components/rich-text/native/index.native.js.map +1 -1
  375. package/build-module/components/rich-text/use-input-rules.js +2 -2
  376. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  377. package/build-module/components/rich-text/use-mark-persistent.js +1 -1
  378. package/build-module/components/rich-text/use-mark-persistent.js.map +1 -1
  379. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
  380. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  381. package/build-module/components/url-input/index.js +9 -6
  382. package/build-module/components/url-input/index.js.map +1 -1
  383. package/build-module/components/use-block-commands/index.js +14 -18
  384. package/build-module/components/use-block-commands/index.js.map +1 -1
  385. package/build-module/components/use-block-drop-zone/index.js +51 -23
  386. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  387. package/build-module/components/use-moving-animation/index.js +102 -94
  388. package/build-module/components/use-moving-animation/index.js.map +1 -1
  389. package/build-module/components/use-on-block-drop/index.js +8 -11
  390. package/build-module/components/use-on-block-drop/index.js.map +1 -1
  391. package/build-module/components/writing-flow/index.js +0 -1
  392. package/build-module/components/writing-flow/index.js.map +1 -1
  393. package/build-module/components/writing-flow/use-drag-selection.js +15 -4
  394. package/build-module/components/writing-flow/use-drag-selection.js.map +1 -1
  395. package/build-module/components/writing-flow/use-selection-observer.js +73 -27
  396. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  397. package/build-module/components/writing-flow/use-tab-nav.js +7 -4
  398. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  399. package/build-module/hooks/align.js +1 -1
  400. package/build-module/hooks/align.js.map +1 -1
  401. package/build-module/hooks/anchor.js +1 -1
  402. package/build-module/hooks/anchor.js.map +1 -1
  403. package/build-module/hooks/aria-label.js +7 -1
  404. package/build-module/hooks/aria-label.js.map +1 -1
  405. package/build-module/hooks/background.js +181 -19
  406. package/build-module/hooks/background.js.map +1 -1
  407. package/build-module/hooks/border.js +2 -8
  408. package/build-module/hooks/border.js.map +1 -1
  409. package/build-module/hooks/color.js +11 -9
  410. package/build-module/hooks/color.js.map +1 -1
  411. package/build-module/hooks/custom-class-name.js +1 -1
  412. package/build-module/hooks/custom-class-name.js.map +1 -1
  413. package/build-module/hooks/custom-class-name.native.js +7 -1
  414. package/build-module/hooks/custom-class-name.native.js.map +1 -1
  415. package/build-module/hooks/dimensions.js +1 -7
  416. package/build-module/hooks/dimensions.js.map +1 -1
  417. package/build-module/hooks/font-family.js +6 -2
  418. package/build-module/hooks/font-family.js.map +1 -1
  419. package/build-module/hooks/font-size.js +1 -1
  420. package/build-module/hooks/font-size.js.map +1 -1
  421. package/build-module/hooks/index.js +5 -5
  422. package/build-module/hooks/index.js.map +1 -1
  423. package/build-module/hooks/index.native.js +6 -4
  424. package/build-module/hooks/index.native.js.map +1 -1
  425. package/build-module/hooks/layout.js +9 -3
  426. package/build-module/hooks/layout.js.map +1 -1
  427. package/build-module/hooks/style.js +1 -1
  428. package/build-module/hooks/style.js.map +1 -1
  429. package/build-module/hooks/typography.js +1 -7
  430. package/build-module/hooks/typography.js.map +1 -1
  431. package/build-module/hooks/typography.native.js +43 -17
  432. package/build-module/hooks/typography.native.js.map +1 -1
  433. package/build-module/hooks/use-typography-props.js +9 -1
  434. package/build-module/hooks/use-typography-props.js.map +1 -1
  435. package/build-module/hooks/utils.js +47 -5
  436. package/build-module/hooks/utils.js.map +1 -1
  437. package/build-module/private-apis.js +2 -4
  438. package/build-module/private-apis.js.map +1 -1
  439. package/build-module/private-apis.native.js +0 -2
  440. package/build-module/private-apis.native.js.map +1 -1
  441. package/build-module/store/actions.js +0 -15
  442. package/build-module/store/actions.js.map +1 -1
  443. package/build-module/store/private-actions.js +49 -4
  444. package/build-module/store/private-actions.js.map +1 -1
  445. package/build-module/store/private-selectors.js +11 -0
  446. package/build-module/store/private-selectors.js.map +1 -1
  447. package/build-module/store/reducer.js +14 -6
  448. package/build-module/store/reducer.js.map +1 -1
  449. package/build-module/store/selectors.js +1 -12
  450. package/build-module/store/selectors.js.map +1 -1
  451. package/build-module/store/undo-ignore.js +5 -0
  452. package/build-module/store/undo-ignore.js.map +1 -0
  453. package/build-module/store/utils.js +2 -2
  454. package/build-module/store/utils.js.map +1 -1
  455. package/build-module/utils/get-px-from-css-unit.js +9 -0
  456. package/build-module/utils/get-px-from-css-unit.js.map +1 -0
  457. package/build-module/utils/index.js +1 -1
  458. package/build-module/utils/index.js.map +1 -1
  459. package/build-module/utils/object.js +16 -37
  460. package/build-module/utils/object.js.map +1 -1
  461. package/build-module/utils/use-can-block-toolbar-be-focused.js +40 -0
  462. package/build-module/utils/use-can-block-toolbar-be-focused.js.map +1 -0
  463. package/build-style/content-rtl.css +7 -6
  464. package/build-style/content.css +7 -6
  465. package/build-style/style-rtl.css +51 -8
  466. package/build-style/style.css +51 -8
  467. package/package.json +31 -31
  468. package/src/components/alignment-control/README.md +0 -5
  469. package/src/components/block-alignment-control/README.md +0 -5
  470. package/src/components/block-alignment-matrix-control/README.md +0 -10
  471. package/src/components/block-breadcrumb/README.md +0 -5
  472. package/src/components/block-canvas/index.js +0 -2
  473. package/src/components/block-canvas/style.scss +6 -0
  474. package/src/components/block-caption/README.md +0 -5
  475. package/src/components/block-card/README.md +0 -5
  476. package/src/components/block-card/index.js +1 -1
  477. package/src/components/block-draggable/draggable-chip.js +11 -1
  478. package/src/components/block-draggable/index.js +116 -4
  479. package/src/components/block-draggable/index.native.js +0 -5
  480. package/src/components/block-draggable/style.scss +35 -0
  481. package/src/components/block-draggable/test/helpers.native.js +8 -7
  482. package/src/components/block-draggable/use-scroll-when-dragging.native.js +1 -1
  483. package/src/components/block-editing-mode/index.js +3 -3
  484. package/src/components/block-icon/README.md +0 -5
  485. package/src/components/block-inspector/README.md +0 -5
  486. package/src/components/block-inspector/index.js +3 -1
  487. package/src/components/block-list/block-list-item-cell.native.js +5 -1
  488. package/src/components/block-list/block.js +290 -119
  489. package/src/components/block-list/block.native.js +55 -21
  490. package/src/components/block-list/content.scss +14 -10
  491. package/src/components/block-list/index.native.js +3 -5
  492. package/src/components/block-list/{block-list-block-context.js → private-block-context.js} +1 -1
  493. package/src/components/block-list/use-block-props/index.js +32 -128
  494. package/src/components/block-list/use-in-between-inserter.js +4 -1
  495. package/src/components/block-list/use-scroll-upon-insertion.native.js +52 -0
  496. package/src/components/block-lock/toolbar.js +23 -34
  497. package/src/components/block-mover/README.md +0 -5
  498. package/src/components/block-mover/index.js +1 -1
  499. package/src/components/block-parent-selector/README.md +0 -5
  500. package/src/components/block-patterns-list/README.md +0 -5
  501. package/src/components/block-patterns-list/index.js +8 -5
  502. package/src/components/block-switcher/index.js +49 -59
  503. package/src/components/block-toolbar/README.md +0 -5
  504. package/src/components/block-toolbar/index.js +1 -2
  505. package/src/components/block-tools/block-toolbar-popover.js +4 -10
  506. package/src/components/block-types-list/README.md +0 -5
  507. package/src/components/block-variation-picker/README.md +0 -5
  508. package/src/components/block-variation-transforms/README.md +0 -5
  509. package/src/components/block-variation-transforms/index.js +49 -3
  510. package/src/components/border-radius-control/linked-button.js +1 -1
  511. package/src/components/caption/README.md +0 -5
  512. package/src/components/color-palette/test/__snapshots__/control.js.snap +0 -1
  513. package/src/components/colors/utils.js +8 -1
  514. package/src/components/colors/with-colors.js +3 -1
  515. package/src/components/contrast-checker/README.md +0 -4
  516. package/src/components/copy-handler/README.md +0 -10
  517. package/src/components/font-sizes/utils.js +7 -1
  518. package/src/components/global-styles/border-panel.js +2 -1
  519. package/src/components/global-styles/color-panel.js +2 -1
  520. package/src/components/global-styles/dimensions-panel.js +4 -3
  521. package/src/components/global-styles/effects-panel.js +2 -1
  522. package/src/components/global-styles/filters-panel.js +2 -5
  523. package/src/components/global-styles/get-global-styles-changes.js +210 -0
  524. package/src/components/global-styles/hooks.js +5 -0
  525. package/src/components/global-styles/image-settings-panel.js +6 -0
  526. package/src/components/global-styles/index.js +1 -0
  527. package/src/components/global-styles/test/get-global-styles-changes.js +234 -0
  528. package/src/components/global-styles/typography-panel.js +47 -14
  529. package/src/components/global-styles/use-global-styles-output.js +9 -5
  530. package/src/components/global-styles/utils.js +7 -0
  531. package/src/components/height-control/README.md +2 -7
  532. package/src/components/height-control/index.js +4 -0
  533. package/src/components/image-size-control/index.js +5 -2
  534. package/src/components/index.native.js +2 -2
  535. package/src/components/inner-blocks/index.js +68 -29
  536. package/src/components/inner-blocks/index.native.js +19 -7
  537. package/src/components/inner-blocks/use-inner-block-template-sync.js +5 -7
  538. package/src/components/inner-blocks/use-nested-settings-update.js +6 -13
  539. package/src/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
  540. package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +15 -15
  541. package/src/components/inserter/block-patterns-tab/patterns-filter.js +15 -13
  542. package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +15 -18
  543. package/src/components/inserter/block-patterns-tab/utils.js +11 -12
  544. package/src/components/inserter/hooks/use-block-types-state.js +9 -11
  545. package/src/components/inserter/hooks/use-patterns-state.js +2 -2
  546. package/src/components/inserter/index.js +0 -1
  547. package/src/components/inserter/library.js +2 -8
  548. package/src/components/inserter/menu.js +13 -31
  549. package/src/components/inserter/style.scss +6 -4
  550. package/src/components/inserter/tabs.js +34 -25
  551. package/src/components/inserter-draggable-blocks/index.js +2 -2
  552. package/src/components/inserter-list-item/index.js +6 -6
  553. package/src/components/inspector-controls/block-support-tools-panel.js +2 -0
  554. package/src/components/inspector-controls-tabs/index.js +39 -28
  555. package/src/components/inspector-controls-tabs/style.scss +3 -2
  556. package/src/components/letter-spacing-control/README.md +0 -5
  557. package/src/components/line-height-control/README.md +0 -5
  558. package/src/components/list-view/README.md +0 -5
  559. package/src/components/list-view/block-select-button.js +4 -0
  560. package/src/components/list-view/block.js +73 -2
  561. package/src/components/list-view/style.scss +6 -0
  562. package/src/components/media-upload-progress/constants.js +6 -0
  563. package/src/components/media-upload-progress/index.native.js +66 -14
  564. package/src/components/media-upload-progress/test/index.native.js +2 -2
  565. package/src/components/multi-selection-inspector/README.md +0 -5
  566. package/src/components/navigable-toolbar/index.js +13 -11
  567. package/src/components/plain-text/index.native.js +6 -1
  568. package/src/components/provider/index.js +1 -1
  569. package/src/components/provider/test/use-block-sync.js +20 -17
  570. package/src/components/provider/use-block-sync.js +6 -0
  571. package/src/components/rich-text/index.js +18 -6
  572. package/src/components/rich-text/native/index.native.js +16 -24
  573. package/src/components/rich-text/native/test/__snapshots__/index.native.js.snap +3 -3
  574. package/src/components/rich-text/native/test/index.native.js +72 -5
  575. package/src/components/rich-text/use-input-rules.js +2 -2
  576. package/src/components/rich-text/use-mark-persistent.js +1 -2
  577. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
  578. package/src/components/text-decoration-control/README.md +40 -0
  579. package/src/components/text-transform-control/README.md +0 -4
  580. package/src/components/ungroup-button/README.md +0 -5
  581. package/src/components/unit-control/README.md +0 -4
  582. package/src/components/url-input/index.js +11 -11
  583. package/src/components/use-block-commands/index.js +18 -21
  584. package/src/components/use-block-drop-zone/index.js +85 -34
  585. package/src/components/use-moving-animation/index.js +107 -103
  586. package/src/components/use-on-block-drop/index.js +7 -23
  587. package/src/components/use-on-block-drop/test/index.js +12 -26
  588. package/src/components/use-resize-canvas/README.md +0 -4
  589. package/src/components/use-settings/README.md +0 -4
  590. package/src/components/writing-flow/index.js +0 -1
  591. package/src/components/writing-flow/use-drag-selection.js +18 -4
  592. package/src/components/writing-flow/use-selection-observer.js +99 -37
  593. package/src/components/writing-flow/use-tab-nav.js +7 -7
  594. package/src/hooks/align.js +1 -5
  595. package/src/hooks/anchor.js +1 -5
  596. package/src/hooks/aria-label.js +8 -5
  597. package/src/hooks/background.js +253 -21
  598. package/src/hooks/border.js +2 -13
  599. package/src/hooks/color.js +19 -14
  600. package/src/hooks/custom-class-name.js +1 -5
  601. package/src/hooks/custom-class-name.native.js +8 -5
  602. package/src/hooks/dimensions.js +1 -7
  603. package/src/hooks/font-family.js +4 -7
  604. package/src/hooks/font-size.js +1 -6
  605. package/src/hooks/index.js +19 -5
  606. package/src/hooks/index.native.js +17 -4
  607. package/src/hooks/layout.js +5 -2
  608. package/src/hooks/style.js +1 -6
  609. package/src/hooks/test/anchor.js +4 -9
  610. package/src/hooks/test/custom-class-name.js +3 -8
  611. package/src/hooks/test/style.js +4 -14
  612. package/src/hooks/typography.js +1 -7
  613. package/src/hooks/typography.native.js +31 -33
  614. package/src/hooks/use-typography-props.js +7 -1
  615. package/src/hooks/utils.js +76 -6
  616. package/src/private-apis.js +2 -4
  617. package/src/private-apis.native.js +0 -2
  618. package/src/store/actions.js +0 -15
  619. package/src/store/private-actions.js +44 -4
  620. package/src/store/private-selectors.js +11 -0
  621. package/src/store/reducer.js +16 -5
  622. package/src/store/selectors.js +5 -13
  623. package/src/store/undo-ignore.js +4 -0
  624. package/src/store/utils.js +2 -2
  625. package/src/style.scss +1 -0
  626. package/src/utils/get-px-from-css-unit.js +8 -0
  627. package/src/utils/index.js +1 -1
  628. package/src/utils/object.js +16 -35
  629. package/src/utils/test/object.js +1 -96
  630. package/src/utils/use-can-block-toolbar-be-focused.js +48 -0
  631. package/build/components/block-list/block-list-block-context.js +0 -14
  632. package/build/components/block-list/block-list-block-context.js.map +0 -1
  633. package/build/hooks/custom-fields.js +0 -106
  634. package/build/hooks/custom-fields.js.map +0 -1
  635. package/build/utils/parse-css-unit-to-px.js +0 -302
  636. package/build/utils/parse-css-unit-to-px.js.map +0 -1
  637. package/build/utils/use-should-contextual-toolbar-show.js +0 -63
  638. package/build/utils/use-should-contextual-toolbar-show.js.map +0 -1
  639. package/build-module/components/block-list/block-list-block-context.js +0 -6
  640. package/build-module/components/block-list/block-list-block-context.js.map +0 -1
  641. package/build-module/hooks/custom-fields.js +0 -99
  642. package/build-module/hooks/custom-fields.js.map +0 -1
  643. package/build-module/utils/parse-css-unit-to-px.js +0 -294
  644. package/build-module/utils/parse-css-unit-to-px.js.map +0 -1
  645. package/build-module/utils/use-should-contextual-toolbar-show.js +0 -57
  646. package/build-module/utils/use-should-contextual-toolbar-show.js.map +0 -1
  647. package/src/hooks/custom-fields.js +0 -115
  648. package/src/utils/parse-css-unit-to-px.js +0 -329
  649. package/src/utils/test/parse-css-unit-to-px.js +0 -172
  650. package/src/utils/use-should-contextual-toolbar-show.js +0 -85
@@ -66,7 +66,6 @@ class URLInput extends Component {
66
66
  this.state = {
67
67
  suggestions: [],
68
68
  showSuggestions: false,
69
- isUpdatingSuggestions: false,
70
69
  suggestionsValue: null,
71
70
  selectedSuggestion: null,
72
71
  suggestionsListboxId: '',
@@ -102,11 +101,7 @@ class URLInput extends Component {
102
101
  }
103
102
 
104
103
  // Update suggestions when the value changes.
105
- if (
106
- prevProps.value !== value &&
107
- ! this.props.disableSuggestions &&
108
- ! this.state.isUpdatingSuggestions
109
- ) {
104
+ if ( prevProps.value !== value && ! this.props.disableSuggestions ) {
110
105
  if ( value?.length ) {
111
106
  // If the new value is not empty we need to update with suggestions for it.
112
107
  this.updateSuggestions( value );
@@ -183,7 +178,6 @@ class URLInput extends Component {
183
178
  }
184
179
 
185
180
  this.setState( {
186
- isUpdatingSuggestions: true,
187
181
  selectedSuggestion: null,
188
182
  loading: true,
189
183
  } );
@@ -203,7 +197,6 @@ class URLInput extends Component {
203
197
 
204
198
  this.setState( {
205
199
  suggestions,
206
- isUpdatingSuggestions: false,
207
200
  suggestionsValue: value,
208
201
  loading: false,
209
202
  showSuggestions: !! suggestions.length,
@@ -235,9 +228,15 @@ class URLInput extends Component {
235
228
  }
236
229
 
237
230
  this.setState( {
238
- isUpdatingSuggestions: false,
239
231
  loading: false,
240
232
  } );
233
+ } )
234
+ .finally( () => {
235
+ // If this is the current promise then reset the reference
236
+ // to allow for checking if a new request is made.
237
+ if ( this.suggestionsRequest === request ) {
238
+ this.suggestionsRequest = null;
239
+ }
241
240
  } );
242
241
 
243
242
  // Note that this assignment is handled *before* the async search request
@@ -255,11 +254,12 @@ class URLInput extends Component {
255
254
 
256
255
  // When opening the link editor, if there's a value present, we want to load the suggestions pane with the results for this input search value
257
256
  // Don't re-run the suggestions on focus if there are already suggestions present (prevents searching again when tabbing between the input and buttons)
257
+ // or there is already a request in progress.
258
258
  if (
259
259
  value &&
260
260
  ! disableSuggestions &&
261
- ! this.state.isUpdatingSuggestions &&
262
- ! ( suggestions && suggestions.length )
261
+ ! ( suggestions && suggestions.length ) &&
262
+ this.suggestionsRequest === null
263
263
  ) {
264
264
  // Ensure the suggestions are updated with the current input value.
265
265
  this.updateSuggestions( value );
@@ -26,40 +26,37 @@ import BlockIcon from '../block-icon';
26
26
  import { store as blockEditorStore } from '../../store';
27
27
 
28
28
  export const useTransformCommands = () => {
29
- const { clientIds } = useSelect( ( select ) => {
30
- const { getSelectedBlockClientIds } = select( blockEditorStore );
31
- const selectedBlockClientIds = getSelectedBlockClientIds();
32
-
33
- return {
34
- clientIds: selectedBlockClientIds,
35
- };
36
- }, [] );
37
- const blocks = useSelect(
38
- ( select ) =>
39
- select( blockEditorStore ).getBlocksByClientId( clientIds ),
40
- [ clientIds ]
41
- );
42
29
  const { replaceBlocks, multiSelect } = useDispatch( blockEditorStore );
43
- const { possibleBlockTransformations, canRemove } = useSelect(
44
- ( select ) => {
30
+ const { blocks, clientIds, canRemove, possibleBlockTransformations } =
31
+ useSelect( ( select ) => {
45
32
  const {
46
33
  getBlockRootClientId,
47
34
  getBlockTransformItems,
35
+ getSelectedBlockClientIds,
36
+ getBlocksByClientId,
48
37
  canRemoveBlocks,
49
38
  } = select( blockEditorStore );
39
+
40
+ const selectedBlockClientIds = getSelectedBlockClientIds();
41
+ const selectedBlocks = getBlocksByClientId(
42
+ selectedBlockClientIds
43
+ );
50
44
  const rootClientId = getBlockRootClientId(
51
- Array.isArray( clientIds ) ? clientIds[ 0 ] : clientIds
45
+ selectedBlockClientIds[ 0 ]
52
46
  );
53
47
  return {
48
+ blocks: selectedBlocks,
49
+ clientIds: selectedBlockClientIds,
54
50
  possibleBlockTransformations: getBlockTransformItems(
55
- blocks,
51
+ selectedBlocks,
52
+ rootClientId
53
+ ),
54
+ canRemove: canRemoveBlocks(
55
+ selectedBlockClientIds,
56
56
  rootClientId
57
57
  ),
58
- canRemove: canRemoveBlocks( clientIds, rootClientId ),
59
58
  };
60
- },
61
- [ clientIds, blocks ]
62
- );
59
+ }, [] );
63
60
 
64
61
  const isTemplate = blocks.length === 1 && isTemplatePart( blocks[ 0 ] );
65
62
 
@@ -8,7 +8,10 @@ import {
8
8
  __experimentalUseDropZone as useDropZone,
9
9
  } from '@wordpress/compose';
10
10
  import { isRTL } from '@wordpress/i18n';
11
- import { isUnmodifiedDefaultBlock as getIsUnmodifiedDefaultBlock } from '@wordpress/blocks';
11
+ import {
12
+ isUnmodifiedDefaultBlock as getIsUnmodifiedDefaultBlock,
13
+ store as blocksStore,
14
+ } from '@wordpress/blocks';
12
15
 
13
16
  /**
14
17
  * Internal dependencies
@@ -191,6 +194,50 @@ export function getDropTargetPosition(
191
194
  ];
192
195
  }
193
196
 
197
+ /**
198
+ * Check if the dragged blocks can be dropped on the target.
199
+ * @param {Function} getBlockType
200
+ * @param {Object[]} allowedBlocks
201
+ * @param {string[]} draggedBlockNames
202
+ * @param {string} targetBlockName
203
+ * @return {boolean} Whether the dragged blocks can be dropped on the target.
204
+ */
205
+ export function isDropTargetValid(
206
+ getBlockType,
207
+ allowedBlocks,
208
+ draggedBlockNames,
209
+ targetBlockName
210
+ ) {
211
+ // At root level allowedBlocks is undefined and all blocks are allowed.
212
+ // Otherwise, check if all dragged blocks are allowed.
213
+ let areBlocksAllowed = true;
214
+ if ( allowedBlocks ) {
215
+ const allowedBlockNames = allowedBlocks?.map( ( { name } ) => name );
216
+
217
+ areBlocksAllowed = draggedBlockNames.every( ( name ) =>
218
+ allowedBlockNames?.includes( name )
219
+ );
220
+ }
221
+
222
+ // Work out if dragged blocks have an allowed parent and if so
223
+ // check target block matches the allowed parent.
224
+ const draggedBlockTypes = draggedBlockNames.map( ( name ) =>
225
+ getBlockType( name )
226
+ );
227
+ const targetMatchesDraggedBlockParents = draggedBlockTypes.every(
228
+ ( block ) => {
229
+ const [ allowedParentName ] = block?.parent || [];
230
+ if ( ! allowedParentName ) {
231
+ return true;
232
+ }
233
+
234
+ return allowedParentName === targetBlockName;
235
+ }
236
+ );
237
+
238
+ return areBlocksAllowed && targetMatchesDraggedBlockParents;
239
+ }
240
+
194
241
  /**
195
242
  * @typedef {Object} WPBlockDropZoneConfig
196
243
  * @property {?HTMLElement} dropZoneElement Optional element to be used as the drop zone.
@@ -209,6 +256,8 @@ export default function useBlockDropZone( {
209
256
  // values returned by the `getRootBlockClientId` selector, which also uses
210
257
  // an empty string to represent top-level blocks.
211
258
  rootClientId: targetRootClientId = '',
259
+ parentClientId: parentBlockClientId = '',
260
+ isDisabled = false,
212
261
  } = {} ) {
213
262
  const registry = useRegistry();
214
263
  const [ dropTarget, setDropTarget ] = useState( {
@@ -216,33 +265,15 @@ export default function useBlockDropZone( {
216
265
  operation: 'insert',
217
266
  } );
218
267
 
219
- const { isDisabled, parentBlockClientId, rootBlockIndex } = useSelect(
220
- ( select ) => {
221
- const {
222
- __unstableIsWithinBlockOverlay,
223
- __unstableHasActiveBlockOverlayActive,
224
- getBlockIndex,
225
- getBlockParents,
226
- getBlockEditingMode,
227
- } = select( blockEditorStore );
228
- const blockEditingMode = getBlockEditingMode( targetRootClientId );
229
- return {
230
- parentBlockClientId:
231
- getBlockParents( targetRootClientId, true )[ 0 ] || '',
232
- rootBlockIndex: getBlockIndex( targetRootClientId ),
233
- isDisabled:
234
- blockEditingMode !== 'default' ||
235
- __unstableHasActiveBlockOverlayActive(
236
- targetRootClientId
237
- ) ||
238
- __unstableIsWithinBlockOverlay( targetRootClientId ),
239
- };
240
- },
241
- [ targetRootClientId ]
242
- );
243
-
244
- const { getBlockListSettings, getBlocks, getBlockIndex } =
245
- useSelect( blockEditorStore );
268
+ const { getBlockType } = useSelect( blocksStore );
269
+ const {
270
+ getBlockListSettings,
271
+ getBlocks,
272
+ getBlockIndex,
273
+ getDraggedBlockClientIds,
274
+ getBlockNamesByClientId,
275
+ getAllowedBlocks,
276
+ } = useSelect( blockEditorStore );
246
277
  const { showInsertionPoint, hideInsertionPoint } =
247
278
  useDispatch( blockEditorStore );
248
279
 
@@ -258,6 +289,23 @@ export default function useBlockDropZone( {
258
289
  const throttled = useThrottle(
259
290
  useCallback(
260
291
  ( event, ownerDocument ) => {
292
+ const allowedBlocks = getAllowedBlocks( targetRootClientId );
293
+ const targetBlockName = getBlockNamesByClientId( [
294
+ targetRootClientId,
295
+ ] )[ 0 ];
296
+ const draggedBlockNames = getBlockNamesByClientId(
297
+ getDraggedBlockClientIds()
298
+ );
299
+ const isBlockDroppingAllowed = isDropTargetValid(
300
+ getBlockType,
301
+ allowedBlocks,
302
+ draggedBlockNames,
303
+ targetBlockName
304
+ );
305
+ if ( ! isBlockDroppingAllowed ) {
306
+ return;
307
+ }
308
+
261
309
  const blocks = getBlocks( targetRootClientId );
262
310
 
263
311
  // The block list is empty, don't show the insertion point but still allow dropping.
@@ -299,7 +347,7 @@ export default function useBlockDropZone( {
299
347
  ? getBlockListSettings( parentBlockClientId )
300
348
  ?.orientation
301
349
  : undefined,
302
- rootBlockIndex,
350
+ rootBlockIndex: getBlockIndex( targetRootClientId ),
303
351
  }
304
352
  );
305
353
 
@@ -322,15 +370,18 @@ export default function useBlockDropZone( {
322
370
  } );
323
371
  },
324
372
  [
325
- dropZoneElement,
326
- getBlocks,
373
+ getAllowedBlocks,
327
374
  targetRootClientId,
375
+ getBlockNamesByClientId,
376
+ getDraggedBlockClientIds,
377
+ getBlockType,
378
+ getBlocks,
328
379
  getBlockListSettings,
380
+ dropZoneElement,
381
+ parentBlockClientId,
382
+ getBlockIndex,
329
383
  registry,
330
384
  showInsertionPoint,
331
- getBlockIndex,
332
- parentBlockClientId,
333
- rootBlockIndex,
334
385
  ]
335
386
  ),
336
387
  200
@@ -1,35 +1,32 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { useSpring } from '@react-spring/web';
4
+ import { Controller } from '@react-spring/web';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import {
10
- useState,
11
- useLayoutEffect,
12
- useReducer,
13
- useMemo,
14
- useRef,
15
- } from '@wordpress/element';
16
- import { useReducedMotion } from '@wordpress/compose';
9
+ import { useLayoutEffect, useMemo, useRef } from '@wordpress/element';
17
10
  import { getScrollContainer } from '@wordpress/dom';
11
+ import { useSelect } from '@wordpress/data';
18
12
 
19
13
  /**
20
- * Simple reducer used to increment a counter.
21
- *
22
- * @param {number} state Previous counter value.
23
- * @return {number} New state value.
14
+ * Internal dependencies
24
15
  */
25
- const counterReducer = ( state ) => state + 1;
16
+ import { store as blockEditorStore } from '../../store';
26
17
 
27
- const getAbsolutePosition = ( element ) => {
18
+ /**
19
+ * If the block count exceeds the threshold, we disable the reordering animation
20
+ * to avoid laginess.
21
+ */
22
+ const BLOCK_ANIMATION_THRESHOLD = 200;
23
+
24
+ function getAbsolutePosition( element ) {
28
25
  return {
29
26
  top: element.offsetTop,
30
27
  left: element.offsetLeft,
31
28
  };
32
- };
29
+ }
33
30
 
34
31
  /**
35
32
  * Hook used to compute the styles required to move a div into a new position.
@@ -42,114 +39,121 @@ const getAbsolutePosition = ( element ) => {
42
39
  * - It uses the "resetAnimation" flag to reset the animation
43
40
  * from the beginning in order to animate to the new destination point.
44
41
  *
45
- * @param {Object} $1 Options
46
- * @param {boolean} $1.isSelected Whether it's the current block or not.
47
- * @param {boolean} $1.adjustScrolling Adjust the scroll position to the current block.
48
- * @param {boolean} $1.enableAnimation Enable/Disable animation.
49
- * @param {*} $1.triggerAnimationOnChange Variable used to trigger the animation if it changes.
42
+ * @param {Object} $1 Options
43
+ * @param {*} $1.triggerAnimationOnChange Variable used to trigger the animation if it changes.
44
+ * @param {string} $1.clientId
50
45
  */
51
- function useMovingAnimation( {
52
- isSelected,
53
- adjustScrolling,
54
- enableAnimation,
55
- triggerAnimationOnChange,
56
- } ) {
46
+ function useMovingAnimation( { triggerAnimationOnChange, clientId } ) {
57
47
  const ref = useRef();
58
- const prefersReducedMotion = useReducedMotion() || ! enableAnimation;
59
- const [ triggeredAnimation, triggerAnimation ] = useReducer(
60
- counterReducer,
61
- 0
62
- );
63
- const [ finishedAnimation, endAnimation ] = useReducer( counterReducer, 0 );
64
- const [ transform, setTransform ] = useState( { x: 0, y: 0 } );
65
- const previous = useMemo(
66
- () => ( ref.current ? getAbsolutePosition( ref.current ) : null ),
48
+ const {
49
+ isTyping,
50
+ getGlobalBlockCount,
51
+ isBlockSelected,
52
+ isFirstMultiSelectedBlock,
53
+ isBlockMultiSelected,
54
+ isAncestorMultiSelected,
55
+ } = useSelect( blockEditorStore );
56
+
57
+ // Whenever the trigger changes, we need to take a snapshot of the current
58
+ // position of the block to use it as a destination point for the animation.
59
+ const { previous, prevRect } = useMemo(
60
+ () => ( {
61
+ previous: ref.current && getAbsolutePosition( ref.current ),
62
+ prevRect: ref.current && ref.current.getBoundingClientRect(),
63
+ } ),
64
+ // eslint-disable-next-line react-hooks/exhaustive-deps
67
65
  [ triggerAnimationOnChange ]
68
66
  );
69
67
 
70
- // Calculate the previous position of the block relative to the viewport and
71
- // return a function to maintain that position by scrolling.
72
- const preserveScrollPosition = useMemo( () => {
73
- if ( ! adjustScrolling || ! ref.current ) {
74
- return () => {};
68
+ useLayoutEffect( () => {
69
+ if ( ! previous || ! ref.current ) {
70
+ return;
75
71
  }
76
72
 
77
73
  const scrollContainer = getScrollContainer( ref.current );
78
-
79
- if ( ! scrollContainer ) {
80
- return () => {};
81
- }
82
-
83
- const prevRect = ref.current.getBoundingClientRect();
84
- return () => {
85
- const blockRect = ref.current.getBoundingClientRect();
86
- const diff = blockRect.top - prevRect.top;
87
-
88
- if ( diff ) {
89
- scrollContainer.scrollTop += diff;
74
+ const isSelected = isBlockSelected( clientId );
75
+ const adjustScrolling =
76
+ isSelected || isFirstMultiSelectedBlock( clientId );
77
+
78
+ function preserveScrollPosition() {
79
+ if ( adjustScrolling && prevRect ) {
80
+ const blockRect = ref.current.getBoundingClientRect();
81
+ const diff = blockRect.top - prevRect.top;
82
+
83
+ if ( diff ) {
84
+ scrollContainer.scrollTop += diff;
85
+ }
90
86
  }
91
- };
92
- }, [ triggerAnimationOnChange, adjustScrolling ] );
93
-
94
- useLayoutEffect( () => {
95
- if ( triggeredAnimation ) {
96
- endAnimation();
97
- }
98
- }, [ triggeredAnimation ] );
99
- useLayoutEffect( () => {
100
- if ( ! previous ) {
101
- return;
102
87
  }
103
88
 
104
- if ( prefersReducedMotion ) {
89
+ // We disable the animation if the user has a preference for reduced
90
+ // motion, if the user is typing (insertion by Enter), or if the block
91
+ // count exceeds the threshold (insertion caused all the blocks that
92
+ // follow to animate).
93
+ // To do: consider enableing the _moving_ animation even for large
94
+ // posts, while only disabling the _insertion_ animation?
95
+ const disableAnimation =
96
+ window.matchMedia( '(prefers-reduced-motion: reduce)' ).matches ||
97
+ isTyping() ||
98
+ getGlobalBlockCount() > BLOCK_ANIMATION_THRESHOLD;
99
+
100
+ if ( disableAnimation ) {
105
101
  // If the animation is disabled and the scroll needs to be adjusted,
106
102
  // just move directly to the final scroll position.
107
103
  preserveScrollPosition();
108
-
109
104
  return;
110
105
  }
111
106
 
107
+ const isPartOfSelection =
108
+ isSelected ||
109
+ isBlockMultiSelected( clientId ) ||
110
+ isAncestorMultiSelected( clientId );
111
+ // Make sure the other blocks move under the selected block(s).
112
+ const zIndex = isPartOfSelection ? '1' : '';
113
+
114
+ const controller = new Controller( {
115
+ x: 0,
116
+ y: 0,
117
+ config: { mass: 5, tension: 2000, friction: 200 },
118
+ onChange( { value } ) {
119
+ if ( ! ref.current ) {
120
+ return;
121
+ }
122
+ let { x, y } = value;
123
+ x = Math.round( x );
124
+ y = Math.round( y );
125
+ const finishedMoving = x === 0 && y === 0;
126
+ ref.current.style.transformOrigin = 'center center';
127
+ ref.current.style.transform = finishedMoving
128
+ ? null // Set to `null` to explicitly remove the transform.
129
+ : `translate3d(${ x }px,${ y }px,0)`;
130
+ ref.current.style.zIndex = zIndex;
131
+ preserveScrollPosition();
132
+ },
133
+ } );
134
+
112
135
  ref.current.style.transform = undefined;
113
136
  const destination = getAbsolutePosition( ref.current );
114
137
 
115
- triggerAnimation();
116
- setTransform( {
117
- x: Math.round( previous.left - destination.left ),
118
- y: Math.round( previous.top - destination.top ),
119
- } );
120
- }, [ triggerAnimationOnChange ] );
138
+ const x = Math.round( previous.left - destination.left );
139
+ const y = Math.round( previous.top - destination.top );
121
140
 
122
- function onChange( { value } ) {
123
- if ( ! ref.current ) {
124
- return;
125
- }
126
- let { x, y } = value;
127
- x = Math.round( x );
128
- y = Math.round( y );
129
- const finishedMoving = x === 0 && y === 0;
130
- ref.current.style.transformOrigin = 'center center';
131
- ref.current.style.transform = finishedMoving
132
- ? null // Set to `null` to explicitly remove the transform.
133
- : `translate3d(${ x }px,${ y }px,0)`;
134
- ref.current.style.zIndex = isSelected ? '1' : '';
135
-
136
- preserveScrollPosition();
137
- }
138
-
139
- useSpring( {
140
- from: {
141
- x: transform.x,
142
- y: transform.y,
143
- },
144
- to: {
145
- x: 0,
146
- y: 0,
147
- },
148
- reset: triggeredAnimation !== finishedAnimation,
149
- config: { mass: 5, tension: 2000, friction: 200 },
150
- immediate: prefersReducedMotion,
151
- onChange,
152
- } );
141
+ controller.start( { x: 0, y: 0, from: { x, y } } );
142
+
143
+ return () => {
144
+ controller.stop();
145
+ };
146
+ }, [
147
+ previous,
148
+ prevRect,
149
+ clientId,
150
+ isTyping,
151
+ getGlobalBlockCount,
152
+ isBlockSelected,
153
+ isFirstMultiSelectedBlock,
154
+ isBlockMultiSelected,
155
+ isAncestorMultiSelected,
156
+ ] );
153
157
 
154
158
  return ref;
155
159
  }
@@ -133,8 +133,7 @@ export function onBlockDrop(
133
133
  * A function that returns an event handler function for block-related file drop events.
134
134
  *
135
135
  * @param {string} targetRootClientId The root client id where the block(s) will be inserted.
136
- * @param {number} targetBlockIndex The index where the block(s) will be inserted.
137
- * @param {boolean} hasUploadPermissions Whether the user has upload permissions.
136
+ * @param {Function} getSettings A function that gets the block editor settings.
138
137
  * @param {Function} updateBlockAttributes A function that updates a block's attributes.
139
138
  * @param {Function} canInsertBlockType A function that returns checks whether a block type can be inserted.
140
139
  * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.
@@ -143,14 +142,13 @@ export function onBlockDrop(
143
142
  */
144
143
  export function onFilesDrop(
145
144
  targetRootClientId,
146
- targetBlockIndex,
147
- hasUploadPermissions,
145
+ getSettings,
148
146
  updateBlockAttributes,
149
147
  canInsertBlockType,
150
148
  insertOrReplaceBlocks
151
149
  ) {
152
150
  return ( files ) => {
153
- if ( ! hasUploadPermissions ) {
151
+ if ( ! getSettings().mediaUpload ) {
154
152
  return;
155
153
  }
156
154
 
@@ -175,17 +173,11 @@ export function onFilesDrop(
175
173
  /**
176
174
  * A function that returns an event handler function for block-related HTML drop events.
177
175
  *
178
- * @param {string} targetRootClientId The root client id where the block(s) will be inserted.
179
- * @param {number} targetBlockIndex The index where the block(s) will be inserted.
180
176
  * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.
181
177
  *
182
178
  * @return {Function} The event handler for a block-related HTML drop event.
183
179
  */
184
- export function onHTMLDrop(
185
- targetRootClientId,
186
- targetBlockIndex,
187
- insertOrReplaceBlocks
188
- ) {
180
+ export function onHTMLDrop( insertOrReplaceBlocks ) {
189
181
  return ( HTML ) => {
190
182
  const blocks = pasteHandler( { HTML, mode: 'BLOCKS' } );
191
183
 
@@ -211,16 +203,13 @@ export default function useOnBlockDrop(
211
203
  options = {}
212
204
  ) {
213
205
  const { operation = 'insert' } = options;
214
- const hasUploadPermissions = useSelect(
215
- ( select ) => select( blockEditorStore ).getSettings().mediaUpload,
216
- []
217
- );
218
206
  const {
219
207
  canInsertBlockType,
220
208
  getBlockIndex,
221
209
  getClientIdsOfDescendants,
222
210
  getBlockOrder,
223
211
  getBlocksByClientId,
212
+ getSettings,
224
213
  } = useSelect( blockEditorStore );
225
214
  const {
226
215
  insertBlocks,
@@ -312,17 +301,12 @@ export default function useOnBlockDrop(
312
301
  );
313
302
  const _onFilesDrop = onFilesDrop(
314
303
  targetRootClientId,
315
- targetBlockIndex,
316
- hasUploadPermissions,
304
+ getSettings,
317
305
  updateBlockAttributes,
318
306
  canInsertBlockType,
319
307
  insertOrReplaceBlocks
320
308
  );
321
- const _onHTMLDrop = onHTMLDrop(
322
- targetRootClientId,
323
- targetBlockIndex,
324
- insertOrReplaceBlocks
325
- );
309
+ const _onHTMLDrop = onHTMLDrop( insertOrReplaceBlocks );
326
310
 
327
311
  return ( event ) => {
328
312
  const files = getFilesFromDataTransfer( event.dataTransfer );