@wordpress/block-editor 12.14.0 → 12.16.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 (664) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +10 -5
  3. package/build/components/block-canvas/index.js +22 -6
  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-controls/hook.js +3 -23
  8. package/build/components/block-controls/hook.js.map +1 -1
  9. package/build/components/block-edit/context.js +5 -1
  10. package/build/components/block-edit/context.js.map +1 -1
  11. package/build/components/block-edit/index.js +18 -9
  12. package/build/components/block-edit/index.js.map +1 -1
  13. package/build/components/block-info-slot-fill/index.js +3 -4
  14. package/build/components/block-info-slot-fill/index.js.map +1 -1
  15. package/build/components/block-list/block.js +28 -9
  16. package/build/components/block-list/block.js.map +1 -1
  17. package/build/components/block-list/block.native.js +16 -5
  18. package/build/components/block-list/block.native.js.map +1 -1
  19. package/build/components/block-list/use-block-props/index.js +61 -18
  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 +4 -29
  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-is-hovered.js +4 -14
  24. package/build/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
  25. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js +4 -2
  26. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
  27. package/build/components/block-parent-selector/index.js +1 -1
  28. package/build/components/block-parent-selector/index.js.map +1 -1
  29. package/build/components/block-pattern-setup/index.js +25 -16
  30. package/build/components/block-pattern-setup/index.js.map +1 -1
  31. package/build/components/block-pattern-setup/setup-toolbar.js +4 -2
  32. package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  33. package/build/components/block-patterns-list/index.js +37 -20
  34. package/build/components/block-patterns-list/index.js.map +1 -1
  35. package/build/components/block-removal-warning-modal/index.js +2 -9
  36. package/build/components/block-removal-warning-modal/index.js.map +1 -1
  37. package/build/components/block-rename/index.js +28 -0
  38. package/build/components/block-rename/index.js.map +1 -0
  39. package/build/components/block-rename/is-empty-string.js +10 -0
  40. package/build/components/block-rename/is-empty-string.js.map +1 -0
  41. package/build/components/block-rename/modal.js +90 -0
  42. package/build/components/block-rename/modal.js.map +1 -0
  43. package/build/components/block-rename/rename-control.js +74 -0
  44. package/build/components/block-rename/rename-control.js.map +1 -0
  45. package/build/components/block-rename/use-block-rename.js +17 -0
  46. package/build/components/block-rename/use-block-rename.js.map +1 -0
  47. package/build/components/block-settings/container.native.js +6 -4
  48. package/build/components/block-settings/container.native.js.map +1 -1
  49. package/build/components/block-settings-menu/block-settings-dropdown.js +33 -20
  50. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  51. package/build/components/block-settings-menu-controls/index.js +7 -0
  52. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  53. package/build/components/block-styles/index.js +1 -1
  54. package/build/components/block-styles/index.js.map +1 -1
  55. package/build/components/block-styles/index.native.js +3 -2
  56. package/build/components/block-styles/index.native.js.map +1 -1
  57. package/build/components/block-toolbar/block-toolbar-menu.native.js +1 -1
  58. package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
  59. package/build/components/block-toolbar/index.js +89 -27
  60. package/build/components/block-toolbar/index.js.map +1 -1
  61. package/build/components/block-tools/block-toolbar-breadcrumb.js +49 -0
  62. package/build/components/block-tools/block-toolbar-breadcrumb.js.map +1 -0
  63. package/build/components/block-tools/block-toolbar-popover.js +86 -0
  64. package/build/components/block-tools/block-toolbar-popover.js.map +1 -0
  65. package/build/components/block-tools/index.js +27 -24
  66. package/build/components/block-tools/index.js.map +1 -1
  67. package/build/components/block-types-list/index.js +6 -2
  68. package/build/components/block-types-list/index.js.map +1 -1
  69. package/build/components/block-types-list/index.native.js +4 -3
  70. package/build/components/block-types-list/index.native.js.map +1 -1
  71. package/build/components/block-variation-picker/index.native.js +2 -1
  72. package/build/components/block-variation-picker/index.native.js.map +1 -1
  73. package/build/components/colors-gradients/control.js +28 -17
  74. package/build/components/colors-gradients/control.js.map +1 -1
  75. package/build/components/date-format-picker/index.js +8 -1
  76. package/build/components/date-format-picker/index.js.map +1 -1
  77. package/build/components/duotone-control/index.js +1 -4
  78. package/build/components/duotone-control/index.js.map +1 -1
  79. package/build/components/global-styles/advanced-panel.js +1 -1
  80. package/build/components/global-styles/advanced-panel.js.map +1 -1
  81. package/build/components/global-styles/color-panel.js +22 -20
  82. package/build/components/global-styles/color-panel.js.map +1 -1
  83. package/build/components/global-styles/filters-panel.js +9 -3
  84. package/build/components/global-styles/filters-panel.js.map +1 -1
  85. package/build/components/global-styles/typography-panel.js +20 -31
  86. package/build/components/global-styles/typography-panel.js.map +1 -1
  87. package/build/components/image-link-destinations/index.native.js +118 -0
  88. package/build/components/image-link-destinations/index.native.js.map +1 -0
  89. package/build/components/image-size-control/index.js +0 -5
  90. package/build/components/image-size-control/index.js.map +1 -1
  91. package/build/components/index.native.js +8 -0
  92. package/build/components/index.native.js.map +1 -1
  93. package/build/components/inner-blocks/index.js +3 -1
  94. package/build/components/inner-blocks/index.js.map +1 -1
  95. package/build/components/inner-blocks/warning-max-depth-exceeded.native.js +29 -31
  96. package/build/components/inner-blocks/warning-max-depth-exceeded.native.js.map +1 -1
  97. package/build/components/inserter/block-patterns-explorer/pattern-list.js +1 -1
  98. package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
  99. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +1 -1
  100. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  101. package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +1 -1
  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 +3 -4
  104. package/build/components/inserter/block-patterns-tab/utils.js.map +1 -1
  105. package/build/components/inserter/hooks/use-patterns-state.js +2 -1
  106. package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
  107. package/build/components/inserter/media-tab/media-panel.js +2 -2
  108. package/build/components/inserter/media-tab/media-panel.js.map +1 -1
  109. package/build/components/inserter/menu.js +14 -7
  110. package/build/components/inserter/menu.js.map +1 -1
  111. package/build/components/inserter/preview-panel.js +2 -2
  112. package/build/components/inserter/preview-panel.js.map +1 -1
  113. package/build/components/inserter-button/index.native.js +98 -0
  114. package/build/components/inserter-button/index.native.js.map +1 -0
  115. package/build/components/inserter-button/sparkles.js +23 -0
  116. package/build/components/inserter-button/sparkles.js.map +1 -0
  117. package/build/components/inserter-draggable-blocks/index.js +8 -4
  118. package/build/components/inserter-draggable-blocks/index.js.map +1 -1
  119. package/build/components/inserter-listbox/index.js +11 -6
  120. package/build/components/inserter-listbox/index.js.map +1 -1
  121. package/build/components/inserter-listbox/item.js +24 -23
  122. package/build/components/inserter-listbox/item.js.map +1 -1
  123. package/build/components/inserter-listbox/row.js +5 -5
  124. package/build/components/inserter-listbox/row.js.map +1 -1
  125. package/build/components/inspector-controls/fill.js +3 -3
  126. package/build/components/inspector-controls/fill.js.map +1 -1
  127. package/build/components/inspector-controls/fill.native.js +3 -3
  128. package/build/components/inspector-controls/fill.native.js.map +1 -1
  129. package/build/components/list-view/use-list-view-expand-selected-item.js +2 -3
  130. package/build/components/list-view/use-list-view-expand-selected-item.js.map +1 -1
  131. package/build/components/navigable-toolbar/index.js +2 -2
  132. package/build/components/navigable-toolbar/index.js.map +1 -1
  133. package/build/components/preview-options/index.js +6 -60
  134. package/build/components/preview-options/index.js.map +1 -1
  135. package/build/components/rich-text/content.js +26 -23
  136. package/build/components/rich-text/content.js.map +1 -1
  137. package/build/components/rich-text/get-rich-text-values.js +2 -1
  138. package/build/components/rich-text/get-rich-text-values.js.map +1 -1
  139. package/build/components/rich-text/index.js +2 -30
  140. package/build/components/rich-text/index.js.map +1 -1
  141. package/build/components/rich-text/index.native.js +10 -17
  142. package/build/components/rich-text/index.native.js.map +1 -1
  143. package/build/components/rich-text/native/get-format-colors.native.js +22 -24
  144. package/build/components/rich-text/native/get-format-colors.native.js.map +1 -1
  145. package/build/components/rich-text/native/index.native.js +41 -37
  146. package/build/components/rich-text/native/index.native.js.map +1 -1
  147. package/build/components/rich-text/use-input-rules.js +35 -2
  148. package/build/components/rich-text/use-input-rules.js.map +1 -1
  149. package/build/components/rich-text/with-deprecations.js +50 -0
  150. package/build/components/rich-text/with-deprecations.js.map +1 -0
  151. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
  152. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  153. package/build/components/use-block-drop-zone/index.js +74 -9
  154. package/build/components/use-block-drop-zone/index.js.map +1 -1
  155. package/build/components/use-moving-animation/index.js +2 -1
  156. package/build/components/use-moving-animation/index.js.map +1 -1
  157. package/build/components/use-on-block-drop/index.js +1 -1
  158. package/build/components/use-on-block-drop/index.js.map +1 -1
  159. package/build/components/use-resize-canvas/index.js +4 -1
  160. package/build/components/use-resize-canvas/index.js.map +1 -1
  161. package/build/components/use-settings/index.js +16 -2
  162. package/build/components/use-settings/index.js.map +1 -1
  163. package/build/hooks/align.js +20 -68
  164. package/build/hooks/align.js.map +1 -1
  165. package/build/hooks/align.native.js +11 -1
  166. package/build/hooks/align.native.js.map +1 -1
  167. package/build/hooks/anchor.js +13 -29
  168. package/build/hooks/anchor.js.map +1 -1
  169. package/build/hooks/background.js +28 -31
  170. package/build/hooks/background.js.map +1 -1
  171. package/build/hooks/block-hooks.js +24 -32
  172. package/build/hooks/block-hooks.js.map +1 -1
  173. package/build/hooks/block-renaming.js +38 -0
  174. package/build/hooks/block-renaming.js.map +1 -1
  175. package/build/hooks/border.js +58 -80
  176. package/build/hooks/border.js.map +1 -1
  177. package/build/hooks/color.js +76 -89
  178. package/build/hooks/color.js.map +1 -1
  179. package/build/hooks/content-lock-ui.js +29 -29
  180. package/build/hooks/content-lock-ui.js.map +1 -1
  181. package/build/hooks/custom-class-name.js +12 -29
  182. package/build/hooks/custom-class-name.js.map +1 -1
  183. package/build/hooks/custom-fields.js +64 -73
  184. package/build/hooks/custom-fields.js.map +1 -1
  185. package/build/hooks/dimensions.js +21 -17
  186. package/build/hooks/dimensions.js.map +1 -1
  187. package/build/hooks/duotone.js +31 -61
  188. package/build/hooks/duotone.js.map +1 -1
  189. package/build/hooks/font-family.js +16 -25
  190. package/build/hooks/font-family.js.map +1 -1
  191. package/build/hooks/font-size.js +51 -119
  192. package/build/hooks/font-size.js.map +1 -1
  193. package/build/hooks/index.js +25 -15
  194. package/build/hooks/index.js.map +1 -1
  195. package/build/hooks/index.native.js +10 -3
  196. package/build/hooks/index.native.js.map +1 -1
  197. package/build/hooks/layout-child.js +68 -0
  198. package/build/hooks/layout-child.js.map +1 -0
  199. package/build/hooks/layout.js +29 -108
  200. package/build/hooks/layout.js.map +1 -1
  201. package/build/hooks/padding.js +2 -2
  202. package/build/hooks/padding.js.map +1 -1
  203. package/build/hooks/position.js +40 -62
  204. package/build/hooks/position.js.map +1 -1
  205. package/build/hooks/style.js +51 -88
  206. package/build/hooks/style.js.map +1 -1
  207. package/build/hooks/typography.js +34 -14
  208. package/build/hooks/typography.js.map +1 -1
  209. package/build/hooks/utils.js +154 -7
  210. package/build/hooks/utils.js.map +1 -1
  211. package/build/layouts/constrained.js +4 -3
  212. package/build/layouts/constrained.js.map +1 -1
  213. package/build/private-apis.js +0 -2
  214. package/build/private-apis.js.map +1 -1
  215. package/build/store/private-actions.js +8 -0
  216. package/build/store/private-actions.js.map +1 -1
  217. package/build/store/private-selectors.js +34 -0
  218. package/build/store/private-selectors.js.map +1 -1
  219. package/build/store/reducer.js +8 -0
  220. package/build/store/reducer.js.map +1 -1
  221. package/build/store/selectors.js +10 -58
  222. package/build/store/selectors.js.map +1 -1
  223. package/build/store/utils.js +66 -0
  224. package/build/store/utils.js.map +1 -0
  225. package/build/utils/object.js +21 -61
  226. package/build/utils/object.js.map +1 -1
  227. package/build/utils/selection.js +9 -1
  228. package/build/utils/selection.js.map +1 -1
  229. package/build/utils/transform-styles/index.js +26 -6
  230. package/build/utils/transform-styles/index.js.map +1 -1
  231. package/build-module/components/block-canvas/index.js +23 -7
  232. package/build-module/components/block-canvas/index.js.map +1 -1
  233. package/build-module/components/block-card/index.js +1 -1
  234. package/build-module/components/block-card/index.js.map +1 -1
  235. package/build-module/components/block-controls/hook.js +4 -24
  236. package/build-module/components/block-controls/hook.js.map +1 -1
  237. package/build-module/components/block-edit/context.js +2 -0
  238. package/build-module/components/block-edit/context.js.map +1 -1
  239. package/build-module/components/block-edit/index.js +19 -10
  240. package/build-module/components/block-edit/index.js.map +1 -1
  241. package/build-module/components/block-info-slot-fill/index.js +3 -3
  242. package/build-module/components/block-info-slot-fill/index.js.map +1 -1
  243. package/build-module/components/block-list/block.js +29 -10
  244. package/build-module/components/block-list/block.js.map +1 -1
  245. package/build-module/components/block-list/block.native.js +16 -5
  246. package/build-module/components/block-list/block.native.js.map +1 -1
  247. package/build-module/components/block-list/use-block-props/index.js +62 -19
  248. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  249. package/build-module/components/block-list/use-block-props/use-focus-first-element.js +4 -29
  250. package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  251. package/build-module/components/block-list/use-block-props/use-is-hovered.js +4 -14
  252. package/build-module/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
  253. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js +4 -2
  254. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
  255. package/build-module/components/block-parent-selector/index.js +1 -1
  256. package/build-module/components/block-parent-selector/index.js.map +1 -1
  257. package/build-module/components/block-pattern-setup/index.js +24 -15
  258. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  259. package/build-module/components/block-pattern-setup/setup-toolbar.js +4 -2
  260. package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  261. package/build-module/components/block-patterns-list/index.js +37 -20
  262. package/build-module/components/block-patterns-list/index.js.map +1 -1
  263. package/build-module/components/block-removal-warning-modal/index.js +3 -10
  264. package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
  265. package/build-module/components/block-rename/index.js +4 -0
  266. package/build-module/components/block-rename/index.js.map +1 -0
  267. package/build-module/components/block-rename/is-empty-string.js +4 -0
  268. package/build-module/components/block-rename/is-empty-string.js.map +1 -0
  269. package/build-module/components/block-rename/modal.js +82 -0
  270. package/build-module/components/block-rename/modal.js.map +1 -0
  271. package/build-module/components/block-rename/rename-control.js +66 -0
  272. package/build-module/components/block-rename/rename-control.js.map +1 -0
  273. package/build-module/components/block-rename/use-block-rename.js +10 -0
  274. package/build-module/components/block-rename/use-block-rename.js.map +1 -0
  275. package/build-module/components/block-settings/container.native.js +4 -2
  276. package/build-module/components/block-settings/container.native.js.map +1 -1
  277. package/build-module/components/block-settings-menu/block-settings-dropdown.js +34 -21
  278. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  279. package/build-module/components/block-settings-menu-controls/index.js +7 -0
  280. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  281. package/build-module/components/block-styles/index.js +1 -1
  282. package/build-module/components/block-styles/index.js.map +1 -1
  283. package/build-module/components/block-styles/index.native.js +3 -2
  284. package/build-module/components/block-styles/index.native.js.map +1 -1
  285. package/build-module/components/block-toolbar/block-toolbar-menu.native.js +1 -1
  286. package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
  287. package/build-module/components/block-toolbar/index.js +88 -25
  288. package/build-module/components/block-toolbar/index.js.map +1 -1
  289. package/build-module/components/block-tools/block-toolbar-breadcrumb.js +41 -0
  290. package/build-module/components/block-tools/block-toolbar-breadcrumb.js.map +1 -0
  291. package/build-module/components/block-tools/block-toolbar-popover.js +76 -0
  292. package/build-module/components/block-tools/block-toolbar-popover.js.map +1 -0
  293. package/build-module/components/block-tools/index.js +27 -24
  294. package/build-module/components/block-tools/index.js.map +1 -1
  295. package/build-module/components/block-types-list/index.js +6 -2
  296. package/build-module/components/block-types-list/index.js.map +1 -1
  297. package/build-module/components/block-types-list/index.native.js +2 -1
  298. package/build-module/components/block-types-list/index.native.js.map +1 -1
  299. package/build-module/components/block-variation-picker/index.native.js +2 -1
  300. package/build-module/components/block-variation-picker/index.native.js.map +1 -1
  301. package/build-module/components/colors-gradients/control.js +29 -18
  302. package/build-module/components/colors-gradients/control.js.map +1 -1
  303. package/build-module/components/date-format-picker/index.js +8 -1
  304. package/build-module/components/date-format-picker/index.js.map +1 -1
  305. package/build-module/components/duotone-control/index.js +1 -4
  306. package/build-module/components/duotone-control/index.js.map +1 -1
  307. package/build-module/components/global-styles/advanced-panel.js +1 -1
  308. package/build-module/components/global-styles/advanced-panel.js.map +1 -1
  309. package/build-module/components/global-styles/color-panel.js +23 -21
  310. package/build-module/components/global-styles/color-panel.js.map +1 -1
  311. package/build-module/components/global-styles/filters-panel.js +10 -4
  312. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  313. package/build-module/components/global-styles/typography-panel.js +20 -31
  314. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  315. package/build-module/components/image-link-destinations/index.native.js +109 -0
  316. package/build-module/components/image-link-destinations/index.native.js.map +1 -0
  317. package/build-module/components/image-size-control/index.js +0 -5
  318. package/build-module/components/image-size-control/index.js.map +1 -1
  319. package/build-module/components/index.native.js +1 -0
  320. package/build-module/components/index.native.js.map +1 -1
  321. package/build-module/components/inner-blocks/index.js +3 -1
  322. package/build-module/components/inner-blocks/index.js.map +1 -1
  323. package/build-module/components/inner-blocks/warning-max-depth-exceeded.native.js +30 -32
  324. package/build-module/components/inner-blocks/warning-max-depth-exceeded.native.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 +4 -4
  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/use-pattern-categories.js +2 -2
  330. package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
  331. package/build-module/components/inserter/block-patterns-tab/utils.js +3 -4
  332. package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -1
  333. package/build-module/components/inserter/hooks/use-patterns-state.js +2 -1
  334. package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
  335. package/build-module/components/inserter/media-tab/media-panel.js +1 -1
  336. package/build-module/components/inserter/media-tab/media-panel.js.map +1 -1
  337. package/build-module/components/inserter/menu.js +14 -7
  338. package/build-module/components/inserter/menu.js.map +1 -1
  339. package/build-module/components/inserter/preview-panel.js +2 -2
  340. package/build-module/components/inserter/preview-panel.js.map +1 -1
  341. package/build-module/components/inserter-button/index.native.js +89 -0
  342. package/build-module/components/inserter-button/index.native.js.map +1 -0
  343. package/build-module/components/inserter-button/sparkles.js +15 -0
  344. package/build-module/components/inserter-button/sparkles.js.map +1 -0
  345. package/build-module/components/inserter-draggable-blocks/index.js +9 -5
  346. package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
  347. package/build-module/components/inserter-listbox/index.js +13 -8
  348. package/build-module/components/inserter-listbox/index.js.map +1 -1
  349. package/build-module/components/inserter-listbox/item.js +25 -23
  350. package/build-module/components/inserter-listbox/item.js.map +1 -1
  351. package/build-module/components/inserter-listbox/row.js +6 -5
  352. package/build-module/components/inserter-listbox/row.js.map +1 -1
  353. package/build-module/components/inspector-controls/fill.js +3 -3
  354. package/build-module/components/inspector-controls/fill.js.map +1 -1
  355. package/build-module/components/inspector-controls/fill.native.js +3 -3
  356. package/build-module/components/inspector-controls/fill.native.js.map +1 -1
  357. package/build-module/components/list-view/use-list-view-expand-selected-item.js +2 -3
  358. package/build-module/components/list-view/use-list-view-expand-selected-item.js.map +1 -1
  359. package/build-module/components/navigable-toolbar/index.js +2 -2
  360. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  361. package/build-module/components/preview-options/index.js +6 -60
  362. package/build-module/components/preview-options/index.js.map +1 -1
  363. package/build-module/components/rich-text/content.js +25 -21
  364. package/build-module/components/rich-text/content.js.map +1 -1
  365. package/build-module/components/rich-text/get-rich-text-values.js +2 -1
  366. package/build-module/components/rich-text/get-rich-text-values.js.map +1 -1
  367. package/build-module/components/rich-text/index.js +4 -32
  368. package/build-module/components/rich-text/index.js.map +1 -1
  369. package/build-module/components/rich-text/index.native.js +11 -19
  370. package/build-module/components/rich-text/index.native.js.map +1 -1
  371. package/build-module/components/rich-text/native/get-format-colors.native.js +22 -24
  372. package/build-module/components/rich-text/native/get-format-colors.native.js.map +1 -1
  373. package/build-module/components/rich-text/native/index.native.js +41 -37
  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 +36 -3
  376. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  377. package/build-module/components/rich-text/with-deprecations.js +42 -0
  378. package/build-module/components/rich-text/with-deprecations.js.map +1 -0
  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/use-block-drop-zone/index.js +73 -9
  382. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  383. package/build-module/components/use-moving-animation/index.js +2 -1
  384. package/build-module/components/use-moving-animation/index.js.map +1 -1
  385. package/build-module/components/use-on-block-drop/index.js +1 -1
  386. package/build-module/components/use-on-block-drop/index.js.map +1 -1
  387. package/build-module/components/use-resize-canvas/index.js +4 -1
  388. package/build-module/components/use-resize-canvas/index.js.map +1 -1
  389. package/build-module/components/use-settings/index.js +15 -3
  390. package/build-module/components/use-settings/index.js.map +1 -1
  391. package/build-module/hooks/align.js +19 -66
  392. package/build-module/hooks/align.js.map +1 -1
  393. package/build-module/hooks/align.native.js +1 -0
  394. package/build-module/hooks/align.native.js.map +1 -1
  395. package/build-module/hooks/anchor.js +11 -26
  396. package/build-module/hooks/anchor.js.map +1 -1
  397. package/build-module/hooks/background.js +26 -28
  398. package/build-module/hooks/background.js.map +1 -1
  399. package/build-module/hooks/block-hooks.js +22 -30
  400. package/build-module/hooks/block-hooks.js.map +1 -1
  401. package/build-module/hooks/block-renaming.js +36 -0
  402. package/build-module/hooks/block-renaming.js.map +1 -1
  403. package/build-module/hooks/border.js +57 -78
  404. package/build-module/hooks/border.js.map +1 -1
  405. package/build-module/hooks/color.js +74 -86
  406. package/build-module/hooks/color.js.map +1 -1
  407. package/build-module/hooks/content-lock-ui.js +27 -27
  408. package/build-module/hooks/content-lock-ui.js.map +1 -1
  409. package/build-module/hooks/custom-class-name.js +11 -27
  410. package/build-module/hooks/custom-class-name.js.map +1 -1
  411. package/build-module/hooks/custom-fields.js +60 -74
  412. package/build-module/hooks/custom-fields.js.map +1 -1
  413. package/build-module/hooks/dimensions.js +21 -16
  414. package/build-module/hooks/dimensions.js.map +1 -1
  415. package/build-module/hooks/duotone.js +30 -61
  416. package/build-module/hooks/duotone.js.map +1 -1
  417. package/build-module/hooks/font-family.js +14 -23
  418. package/build-module/hooks/font-family.js.map +1 -1
  419. package/build-module/hooks/font-size.js +49 -119
  420. package/build-module/hooks/font-size.js.map +1 -1
  421. package/build-module/hooks/index.js +18 -15
  422. package/build-module/hooks/index.js.map +1 -1
  423. package/build-module/hooks/index.native.js +5 -3
  424. package/build-module/hooks/index.native.js.map +1 -1
  425. package/build-module/hooks/layout-child.js +60 -0
  426. package/build-module/hooks/layout-child.js.map +1 -0
  427. package/build-module/hooks/layout.js +26 -105
  428. package/build-module/hooks/layout.js.map +1 -1
  429. package/build-module/hooks/padding.js +2 -2
  430. package/build-module/hooks/padding.js.map +1 -1
  431. package/build-module/hooks/position.js +38 -59
  432. package/build-module/hooks/position.js.map +1 -1
  433. package/build-module/hooks/style.js +51 -84
  434. package/build-module/hooks/style.js.map +1 -1
  435. package/build-module/hooks/typography.js +33 -12
  436. package/build-module/hooks/typography.js.map +1 -1
  437. package/build-module/hooks/utils.js +149 -6
  438. package/build-module/hooks/utils.js.map +1 -1
  439. package/build-module/layouts/constrained.js +4 -3
  440. package/build-module/layouts/constrained.js.map +1 -1
  441. package/build-module/private-apis.js +0 -2
  442. package/build-module/private-apis.js.map +1 -1
  443. package/build-module/store/private-actions.js +7 -0
  444. package/build-module/store/private-actions.js.map +1 -1
  445. package/build-module/store/private-selectors.js +33 -1
  446. package/build-module/store/private-selectors.js.map +1 -1
  447. package/build-module/store/reducer.js +8 -0
  448. package/build-module/store/reducer.js.map +1 -1
  449. package/build-module/store/selectors.js +3 -51
  450. package/build-module/store/selectors.js.map +1 -1
  451. package/build-module/store/utils.js +56 -0
  452. package/build-module/store/utils.js.map +1 -0
  453. package/build-module/utils/object.js +21 -60
  454. package/build-module/utils/object.js.map +1 -1
  455. package/build-module/utils/selection.js +9 -1
  456. package/build-module/utils/selection.js.map +1 -1
  457. package/build-module/utils/transform-styles/index.js +24 -7
  458. package/build-module/utils/transform-styles/index.js.map +1 -1
  459. package/build-style/content-rtl.css +6 -6
  460. package/build-style/content.css +6 -6
  461. package/build-style/style-rtl.css +123 -298
  462. package/build-style/style.css +123 -298
  463. package/package.json +31 -31
  464. package/src/components/block-canvas/index.js +31 -17
  465. package/src/components/block-caption/README.md +2 -2
  466. package/src/components/block-card/index.js +5 -3
  467. package/src/components/block-card/style.scss +7 -3
  468. package/src/components/block-controls/hook.js +8 -30
  469. package/src/components/block-controls/test/index.js +3 -3
  470. package/src/components/block-edit/context.js +3 -0
  471. package/src/components/block-edit/index.js +36 -10
  472. package/src/components/block-info-slot-fill/index.js +6 -3
  473. package/src/components/block-inspector/style.scss +0 -4
  474. package/src/components/block-list/block.js +39 -5
  475. package/src/components/block-list/block.native.js +20 -4
  476. package/src/components/block-list/use-block-props/index.js +74 -21
  477. package/src/components/block-list/use-block-props/use-focus-first-element.js +1 -34
  478. package/src/components/block-list/use-block-props/use-is-hovered.js +2 -13
  479. package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +1 -5
  480. package/src/components/block-parent-selector/index.js +1 -1
  481. package/src/components/block-pattern-setup/index.js +38 -22
  482. package/src/components/block-pattern-setup/setup-toolbar.js +2 -0
  483. package/src/components/block-pattern-setup/style.scss +4 -1
  484. package/src/components/block-patterns-list/README.md +4 -4
  485. package/src/components/block-patterns-list/index.js +61 -35
  486. package/src/components/block-patterns-list/style.scss +7 -0
  487. package/src/components/block-removal-warning-modal/index.js +7 -14
  488. package/src/components/block-rename/index.js +3 -0
  489. package/src/components/block-rename/is-empty-string.js +3 -0
  490. package/src/components/block-rename/modal.js +121 -0
  491. package/src/components/block-rename/rename-control.js +80 -0
  492. package/src/components/block-rename/use-block-rename.js +10 -0
  493. package/src/components/block-settings/container.native.js +3 -5
  494. package/src/components/block-settings-menu/block-settings-dropdown.js +38 -34
  495. package/src/components/block-settings-menu-controls/index.js +9 -0
  496. package/src/components/block-styles/index.js +1 -1
  497. package/src/components/block-styles/index.native.js +4 -2
  498. package/src/components/block-styles/style.scss +0 -11
  499. package/src/components/block-switcher/test/__snapshots__/index.js.snap +3 -1
  500. package/src/components/block-toolbar/block-toolbar-menu.native.js +1 -4
  501. package/src/components/block-toolbar/index.js +180 -95
  502. package/src/components/block-toolbar/style.scss +50 -66
  503. package/src/components/block-tools/block-toolbar-breadcrumb.js +46 -0
  504. package/src/components/block-tools/block-toolbar-popover.js +90 -0
  505. package/src/components/block-tools/index.js +42 -29
  506. package/src/components/block-tools/style.scss +60 -172
  507. package/src/components/block-types-list/index.js +5 -4
  508. package/src/components/block-types-list/index.native.js +2 -1
  509. package/src/components/block-variation-picker/index.native.js +1 -1
  510. package/src/components/button-block-appender/content.scss +2 -2
  511. package/src/components/colors-gradients/control.js +49 -30
  512. package/src/components/colors-gradients/style.scss +0 -7
  513. package/src/components/date-format-picker/index.js +7 -0
  514. package/src/components/duotone-control/index.js +2 -5
  515. package/src/components/duotone-control/style.scss +1 -6
  516. package/src/components/editable-text/README.md +0 -36
  517. package/src/components/global-styles/advanced-panel.js +1 -1
  518. package/src/components/global-styles/color-panel.js +34 -25
  519. package/src/components/global-styles/filters-panel.js +8 -4
  520. package/src/components/global-styles/typography-panel.js +23 -43
  521. package/src/components/image-link-destinations/index.native.js +152 -0
  522. package/src/components/image-link-destinations/style.native.scss +16 -0
  523. package/src/components/image-size-control/index.js +0 -6
  524. package/src/components/index.native.js +1 -0
  525. package/src/components/inner-blocks/README.md +13 -2
  526. package/src/components/inner-blocks/index.js +6 -2
  527. package/src/components/inner-blocks/warning-max-depth-exceeded.native.js +57 -33
  528. package/src/components/inserter/block-patterns-explorer/pattern-list.js +5 -1
  529. package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +7 -3
  530. package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +6 -1
  531. package/src/components/inserter/block-patterns-tab/utils.js +6 -4
  532. package/src/components/inserter/hooks/use-patterns-state.js +3 -1
  533. package/src/components/inserter/media-tab/media-panel.js +1 -1
  534. package/src/components/inserter/menu.js +16 -8
  535. package/src/components/inserter/preview-panel.js +2 -2
  536. package/src/components/inserter/style.scss +15 -17
  537. package/src/components/inserter-button/README.md +62 -0
  538. package/src/components/inserter-button/index.native.js +116 -0
  539. package/src/components/inserter-button/sparkles.js +15 -0
  540. package/src/components/inserter-button/style.native.scss +72 -0
  541. package/src/components/inserter-draggable-blocks/index.js +18 -5
  542. package/src/components/inserter-listbox/index.js +11 -7
  543. package/src/components/inserter-listbox/item.js +11 -12
  544. package/src/components/inserter-listbox/row.js +6 -12
  545. package/src/components/inspector-controls/fill.js +6 -3
  546. package/src/components/inspector-controls/fill.native.js +6 -3
  547. package/src/components/link-control/style.scss +1 -1
  548. package/src/components/link-control/test/index.js +1 -1
  549. package/src/components/list-view/use-list-view-expand-selected-item.js +7 -8
  550. package/src/components/navigable-toolbar/README.md +2 -0
  551. package/src/components/navigable-toolbar/index.js +2 -2
  552. package/src/components/plain-text/README.md +0 -28
  553. package/src/components/preview-options/index.js +6 -84
  554. package/src/components/rich-text/README.md +0 -58
  555. package/src/components/rich-text/content.js +27 -20
  556. package/src/components/rich-text/get-rich-text-values.js +6 -1
  557. package/src/components/rich-text/index.js +5 -46
  558. package/src/components/rich-text/index.native.js +9 -26
  559. package/src/components/rich-text/native/get-format-colors.native.js +33 -40
  560. package/src/components/rich-text/native/index.native.js +52 -50
  561. package/src/components/rich-text/use-input-rules.js +36 -3
  562. package/src/components/rich-text/with-deprecations.js +51 -0
  563. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
  564. package/src/components/url-input/README.md +1 -74
  565. package/src/components/use-block-drop-zone/index.js +118 -15
  566. package/src/components/use-moving-animation/index.js +1 -1
  567. package/src/components/use-on-block-drop/index.js +2 -1
  568. package/src/components/use-resize-canvas/README.md +3 -3
  569. package/src/components/use-resize-canvas/index.js +4 -1
  570. package/src/components/use-settings/index.js +17 -3
  571. package/src/components/use-settings/test/index.js +1 -1
  572. package/src/hooks/align.js +15 -76
  573. package/src/hooks/align.native.js +1 -0
  574. package/src/hooks/anchor.js +13 -33
  575. package/src/hooks/background.js +28 -23
  576. package/src/hooks/block-hooks.js +22 -51
  577. package/src/hooks/block-renaming.js +33 -0
  578. package/src/hooks/border.js +67 -118
  579. package/src/hooks/color.js +100 -132
  580. package/src/hooks/content-lock-ui.js +110 -122
  581. package/src/hooks/custom-class-name.js +8 -40
  582. package/src/hooks/custom-fields.js +70 -94
  583. package/src/hooks/dimensions.js +20 -16
  584. package/src/hooks/duotone.js +70 -127
  585. package/src/hooks/font-family.js +10 -29
  586. package/src/hooks/font-size.js +66 -162
  587. package/src/hooks/index.js +42 -15
  588. package/src/hooks/index.native.js +6 -3
  589. package/src/hooks/layout-child.js +53 -0
  590. package/src/hooks/layout.js +25 -110
  591. package/src/hooks/padding.js +2 -2
  592. package/src/hooks/position.js +50 -90
  593. package/src/hooks/style.js +117 -187
  594. package/src/hooks/test/__snapshots__/align.native.js.snap +5 -5
  595. package/src/hooks/test/align.js +1 -178
  596. package/src/hooks/typography.js +20 -16
  597. package/src/hooks/utils.js +187 -6
  598. package/src/layouts/constrained.js +57 -50
  599. package/src/private-apis.js +0 -2
  600. package/src/store/private-actions.js +8 -0
  601. package/src/store/private-selectors.js +45 -0
  602. package/src/store/reducer.js +8 -0
  603. package/src/store/selectors.js +5 -67
  604. package/src/store/utils.js +74 -0
  605. package/src/style.scss +1 -3
  606. package/src/utils/object.js +18 -69
  607. package/src/utils/selection.js +9 -2
  608. package/src/utils/test/transform-styles.js +49 -0
  609. package/src/utils/transform-styles/index.js +39 -13
  610. package/build/components/block-list/use-block-props/use-block-class-names.js +0 -67
  611. package/build/components/block-list/use-block-props/use-block-class-names.js.map +0 -1
  612. package/build/components/block-list/use-block-props/use-block-custom-class-name.js +0 -46
  613. package/build/components/block-list/use-block-props/use-block-custom-class-name.js.map +0 -1
  614. package/build/components/block-list/use-block-props/use-block-default-class-name.js +0 -37
  615. package/build/components/block-list/use-block-props/use-block-default-class-name.js.map +0 -1
  616. package/build/components/block-tools/back-compat.js +0 -45
  617. package/build/components/block-tools/back-compat.js.map +0 -1
  618. package/build/components/block-tools/block-contextual-toolbar.js +0 -91
  619. package/build/components/block-tools/block-contextual-toolbar.js.map +0 -1
  620. package/build/components/block-tools/selected-block-tools.js +0 -113
  621. package/build/components/block-tools/selected-block-tools.js.map +0 -1
  622. package/build/components/inserter/hooks/use-debounced-input.js +0 -22
  623. package/build/components/inserter/hooks/use-debounced-input.js.map +0 -1
  624. package/build/components/use-display-block-controls/index.js +0 -39
  625. package/build/components/use-display-block-controls/index.js.map +0 -1
  626. package/build/components/use-display-block-controls/index.native.js +0 -39
  627. package/build/components/use-display-block-controls/index.native.js.map +0 -1
  628. package/build/hooks/block-rename-ui.js +0 -167
  629. package/build/hooks/block-rename-ui.js.map +0 -1
  630. package/build-module/components/block-list/use-block-props/use-block-class-names.js +0 -60
  631. package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +0 -1
  632. package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js +0 -40
  633. package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js.map +0 -1
  634. package/build-module/components/block-list/use-block-props/use-block-default-class-name.js +0 -31
  635. package/build-module/components/block-list/use-block-props/use-block-default-class-name.js.map +0 -1
  636. package/build-module/components/block-tools/back-compat.js +0 -35
  637. package/build-module/components/block-tools/back-compat.js.map +0 -1
  638. package/build-module/components/block-tools/block-contextual-toolbar.js +0 -83
  639. package/build-module/components/block-tools/block-contextual-toolbar.js.map +0 -1
  640. package/build-module/components/block-tools/selected-block-tools.js +0 -105
  641. package/build-module/components/block-tools/selected-block-tools.js.map +0 -1
  642. package/build-module/components/inserter/hooks/use-debounced-input.js +0 -15
  643. package/build-module/components/inserter/hooks/use-debounced-input.js.map +0 -1
  644. package/build-module/components/use-display-block-controls/index.js +0 -32
  645. package/build-module/components/use-display-block-controls/index.js.map +0 -1
  646. package/build-module/components/use-display-block-controls/index.native.js +0 -32
  647. package/build-module/components/use-display-block-controls/index.native.js.map +0 -1
  648. package/build-module/hooks/block-rename-ui.js +0 -159
  649. package/build-module/hooks/block-rename-ui.js.map +0 -1
  650. package/src/components/block-list/use-block-props/use-block-class-names.js +0 -66
  651. package/src/components/block-list/use-block-props/use-block-custom-class-name.js +0 -44
  652. package/src/components/block-list/use-block-props/use-block-default-class-name.js +0 -35
  653. package/src/components/block-parent-selector/style.scss +0 -11
  654. package/src/components/block-tools/back-compat.js +0 -35
  655. package/src/components/block-tools/block-contextual-toolbar.js +0 -100
  656. package/src/components/block-tools/selected-block-tools.js +0 -127
  657. package/src/components/inserter/hooks/use-debounced-input.js +0 -18
  658. package/src/components/preview-options/README.md +0 -94
  659. package/src/components/preview-options/style.scss +0 -64
  660. package/src/components/use-display-block-controls/index.js +0 -36
  661. package/src/components/use-display-block-controls/index.native.js +0 -37
  662. package/src/hooks/block-rename-ui.js +0 -228
  663. package/src/hooks/test/color.js +0 -112
  664. /package/src/{hooks/block-rename-ui.scss → components/block-rename/style.scss} +0 -0
@@ -1 +1 @@
1
- {"version":3,"names":["Button","CustomSelectControl","Icon","RangeControl","__experimentalHStack","HStack","__experimentalUnitControl","UnitControl","__experimentalUseCustomUnits","useCustomUnits","__experimentalParseQuantityAndUnitFromRawValue","parseQuantityAndUnitFromRawValue","useSelect","useState","useMemo","usePrevious","__","sprintf","settings","useSettings","store","blockEditorStore","ALL_SIDES","LABELS","getSliderValueFromPreset","getCustomValueFromPreset","getPresetValueFromCustomValue","isValueSpacingPreset","CUSTOM_VALUE_SETTINGS","px","max","steps","vw","vh","em","rm","svw","lvw","dvw","svh","lvh","dvh","vi","svi","lvi","dvi","vb","svb","lvb","dvb","vmin","svmin","lvmin","dvmin","vmax","svmax","lvmax","dvmax","SpacingInputControl","icon","isMixed","minimumCustomValue","onChange","onMouseOut","onMouseOver","showSideInLabel","side","spacingSizes","type","value","_CUSTOM_VALUE_SETTING","_CUSTOM_VALUE_SETTING2","selectListSizes","showRangeControl","length","disableCustomSpacingSizes","select","editorSettings","getSettings","showCustomValueControl","setShowCustomValueControl","undefined","previousValue","availableUnits","units","currentValue","showCustomValueInSelectList","name","slug","size","selectedUnit","setInitialValue","customTooltipContent","newValue","customRangeValue","parseFloat","getNewCustomValue","newSize","isNumeric","isNaN","nextValue","getNewPresetValue","controlType","parseInt","handleCustomValueSliderChange","next","join","allPlaceholder","options","map","index","key","marks","_newValue","label","sideLabel","includes","typeLabel","toLowerCase","ariaLabel","trim","createElement","className","Fragment","onFocus","onBlur","min","placeholder","disableUnits","hideLabelFromVision","step","withInputField","__nextHasNoMarginBottom","onMouseDown","event","nativeEvent","offsetX","renderTooltipContent","find","option","selection","selectedItem","__nextUnconstrainedWidth","onClick","isPressed","isSmall","iconSize"],"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/input-controls/spacing-input-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tCustomSelectControl,\n\tIcon,\n\tRangeControl,\n\t__experimentalHStack as HStack,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { usePrevious } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { settings } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../../use-settings';\nimport { store as blockEditorStore } from '../../../store';\nimport {\n\tALL_SIDES,\n\tLABELS,\n\tgetSliderValueFromPreset,\n\tgetCustomValueFromPreset,\n\tgetPresetValueFromCustomValue,\n\tisValueSpacingPreset,\n} from '../utils';\n\nconst CUSTOM_VALUE_SETTINGS = {\n\tpx: { max: 300, steps: 1 },\n\t'%': { max: 100, steps: 1 },\n\tvw: { max: 100, steps: 1 },\n\tvh: { max: 100, steps: 1 },\n\tem: { max: 10, steps: 0.1 },\n\trm: { max: 10, steps: 0.1 },\n\tsvw: { max: 100, steps: 1 },\n\tlvw: { max: 100, steps: 1 },\n\tdvw: { max: 100, steps: 1 },\n\tsvh: { max: 100, steps: 1 },\n\tlvh: { max: 100, steps: 1 },\n\tdvh: { max: 100, steps: 1 },\n\tvi: { max: 100, steps: 1 },\n\tsvi: { max: 100, steps: 1 },\n\tlvi: { max: 100, steps: 1 },\n\tdvi: { max: 100, steps: 1 },\n\tvb: { max: 100, steps: 1 },\n\tsvb: { max: 100, steps: 1 },\n\tlvb: { max: 100, steps: 1 },\n\tdvb: { max: 100, steps: 1 },\n\tvmin: { max: 100, steps: 1 },\n\tsvmin: { max: 100, steps: 1 },\n\tlvmin: { max: 100, steps: 1 },\n\tdvmin: { max: 100, steps: 1 },\n\tvmax: { max: 100, steps: 1 },\n\tsvmax: { max: 100, steps: 1 },\n\tlvmax: { max: 100, steps: 1 },\n\tdvmax: { max: 100, steps: 1 },\n};\n\nexport default function SpacingInputControl( {\n\ticon,\n\tisMixed = false,\n\tminimumCustomValue,\n\tonChange,\n\tonMouseOut,\n\tonMouseOver,\n\tshowSideInLabel = true,\n\tside,\n\tspacingSizes,\n\ttype,\n\tvalue,\n} ) {\n\t// Treat value as a preset value if the passed in value matches the value of one of the spacingSizes.\n\tvalue = getPresetValueFromCustomValue( value, spacingSizes );\n\n\tlet selectListSizes = spacingSizes;\n\tconst showRangeControl = spacingSizes.length <= 8;\n\n\tconst disableCustomSpacingSizes = useSelect( ( select ) => {\n\t\tconst editorSettings = select( blockEditorStore ).getSettings();\n\t\treturn editorSettings?.disableCustomSpacingSizes;\n\t} );\n\n\tconst [ showCustomValueControl, setShowCustomValueControl ] = useState(\n\t\t! disableCustomSpacingSizes &&\n\t\t\tvalue !== undefined &&\n\t\t\t! isValueSpacingPreset( value )\n\t);\n\n\tconst previousValue = usePrevious( value );\n\tif (\n\t\t!! value &&\n\t\tpreviousValue !== value &&\n\t\t! isValueSpacingPreset( value ) &&\n\t\tshowCustomValueControl !== true\n\t) {\n\t\tsetShowCustomValueControl( true );\n\t}\n\n\tconst [ availableUnits ] = useSettings( 'spacing.units' );\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: availableUnits || [ 'px', 'em', 'rem' ],\n\t} );\n\n\tlet currentValue = null;\n\n\tconst showCustomValueInSelectList =\n\t\t! showRangeControl &&\n\t\t! showCustomValueControl &&\n\t\tvalue !== undefined &&\n\t\t( ! isValueSpacingPreset( value ) ||\n\t\t\t( isValueSpacingPreset( value ) && isMixed ) );\n\n\tif ( showCustomValueInSelectList ) {\n\t\tselectListSizes = [\n\t\t\t...spacingSizes,\n\t\t\t{\n\t\t\t\tname: ! isMixed\n\t\t\t\t\t? // translators: A custom measurement, eg. a number followed by a unit like 12px.\n\t\t\t\t\t sprintf( __( 'Custom (%s)' ), value )\n\t\t\t\t\t: __( 'Mixed' ),\n\t\t\t\tslug: 'custom',\n\t\t\t\tsize: value,\n\t\t\t},\n\t\t];\n\t\tcurrentValue = selectListSizes.length - 1;\n\t} else if ( ! isMixed ) {\n\t\tcurrentValue = ! showCustomValueControl\n\t\t\t? getSliderValueFromPreset( value, spacingSizes )\n\t\t\t: getCustomValueFromPreset( value, spacingSizes );\n\t}\n\n\tconst selectedUnit =\n\t\tuseMemo(\n\t\t\t() => parseQuantityAndUnitFromRawValue( currentValue ),\n\t\t\t[ currentValue ]\n\t\t)[ 1 ] || units[ 0 ].value;\n\n\tconst setInitialValue = () => {\n\t\tif ( value === undefined ) {\n\t\t\tonChange( '0' );\n\t\t}\n\t};\n\n\tconst customTooltipContent = ( newValue ) =>\n\t\tvalue === undefined ? undefined : spacingSizes[ newValue ]?.name;\n\n\tconst customRangeValue = parseFloat( currentValue, 10 );\n\n\tconst getNewCustomValue = ( newSize ) => {\n\t\tconst isNumeric = ! isNaN( parseFloat( newSize ) );\n\t\tconst nextValue = isNumeric ? newSize : undefined;\n\t\treturn nextValue;\n\t};\n\n\tconst getNewPresetValue = ( newSize, controlType ) => {\n\t\tconst size = parseInt( newSize, 10 );\n\n\t\tif ( controlType === 'selectList' ) {\n\t\t\tif ( size === 0 ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif ( size === 1 ) {\n\t\t\t\treturn '0';\n\t\t\t}\n\t\t} else if ( size === 0 ) {\n\t\t\treturn '0';\n\t\t}\n\t\treturn `var:preset|spacing|${ spacingSizes[ newSize ]?.slug }`;\n\t};\n\n\tconst handleCustomValueSliderChange = ( next ) => {\n\t\tonChange( [ next, selectedUnit ].join( '' ) );\n\t};\n\n\tconst allPlaceholder = isMixed ? __( 'Mixed' ) : null;\n\n\tconst options = selectListSizes.map( ( size, index ) => ( {\n\t\tkey: index,\n\t\tname: size.name,\n\t} ) );\n\n\tconst marks = spacingSizes.map( ( _newValue, index ) => ( {\n\t\tvalue: index,\n\t\tlabel: undefined,\n\t} ) );\n\n\tconst sideLabel =\n\t\tALL_SIDES.includes( side ) && showSideInLabel ? LABELS[ side ] : '';\n\tconst typeLabel = showSideInLabel ? type?.toLowerCase() : type;\n\n\tconst ariaLabel = sprintf(\n\t\t// translators: 1: The side of the block being modified (top, bottom, left, All sides etc.). 2. Type of spacing being modified (Padding, margin, etc)\n\t\t__( '%1$s %2$s' ),\n\t\tsideLabel,\n\t\ttypeLabel\n\t).trim();\n\n\treturn (\n\t\t<HStack className=\"spacing-sizes-control__wrapper\">\n\t\t\t{ icon && (\n\t\t\t\t<Icon\n\t\t\t\t\tclassName=\"spacing-sizes-control__icon\"\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tsize={ 24 }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showCustomValueControl && (\n\t\t\t\t<>\n\t\t\t\t\t<UnitControl\n\t\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\t\tonChange={ ( newSize ) =>\n\t\t\t\t\t\t\tonChange( getNewCustomValue( newSize ) )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalue={ currentValue }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tmin={ minimumCustomValue }\n\t\t\t\t\t\tplaceholder={ allPlaceholder }\n\t\t\t\t\t\tdisableUnits={ isMixed }\n\t\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t\tclassName=\"spacing-sizes-control__custom-value-input\"\n\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t/>\n\t\t\t\t\t<RangeControl\n\t\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\t\tvalue={ customRangeValue }\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\tmax={ CUSTOM_VALUE_SETTINGS[ selectedUnit ]?.max ?? 10 }\n\t\t\t\t\t\tstep={\n\t\t\t\t\t\t\tCUSTOM_VALUE_SETTINGS[ selectedUnit ]?.steps ?? 0.1\n\t\t\t\t\t\t}\n\t\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t\tonChange={ handleCustomValueSliderChange }\n\t\t\t\t\t\tclassName=\"spacing-sizes-control__custom-value-range\"\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<RangeControl\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tclassName=\"spacing-sizes-control__range-control\"\n\t\t\t\t\tvalue={ currentValue }\n\t\t\t\t\tonChange={ ( newSize ) =>\n\t\t\t\t\t\tonChange( getNewPresetValue( newSize ) )\n\t\t\t\t\t}\n\t\t\t\t\tonMouseDown={ ( event ) => {\n\t\t\t\t\t\t// If mouse down is near start of range set initial value to 0, which\n\t\t\t\t\t\t// prevents the user have to drag right then left to get 0 setting.\n\t\t\t\t\t\tif ( event?.nativeEvent?.offsetX < 35 ) {\n\t\t\t\t\t\t\tsetInitialValue();\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\twithInputField={ false }\n\t\t\t\t\taria-valuenow={ currentValue }\n\t\t\t\t\taria-valuetext={ spacingSizes[ currentValue ]?.name }\n\t\t\t\t\trenderTooltipContent={ customTooltipContent }\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tmax={ spacingSizes.length - 1 }\n\t\t\t\t\tmarks={ marks }\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t__nextHasNoMarginBottom={ true }\n\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ! showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<CustomSelectControl\n\t\t\t\t\tclassName=\"spacing-sizes-control__custom-select-control\"\n\t\t\t\t\tvalue={\n\t\t\t\t\t\toptions.find(\n\t\t\t\t\t\t\t( option ) => option.key === currentValue\n\t\t\t\t\t\t) || '' // passing undefined here causes a downshift controlled/uncontrolled warning\n\t\t\t\t\t}\n\t\t\t\t\tonChange={ ( selection ) => {\n\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\tgetNewPresetValue(\n\t\t\t\t\t\t\t\tselection.selectedItem.key,\n\t\t\t\t\t\t\t\t'selectList'\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t} }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t__nextUnconstrainedWidth={ true }\n\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ! disableCustomSpacingSizes && (\n\t\t\t\t<Button\n\t\t\t\t\tlabel={\n\t\t\t\t\t\tshowCustomValueControl\n\t\t\t\t\t\t\t? __( 'Use size preset' )\n\t\t\t\t\t\t\t: __( 'Set custom size' )\n\t\t\t\t\t}\n\t\t\t\t\ticon={ settings }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetShowCustomValueControl( ! showCustomValueControl );\n\t\t\t\t\t} }\n\t\t\t\t\tisPressed={ showCustomValueControl }\n\t\t\t\t\tisSmall\n\t\t\t\t\tclassName=\"spacing-sizes-control__custom-toggle\"\n\t\t\t\t\ticonSize={ 24 }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</HStack>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,MAAM,EACNC,mBAAmB,EACnBC,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,CAEK,CAAC;AAEX"}
1
+ {"version":3,"names":["Button","CustomSelectControl","Icon","RangeControl","__experimentalHStack","HStack","__experimentalUnitControl","UnitControl","__experimentalUseCustomUnits","useCustomUnits","__experimentalParseQuantityAndUnitFromRawValue","parseQuantityAndUnitFromRawValue","useSelect","useState","useMemo","usePrevious","__","sprintf","settings","useSettings","store","blockEditorStore","ALL_SIDES","LABELS","getSliderValueFromPreset","getCustomValueFromPreset","getPresetValueFromCustomValue","isValueSpacingPreset","CUSTOM_VALUE_SETTINGS","px","max","steps","vw","vh","em","rm","svw","lvw","dvw","svh","lvh","dvh","vi","svi","lvi","dvi","vb","svb","lvb","dvb","vmin","svmin","lvmin","dvmin","vmax","svmax","lvmax","dvmax","SpacingInputControl","icon","isMixed","minimumCustomValue","onChange","onMouseOut","onMouseOver","showSideInLabel","side","spacingSizes","type","value","_CUSTOM_VALUE_SETTING","_CUSTOM_VALUE_SETTING2","selectListSizes","showRangeControl","length","disableCustomSpacingSizes","select","editorSettings","getSettings","showCustomValueControl","setShowCustomValueControl","undefined","previousValue","availableUnits","units","currentValue","showCustomValueInSelectList","name","slug","size","selectedUnit","setInitialValue","customTooltipContent","newValue","customRangeValue","parseFloat","getNewCustomValue","newSize","isNumeric","isNaN","nextValue","getNewPresetValue","controlType","parseInt","handleCustomValueSliderChange","next","join","allPlaceholder","options","map","index","key","marks","_newValue","label","sideLabel","includes","typeLabel","toLowerCase","ariaLabel","trim","createElement","className","Fragment","onFocus","onBlur","min","placeholder","disableUnits","hideLabelFromVision","step","withInputField","__nextHasNoMarginBottom","onMouseDown","event","nativeEvent","offsetX","renderTooltipContent","find","option","selection","selectedItem","__nextUnconstrainedWidth","onClick","isPressed","isSmall","iconSize"],"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/input-controls/spacing-input-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tCustomSelectControl,\n\tIcon,\n\tRangeControl,\n\t__experimentalHStack as HStack,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { usePrevious } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { settings } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../../use-settings';\nimport { store as blockEditorStore } from '../../../store';\nimport {\n\tALL_SIDES,\n\tLABELS,\n\tgetSliderValueFromPreset,\n\tgetCustomValueFromPreset,\n\tgetPresetValueFromCustomValue,\n\tisValueSpacingPreset,\n} from '../utils';\n\nconst CUSTOM_VALUE_SETTINGS = {\n\tpx: { max: 300, steps: 1 },\n\t'%': { max: 100, steps: 1 },\n\tvw: { max: 100, steps: 1 },\n\tvh: { max: 100, steps: 1 },\n\tem: { max: 10, steps: 0.1 },\n\trm: { max: 10, steps: 0.1 },\n\tsvw: { max: 100, steps: 1 },\n\tlvw: { max: 100, steps: 1 },\n\tdvw: { max: 100, steps: 1 },\n\tsvh: { max: 100, steps: 1 },\n\tlvh: { max: 100, steps: 1 },\n\tdvh: { max: 100, steps: 1 },\n\tvi: { max: 100, steps: 1 },\n\tsvi: { max: 100, steps: 1 },\n\tlvi: { max: 100, steps: 1 },\n\tdvi: { max: 100, steps: 1 },\n\tvb: { max: 100, steps: 1 },\n\tsvb: { max: 100, steps: 1 },\n\tlvb: { max: 100, steps: 1 },\n\tdvb: { max: 100, steps: 1 },\n\tvmin: { max: 100, steps: 1 },\n\tsvmin: { max: 100, steps: 1 },\n\tlvmin: { max: 100, steps: 1 },\n\tdvmin: { max: 100, steps: 1 },\n\tvmax: { max: 100, steps: 1 },\n\tsvmax: { max: 100, steps: 1 },\n\tlvmax: { max: 100, steps: 1 },\n\tdvmax: { max: 100, steps: 1 },\n};\n\nexport default function SpacingInputControl( {\n\ticon,\n\tisMixed = false,\n\tminimumCustomValue,\n\tonChange,\n\tonMouseOut,\n\tonMouseOver,\n\tshowSideInLabel = true,\n\tside,\n\tspacingSizes,\n\ttype,\n\tvalue,\n} ) {\n\t// Treat value as a preset value if the passed in value matches the value of one of the spacingSizes.\n\tvalue = getPresetValueFromCustomValue( value, spacingSizes );\n\n\tlet selectListSizes = spacingSizes;\n\tconst showRangeControl = spacingSizes.length <= 8;\n\n\tconst disableCustomSpacingSizes = useSelect( ( select ) => {\n\t\tconst editorSettings = select( blockEditorStore ).getSettings();\n\t\treturn editorSettings?.disableCustomSpacingSizes;\n\t} );\n\n\tconst [ showCustomValueControl, setShowCustomValueControl ] = useState(\n\t\t! disableCustomSpacingSizes &&\n\t\t\tvalue !== undefined &&\n\t\t\t! isValueSpacingPreset( value )\n\t);\n\n\tconst previousValue = usePrevious( value );\n\tif (\n\t\t!! value &&\n\t\tpreviousValue !== value &&\n\t\t! isValueSpacingPreset( value ) &&\n\t\tshowCustomValueControl !== true\n\t) {\n\t\tsetShowCustomValueControl( true );\n\t}\n\n\tconst [ availableUnits ] = useSettings( 'spacing.units' );\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: availableUnits || [ 'px', 'em', 'rem' ],\n\t} );\n\n\tlet currentValue = null;\n\n\tconst showCustomValueInSelectList =\n\t\t! showRangeControl &&\n\t\t! showCustomValueControl &&\n\t\tvalue !== undefined &&\n\t\t( ! isValueSpacingPreset( value ) ||\n\t\t\t( isValueSpacingPreset( value ) && isMixed ) );\n\n\tif ( showCustomValueInSelectList ) {\n\t\tselectListSizes = [\n\t\t\t...spacingSizes,\n\t\t\t{\n\t\t\t\tname: ! isMixed\n\t\t\t\t\t? // translators: A custom measurement, eg. a number followed by a unit like 12px.\n\t\t\t\t\t sprintf( __( 'Custom (%s)' ), value )\n\t\t\t\t\t: __( 'Mixed' ),\n\t\t\t\tslug: 'custom',\n\t\t\t\tsize: value,\n\t\t\t},\n\t\t];\n\t\tcurrentValue = selectListSizes.length - 1;\n\t} else if ( ! isMixed ) {\n\t\tcurrentValue = ! showCustomValueControl\n\t\t\t? getSliderValueFromPreset( value, spacingSizes )\n\t\t\t: getCustomValueFromPreset( value, spacingSizes );\n\t}\n\n\tconst selectedUnit =\n\t\tuseMemo(\n\t\t\t() => parseQuantityAndUnitFromRawValue( currentValue ),\n\t\t\t[ currentValue ]\n\t\t)[ 1 ] || units[ 0 ]?.value;\n\n\tconst setInitialValue = () => {\n\t\tif ( value === undefined ) {\n\t\t\tonChange( '0' );\n\t\t}\n\t};\n\n\tconst customTooltipContent = ( newValue ) =>\n\t\tvalue === undefined ? undefined : spacingSizes[ newValue ]?.name;\n\n\tconst customRangeValue = parseFloat( currentValue, 10 );\n\n\tconst getNewCustomValue = ( newSize ) => {\n\t\tconst isNumeric = ! isNaN( parseFloat( newSize ) );\n\t\tconst nextValue = isNumeric ? newSize : undefined;\n\t\treturn nextValue;\n\t};\n\n\tconst getNewPresetValue = ( newSize, controlType ) => {\n\t\tconst size = parseInt( newSize, 10 );\n\n\t\tif ( controlType === 'selectList' ) {\n\t\t\tif ( size === 0 ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif ( size === 1 ) {\n\t\t\t\treturn '0';\n\t\t\t}\n\t\t} else if ( size === 0 ) {\n\t\t\treturn '0';\n\t\t}\n\t\treturn `var:preset|spacing|${ spacingSizes[ newSize ]?.slug }`;\n\t};\n\n\tconst handleCustomValueSliderChange = ( next ) => {\n\t\tonChange( [ next, selectedUnit ].join( '' ) );\n\t};\n\n\tconst allPlaceholder = isMixed ? __( 'Mixed' ) : null;\n\n\tconst options = selectListSizes.map( ( size, index ) => ( {\n\t\tkey: index,\n\t\tname: size.name,\n\t} ) );\n\n\tconst marks = spacingSizes.map( ( _newValue, index ) => ( {\n\t\tvalue: index,\n\t\tlabel: undefined,\n\t} ) );\n\n\tconst sideLabel =\n\t\tALL_SIDES.includes( side ) && showSideInLabel ? LABELS[ side ] : '';\n\tconst typeLabel = showSideInLabel ? type?.toLowerCase() : type;\n\n\tconst ariaLabel = sprintf(\n\t\t// translators: 1: The side of the block being modified (top, bottom, left, All sides etc.). 2. Type of spacing being modified (Padding, margin, etc)\n\t\t__( '%1$s %2$s' ),\n\t\tsideLabel,\n\t\ttypeLabel\n\t).trim();\n\n\treturn (\n\t\t<HStack className=\"spacing-sizes-control__wrapper\">\n\t\t\t{ icon && (\n\t\t\t\t<Icon\n\t\t\t\t\tclassName=\"spacing-sizes-control__icon\"\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tsize={ 24 }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showCustomValueControl && (\n\t\t\t\t<>\n\t\t\t\t\t<UnitControl\n\t\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\t\tonChange={ ( newSize ) =>\n\t\t\t\t\t\t\tonChange( getNewCustomValue( newSize ) )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalue={ currentValue }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tmin={ minimumCustomValue }\n\t\t\t\t\t\tplaceholder={ allPlaceholder }\n\t\t\t\t\t\tdisableUnits={ isMixed }\n\t\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t\tclassName=\"spacing-sizes-control__custom-value-input\"\n\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t/>\n\t\t\t\t\t<RangeControl\n\t\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\t\tvalue={ customRangeValue }\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\tmax={ CUSTOM_VALUE_SETTINGS[ selectedUnit ]?.max ?? 10 }\n\t\t\t\t\t\tstep={\n\t\t\t\t\t\t\tCUSTOM_VALUE_SETTINGS[ selectedUnit ]?.steps ?? 0.1\n\t\t\t\t\t\t}\n\t\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t\tonChange={ handleCustomValueSliderChange }\n\t\t\t\t\t\tclassName=\"spacing-sizes-control__custom-value-range\"\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<RangeControl\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tclassName=\"spacing-sizes-control__range-control\"\n\t\t\t\t\tvalue={ currentValue }\n\t\t\t\t\tonChange={ ( newSize ) =>\n\t\t\t\t\t\tonChange( getNewPresetValue( newSize ) )\n\t\t\t\t\t}\n\t\t\t\t\tonMouseDown={ ( event ) => {\n\t\t\t\t\t\t// If mouse down is near start of range set initial value to 0, which\n\t\t\t\t\t\t// prevents the user have to drag right then left to get 0 setting.\n\t\t\t\t\t\tif ( event?.nativeEvent?.offsetX < 35 ) {\n\t\t\t\t\t\t\tsetInitialValue();\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\twithInputField={ false }\n\t\t\t\t\taria-valuenow={ currentValue }\n\t\t\t\t\taria-valuetext={ spacingSizes[ currentValue ]?.name }\n\t\t\t\t\trenderTooltipContent={ customTooltipContent }\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tmax={ spacingSizes.length - 1 }\n\t\t\t\t\tmarks={ marks }\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t__nextHasNoMarginBottom={ true }\n\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ! showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<CustomSelectControl\n\t\t\t\t\tclassName=\"spacing-sizes-control__custom-select-control\"\n\t\t\t\t\tvalue={\n\t\t\t\t\t\toptions.find(\n\t\t\t\t\t\t\t( option ) => option.key === currentValue\n\t\t\t\t\t\t) || '' // passing undefined here causes a downshift controlled/uncontrolled warning\n\t\t\t\t\t}\n\t\t\t\t\tonChange={ ( selection ) => {\n\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\tgetNewPresetValue(\n\t\t\t\t\t\t\t\tselection.selectedItem.key,\n\t\t\t\t\t\t\t\t'selectList'\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t} }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t__nextUnconstrainedWidth={ true }\n\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ! disableCustomSpacingSizes && (\n\t\t\t\t<Button\n\t\t\t\t\tlabel={\n\t\t\t\t\t\tshowCustomValueControl\n\t\t\t\t\t\t\t? __( 'Use size preset' )\n\t\t\t\t\t\t\t: __( 'Set custom size' )\n\t\t\t\t\t}\n\t\t\t\t\ticon={ settings }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetShowCustomValueControl( ! showCustomValueControl );\n\t\t\t\t\t} }\n\t\t\t\t\tisPressed={ showCustomValueControl }\n\t\t\t\t\tisSmall\n\t\t\t\t\tclassName=\"spacing-sizes-control__custom-toggle\"\n\t\t\t\t\ticonSize={ 24 }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</HStack>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,MAAM,EACNC,mBAAmB,EACnBC,IAAI,EACJC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AC;AAEX"}
@@ -13,6 +13,9 @@ import { isUnmodifiedDefaultBlock as getIsUnmodifiedDefaultBlock } from '@wordpr
13
13
  import useOnBlockDrop from '../use-on-block-drop';
14
14
  import { getDistanceToNearestEdge, isPointContainedByRect } from '../../utils/math';
15
15
  import { store as blockEditorStore } from '../../store';
16
+ const THRESHOLD_DISTANCE = 30;
17
+ const MINIMUM_HEIGHT_FOR_THRESHOLD = 120;
18
+ const MINIMUM_WIDTH_FOR_THRESHOLD = 120;
16
19
 
17
20
  /** @typedef {import('../../utils/math').WPPoint} WPPoint */
18
21
  /** @typedef {import('../use-on-block-drop/types').WPDropOperation} WPDropOperation */
@@ -42,14 +45,56 @@ import { store as blockEditorStore } from '../../store';
42
45
  * @param {WPBlockData[]} blocksData The block data list.
43
46
  * @param {WPPoint} position The position of the item being dragged.
44
47
  * @param {WPBlockListOrientation} orientation The orientation of the block list.
48
+ * @param {Object} options Additional options.
45
49
  * @return {[number, WPDropOperation]} The drop target position.
46
50
  */
47
- export function getDropTargetPosition(blocksData, position, orientation = 'vertical') {
51
+ export function getDropTargetPosition(blocksData, position, orientation = 'vertical', options = {}) {
48
52
  const allowedEdges = orientation === 'horizontal' ? ['left', 'right'] : ['top', 'bottom'];
49
- const isRightToLeft = isRTL();
50
53
  let nearestIndex = 0;
51
54
  let insertPosition = 'before';
52
55
  let minDistance = Infinity;
56
+ const {
57
+ dropZoneElement,
58
+ parentBlockOrientation,
59
+ rootBlockIndex = 0
60
+ } = options;
61
+
62
+ // Allow before/after when dragging over the top/bottom edges of the drop zone.
63
+ if (dropZoneElement && parentBlockOrientation !== 'horizontal') {
64
+ const rect = dropZoneElement.getBoundingClientRect();
65
+ const [distance, edge] = getDistanceToNearestEdge(position, rect, ['top', 'bottom']);
66
+
67
+ // If dragging over the top or bottom of the drop zone, insert the block
68
+ // before or after the parent block. This only applies to blocks that use
69
+ // a drop zone element, typically container blocks such as Group or Cover.
70
+ if (rect.height > MINIMUM_HEIGHT_FOR_THRESHOLD && distance < THRESHOLD_DISTANCE) {
71
+ if (edge === 'top') {
72
+ return [rootBlockIndex, 'before'];
73
+ }
74
+ if (edge === 'bottom') {
75
+ return [rootBlockIndex + 1, 'after'];
76
+ }
77
+ }
78
+ }
79
+ const isRightToLeft = isRTL();
80
+
81
+ // Allow before/after when dragging over the left/right edges of the drop zone.
82
+ if (dropZoneElement && parentBlockOrientation === 'horizontal') {
83
+ const rect = dropZoneElement.getBoundingClientRect();
84
+ const [distance, edge] = getDistanceToNearestEdge(position, rect, ['left', 'right']);
85
+
86
+ // If dragging over the left or right of the drop zone, insert the block
87
+ // before or after the parent block. This only applies to blocks that use
88
+ // a drop zone element, typically container blocks such as Group.
89
+ if (rect.width > MINIMUM_WIDTH_FOR_THRESHOLD && distance < THRESHOLD_DISTANCE) {
90
+ if (isRightToLeft && edge === 'right' || !isRightToLeft && edge === 'left') {
91
+ return [rootBlockIndex, 'before'];
92
+ }
93
+ if (isRightToLeft && edge === 'left' || !isRightToLeft && edge === 'right') {
94
+ return [rootBlockIndex + 1, 'after'];
95
+ }
96
+ }
97
+ }
53
98
  blocksData.forEach(({
54
99
  isUnmodifiedDefaultBlock,
55
100
  getBoundingClientRect,
@@ -88,7 +133,8 @@ export function getDropTargetPosition(blocksData, position, orientation = 'verti
88
133
 
89
134
  /**
90
135
  * @typedef {Object} WPBlockDropZoneConfig
91
- * @property {string} rootClientId The root client id for the block list.
136
+ * @property {?HTMLElement} dropZoneElement Optional element to be used as the drop zone.
137
+ * @property {string} rootClientId The root client id for the block list.
92
138
  */
93
139
 
94
140
  /**
@@ -97,6 +143,7 @@ export function getDropTargetPosition(blocksData, position, orientation = 'verti
97
143
  * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.
98
144
  */
99
145
  export default function useBlockDropZone({
146
+ dropZoneElement,
100
147
  // An undefined value represents a top-level block. Default to an empty
101
148
  // string for this so that `targetRootClientId` can be easily compared to
102
149
  // values returned by the `getRootBlockClientId` selector, which also uses
@@ -108,14 +155,24 @@ export default function useBlockDropZone({
108
155
  index: null,
109
156
  operation: 'insert'
110
157
  });
111
- const isDisabled = useSelect(select => {
158
+ const {
159
+ isDisabled,
160
+ parentBlockClientId,
161
+ rootBlockIndex
162
+ } = useSelect(select => {
112
163
  const {
113
164
  __unstableIsWithinBlockOverlay,
114
165
  __unstableHasActiveBlockOverlayActive,
166
+ getBlockIndex,
167
+ getBlockParents,
115
168
  getBlockEditingMode
116
169
  } = select(blockEditorStore);
117
170
  const blockEditingMode = getBlockEditingMode(targetRootClientId);
118
- return blockEditingMode !== 'default' || __unstableHasActiveBlockOverlayActive(targetRootClientId) || __unstableIsWithinBlockOverlay(targetRootClientId);
171
+ return {
172
+ parentBlockClientId: getBlockParents(targetRootClientId, true)[0] || '',
173
+ rootBlockIndex: getBlockIndex(targetRootClientId),
174
+ isDisabled: blockEditingMode !== 'default' || __unstableHasActiveBlockOverlayActive(targetRootClientId) || __unstableIsWithinBlockOverlay(targetRootClientId)
175
+ };
119
176
  }, [targetRootClientId]);
120
177
  const {
121
178
  getBlockListSettings,
@@ -126,7 +183,7 @@ export default function useBlockDropZone({
126
183
  showInsertionPoint,
127
184
  hideInsertionPoint
128
185
  } = useDispatch(blockEditorStore);
129
- const onBlockDrop = useOnBlockDrop(targetRootClientId, dropTarget.index, {
186
+ const onBlockDrop = useOnBlockDrop(dropTarget.operation === 'before' || dropTarget.operation === 'after' ? parentBlockClientId : targetRootClientId, dropTarget.index, {
130
187
  operation: dropTarget.operation
131
188
  });
132
189
  const throttled = useThrottle(useCallback((event, ownerDocument) => {
@@ -156,18 +213,25 @@ export default function useBlockDropZone({
156
213
  const [targetIndex, operation] = getDropTargetPosition(blocksData, {
157
214
  x: event.clientX,
158
215
  y: event.clientY
159
- }, getBlockListSettings(targetRootClientId)?.orientation);
216
+ }, getBlockListSettings(targetRootClientId)?.orientation, {
217
+ dropZoneElement,
218
+ parentBlockClientId,
219
+ parentBlockOrientation: parentBlockClientId ? getBlockListSettings(parentBlockClientId)?.orientation : undefined,
220
+ rootBlockIndex
221
+ });
160
222
  registry.batch(() => {
161
223
  setDropTarget({
162
224
  index: targetIndex,
163
225
  operation
164
226
  });
165
- showInsertionPoint(targetRootClientId, targetIndex, {
227
+ const insertionPointClientId = ['before', 'after'].includes(operation) ? parentBlockClientId : targetRootClientId;
228
+ showInsertionPoint(insertionPointClientId, targetIndex, {
166
229
  operation
167
230
  });
168
231
  });
169
- }, [getBlocks, targetRootClientId, getBlockListSettings, registry, showInsertionPoint, getBlockIndex]), 200);
232
+ }, [dropZoneElement, getBlocks, targetRootClientId, getBlockListSettings, registry, showInsertionPoint, getBlockIndex, parentBlockClientId, rootBlockIndex]), 200);
170
233
  return useDropZone({
234
+ dropZoneElement,
171
235
  isDisabled,
172
236
  onDrop: onBlockDrop,
173
237
  onDragOver(event) {
@@ -1 +1 @@
1
- {"version":3,"names":["useDispatch","useSelect","useRegistry","useCallback","useState","useThrottle","__experimentalUseDropZone","useDropZone","isRTL","isUnmodifiedDefaultBlock","getIsUnmodifiedDefaultBlock","useOnBlockDrop","getDistanceToNearestEdge","isPointContainedByRect","store","blockEditorStore","getDropTargetPosition","blocksData","position","orientation","allowedEdges","isRightToLeft","nearestIndex","insertPosition","minDistance","Infinity","forEach","getBoundingClientRect","blockIndex","rect","distance","edge","adjacentIndex","isNearestBlockUnmodifiedDefaultBlock","isAdjacentBlockUnmodifiedDefaultBlock","insertionIndex","useBlockDropZone","rootClientId","targetRootClientId","registry","dropTarget","setDropTarget","index","operation","isDisabled","select","__unstableIsWithinBlockOverlay","__unstableHasActiveBlockOverlayActive","getBlockEditingMode","blockEditingMode","getBlockListSettings","getBlocks","getBlockIndex","showInsertionPoint","hideInsertionPoint","onBlockDrop","throttled","event","ownerDocument","blocks","length","batch","map","block","clientId","getElementById","targetIndex","x","clientX","y","clientY","onDrop","onDragOver","currentTarget","onDragLeave","cancel","onDragEnd"],"sources":["@wordpress/block-editor/src/components/use-block-drop-zone/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { useCallback, useState } from '@wordpress/element';\nimport {\n\tuseThrottle,\n\t__experimentalUseDropZone as useDropZone,\n} from '@wordpress/compose';\nimport { isRTL } from '@wordpress/i18n';\nimport { isUnmodifiedDefaultBlock as getIsUnmodifiedDefaultBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport useOnBlockDrop from '../use-on-block-drop';\nimport {\n\tgetDistanceToNearestEdge,\n\tisPointContainedByRect,\n} from '../../utils/math';\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('../../utils/math').WPPoint} WPPoint */\n/** @typedef {import('../use-on-block-drop/types').WPDropOperation} WPDropOperation */\n\n/**\n * The orientation of a block list.\n *\n * @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation\n */\n\n/**\n * The insert position when dropping a block.\n *\n * @typedef {'before'|'after'} WPInsertPosition\n */\n\n/**\n * @typedef {Object} WPBlockData\n * @property {boolean} isUnmodifiedDefaultBlock Is the block unmodified default block.\n * @property {() => DOMRect} getBoundingClientRect Get the bounding client rect of the block.\n * @property {number} blockIndex The index of the block.\n */\n\n/**\n * Get the drop target position from a given drop point and the orientation.\n *\n * @param {WPBlockData[]} blocksData The block data list.\n * @param {WPPoint} position The position of the item being dragged.\n * @param {WPBlockListOrientation} orientation The orientation of the block list.\n * @return {[number, WPDropOperation]} The drop target position.\n */\nexport function getDropTargetPosition(\n\tblocksData,\n\tposition,\n\torientation = 'vertical'\n) {\n\tconst allowedEdges =\n\t\torientation === 'horizontal'\n\t\t\t? [ 'left', 'right' ]\n\t\t\t: [ 'top', 'bottom' ];\n\n\tconst isRightToLeft = isRTL();\n\n\tlet nearestIndex = 0;\n\tlet insertPosition = 'before';\n\tlet minDistance = Infinity;\n\n\tblocksData.forEach(\n\t\t( { isUnmodifiedDefaultBlock, getBoundingClientRect, blockIndex } ) => {\n\t\t\tconst rect = getBoundingClientRect();\n\n\t\t\tlet [ distance, edge ] = getDistanceToNearestEdge(\n\t\t\t\tposition,\n\t\t\t\trect,\n\t\t\t\tallowedEdges\n\t\t\t);\n\t\t\t// Prioritize the element if the point is inside of an unmodified default block.\n\t\t\tif (\n\t\t\t\tisUnmodifiedDefaultBlock &&\n\t\t\t\tisPointContainedByRect( position, rect )\n\t\t\t) {\n\t\t\t\tdistance = 0;\n\t\t\t}\n\n\t\t\tif ( distance < minDistance ) {\n\t\t\t\t// Where the dropped block will be inserted on the nearest block.\n\t\t\t\tinsertPosition =\n\t\t\t\t\tedge === 'bottom' ||\n\t\t\t\t\t( ! isRightToLeft && edge === 'right' ) ||\n\t\t\t\t\t( isRightToLeft && edge === 'left' )\n\t\t\t\t\t\t? 'after'\n\t\t\t\t\t\t: 'before';\n\n\t\t\t\t// Update the currently known best candidate.\n\t\t\t\tminDistance = distance;\n\t\t\t\tnearestIndex = blockIndex;\n\t\t\t}\n\t\t}\n\t);\n\n\tconst adjacentIndex =\n\t\tnearestIndex + ( insertPosition === 'after' ? 1 : -1 );\n\tconst isNearestBlockUnmodifiedDefaultBlock =\n\t\t!! blocksData[ nearestIndex ]?.isUnmodifiedDefaultBlock;\n\tconst isAdjacentBlockUnmodifiedDefaultBlock =\n\t\t!! blocksData[ adjacentIndex ]?.isUnmodifiedDefaultBlock;\n\n\t// If both blocks are not unmodified default blocks then just insert between them.\n\tif (\n\t\t! isNearestBlockUnmodifiedDefaultBlock &&\n\t\t! isAdjacentBlockUnmodifiedDefaultBlock\n\t) {\n\t\t// If the user is dropping to the trailing edge of the block\n\t\t// add 1 to the index to represent dragging after.\n\t\tconst insertionIndex =\n\t\t\tinsertPosition === 'after' ? nearestIndex + 1 : nearestIndex;\n\t\treturn [ insertionIndex, 'insert' ];\n\t}\n\n\t// Otherwise, replace the nearest unmodified default block.\n\treturn [\n\t\tisNearestBlockUnmodifiedDefaultBlock ? nearestIndex : adjacentIndex,\n\t\t'replace',\n\t];\n}\n\n/**\n * @typedef {Object} WPBlockDropZoneConfig\n * @property {string} rootClientId The root client id for the block list.\n */\n\n/**\n * A React hook that can be used to make a block list handle drag and drop.\n *\n * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.\n */\nexport default function useBlockDropZone( {\n\t// An undefined value represents a top-level block. Default to an empty\n\t// string for this so that `targetRootClientId` can be easily compared to\n\t// values returned by the `getRootBlockClientId` selector, which also uses\n\t// an empty string to represent top-level blocks.\n\trootClientId: targetRootClientId = '',\n} = {} ) {\n\tconst registry = useRegistry();\n\tconst [ dropTarget, setDropTarget ] = useState( {\n\t\tindex: null,\n\t\toperation: 'insert',\n\t} );\n\n\tconst isDisabled = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\t__unstableIsWithinBlockOverlay,\n\t\t\t\t__unstableHasActiveBlockOverlayActive,\n\t\t\t\tgetBlockEditingMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst blockEditingMode = getBlockEditingMode( targetRootClientId );\n\t\t\treturn (\n\t\t\t\tblockEditingMode !== 'default' ||\n\t\t\t\t__unstableHasActiveBlockOverlayActive( targetRootClientId ) ||\n\t\t\t\t__unstableIsWithinBlockOverlay( targetRootClientId )\n\t\t\t);\n\t\t},\n\t\t[ targetRootClientId ]\n\t);\n\n\tconst { getBlockListSettings, getBlocks, getBlockIndex } =\n\t\tuseSelect( blockEditorStore );\n\tconst { showInsertionPoint, hideInsertionPoint } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst onBlockDrop = useOnBlockDrop( targetRootClientId, dropTarget.index, {\n\t\toperation: dropTarget.operation,\n\t} );\n\tconst throttled = useThrottle(\n\t\tuseCallback(\n\t\t\t( event, ownerDocument ) => {\n\t\t\t\tconst blocks = getBlocks( targetRootClientId );\n\n\t\t\t\t// The block list is empty, don't show the insertion point but still allow dropping.\n\t\t\t\tif ( blocks.length === 0 ) {\n\t\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t\tsetDropTarget( {\n\t\t\t\t\t\t\tindex: 0,\n\t\t\t\t\t\t\toperation: 'insert',\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tshowInsertionPoint( targetRootClientId, 0, {\n\t\t\t\t\t\t\toperation: 'insert',\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst blocksData = blocks.map( ( block ) => {\n\t\t\t\t\tconst clientId = block.clientId;\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisUnmodifiedDefaultBlock:\n\t\t\t\t\t\t\tgetIsUnmodifiedDefaultBlock( block ),\n\t\t\t\t\t\tgetBoundingClientRect: () =>\n\t\t\t\t\t\t\townerDocument\n\t\t\t\t\t\t\t\t.getElementById( `block-${ clientId }` )\n\t\t\t\t\t\t\t\t.getBoundingClientRect(),\n\t\t\t\t\t\tblockIndex: getBlockIndex( clientId ),\n\t\t\t\t\t};\n\t\t\t\t} );\n\n\t\t\t\tconst [ targetIndex, operation ] = getDropTargetPosition(\n\t\t\t\t\tblocksData,\n\t\t\t\t\t{ x: event.clientX, y: event.clientY },\n\t\t\t\t\tgetBlockListSettings( targetRootClientId )?.orientation\n\t\t\t\t);\n\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tsetDropTarget( {\n\t\t\t\t\t\tindex: targetIndex,\n\t\t\t\t\t\toperation,\n\t\t\t\t\t} );\n\t\t\t\t\tshowInsertionPoint( targetRootClientId, targetIndex, {\n\t\t\t\t\t\toperation,\n\t\t\t\t\t} );\n\t\t\t\t} );\n\t\t\t},\n\t\t\t[\n\t\t\t\tgetBlocks,\n\t\t\t\ttargetRootClientId,\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tregistry,\n\t\t\t\tshowInsertionPoint,\n\t\t\t\tgetBlockIndex,\n\t\t\t]\n\t\t),\n\t\t200\n\t);\n\n\treturn useDropZone( {\n\t\tisDisabled,\n\t\tonDrop: onBlockDrop,\n\t\tonDragOver( event ) {\n\t\t\t// `currentTarget` is only available while the event is being\n\t\t\t// handled, so get it now and pass it to the thottled function.\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget\n\t\t\tthrottled( event, event.currentTarget.ownerDocument );\n\t\t},\n\t\tonDragLeave() {\n\t\t\tthrottled.cancel();\n\t\t\thideInsertionPoint();\n\t\t},\n\t\tonDragEnd() {\n\t\t\tthrottled.cancel();\n\t\t\thideInsertionPoint();\n\t\t},\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACrE,SAASC,WAAW,EAAEC,QAAQ,QAAQ,oBAAoB;AAC1D,SACCC,WAAW,EACXC,yBAAyB,IAAIC,WAAW,QAClC,oBAAoB;AAC3B,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SAASC,wBAAwB,IAAIC,2BAA2B,QAAQ,mBAAmB;;AAE3F;AACA;AACA;AACA,OAAOC,cAAc,MAAM,sBAAsB;AACjD,SACCC,wBAAwB,EACxBC,sBAAsB,QAChB,kBAAkB;AACzB,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;;AAEvD;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CACpCC,UAAU,EACVC,QAAQ,EACRC,WAAW,GAAG,UAAU,EACvB;EACD,MAAMC,YAAY,GACjBD,WAAW,KAAK,YAAY,GACzB,CAAE,MAAM,EAAE,OAAO,CAAE,GACnB,CAAE,KAAK,EAAE,QAAQ,CAAE;EAEvB,MAAME,aAAa,GAAGb,KAAK,CAAC,CAAC;EAE7B,IAAIc,YAAY,GAAG,CAAC;EACpB,IAAIC,cAAc,GAAG,QAAQ;EAC7B,IAAIC,WAAW,GAAGC,QAAQ;EAE1BR,UAAU,CAACS,OAAO,CACjB,CAAE;IAAEjB,wBAAwB;IAAEkB,qBAAqB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,CAAC;IACtD,CAAC;IACDgB,WAAWA,CAAA,EAAG;MACblB,SAAS,CAACmB,MAAM,CAAC,CAAC;MAClBrB,kBAAkB,CAAC,CAAC;IACrB,CAAC;IACDsB,SAASA,CAAA,EAAG;MACXpB,SAAS,CAACmB,MAAM,CAAC,CAAC;MAClBrB,kBAAkB,CAAC,CAAC;IACrB;EACD,CAAE,CAAC;AACJ"}
1
+ {"version":3,"names":["useDispatch","useSelect","useRegistry","useCallback","useState","useThrottle","__experimentalUseDropZone","useDropZone","isRTL","isUnmodifiedDefaultBlock","getIsUnmodifiedDefaultBlock","useOnBlockDrop","getDistanceToNearestEdge","isPointContainedByRect","store","blockEditorStore","THRESHOLD_DISTANCE","MINIMUM_HEIGHT_FOR_THRESHOLD","MINIMUM_WIDTH_FOR_THRESHOLD","getDropTargetPosition","blocksData","position","orientation","options","allowedEdges","nearestIndex","insertPosition","minDistance","Infinity","dropZoneElement","parentBlockOrientation","rootBlockIndex","rect","getBoundingClientRect","distance","edge","height","isRightToLeft","width","forEach","blockIndex","adjacentIndex","isNearestBlockUnmodifiedDefaultBlock","isAdjacentBlockUnmodifiedDefaultBlock","insertionIndex","useBlockDropZone","rootClientId","targetRootClientId","registry","dropTarget","setDropTarget","index","operation","isDisabled","parentBlockClientId","select","__unstableIsWithinBlockOverlay","__unstableHasActiveBlockOverlayActive","getBlockIndex","getBlockParents","getBlockEditingMode","blockEditingMode","getBlockListSettings","getBlocks","showInsertionPoint","hideInsertionPoint","onBlockDrop","throttled","event","ownerDocument","blocks","length","batch","map","block","clientId","getElementById","targetIndex","x","clientX","y","clientY","undefined","insertionPointClientId","includes","onDrop","onDragOver","currentTarget","onDragLeave","cancel","onDragEnd"],"sources":["@wordpress/block-editor/src/components/use-block-drop-zone/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { useCallback, useState } from '@wordpress/element';\nimport {\n\tuseThrottle,\n\t__experimentalUseDropZone as useDropZone,\n} from '@wordpress/compose';\nimport { isRTL } from '@wordpress/i18n';\nimport { isUnmodifiedDefaultBlock as getIsUnmodifiedDefaultBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport useOnBlockDrop from '../use-on-block-drop';\nimport {\n\tgetDistanceToNearestEdge,\n\tisPointContainedByRect,\n} from '../../utils/math';\nimport { store as blockEditorStore } from '../../store';\n\nconst THRESHOLD_DISTANCE = 30;\nconst MINIMUM_HEIGHT_FOR_THRESHOLD = 120;\nconst MINIMUM_WIDTH_FOR_THRESHOLD = 120;\n\n/** @typedef {import('../../utils/math').WPPoint} WPPoint */\n/** @typedef {import('../use-on-block-drop/types').WPDropOperation} WPDropOperation */\n\n/**\n * The orientation of a block list.\n *\n * @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation\n */\n\n/**\n * The insert position when dropping a block.\n *\n * @typedef {'before'|'after'} WPInsertPosition\n */\n\n/**\n * @typedef {Object} WPBlockData\n * @property {boolean} isUnmodifiedDefaultBlock Is the block unmodified default block.\n * @property {() => DOMRect} getBoundingClientRect Get the bounding client rect of the block.\n * @property {number} blockIndex The index of the block.\n */\n\n/**\n * Get the drop target position from a given drop point and the orientation.\n *\n * @param {WPBlockData[]} blocksData The block data list.\n * @param {WPPoint} position The position of the item being dragged.\n * @param {WPBlockListOrientation} orientation The orientation of the block list.\n * @param {Object} options Additional options.\n * @return {[number, WPDropOperation]} The drop target position.\n */\nexport function getDropTargetPosition(\n\tblocksData,\n\tposition,\n\torientation = 'vertical',\n\toptions = {}\n) {\n\tconst allowedEdges =\n\t\torientation === 'horizontal'\n\t\t\t? [ 'left', 'right' ]\n\t\t\t: [ 'top', 'bottom' ];\n\n\tlet nearestIndex = 0;\n\tlet insertPosition = 'before';\n\tlet minDistance = Infinity;\n\n\tconst {\n\t\tdropZoneElement,\n\t\tparentBlockOrientation,\n\t\trootBlockIndex = 0,\n\t} = options;\n\n\t// Allow before/after when dragging over the top/bottom edges of the drop zone.\n\tif ( dropZoneElement && parentBlockOrientation !== 'horizontal' ) {\n\t\tconst rect = dropZoneElement.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge( position, rect, [\n\t\t\t'top',\n\t\t\t'bottom',\n\t\t] );\n\n\t\t// If dragging over the top or bottom of the drop zone, insert the block\n\t\t// before or after the parent block. This only applies to blocks that use\n\t\t// a drop zone element, typically container blocks such as Group or Cover.\n\t\tif (\n\t\t\trect.height > MINIMUM_HEIGHT_FOR_THRESHOLD &&\n\t\t\tdistance < THRESHOLD_DISTANCE\n\t\t) {\n\t\t\tif ( edge === 'top' ) {\n\t\t\t\treturn [ rootBlockIndex, 'before' ];\n\t\t\t}\n\t\t\tif ( edge === 'bottom' ) {\n\t\t\t\treturn [ rootBlockIndex + 1, 'after' ];\n\t\t\t}\n\t\t}\n\t}\n\n\tconst isRightToLeft = isRTL();\n\n\t// Allow before/after when dragging over the left/right edges of the drop zone.\n\tif ( dropZoneElement && parentBlockOrientation === 'horizontal' ) {\n\t\tconst rect = dropZoneElement.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge( position, rect, [\n\t\t\t'left',\n\t\t\t'right',\n\t\t] );\n\n\t\t// If dragging over the left or right of the drop zone, insert the block\n\t\t// before or after the parent block. This only applies to blocks that use\n\t\t// a drop zone element, typically container blocks such as Group.\n\t\tif (\n\t\t\trect.width > MINIMUM_WIDTH_FOR_THRESHOLD &&\n\t\t\tdistance < THRESHOLD_DISTANCE\n\t\t) {\n\t\t\tif (\n\t\t\t\t( isRightToLeft && edge === 'right' ) ||\n\t\t\t\t( ! isRightToLeft && edge === 'left' )\n\t\t\t) {\n\t\t\t\treturn [ rootBlockIndex, 'before' ];\n\t\t\t}\n\t\t\tif (\n\t\t\t\t( isRightToLeft && edge === 'left' ) ||\n\t\t\t\t( ! isRightToLeft && edge === 'right' )\n\t\t\t) {\n\t\t\t\treturn [ rootBlockIndex + 1, 'after' ];\n\t\t\t}\n\t\t}\n\t}\n\n\tblocksData.forEach(\n\t\t( { isUnmodifiedDefaultBlock, getBoundingClientRect, blockIndex } ) => {\n\t\t\tconst rect = getBoundingClientRect();\n\n\t\t\tlet [ distance, edge ] = getDistanceToNearestEdge(\n\t\t\t\tposition,\n\t\t\t\trect,\n\t\t\t\tallowedEdges\n\t\t\t);\n\t\t\t// Prioritize the element if the point is inside of an unmodified default block.\n\t\t\tif (\n\t\t\t\tisUnmodifiedDefaultBlock &&\n\t\t\t\tisPointContainedByRect( position, rect )\n\t\t\t) {\n\t\t\t\tdistance = 0;\n\t\t\t}\n\n\t\t\tif ( distance < minDistance ) {\n\t\t\t\t// Where the dropped block will be inserted on the nearest block.\n\t\t\t\tinsertPosition =\n\t\t\t\t\tedge === 'bottom' ||\n\t\t\t\t\t( ! isRightToLeft && edge === 'right' ) ||\n\t\t\t\t\t( isRightToLeft && edge === 'left' )\n\t\t\t\t\t\t? 'after'\n\t\t\t\t\t\t: 'before';\n\n\t\t\t\t// Update the currently known best candidate.\n\t\t\t\tminDistance = distance;\n\t\t\t\tnearestIndex = blockIndex;\n\t\t\t}\n\t\t}\n\t);\n\n\tconst adjacentIndex =\n\t\tnearestIndex + ( insertPosition === 'after' ? 1 : -1 );\n\tconst isNearestBlockUnmodifiedDefaultBlock =\n\t\t!! blocksData[ nearestIndex ]?.isUnmodifiedDefaultBlock;\n\tconst isAdjacentBlockUnmodifiedDefaultBlock =\n\t\t!! blocksData[ adjacentIndex ]?.isUnmodifiedDefaultBlock;\n\n\t// If both blocks are not unmodified default blocks then just insert between them.\n\tif (\n\t\t! isNearestBlockUnmodifiedDefaultBlock &&\n\t\t! isAdjacentBlockUnmodifiedDefaultBlock\n\t) {\n\t\t// If the user is dropping to the trailing edge of the block\n\t\t// add 1 to the index to represent dragging after.\n\t\tconst insertionIndex =\n\t\t\tinsertPosition === 'after' ? nearestIndex + 1 : nearestIndex;\n\t\treturn [ insertionIndex, 'insert' ];\n\t}\n\n\t// Otherwise, replace the nearest unmodified default block.\n\treturn [\n\t\tisNearestBlockUnmodifiedDefaultBlock ? nearestIndex : adjacentIndex,\n\t\t'replace',\n\t];\n}\n\n/**\n * @typedef {Object} WPBlockDropZoneConfig\n * @property {?HTMLElement} dropZoneElement Optional element to be used as the drop zone.\n * @property {string} rootClientId The root client id for the block list.\n */\n\n/**\n * A React hook that can be used to make a block list handle drag and drop.\n *\n * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.\n */\nexport default function useBlockDropZone( {\n\tdropZoneElement,\n\t// An undefined value represents a top-level block. Default to an empty\n\t// string for this so that `targetRootClientId` can be easily compared to\n\t// values returned by the `getRootBlockClientId` selector, which also uses\n\t// an empty string to represent top-level blocks.\n\trootClientId: targetRootClientId = '',\n} = {} ) {\n\tconst registry = useRegistry();\n\tconst [ dropTarget, setDropTarget ] = useState( {\n\t\tindex: null,\n\t\toperation: 'insert',\n\t} );\n\n\tconst { isDisabled, parentBlockClientId, rootBlockIndex } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\t__unstableIsWithinBlockOverlay,\n\t\t\t\t__unstableHasActiveBlockOverlayActive,\n\t\t\t\tgetBlockIndex,\n\t\t\t\tgetBlockParents,\n\t\t\t\tgetBlockEditingMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst blockEditingMode = getBlockEditingMode( targetRootClientId );\n\t\t\treturn {\n\t\t\t\tparentBlockClientId:\n\t\t\t\t\tgetBlockParents( targetRootClientId, true )[ 0 ] || '',\n\t\t\t\trootBlockIndex: getBlockIndex( targetRootClientId ),\n\t\t\t\tisDisabled:\n\t\t\t\t\tblockEditingMode !== 'default' ||\n\t\t\t\t\t__unstableHasActiveBlockOverlayActive(\n\t\t\t\t\t\ttargetRootClientId\n\t\t\t\t\t) ||\n\t\t\t\t\t__unstableIsWithinBlockOverlay( targetRootClientId ),\n\t\t\t};\n\t\t},\n\t\t[ targetRootClientId ]\n\t);\n\n\tconst { getBlockListSettings, getBlocks, getBlockIndex } =\n\t\tuseSelect( blockEditorStore );\n\tconst { showInsertionPoint, hideInsertionPoint } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst onBlockDrop = useOnBlockDrop(\n\t\tdropTarget.operation === 'before' || dropTarget.operation === 'after'\n\t\t\t? parentBlockClientId\n\t\t\t: targetRootClientId,\n\t\tdropTarget.index,\n\t\t{\n\t\t\toperation: dropTarget.operation,\n\t\t}\n\t);\n\tconst throttled = useThrottle(\n\t\tuseCallback(\n\t\t\t( event, ownerDocument ) => {\n\t\t\t\tconst blocks = getBlocks( targetRootClientId );\n\n\t\t\t\t// The block list is empty, don't show the insertion point but still allow dropping.\n\t\t\t\tif ( blocks.length === 0 ) {\n\t\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t\tsetDropTarget( {\n\t\t\t\t\t\t\tindex: 0,\n\t\t\t\t\t\t\toperation: 'insert',\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tshowInsertionPoint( targetRootClientId, 0, {\n\t\t\t\t\t\t\toperation: 'insert',\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst blocksData = blocks.map( ( block ) => {\n\t\t\t\t\tconst clientId = block.clientId;\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisUnmodifiedDefaultBlock:\n\t\t\t\t\t\t\tgetIsUnmodifiedDefaultBlock( block ),\n\t\t\t\t\t\tgetBoundingClientRect: () =>\n\t\t\t\t\t\t\townerDocument\n\t\t\t\t\t\t\t\t.getElementById( `block-${ clientId }` )\n\t\t\t\t\t\t\t\t.getBoundingClientRect(),\n\t\t\t\t\t\tblockIndex: getBlockIndex( clientId ),\n\t\t\t\t\t};\n\t\t\t\t} );\n\n\t\t\t\tconst [ targetIndex, operation ] = getDropTargetPosition(\n\t\t\t\t\tblocksData,\n\t\t\t\t\t{ x: event.clientX, y: event.clientY },\n\t\t\t\t\tgetBlockListSettings( targetRootClientId )?.orientation,\n\t\t\t\t\t{\n\t\t\t\t\t\tdropZoneElement,\n\t\t\t\t\t\tparentBlockClientId,\n\t\t\t\t\t\tparentBlockOrientation: parentBlockClientId\n\t\t\t\t\t\t\t? getBlockListSettings( parentBlockClientId )\n\t\t\t\t\t\t\t\t\t?.orientation\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\trootBlockIndex,\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tsetDropTarget( {\n\t\t\t\t\t\tindex: targetIndex,\n\t\t\t\t\t\toperation,\n\t\t\t\t\t} );\n\n\t\t\t\t\tconst insertionPointClientId = [\n\t\t\t\t\t\t'before',\n\t\t\t\t\t\t'after',\n\t\t\t\t\t].includes( operation )\n\t\t\t\t\t\t? parentBlockClientId\n\t\t\t\t\t\t: targetRootClientId;\n\n\t\t\t\t\tshowInsertionPoint( insertionPointClientId, targetIndex, {\n\t\t\t\t\t\toperation,\n\t\t\t\t\t} );\n\t\t\t\t} );\n\t\t\t},\n\t\t\t[\n\t\t\t\tdropZoneElement,\n\t\t\t\tgetBlocks,\n\t\t\t\ttargetRootClientId,\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tregistry,\n\t\t\t\tshowInsertionPoint,\n\t\t\t\tgetBlockIndex,\n\t\t\t\tparentBlockClientId,\n\t\t\t\trootBlockIndex,\n\t\t\t]\n\t\t),\n\t\t200\n\t);\n\n\treturn useDropZone( {\n\t\tdropZoneElement,\n\t\tisDisabled,\n\t\tonDrop: onBlockDrop,\n\t\tonDragOver( event ) {\n\t\t\t// `currentTarget` is only available while the event is being\n\t\t\t// handled, so get it now and pass it to the thottled function.\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget\n\t\t\tthrottled( event, event.currentTarget.ownerDocument );\n\t\t},\n\t\tonDragLeave() {\n\t\t\tthrottled.cancel();\n\t\t\thideInsertionPoint();\n\t\t},\n\t\tonDragEnd() {\n\t\t\tthrottled.cancel();\n\t\t\thideInsertionPoint();\n\t\t},\n\t}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KAAK,EAAE0B,WAAW;QAClBzB;MACD,CAAE,CAAC;MAEH,MAAM+B,sBAAsB,GAAG,CAC9B,QAAQ,EACR,OAAO,CACP,CAACC,QAAQ,CAAEhC,SAAU,CAAC,GACpBE,mBAAmB,GACnBP,kBAAkB;MAErBiB,kBAAkB,CAAEmB,sBAAsB,EAAEN,WAAW,EAAE;QACxDzB;MACD,CAAE,CAAC;IACJ,CAAE,CAAC;EACJ,CAAC,EACD,CACCvB,eAAe,EACfkC,SAAS,EACThB,kBAAkB,EAClBe,oBAAoB,EACpBd,QAAQ,EACRgB,kBAAkB,EAClBN,aAAa,EACbJ,mBAAmB,EACnBvB,cAAc,CAEhB,CAAC,EACD,GACD,CAAC;EAED,OAAOxB,WAAW,CAAE;IACnBsB,eAAe;IACfwB,UAAU;IACVgC,MAAM,EAAEnB,WAAW;IACnBoB,UAAUA,CAAElB,KAAK,EAAG;MACnB;MACA;MACA;MACAD,SAAS,CAAEC,KAAK,EAAEA,KAAK,CAACmB,aAAa,CAAClB,aAAc,CAAC;IACtD,CAAC;IACDmB,WAAWA,CAAA,EAAG;MACbrB,SAAS,CAACsB,MAAM,CAAC,CAAC;MAClBxB,kBAAkB,CAAC,CAAC;IACrB,CAAC;IACDyB,SAASA,CAAA,EAAG;MACXvB,SAAS,CAACsB,MAAM,CAAC,CAAC;MAClBxB,kBAAkB,CAAC,CAAC;IACrB;EACD,CAAE,CAAC;AACJ"}
@@ -113,7 +113,8 @@ function useMovingAnimation({
113
113
  y = Math.round(y);
114
114
  const finishedMoving = x === 0 && y === 0;
115
115
  ref.current.style.transformOrigin = 'center center';
116
- ref.current.style.transform = finishedMoving ? undefined : `translate3d(${x}px,${y}px,0)`;
116
+ ref.current.style.transform = finishedMoving ? null // Set to `null` to explicitly remove the transform.
117
+ : `translate3d(${x}px,${y}px,0)`;
117
118
  ref.current.style.zIndex = isSelected ? '1' : '';
118
119
  preserveScrollPosition();
119
120
  }
@@ -1 +1 @@
1
- {"version":3,"names":["useSpring","useState","useLayoutEffect","useReducer","useMemo","useRef","useReducedMotion","getScrollContainer","counterReducer","state","getAbsolutePosition","element","top","offsetTop","left","offsetLeft","useMovingAnimation","isSelected","adjustScrolling","enableAnimation","triggerAnimationOnChange","ref","prefersReducedMotion","triggeredAnimation","triggerAnimation","finishedAnimation","endAnimation","transform","setTransform","x","y","previous","current","preserveScrollPosition","scrollContainer","prevRect","getBoundingClientRect","blockRect","diff","scrollTop","style","undefined","destination","Math","round","onChange","value","finishedMoving","transformOrigin","zIndex","from","to","reset","config","mass","tension","friction","immediate"],"sources":["@wordpress/block-editor/src/components/use-moving-animation/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { useSpring } from '@react-spring/web';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tuseLayoutEffect,\n\tuseReducer,\n\tuseMemo,\n\tuseRef,\n} from '@wordpress/element';\nimport { useReducedMotion } from '@wordpress/compose';\nimport { getScrollContainer } from '@wordpress/dom';\n\n/**\n * Simple reducer used to increment a counter.\n *\n * @param {number} state Previous counter value.\n * @return {number} New state value.\n */\nconst counterReducer = ( state ) => state + 1;\n\nconst getAbsolutePosition = ( element ) => {\n\treturn {\n\t\ttop: element.offsetTop,\n\t\tleft: element.offsetLeft,\n\t};\n};\n\n/**\n * Hook used to compute the styles required to move a div into a new position.\n *\n * The way this animation works is the following:\n * - It first renders the element as if there was no animation.\n * - It takes a snapshot of the position of the block to use it\n * as a destination point for the animation.\n * - It restores the element to the previous position using a CSS transform\n * - It uses the \"resetAnimation\" flag to reset the animation\n * from the beginning in order to animate to the new destination point.\n *\n * @param {Object} $1 Options\n * @param {boolean} $1.isSelected Whether it's the current block or not.\n * @param {boolean} $1.adjustScrolling Adjust the scroll position to the current block.\n * @param {boolean} $1.enableAnimation Enable/Disable animation.\n * @param {*} $1.triggerAnimationOnChange Variable used to trigger the animation if it changes.\n */\nfunction useMovingAnimation( {\n\tisSelected,\n\tadjustScrolling,\n\tenableAnimation,\n\ttriggerAnimationOnChange,\n} ) {\n\tconst ref = useRef();\n\tconst prefersReducedMotion = useReducedMotion() || ! enableAnimation;\n\tconst [ triggeredAnimation, triggerAnimation ] = useReducer(\n\t\tcounterReducer,\n\t\t0\n\t);\n\tconst [ finishedAnimation, endAnimation ] = useReducer( counterReducer, 0 );\n\tconst [ transform, setTransform ] = useState( { x: 0, y: 0 } );\n\tconst previous = useMemo(\n\t\t() => ( ref.current ? getAbsolutePosition( ref.current ) : null ),\n\t\t[ triggerAnimationOnChange ]\n\t);\n\n\t// Calculate the previous position of the block relative to the viewport and\n\t// return a function to maintain that position by scrolling.\n\tconst preserveScrollPosition = useMemo( () => {\n\t\tif ( ! adjustScrolling || ! ref.current ) {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst scrollContainer = getScrollContainer( ref.current );\n\n\t\tif ( ! scrollContainer ) {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst prevRect = ref.current.getBoundingClientRect();\n\t\treturn () => {\n\t\t\tconst blockRect = ref.current.getBoundingClientRect();\n\t\t\tconst diff = blockRect.top - prevRect.top;\n\n\t\t\tif ( diff ) {\n\t\t\t\tscrollContainer.scrollTop += diff;\n\t\t\t}\n\t\t};\n\t}, [ triggerAnimationOnChange, adjustScrolling ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( triggeredAnimation ) {\n\t\t\tendAnimation();\n\t\t}\n\t}, [ triggeredAnimation ] );\n\tuseLayoutEffect( () => {\n\t\tif ( ! previous ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( prefersReducedMotion ) {\n\t\t\t// If the animation is disabled and the scroll needs to be adjusted,\n\t\t\t// just move directly to the final scroll position.\n\t\t\tpreserveScrollPosition();\n\n\t\t\treturn;\n\t\t}\n\n\t\tref.current.style.transform = undefined;\n\t\tconst destination = getAbsolutePosition( ref.current );\n\n\t\ttriggerAnimation();\n\t\tsetTransform( {\n\t\t\tx: Math.round( previous.left - destination.left ),\n\t\t\ty: Math.round( previous.top - destination.top ),\n\t\t} );\n\t}, [ triggerAnimationOnChange ] );\n\n\tfunction onChange( { value } ) {\n\t\tif ( ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\t\tlet { x, y } = value;\n\t\tx = Math.round( x );\n\t\ty = Math.round( y );\n\t\tconst finishedMoving = x === 0 && y === 0;\n\t\tref.current.style.transformOrigin = 'center center';\n\t\tref.current.style.transform = finishedMoving\n\t\t\t? undefined\n\t\t\t: `translate3d(${ x }px,${ y }px,0)`;\n\t\tref.current.style.zIndex = isSelected ? '1' : '';\n\n\t\tpreserveScrollPosition();\n\t}\n\n\tuseSpring( {\n\t\tfrom: {\n\t\t\tx: transform.x,\n\t\t\ty: transform.y,\n\t\t},\n\t\tto: {\n\t\t\tx: 0,\n\t\t\ty: 0,\n\t\t},\n\t\treset: triggeredAnimation !== finishedAnimation,\n\t\tconfig: { mass: 5, tension: 2000, friction: 200 },\n\t\timmediate: prefersReducedMotion,\n\t\tonChange,\n\t} );\n\n\treturn ref;\n}\n\nexport default useMovingAnimation;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,mBAAmB;;AAE7C;AACA;AACA;AACA,SACCC,QAAQ,EACRC,eAAe,EACfC,UAAU,EACVC,OAAO,EACPC,MAAM,QACA,oBAAoB;AAC3B,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,kBAAkB,QAAQ,gBAAgB;;AAEnD;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,cAAc,GAAKC,KAAK,IAAMA,KAAK,GAAG,CAAC;AAE7C,MAAMC,mBAAmB,GAAKC,OAAO,IAAM;EAC1C,OAAO;IACNC,GAAG,EAAED,OAAO,CAACE,SAAS;IACtBC,IAAI,EAAEH,OAAO,CAACI;EACf,CAAC;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,kBAAkBA,CAAE;EAC5BC,UAAU;EACVC,eAAe;EACfC,e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O,CAACQ,KAAK,CAACb,SAAS,GAAGoB,cAAc,GACzCN,SAAS,GACR,eAAeZ,CAAG,MAAMC,CAAG,OAAM;IACrCT,GAAG,CAACW,OAAO,CAACQ,KAAK,CAACS,MAAM,GAAGhC,UAAU,GAAG,GAAG,GAAG,EAAE;IAEhDgB,sBAAsB,CAAC,CAAC;EACzB;EAEAjC,SAAS,CAAE;IACVkD,IAAI,EAAE;MACLrB,CAAC,EAAEF,SAAS,CAACE,CAAC;MACdC,CAAC,EAAEH,SAAS,CAACG;IACd,CAAC;IACDqB,EAAE,EAAE;MACHtB,CAAC,EAAE,CAAC;MACJC,CAAC,EAAE;IACJ,CAAC;IACDsB,KAAK,EAAE7B,kBAAkB,KAAKE,iBAAiB;IAC/C4B,MAAM,EAAE;MAAEC,IAAI,EAAE,CAAC;MAAEC,OAAO,EAAE,IAAI;MAAEC,QAAQ,EAAE;IAAI,CAAC;IACjDC,SAAS,EAAEnC,oBAAoB;IAC/BuB;EACD,CAAE,CAAC;EAEH,OAAOxB,GAAG;AACX;AAEA,eAAeL,kBAAkB"}
1
+ {"version":3,"names":["useSpring","useState","useLayoutEffect","useReducer","useMemo","useRef","useReducedMotion","getScrollContainer","counterReducer","state","getAbsolutePosition","element","top","offsetTop","left","offsetLeft","useMovingAnimation","isSelected","adjustScrolling","enableAnimation","triggerAnimationOnChange","ref","prefersReducedMotion","triggeredAnimation","triggerAnimation","finishedAnimation","endAnimation","transform","setTransform","x","y","previous","current","preserveScrollPosition","scrollContainer","prevRect","getBoundingClientRect","blockRect","diff","scrollTop","style","undefined","destination","Math","round","onChange","value","finishedMoving","transformOrigin","zIndex","from","to","reset","config","mass","tension","friction","immediate"],"sources":["@wordpress/block-editor/src/components/use-moving-animation/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { useSpring } from '@react-spring/web';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tuseLayoutEffect,\n\tuseReducer,\n\tuseMemo,\n\tuseRef,\n} from '@wordpress/element';\nimport { useReducedMotion } from '@wordpress/compose';\nimport { getScrollContainer } from '@wordpress/dom';\n\n/**\n * Simple reducer used to increment a counter.\n *\n * @param {number} state Previous counter value.\n * @return {number} New state value.\n */\nconst counterReducer = ( state ) => state + 1;\n\nconst getAbsolutePosition = ( element ) => {\n\treturn {\n\t\ttop: element.offsetTop,\n\t\tleft: element.offsetLeft,\n\t};\n};\n\n/**\n * Hook used to compute the styles required to move a div into a new position.\n *\n * The way this animation works is the following:\n * - It first renders the element as if there was no animation.\n * - It takes a snapshot of the position of the block to use it\n * as a destination point for the animation.\n * - It restores the element to the previous position using a CSS transform\n * - It uses the \"resetAnimation\" flag to reset the animation\n * from the beginning in order to animate to the new destination point.\n *\n * @param {Object} $1 Options\n * @param {boolean} $1.isSelected Whether it's the current block or not.\n * @param {boolean} $1.adjustScrolling Adjust the scroll position to the current block.\n * @param {boolean} $1.enableAnimation Enable/Disable animation.\n * @param {*} $1.triggerAnimationOnChange Variable used to trigger the animation if it changes.\n */\nfunction useMovingAnimation( {\n\tisSelected,\n\tadjustScrolling,\n\tenableAnimation,\n\ttriggerAnimationOnChange,\n} ) {\n\tconst ref = useRef();\n\tconst prefersReducedMotion = useReducedMotion() || ! enableAnimation;\n\tconst [ triggeredAnimation, triggerAnimation ] = useReducer(\n\t\tcounterReducer,\n\t\t0\n\t);\n\tconst [ finishedAnimation, endAnimation ] = useReducer( counterReducer, 0 );\n\tconst [ transform, setTransform ] = useState( { x: 0, y: 0 } );\n\tconst previous = useMemo(\n\t\t() => ( ref.current ? getAbsolutePosition( ref.current ) : null ),\n\t\t[ triggerAnimationOnChange ]\n\t);\n\n\t// Calculate the previous position of the block relative to the viewport and\n\t// return a function to maintain that position by scrolling.\n\tconst preserveScrollPosition = useMemo( () => {\n\t\tif ( ! adjustScrolling || ! ref.current ) {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst scrollContainer = getScrollContainer( ref.current );\n\n\t\tif ( ! scrollContainer ) {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst prevRect = ref.current.getBoundingClientRect();\n\t\treturn () => {\n\t\t\tconst blockRect = ref.current.getBoundingClientRect();\n\t\t\tconst diff = blockRect.top - prevRect.top;\n\n\t\t\tif ( diff ) {\n\t\t\t\tscrollContainer.scrollTop += diff;\n\t\t\t}\n\t\t};\n\t}, [ triggerAnimationOnChange, adjustScrolling ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( triggeredAnimation ) {\n\t\t\tendAnimation();\n\t\t}\n\t}, [ triggeredAnimation ] );\n\tuseLayoutEffect( () => {\n\t\tif ( ! previous ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( prefersReducedMotion ) {\n\t\t\t// If the animation is disabled and the scroll needs to be adjusted,\n\t\t\t// just move directly to the final scroll position.\n\t\t\tpreserveScrollPosition();\n\n\t\t\treturn;\n\t\t}\n\n\t\tref.current.style.transform = undefined;\n\t\tconst destination = getAbsolutePosition( ref.current );\n\n\t\ttriggerAnimation();\n\t\tsetTransform( {\n\t\t\tx: Math.round( previous.left - destination.left ),\n\t\t\ty: Math.round( previous.top - destination.top ),\n\t\t} );\n\t}, [ triggerAnimationOnChange ] );\n\n\tfunction onChange( { value } ) {\n\t\tif ( ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\t\tlet { x, y } = value;\n\t\tx = Math.round( x );\n\t\ty = Math.round( y );\n\t\tconst finishedMoving = x === 0 && y === 0;\n\t\tref.current.style.transformOrigin = 'center center';\n\t\tref.current.style.transform = finishedMoving\n\t\t\t? null // Set to `null` to explicitly remove the transform.\n\t\t\t: `translate3d(${ x }px,${ y }px,0)`;\n\t\tref.current.style.zIndex = isSelected ? '1' : '';\n\n\t\tpreserveScrollPosition();\n\t}\n\n\tuseSpring( {\n\t\tfrom: {\n\t\t\tx: transform.x,\n\t\t\ty: transform.y,\n\t\t},\n\t\tto: {\n\t\t\tx: 0,\n\t\t\ty: 0,\n\t\t},\n\t\treset: triggeredAnimation !== finishedAnimation,\n\t\tconfig: { mass: 5, tension: 2000, friction: 200 },\n\t\timmediate: prefersReducedMotion,\n\t\tonChange,\n\t} );\n\n\treturn ref;\n}\n\nexport default useMovingAnimation;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,mBAAmB;;AAE7C;AACA;AACA;AACA,SACCC,QAAQ,EACRC,eAAe,EACfC,UAAU,EACVC,OAAO,EACPC,MAAM,QACA,oBAAoB;AAC3B,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,kBAAkB,QAAQ,gBAAgB;;AAEnD;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,cAAc,GAAKC,KAAK,IAAMA,KAAK,GAAG,CAAC;AAE7C,MAAMC,mBAAmB,GAAKC,OAAO,IAAM;EAC1C,OAAO;IACNC,GAAG,EAAED,OAAO,CAACE,SAAS;IACtBC,IAAI,EAAEH,OAAO,CAACI;EACf,CAAC;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,kBAAkBA,CAAE;EAC5BC,UAAU;EACVC,eAAe;EACfC,eAAe;EACfC;AACD,CAAC,EAAG;EACH,MAAMC,GAAG,GAAGhB,MAAM,CAAC,CAAC;EACpB,MAAMiB,oBAAoB,GAAGhB,gBAAgB,CAAC,CAAC,IAAI,CAAEa,eAAe;EACpE,MAAM,CAAEI,kBAAkB,EAAEC,gBAAgB,CAAE,GAAGrB,UAAU,CAC1DK,cAAc,EACd,CACD,CAAC;EACD,MAAM,CAAEiB,iBAAiB,EAAEC,YAAY,CAAE,GAAGvB,UAAU,CAAEK,cAAc,EAAE,CAAE,CAAC;EAC3E,MAAM,CAAEmB,SAAS,EAAEC,YAAY,CAAE,GAAG3B,QAAQ,CAAE;IAAE4B,CAAC,EAAE,CAAC;IAAEC,CAAC,EAAE;EAAE,CAAE,CAAC;EAC9D,MAAMC,QAAQ,GAAG3B,OAAO,CACvB,MAAQiB,GAAG,CA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EC,OAAO,EAAE,IAAI;MAAEC,QAAQ,EAAE;IAAI,CAAC;IACjDC,SAAS,EAAEnC,oBAAoB;IAC/BuB;EACD,CAAE,CAAC;EAEH,OAAOxB,GAAG;AACX;AAEA,eAAeL,kBAAkB"}
@@ -195,7 +195,7 @@ export default function useOnBlockDrop(targetRootClientId, targetBlockIndex, opt
195
195
  } else {
196
196
  moveBlocksToPosition(sourceClientIds, sourceRootClientId, targetRootClientId, insertIndex);
197
197
  }
198
- }, [operation, getBlockOrder, getBlocksByClientId, insertBlocks, moveBlocksToPosition, removeBlocks, targetBlockIndex, targetRootClientId]);
198
+ }, [operation, getBlockOrder, getBlocksByClientId, moveBlocksToPosition, registry, removeBlocks, replaceBlocks, targetBlockIndex, targetRootClientId]);
199
199
  const _onDrop = onBlockDrop(targetRootClientId, targetBlockIndex, getBlockIndex, getClientIdsOfDescendants, moveBlocks, insertOrReplaceBlocks, clearSelectedBlock);
200
200
  const _onFilesDrop = onFilesDrop(targetRootClientId, targetBlockIndex, hasUploadPermissions, updateBlockAttributes, canInsertBlockType, insertOrReplaceBlocks);
201
201
  const _onHTMLDrop = onHTMLDrop(targetRootClientId, targetBlockIndex, insertOrReplaceBlocks);
@@ -1 +1 @@
1
- {"version":3,"names":["useCallback","cloneBlock","findTransform","getBlockTransforms","pasteHandler","useDispatch","useSelect","useRegistry","getFilesFromDataTransfer","store","blockEditorStore","parseDropEvent","event","result","srcRootClientId","srcClientIds","srcIndex","type","blocks","dataTransfer","Object","assign","JSON","parse","getData","err","onBlockDrop","targetRootClientId","targetBlockIndex","getBlockIndex","getClientIdsOfDescendants","moveBlocks","insertOrReplaceBlocks","clearSelectedBlock","sourceRootClientId","sourceClientIds","dropType","blocksToInsert","map","block","sourceBlockIndex","includes","some","id","isAtSameLevel","draggedBlockCount","length","insertIndex","onFilesDrop","hasUploadPermissions","updateBlockAttributes","canInsertBlockType","files","transformation","transform","blockName","isMatch","onHTMLDrop","HTML","mode","useOnBlockDrop","options","operation","select","getSettings","mediaUpload","getBlockOrder","getBlocksByClientId","insertBlocks","moveBlocksToPosition","replaceBlocks","removeBlocks","registry","updateSelection","initialPosition","clientIds","clientId","undefined","sourceBlocks","targetBlockClientIds","targetBlockClientId","batch","_onDrop","_onFilesDrop","_onHTMLDrop","html"],"sources":["@wordpress/block-editor/src/components/use-on-block-drop/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport {\n\tcloneBlock,\n\tfindTransform,\n\tgetBlockTransforms,\n\tpasteHandler,\n} from '@wordpress/blocks';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('react').SyntheticEvent} SyntheticEvent */\n/** @typedef {import('./types').WPDropOperation} WPDropOperation */\n\n/**\n * Retrieve the data for a block drop event.\n *\n * @param {SyntheticEvent} event The drop event.\n *\n * @return {Object} An object with block drag and drop data.\n */\nexport function parseDropEvent( event ) {\n\tlet result = {\n\t\tsrcRootClientId: null,\n\t\tsrcClientIds: null,\n\t\tsrcIndex: null,\n\t\ttype: null,\n\t\tblocks: null,\n\t};\n\n\tif ( ! event.dataTransfer ) {\n\t\treturn result;\n\t}\n\n\ttry {\n\t\tresult = Object.assign(\n\t\t\tresult,\n\t\t\tJSON.parse( event.dataTransfer.getData( 'wp-blocks' ) )\n\t\t);\n\t} catch ( err ) {\n\t\treturn result;\n\t}\n\n\treturn result;\n}\n\n/**\n * A function that returns an event handler function for block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Function} getBlockIndex A function that gets the index of a block.\n * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.\n * @param {Function} moveBlocks A function that moves blocks.\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n * @param {Function} clearSelectedBlock A function that clears block selection.\n * @return {Function} The event handler for a block drop event.\n */\nexport function onBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tgetBlockIndex,\n\tgetClientIdsOfDescendants,\n\tmoveBlocks,\n\tinsertOrReplaceBlocks,\n\tclearSelectedBlock\n) {\n\treturn ( event ) => {\n\t\tconst {\n\t\t\tsrcRootClientId: sourceRootClientId,\n\t\t\tsrcClientIds: sourceClientIds,\n\t\t\ttype: dropType,\n\t\t\tblocks,\n\t\t} = parseDropEvent( event );\n\n\t\t// If the user is inserting a block.\n\t\tif ( dropType === 'inserter' ) {\n\t\t\tclearSelectedBlock();\n\t\t\tconst blocksToInsert = blocks.map( ( block ) =>\n\t\t\t\tcloneBlock( block )\n\t\t\t);\n\t\t\tinsertOrReplaceBlocks( blocksToInsert, true, null );\n\t\t}\n\n\t\t// If the user is moving a block.\n\t\tif ( dropType === 'block' ) {\n\t\t\tconst sourceBlockIndex = getBlockIndex( sourceClientIds[ 0 ] );\n\n\t\t\t// If the user is dropping to the same position, return early.\n\t\t\tif (\n\t\t\t\tsourceRootClientId === targetRootClientId &&\n\t\t\t\tsourceBlockIndex === targetBlockIndex\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the user is attempting to drop a block within its own\n\t\t\t// nested blocks, return early as this would create infinite\n\t\t\t// recursion.\n\t\t\tif (\n\t\t\t\tsourceClientIds.includes( targetRootClientId ) ||\n\t\t\t\tgetClientIdsOfDescendants( sourceClientIds ).some(\n\t\t\t\t\t( id ) => id === targetRootClientId\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isAtSameLevel = sourceRootClientId === targetRootClientId;\n\t\t\tconst draggedBlockCount = sourceClientIds.length;\n\n\t\t\t// If the block is kept at the same level and moved downwards,\n\t\t\t// subtract to take into account that the blocks being dragged\n\t\t\t// were removed from the block list above the insertion point.\n\t\t\tconst insertIndex =\n\t\t\t\tisAtSameLevel && sourceBlockIndex < targetBlockIndex\n\t\t\t\t\t? targetBlockIndex - draggedBlockCount\n\t\t\t\t\t: targetBlockIndex;\n\n\t\t\tmoveBlocks( sourceClientIds, sourceRootClientId, insertIndex );\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related file drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {boolean} hasUploadPermissions Whether the user has upload permissions.\n * @param {Function} updateBlockAttributes A function that updates a block's attributes.\n * @param {Function} canInsertBlockType A function that returns checks whether a block type can be inserted.\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n *\n * @return {Function} The event handler for a block-related file drop event.\n */\nexport function onFilesDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\thasUploadPermissions,\n\tupdateBlockAttributes,\n\tcanInsertBlockType,\n\tinsertOrReplaceBlocks\n) {\n\treturn ( files ) => {\n\t\tif ( ! hasUploadPermissions ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst transformation = findTransform(\n\t\t\tgetBlockTransforms( 'from' ),\n\t\t\t( transform ) =>\n\t\t\t\ttransform.type === 'files' &&\n\t\t\t\tcanInsertBlockType( transform.blockName, targetRootClientId ) &&\n\t\t\t\ttransform.isMatch( files )\n\t\t);\n\n\t\tif ( transformation ) {\n\t\t\tconst blocks = transformation.transform(\n\t\t\t\tfiles,\n\t\t\t\tupdateBlockAttributes\n\t\t\t);\n\t\t\tinsertOrReplaceBlocks( blocks );\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related HTML drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n *\n * @return {Function} The event handler for a block-related HTML drop event.\n */\nexport function onHTMLDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tinsertOrReplaceBlocks\n) {\n\treturn ( HTML ) => {\n\t\tconst blocks = pasteHandler( { HTML, mode: 'BLOCKS' } );\n\n\t\tif ( blocks.length ) {\n\t\t\tinsertOrReplaceBlocks( blocks );\n\t\t}\n\t};\n}\n\n/**\n * A React hook for handling block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Object} options The optional options.\n * @param {WPDropOperation} [options.operation] The type of operation to perform on drop. Could be `insert` or `replace` for now.\n *\n * @return {Function} A function to be passed to the onDrop handler.\n */\nexport default function useOnBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\toptions = {}\n) {\n\tconst { operation = 'insert' } = options;\n\tconst hasUploadPermissions = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings().mediaUpload,\n\t\t[]\n\t);\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tgetBlockOrder,\n\t\tgetBlocksByClientId,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\tinsertBlocks,\n\t\tmoveBlocksToPosition,\n\t\tupdateBlockAttributes,\n\t\tclearSelectedBlock,\n\t\treplaceBlocks,\n\t\tremoveBlocks,\n\t} = useDispatch( blockEditorStore );\n\tconst registry = useRegistry();\n\n\tconst insertOrReplaceBlocks = useCallback(\n\t\t( blocks, updateSelection = true, initialPosition = 0 ) => {\n\t\t\tif ( operation === 'replace' ) {\n\t\t\t\tconst clientIds = getBlockOrder( targetRootClientId );\n\t\t\t\tconst clientId = clientIds[ targetBlockIndex ];\n\n\t\t\t\treplaceBlocks( clientId, blocks, undefined, initialPosition );\n\t\t\t} else {\n\t\t\t\tinsertBlocks(\n\t\t\t\t\tblocks,\n\t\t\t\t\ttargetBlockIndex,\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\tupdateSelection,\n\t\t\t\t\tinitialPosition\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\toperation,\n\t\t\tgetBlockOrder,\n\t\t\tinsertBlocks,\n\t\t\treplaceBlocks,\n\t\t\ttargetBlockIndex,\n\t\t\ttargetRootClientId,\n\t\t]\n\t);\n\n\tconst moveBlocks = useCallback(\n\t\t( sourceClientIds, sourceRootClientId, insertIndex ) => {\n\t\t\tif ( operation === 'replace' ) {\n\t\t\t\tconst sourceBlocks = getBlocksByClientId( sourceClientIds );\n\t\t\t\tconst targetBlockClientIds =\n\t\t\t\t\tgetBlockOrder( targetRootClientId );\n\t\t\t\tconst targetBlockClientId =\n\t\t\t\t\ttargetBlockClientIds[ targetBlockIndex ];\n\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t// Remove the source blocks.\n\t\t\t\t\tremoveBlocks( sourceClientIds, false );\n\t\t\t\t\t// Replace the target block with the source blocks.\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\ttargetBlockClientId,\n\t\t\t\t\t\tsourceBlocks,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t0\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\tsourceClientIds,\n\t\t\t\t\tsourceRootClientId,\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\tinsertIndex\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\toperation,\n\t\t\tgetBlockOrder,\n\t\t\tgetBlocksByClientId,\n\t\t\tinsertBlocks,\n\t\t\tmoveBlocksToPosition,\n\t\t\tremoveBlocks,\n\t\t\ttargetBlockIndex,\n\t\t\ttargetRootClientId,\n\t\t]\n\t);\n\n\tconst _onDrop = onBlockDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tmoveBlocks,\n\t\tinsertOrReplaceBlocks,\n\t\tclearSelectedBlock\n\t);\n\tconst _onFilesDrop = onFilesDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\thasUploadPermissions,\n\t\tupdateBlockAttributes,\n\t\tcanInsertBlockType,\n\t\tinsertOrReplaceBlocks\n\t);\n\tconst _onHTMLDrop = onHTMLDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tinsertOrReplaceBlocks\n\t);\n\n\treturn ( event ) => {\n\t\tconst files = getFilesFromDataTransfer( event.dataTransfer );\n\t\tconst html = event.dataTransfer.getData( 'text/html' );\n\n\t\t/**\n\t\t * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.\n\t\t * The order of the checks is important to recognise the HTML drop.\n\t\t */\n\t\tif ( html ) {\n\t\t\t_onHTMLDrop( html );\n\t\t} else if ( files.length ) {\n\t\t\t_onFilesDrop( files );\n\t\t} else {\n\t\t\t_onDrop( event );\n\t\t}\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,QAAQ,oBAAoB;AAChD,SACCC,UAAU,EACVC,aAAa,EACbC,kBAAkB,EAClBC,YAAY,QACN,mBAAmB;AAC1B,SAASC,WAAW,EAAEC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACrE,SAASC,wBAAwB,QAAQ,gBAAgB;;AAEzD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;;AAEvD;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAAEC,KAAK,EAAG;EACvC,IAAIC,MAAM,GAAG;IACZC,eAAe,EAAE,IAAI;IACrBC,YAAY,EAAE,IAAI;IAClBC,QAAQ,EAAE,IAAI;IACdC,IAAI,EAAE,IAAI;IACVC,MAAM,EAAE;EACT,CAAC;EAED,IAAK,CAAEN,KAAK,CAACO,YAAY,EAAG;IAC3B,OAAON,MAAM;EACd;EAEA,IAAI;IACHA,MAAM,GAAGO,MAAM,CAACC,MAAM,CACrBR,MAAM,EACNS,IAAI,CAACC,KAAK,CAAEX,KAAK,CAACO,YAAY,CAACK,O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AEtD;AACF;AACA;AACA;IACE,IAAK6D,IAAI,EAAG;MACXD,WAAW,CAAEC,IAAK,CAAC;IACpB,CAAC,MAAM,IAAKjC,KAAK,CAACN,MAAM,EAAG;MAC1BqC,YAAY,CAAE/B,KAAM,CAAC;IACtB,CAAC,MAAM;MACN8B,OAAO,CAAEtE,KAAM,CAAC;IACjB;EACD,CAAC;AACF"}
1
+ {"version":3,"names":["useCallback","cloneBlock","findTransform","getBlockTransforms","pasteHandler","useDispatch","useSelect","useRegistry","getFilesFromDataTransfer","store","blockEditorStore","parseDropEvent","event","result","srcRootClientId","srcClientIds","srcIndex","type","blocks","dataTransfer","Object","assign","JSON","parse","getData","err","onBlockDrop","targetRootClientId","targetBlockIndex","getBlockIndex","getClientIdsOfDescendants","moveBlocks","insertOrReplaceBlocks","clearSelectedBlock","sourceRootClientId","sourceClientIds","dropType","blocksToInsert","map","block","sourceBlockIndex","includes","some","id","isAtSameLevel","draggedBlockCount","length","insertIndex","onFilesDrop","hasUploadPermissions","updateBlockAttributes","canInsertBlockType","files","transformation","transform","blockName","isMatch","onHTMLDrop","HTML","mode","useOnBlockDrop","options","operation","select","getSettings","mediaUpload","getBlockOrder","getBlocksByClientId","insertBlocks","moveBlocksToPosition","replaceBlocks","removeBlocks","registry","updateSelection","initialPosition","clientIds","clientId","undefined","sourceBlocks","targetBlockClientIds","targetBlockClientId","batch","_onDrop","_onFilesDrop","_onHTMLDrop","html"],"sources":["@wordpress/block-editor/src/components/use-on-block-drop/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport {\n\tcloneBlock,\n\tfindTransform,\n\tgetBlockTransforms,\n\tpasteHandler,\n} from '@wordpress/blocks';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('react').SyntheticEvent} SyntheticEvent */\n/** @typedef {import('./types').WPDropOperation} WPDropOperation */\n\n/**\n * Retrieve the data for a block drop event.\n *\n * @param {SyntheticEvent} event The drop event.\n *\n * @return {Object} An object with block drag and drop data.\n */\nexport function parseDropEvent( event ) {\n\tlet result = {\n\t\tsrcRootClientId: null,\n\t\tsrcClientIds: null,\n\t\tsrcIndex: null,\n\t\ttype: null,\n\t\tblocks: null,\n\t};\n\n\tif ( ! event.dataTransfer ) {\n\t\treturn result;\n\t}\n\n\ttry {\n\t\tresult = Object.assign(\n\t\t\tresult,\n\t\t\tJSON.parse( event.dataTransfer.getData( 'wp-blocks' ) )\n\t\t);\n\t} catch ( err ) {\n\t\treturn result;\n\t}\n\n\treturn result;\n}\n\n/**\n * A function that returns an event handler function for block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Function} getBlockIndex A function that gets the index of a block.\n * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.\n * @param {Function} moveBlocks A function that moves blocks.\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n * @param {Function} clearSelectedBlock A function that clears block selection.\n * @return {Function} The event handler for a block drop event.\n */\nexport function onBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tgetBlockIndex,\n\tgetClientIdsOfDescendants,\n\tmoveBlocks,\n\tinsertOrReplaceBlocks,\n\tclearSelectedBlock\n) {\n\treturn ( event ) => {\n\t\tconst {\n\t\t\tsrcRootClientId: sourceRootClientId,\n\t\t\tsrcClientIds: sourceClientIds,\n\t\t\ttype: dropType,\n\t\t\tblocks,\n\t\t} = parseDropEvent( event );\n\n\t\t// If the user is inserting a block.\n\t\tif ( dropType === 'inserter' ) {\n\t\t\tclearSelectedBlock();\n\t\t\tconst blocksToInsert = blocks.map( ( block ) =>\n\t\t\t\tcloneBlock( block )\n\t\t\t);\n\t\t\tinsertOrReplaceBlocks( blocksToInsert, true, null );\n\t\t}\n\n\t\t// If the user is moving a block.\n\t\tif ( dropType === 'block' ) {\n\t\t\tconst sourceBlockIndex = getBlockIndex( sourceClientIds[ 0 ] );\n\n\t\t\t// If the user is dropping to the same position, return early.\n\t\t\tif (\n\t\t\t\tsourceRootClientId === targetRootClientId &&\n\t\t\t\tsourceBlockIndex === targetBlockIndex\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the user is attempting to drop a block within its own\n\t\t\t// nested blocks, return early as this would create infinite\n\t\t\t// recursion.\n\t\t\tif (\n\t\t\t\tsourceClientIds.includes( targetRootClientId ) ||\n\t\t\t\tgetClientIdsOfDescendants( sourceClientIds ).some(\n\t\t\t\t\t( id ) => id === targetRootClientId\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isAtSameLevel = sourceRootClientId === targetRootClientId;\n\t\t\tconst draggedBlockCount = sourceClientIds.length;\n\n\t\t\t// If the block is kept at the same level and moved downwards,\n\t\t\t// subtract to take into account that the blocks being dragged\n\t\t\t// were removed from the block list above the insertion point.\n\t\t\tconst insertIndex =\n\t\t\t\tisAtSameLevel && sourceBlockIndex < targetBlockIndex\n\t\t\t\t\t? targetBlockIndex - draggedBlockCount\n\t\t\t\t\t: targetBlockIndex;\n\n\t\t\tmoveBlocks( sourceClientIds, sourceRootClientId, insertIndex );\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related file drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {boolean} hasUploadPermissions Whether the user has upload permissions.\n * @param {Function} updateBlockAttributes A function that updates a block's attributes.\n * @param {Function} canInsertBlockType A function that returns checks whether a block type can be inserted.\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n *\n * @return {Function} The event handler for a block-related file drop event.\n */\nexport function onFilesDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\thasUploadPermissions,\n\tupdateBlockAttributes,\n\tcanInsertBlockType,\n\tinsertOrReplaceBlocks\n) {\n\treturn ( files ) => {\n\t\tif ( ! hasUploadPermissions ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst transformation = findTransform(\n\t\t\tgetBlockTransforms( 'from' ),\n\t\t\t( transform ) =>\n\t\t\t\ttransform.type === 'files' &&\n\t\t\t\tcanInsertBlockType( transform.blockName, targetRootClientId ) &&\n\t\t\t\ttransform.isMatch( files )\n\t\t);\n\n\t\tif ( transformation ) {\n\t\t\tconst blocks = transformation.transform(\n\t\t\t\tfiles,\n\t\t\t\tupdateBlockAttributes\n\t\t\t);\n\t\t\tinsertOrReplaceBlocks( blocks );\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related HTML drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n *\n * @return {Function} The event handler for a block-related HTML drop event.\n */\nexport function onHTMLDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tinsertOrReplaceBlocks\n) {\n\treturn ( HTML ) => {\n\t\tconst blocks = pasteHandler( { HTML, mode: 'BLOCKS' } );\n\n\t\tif ( blocks.length ) {\n\t\t\tinsertOrReplaceBlocks( blocks );\n\t\t}\n\t};\n}\n\n/**\n * A React hook for handling block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Object} options The optional options.\n * @param {WPDropOperation} [options.operation] The type of operation to perform on drop. Could be `insert` or `replace` for now.\n *\n * @return {Function} A function to be passed to the onDrop handler.\n */\nexport default function useOnBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\toptions = {}\n) {\n\tconst { operation = 'insert' } = options;\n\tconst hasUploadPermissions = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings().mediaUpload,\n\t\t[]\n\t);\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tgetBlockOrder,\n\t\tgetBlocksByClientId,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\tinsertBlocks,\n\t\tmoveBlocksToPosition,\n\t\tupdateBlockAttributes,\n\t\tclearSelectedBlock,\n\t\treplaceBlocks,\n\t\tremoveBlocks,\n\t} = useDispatch( blockEditorStore );\n\tconst registry = useRegistry();\n\n\tconst insertOrReplaceBlocks = useCallback(\n\t\t( blocks, updateSelection = true, initialPosition = 0 ) => {\n\t\t\tif ( operation === 'replace' ) {\n\t\t\t\tconst clientIds = getBlockOrder( targetRootClientId );\n\t\t\t\tconst clientId = clientIds[ targetBlockIndex ];\n\n\t\t\t\treplaceBlocks( clientId, blocks, undefined, initialPosition );\n\t\t\t} else {\n\t\t\t\tinsertBlocks(\n\t\t\t\t\tblocks,\n\t\t\t\t\ttargetBlockIndex,\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\tupdateSelection,\n\t\t\t\t\tinitialPosition\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\toperation,\n\t\t\tgetBlockOrder,\n\t\t\tinsertBlocks,\n\t\t\treplaceBlocks,\n\t\t\ttargetBlockIndex,\n\t\t\ttargetRootClientId,\n\t\t]\n\t);\n\n\tconst moveBlocks = useCallback(\n\t\t( sourceClientIds, sourceRootClientId, insertIndex ) => {\n\t\t\tif ( operation === 'replace' ) {\n\t\t\t\tconst sourceBlocks = getBlocksByClientId( sourceClientIds );\n\t\t\t\tconst targetBlockClientIds =\n\t\t\t\t\tgetBlockOrder( targetRootClientId );\n\t\t\t\tconst targetBlockClientId =\n\t\t\t\t\ttargetBlockClientIds[ targetBlockIndex ];\n\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t// Remove the source blocks.\n\t\t\t\t\tremoveBlocks( sourceClientIds, false );\n\t\t\t\t\t// Replace the target block with the source blocks.\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\ttargetBlockClientId,\n\t\t\t\t\t\tsourceBlocks,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t0\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\tsourceClientIds,\n\t\t\t\t\tsourceRootClientId,\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\tinsertIndex\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\toperation,\n\t\t\tgetBlockOrder,\n\t\t\tgetBlocksByClientId,\n\t\t\tmoveBlocksToPosition,\n\t\t\tregistry,\n\t\t\tremoveBlocks,\n\t\t\treplaceBlocks,\n\t\t\ttargetBlockIndex,\n\t\t\ttargetRootClientId,\n\t\t]\n\t);\n\n\tconst _onDrop = onBlockDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tmoveBlocks,\n\t\tinsertOrReplaceBlocks,\n\t\tclearSelectedBlock\n\t);\n\tconst _onFilesDrop = onFilesDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\thasUploadPermissions,\n\t\tupdateBlockAttributes,\n\t\tcanInsertBlockType,\n\t\tinsertOrReplaceBlocks\n\t);\n\tconst _onHTMLDrop = onHTMLDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tinsertOrReplaceBlocks\n\t);\n\n\treturn ( event ) => {\n\t\tconst files = getFilesFromDataTransfer( event.dataTransfer );\n\t\tconst html = event.dataTransfer.getData( 'text/html' );\n\n\t\t/**\n\t\t * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.\n\t\t * The order of the checks is important to recognise the HTML drop.\n\t\t */\n\t\tif ( html ) {\n\t\t\t_onHTMLDrop( html );\n\t\t} else if ( files.length ) {\n\t\t\t_onFilesDrop( files );\n\t\t} else {\n\t\t\t_onDrop( event );\n\t\t}\n\t};\n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kBAAkB,EAClBP,kBAAkB,EAClBoB,WACD,CAAC;IACF;EACD,CAAC,EACD,CACCe,SAAS,EACTI,aAAa,EACbC,mBAAmB,EACnBE,oBAAoB,EACpBG,QAAQ,EACRD,YAAY,EACZD,aAAa,EACb1C,gBAAgB,EAChBD,kBAAkB,CAEpB,CAAC;EAED,MAAMuD,OAAO,GAAGxD,WAAW,CAC1BC,kBAAkB,EAClBC,gBAAgB,EAChBC,aAAa,EACbC,yBAAyB,EACzBC,UAAU,EACVC,qBAAqB,EACrBC,kBACD,CAAC;EACD,MAAMkD,YAAY,GAAGnC,WAAW,CAC/BrB,kBAAkB,EAClBC,gBAAgB,EAChBqB,oBAAoB,EACpBC,qBAAqB,EACrBC,kBAAkB,EAClBnB,qBACD,CAAC;EACD,MAAMoD,WAAW,GAAG3B,UAAU,CAC7B9B,kBAAkB,EAClBC,gBAAgB,EAChBI,qBACD,CAAC;EAED,OAASpB,KAAK,IAAM;IACnB,MAAMwC,KAAK,GAAG5C,wBAAwB,CAAEI,KAAK,CAACO,YAAa,CAAC;IAC5D,MAAMkE,IAAI,GAAGzE,KAAK,CAACO,YAAY,CAACK,OAAO,CAAE,WAAY,CAAC;;IAEtD;AACF;AACA;AACA;IACE,IAAK6D,IAAI,EAAG;MACXD,WAAW,CAAEC,IAAK,CAAC;IACpB,CAAC,MAAM,IAAKjC,KAAK,CAACN,MAAM,EAAG;MAC1BqC,YAAY,CAAE/B,KAAM,CAAC;IACtB,CAAC,MAAM;MACN8B,OAAO,CAAEtE,KAAM,CAAC;IACjB;EACD,CAAC;AACF"}
@@ -58,7 +58,10 @@ export default function useResizeCanvas(deviceType) {
58
58
  overflowY: 'auto'
59
59
  };
60
60
  default:
61
- return null;
61
+ return {
62
+ marginLeft: marginHorizontal,
63
+ marginRight: marginHorizontal
64
+ };
62
65
  }
63
66
  };
64
67
  return contentInlineStyles(deviceType);
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useState","useResizeCanvas","deviceType","actualWidth","updateActualWidth","window","innerWidth","resizeListener","addEventListener","removeEventListener","getCanvasWidth","device","deviceWidth","marginValue","innerHeight","contentInlineStyles","height","marginVertical","marginHorizontal","width","marginTop","marginBottom","marginLeft","marginRight","borderRadius","border","overflowY"],"sources":["@wordpress/block-editor/src/components/use-resize-canvas/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState } from '@wordpress/element';\n\n/**\n * Function to resize the editor window.\n *\n * @param {string} deviceType Used for determining the size of the container (e.g. Desktop, Tablet, Mobile)\n *\n * @return {Object} Inline styles to be added to resizable container.\n */\nexport default function useResizeCanvas( deviceType ) {\n\tconst [ actualWidth, updateActualWidth ] = useState( window.innerWidth );\n\n\tuseEffect( () => {\n\t\tif ( deviceType === 'Desktop' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst resizeListener = () => updateActualWidth( window.innerWidth );\n\t\twindow.addEventListener( 'resize', resizeListener );\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener( 'resize', resizeListener );\n\t\t};\n\t}, [ deviceType ] );\n\n\tconst getCanvasWidth = ( device ) => {\n\t\tlet deviceWidth;\n\n\t\tswitch ( device ) {\n\t\t\tcase 'Tablet':\n\t\t\t\tdeviceWidth = 780;\n\t\t\t\tbreak;\n\t\t\tcase 'Mobile':\n\t\t\t\tdeviceWidth = 360;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\treturn null;\n\t\t}\n\n\t\treturn deviceWidth < actualWidth ? deviceWidth : actualWidth;\n\t};\n\n\tconst marginValue = () => ( window.innerHeight < 800 ? 36 : 72 );\n\n\tconst contentInlineStyles = ( device ) => {\n\t\tconst height = device === 'Mobile' ? '768px' : '1024px';\n\t\tconst marginVertical = marginValue() + 'px';\n\t\tconst marginHorizontal = 'auto';\n\n\t\tswitch ( device ) {\n\t\t\tcase 'Tablet':\n\t\t\tcase 'Mobile':\n\t\t\t\treturn {\n\t\t\t\t\twidth: getCanvasWidth( device ),\n\t\t\t\t\t// Keeping margin styles separate to avoid warnings\n\t\t\t\t\t// when those props get overridden in the iframe component\n\t\t\t\t\tmarginTop: marginVertical,\n\t\t\t\t\tmarginBottom: marginVertical,\n\t\t\t\t\tmarginLeft: marginHorizontal,\n\t\t\t\t\tmarginRight: marginHorizontal,\n\t\t\t\t\theight,\n\t\t\t\t\tborderRadius: '2px 2px 2px 2px',\n\t\t\t\t\tborder: '1px solid #ddd',\n\t\t\t\t\toverflowY: 'auto',\n\t\t\t\t};\n\t\t\tdefault:\n\t\t\t\treturn null;\n\t\t}\n\t};\n\n\treturn contentInlineStyles( deviceType );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,oBAAoB;;AAExD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,eAAeA,CAAEC,UAAU,EAAG;EACrD,MAAM,CAAEC,WAAW,EAAEC,iBAAiB,CAAE,GAAGJ,QAAQ,CAAEK,MAAM,CAACC,UAAW,CAAC;EAExEP,SAAS,CAAE,MAAM;IAChB,IAAKG,UAAU,KAAK,SAAS,EAAG;MAC/B;IACD;IAEA,MAAMK,cAAc,GAAGA,CAAA,KAAMH,iBAAiB,CAAEC,MAAM,CAACC,UAAW,CAAC;IACnED,MAAM,CAACG,gBAAgB,CAAE,QAAQ,EAAED,cAAe,CAAC;IAEnD,OAAO,MAAM;MACZF,MAAM,CAACI,mBAAmB,CAAE,QAAQ,EAAEF,cAAe,CAAC;IACvD,CAAC;EACF,CAAC,EAAE,CAAEL,UAAU,CAAG,CAAC;EAEnB,MAAMQ,cAAc,GAAKC,MAAM,IAAM;IACpC,IAAIC,WAAW;IAEf,QAASD,MAAM;MACd,KAAK,QAAQ;QACZC,WAAW,GAAG,GAAG;QACjB;MACD,KAAK,QAAQ;QACZA,WAAW,GAAG,GAAG;QACjB;MACD;QACC,OAAO,IAAI;IACb;IAEA,OAAOA,WAAW,GAAGT,WAAW,GAAGS,WAAW,GAAGT,WAAW;EAC7D,CAAC;EAED,MAAMU,WAAW,GAAGA,CAAA,KAAQR,MAAM,CAACS,WAAW,GAAG,GAAG,GAAG,EAAE,GAAG,EAAI;EAEhE,MAAMC,mBAAmB,GAAKJ,MAAM,IAAM;IACzC,MAAMK,MAAM,GAAGL,MAAM,KAAK,QAAQ,GAAG,OAAO,GAAG,QAAQ;IACvD,MAAMM,cAAc,GAAGJ,WAAW,CAAC,CAAC,GAAG,IAAI;IAC3C,MAAMK,gBAAgB,GAAG,MAAM;IAE/B,QAASP,MAAM;MACd,KAAK,QAAQ;MACb,KAAK,QAAQ;QACZ,OAAO;UACNQ,KAAK,EAAET,cAAc,CAAEC,MAAO,CAAC;UAC/B;UACA;UACAS,SAAS,EAAEH,cAAc;UACzBI,YAAY,EAAEJ,cAAc;UAC5BK,UAAU,EAAEJ,gBAAgB;UAC5BK,WAAW,EAAEL,gBAAgB;UAC7BF,MAAM;UACNQ,YAAY,EAAE,iBAAiB;UAC/BC,MAAM,EAAE,gBAAgB;UACxBC,SAAS,EAAE;QACZ,CAAC;MACF;QACC,OAAO,IAAI;IACb;EACD,CAAC;EAED,OAAOX,mBAAmB,CAAEb,UAAW,CAAC;AACzC"}
1
+ {"version":3,"names":["useEffect","useState","useResizeCanvas","deviceType","actualWidth","updateActualWidth","window","innerWidth","resizeListener","addEventListener","removeEventListener","getCanvasWidth","device","deviceWidth","marginValue","innerHeight","contentInlineStyles","height","marginVertical","marginHorizontal","width","marginTop","marginBottom","marginLeft","marginRight","borderRadius","border","overflowY"],"sources":["@wordpress/block-editor/src/components/use-resize-canvas/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState } from '@wordpress/element';\n\n/**\n * Function to resize the editor window.\n *\n * @param {string} deviceType Used for determining the size of the container (e.g. Desktop, Tablet, Mobile)\n *\n * @return {Object} Inline styles to be added to resizable container.\n */\nexport default function useResizeCanvas( deviceType ) {\n\tconst [ actualWidth, updateActualWidth ] = useState( window.innerWidth );\n\n\tuseEffect( () => {\n\t\tif ( deviceType === 'Desktop' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst resizeListener = () => updateActualWidth( window.innerWidth );\n\t\twindow.addEventListener( 'resize', resizeListener );\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener( 'resize', resizeListener );\n\t\t};\n\t}, [ deviceType ] );\n\n\tconst getCanvasWidth = ( device ) => {\n\t\tlet deviceWidth;\n\n\t\tswitch ( device ) {\n\t\t\tcase 'Tablet':\n\t\t\t\tdeviceWidth = 780;\n\t\t\t\tbreak;\n\t\t\tcase 'Mobile':\n\t\t\t\tdeviceWidth = 360;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\treturn null;\n\t\t}\n\n\t\treturn deviceWidth < actualWidth ? deviceWidth : actualWidth;\n\t};\n\n\tconst marginValue = () => ( window.innerHeight < 800 ? 36 : 72 );\n\n\tconst contentInlineStyles = ( device ) => {\n\t\tconst height = device === 'Mobile' ? '768px' : '1024px';\n\t\tconst marginVertical = marginValue() + 'px';\n\t\tconst marginHorizontal = 'auto';\n\n\t\tswitch ( device ) {\n\t\t\tcase 'Tablet':\n\t\t\tcase 'Mobile':\n\t\t\t\treturn {\n\t\t\t\t\twidth: getCanvasWidth( device ),\n\t\t\t\t\t// Keeping margin styles separate to avoid warnings\n\t\t\t\t\t// when those props get overridden in the iframe component\n\t\t\t\t\tmarginTop: marginVertical,\n\t\t\t\t\tmarginBottom: marginVertical,\n\t\t\t\t\tmarginLeft: marginHorizontal,\n\t\t\t\t\tmarginRight: marginHorizontal,\n\t\t\t\t\theight,\n\t\t\t\t\tborderRadius: '2px 2px 2px 2px',\n\t\t\t\t\tborder: '1px solid #ddd',\n\t\t\t\t\toverflowY: 'auto',\n\t\t\t\t};\n\t\t\tdefault:\n\t\t\t\treturn {\n\t\t\t\t\tmarginLeft: marginHorizontal,\n\t\t\t\t\tmarginRight: marginHorizontal,\n\t\t\t\t};\n\t\t}\n\t};\n\n\treturn contentInlineStyles( deviceType );\n}\n"],"mappings":"AAAA;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,cAAc,CAAEC,MAAO,CAAC;UAC/B;UACA;UACAS,SAAS,EAAEH,cAAc;UACzBI,YAAY,EAAEJ,cAAc;UAC5BK,UAAU,EAAEJ,gBAAgB;UAC5BK,WAAW,EAAEL,gBAAgB;UAC7BF,MAAM;UACNQ,YAAY,EAAE,iBAAiB;UAC/BC,MAAM,EAAE,gBAAgB;UACxBC,SAAS,EAAE;QACZ,CAAC;MACF;QACC,OAAO;UACNJ,UAAU,EAAEJ,gBAAgB;UAC5BK,WAAW,EAAEL;QACd,CAAC;IACH;EACD,CAAC;EAED,OAAOH,mBAAmB,CAAEb,UAAW,CAAC;AACzC"}
@@ -80,7 +80,7 @@ const removeCustomPrefixes = path => {
80
80
  * @param {Object} value Object to merge
81
81
  * @return {Array} Array of merged items
82
82
  */
83
- function mergeOrigins(value) {
83
+ export function mergeOrigins(value) {
84
84
  let result = mergeCache.get(value);
85
85
  if (!result) {
86
86
  result = ['default', 'theme', 'custom'].flatMap(key => {
@@ -93,6 +93,18 @@ function mergeOrigins(value) {
93
93
  }
94
94
  const mergeCache = new WeakMap();
95
95
 
96
+ /**
97
+ * For settings like `color.palette`, which have a value that is an object
98
+ * with `default`, `theme`, `custom`, with field values that are arrays of
99
+ * items, see if any of the three origins have values.
100
+ *
101
+ * @param {Object} value Object to check
102
+ * @return {boolean} Whether the object has values in any of the three origins
103
+ */
104
+ export function hasMergedOrigins(value) {
105
+ return ['default', 'theme', 'custom'].some(key => value?.[key]?.length);
106
+ }
107
+
96
108
  /**
97
109
  * Hook that retrieves the given settings for the block instance in use.
98
110
  *
@@ -185,7 +197,7 @@ export function useSettings(...paths) {
185
197
  *
186
198
  * @param {string} path The path to the setting.
187
199
  * @return {any} Returns the value defined for the setting.
188
- * @deprecated 6.4.0 Use useSettings instead.
200
+ * @deprecated 6.5.0 Use useSettings instead.
189
201
  * @example
190
202
  * ```js
191
203
  * const isEnabled = useSetting( 'typography.dropCap' );
@@ -193,7 +205,7 @@ export function useSettings(...paths) {
193
205
  */
194
206
  export function useSetting(path) {
195
207
  deprecated('wp.blockEditor.useSetting', {
196
- since: '6.4',
208
+ since: '6.5',
197
209
  alternative: 'wp.blockEditor.useSettings',
198
210
  note: 'The new useSettings function can retrieve multiple settings at once, with better performance.'
199
211
  });