@wordpress/block-editor 12.1.0 → 12.2.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 (391) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/autocompleters/block.js +13 -5
  3. package/build/autocompleters/block.js.map +1 -1
  4. package/build/components/block-breadcrumb/index.js +6 -3
  5. package/build/components/block-breadcrumb/index.js.map +1 -1
  6. package/build/components/block-editing-mode/index.js +84 -0
  7. package/build/components/block-editing-mode/index.js.map +1 -0
  8. package/build/components/block-list/block-list-block-context.js +15 -0
  9. package/build/components/block-list/block-list-block-context.js.map +1 -0
  10. package/build/components/block-list/block.js +29 -37
  11. package/build/components/block-list/block.js.map +1 -1
  12. package/build/components/block-list/block.native.js +14 -22
  13. package/build/components/block-list/block.native.js.map +1 -1
  14. package/build/components/block-list/index.native.js +107 -108
  15. package/build/components/block-list/index.native.js.map +1 -1
  16. package/build/components/block-list/use-block-props/index.js +2 -2
  17. package/build/components/block-list/use-block-props/index.js.map +1 -1
  18. package/build/components/block-list/use-in-between-inserter.js +7 -5
  19. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  20. package/build/components/block-list-appender/index.js +15 -1
  21. package/build/components/block-list-appender/index.js.map +1 -1
  22. package/build/components/block-mobile-toolbar/block-actions-menu.native.js +19 -4
  23. package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  24. package/build/components/block-styles/preview-panel.js +1 -2
  25. package/build/components/block-styles/preview-panel.js.map +1 -1
  26. package/build/components/block-switcher/block-transformations-menu.js +8 -0
  27. package/build/components/block-switcher/block-transformations-menu.js.map +1 -1
  28. package/build/components/block-switcher/block-variation-transformations.js +125 -0
  29. package/build/components/block-switcher/block-variation-transformations.js.map +1 -0
  30. package/build/components/block-switcher/index.js +34 -12
  31. package/build/components/block-switcher/index.js.map +1 -1
  32. package/build/components/block-switcher/pattern-transformations-menu.js +3 -3
  33. package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  34. package/build/components/block-toolbar/index.js +9 -7
  35. package/build/components/block-toolbar/index.js.map +1 -1
  36. package/build/components/block-tools/block-contextual-toolbar.js +5 -3
  37. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  38. package/build/components/block-tools/insertion-point.js +11 -5
  39. package/build/components/block-tools/insertion-point.js.map +1 -1
  40. package/build/components/convert-to-group-buttons/index.js +7 -2
  41. package/build/components/convert-to-group-buttons/index.js.map +1 -1
  42. package/build/components/convert-to-group-buttons/index.native.js +87 -3
  43. package/build/components/convert-to-group-buttons/index.native.js.map +1 -1
  44. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +23 -37
  45. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  46. package/build/components/global-styles/dimensions-panel.js +3 -2
  47. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  48. package/build/components/iframe/index.js +14 -7
  49. package/build/components/iframe/index.js.map +1 -1
  50. package/build/components/inner-blocks/index.js +2 -1
  51. package/build/components/inner-blocks/index.js.map +1 -1
  52. package/build/components/inner-blocks/index.native.js +7 -7
  53. package/build/components/inner-blocks/index.native.js.map +1 -1
  54. package/build/components/inner-blocks/use-nested-settings-update.js +13 -5
  55. package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  56. package/build/components/inserter/index.js +3 -7
  57. package/build/components/inserter/index.js.map +1 -1
  58. package/build/components/inserter/quick-inserter.js +2 -4
  59. package/build/components/inserter/quick-inserter.js.map +1 -1
  60. package/build/components/inserter/search-results.js +19 -6
  61. package/build/components/inserter/search-results.js.map +1 -1
  62. package/build/components/list-view/appender.js +6 -1
  63. package/build/components/list-view/appender.js.map +1 -1
  64. package/build/components/list-view/block-contents.js +4 -2
  65. package/build/components/list-view/block-contents.js.map +1 -1
  66. package/build/components/list-view/block.js +21 -25
  67. package/build/components/list-view/block.js.map +1 -1
  68. package/build/components/list-view/branch.js +1 -3
  69. package/build/components/list-view/branch.js.map +1 -1
  70. package/build/components/list-view/index.js +14 -7
  71. package/build/components/list-view/index.js.map +1 -1
  72. package/build/components/list-view/use-list-view-client-ids.js +27 -3
  73. package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
  74. package/build/components/publish-date-time-picker/index.js +0 -2
  75. package/build/components/publish-date-time-picker/index.js.map +1 -1
  76. package/build/components/url-input/index.js +3 -0
  77. package/build/components/url-input/index.js.map +1 -1
  78. package/build/components/use-block-drop-zone/index.js +25 -15
  79. package/build/components/use-block-drop-zone/index.js.map +1 -1
  80. package/build/components/use-resize-canvas/index.js +8 -1
  81. package/build/components/use-resize-canvas/index.js.map +1 -1
  82. package/build/components/writing-flow/use-arrow-nav.js +13 -7
  83. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  84. package/build/hooks/align.js +3 -7
  85. package/build/hooks/align.js.map +1 -1
  86. package/build/hooks/behaviors.js +115 -0
  87. package/build/hooks/behaviors.js.map +1 -0
  88. package/build/hooks/dimensions.js +0 -30
  89. package/build/hooks/dimensions.js.map +1 -1
  90. package/build/hooks/duotone.js +4 -8
  91. package/build/hooks/duotone.js.map +1 -1
  92. package/build/hooks/index.js +2 -0
  93. package/build/hooks/index.js.map +1 -1
  94. package/build/hooks/layout.js +8 -9
  95. package/build/hooks/layout.js.map +1 -1
  96. package/build/private-apis.js +4 -7
  97. package/build/private-apis.js.map +1 -1
  98. package/build/store/private-actions.js +46 -0
  99. package/build/store/private-actions.js.map +1 -1
  100. package/build/store/private-selectors.js +88 -0
  101. package/build/store/private-selectors.js.map +1 -1
  102. package/build/store/reducer.js +36 -1
  103. package/build/store/reducer.js.map +1 -1
  104. package/build/store/selectors.js +28 -18
  105. package/build/store/selectors.js.map +1 -1
  106. package/build/utils/order-inserter-block-items.js +41 -0
  107. package/build/utils/order-inserter-block-items.js.map +1 -0
  108. package/build-module/autocompleters/block.js +12 -5
  109. package/build-module/autocompleters/block.js.map +1 -1
  110. package/build-module/components/block-breadcrumb/index.js +5 -3
  111. package/build-module/components/block-breadcrumb/index.js.map +1 -1
  112. package/build-module/components/block-editing-mode/index.js +72 -0
  113. package/build-module/components/block-editing-mode/index.js.map +1 -0
  114. package/build-module/components/block-list/block-list-block-context.js +6 -0
  115. package/build-module/components/block-list/block-list-block-context.js.map +1 -0
  116. package/build-module/components/block-list/block.js +26 -34
  117. package/build-module/components/block-list/block.js.map +1 -1
  118. package/build-module/components/block-list/block.native.js +14 -22
  119. package/build-module/components/block-list/block.native.js.map +1 -1
  120. package/build-module/components/block-list/index.native.js +108 -110
  121. package/build-module/components/block-list/index.native.js.map +1 -1
  122. package/build-module/components/block-list/use-block-props/index.js +1 -1
  123. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  124. package/build-module/components/block-list/use-in-between-inserter.js +6 -5
  125. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  126. package/build-module/components/block-list-appender/index.js +15 -1
  127. package/build-module/components/block-list-appender/index.js.map +1 -1
  128. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +18 -4
  129. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  130. package/build-module/components/block-styles/preview-panel.js +1 -2
  131. package/build-module/components/block-styles/preview-panel.js.map +1 -1
  132. package/build-module/components/block-switcher/block-transformations-menu.js +7 -0
  133. package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
  134. package/build-module/components/block-switcher/block-variation-transformations.js +108 -0
  135. package/build-module/components/block-switcher/block-variation-transformations.js.map +1 -0
  136. package/build-module/components/block-switcher/index.js +33 -12
  137. package/build-module/components/block-switcher/index.js.map +1 -1
  138. package/build-module/components/block-switcher/pattern-transformations-menu.js +3 -3
  139. package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  140. package/build-module/components/block-toolbar/index.js +8 -7
  141. package/build-module/components/block-toolbar/index.js.map +1 -1
  142. package/build-module/components/block-tools/block-contextual-toolbar.js +4 -3
  143. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  144. package/build-module/components/block-tools/insertion-point.js +11 -5
  145. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  146. package/build-module/components/convert-to-group-buttons/index.js +7 -2
  147. package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
  148. package/build-module/components/convert-to-group-buttons/index.native.js +76 -1
  149. package/build-module/components/convert-to-group-buttons/index.native.js.map +1 -1
  150. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +22 -36
  151. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  152. package/build-module/components/global-styles/dimensions-panel.js +3 -2
  153. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  154. package/build-module/components/iframe/index.js +15 -8
  155. package/build-module/components/iframe/index.js.map +1 -1
  156. package/build-module/components/inner-blocks/index.js +2 -1
  157. package/build-module/components/inner-blocks/index.js.map +1 -1
  158. package/build-module/components/inner-blocks/index.native.js +7 -6
  159. package/build-module/components/inner-blocks/index.native.js.map +1 -1
  160. package/build-module/components/inner-blocks/use-nested-settings-update.js +13 -5
  161. package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  162. package/build-module/components/inserter/index.js +3 -7
  163. package/build-module/components/inserter/index.js.map +1 -1
  164. package/build-module/components/inserter/quick-inserter.js +2 -4
  165. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  166. package/build-module/components/inserter/search-results.js +16 -6
  167. package/build-module/components/inserter/search-results.js.map +1 -1
  168. package/build-module/components/list-view/appender.js +6 -2
  169. package/build-module/components/list-view/appender.js.map +1 -1
  170. package/build-module/components/list-view/block-contents.js +4 -2
  171. package/build-module/components/list-view/block-contents.js.map +1 -1
  172. package/build-module/components/list-view/block.js +20 -25
  173. package/build-module/components/list-view/block.js.map +1 -1
  174. package/build-module/components/list-view/branch.js +1 -3
  175. package/build-module/components/list-view/branch.js.map +1 -1
  176. package/build-module/components/list-view/index.js +15 -8
  177. package/build-module/components/list-view/index.js.map +1 -1
  178. package/build-module/components/list-view/use-list-view-client-ids.js +26 -3
  179. package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
  180. package/build-module/components/publish-date-time-picker/index.js +0 -2
  181. package/build-module/components/publish-date-time-picker/index.js.map +1 -1
  182. package/build-module/components/url-input/index.js +3 -0
  183. package/build-module/components/url-input/index.js.map +1 -1
  184. package/build-module/components/use-block-drop-zone/index.js +25 -16
  185. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  186. package/build-module/components/use-resize-canvas/index.js +8 -1
  187. package/build-module/components/use-resize-canvas/index.js.map +1 -1
  188. package/build-module/components/writing-flow/use-arrow-nav.js +13 -7
  189. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  190. package/build-module/hooks/align.js +3 -6
  191. package/build-module/hooks/align.js.map +1 -1
  192. package/build-module/hooks/behaviors.js +97 -0
  193. package/build-module/hooks/behaviors.js.map +1 -0
  194. package/build-module/hooks/dimensions.js +0 -28
  195. package/build-module/hooks/dimensions.js.map +1 -1
  196. package/build-module/hooks/duotone.js +3 -6
  197. package/build-module/hooks/duotone.js.map +1 -1
  198. package/build-module/hooks/index.js +1 -0
  199. package/build-module/hooks/index.js.map +1 -1
  200. package/build-module/hooks/layout.js +7 -9
  201. package/build-module/hooks/layout.js.map +1 -1
  202. package/build-module/private-apis.js +3 -5
  203. package/build-module/private-apis.js.map +1 -1
  204. package/build-module/store/private-actions.js +42 -0
  205. package/build-module/store/private-actions.js.map +1 -1
  206. package/build-module/store/private-selectors.js +79 -0
  207. package/build-module/store/private-selectors.js.map +1 -1
  208. package/build-module/store/reducer.js +34 -1
  209. package/build-module/store/reducer.js.map +1 -1
  210. package/build-module/store/selectors.js +26 -17
  211. package/build-module/store/selectors.js.map +1 -1
  212. package/build-module/utils/order-inserter-block-items.js +32 -0
  213. package/build-module/utils/order-inserter-block-items.js.map +1 -0
  214. package/build-style/content-rtl.css +32 -13
  215. package/build-style/content.css +32 -13
  216. package/build-style/default-editor-styles-rtl.css +1 -1
  217. package/build-style/default-editor-styles.css +1 -1
  218. package/build-style/style-rtl.css +19 -64
  219. package/build-style/style.css +20 -64
  220. package/package.json +32 -31
  221. package/src/autocompleters/block.js +15 -7
  222. package/src/components/block-breadcrumb/index.js +11 -3
  223. package/src/components/block-editing-mode/index.js +71 -0
  224. package/src/components/block-list/block-list-block-context.js +6 -0
  225. package/src/components/block-list/block.js +38 -56
  226. package/src/components/block-list/block.native.js +30 -41
  227. package/src/components/block-list/content.scss +5 -5
  228. package/src/components/block-list/index.native.js +164 -153
  229. package/src/components/block-list/test/index.native.js +2 -2
  230. package/src/components/block-list/use-block-props/index.js +1 -1
  231. package/src/components/block-list/use-in-between-inserter.js +7 -3
  232. package/src/components/block-list-appender/index.js +22 -4
  233. package/src/components/block-mobile-toolbar/block-actions-menu.native.js +23 -0
  234. package/src/components/block-mover/style.scss +1 -0
  235. package/src/components/block-styles/preview-panel.js +1 -3
  236. package/src/components/block-switcher/block-transformations-menu.js +12 -0
  237. package/src/components/block-switcher/block-variation-transformations.js +115 -0
  238. package/src/components/block-switcher/index.js +38 -5
  239. package/src/components/block-switcher/pattern-transformations-menu.js +5 -5
  240. package/src/components/block-switcher/style.scss +6 -5
  241. package/src/components/block-toolbar/index.js +10 -11
  242. package/src/components/block-tools/block-contextual-toolbar.js +4 -5
  243. package/src/components/block-tools/insertion-point.js +23 -9
  244. package/src/components/button-block-appender/content.scss +22 -0
  245. package/src/components/convert-to-group-buttons/index.js +9 -2
  246. package/src/components/convert-to-group-buttons/index.native.js +79 -1
  247. package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +32 -38
  248. package/src/components/global-styles/dimensions-panel.js +3 -2
  249. package/src/components/global-styles/style.scss +3 -0
  250. package/src/components/iframe/index.js +22 -12
  251. package/src/components/inner-blocks/README.md +5 -0
  252. package/src/components/inner-blocks/index.js +2 -0
  253. package/src/components/inner-blocks/index.native.js +16 -6
  254. package/src/components/inner-blocks/use-nested-settings-update.js +20 -3
  255. package/src/components/inserter/index.js +1 -9
  256. package/src/components/inserter/quick-inserter.js +0 -2
  257. package/src/components/inserter/search-results.js +32 -6
  258. package/src/components/list-view/appender.js +3 -2
  259. package/src/components/list-view/block-contents.js +8 -2
  260. package/src/components/list-view/block.js +29 -35
  261. package/src/components/list-view/branch.js +1 -7
  262. package/src/components/list-view/index.js +17 -4
  263. package/src/components/list-view/style.scss +2 -5
  264. package/src/components/list-view/use-list-view-client-ids.js +21 -4
  265. package/src/components/publish-date-time-picker/index.js +0 -2
  266. package/src/components/url-input/README.md +6 -0
  267. package/src/components/url-input/index.js +1 -0
  268. package/src/components/use-block-drop-zone/index.js +31 -17
  269. package/src/components/use-resize-canvas/index.js +9 -1
  270. package/src/components/writing-flow/test/index.js +15 -0
  271. package/src/components/writing-flow/use-arrow-nav.js +17 -4
  272. package/src/hooks/align.js +3 -11
  273. package/src/hooks/behaviors.js +104 -0
  274. package/src/hooks/dimensions.js +0 -40
  275. package/src/hooks/duotone.js +3 -11
  276. package/src/hooks/index.js +1 -0
  277. package/src/hooks/layout.js +10 -18
  278. package/src/private-apis.js +2 -4
  279. package/src/store/private-actions.js +39 -0
  280. package/src/store/private-selectors.js +95 -0
  281. package/src/store/reducer.js +27 -0
  282. package/src/store/selectors.js +25 -15
  283. package/src/store/test/private-actions.js +32 -1
  284. package/src/store/test/private-selectors.js +158 -0
  285. package/src/store/test/reducer.js +48 -0
  286. package/src/style.scss +0 -3
  287. package/src/utils/order-inserter-block-items.js +26 -0
  288. package/build/components/block-list/block-list-compact.native.js +0 -75
  289. package/build/components/block-list/block-list-compact.native.js.map +0 -1
  290. package/build/components/off-canvas-editor/appender.js +0 -125
  291. package/build/components/off-canvas-editor/appender.js.map +0 -1
  292. package/build/components/off-canvas-editor/block-contents.js +0 -141
  293. package/build/components/off-canvas-editor/block-contents.js.map +0 -1
  294. package/build/components/off-canvas-editor/block-select-button.js +0 -126
  295. package/build/components/off-canvas-editor/block-select-button.js.map +0 -1
  296. package/build/components/off-canvas-editor/block.js +0 -297
  297. package/build/components/off-canvas-editor/block.js.map +0 -1
  298. package/build/components/off-canvas-editor/branch.js +0 -197
  299. package/build/components/off-canvas-editor/branch.js.map +0 -1
  300. package/build/components/off-canvas-editor/context.js +0 -19
  301. package/build/components/off-canvas-editor/context.js.map +0 -1
  302. package/build/components/off-canvas-editor/drop-indicator.js +0 -118
  303. package/build/components/off-canvas-editor/drop-indicator.js.map +0 -1
  304. package/build/components/off-canvas-editor/expander.js +0 -41
  305. package/build/components/off-canvas-editor/expander.js.map +0 -1
  306. package/build/components/off-canvas-editor/index.js +0 -236
  307. package/build/components/off-canvas-editor/index.js.map +0 -1
  308. package/build/components/off-canvas-editor/leaf-more-menu.js +0 -148
  309. package/build/components/off-canvas-editor/leaf-more-menu.js.map +0 -1
  310. package/build/components/off-canvas-editor/leaf.js +0 -60
  311. package/build/components/off-canvas-editor/leaf.js.map +0 -1
  312. package/build/components/off-canvas-editor/link-ui.js +0 -186
  313. package/build/components/off-canvas-editor/link-ui.js.map +0 -1
  314. package/build/components/off-canvas-editor/update-attributes.js +0 -108
  315. package/build/components/off-canvas-editor/update-attributes.js.map +0 -1
  316. package/build/components/off-canvas-editor/use-block-selection.js +0 -139
  317. package/build/components/off-canvas-editor/use-block-selection.js.map +0 -1
  318. package/build/components/off-canvas-editor/use-inserted-block.js +0 -58
  319. package/build/components/off-canvas-editor/use-inserted-block.js.map +0 -1
  320. package/build/components/off-canvas-editor/use-list-view-client-ids.js +0 -33
  321. package/build/components/off-canvas-editor/use-list-view-client-ids.js.map +0 -1
  322. package/build/components/off-canvas-editor/use-list-view-drop-zone.js +0 -235
  323. package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +0 -1
  324. package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js +0 -60
  325. package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +0 -1
  326. package/build/components/off-canvas-editor/utils.js +0 -60
  327. package/build/components/off-canvas-editor/utils.js.map +0 -1
  328. package/build-module/components/block-list/block-list-compact.native.js +0 -60
  329. package/build-module/components/block-list/block-list-compact.native.js.map +0 -1
  330. package/build-module/components/off-canvas-editor/appender.js +0 -108
  331. package/build-module/components/off-canvas-editor/appender.js.map +0 -1
  332. package/build-module/components/off-canvas-editor/block-contents.js +0 -121
  333. package/build-module/components/off-canvas-editor/block-contents.js.map +0 -1
  334. package/build-module/components/off-canvas-editor/block-select-button.js +0 -107
  335. package/build-module/components/off-canvas-editor/block-select-button.js.map +0 -1
  336. package/build-module/components/off-canvas-editor/block.js +0 -273
  337. package/build-module/components/off-canvas-editor/block.js.map +0 -1
  338. package/build-module/components/off-canvas-editor/branch.js +0 -179
  339. package/build-module/components/off-canvas-editor/branch.js.map +0 -1
  340. package/build-module/components/off-canvas-editor/context.js +0 -7
  341. package/build-module/components/off-canvas-editor/context.js.map +0 -1
  342. package/build-module/components/off-canvas-editor/drop-indicator.js +0 -111
  343. package/build-module/components/off-canvas-editor/drop-indicator.js.map +0 -1
  344. package/build-module/components/off-canvas-editor/expander.js +0 -32
  345. package/build-module/components/off-canvas-editor/expander.js.map +0 -1
  346. package/build-module/components/off-canvas-editor/index.js +0 -213
  347. package/build-module/components/off-canvas-editor/index.js.map +0 -1
  348. package/build-module/components/off-canvas-editor/leaf-more-menu.js +0 -130
  349. package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +0 -1
  350. package/build-module/components/off-canvas-editor/leaf.js +0 -45
  351. package/build-module/components/off-canvas-editor/leaf.js.map +0 -1
  352. package/build-module/components/off-canvas-editor/link-ui.js +0 -166
  353. package/build-module/components/off-canvas-editor/link-ui.js.map +0 -1
  354. package/build-module/components/off-canvas-editor/update-attributes.js +0 -97
  355. package/build-module/components/off-canvas-editor/update-attributes.js.map +0 -1
  356. package/build-module/components/off-canvas-editor/use-block-selection.js +0 -124
  357. package/build-module/components/off-canvas-editor/use-block-selection.js.map +0 -1
  358. package/build-module/components/off-canvas-editor/use-inserted-block.js +0 -47
  359. package/build-module/components/off-canvas-editor/use-inserted-block.js.map +0 -1
  360. package/build-module/components/off-canvas-editor/use-list-view-client-ids.js +0 -24
  361. package/build-module/components/off-canvas-editor/use-list-view-client-ids.js.map +0 -1
  362. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +0 -220
  363. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +0 -1
  364. package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js +0 -50
  365. package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +0 -1
  366. package/build-module/components/off-canvas-editor/utils.js +0 -44
  367. package/build-module/components/off-canvas-editor/utils.js.map +0 -1
  368. package/src/components/block-list/block-list-compact.native.js +0 -63
  369. package/src/components/off-canvas-editor/README.md +0 -5
  370. package/src/components/off-canvas-editor/appender.js +0 -124
  371. package/src/components/off-canvas-editor/block-contents.js +0 -156
  372. package/src/components/off-canvas-editor/block-select-button.js +0 -128
  373. package/src/components/off-canvas-editor/block.js +0 -347
  374. package/src/components/off-canvas-editor/branch.js +0 -238
  375. package/src/components/off-canvas-editor/context.js +0 -8
  376. package/src/components/off-canvas-editor/drop-indicator.js +0 -126
  377. package/src/components/off-canvas-editor/expander.js +0 -26
  378. package/src/components/off-canvas-editor/index.js +0 -271
  379. package/src/components/off-canvas-editor/leaf-more-menu.js +0 -158
  380. package/src/components/off-canvas-editor/leaf.js +0 -52
  381. package/src/components/off-canvas-editor/link-ui.js +0 -167
  382. package/src/components/off-canvas-editor/style.scss +0 -34
  383. package/src/components/off-canvas-editor/test/use-inserted-block.js +0 -108
  384. package/src/components/off-canvas-editor/test/utils.js +0 -50
  385. package/src/components/off-canvas-editor/update-attributes.js +0 -99
  386. package/src/components/off-canvas-editor/use-block-selection.js +0 -169
  387. package/src/components/off-canvas-editor/use-inserted-block.js +0 -47
  388. package/src/components/off-canvas-editor/use-list-view-client-ids.js +0 -29
  389. package/src/components/off-canvas-editor/use-list-view-drop-zone.js +0 -260
  390. package/src/components/off-canvas-editor/use-list-view-expand-selected-item.js +0 -58
  391. package/src/components/off-canvas-editor/utils.js +0 -58
@@ -1,139 +0,0 @@
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
@@ -1 +0,0 @@
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,iBANK;AAOLC,IAAAA;AAPK,MAQF,qBAAWP,YAAX,CARJ;AAUA,QAAM;AAAEQ,IAAAA;AAAF,MAAmB,qBAAWC,aAAX,CAAzB;AAEA,QAAMC,oBAAoB,GAAG,0BAC5B,OAAQC,KAAR,EAAeC,QAAf,EAAyBC,mBAAzB,KAAkD;AACj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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"]}
@@ -1,58 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useInsertedBlock = void 0;
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
- const useInsertedBlock = insertedBlockClientId => {
20
- const {
21
- insertedBlockAttributes,
22
- insertedBlockName
23
- } = (0, _data.useSelect)(select => {
24
- const {
25
- getBlockName,
26
- getBlockAttributes
27
- } = select(_store.store);
28
- return {
29
- insertedBlockAttributes: getBlockAttributes(insertedBlockClientId),
30
- insertedBlockName: getBlockName(insertedBlockClientId)
31
- };
32
- }, [insertedBlockClientId]);
33
- const {
34
- updateBlockAttributes
35
- } = (0, _data.useDispatch)(_store.store);
36
-
37
- const setInsertedBlockAttributes = _updatedAttributes => {
38
- if (!insertedBlockClientId) return;
39
- updateBlockAttributes(insertedBlockClientId, _updatedAttributes);
40
- };
41
-
42
- if (!insertedBlockClientId) {
43
- return {
44
- insertedBlockAttributes: undefined,
45
- insertedBlockName: undefined,
46
- setInsertedBlockAttributes
47
- };
48
- }
49
-
50
- return {
51
- insertedBlockAttributes,
52
- insertedBlockName,
53
- setInsertedBlockAttributes
54
- };
55
- };
56
-
57
- exports.useInsertedBlock = useInsertedBlock;
58
- //# sourceMappingURL=use-inserted-block.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/use-inserted-block.js"],"names":["useInsertedBlock","insertedBlockClientId","insertedBlockAttributes","insertedBlockName","select","getBlockName","getBlockAttributes","blockEditorStore","updateBlockAttributes","setInsertedBlockAttributes","_updatedAttributes","undefined"],"mappings":";;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAGO,MAAMA,gBAAgB,GAAKC,qBAAF,IAA6B;AAC5D,QAAM;AAAEC,IAAAA,uBAAF;AAA2BC,IAAAA;AAA3B,MAAiD,qBACpDC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,YAAF;AAAgBC,MAAAA;AAAhB,QACLF,MAAM,CAAEG,YAAF,CADP;AAGA,WAAO;AACNL,MAAAA,uBAAuB,EAAEI,kBAAkB,CAC1CL,qBAD0C,CADrC;AAINE,MAAAA,iBAAiB,EAAEE,YAAY,CAAEJ,qBAAF;AAJzB,KAAP;AAMA,GAXqD,EAYtD,CAAEA,qBAAF,CAZsD,CAAvD;AAeA,QAAM;AAAEO,IAAAA;AAAF,MAA4B,uBAAaD,YAAb,CAAlC;;AAEA,QAAME,0BAA0B,GAAKC,kBAAF,IAA0B;AAC5D,QAAK,CAAET,qBAAP,EAA+B;AAC/BO,IAAAA,qBAAqB,CAAEP,qBAAF,EAAyBS,kBAAzB,CAArB;AACA,GAHD;;AAKA,MAAK,CAAET,qBAAP,EAA+B;AAC9B,WAAO;AACNC,MAAAA,uBAAuB,EAAES,SADnB;AAENR,MAAAA,iBAAiB,EAAEQ,SAFb;AAGNF,MAAAA;AAHM,KAAP;AAKA;;AAED,SAAO;AACNP,IAAAA,uBADM;AAENC,IAAAA,iBAFM;AAGNM,IAAAA;AAHM,GAAP;AAKA,CApCM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nexport const useInsertedBlock = ( insertedBlockClientId ) => {\n\tconst { insertedBlockAttributes, insertedBlockName } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockName, getBlockAttributes } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\tinsertedBlockAttributes: getBlockAttributes(\n\t\t\t\t\tinsertedBlockClientId\n\t\t\t\t),\n\t\t\t\tinsertedBlockName: getBlockName( insertedBlockClientId ),\n\t\t\t};\n\t\t},\n\t\t[ insertedBlockClientId ]\n\t);\n\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\tconst setInsertedBlockAttributes = ( _updatedAttributes ) => {\n\t\tif ( ! insertedBlockClientId ) return;\n\t\tupdateBlockAttributes( insertedBlockClientId, _updatedAttributes );\n\t};\n\n\tif ( ! insertedBlockClientId ) {\n\t\treturn {\n\t\t\tinsertedBlockAttributes: undefined,\n\t\t\tinsertedBlockName: undefined,\n\t\t\tsetInsertedBlockAttributes,\n\t\t};\n\t}\n\n\treturn {\n\t\tinsertedBlockAttributes,\n\t\tinsertedBlockName,\n\t\tsetInsertedBlockAttributes,\n\t};\n};\n"]}
@@ -1,33 +0,0 @@
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
@@ -1 +0,0 @@
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"]}
@@ -1,235 +0,0 @@
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 | undefined} 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
@@ -1 +0,0 @@
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;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;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AA,+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 | undefined} 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"]}
@@ -1,60 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = useListViewExpandSelectedItem;
7
-
8
- var _element = require("@wordpress/element");
9
-
10
- var _data = require("@wordpress/data");
11
-
12
- var _store = require("../../store");
13
-
14
- /**
15
- * WordPress dependencies
16
- */
17
-
18
- /**
19
- * Internal dependencies
20
- */
21
- function useListViewExpandSelectedItem(_ref) {
22
- let {
23
- firstSelectedBlockClientId,
24
- setExpandedState
25
- } = _ref;
26
- const [selectedTreeId, setSelectedTreeId] = (0, _element.useState)(null);
27
- const {
28
- selectedBlockParentClientIds
29
- } = (0, _data.useSelect)(select => {
30
- const {
31
- getBlockParents
32
- } = select(_store.store);
33
- return {
34
- selectedBlockParentClientIds: getBlockParents(firstSelectedBlockClientId, false)
35
- };
36
- }, [firstSelectedBlockClientId]);
37
- const parentClientIds = Array.isArray(selectedBlockParentClientIds) && selectedBlockParentClientIds.length ? selectedBlockParentClientIds : null; // Expand tree when a block is selected.
38
-
39
- (0, _element.useEffect)(() => {
40
- // If the selectedTreeId is the same as the selected block,
41
- // it means that the block was selected using the block list tree.
42
- if (selectedTreeId === firstSelectedBlockClientId) {
43
- return;
44
- } // If the selected block has parents, get the top-level parent.
45
-
46
-
47
- if (parentClientIds) {
48
- // If the selected block has parents,
49
- // expand the tree branch.
50
- setExpandedState({
51
- type: 'expand',
52
- clientIds: selectedBlockParentClientIds
53
- });
54
- }
55
- }, [firstSelectedBlockClientId]);
56
- return {
57
- setSelectedTreeId
58
- };
59
- }
60
- //# sourceMappingURL=use-list-view-expand-selected-item.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/use-list-view-expand-selected-item.js"],"names":["useListViewExpandSelectedItem","firstSelectedBlockClientId","setExpandedState","selectedTreeId","setSelectedTreeId","selectedBlockParentClientIds","select","getBlockParents","blockEditorStore","parentClientIds","Array","isArray","length","type","clientIds"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAGe,SAASA,6BAAT,OAGX;AAAA,MAHmD;AACtDC,IAAAA,0BADsD;AAEtDC,IAAAA;AAFsD,GAGnD;AACH,QAAM,CAAEC,cAAF,EAAkBC,iBAAlB,IAAwC,uBAAU,IAAV,CAA9C;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAmC,qBACtCC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA;AAAF,QAAsBD,MAAM,CAAEE,YAAF,CAAlC;AACA,WAAO;AACNH,MAAAA,4BAA4B,EAAEE,eAAe,CAC5CN,0BAD4C,EAE5C,KAF4C;AADvC,KAAP;AAMA,GATuC,EAUxC,CAAEA,0BAAF,CAVwC,CAAzC;AAaA,QAAMQ,eAAe,GACpBC,KAAK,CAACC,OAAN,CAAeN,4BAAf,KACAA,4BAA4B,CAACO,MAD7B,GAEGP,4BAFH,GAGG,IAJJ,CAfG,CAqBH;;AACA,0BAAW,MAAM;AAChB;AACA;AACA,QAAKF,cAAc,KAAKF,0BAAxB,EAAqD;AACpD;AACA,KALe,CAOhB;;;AACA,QAAKQ,eAAL,EAAuB;AACtB;AACA;AACAP,MAAAA,gBAAgB,CAAE;AACjBW,QAAAA,IAAI,EAAE,QADW;AAEjBC,QAAAA,SAAS,EAAET;AAFM,OAAF,CAAhB;AAIA;AACD,GAhBD,EAgBG,CAAEJ,0BAAF,CAhBH;AAkBA,SAAO;AACNG,IAAAA;AADM,GAAP;AAGA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nexport default function useListViewExpandSelectedItem( {\n\tfirstSelectedBlockClientId,\n\tsetExpandedState,\n} ) {\n\tconst [ selectedTreeId, setSelectedTreeId ] = useState( null );\n\tconst { selectedBlockParentClientIds } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockParents } = select( blockEditorStore );\n\t\t\treturn {\n\t\t\t\tselectedBlockParentClientIds: getBlockParents(\n\t\t\t\t\tfirstSelectedBlockClientId,\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ firstSelectedBlockClientId ]\n\t);\n\n\tconst parentClientIds =\n\t\tArray.isArray( selectedBlockParentClientIds ) &&\n\t\tselectedBlockParentClientIds.length\n\t\t\t? selectedBlockParentClientIds\n\t\t\t: null;\n\n\t// Expand tree when a block is selected.\n\tuseEffect( () => {\n\t\t// If the selectedTreeId is the same as the selected block,\n\t\t// it means that the block was selected using the block list tree.\n\t\tif ( selectedTreeId === firstSelectedBlockClientId ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If the selected block has parents, get the top-level parent.\n\t\tif ( parentClientIds ) {\n\t\t\t// If the selected block has parents,\n\t\t\t// expand the tree branch.\n\t\t\tsetExpandedState( {\n\t\t\t\ttype: 'expand',\n\t\t\t\tclientIds: selectedBlockParentClientIds,\n\t\t\t} );\n\t\t}\n\t}, [ firstSelectedBlockClientId ] );\n\n\treturn {\n\t\tsetSelectedTreeId,\n\t};\n}\n"]}
@@ -1,60 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getBlockPositionDescription = void 0;
7
- exports.getCommonDepthClientIds = getCommonDepthClientIds;
8
- exports.isClientIdSelected = void 0;
9
-
10
- var _i18n = require("@wordpress/i18n");
11
-
12
- /**
13
- * WordPress dependencies
14
- */
15
- const getBlockPositionDescription = (position, siblingCount, level) => (0, _i18n.sprintf)(
16
- /* translators: 1: The numerical position of the block. 2: The total number of blocks. 3. The level of nesting for the block. */
17
- (0, _i18n.__)('Block %1$d of %2$d, Level %3$d'), position, siblingCount, level);
18
- /**
19
- * Returns true if the client ID occurs within the block selection or multi-selection,
20
- * or false otherwise.
21
- *
22
- * @param {string} clientId Block client ID.
23
- * @param {string|string[]} selectedBlockClientIds Selected block client ID, or an array of multi-selected blocks client IDs.
24
- *
25
- * @return {boolean} Whether the block is in multi-selection set.
26
- */
27
-
28
-
29
- exports.getBlockPositionDescription = getBlockPositionDescription;
30
-
31
- const isClientIdSelected = (clientId, selectedBlockClientIds) => Array.isArray(selectedBlockClientIds) && selectedBlockClientIds.length ? selectedBlockClientIds.indexOf(clientId) !== -1 : selectedBlockClientIds === clientId;
32
- /**
33
- * From a start and end clientId of potentially different nesting levels,
34
- * return the nearest-depth ids that have a common level of depth in the
35
- * nesting hierarchy. For multiple block selection, this ensure that the
36
- * selection is always at the same nesting level, and not split across
37
- * separate levels.
38
- *
39
- * @param {string} startId The first id of a selection.
40
- * @param {string} endId The end id of a selection, usually one that has been clicked on.
41
- * @param {string[]} startParents An array of ancestor ids for the start id, in descending order.
42
- * @param {string[]} endParents An array of ancestor ids for the end id, in descending order.
43
- * @return {Object} An object containing the start and end ids.
44
- */
45
-
46
-
47
- exports.isClientIdSelected = isClientIdSelected;
48
-
49
- function getCommonDepthClientIds(startId, endId, startParents, endParents) {
50
- const startPath = [...startParents, startId];
51
- const endPath = [...endParents, endId];
52
- const depth = Math.min(startPath.length, endPath.length) - 1;
53
- const start = startPath[depth];
54
- const end = endPath[depth];
55
- return {
56
- start,
57
- end
58
- };
59
- }
60
- //# sourceMappingURL=utils.js.map