@wordpress/block-editor 10.4.0 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (638) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +0 -1
  3. package/build/autocompleters/block.js +2 -6
  4. package/build/autocompleters/block.js.map +1 -1
  5. package/build/autocompleters/link.js +2 -0
  6. package/build/autocompleters/link.js.map +1 -1
  7. package/build/components/block-card/index.js +51 -3
  8. package/build/components/block-card/index.js.map +1 -1
  9. package/build/components/block-draggable/index.native.js +46 -39
  10. package/build/components/block-draggable/index.native.js.map +1 -1
  11. package/build/components/block-edit/edit.js +4 -3
  12. package/build/components/block-edit/edit.js.map +1 -1
  13. package/build/components/block-edit/edit.native.js +4 -7
  14. package/build/components/block-edit/edit.native.js.map +1 -1
  15. package/build/components/block-inspector/index.js +35 -33
  16. package/build/components/block-inspector/index.js.map +1 -1
  17. package/build/components/block-list/block-list-context.native.js +5 -8
  18. package/build/components/block-list/block-list-context.native.js.map +1 -1
  19. package/build/components/block-list/block.js +55 -24
  20. package/build/components/block-list/block.js.map +1 -1
  21. package/build/components/block-list/block.native.js +61 -28
  22. package/build/components/block-list/block.native.js.map +1 -1
  23. package/build/components/block-lock/menu-item.js +1 -1
  24. package/build/components/block-lock/menu-item.js.map +1 -1
  25. package/build/components/block-lock/modal.js +16 -9
  26. package/build/components/block-lock/modal.js.map +1 -1
  27. package/build/components/block-mobile-toolbar/block-actions-menu.native.js +12 -4
  28. package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  29. package/build/components/block-pattern-setup/index.js +3 -2
  30. package/build/components/block-pattern-setup/index.js.map +1 -1
  31. package/build/components/block-patterns-list/index.js +33 -11
  32. package/build/components/block-patterns-list/index.js.map +1 -1
  33. package/build/components/block-preview/auto.js +9 -3
  34. package/build/components/block-preview/auto.js.map +1 -1
  35. package/build/components/block-preview/index.js +5 -9
  36. package/build/components/block-preview/index.js.map +1 -1
  37. package/build/components/block-settings-menu/block-settings-dropdown.js +5 -2
  38. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  39. package/build/components/block-styles/utils.js +3 -3
  40. package/build/components/block-styles/utils.js.map +1 -1
  41. package/build/components/block-switcher/index.js +19 -4
  42. package/build/components/block-switcher/index.js.map +1 -1
  43. package/build/components/block-toolbar/index.js +5 -1
  44. package/build/components/block-toolbar/index.js.map +1 -1
  45. package/build/components/block-tools/insertion-point.js +8 -49
  46. package/build/components/block-tools/insertion-point.js.map +1 -1
  47. package/build/components/block-tools/selected-block-popover.js +27 -4
  48. package/build/components/block-tools/selected-block-popover.js.map +1 -1
  49. package/build/components/block-variation-picker/index.js +1 -2
  50. package/build/components/block-variation-picker/index.js.map +1 -1
  51. package/build/components/colors/with-colors.js +4 -3
  52. package/build/components/colors/with-colors.js.map +1 -1
  53. package/build/components/font-sizes/fluid-utils.js +24 -40
  54. package/build/components/font-sizes/fluid-utils.js.map +1 -1
  55. package/build/components/font-sizes/with-font-sizes.js +7 -5
  56. package/build/components/font-sizes/with-font-sizes.js.map +1 -1
  57. package/build/components/height-control/index.js +115 -0
  58. package/build/components/height-control/index.js.map +1 -0
  59. package/build/components/iframe/index.js +11 -8
  60. package/build/components/iframe/index.js.map +1 -1
  61. package/build/components/image-editor/use-save-image.js +2 -0
  62. package/build/components/image-editor/use-save-image.js.map +1 -1
  63. package/build/components/image-editor/zoom-dropdown.js +1 -0
  64. package/build/components/image-editor/zoom-dropdown.js.map +1 -1
  65. package/build/components/index.js +18 -0
  66. package/build/components/index.js.map +1 -1
  67. package/build/components/inner-blocks/index.js +25 -9
  68. package/build/components/inner-blocks/index.js.map +1 -1
  69. package/build/components/inner-blocks/use-inner-block-template-sync.js +25 -10
  70. package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  71. package/build/components/inserter/block-patterns-explorer/sidebar.js +1 -0
  72. package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
  73. package/build/components/inserter/block-patterns-tab.js +25 -46
  74. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  75. package/build/components/inserter/block-types-tab.js +3 -1
  76. package/build/components/inserter/block-types-tab.js.map +1 -1
  77. package/build/components/inserter/hooks/use-debounced-input.js +27 -0
  78. package/build/components/inserter/hooks/use-debounced-input.js.map +1 -0
  79. package/build/components/inserter/index.js +8 -3
  80. package/build/components/inserter/index.js.map +1 -1
  81. package/build/components/inserter/index.native.js +3 -4
  82. package/build/components/inserter/index.native.js.map +1 -1
  83. package/build/components/inserter/media-tab/hooks.js +103 -0
  84. package/build/components/inserter/media-tab/hooks.js.map +1 -0
  85. package/build/components/inserter/media-tab/index.js +32 -0
  86. package/build/components/inserter/media-tab/index.js.map +1 -0
  87. package/build/components/inserter/media-tab/media-list.js +100 -0
  88. package/build/components/inserter/media-tab/media-list.js.map +1 -0
  89. package/build/components/inserter/media-tab/media-panel.js +96 -0
  90. package/build/components/inserter/media-tab/media-panel.js.map +1 -0
  91. package/build/components/inserter/media-tab/media-tab.js +120 -0
  92. package/build/components/inserter/media-tab/media-tab.js.map +1 -0
  93. package/build/components/inserter/media-tab/utils.js +54 -0
  94. package/build/components/inserter/media-tab/utils.js.map +1 -0
  95. package/build/components/inserter/menu.js +35 -12
  96. package/build/components/inserter/menu.js.map +1 -1
  97. package/build/components/inserter/mobile-tab-navigation.js +70 -0
  98. package/build/components/inserter/mobile-tab-navigation.js.map +1 -0
  99. package/build/components/inserter/quick-inserter.js +1 -0
  100. package/build/components/inserter/quick-inserter.js.map +1 -1
  101. package/build/components/inserter/reusable-blocks-tab.js +4 -1
  102. package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
  103. package/build/components/inserter/search-results.js +3 -1
  104. package/build/components/inserter/search-results.js.map +1 -1
  105. package/build/components/inserter/tabs.js +16 -2
  106. package/build/components/inserter/tabs.js.map +1 -1
  107. package/build/components/inserter-list-item/index.js +4 -1
  108. package/build/components/inserter-list-item/index.js.map +1 -1
  109. package/build/components/inspector-controls/groups.js +2 -0
  110. package/build/components/inspector-controls/groups.js.map +1 -1
  111. package/build/components/inspector-controls-tabs/advanced-controls-panel.js +46 -0
  112. package/build/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
  113. package/build/components/inspector-controls-tabs/index.js +71 -0
  114. package/build/components/inspector-controls-tabs/index.js.map +1 -0
  115. package/build/components/inspector-controls-tabs/settings-tab.js +28 -0
  116. package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -0
  117. package/build/components/inspector-controls-tabs/styles-tab.js +61 -0
  118. package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -0
  119. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +97 -0
  120. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
  121. package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +18 -0
  122. package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
  123. package/build/components/inspector-controls-tabs/utils.js +37 -0
  124. package/build/components/inspector-controls-tabs/utils.js.map +1 -0
  125. package/build/components/link-control/index.js +19 -34
  126. package/build/components/link-control/index.js.map +1 -1
  127. package/build/components/link-control/search-input.js +1 -2
  128. package/build/components/link-control/search-input.js.map +1 -1
  129. package/build/components/link-control/use-internal-input-value.js +26 -0
  130. package/build/components/link-control/use-internal-input-value.js.map +1 -0
  131. package/build/components/list-view/block.js +10 -5
  132. package/build/components/list-view/block.js.map +1 -1
  133. package/build/components/list-view/branch.js +22 -15
  134. package/build/components/list-view/branch.js.map +1 -1
  135. package/build/components/media-upload/index.native.js +2 -3
  136. package/build/components/media-upload/index.native.js.map +1 -1
  137. package/build/components/off-canvas-editor/appender.js +104 -0
  138. package/build/components/off-canvas-editor/appender.js.map +1 -0
  139. package/build/components/off-canvas-editor/block-contents.js +100 -0
  140. package/build/components/off-canvas-editor/block-contents.js.map +1 -0
  141. package/build/components/off-canvas-editor/block-edit-button.js +50 -0
  142. package/build/components/off-canvas-editor/block-edit-button.js.map +1 -0
  143. package/build/components/off-canvas-editor/block-select-button.js +119 -0
  144. package/build/components/off-canvas-editor/block-select-button.js.map +1 -0
  145. package/build/components/off-canvas-editor/block.js +324 -0
  146. package/build/components/off-canvas-editor/block.js.map +1 -0
  147. package/build/components/off-canvas-editor/branch.js +179 -0
  148. package/build/components/off-canvas-editor/branch.js.map +1 -0
  149. package/build/components/off-canvas-editor/context.js +19 -0
  150. package/build/components/off-canvas-editor/context.js.map +1 -0
  151. package/build/components/off-canvas-editor/drop-indicator.js +118 -0
  152. package/build/components/off-canvas-editor/drop-indicator.js.map +1 -0
  153. package/build/components/off-canvas-editor/expander.js +41 -0
  154. package/build/components/off-canvas-editor/expander.js.map +1 -0
  155. package/build/components/off-canvas-editor/index.js +213 -0
  156. package/build/components/off-canvas-editor/index.js.map +1 -0
  157. package/build/components/off-canvas-editor/leaf.js +60 -0
  158. package/build/components/off-canvas-editor/leaf.js.map +1 -0
  159. package/build/components/off-canvas-editor/link-ui.js +185 -0
  160. package/build/components/off-canvas-editor/link-ui.js.map +1 -0
  161. package/build/components/off-canvas-editor/update-attributes.js +108 -0
  162. package/build/components/off-canvas-editor/update-attributes.js.map +1 -0
  163. package/build/components/off-canvas-editor/use-block-selection.js +139 -0
  164. package/build/components/off-canvas-editor/use-block-selection.js.map +1 -0
  165. package/build/components/off-canvas-editor/use-list-view-client-ids.js +33 -0
  166. package/build/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
  167. package/build/components/off-canvas-editor/use-list-view-drop-zone.js +235 -0
  168. package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
  169. package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js +60 -0
  170. package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
  171. package/build/components/off-canvas-editor/utils.js +60 -0
  172. package/build/components/off-canvas-editor/utils.js.map +1 -0
  173. package/build/components/rich-text/format-toolbar/index.js +8 -4
  174. package/build/components/rich-text/format-toolbar/index.js.map +1 -1
  175. package/build/components/rich-text/index.js +3 -3
  176. package/build/components/rich-text/index.js.map +1 -1
  177. package/build/components/rich-text/index.native.js +0 -2
  178. package/build/components/rich-text/index.native.js.map +1 -1
  179. package/build/components/rich-text/use-insert-replacement-text.js +43 -0
  180. package/build/components/rich-text/use-insert-replacement-text.js.map +1 -0
  181. package/build/components/rich-text/use-undo-automatic-change.js +9 -1
  182. package/build/components/rich-text/use-undo-automatic-change.js.map +1 -1
  183. package/build/components/rich-text/utils.js +1 -19
  184. package/build/components/rich-text/utils.js.map +1 -1
  185. package/build/components/spacing-sizes-control/spacing-input-control.js +12 -3
  186. package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  187. package/build/components/ungroup-button/index.native.js +4 -2
  188. package/build/components/ungroup-button/index.native.js.map +1 -1
  189. package/build/components/url-input/index.js +46 -43
  190. package/build/components/url-input/index.js.map +1 -1
  191. package/build/components/url-popover/index.js +31 -2
  192. package/build/components/url-popover/index.js.map +1 -1
  193. package/build/components/use-block-display-information/index.js +8 -4
  194. package/build/components/use-block-display-information/index.js.map +1 -1
  195. package/build/components/use-setting/index.js +10 -2
  196. package/build/components/use-setting/index.js.map +1 -1
  197. package/build/hooks/child-layout.js +209 -0
  198. package/build/hooks/child-layout.js.map +1 -0
  199. package/build/hooks/color-panel.js +17 -1
  200. package/build/hooks/color-panel.js.map +1 -1
  201. package/build/hooks/color.js +1 -1
  202. package/build/hooks/color.js.map +1 -1
  203. package/build/hooks/content-lock-ui.js +14 -7
  204. package/build/hooks/content-lock-ui.js.map +1 -1
  205. package/build/hooks/dimensions.js +65 -16
  206. package/build/hooks/dimensions.js.map +1 -1
  207. package/build/hooks/layout.js +59 -3
  208. package/build/hooks/layout.js.map +1 -1
  209. package/build/hooks/margin.js +4 -2
  210. package/build/hooks/margin.js.map +1 -1
  211. package/build/hooks/min-height.js +139 -0
  212. package/build/hooks/min-height.js.map +1 -0
  213. package/build/hooks/padding.js +4 -2
  214. package/build/hooks/padding.js.map +1 -1
  215. package/build/hooks/style.js +3 -2
  216. package/build/hooks/style.js.map +1 -1
  217. package/build/layouts/flex.js +22 -21
  218. package/build/layouts/flex.js.map +1 -1
  219. package/build/store/actions.js +26 -0
  220. package/build/store/actions.js.map +1 -1
  221. package/build/store/reducer.js +420 -265
  222. package/build/store/reducer.js.map +1 -1
  223. package/build/store/selectors.js +73 -49
  224. package/build/store/selectors.js.map +1 -1
  225. package/build/utils/sorting.js +63 -0
  226. package/build/utils/sorting.js.map +1 -0
  227. package/build-module/autocompleters/block.js +2 -6
  228. package/build-module/autocompleters/block.js.map +1 -1
  229. package/build-module/autocompleters/link.js +2 -0
  230. package/build-module/autocompleters/link.js.map +1 -1
  231. package/build-module/components/block-card/index.js +45 -3
  232. package/build-module/components/block-card/index.js.map +1 -1
  233. package/build-module/components/block-draggable/index.native.js +40 -31
  234. package/build-module/components/block-draggable/index.native.js.map +1 -1
  235. package/build-module/components/block-edit/edit.js +4 -2
  236. package/build-module/components/block-edit/edit.js.map +1 -1
  237. package/build-module/components/block-edit/edit.native.js +4 -6
  238. package/build-module/components/block-edit/edit.native.js.map +1 -1
  239. package/build-module/components/block-inspector/index.js +32 -30
  240. package/build-module/components/block-inspector/index.js.map +1 -1
  241. package/build-module/components/block-list/block-list-context.native.js +5 -8
  242. package/build-module/components/block-list/block-list-context.native.js.map +1 -1
  243. package/build-module/components/block-list/block.js +55 -25
  244. package/build-module/components/block-list/block.js.map +1 -1
  245. package/build-module/components/block-list/block.native.js +61 -28
  246. package/build-module/components/block-list/block.native.js.map +1 -1
  247. package/build-module/components/block-lock/menu-item.js +2 -2
  248. package/build-module/components/block-lock/menu-item.js.map +1 -1
  249. package/build-module/components/block-lock/modal.js +17 -10
  250. package/build-module/components/block-lock/modal.js.map +1 -1
  251. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +13 -6
  252. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  253. package/build-module/components/block-pattern-setup/index.js +3 -2
  254. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  255. package/build-module/components/block-patterns-list/index.js +35 -13
  256. package/build-module/components/block-patterns-list/index.js.map +1 -1
  257. package/build-module/components/block-preview/auto.js +9 -3
  258. package/build-module/components/block-preview/auto.js.map +1 -1
  259. package/build-module/components/block-preview/index.js +5 -8
  260. package/build-module/components/block-preview/index.js.map +1 -1
  261. package/build-module/components/block-settings-menu/block-settings-dropdown.js +5 -2
  262. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  263. package/build-module/components/block-styles/utils.js +3 -3
  264. package/build-module/components/block-styles/utils.js.map +1 -1
  265. package/build-module/components/block-switcher/index.js +19 -4
  266. package/build-module/components/block-switcher/index.js.map +1 -1
  267. package/build-module/components/block-toolbar/index.js +6 -2
  268. package/build-module/components/block-toolbar/index.js.map +1 -1
  269. package/build-module/components/block-tools/insertion-point.js +8 -49
  270. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  271. package/build-module/components/block-tools/selected-block-popover.js +27 -5
  272. package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
  273. package/build-module/components/block-variation-picker/index.js +1 -2
  274. package/build-module/components/block-variation-picker/index.js.map +1 -1
  275. package/build-module/components/colors/with-colors.js +5 -4
  276. package/build-module/components/colors/with-colors.js.map +1 -1
  277. package/build-module/components/font-sizes/fluid-utils.js +24 -40
  278. package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
  279. package/build-module/components/font-sizes/with-font-sizes.js +8 -6
  280. package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
  281. package/build-module/components/height-control/index.js +103 -0
  282. package/build-module/components/height-control/index.js.map +1 -0
  283. package/build-module/components/iframe/index.js +11 -8
  284. package/build-module/components/iframe/index.js.map +1 -1
  285. package/build-module/components/image-editor/use-save-image.js +2 -0
  286. package/build-module/components/image-editor/use-save-image.js.map +1 -1
  287. package/build-module/components/image-editor/zoom-dropdown.js +1 -0
  288. package/build-module/components/image-editor/zoom-dropdown.js.map +1 -1
  289. package/build-module/components/index.js +2 -0
  290. package/build-module/components/index.js.map +1 -1
  291. package/build-module/components/inner-blocks/index.js +27 -11
  292. package/build-module/components/inner-blocks/index.js.map +1 -1
  293. package/build-module/components/inner-blocks/use-inner-block-template-sync.js +23 -10
  294. package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  295. package/build-module/components/inserter/block-patterns-explorer/sidebar.js +1 -0
  296. package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
  297. package/build-module/components/inserter/block-patterns-tab.js +27 -49
  298. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  299. package/build-module/components/inserter/block-types-tab.js +3 -2
  300. package/build-module/components/inserter/block-types-tab.js.map +1 -1
  301. package/build-module/components/inserter/hooks/use-debounced-input.js +18 -0
  302. package/build-module/components/inserter/hooks/use-debounced-input.js.map +1 -0
  303. package/build-module/components/inserter/index.js +8 -3
  304. package/build-module/components/inserter/index.js.map +1 -1
  305. package/build-module/components/inserter/index.native.js +3 -5
  306. package/build-module/components/inserter/index.native.js.map +1 -1
  307. package/build-module/components/inserter/media-tab/hooks.js +89 -0
  308. package/build-module/components/inserter/media-tab/hooks.js.map +1 -0
  309. package/build-module/components/inserter/media-tab/index.js +4 -0
  310. package/build-module/components/inserter/media-tab/index.js.map +1 -0
  311. package/build-module/components/inserter/media-tab/media-list.js +86 -0
  312. package/build-module/components/inserter/media-tab/media-list.js.map +1 -0
  313. package/build-module/components/inserter/media-tab/media-panel.js +77 -0
  314. package/build-module/components/inserter/media-tab/media-panel.js.map +1 -0
  315. package/build-module/components/inserter/media-tab/media-tab.js +100 -0
  316. package/build-module/components/inserter/media-tab/media-tab.js.map +1 -0
  317. package/build-module/components/inserter/media-tab/utils.js +45 -0
  318. package/build-module/components/inserter/media-tab/utils.js.map +1 -0
  319. package/build-module/components/inserter/menu.js +33 -12
  320. package/build-module/components/inserter/menu.js.map +1 -1
  321. package/build-module/components/inserter/mobile-tab-navigation.js +61 -0
  322. package/build-module/components/inserter/mobile-tab-navigation.js.map +1 -0
  323. package/build-module/components/inserter/quick-inserter.js +1 -0
  324. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  325. package/build-module/components/inserter/reusable-blocks-tab.js +3 -1
  326. package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
  327. package/build-module/components/inserter/search-results.js +3 -2
  328. package/build-module/components/inserter/search-results.js.map +1 -1
  329. package/build-module/components/inserter/tabs.js +15 -2
  330. package/build-module/components/inserter/tabs.js.map +1 -1
  331. package/build-module/components/inserter-list-item/index.js +5 -2
  332. package/build-module/components/inserter-list-item/index.js.map +1 -1
  333. package/build-module/components/inspector-controls/groups.js +2 -0
  334. package/build-module/components/inspector-controls/groups.js.map +1 -1
  335. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js +32 -0
  336. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
  337. package/build-module/components/inspector-controls-tabs/index.js +56 -0
  338. package/build-module/components/inspector-controls-tabs/index.js.map +1 -0
  339. package/build-module/components/inspector-controls-tabs/settings-tab.js +17 -0
  340. package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -0
  341. package/build-module/components/inspector-controls-tabs/styles-tab.js +46 -0
  342. package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -0
  343. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +81 -0
  344. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
  345. package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +8 -0
  346. package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
  347. package/build-module/components/inspector-controls-tabs/utils.js +26 -0
  348. package/build-module/components/inspector-controls-tabs/utils.js.map +1 -0
  349. package/build-module/components/link-control/index.js +18 -34
  350. package/build-module/components/link-control/index.js.map +1 -1
  351. package/build-module/components/link-control/search-input.js +1 -2
  352. package/build-module/components/link-control/search-input.js.map +1 -1
  353. package/build-module/components/link-control/use-internal-input-value.js +18 -0
  354. package/build-module/components/link-control/use-internal-input-value.js.map +1 -0
  355. package/build-module/components/list-view/block.js +10 -5
  356. package/build-module/components/list-view/block.js.map +1 -1
  357. package/build-module/components/list-view/branch.js +21 -14
  358. package/build-module/components/list-view/branch.js.map +1 -1
  359. package/build-module/components/media-upload/index.native.js +2 -4
  360. package/build-module/components/media-upload/index.native.js.map +1 -1
  361. package/build-module/components/off-canvas-editor/appender.js +89 -0
  362. package/build-module/components/off-canvas-editor/appender.js.map +1 -0
  363. package/build-module/components/off-canvas-editor/block-contents.js +85 -0
  364. package/build-module/components/off-canvas-editor/block-contents.js.map +1 -0
  365. package/build-module/components/off-canvas-editor/block-edit-button.js +35 -0
  366. package/build-module/components/off-canvas-editor/block-edit-button.js.map +1 -0
  367. package/build-module/components/off-canvas-editor/block-select-button.js +101 -0
  368. package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -0
  369. package/build-module/components/off-canvas-editor/block.js +298 -0
  370. package/build-module/components/off-canvas-editor/block.js.map +1 -0
  371. package/build-module/components/off-canvas-editor/branch.js +164 -0
  372. package/build-module/components/off-canvas-editor/branch.js.map +1 -0
  373. package/build-module/components/off-canvas-editor/context.js +7 -0
  374. package/build-module/components/off-canvas-editor/context.js.map +1 -0
  375. package/build-module/components/off-canvas-editor/drop-indicator.js +111 -0
  376. package/build-module/components/off-canvas-editor/drop-indicator.js.map +1 -0
  377. package/build-module/components/off-canvas-editor/expander.js +32 -0
  378. package/build-module/components/off-canvas-editor/expander.js.map +1 -0
  379. package/build-module/components/off-canvas-editor/index.js +189 -0
  380. package/build-module/components/off-canvas-editor/index.js.map +1 -0
  381. package/build-module/components/off-canvas-editor/leaf.js +45 -0
  382. package/build-module/components/off-canvas-editor/leaf.js.map +1 -0
  383. package/build-module/components/off-canvas-editor/link-ui.js +165 -0
  384. package/build-module/components/off-canvas-editor/link-ui.js.map +1 -0
  385. package/build-module/components/off-canvas-editor/update-attributes.js +97 -0
  386. package/build-module/components/off-canvas-editor/update-attributes.js.map +1 -0
  387. package/build-module/components/off-canvas-editor/use-block-selection.js +124 -0
  388. package/build-module/components/off-canvas-editor/use-block-selection.js.map +1 -0
  389. package/build-module/components/off-canvas-editor/use-list-view-client-ids.js +24 -0
  390. package/build-module/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
  391. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +220 -0
  392. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
  393. package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js +50 -0
  394. package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
  395. package/build-module/components/off-canvas-editor/utils.js +44 -0
  396. package/build-module/components/off-canvas-editor/utils.js.map +1 -0
  397. package/build-module/components/rich-text/format-toolbar/index.js +6 -2
  398. package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
  399. package/build-module/components/rich-text/index.js +2 -3
  400. package/build-module/components/rich-text/index.js.map +1 -1
  401. package/build-module/components/rich-text/index.native.js +0 -2
  402. package/build-module/components/rich-text/index.native.js.map +1 -1
  403. package/build-module/components/rich-text/use-insert-replacement-text.js +33 -0
  404. package/build-module/components/rich-text/use-insert-replacement-text.js.map +1 -0
  405. package/build-module/components/rich-text/use-undo-automatic-change.js +9 -1
  406. package/build-module/components/rich-text/use-undo-automatic-change.js.map +1 -1
  407. package/build-module/components/rich-text/utils.js +1 -16
  408. package/build-module/components/rich-text/utils.js.map +1 -1
  409. package/build-module/components/spacing-sizes-control/spacing-input-control.js +12 -3
  410. package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  411. package/build-module/components/ungroup-button/index.native.js +3 -2
  412. package/build-module/components/ungroup-button/index.native.js.map +1 -1
  413. package/build-module/components/url-input/index.js +46 -43
  414. package/build-module/components/url-input/index.js.map +1 -1
  415. package/build-module/components/url-popover/index.js +30 -3
  416. package/build-module/components/url-popover/index.js.map +1 -1
  417. package/build-module/components/use-block-display-information/index.js +9 -5
  418. package/build-module/components/use-block-display-information/index.js.map +1 -1
  419. package/build-module/components/use-setting/index.js +9 -2
  420. package/build-module/components/use-setting/index.js.map +1 -1
  421. package/build-module/hooks/child-layout.js +189 -0
  422. package/build-module/hooks/child-layout.js.map +1 -0
  423. package/build-module/hooks/color-panel.js +17 -1
  424. package/build-module/hooks/color-panel.js.map +1 -1
  425. package/build-module/hooks/color.js +1 -1
  426. package/build-module/hooks/color.js.map +1 -1
  427. package/build-module/hooks/content-lock-ui.js +16 -9
  428. package/build-module/hooks/content-lock-ui.js.map +1 -1
  429. package/build-module/hooks/dimensions.js +60 -16
  430. package/build-module/hooks/dimensions.js.map +1 -1
  431. package/build-module/hooks/layout.js +57 -2
  432. package/build-module/hooks/layout.js.map +1 -1
  433. package/build-module/hooks/margin.js +4 -2
  434. package/build-module/hooks/margin.js.map +1 -1
  435. package/build-module/hooks/min-height.js +116 -0
  436. package/build-module/hooks/min-height.js.map +1 -0
  437. package/build-module/hooks/padding.js +4 -2
  438. package/build-module/hooks/padding.js.map +1 -1
  439. package/build-module/hooks/style.js +4 -3
  440. package/build-module/hooks/style.js.map +1 -1
  441. package/build-module/layouts/flex.js +23 -22
  442. package/build-module/layouts/flex.js.map +1 -1
  443. package/build-module/store/actions.js +22 -0
  444. package/build-module/store/actions.js.map +1 -1
  445. package/build-module/store/reducer.js +415 -265
  446. package/build-module/store/reducer.js.map +1 -1
  447. package/build-module/store/selectors.js +66 -48
  448. package/build-module/store/selectors.js.map +1 -1
  449. package/build-module/utils/sorting.js +56 -0
  450. package/build-module/utils/sorting.js.map +1 -0
  451. package/build-style/content-rtl.css +701 -0
  452. package/build-style/content.css +701 -0
  453. package/build-style/default-editor-styles-rtl.css +14 -0
  454. package/build-style/default-editor-styles.css +14 -0
  455. package/build-style/style-rtl.css +305 -668
  456. package/build-style/style.css +305 -668
  457. package/package.json +32 -30
  458. package/src/autocompleters/block.js +2 -6
  459. package/src/autocompleters/link.js +2 -0
  460. package/src/components/alignment-control/README.md +1 -1
  461. package/src/components/alignment-control/test/index.js +4 -1
  462. package/src/components/block-alignment-control/test/index.js +4 -1
  463. package/src/components/block-alignment-control/test/index.native.js +4 -4
  464. package/src/components/block-card/index.js +46 -2
  465. package/src/components/block-card/style.scss +4 -0
  466. package/src/components/block-content-overlay/{style.scss → content.scss} +7 -1
  467. package/src/components/block-draggable/content.scss +20 -0
  468. package/src/components/block-draggable/index.native.js +54 -40
  469. package/src/components/block-draggable/style.scss +0 -21
  470. package/src/components/block-draggable/test/helpers.native.js +7 -9
  471. package/src/components/block-draggable/test/index.native.js +35 -45
  472. package/src/components/block-edit/edit.js +5 -2
  473. package/src/components/block-edit/edit.native.js +5 -6
  474. package/src/components/block-inspector/index.js +96 -81
  475. package/src/components/block-inspector/style.scss +9 -1
  476. package/src/components/block-list/block-list-context.native.js +5 -8
  477. package/src/components/block-list/block.js +74 -23
  478. package/src/components/block-list/block.native.js +78 -23
  479. package/src/components/block-list/{style.scss → content.scss} +11 -20
  480. package/src/components/block-list-appender/{style.scss → content.scss} +0 -0
  481. package/src/components/block-lock/menu-item.js +5 -2
  482. package/src/components/block-lock/modal.js +19 -36
  483. package/src/components/block-lock/style.scss +8 -17
  484. package/src/components/block-mobile-toolbar/block-actions-menu.native.js +24 -6
  485. package/src/components/block-mover/style.scss +0 -1
  486. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +0 -2
  487. package/src/components/block-pattern-setup/index.js +2 -1
  488. package/src/components/block-patterns-list/index.js +47 -24
  489. package/src/components/block-popover/style.scss +1 -1
  490. package/src/components/block-preview/README.md +15 -10
  491. package/src/components/block-preview/auto.js +7 -1
  492. package/src/components/block-preview/content.scss +4 -0
  493. package/src/components/block-preview/index.js +7 -12
  494. package/src/components/block-preview/style.scss +0 -7
  495. package/src/components/block-preview/test/index.js +18 -35
  496. package/src/components/block-selection-clearer/test/index.js +12 -12
  497. package/src/components/block-settings-menu/block-settings-dropdown.js +32 -20
  498. package/src/components/block-styles/utils.js +3 -3
  499. package/src/components/block-switcher/index.js +19 -4
  500. package/src/components/block-switcher/test/index.js +4 -0
  501. package/src/components/block-toolbar/index.js +12 -5
  502. package/src/components/block-toolbar/style.scss +10 -0
  503. package/src/components/block-tools/insertion-point.js +3 -47
  504. package/src/components/block-tools/selected-block-popover.js +80 -34
  505. package/src/components/block-tools/style.scss +27 -5
  506. package/src/components/block-variation-picker/index.js +1 -4
  507. package/src/components/block-vertical-alignment-control/test/index.js +4 -1
  508. package/src/components/colors/with-colors.js +13 -23
  509. package/src/components/default-block-appender/{style.scss → content.scss} +1 -0
  510. package/src/components/font-sizes/fluid-utils.js +37 -64
  511. package/src/components/font-sizes/test/fluid-utils.js +5 -5
  512. package/src/components/font-sizes/with-font-sizes.js +14 -11
  513. package/src/components/height-control/index.js +123 -0
  514. package/src/components/height-control/stories/index.js +21 -0
  515. package/src/components/height-control/style.scss +5 -0
  516. package/src/components/iframe/index.js +25 -18
  517. package/src/components/image-editor/use-save-image.js +2 -0
  518. package/src/components/image-editor/zoom-dropdown.js +1 -0
  519. package/src/components/index.js +2 -0
  520. package/src/components/inner-blocks/{style.scss → content.scss} +0 -0
  521. package/src/components/inner-blocks/index.js +30 -10
  522. package/src/components/inner-blocks/use-inner-block-template-sync.js +28 -10
  523. package/src/components/inserter/block-patterns-explorer/sidebar.js +1 -0
  524. package/src/components/inserter/block-patterns-tab.js +28 -71
  525. package/src/components/inserter/block-types-tab.js +3 -2
  526. package/src/components/inserter/hooks/use-debounced-input.js +17 -0
  527. package/src/components/inserter/index.js +10 -2
  528. package/src/components/inserter/index.native.js +1 -1
  529. package/src/components/inserter/media-tab/hooks.js +88 -0
  530. package/src/components/inserter/media-tab/index.js +3 -0
  531. package/src/components/inserter/media-tab/media-list.js +93 -0
  532. package/src/components/inserter/media-tab/media-panel.js +83 -0
  533. package/src/components/inserter/media-tab/media-tab.js +135 -0
  534. package/src/components/inserter/media-tab/utils.js +37 -0
  535. package/src/components/inserter/menu.js +55 -13
  536. package/src/components/inserter/mobile-tab-navigation.js +85 -0
  537. package/src/components/inserter/quick-inserter.js +1 -0
  538. package/src/components/inserter/reusable-blocks-tab.js +4 -2
  539. package/src/components/inserter/search-results.js +3 -2
  540. package/src/components/inserter/stories/index.js +1 -1
  541. package/src/components/inserter/stories/{fixtures.js → utils/fixtures.js} +0 -0
  542. package/src/components/inserter/style.scss +184 -18
  543. package/src/components/inserter/tabs.js +12 -1
  544. package/src/components/inserter/test/reusable-blocks-tab.js +14 -57
  545. package/src/components/inserter-list-item/index.js +11 -1
  546. package/src/components/inserter-list-item/style.scss +26 -0
  547. package/src/components/inspector-controls/groups.js +2 -0
  548. package/src/components/inspector-controls-tabs/advanced-controls-panel.js +37 -0
  549. package/src/components/inspector-controls-tabs/index.js +62 -0
  550. package/src/components/inspector-controls-tabs/settings-tab.js +18 -0
  551. package/src/components/inspector-controls-tabs/styles-tab.js +51 -0
  552. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +89 -0
  553. package/src/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +9 -0
  554. package/src/components/inspector-controls-tabs/utils.js +28 -0
  555. package/src/components/line-height-control/test/index.js +5 -5
  556. package/src/components/link-control/README.md +1 -1
  557. package/src/components/link-control/index.js +24 -39
  558. package/src/components/link-control/search-input.js +1 -2
  559. package/src/components/link-control/test/index.js +400 -582
  560. package/src/components/link-control/use-internal-input-value.js +22 -0
  561. package/src/components/list-view/block.js +7 -3
  562. package/src/components/list-view/branch.js +21 -14
  563. package/src/components/list-view/style.scss +20 -9
  564. package/src/components/media-placeholder/{style.scss → content.scss} +0 -0
  565. package/src/components/media-replace-flow/test/index.js +37 -9
  566. package/src/components/media-upload/test/index.native.js +2 -0
  567. package/src/components/off-canvas-editor/README.md +5 -0
  568. package/src/components/off-canvas-editor/appender.js +93 -0
  569. package/src/components/off-canvas-editor/block-contents.js +89 -0
  570. package/src/components/off-canvas-editor/block-edit-button.js +27 -0
  571. package/src/components/off-canvas-editor/block-select-button.js +113 -0
  572. package/src/components/off-canvas-editor/block.js +401 -0
  573. package/src/components/off-canvas-editor/branch.js +208 -0
  574. package/src/components/off-canvas-editor/context.js +8 -0
  575. package/src/components/off-canvas-editor/drop-indicator.js +126 -0
  576. package/src/components/off-canvas-editor/expander.js +26 -0
  577. package/src/components/off-canvas-editor/index.js +242 -0
  578. package/src/components/off-canvas-editor/leaf.js +52 -0
  579. package/src/components/off-canvas-editor/link-ui.js +166 -0
  580. package/src/components/off-canvas-editor/style.scss +26 -0
  581. package/src/components/off-canvas-editor/test/utils.js +50 -0
  582. package/src/components/off-canvas-editor/update-attributes.js +99 -0
  583. package/src/components/off-canvas-editor/use-block-selection.js +169 -0
  584. package/src/components/off-canvas-editor/use-list-view-client-ids.js +29 -0
  585. package/src/components/off-canvas-editor/use-list-view-drop-zone.js +260 -0
  586. package/src/components/off-canvas-editor/use-list-view-expand-selected-item.js +58 -0
  587. package/src/components/off-canvas-editor/utils.js +58 -0
  588. package/src/components/plain-text/{style.scss → content.scss} +0 -0
  589. package/src/components/recursion-provider/test/index.js +27 -29
  590. package/src/components/responsive-block-control/test/index.js +69 -92
  591. package/src/components/rich-text/content.scss +42 -0
  592. package/src/components/rich-text/format-toolbar/index.js +6 -4
  593. package/src/components/rich-text/index.js +2 -2
  594. package/src/components/rich-text/index.native.js +0 -2
  595. package/src/components/rich-text/style.scss +0 -43
  596. package/src/components/rich-text/use-insert-replacement-text.js +31 -0
  597. package/src/components/rich-text/use-undo-automatic-change.js +7 -1
  598. package/src/components/rich-text/utils.js +2 -21
  599. package/src/components/spacing-sizes-control/spacing-input-control.js +9 -0
  600. package/src/components/ungroup-button/index.native.js +6 -2
  601. package/src/components/url-input/index.js +57 -73
  602. package/src/components/url-popover/README.md +12 -3
  603. package/src/components/url-popover/index.js +33 -3
  604. package/src/components/url-popover/test/__snapshots__/index.js.snap +8 -6
  605. package/src/components/url-popover/test/index.js +21 -9
  606. package/src/components/use-block-display-information/index.js +14 -5
  607. package/src/components/use-setting/index.js +20 -2
  608. package/src/components/use-setting/test/index.js +99 -0
  609. package/src/content.scss +10 -0
  610. package/src/hooks/child-layout.js +190 -0
  611. package/src/hooks/color-panel.js +13 -1
  612. package/src/hooks/color.js +2 -0
  613. package/src/hooks/content-lock-ui.js +47 -35
  614. package/src/hooks/dimensions.js +119 -21
  615. package/src/hooks/layout.js +62 -3
  616. package/src/hooks/margin.js +4 -3
  617. package/src/hooks/min-height.js +104 -0
  618. package/src/hooks/padding.js +4 -3
  619. package/src/hooks/style.js +10 -2
  620. package/src/hooks/test/style.js +4 -0
  621. package/src/hooks/test/use-typography-props.js +1 -1
  622. package/src/layouts/flex.js +43 -38
  623. package/src/store/actions.js +22 -0
  624. package/src/store/reducer.js +480 -434
  625. package/src/store/selectors.js +70 -64
  626. package/src/store/test/actions.js +18 -0
  627. package/src/store/test/performance.js +71 -0
  628. package/src/store/test/reducer.js +662 -490
  629. package/src/store/test/selectors.js +1839 -1306
  630. package/src/style.scss +4 -7
  631. package/src/utils/sorting.js +54 -0
  632. package/src/utils/test/sorting.js +49 -0
  633. package/tsconfig.tsbuildinfo +1 -1
  634. package/build/components/block-preview/live.js +0 -30
  635. package/build/components/block-preview/live.js.map +0 -1
  636. package/build-module/components/block-preview/live.js +0 -20
  637. package/build-module/components/block-preview/live.js.map +0 -1
  638. package/src/components/block-preview/live.js +0 -19
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/link-ui.js"],"names":["getSuggestionsQuery","type","kind","subtype","LinkControlTransforms","clientId","getBlock","blockTransforms","select","_getBlock","getBlockRootClientId","getBlockTransformItems","blockEditorStore","replaceBlock","featuredBlocks","transforms","filter","item","includes","name","length","map","index","icon","title","LinkUI","props","label","url","opensInNewTab","link","onClose","anchor","className","hasCreateSuggestion","onChange","onRemove"],"mappings":";;;;;;;;;;;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAhBA;;AAEA;AACA;AACA;;AAOA;AACA;AACA;;AAKA;AACA;AACA;AACA;AAC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IAAAA;AAAnC,MAA4CwB,KAAK,CAACI,IAAxD;AACA,QAAMA,IAAI,GAAG;AACZF,IAAAA,GADY;AAEZC,IAAAA,aAFY;AAGZL,IAAAA,KAAK,EAAEG,KAAK,IAAI,8BAAWA,KAAX;AAHJ,GAAb;AAMA,SACC,4BAAC,mBAAD;AACC,IAAA,SAAS,EAAC,QADX;AAEC,IAAA,OAAO,EAAGD,KAAK,CAACK,OAFjB;AAGC,IAAA,MAAM,EAAGL,KAAK,CAACM,MAHhB;AAIC,IAAA,KAAK;AAJN,KAMC,4BAAC,oBAAD;AACC,IAAA,cAAc,MADf;AAEC,IAAA,eAAe,MAFhB;AAGC,IAAA,SAAS,EAAGN,KAAK,CAACO,SAHnB;AAIC,IAAA,KAAK,EAAGH,IAJT;AAKC,IAAA,sBAAsB,EAAG,IAL1B;AAMC,IAAA,oBAAoB,EAAGJ,KAAK,CAACQ,mBAN9B;AAOC,IAAA,aAAa,EAAG,CAAC,CAAEjC,IAPpB;AAQC,IAAA,eAAe,EAAG,CAAC,CAAEA,IARtB;AASC,IAAA,gBAAgB,EAAGD,mBAAmB,CAAEC,IAAF,EAAQC,IAAR,CATvC;AAUC,IAAA,QAAQ,EAAGwB,KAAK,CAACS,QAVlB;AAWC,IAAA,QAAQ,EAAGT,KAAK,CAACU,QAXlB;AAYC,IAAA,mBAAmB,EAClB,CAAER,GAAF,GACG,MACA,4BAAC,qBAAD;AACC,MAAA,QAAQ,EAAGF,KAAK,CAACrB;AADlB,MAFH,GAMG;AAnBL,IAND,CADD;AA+BA","sourcesContent":["// Note: this file is copied directly from packages/block-library/src/navigation-link/link-ui.js\n\n/**\n * WordPress dependencies\n */\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { Popover, Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { switchToBlockType } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport LinkControl from '../link-control';\nimport BlockIcon from '../block-icon';\n\n/**\n * Given the Link block's type attribute, return the query params to give to\n * /wp/v2/search.\n *\n * @param {string} type Link block's type attribute.\n * @param {string} kind Link block's entity of kind (post-type|taxonomy)\n * @return {{ type?: string, subtype?: string }} Search query params.\n */\nexport function getSuggestionsQuery( type, kind ) {\n\tswitch ( type ) {\n\t\tcase 'post':\n\t\tcase 'page':\n\t\t\treturn { type: 'post', subtype: type };\n\t\tcase 'category':\n\t\t\treturn { type: 'term', subtype: 'category' };\n\t\tcase 'tag':\n\t\t\treturn { type: 'term', subtype: 'post_tag' };\n\t\tcase 'post_format':\n\t\t\treturn { type: 'post-format' };\n\t\tdefault:\n\t\t\tif ( kind === 'taxonomy' ) {\n\t\t\t\treturn { type: 'term', subtype: type };\n\t\t\t}\n\t\t\tif ( kind === 'post-type' ) {\n\t\t\t\treturn { type: 'post', subtype: type };\n\t\t\t}\n\t\t\treturn {};\n\t}\n}\n\n/**\n * Add transforms to Link Control\n *\n * @param {Object} props Component props.\n * @param {string} props.clientId Block client ID.\n */\nfunction LinkControlTransforms( { clientId } ) {\n\tconst { getBlock, blockTransforms } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlock: _getBlock,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockTransformItems,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\tgetBlock: _getBlock,\n\t\t\t\tblockTransforms: getBlockTransformItems(\n\t\t\t\t\t_getBlock( clientId ),\n\t\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { replaceBlock } = useDispatch( blockEditorStore );\n\n\tconst featuredBlocks = [\n\t\t'core/page-list',\n\t\t'core/site-logo',\n\t\t'core/social-links',\n\t\t'core/search',\n\t];\n\n\tconst transforms = blockTransforms.filter( ( item ) => {\n\t\treturn featuredBlocks.includes( item.name );\n\t} );\n\n\tif ( ! transforms?.length ) {\n\t\treturn null;\n\t}\n\n\tif ( ! clientId ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div className=\"link-control-transform\">\n\t\t\t<h3 className=\"link-control-transform__subheading\">\n\t\t\t\t{ __( 'Transform' ) }\n\t\t\t</h3>\n\t\t\t<div className=\"link-control-transform__items\">\n\t\t\t\t{ transforms.map( ( item, index ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ `transform-${ index }` }\n\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\treplaceBlock(\n\t\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\t\tswitchToBlockType(\n\t\t\t\t\t\t\t\t\t\tgetBlock( clientId ),\n\t\t\t\t\t\t\t\t\t\titem.name\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tclassName=\"link-control-transform__item\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockIcon icon={ item.icon } />\n\t\t\t\t\t\t\t{ item.title }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nexport function LinkUI( props ) {\n\tconst { label, url, opensInNewTab, type, kind } = props.link;\n\tconst link = {\n\t\turl,\n\t\topensInNewTab,\n\t\ttitle: label && stripHTML( label ),\n\t};\n\n\treturn (\n\t\t<Popover\n\t\t\tplacement=\"bottom\"\n\t\t\tonClose={ props.onClose }\n\t\t\tanchor={ props.anchor }\n\t\t\tshift\n\t\t>\n\t\t\t<LinkControl\n\t\t\t\thasTextControl\n\t\t\t\thasRichPreviews\n\t\t\t\tclassName={ props.className }\n\t\t\t\tvalue={ link }\n\t\t\t\tshowInitialSuggestions={ true }\n\t\t\t\twithCreateSuggestion={ props.hasCreateSuggestion }\n\t\t\t\tnoDirectEntry={ !! type }\n\t\t\t\tnoURLSuggestion={ !! type }\n\t\t\t\tsuggestionsQuery={ getSuggestionsQuery( type, kind ) }\n\t\t\t\tonChange={ props.onChange }\n\t\t\t\tonRemove={ props.onRemove }\n\t\t\t\trenderControlBottom={\n\t\t\t\t\t! url\n\t\t\t\t\t\t? () => (\n\t\t\t\t\t\t\t\t<LinkControlTransforms\n\t\t\t\t\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: null\n\t\t\t\t}\n\t\t\t/>\n\t\t</Popover>\n\t);\n}\n"]}
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.updateAttributes = void 0;
7
+
8
+ var _escapeHtml = require("@wordpress/escape-html");
9
+
10
+ var _url = require("@wordpress/url");
11
+
12
+ /**
13
+ * WordPress dependencies
14
+ */
15
+
16
+ /**
17
+ * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind
18
+ */
19
+
20
+ /**
21
+ * Navigation Link Block Attributes
22
+ *
23
+ * @typedef {Object} WPNavigationLinkBlockAttributes
24
+ *
25
+ * @property {string} [label] Link text.
26
+ * @property {WPNavigationLinkKind} [kind] Kind is used to differentiate between term and post ids to check post draft status.
27
+ * @property {string} [type] The type such as post, page, tag, category and other custom types.
28
+ * @property {string} [rel] The relationship of the linked URL.
29
+ * @property {number} [id] A post or term id.
30
+ * @property {boolean} [opensInNewTab] Sets link target to _blank when true.
31
+ * @property {string} [url] Link href.
32
+ * @property {string} [title] Link title attribute.
33
+ */
34
+
35
+ /**
36
+ * Link Control onChange handler that updates block attributes when a setting is changed.
37
+ *
38
+ * @param {Object} updatedValue New block attributes to update.
39
+ * @param {Function} setAttributes Block attribute update function.
40
+ * @param {WPNavigationLinkBlockAttributes} blockAttributes Current block attributes.
41
+ *
42
+ */
43
+ const updateAttributes = function () {
44
+ let updatedValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
45
+ let setAttributes = arguments.length > 1 ? arguments[1] : undefined;
46
+ let blockAttributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
47
+ const {
48
+ label: originalLabel = '',
49
+ kind: originalKind = '',
50
+ type: originalType = ''
51
+ } = blockAttributes;
52
+ const {
53
+ title: newLabel = '',
54
+ // the title of any provided Post.
55
+ url: newUrl = '',
56
+ opensInNewTab,
57
+ id,
58
+ kind: newKind = originalKind,
59
+ type: newType = originalType
60
+ } = updatedValue;
61
+ const newLabelWithoutHttp = newLabel.replace(/http(s?):\/\//gi, '');
62
+ const newUrlWithoutHttp = newUrl.replace(/http(s?):\/\//gi, '');
63
+ const useNewLabel = newLabel && newLabel !== originalLabel && // LinkControl without the title field relies
64
+ // on the check below. Specifically, it assumes that
65
+ // the URL is the same as a title.
66
+ // This logic a) looks suspicious and b) should really
67
+ // live in the LinkControl and not here. It's a great
68
+ // candidate for future refactoring.
69
+ newLabelWithoutHttp !== newUrlWithoutHttp; // Unfortunately this causes the escaping model to be inverted.
70
+ // The escaped content is stored in the block attributes (and ultimately in the database),
71
+ // and then the raw data is "recovered" when outputting into the DOM.
72
+ // It would be preferable to store the **raw** data in the block attributes and escape it in JS.
73
+ // Why? Because there isn't one way to escape data. Depending on the context, you need to do
74
+ // different transforms. It doesn't make sense to me to choose one of them for the purposes of storage.
75
+ // See also:
76
+ // - https://github.com/WordPress/gutenberg/pull/41063
77
+ // - https://github.com/WordPress/gutenberg/pull/18617.
78
+
79
+ const label = useNewLabel ? (0, _escapeHtml.escapeHTML)(newLabel) : originalLabel || (0, _escapeHtml.escapeHTML)(newUrlWithoutHttp); // In https://github.com/WordPress/gutenberg/pull/24670 we decided to use "tag" in favor of "post_tag"
80
+
81
+ const type = newType === 'post_tag' ? 'tag' : newType.replace('-', '_');
82
+ const isBuiltInType = ['post', 'page', 'tag', 'category'].indexOf(type) > -1;
83
+ const isCustomLink = !newKind && !isBuiltInType || newKind === 'custom';
84
+ const kind = isCustomLink ? 'custom' : newKind;
85
+ setAttributes({ // Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.
86
+ ...(newUrl && {
87
+ url: encodeURI((0, _url.safeDecodeURI)(newUrl))
88
+ }),
89
+ ...(label && {
90
+ label
91
+ }),
92
+ ...(undefined !== opensInNewTab && {
93
+ opensInNewTab
94
+ }),
95
+ ...(id && Number.isInteger(id) && {
96
+ id
97
+ }),
98
+ ...(kind && {
99
+ kind
100
+ }),
101
+ ...(type && type !== 'URL' && {
102
+ type
103
+ })
104
+ });
105
+ };
106
+
107
+ exports.updateAttributes = updateAttributes;
108
+ //# sourceMappingURL=update-attributes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/update-attributes.js"],"names":["updateAttributes","updatedValue","setAttributes","blockAttributes","label","originalLabel","kind","originalKind","type","originalType","title","newLabel","url","newUrl","opensInNewTab","id","newKind","newType","newLabelWithoutHttp","replace","newUrlWithoutHttp","useNewLabel","isBuiltInType","indexOf","isCustomLink","encodeURI","undefined","Number","isInteger"],"mappings":";;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEO,MAAMA,gBAAgB,GAAG,YAI3B;AAAA,MAHJC,YAGI,uEAHW,EAGX;AAAA,MAFJC,aAEI;AAAA,MADJC,eACI,uEADc,EACd;AACJ,QAAM;AACLC,IAAAA,KAAK,EAAEC,aAAa,GAAG,EADlB;AAELC,IAAAA,IAAI,EAAEC,YAAY,GAAG,EAFhB;AAGLC,IAAAA,IAAI,EAAEC,YAAY,GAAG;AAHhB,MAIFN,eAJJ;AAMA,QAAM;AACLO,IAAAA,KAAK,EAAEC,QAAQ,GAAG,EADb;AACiB;AACtBC,IAAAA,GAAG,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AId,QAAKsB,SAAS,KAAKZ,aAAd,IAA+B;AAAEA,MAAAA;AAAF,KAApC,CAJc;AAKd,QAAKC,EAAE,IAAIY,MAAM,CAACC,SAAP,CAAkBb,EAAlB,CAAN,IAAgC;AAAEA,MAAAA;AAAF,KAArC,CALc;AAMd,QAAKT,IAAI,IAAI;AAAEA,MAAAA;AAAF,KAAb,CANc;AAOd,QAAKE,IAAI,IAAIA,IAAI,KAAK,KAAjB,IAA0B;AAAEA,MAAAA;AAAF,KAA/B;AAPc,GAAF,CAAb;AASA,CAlEM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { escapeHTML } from '@wordpress/escape-html';\nimport { safeDecodeURI } from '@wordpress/url';\n\n/**\n * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind\n */\n/**\n * Navigation Link Block Attributes\n *\n * @typedef {Object} WPNavigationLinkBlockAttributes\n *\n * @property {string} [label] Link text.\n * @property {WPNavigationLinkKind} [kind] Kind is used to differentiate between term and post ids to check post draft status.\n * @property {string} [type] The type such as post, page, tag, category and other custom types.\n * @property {string} [rel] The relationship of the linked URL.\n * @property {number} [id] A post or term id.\n * @property {boolean} [opensInNewTab] Sets link target to _blank when true.\n * @property {string} [url] Link href.\n * @property {string} [title] Link title attribute.\n */\n/**\n * Link Control onChange handler that updates block attributes when a setting is changed.\n *\n * @param {Object} updatedValue New block attributes to update.\n * @param {Function} setAttributes Block attribute update function.\n * @param {WPNavigationLinkBlockAttributes} blockAttributes Current block attributes.\n *\n */\n\nexport const updateAttributes = (\n\tupdatedValue = {},\n\tsetAttributes,\n\tblockAttributes = {}\n) => {\n\tconst {\n\t\tlabel: originalLabel = '',\n\t\tkind: originalKind = '',\n\t\ttype: originalType = '',\n\t} = blockAttributes;\n\n\tconst {\n\t\ttitle: newLabel = '', // the title of any provided Post.\n\t\turl: newUrl = '',\n\t\topensInNewTab,\n\t\tid,\n\t\tkind: newKind = originalKind,\n\t\ttype: newType = originalType,\n\t} = updatedValue;\n\n\tconst newLabelWithoutHttp = newLabel.replace( /http(s?):\\/\\//gi, '' );\n\tconst newUrlWithoutHttp = newUrl.replace( /http(s?):\\/\\//gi, '' );\n\n\tconst useNewLabel =\n\t\tnewLabel &&\n\t\tnewLabel !== originalLabel &&\n\t\t// LinkControl without the title field relies\n\t\t// on the check below. Specifically, it assumes that\n\t\t// the URL is the same as a title.\n\t\t// This logic a) looks suspicious and b) should really\n\t\t// live in the LinkControl and not here. It's a great\n\t\t// candidate for future refactoring.\n\t\tnewLabelWithoutHttp !== newUrlWithoutHttp;\n\n\t// Unfortunately this causes the escaping model to be inverted.\n\t// The escaped content is stored in the block attributes (and ultimately in the database),\n\t// and then the raw data is \"recovered\" when outputting into the DOM.\n\t// It would be preferable to store the **raw** data in the block attributes and escape it in JS.\n\t// Why? Because there isn't one way to escape data. Depending on the context, you need to do\n\t// different transforms. It doesn't make sense to me to choose one of them for the purposes of storage.\n\t// See also:\n\t// - https://github.com/WordPress/gutenberg/pull/41063\n\t// - https://github.com/WordPress/gutenberg/pull/18617.\n\tconst label = useNewLabel\n\t\t? escapeHTML( newLabel )\n\t\t: originalLabel || escapeHTML( newUrlWithoutHttp );\n\n\t// In https://github.com/WordPress/gutenberg/pull/24670 we decided to use \"tag\" in favor of \"post_tag\"\n\tconst type = newType === 'post_tag' ? 'tag' : newType.replace( '-', '_' );\n\n\tconst isBuiltInType =\n\t\t[ 'post', 'page', 'tag', 'category' ].indexOf( type ) > -1;\n\n\tconst isCustomLink =\n\t\t( ! newKind && ! isBuiltInType ) || newKind === 'custom';\n\tconst kind = isCustomLink ? 'custom' : newKind;\n\n\tsetAttributes( {\n\t\t// Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.\n\t\t...( newUrl && { url: encodeURI( safeDecodeURI( newUrl ) ) } ),\n\t\t...( label && { label } ),\n\t\t...( undefined !== opensInNewTab && { opensInNewTab } ),\n\t\t...( id && Number.isInteger( id ) && { id } ),\n\t\t...( kind && { kind } ),\n\t\t...( type && type !== 'URL' && { type } ),\n\t} );\n};\n"]}
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useBlockSelection;
7
+
8
+ var _a11y = require("@wordpress/a11y");
9
+
10
+ var _i18n = require("@wordpress/i18n");
11
+
12
+ var _data = require("@wordpress/data");
13
+
14
+ var _element = require("@wordpress/element");
15
+
16
+ var _keycodes = require("@wordpress/keycodes");
17
+
18
+ var _blocks = require("@wordpress/blocks");
19
+
20
+ var _store = require("../../store");
21
+
22
+ var _utils = require("./utils");
23
+
24
+ /**
25
+ * WordPress dependencies
26
+ */
27
+
28
+ /**
29
+ * Internal dependencies
30
+ */
31
+ function useBlockSelection() {
32
+ const {
33
+ clearSelectedBlock,
34
+ multiSelect,
35
+ selectBlock
36
+ } = (0, _data.useDispatch)(_store.store);
37
+ const {
38
+ getBlockName,
39
+ getBlockParents,
40
+ getBlockSelectionStart,
41
+ getBlockSelectionEnd,
42
+ getSelectedBlockClientIds,
43
+ hasMultiSelection,
44
+ hasSelectedBlock
45
+ } = (0, _data.useSelect)(_store.store);
46
+ const {
47
+ getBlockType
48
+ } = (0, _data.useSelect)(_blocks.store);
49
+ const updateBlockSelection = (0, _element.useCallback)(async (event, clientId, destinationClientId) => {
50
+ if (!(event !== null && event !== void 0 && event.shiftKey)) {
51
+ selectBlock(clientId);
52
+ return;
53
+ } // To handle multiple block selection via the `SHIFT` key, prevent
54
+ // the browser default behavior of opening the link in a new window.
55
+
56
+
57
+ event.preventDefault();
58
+ const isKeyPress = event.type === 'keydown' && (event.keyCode === _keycodes.UP || event.keyCode === _keycodes.DOWN || event.keyCode === _keycodes.HOME || event.keyCode === _keycodes.END); // Handle clicking on a block when no blocks are selected, and return early.
59
+
60
+ if (!isKeyPress && !hasSelectedBlock() && !hasMultiSelection()) {
61
+ selectBlock(clientId, null);
62
+ return;
63
+ }
64
+
65
+ const selectedBlocks = getSelectedBlockClientIds();
66
+ const clientIdWithParents = [...getBlockParents(clientId), clientId];
67
+
68
+ if (isKeyPress && !selectedBlocks.some(blockId => clientIdWithParents.includes(blockId))) {
69
+ // Ensure that shift-selecting blocks via the keyboard only
70
+ // expands the current selection if focusing over already
71
+ // selected blocks. Otherwise, clear the selection so that
72
+ // a user can create a new selection entirely by keyboard.
73
+ await clearSelectedBlock();
74
+ }
75
+
76
+ let startTarget = getBlockSelectionStart();
77
+ let endTarget = clientId; // Handle keyboard behavior for selecting multiple blocks.
78
+
79
+ if (isKeyPress) {
80
+ if (!hasSelectedBlock() && !hasMultiSelection()) {
81
+ // Set the starting point of the selection to the currently
82
+ // focused block, if there are no blocks currently selected.
83
+ // This ensures that as the selection is expanded or contracted,
84
+ // the starting point of the selection is anchored to that block.
85
+ startTarget = clientId;
86
+ }
87
+
88
+ if (destinationClientId) {
89
+ // If the user presses UP or DOWN, we want to ensure that the block they're
90
+ // moving to is the target for selection, and not the currently focused one.
91
+ endTarget = destinationClientId;
92
+ }
93
+ }
94
+
95
+ const startParents = getBlockParents(startTarget);
96
+ const endParents = getBlockParents(endTarget);
97
+ const {
98
+ start,
99
+ end
100
+ } = (0, _utils.getCommonDepthClientIds)(startTarget, endTarget, startParents, endParents);
101
+ await multiSelect(start, end, null); // Announce deselected block, or number of deselected blocks if
102
+ // the total number of blocks deselected is greater than one.
103
+
104
+ const updatedSelectedBlocks = getSelectedBlockClientIds(); // If the selection is greater than 1 and the Home or End keys
105
+ // were used to generate the selection, then skip announcing the
106
+ // deselected blocks.
107
+
108
+ if ((event.keyCode === _keycodes.HOME || event.keyCode === _keycodes.END) && updatedSelectedBlocks.length > 1) {
109
+ return;
110
+ }
111
+
112
+ const selectionDiff = selectedBlocks.filter(blockId => !updatedSelectedBlocks.includes(blockId));
113
+ let label;
114
+
115
+ if (selectionDiff.length === 1) {
116
+ var _getBlockType;
117
+
118
+ const title = (_getBlockType = getBlockType(getBlockName(selectionDiff[0]))) === null || _getBlockType === void 0 ? void 0 : _getBlockType.title;
119
+
120
+ if (title) {
121
+ label = (0, _i18n.sprintf)(
122
+ /* translators: %s: block name */
123
+ (0, _i18n.__)('%s deselected.'), title);
124
+ }
125
+ } else if (selectionDiff.length > 1) {
126
+ label = (0, _i18n.sprintf)(
127
+ /* translators: %s: number of deselected blocks */
128
+ (0, _i18n.__)('%s blocks deselected.'), selectionDiff.length);
129
+ }
130
+
131
+ if (label) {
132
+ (0, _a11y.speak)(label);
133
+ }
134
+ }, [clearSelectedBlock, getBlockName, getBlockType, getBlockParents, getBlockSelectionStart, getBlockSelectionEnd, getSelectedBlockClientIds, hasMultiSelection, hasSelectedBlock, multiSelect, selectBlock]);
135
+ return {
136
+ updateBlockSelection
137
+ };
138
+ }
139
+ //# sourceMappingURL=use-block-selection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/use-block-selection.js"],"names":["useBlockSelection","clearSelectedBlock","multiSelect","selectBlock","blockEditorStore","getBlockName","getBlockParents","getBlockSelectionStart","getBlockSelectionEnd","getSelectedBlockClientIds","hasMultiSelection","hasSelectedBlock","getBlockType","blocksStore","updateBlockSelection","event","clientId","destinationClientId","shiftKey","preventDefault","isKeyPress","type","keyCode","UP","DOWN","HOME","END","selectedBlocks","clientIdWithParents","some","blockId","includes","startTarget","endTarget","startParents","endParents","start","end","updatedSelectedBlocks","length","selectionDiff","filter","label","title"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAdA;AACA;AACA;;AAQA;AACA;AACA;AAIe,SAASA,iBAAT,GAA6B;AAC3C,QAAM;AAAEC,IAAAA,kBAAF;AAAsBC,IAAAA,WAAtB;AAAmCC,IAAAA;AAAnC,MACL,uBAAaC,YAAb,CADD;AAEA,QAAM;AACLC,IAAAA,YADK;AAELC,IAAAA,eAFK;AAGLC,IAAAA,sBAHK;AAILC,IAAAA,oBAJK;AAKLC,IAAAA,yBALK;AAMLC,IAAAA,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,GAAG;AACP;AACA,oBAAI,uBAAJ,CAFO,EAGPF,aAAa,CAACD,MAHP,CAAR;AAKA;;AAED,QAAKG,KAAL,EAAa;AACZ,uBAAOA,KAAP;AACA;AACD,GAtH2B,EAuH5B,CACCzC,kBADD,EAECI,YAFD,EAGCO,YAHD,EAICN,eAJD,EAKCC,sBALD,EAMCC,oBAND,EAOCC,yBAPD,EAQCC,iBARD,EASCC,gBATD,EAUCT,WAVD,EAWCC,WAXD,CAvH4B,CAA7B;AAsIA,SAAO;AACNW,IAAAA;AADM,GAAP;AAGA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\nimport { UP, DOWN, HOME, END } from '@wordpress/keycodes';\nimport { store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getCommonDepthClientIds } from './utils';\n\nexport default function useBlockSelection() {\n\tconst { clearSelectedBlock, multiSelect, selectBlock } =\n\t\tuseDispatch( blockEditorStore );\n\tconst {\n\t\tgetBlockName,\n\t\tgetBlockParents,\n\t\tgetBlockSelectionStart,\n\t\tgetBlockSelectionEnd,\n\t\tgetSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\thasSelectedBlock,\n\t} = useSelect( blockEditorStore );\n\n\tconst { getBlockType } = useSelect( blocksStore );\n\n\tconst updateBlockSelection = useCallback(\n\t\tasync ( event, clientId, destinationClientId ) => {\n\t\t\tif ( ! event?.shiftKey ) {\n\t\t\t\tselectBlock( clientId );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// To handle multiple block selection via the `SHIFT` key, prevent\n\t\t\t// the browser default behavior of opening the link in a new window.\n\t\t\tevent.preventDefault();\n\n\t\t\tconst isKeyPress =\n\t\t\t\tevent.type === 'keydown' &&\n\t\t\t\t( event.keyCode === UP ||\n\t\t\t\t\tevent.keyCode === DOWN ||\n\t\t\t\t\tevent.keyCode === HOME ||\n\t\t\t\t\tevent.keyCode === END );\n\n\t\t\t// Handle clicking on a block when no blocks are selected, and return early.\n\t\t\tif (\n\t\t\t\t! isKeyPress &&\n\t\t\t\t! hasSelectedBlock() &&\n\t\t\t\t! hasMultiSelection()\n\t\t\t) {\n\t\t\t\tselectBlock( clientId, null );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selectedBlocks = getSelectedBlockClientIds();\n\t\t\tconst clientIdWithParents = [\n\t\t\t\t...getBlockParents( clientId ),\n\t\t\t\tclientId,\n\t\t\t];\n\n\t\t\tif (\n\t\t\t\tisKeyPress &&\n\t\t\t\t! selectedBlocks.some( ( blockId ) =>\n\t\t\t\t\tclientIdWithParents.includes( blockId )\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\t// Ensure that shift-selecting blocks via the keyboard only\n\t\t\t\t// expands the current selection if focusing over already\n\t\t\t\t// selected blocks. Otherwise, clear the selection so that\n\t\t\t\t// a user can create a new selection entirely by keyboard.\n\t\t\t\tawait clearSelectedBlock();\n\t\t\t}\n\n\t\t\tlet startTarget = getBlockSelectionStart();\n\t\t\tlet endTarget = clientId;\n\n\t\t\t// Handle keyboard behavior for selecting multiple blocks.\n\t\t\tif ( isKeyPress ) {\n\t\t\t\tif ( ! hasSelectedBlock() && ! hasMultiSelection() ) {\n\t\t\t\t\t// Set the starting point of the selection to the currently\n\t\t\t\t\t// focused block, if there are no blocks currently selected.\n\t\t\t\t\t// This ensures that as the selection is expanded or contracted,\n\t\t\t\t\t// the starting point of the selection is anchored to that block.\n\t\t\t\t\tstartTarget = clientId;\n\t\t\t\t}\n\t\t\t\tif ( destinationClientId ) {\n\t\t\t\t\t// If the user presses UP or DOWN, we want to ensure that the block they're\n\t\t\t\t\t// moving to is the target for selection, and not the currently focused one.\n\t\t\t\t\tendTarget = destinationClientId;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst startParents = getBlockParents( startTarget );\n\t\t\tconst endParents = getBlockParents( endTarget );\n\n\t\t\tconst { start, end } = getCommonDepthClientIds(\n\t\t\t\tstartTarget,\n\t\t\t\tendTarget,\n\t\t\t\tstartParents,\n\t\t\t\tendParents\n\t\t\t);\n\t\t\tawait multiSelect( start, end, null );\n\n\t\t\t// Announce deselected block, or number of deselected blocks if\n\t\t\t// the total number of blocks deselected is greater than one.\n\t\t\tconst updatedSelectedBlocks = getSelectedBlockClientIds();\n\n\t\t\t// If the selection is greater than 1 and the Home or End keys\n\t\t\t// were used to generate the selection, then skip announcing the\n\t\t\t// deselected blocks.\n\t\t\tif (\n\t\t\t\t( event.keyCode === HOME || event.keyCode === END ) &&\n\t\t\t\tupdatedSelectedBlocks.length > 1\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selectionDiff = selectedBlocks.filter(\n\t\t\t\t( blockId ) => ! updatedSelectedBlocks.includes( blockId )\n\t\t\t);\n\n\t\t\tlet label;\n\t\t\tif ( selectionDiff.length === 1 ) {\n\t\t\t\tconst title = getBlockType(\n\t\t\t\t\tgetBlockName( selectionDiff[ 0 ] )\n\t\t\t\t)?.title;\n\t\t\t\tif ( title ) {\n\t\t\t\t\tlabel = sprintf(\n\t\t\t\t\t\t/* translators: %s: block name */\n\t\t\t\t\t\t__( '%s deselected.' ),\n\t\t\t\t\t\ttitle\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else if ( selectionDiff.length > 1 ) {\n\t\t\t\tlabel = sprintf(\n\t\t\t\t\t/* translators: %s: number of deselected blocks */\n\t\t\t\t\t__( '%s blocks deselected.' ),\n\t\t\t\t\tselectionDiff.length\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif ( label ) {\n\t\t\t\tspeak( label );\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tclearSelectedBlock,\n\t\t\tgetBlockName,\n\t\t\tgetBlockType,\n\t\t\tgetBlockParents,\n\t\t\tgetBlockSelectionStart,\n\t\t\tgetBlockSelectionEnd,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\thasMultiSelection,\n\t\t\thasSelectedBlock,\n\t\t\tmultiSelect,\n\t\t\tselectBlock,\n\t\t]\n\t);\n\n\treturn {\n\t\tupdateBlockSelection,\n\t};\n}\n"]}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useListViewClientIds;
7
+
8
+ var _data = require("@wordpress/data");
9
+
10
+ var _store = require("../../store");
11
+
12
+ /**
13
+ * WordPress dependencies
14
+ */
15
+
16
+ /**
17
+ * Internal dependencies
18
+ */
19
+ function useListViewClientIds(blocks) {
20
+ return (0, _data.useSelect)(select => {
21
+ const {
22
+ getDraggedBlockClientIds,
23
+ getSelectedBlockClientIds,
24
+ __unstableGetClientIdsTree
25
+ } = select(_store.store);
26
+ return {
27
+ selectedClientIds: getSelectedBlockClientIds(),
28
+ draggedClientIds: getDraggedBlockClientIds(),
29
+ clientIdsTree: blocks ? blocks : __unstableGetClientIdsTree()
30
+ };
31
+ }, [blocks]);
32
+ }
33
+ //# sourceMappingURL=use-list-view-client-ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/use-list-view-client-ids.js"],"names":["useListViewClientIds","blocks","select","getDraggedBlockClientIds","getSelectedBlockClientIds","__unstableGetClientIdsTree","blockEditorStore","selectedClientIds","draggedClientIds","clientIdsTree"],"mappings":";;;;;;;AAIA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAGe,SAASA,oBAAT,CAA+BC,MAA/B,EAAwC;AACtD,SAAO,qBACJC,MAAF,IAAc;AACb,UAAM;AACLC,MAAAA,wBADK;AAELC,MAAAA,yBAFK;AAGLC,MAAAA;AAHK,QAIFH,MAAM,CAAEI,YAAF,CAJV;AAMA,WAAO;AACNC,MAAAA,iBAAiB,EAAEH,yBAAyB,EADtC;AAENI,MAAAA,gBAAgB,EAAEL,wBAAwB,EAFpC;AAGNM,MAAAA,aAAa,EAAER,MAAM,GAAGA,MAAH,GAAYI,0BAA0B;AAHrD,KAAP;AAKA,GAbK,EAcN,CAAEJ,MAAF,CAdM,CAAP;AAgBA","sourcesContent":["/**\n * WordPress dependencies\n */\n\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nexport default function useListViewClientIds( blocks ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetDraggedBlockClientIds,\n\t\t\t\tgetSelectedBlockClientIds,\n\t\t\t\t__unstableGetClientIdsTree,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\tselectedClientIds: getSelectedBlockClientIds(),\n\t\t\t\tdraggedClientIds: getDraggedBlockClientIds(),\n\t\t\t\tclientIdsTree: blocks ? blocks : __unstableGetClientIdsTree(),\n\t\t\t};\n\t\t},\n\t\t[ blocks ]\n\t);\n}\n"]}
@@ -0,0 +1,235 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = useListViewDropZone;
9
+
10
+ var _data = require("@wordpress/data");
11
+
12
+ var _element = require("@wordpress/element");
13
+
14
+ var _compose = require("@wordpress/compose");
15
+
16
+ var _math = require("../../utils/math");
17
+
18
+ var _useOnBlockDrop = _interopRequireDefault(require("../use-on-block-drop"));
19
+
20
+ var _store = require("../../store");
21
+
22
+ /**
23
+ * WordPress dependencies
24
+ */
25
+
26
+ /**
27
+ * Internal dependencies
28
+ */
29
+
30
+ /** @typedef {import('../../utils/math').WPPoint} WPPoint */
31
+
32
+ /**
33
+ * The type of a drag event.
34
+ *
35
+ * @typedef {'default'|'file'|'html'} WPDragEventType
36
+ */
37
+
38
+ /**
39
+ * An array representing data for blocks in the DOM used by drag and drop.
40
+ *
41
+ * @typedef {Object} WPListViewDropZoneBlocks
42
+ * @property {string} clientId The client id for the block.
43
+ * @property {string} rootClientId The root client id for the block.
44
+ * @property {number} blockIndex The block's index.
45
+ * @property {Element} element The DOM element representing the block.
46
+ * @property {number} innerBlockCount The number of inner blocks the block has.
47
+ * @property {boolean} isDraggedBlock Whether the block is currently being dragged.
48
+ * @property {boolean} canInsertDraggedBlocksAsSibling Whether the dragged block can be a sibling of this block.
49
+ * @property {boolean} canInsertDraggedBlocksAsChild Whether the dragged block can be a child of this block.
50
+ */
51
+
52
+ /**
53
+ * An object containing details of a drop target.
54
+ *
55
+ * @typedef {Object} WPListViewDropZoneTarget
56
+ * @property {string} blockIndex The insertion index.
57
+ * @property {string} rootClientId The root client id for the block.
58
+ * @property {string|undefined} clientId The client id for the block.
59
+ * @property {'top'|'bottom'|'inside'} dropPosition The position relative to the block that the user is dropping to.
60
+ * 'inside' refers to nesting as an inner block.
61
+ */
62
+
63
+ /**
64
+ * Determines whether the user positioning the dragged block to nest as an
65
+ * inner block.
66
+ *
67
+ * Presently this is determined by whether the cursor is on the right hand side
68
+ * of the block.
69
+ *
70
+ * @param {WPPoint} point The point representing the cursor position when dragging.
71
+ * @param {DOMRect} rect The rectangle.
72
+ */
73
+ function isNestingGesture(point, rect) {
74
+ const blockCenterX = rect.left + rect.width / 2;
75
+ return point.x > blockCenterX;
76
+ } // Block navigation is always a vertical list, so only allow dropping
77
+ // to the above or below a block.
78
+
79
+
80
+ const ALLOWED_DROP_EDGES = ['top', 'bottom'];
81
+ /**
82
+ * Given blocks data and the cursor position, compute the drop target.
83
+ *
84
+ * @param {WPListViewDropZoneBlocks} blocksData Data about the blocks in list view.
85
+ * @param {WPPoint} position The point representing the cursor position when dragging.
86
+ *
87
+ * @return {WPListViewDropZoneTarget} An object containing data about the drop target.
88
+ */
89
+
90
+ function getListViewDropTarget(blocksData, position) {
91
+ let candidateEdge;
92
+ let candidateBlockData;
93
+ let candidateDistance;
94
+ let candidateRect;
95
+
96
+ for (const blockData of blocksData) {
97
+ if (blockData.isDraggedBlock) {
98
+ continue;
99
+ }
100
+
101
+ const rect = blockData.element.getBoundingClientRect();
102
+ const [distance, edge] = (0, _math.getDistanceToNearestEdge)(position, rect, ALLOWED_DROP_EDGES);
103
+ const isCursorWithinBlock = (0, _math.isPointContainedByRect)(position, rect);
104
+
105
+ if (candidateDistance === undefined || distance < candidateDistance || isCursorWithinBlock) {
106
+ candidateDistance = distance;
107
+ const index = blocksData.indexOf(blockData);
108
+ const previousBlockData = blocksData[index - 1]; // If dragging near the top of a block and the preceding block
109
+ // is at the same level, use the preceding block as the candidate
110
+ // instead, as later it makes determining a nesting drop easier.
111
+
112
+ if (edge === 'top' && previousBlockData && previousBlockData.rootClientId === blockData.rootClientId && !previousBlockData.isDraggedBlock) {
113
+ candidateBlockData = previousBlockData;
114
+ candidateEdge = 'bottom';
115
+ candidateRect = previousBlockData.element.getBoundingClientRect();
116
+ } else {
117
+ candidateBlockData = blockData;
118
+ candidateEdge = edge;
119
+ candidateRect = rect;
120
+ } // If the mouse position is within the block, break early
121
+ // as the user would intend to drop either before or after
122
+ // this block.
123
+ //
124
+ // This solves an issue where some rows in the list view
125
+ // tree overlap slightly due to sub-pixel rendering.
126
+
127
+
128
+ if (isCursorWithinBlock) {
129
+ break;
130
+ }
131
+ }
132
+ }
133
+
134
+ if (!candidateBlockData) {
135
+ return;
136
+ }
137
+
138
+ const isDraggingBelow = candidateEdge === 'bottom'; // If the user is dragging towards the bottom of the block check whether
139
+ // they might be trying to nest the block as a child.
140
+ // If the block already has inner blocks, this should always be treated
141
+ // as nesting since the next block in the tree will be the first child.
142
+
143
+ if (isDraggingBelow && candidateBlockData.canInsertDraggedBlocksAsChild && (candidateBlockData.innerBlockCount > 0 || isNestingGesture(position, candidateRect))) {
144
+ return {
145
+ rootClientId: candidateBlockData.clientId,
146
+ blockIndex: 0,
147
+ dropPosition: 'inside'
148
+ };
149
+ } // If dropping as a sibling, but block cannot be inserted in
150
+ // this context, return early.
151
+
152
+
153
+ if (!candidateBlockData.canInsertDraggedBlocksAsSibling) {
154
+ return;
155
+ }
156
+
157
+ const offset = isDraggingBelow ? 1 : 0;
158
+ return {
159
+ rootClientId: candidateBlockData.rootClientId,
160
+ clientId: candidateBlockData.clientId,
161
+ blockIndex: candidateBlockData.blockIndex + offset,
162
+ dropPosition: candidateEdge
163
+ };
164
+ }
165
+ /**
166
+ * A react hook for implementing a drop zone in list view.
167
+ *
168
+ * @return {WPListViewDropZoneTarget} The drop target.
169
+ */
170
+
171
+
172
+ function useListViewDropZone() {
173
+ const {
174
+ getBlockRootClientId,
175
+ getBlockIndex,
176
+ getBlockCount,
177
+ getDraggedBlockClientIds,
178
+ canInsertBlocks
179
+ } = (0, _data.useSelect)(_store.store);
180
+ const [target, setTarget] = (0, _element.useState)();
181
+ const {
182
+ rootClientId: targetRootClientId,
183
+ blockIndex: targetBlockIndex
184
+ } = target || {};
185
+ const onBlockDrop = (0, _useOnBlockDrop.default)(targetRootClientId, targetBlockIndex);
186
+ const draggedBlockClientIds = getDraggedBlockClientIds();
187
+ const throttled = (0, _compose.useThrottle)((0, _element.useCallback)((event, currentTarget) => {
188
+ const position = {
189
+ x: event.clientX,
190
+ y: event.clientY
191
+ };
192
+ const isBlockDrag = !!(draggedBlockClientIds !== null && draggedBlockClientIds !== void 0 && draggedBlockClientIds.length);
193
+ const blockElements = Array.from(currentTarget.querySelectorAll('[data-block]'));
194
+ const blocksData = blockElements.map(blockElement => {
195
+ const clientId = blockElement.dataset.block;
196
+ const rootClientId = getBlockRootClientId(clientId);
197
+ return {
198
+ clientId,
199
+ rootClientId,
200
+ blockIndex: getBlockIndex(clientId),
201
+ element: blockElement,
202
+ isDraggedBlock: isBlockDrag ? draggedBlockClientIds.includes(clientId) : false,
203
+ innerBlockCount: getBlockCount(clientId),
204
+ canInsertDraggedBlocksAsSibling: isBlockDrag ? canInsertBlocks(draggedBlockClientIds, rootClientId) : true,
205
+ canInsertDraggedBlocksAsChild: isBlockDrag ? canInsertBlocks(draggedBlockClientIds, clientId) : true
206
+ };
207
+ });
208
+ const newTarget = getListViewDropTarget(blocksData, position);
209
+
210
+ if (newTarget) {
211
+ setTarget(newTarget);
212
+ }
213
+ }, [draggedBlockClientIds]), 200);
214
+ const ref = (0, _compose.__experimentalUseDropZone)({
215
+ onDrop: onBlockDrop,
216
+
217
+ onDragOver(event) {
218
+ // `currentTarget` is only available while the event is being
219
+ // handled, so get it now and pass it to the thottled function.
220
+ // https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget
221
+ throttled(event, event.currentTarget);
222
+ },
223
+
224
+ onDragEnd() {
225
+ throttled.cancel();
226
+ setTarget(null);
227
+ }
228
+
229
+ });
230
+ return {
231
+ ref,
232
+ target
233
+ };
234
+ }
235
+ //# sourceMappingURL=use-list-view-drop-zone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/use-list-view-drop-zone.js"],"names":["isNestingGesture","point","rect","blockCenterX","left","width","x","ALLOWED_DROP_EDGES","getListViewDropTarget","blocksData","position","candidateEdge","candidateBlockData","candidateDistance","candidateRect","blockData","isDraggedBlock","element","getBoundingClientRect","distance","edge","isCursorWithinBlock","undefined","index","indexOf","previousBlockData","rootClientId","isDraggingBelow","canInsertDraggedBlocksAsChild","innerBlockCount","clientId","blockIndex","dropPosition","canInsertDraggedBlocksAsSibling","offset","useListViewDropZone","getBlockRootClientId","getBlockIndex","getBlockCount","getDraggedBlockClientIds","canInsertBlocks","blockEditorStore","target","setTarget","targetRootClientId","targetBlockIndex","onBlockDrop","draggedBlockClientIds","throttled","event","currentTarget","clientX","y","clientY","isBlockDrag","length","blockElements","Array","from","querySelectorAll","map","blockElement","dataset","block","includes","newTarget","ref","onDrop","onDragOver","onDragEnd","cancel"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAQA;;AAIA;;AACA;;AAlBA;AACA;AACA;;AAQA;AACA;AACA;;AAQA;;AAEA;AACA;AACA;AACA;AACA;;AA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WAAW,GACxBP,qBAAqB,CAACiB,QAAtB,CAAgClC,QAAhC,CADwB,GAExB,KAPG;AAQND,QAAAA,eAAe,EAAES,aAAa,CAAER,QAAF,CARxB;AASNG,QAAAA,+BAA+B,EAAEqB,WAAW,GACzCd,eAAe,CACfO,qBADe,EAEfrB,YAFe,CAD0B,GAKzC,IAdG;AAeNE,QAAAA,6BAA6B,EAAE0B,WAAW,GACvCd,eAAe,CAAEO,qBAAF,EAAyBjB,QAAzB,CADwB,GAEvC;AAjBG,OAAP;AAmBA,KAvBkB,CAAnB;AAyBA,UAAMmC,SAAS,GAAGzD,qBAAqB,CAAEC,UAAF,EAAcC,QAAd,CAAvC;;AAEA,QAAKuD,SAAL,EAAiB;AAChBtB,MAAAA,SAAS,CAAEsB,SAAF,CAAT;AACA;AACD,GAvCF,EAwCC,CAAElB,qBAAF,CAxCD,CADiB,EA2CjB,GA3CiB,CAAlB;AA8CA,QAAMmB,GAAG,GAAG,wCAAa;AACxBC,IAAAA,MAAM,EAAErB,WADgB;;AAExBsB,IAAAA,UAAU,CAAEnB,KAAF,EAAU;AACnB;AACA;AACA;AACAD,MAAAA,SAAS,CAAEC,KAAF,EAASA,KAAK,CAACC,aAAf,CAAT;AACA,KAPuB;;AAQxBmB,IAAAA,SAAS,GAAG;AACXrB,MAAAA,SAAS,CAACsB,MAAV;AACA3B,MAAAA,SAAS,CAAE,IAAF,CAAT;AACA;;AAXuB,GAAb,CAAZ;AAcA,SAAO;AAAEuB,IAAAA,GAAF;AAAOxB,IAAAA;AAAP,GAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useState, useCallback } from '@wordpress/element';\nimport {\n\tuseThrottle,\n\t__experimentalUseDropZone as useDropZone,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetDistanceToNearestEdge,\n\tisPointContainedByRect,\n} from '../../utils/math';\nimport useOnBlockDrop from '../use-on-block-drop';\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('../../utils/math').WPPoint} WPPoint */\n\n/**\n * The type of a drag event.\n *\n * @typedef {'default'|'file'|'html'} WPDragEventType\n */\n\n/**\n * An array representing data for blocks in the DOM used by drag and drop.\n *\n * @typedef {Object} WPListViewDropZoneBlocks\n * @property {string} clientId The client id for the block.\n * @property {string} rootClientId The root client id for the block.\n * @property {number} blockIndex The block's index.\n * @property {Element} element The DOM element representing the block.\n * @property {number} innerBlockCount The number of inner blocks the block has.\n * @property {boolean} isDraggedBlock Whether the block is currently being dragged.\n * @property {boolean} canInsertDraggedBlocksAsSibling Whether the dragged block can be a sibling of this block.\n * @property {boolean} canInsertDraggedBlocksAsChild Whether the dragged block can be a child of this block.\n */\n\n/**\n * An object containing details of a drop target.\n *\n * @typedef {Object} WPListViewDropZoneTarget\n * @property {string} blockIndex The insertion index.\n * @property {string} rootClientId The root client id for the block.\n * @property {string|undefined} clientId The client id for the block.\n * @property {'top'|'bottom'|'inside'} dropPosition The position relative to the block that the user is dropping to.\n * 'inside' refers to nesting as an inner block.\n */\n\n/**\n * Determines whether the user positioning the dragged block to nest as an\n * inner block.\n *\n * Presently this is determined by whether the cursor is on the right hand side\n * of the block.\n *\n * @param {WPPoint} point The point representing the cursor position when dragging.\n * @param {DOMRect} rect The rectangle.\n */\nfunction isNestingGesture( point, rect ) {\n\tconst blockCenterX = rect.left + rect.width / 2;\n\treturn point.x > blockCenterX;\n}\n\n// Block navigation is always a vertical list, so only allow dropping\n// to the above or below a block.\nconst ALLOWED_DROP_EDGES = [ 'top', 'bottom' ];\n\n/**\n * Given blocks data and the cursor position, compute the drop target.\n *\n * @param {WPListViewDropZoneBlocks} blocksData Data about the blocks in list view.\n * @param {WPPoint} position The point representing the cursor position when dragging.\n *\n * @return {WPListViewDropZoneTarget} An object containing data about the drop target.\n */\nfunction getListViewDropTarget( blocksData, position ) {\n\tlet candidateEdge;\n\tlet candidateBlockData;\n\tlet candidateDistance;\n\tlet candidateRect;\n\n\tfor ( const blockData of blocksData ) {\n\t\tif ( blockData.isDraggedBlock ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst rect = blockData.element.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge(\n\t\t\tposition,\n\t\t\trect,\n\t\t\tALLOWED_DROP_EDGES\n\t\t);\n\n\t\tconst isCursorWithinBlock = isPointContainedByRect( position, rect );\n\t\tif (\n\t\t\tcandidateDistance === undefined ||\n\t\t\tdistance < candidateDistance ||\n\t\t\tisCursorWithinBlock\n\t\t) {\n\t\t\tcandidateDistance = distance;\n\n\t\t\tconst index = blocksData.indexOf( blockData );\n\t\t\tconst previousBlockData = blocksData[ index - 1 ];\n\n\t\t\t// If dragging near the top of a block and the preceding block\n\t\t\t// is at the same level, use the preceding block as the candidate\n\t\t\t// instead, as later it makes determining a nesting drop easier.\n\t\t\tif (\n\t\t\t\tedge === 'top' &&\n\t\t\t\tpreviousBlockData &&\n\t\t\t\tpreviousBlockData.rootClientId === blockData.rootClientId &&\n\t\t\t\t! previousBlockData.isDraggedBlock\n\t\t\t) {\n\t\t\t\tcandidateBlockData = previousBlockData;\n\t\t\t\tcandidateEdge = 'bottom';\n\t\t\t\tcandidateRect =\n\t\t\t\t\tpreviousBlockData.element.getBoundingClientRect();\n\t\t\t} else {\n\t\t\t\tcandidateBlockData = blockData;\n\t\t\t\tcandidateEdge = edge;\n\t\t\t\tcandidateRect = rect;\n\t\t\t}\n\n\t\t\t// If the mouse position is within the block, break early\n\t\t\t// as the user would intend to drop either before or after\n\t\t\t// this block.\n\t\t\t//\n\t\t\t// This solves an issue where some rows in the list view\n\t\t\t// tree overlap slightly due to sub-pixel rendering.\n\t\t\tif ( isCursorWithinBlock ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( ! candidateBlockData ) {\n\t\treturn;\n\t}\n\n\tconst isDraggingBelow = candidateEdge === 'bottom';\n\n\t// If the user is dragging towards the bottom of the block check whether\n\t// they might be trying to nest the block as a child.\n\t// If the block already has inner blocks, this should always be treated\n\t// as nesting since the next block in the tree will be the first child.\n\tif (\n\t\tisDraggingBelow &&\n\t\tcandidateBlockData.canInsertDraggedBlocksAsChild &&\n\t\t( candidateBlockData.innerBlockCount > 0 ||\n\t\t\tisNestingGesture( position, candidateRect ) )\n\t) {\n\t\treturn {\n\t\t\trootClientId: candidateBlockData.clientId,\n\t\t\tblockIndex: 0,\n\t\t\tdropPosition: 'inside',\n\t\t};\n\t}\n\n\t// If dropping as a sibling, but block cannot be inserted in\n\t// this context, return early.\n\tif ( ! candidateBlockData.canInsertDraggedBlocksAsSibling ) {\n\t\treturn;\n\t}\n\n\tconst offset = isDraggingBelow ? 1 : 0;\n\treturn {\n\t\trootClientId: candidateBlockData.rootClientId,\n\t\tclientId: candidateBlockData.clientId,\n\t\tblockIndex: candidateBlockData.blockIndex + offset,\n\t\tdropPosition: candidateEdge,\n\t};\n}\n\n/**\n * A react hook for implementing a drop zone in list view.\n *\n * @return {WPListViewDropZoneTarget} The drop target.\n */\nexport default function useListViewDropZone() {\n\tconst {\n\t\tgetBlockRootClientId,\n\t\tgetBlockIndex,\n\t\tgetBlockCount,\n\t\tgetDraggedBlockClientIds,\n\t\tcanInsertBlocks,\n\t} = useSelect( blockEditorStore );\n\tconst [ target, setTarget ] = useState();\n\tconst { rootClientId: targetRootClientId, blockIndex: targetBlockIndex } =\n\t\ttarget || {};\n\n\tconst onBlockDrop = useOnBlockDrop( targetRootClientId, targetBlockIndex );\n\n\tconst draggedBlockClientIds = getDraggedBlockClientIds();\n\tconst throttled = useThrottle(\n\t\tuseCallback(\n\t\t\t( event, currentTarget ) => {\n\t\t\t\tconst position = { x: event.clientX, y: event.clientY };\n\t\t\t\tconst isBlockDrag = !! draggedBlockClientIds?.length;\n\n\t\t\t\tconst blockElements = Array.from(\n\t\t\t\t\tcurrentTarget.querySelectorAll( '[data-block]' )\n\t\t\t\t);\n\n\t\t\t\tconst blocksData = blockElements.map( ( blockElement ) => {\n\t\t\t\t\tconst clientId = blockElement.dataset.block;\n\t\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\trootClientId,\n\t\t\t\t\t\tblockIndex: getBlockIndex( clientId ),\n\t\t\t\t\t\telement: blockElement,\n\t\t\t\t\t\tisDraggedBlock: isBlockDrag\n\t\t\t\t\t\t\t? draggedBlockClientIds.includes( clientId )\n\t\t\t\t\t\t\t: false,\n\t\t\t\t\t\tinnerBlockCount: getBlockCount( clientId ),\n\t\t\t\t\t\tcanInsertDraggedBlocksAsSibling: isBlockDrag\n\t\t\t\t\t\t\t? canInsertBlocks(\n\t\t\t\t\t\t\t\t\tdraggedBlockClientIds,\n\t\t\t\t\t\t\t\t\trootClientId\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: true,\n\t\t\t\t\t\tcanInsertDraggedBlocksAsChild: isBlockDrag\n\t\t\t\t\t\t\t? canInsertBlocks( draggedBlockClientIds, clientId )\n\t\t\t\t\t\t\t: true,\n\t\t\t\t\t};\n\t\t\t\t} );\n\n\t\t\t\tconst newTarget = getListViewDropTarget( blocksData, position );\n\n\t\t\t\tif ( newTarget ) {\n\t\t\t\t\tsetTarget( newTarget );\n\t\t\t\t}\n\t\t\t},\n\t\t\t[ draggedBlockClientIds ]\n\t\t),\n\t\t200\n\t);\n\n\tconst ref = useDropZone( {\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 );\n\t\t},\n\t\tonDragEnd() {\n\t\t\tthrottled.cancel();\n\t\t\tsetTarget( null );\n\t\t},\n\t} );\n\n\treturn { ref, target };\n}\n"]}