@wordpress/block-editor 12.0.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 (627) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/build/autocompleters/block.js +13 -5
  4. package/build/autocompleters/block.js.map +1 -1
  5. package/build/components/block-breadcrumb/index.js +6 -3
  6. package/build/components/block-breadcrumb/index.js.map +1 -1
  7. package/build/components/block-controls/slot.js +12 -4
  8. package/build/components/block-controls/slot.js.map +1 -1
  9. package/build/components/block-controls/slot.native.js +10 -1
  10. package/build/components/block-controls/slot.native.js.map +1 -1
  11. package/build/components/block-draggable/index.js +11 -7
  12. package/build/components/block-draggable/index.js.map +1 -1
  13. package/build/components/block-draggable/use-scroll-when-dragging.js +2 -2
  14. package/build/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
  15. package/build/components/block-editing-mode/index.js +84 -0
  16. package/build/components/block-editing-mode/index.js.map +1 -0
  17. package/build/components/block-list/block-invalid-warning.native.js +15 -7
  18. package/build/components/block-list/block-invalid-warning.native.js.map +1 -1
  19. package/build/components/block-list/block-list-block-context.js +15 -0
  20. package/build/components/block-list/block-list-block-context.js.map +1 -0
  21. package/build/components/block-list/block-list-item-cell.native.js +15 -2
  22. package/build/components/block-list/block-list-item-cell.native.js.map +1 -1
  23. package/build/components/block-list/block-list-item.native.js +158 -195
  24. package/build/components/block-list/block-list-item.native.js.map +1 -1
  25. package/build/components/block-list/block-outline.native.js +57 -0
  26. package/build/components/block-list/block-outline.native.js.map +1 -0
  27. package/build/components/block-list/block.js +29 -37
  28. package/build/components/block-list/block.js.map +1 -1
  29. package/build/components/block-list/block.native.js +347 -311
  30. package/build/components/block-list/block.native.js.map +1 -1
  31. package/build/components/block-list/index.native.js +260 -357
  32. package/build/components/block-list/index.native.js.map +1 -1
  33. package/build/components/block-list/insertion-point.native.js +4 -2
  34. package/build/components/block-list/insertion-point.native.js.map +1 -1
  35. package/build/components/block-list/use-block-props/index.js +2 -2
  36. package/build/components/block-list/use-block-props/index.js.map +1 -1
  37. package/build/components/block-list/use-in-between-inserter.js +7 -5
  38. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  39. package/build/components/block-list-appender/index.js +15 -1
  40. package/build/components/block-list-appender/index.js.map +1 -1
  41. package/build/components/block-mobile-toolbar/block-actions-menu.native.js +19 -4
  42. package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  43. package/build/components/block-settings-menu/block-settings-dropdown.js +8 -10
  44. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  45. package/build/components/block-settings-menu-controls/index.js +15 -4
  46. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  47. package/build/components/block-styles/preview-panel.js +1 -2
  48. package/build/components/block-styles/preview-panel.js.map +1 -1
  49. package/build/components/block-switcher/block-transformations-menu.js +8 -0
  50. package/build/components/block-switcher/block-transformations-menu.js.map +1 -1
  51. package/build/components/block-switcher/block-variation-transformations.js +125 -0
  52. package/build/components/block-switcher/block-variation-transformations.js.map +1 -0
  53. package/build/components/block-switcher/index.js +34 -12
  54. package/build/components/block-switcher/index.js.map +1 -1
  55. package/build/components/block-switcher/pattern-transformations-menu.js +3 -3
  56. package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  57. package/build/components/block-toolbar/index.js +9 -7
  58. package/build/components/block-toolbar/index.js.map +1 -1
  59. package/build/components/block-tools/block-contextual-toolbar.js +22 -65
  60. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  61. package/build/components/block-tools/insertion-point.js +11 -5
  62. package/build/components/block-tools/insertion-point.js.map +1 -1
  63. package/build/components/block-tools/selected-block-popover.js +3 -8
  64. package/build/components/block-tools/selected-block-popover.js.map +1 -1
  65. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +3 -2
  66. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
  67. package/build/components/convert-to-group-buttons/index.js +7 -2
  68. package/build/components/convert-to-group-buttons/index.js.map +1 -1
  69. package/build/components/convert-to-group-buttons/index.native.js +87 -3
  70. package/build/components/convert-to-group-buttons/index.native.js.map +1 -1
  71. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +23 -37
  72. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  73. package/build/components/global-styles/advanced-panel.js +86 -0
  74. package/build/components/global-styles/advanced-panel.js.map +1 -0
  75. package/build/components/global-styles/color-panel.js +4 -1
  76. package/build/components/global-styles/color-panel.js.map +1 -1
  77. package/build/components/global-styles/dimensions-panel.js +9 -8
  78. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  79. package/build/components/global-styles/hooks.js +1 -2
  80. package/build/components/global-styles/hooks.js.map +1 -1
  81. package/build/components/global-styles/index.js +24 -0
  82. package/build/components/global-styles/index.js.map +1 -1
  83. package/build/components/global-styles/typography-panel.js +1 -1
  84. package/build/components/global-styles/typography-panel.js.map +1 -1
  85. package/build/components/global-styles/use-global-styles-output.js +27 -4
  86. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  87. package/build/components/global-styles/utils.js +30 -0
  88. package/build/components/global-styles/utils.js.map +1 -1
  89. package/build/components/iframe/index.js +14 -7
  90. package/build/components/iframe/index.js.map +1 -1
  91. package/build/components/image-editor/use-save-image.js +24 -8
  92. package/build/components/image-editor/use-save-image.js.map +1 -1
  93. package/build/components/inner-blocks/index.js +2 -1
  94. package/build/components/inner-blocks/index.js.map +1 -1
  95. package/build/components/inner-blocks/index.native.js +7 -7
  96. package/build/components/inner-blocks/index.native.js.map +1 -1
  97. package/build/components/inner-blocks/use-nested-settings-update.js +13 -5
  98. package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  99. package/build/components/inserter/index.js +3 -7
  100. package/build/components/inserter/index.js.map +1 -1
  101. package/build/components/inserter/quick-inserter.js +2 -4
  102. package/build/components/inserter/quick-inserter.js.map +1 -1
  103. package/build/components/inserter/search-results.js +19 -6
  104. package/build/components/inserter/search-results.js.map +1 -1
  105. package/build/components/inserter-draggable-blocks/index.js +5 -0
  106. package/build/components/inserter-draggable-blocks/index.js.map +1 -1
  107. package/build/components/inspector-controls/fill.js +1 -1
  108. package/build/components/inspector-controls/fill.js.map +1 -1
  109. package/build/components/inspector-controls/fill.native.js +1 -1
  110. package/build/components/inspector-controls/fill.native.js.map +1 -1
  111. package/build/components/inspector-controls/slot.js +3 -6
  112. package/build/components/inspector-controls/slot.js.map +1 -1
  113. package/build/components/inspector-controls/slot.native.js +1 -1
  114. package/build/components/inspector-controls/slot.native.js.map +1 -1
  115. package/build/components/line-height-control/index.js +7 -2
  116. package/build/components/line-height-control/index.js.map +1 -1
  117. package/build/components/link-control/use-internal-input-value.js +9 -8
  118. package/build/components/link-control/use-internal-input-value.js.map +1 -1
  119. package/build/components/list-view/appender.js +6 -1
  120. package/build/components/list-view/appender.js.map +1 -1
  121. package/build/components/list-view/block-contents.js +9 -2
  122. package/build/components/list-view/block-contents.js.map +1 -1
  123. package/build/components/list-view/block-select-button.js +2 -1
  124. package/build/components/list-view/block-select-button.js.map +1 -1
  125. package/build/components/list-view/block.js +25 -29
  126. package/build/components/list-view/block.js.map +1 -1
  127. package/build/components/list-view/branch.js +1 -3
  128. package/build/components/list-view/branch.js.map +1 -1
  129. package/build/components/list-view/index.js +43 -22
  130. package/build/components/list-view/index.js.map +1 -1
  131. package/build/components/list-view/use-list-view-client-ids.js +27 -3
  132. package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
  133. package/build/components/list-view/use-list-view-drop-zone.js +163 -11
  134. package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
  135. package/build/components/media-placeholder/index.js +68 -7
  136. package/build/components/media-placeholder/index.js.map +1 -1
  137. package/build/components/multi-selection-inspector/index.js +2 -2
  138. package/build/components/multi-selection-inspector/index.js.map +1 -1
  139. package/build/components/preview-options/index.js +6 -1
  140. package/build/components/preview-options/index.js.map +1 -1
  141. package/build/components/publish-date-time-picker/index.js +0 -2
  142. package/build/components/publish-date-time-picker/index.js.map +1 -1
  143. package/build/components/spacing-sizes-control/spacing-input-control.js +1 -1
  144. package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  145. package/build/components/url-input/index.js +4 -2
  146. package/build/components/url-input/index.js.map +1 -1
  147. package/build/components/use-block-drop-zone/index.js +25 -15
  148. package/build/components/use-block-drop-zone/index.js.map +1 -1
  149. package/build/components/use-resize-canvas/index.js +8 -1
  150. package/build/components/use-resize-canvas/index.js.map +1 -1
  151. package/build/components/writing-flow/use-arrow-nav.js +13 -7
  152. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  153. package/build/hooks/align.js +4 -8
  154. package/build/hooks/align.js.map +1 -1
  155. package/build/hooks/behaviors.js +115 -0
  156. package/build/hooks/behaviors.js.map +1 -0
  157. package/build/hooks/border.js +1 -1
  158. package/build/hooks/border.js.map +1 -1
  159. package/build/hooks/color.js +1 -1
  160. package/build/hooks/color.js.map +1 -1
  161. package/build/hooks/content-lock-ui.js +8 -12
  162. package/build/hooks/content-lock-ui.js.map +1 -1
  163. package/build/hooks/dimensions.js +0 -30
  164. package/build/hooks/dimensions.js.map +1 -1
  165. package/build/hooks/duotone.js +5 -9
  166. package/build/hooks/duotone.js.map +1 -1
  167. package/build/hooks/index.js +2 -0
  168. package/build/hooks/index.js.map +1 -1
  169. package/build/hooks/index.native.js +8 -0
  170. package/build/hooks/index.native.js.map +1 -1
  171. package/build/hooks/layout.js +10 -11
  172. package/build/hooks/layout.js.map +1 -1
  173. package/build/hooks/position.js +1 -1
  174. package/build/hooks/position.js.map +1 -1
  175. package/build/hooks/style.js +1 -1
  176. package/build/hooks/style.js.map +1 -1
  177. package/build/hooks/use-editor-wrapper-styles.native.js +255 -0
  178. package/build/hooks/use-editor-wrapper-styles.native.js.map +1 -0
  179. package/build/hooks/use-typography-props.js +14 -10
  180. package/build/hooks/use-typography-props.js.map +1 -1
  181. package/build/index.native.js +31 -0
  182. package/build/index.native.js.map +1 -0
  183. package/build/private-apis.js +4 -7
  184. package/build/private-apis.js.map +1 -1
  185. package/build/store/private-actions.js +46 -0
  186. package/build/store/private-actions.js.map +1 -1
  187. package/build/store/private-selectors.js +88 -0
  188. package/build/store/private-selectors.js.map +1 -1
  189. package/build/store/reducer.js +36 -1
  190. package/build/store/reducer.js.map +1 -1
  191. package/build/store/selectors.js +28 -18
  192. package/build/store/selectors.js.map +1 -1
  193. package/build/utils/order-inserter-block-items.js +41 -0
  194. package/build/utils/order-inserter-block-items.js.map +1 -0
  195. package/build/utils/use-should-contextual-toolbar-show.js +16 -12
  196. package/build/utils/use-should-contextual-toolbar-show.js.map +1 -1
  197. package/build-module/autocompleters/block.js +12 -5
  198. package/build-module/autocompleters/block.js.map +1 -1
  199. package/build-module/components/block-breadcrumb/index.js +5 -3
  200. package/build-module/components/block-breadcrumb/index.js.map +1 -1
  201. package/build-module/components/block-controls/slot.js +11 -4
  202. package/build-module/components/block-controls/slot.js.map +1 -1
  203. package/build-module/components/block-controls/slot.native.js +9 -1
  204. package/build-module/components/block-controls/slot.native.js.map +1 -1
  205. package/build-module/components/block-draggable/index.js +10 -6
  206. package/build-module/components/block-draggable/index.js.map +1 -1
  207. package/build-module/components/block-draggable/use-scroll-when-dragging.js +2 -2
  208. package/build-module/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
  209. package/build-module/components/block-editing-mode/index.js +72 -0
  210. package/build-module/components/block-editing-mode/index.js.map +1 -0
  211. package/build-module/components/block-list/block-invalid-warning.native.js +16 -8
  212. package/build-module/components/block-list/block-invalid-warning.native.js.map +1 -1
  213. package/build-module/components/block-list/block-list-block-context.js +6 -0
  214. package/build-module/components/block-list/block-list-block-context.js.map +1 -0
  215. package/build-module/components/block-list/block-list-item-cell.native.js +13 -2
  216. package/build-module/components/block-list/block-list-item-cell.native.js.map +1 -1
  217. package/build-module/components/block-list/block-list-item.native.js +160 -190
  218. package/build-module/components/block-list/block-list-item.native.js.map +1 -1
  219. package/build-module/components/block-list/block-outline.native.js +44 -0
  220. package/build-module/components/block-list/block-outline.native.js.map +1 -0
  221. package/build-module/components/block-list/block.js +26 -34
  222. package/build-module/components/block-list/block.js.map +1 -1
  223. package/build-module/components/block-list/block.native.js +345 -310
  224. package/build-module/components/block-list/block.native.js.map +1 -1
  225. package/build-module/components/block-list/index.native.js +263 -355
  226. package/build-module/components/block-list/index.native.js.map +1 -1
  227. package/build-module/components/block-list/insertion-point.native.js +4 -2
  228. package/build-module/components/block-list/insertion-point.native.js.map +1 -1
  229. package/build-module/components/block-list/use-block-props/index.js +1 -1
  230. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  231. package/build-module/components/block-list/use-in-between-inserter.js +6 -5
  232. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  233. package/build-module/components/block-list-appender/index.js +15 -1
  234. package/build-module/components/block-list-appender/index.js.map +1 -1
  235. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +18 -4
  236. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  237. package/build-module/components/block-settings-menu/block-settings-dropdown.js +8 -9
  238. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  239. package/build-module/components/block-settings-menu-controls/index.js +13 -5
  240. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  241. package/build-module/components/block-styles/preview-panel.js +1 -2
  242. package/build-module/components/block-styles/preview-panel.js.map +1 -1
  243. package/build-module/components/block-switcher/block-transformations-menu.js +7 -0
  244. package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
  245. package/build-module/components/block-switcher/block-variation-transformations.js +108 -0
  246. package/build-module/components/block-switcher/block-variation-transformations.js.map +1 -0
  247. package/build-module/components/block-switcher/index.js +33 -12
  248. package/build-module/components/block-switcher/index.js.map +1 -1
  249. package/build-module/components/block-switcher/pattern-transformations-menu.js +3 -3
  250. package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  251. package/build-module/components/block-toolbar/index.js +8 -7
  252. package/build-module/components/block-toolbar/index.js.map +1 -1
  253. package/build-module/components/block-tools/block-contextual-toolbar.js +22 -65
  254. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  255. package/build-module/components/block-tools/insertion-point.js +11 -5
  256. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  257. package/build-module/components/block-tools/selected-block-popover.js +3 -7
  258. package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
  259. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +3 -2
  260. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
  261. package/build-module/components/convert-to-group-buttons/index.js +7 -2
  262. package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
  263. package/build-module/components/convert-to-group-buttons/index.native.js +76 -1
  264. package/build-module/components/convert-to-group-buttons/index.native.js.map +1 -1
  265. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +22 -36
  266. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  267. package/build-module/components/global-styles/advanced-panel.js +74 -0
  268. package/build-module/components/global-styles/advanced-panel.js.map +1 -0
  269. package/build-module/components/global-styles/color-panel.js +5 -2
  270. package/build-module/components/global-styles/color-panel.js.map +1 -1
  271. package/build-module/components/global-styles/dimensions-panel.js +9 -8
  272. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  273. package/build-module/components/global-styles/hooks.js +1 -2
  274. package/build-module/components/global-styles/hooks.js.map +1 -1
  275. package/build-module/components/global-styles/index.js +3 -1
  276. package/build-module/components/global-styles/index.js.map +1 -1
  277. package/build-module/components/global-styles/typography-panel.js +1 -1
  278. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  279. package/build-module/components/global-styles/use-global-styles-output.js +25 -4
  280. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  281. package/build-module/components/global-styles/utils.js +25 -0
  282. package/build-module/components/global-styles/utils.js.map +1 -1
  283. package/build-module/components/iframe/index.js +15 -8
  284. package/build-module/components/iframe/index.js.map +1 -1
  285. package/build-module/components/image-editor/use-save-image.js +24 -8
  286. package/build-module/components/image-editor/use-save-image.js.map +1 -1
  287. package/build-module/components/inner-blocks/index.js +2 -1
  288. package/build-module/components/inner-blocks/index.js.map +1 -1
  289. package/build-module/components/inner-blocks/index.native.js +7 -6
  290. package/build-module/components/inner-blocks/index.native.js.map +1 -1
  291. package/build-module/components/inner-blocks/use-nested-settings-update.js +13 -5
  292. package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  293. package/build-module/components/inserter/index.js +3 -7
  294. package/build-module/components/inserter/index.js.map +1 -1
  295. package/build-module/components/inserter/quick-inserter.js +2 -4
  296. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  297. package/build-module/components/inserter/search-results.js +16 -6
  298. package/build-module/components/inserter/search-results.js.map +1 -1
  299. package/build-module/components/inserter-draggable-blocks/index.js +4 -0
  300. package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
  301. package/build-module/components/inspector-controls/fill.js +1 -1
  302. package/build-module/components/inspector-controls/fill.js.map +1 -1
  303. package/build-module/components/inspector-controls/fill.native.js +1 -1
  304. package/build-module/components/inspector-controls/fill.native.js.map +1 -1
  305. package/build-module/components/inspector-controls/slot.js +4 -7
  306. package/build-module/components/inspector-controls/slot.js.map +1 -1
  307. package/build-module/components/inspector-controls/slot.native.js +1 -1
  308. package/build-module/components/inspector-controls/slot.native.js.map +1 -1
  309. package/build-module/components/line-height-control/index.js +7 -2
  310. package/build-module/components/line-height-control/index.js.map +1 -1
  311. package/build-module/components/link-control/use-internal-input-value.js +9 -8
  312. package/build-module/components/link-control/use-internal-input-value.js.map +1 -1
  313. package/build-module/components/list-view/appender.js +6 -2
  314. package/build-module/components/list-view/appender.js.map +1 -1
  315. package/build-module/components/list-view/block-contents.js +9 -3
  316. package/build-module/components/list-view/block-contents.js.map +1 -1
  317. package/build-module/components/list-view/block-select-button.js +2 -1
  318. package/build-module/components/list-view/block-select-button.js.map +1 -1
  319. package/build-module/components/list-view/block.js +24 -29
  320. package/build-module/components/list-view/block.js.map +1 -1
  321. package/build-module/components/list-view/branch.js +1 -3
  322. package/build-module/components/list-view/branch.js.map +1 -1
  323. package/build-module/components/list-view/index.js +44 -23
  324. package/build-module/components/list-view/index.js.map +1 -1
  325. package/build-module/components/list-view/use-list-view-client-ids.js +26 -3
  326. package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
  327. package/build-module/components/list-view/use-list-view-drop-zone.js +160 -11
  328. package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
  329. package/build-module/components/media-placeholder/index.js +66 -7
  330. package/build-module/components/media-placeholder/index.js.map +1 -1
  331. package/build-module/components/multi-selection-inspector/index.js +2 -2
  332. package/build-module/components/multi-selection-inspector/index.js.map +1 -1
  333. package/build-module/components/preview-options/index.js +7 -2
  334. package/build-module/components/preview-options/index.js.map +1 -1
  335. package/build-module/components/publish-date-time-picker/index.js +0 -2
  336. package/build-module/components/publish-date-time-picker/index.js.map +1 -1
  337. package/build-module/components/spacing-sizes-control/spacing-input-control.js +1 -1
  338. package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  339. package/build-module/components/url-input/index.js +4 -2
  340. package/build-module/components/url-input/index.js.map +1 -1
  341. package/build-module/components/use-block-drop-zone/index.js +25 -16
  342. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  343. package/build-module/components/use-resize-canvas/index.js +8 -1
  344. package/build-module/components/use-resize-canvas/index.js.map +1 -1
  345. package/build-module/components/writing-flow/use-arrow-nav.js +13 -7
  346. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  347. package/build-module/hooks/align.js +4 -7
  348. package/build-module/hooks/align.js.map +1 -1
  349. package/build-module/hooks/behaviors.js +97 -0
  350. package/build-module/hooks/behaviors.js.map +1 -0
  351. package/build-module/hooks/border.js +1 -1
  352. package/build-module/hooks/border.js.map +1 -1
  353. package/build-module/hooks/color.js +1 -1
  354. package/build-module/hooks/color.js.map +1 -1
  355. package/build-module/hooks/content-lock-ui.js +8 -11
  356. package/build-module/hooks/content-lock-ui.js.map +1 -1
  357. package/build-module/hooks/dimensions.js +0 -28
  358. package/build-module/hooks/dimensions.js.map +1 -1
  359. package/build-module/hooks/duotone.js +4 -7
  360. package/build-module/hooks/duotone.js.map +1 -1
  361. package/build-module/hooks/index.js +1 -0
  362. package/build-module/hooks/index.js.map +1 -1
  363. package/build-module/hooks/index.native.js +1 -0
  364. package/build-module/hooks/index.native.js.map +1 -1
  365. package/build-module/hooks/layout.js +9 -11
  366. package/build-module/hooks/layout.js.map +1 -1
  367. package/build-module/hooks/position.js +1 -1
  368. package/build-module/hooks/position.js.map +1 -1
  369. package/build-module/hooks/style.js +1 -1
  370. package/build-module/hooks/style.js.map +1 -1
  371. package/build-module/hooks/use-editor-wrapper-styles.native.js +242 -0
  372. package/build-module/hooks/use-editor-wrapper-styles.native.js.map +1 -0
  373. package/build-module/hooks/use-typography-props.js +14 -10
  374. package/build-module/hooks/use-typography-props.js.map +1 -1
  375. package/build-module/index.native.js +6 -0
  376. package/build-module/index.native.js.map +1 -0
  377. package/build-module/private-apis.js +3 -5
  378. package/build-module/private-apis.js.map +1 -1
  379. package/build-module/store/private-actions.js +42 -0
  380. package/build-module/store/private-actions.js.map +1 -1
  381. package/build-module/store/private-selectors.js +79 -0
  382. package/build-module/store/private-selectors.js.map +1 -1
  383. package/build-module/store/reducer.js +34 -1
  384. package/build-module/store/reducer.js.map +1 -1
  385. package/build-module/store/selectors.js +26 -17
  386. package/build-module/store/selectors.js.map +1 -1
  387. package/build-module/utils/order-inserter-block-items.js +32 -0
  388. package/build-module/utils/order-inserter-block-items.js.map +1 -0
  389. package/build-module/utils/use-should-contextual-toolbar-show.js +16 -12
  390. package/build-module/utils/use-should-contextual-toolbar-show.js.map +1 -1
  391. package/build-style/content-rtl.css +32 -14
  392. package/build-style/content.css +32 -14
  393. package/build-style/default-editor-styles-rtl.css +1 -1
  394. package/build-style/default-editor-styles.css +1 -1
  395. package/build-style/style-rtl.css +56 -77
  396. package/build-style/style.css +57 -77
  397. package/package.json +32 -31
  398. package/src/autocompleters/block.js +15 -7
  399. package/src/components/block-breadcrumb/index.js +11 -3
  400. package/src/components/block-breadcrumb/style.scss +2 -1
  401. package/src/components/block-controls/slot.js +8 -4
  402. package/src/components/block-controls/slot.native.js +6 -1
  403. package/src/components/block-draggable/index.js +10 -6
  404. package/src/components/block-draggable/use-scroll-when-dragging.js +8 -2
  405. package/src/components/block-editing-mode/index.js +71 -0
  406. package/src/components/block-list/block-invalid-warning.native.js +17 -9
  407. package/src/components/block-list/block-list-block-context.js +6 -0
  408. package/src/components/block-list/block-list-item-cell.native.js +10 -1
  409. package/src/components/block-list/block-list-item.native.js +180 -208
  410. package/src/components/block-list/block-outline.native.js +58 -0
  411. package/src/components/block-list/block.js +38 -56
  412. package/src/components/block-list/block.native.js +531 -501
  413. package/src/components/block-list/content.scss +5 -6
  414. package/src/components/block-list/index.native.js +324 -382
  415. package/src/components/block-list/insertion-point.native.js +2 -2
  416. package/src/components/block-list/test/block-invalid-warning.native.js +48 -0
  417. package/src/components/block-list/test/index.native.js +205 -0
  418. package/src/components/block-list/use-block-props/index.js +1 -1
  419. package/src/components/block-list/use-in-between-inserter.js +7 -3
  420. package/src/components/block-list-appender/index.js +22 -4
  421. package/src/components/block-mobile-toolbar/block-actions-menu.native.js +26 -1
  422. package/src/components/block-mover/style.scss +1 -0
  423. package/src/components/block-pattern-setup/style.scss +1 -4
  424. package/src/components/block-patterns-list/style.scss +1 -4
  425. package/src/components/block-settings-menu/block-settings-dropdown.js +10 -17
  426. package/src/components/block-settings-menu-controls/index.js +24 -4
  427. package/src/components/block-styles/preview-panel.js +1 -3
  428. package/src/components/block-styles/style.scss +4 -4
  429. package/src/components/block-switcher/block-transformations-menu.js +12 -0
  430. package/src/components/block-switcher/block-variation-transformations.js +115 -0
  431. package/src/components/block-switcher/index.js +38 -5
  432. package/src/components/block-switcher/pattern-transformations-menu.js +5 -5
  433. package/src/components/block-switcher/style.scss +6 -5
  434. package/src/components/block-toolbar/index.js +10 -11
  435. package/src/components/block-tools/block-contextual-toolbar.js +32 -67
  436. package/src/components/block-tools/insertion-point.js +23 -9
  437. package/src/components/block-tools/selected-block-popover.js +3 -5
  438. package/src/components/block-tools/style.scss +8 -0
  439. package/src/components/button-block-appender/content.scss +22 -0
  440. package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +16 -2
  441. package/src/components/convert-to-group-buttons/index.js +9 -2
  442. package/src/components/convert-to-group-buttons/index.native.js +79 -1
  443. package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +32 -38
  444. package/src/components/global-styles/advanced-panel.js +82 -0
  445. package/src/components/global-styles/color-panel.js +6 -1
  446. package/src/components/global-styles/dimensions-panel.js +9 -8
  447. package/src/components/global-styles/hooks.js +1 -5
  448. package/src/components/global-styles/index.js +6 -1
  449. package/src/components/global-styles/style.scss +17 -0
  450. package/src/components/global-styles/test/utils.js +57 -1
  451. package/src/components/global-styles/typography-panel.js +1 -1
  452. package/src/components/global-styles/use-global-styles-output.js +21 -3
  453. package/src/components/global-styles/utils.js +27 -0
  454. package/src/components/iframe/index.js +22 -12
  455. package/src/components/image-editor/use-save-image.js +20 -9
  456. package/src/components/inner-blocks/README.md +5 -0
  457. package/src/components/inner-blocks/index.js +2 -0
  458. package/src/components/inner-blocks/index.native.js +16 -6
  459. package/src/components/inner-blocks/use-nested-settings-update.js +20 -3
  460. package/src/components/inserter/index.js +1 -9
  461. package/src/components/inserter/quick-inserter.js +0 -2
  462. package/src/components/inserter/search-results.js +32 -6
  463. package/src/components/inserter-draggable-blocks/index.js +4 -0
  464. package/src/components/inspector-controls/fill.js +1 -1
  465. package/src/components/inspector-controls/fill.native.js +1 -1
  466. package/src/components/inspector-controls/slot.js +4 -9
  467. package/src/components/inspector-controls/slot.native.js +1 -1
  468. package/src/components/line-height-control/index.js +7 -2
  469. package/src/components/line-height-control/stories/index.js +1 -1
  470. package/src/components/link-control/test/index.js +42 -0
  471. package/src/components/link-control/use-internal-input-value.js +8 -7
  472. package/src/components/list-view/appender.js +3 -2
  473. package/src/components/list-view/block-contents.js +32 -20
  474. package/src/components/list-view/block-select-button.js +5 -1
  475. package/src/components/list-view/block.js +34 -37
  476. package/src/components/list-view/branch.js +1 -7
  477. package/src/components/list-view/index.js +42 -17
  478. package/src/components/list-view/style.scss +7 -7
  479. package/src/components/list-view/test/use-list-view-drop-zone.js +88 -12
  480. package/src/components/list-view/use-list-view-client-ids.js +21 -4
  481. package/src/components/list-view/use-list-view-drop-zone.js +194 -11
  482. package/src/components/media-placeholder/index.js +74 -1
  483. package/src/components/multi-selection-inspector/index.js +2 -2
  484. package/src/components/preview-options/index.js +9 -2
  485. package/src/components/publish-date-time-picker/index.js +0 -2
  486. package/src/components/spacing-sizes-control/spacing-input-control.js +1 -0
  487. package/src/components/url-input/README.md +6 -0
  488. package/src/components/url-input/index.js +2 -2
  489. package/src/components/use-block-drop-zone/index.js +31 -17
  490. package/src/components/use-resize-canvas/index.js +9 -1
  491. package/src/components/writing-flow/test/index.js +15 -0
  492. package/src/components/writing-flow/use-arrow-nav.js +17 -4
  493. package/src/hooks/align.js +5 -12
  494. package/src/hooks/behaviors.js +104 -0
  495. package/src/hooks/border.js +2 -1
  496. package/src/hooks/color.js +2 -1
  497. package/src/hooks/content-lock-ui.js +3 -15
  498. package/src/hooks/dimensions.js +0 -40
  499. package/src/hooks/duotone.js +4 -11
  500. package/src/hooks/index.js +1 -0
  501. package/src/hooks/index.native.js +1 -0
  502. package/src/hooks/layout.js +14 -20
  503. package/src/hooks/position.js +2 -1
  504. package/src/hooks/style.js +2 -1
  505. package/src/hooks/test/use-editor-wrapper-styles.native.js +282 -0
  506. package/src/hooks/test/use-typography-props.js +47 -2
  507. package/src/hooks/use-editor-wrapper-styles.native.js +250 -0
  508. package/src/hooks/use-editor-wrapper-styles.native.scss +11 -0
  509. package/src/hooks/use-typography-props.js +10 -11
  510. package/src/index.native.js +6 -0
  511. package/src/private-apis.js +2 -4
  512. package/src/store/private-actions.js +39 -0
  513. package/src/store/private-selectors.js +95 -0
  514. package/src/store/reducer.js +27 -0
  515. package/src/store/selectors.js +25 -15
  516. package/src/store/test/private-actions.js +32 -1
  517. package/src/store/test/private-selectors.js +158 -0
  518. package/src/store/test/reducer.js +48 -0
  519. package/src/style.scss +0 -3
  520. package/src/utils/order-inserter-block-items.js +26 -0
  521. package/src/utils/use-should-contextual-toolbar-show.js +19 -9
  522. package/tsconfig.json +1 -0
  523. package/tsconfig.tsbuildinfo +1 -1
  524. package/build/components/block-list/block-list-compact.native.js +0 -75
  525. package/build/components/block-list/block-list-compact.native.js.map +0 -1
  526. package/build/components/off-canvas-editor/appender.js +0 -125
  527. package/build/components/off-canvas-editor/appender.js.map +0 -1
  528. package/build/components/off-canvas-editor/block-contents.js +0 -141
  529. package/build/components/off-canvas-editor/block-contents.js.map +0 -1
  530. package/build/components/off-canvas-editor/block-select-button.js +0 -126
  531. package/build/components/off-canvas-editor/block-select-button.js.map +0 -1
  532. package/build/components/off-canvas-editor/block.js +0 -297
  533. package/build/components/off-canvas-editor/block.js.map +0 -1
  534. package/build/components/off-canvas-editor/branch.js +0 -197
  535. package/build/components/off-canvas-editor/branch.js.map +0 -1
  536. package/build/components/off-canvas-editor/context.js +0 -19
  537. package/build/components/off-canvas-editor/context.js.map +0 -1
  538. package/build/components/off-canvas-editor/drop-indicator.js +0 -118
  539. package/build/components/off-canvas-editor/drop-indicator.js.map +0 -1
  540. package/build/components/off-canvas-editor/expander.js +0 -41
  541. package/build/components/off-canvas-editor/expander.js.map +0 -1
  542. package/build/components/off-canvas-editor/index.js +0 -236
  543. package/build/components/off-canvas-editor/index.js.map +0 -1
  544. package/build/components/off-canvas-editor/leaf-more-menu.js +0 -146
  545. package/build/components/off-canvas-editor/leaf-more-menu.js.map +0 -1
  546. package/build/components/off-canvas-editor/leaf.js +0 -60
  547. package/build/components/off-canvas-editor/leaf.js.map +0 -1
  548. package/build/components/off-canvas-editor/link-ui.js +0 -186
  549. package/build/components/off-canvas-editor/link-ui.js.map +0 -1
  550. package/build/components/off-canvas-editor/update-attributes.js +0 -108
  551. package/build/components/off-canvas-editor/update-attributes.js.map +0 -1
  552. package/build/components/off-canvas-editor/use-block-selection.js +0 -139
  553. package/build/components/off-canvas-editor/use-block-selection.js.map +0 -1
  554. package/build/components/off-canvas-editor/use-inserted-block.js +0 -58
  555. package/build/components/off-canvas-editor/use-inserted-block.js.map +0 -1
  556. package/build/components/off-canvas-editor/use-list-view-client-ids.js +0 -33
  557. package/build/components/off-canvas-editor/use-list-view-client-ids.js.map +0 -1
  558. package/build/components/off-canvas-editor/use-list-view-drop-zone.js +0 -235
  559. package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +0 -1
  560. package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js +0 -60
  561. package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +0 -1
  562. package/build/components/off-canvas-editor/utils.js +0 -60
  563. package/build/components/off-canvas-editor/utils.js.map +0 -1
  564. package/build-module/components/block-list/block-list-compact.native.js +0 -60
  565. package/build-module/components/block-list/block-list-compact.native.js.map +0 -1
  566. package/build-module/components/off-canvas-editor/appender.js +0 -108
  567. package/build-module/components/off-canvas-editor/appender.js.map +0 -1
  568. package/build-module/components/off-canvas-editor/block-contents.js +0 -121
  569. package/build-module/components/off-canvas-editor/block-contents.js.map +0 -1
  570. package/build-module/components/off-canvas-editor/block-select-button.js +0 -107
  571. package/build-module/components/off-canvas-editor/block-select-button.js.map +0 -1
  572. package/build-module/components/off-canvas-editor/block.js +0 -273
  573. package/build-module/components/off-canvas-editor/block.js.map +0 -1
  574. package/build-module/components/off-canvas-editor/branch.js +0 -179
  575. package/build-module/components/off-canvas-editor/branch.js.map +0 -1
  576. package/build-module/components/off-canvas-editor/context.js +0 -7
  577. package/build-module/components/off-canvas-editor/context.js.map +0 -1
  578. package/build-module/components/off-canvas-editor/drop-indicator.js +0 -111
  579. package/build-module/components/off-canvas-editor/drop-indicator.js.map +0 -1
  580. package/build-module/components/off-canvas-editor/expander.js +0 -32
  581. package/build-module/components/off-canvas-editor/expander.js.map +0 -1
  582. package/build-module/components/off-canvas-editor/index.js +0 -213
  583. package/build-module/components/off-canvas-editor/index.js.map +0 -1
  584. package/build-module/components/off-canvas-editor/leaf-more-menu.js +0 -128
  585. package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +0 -1
  586. package/build-module/components/off-canvas-editor/leaf.js +0 -45
  587. package/build-module/components/off-canvas-editor/leaf.js.map +0 -1
  588. package/build-module/components/off-canvas-editor/link-ui.js +0 -166
  589. package/build-module/components/off-canvas-editor/link-ui.js.map +0 -1
  590. package/build-module/components/off-canvas-editor/update-attributes.js +0 -97
  591. package/build-module/components/off-canvas-editor/update-attributes.js.map +0 -1
  592. package/build-module/components/off-canvas-editor/use-block-selection.js +0 -124
  593. package/build-module/components/off-canvas-editor/use-block-selection.js.map +0 -1
  594. package/build-module/components/off-canvas-editor/use-inserted-block.js +0 -47
  595. package/build-module/components/off-canvas-editor/use-inserted-block.js.map +0 -1
  596. package/build-module/components/off-canvas-editor/use-list-view-client-ids.js +0 -24
  597. package/build-module/components/off-canvas-editor/use-list-view-client-ids.js.map +0 -1
  598. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +0 -220
  599. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +0 -1
  600. package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js +0 -50
  601. package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +0 -1
  602. package/build-module/components/off-canvas-editor/utils.js +0 -44
  603. package/build-module/components/off-canvas-editor/utils.js.map +0 -1
  604. package/src/components/block-list/block-list-compact.native.js +0 -63
  605. package/src/components/off-canvas-editor/README.md +0 -5
  606. package/src/components/off-canvas-editor/appender.js +0 -124
  607. package/src/components/off-canvas-editor/block-contents.js +0 -156
  608. package/src/components/off-canvas-editor/block-select-button.js +0 -128
  609. package/src/components/off-canvas-editor/block.js +0 -347
  610. package/src/components/off-canvas-editor/branch.js +0 -238
  611. package/src/components/off-canvas-editor/context.js +0 -8
  612. package/src/components/off-canvas-editor/drop-indicator.js +0 -126
  613. package/src/components/off-canvas-editor/expander.js +0 -26
  614. package/src/components/off-canvas-editor/index.js +0 -271
  615. package/src/components/off-canvas-editor/leaf-more-menu.js +0 -157
  616. package/src/components/off-canvas-editor/leaf.js +0 -52
  617. package/src/components/off-canvas-editor/link-ui.js +0 -167
  618. package/src/components/off-canvas-editor/style.scss +0 -34
  619. package/src/components/off-canvas-editor/test/use-inserted-block.js +0 -108
  620. package/src/components/off-canvas-editor/test/utils.js +0 -50
  621. package/src/components/off-canvas-editor/update-attributes.js +0 -99
  622. package/src/components/off-canvas-editor/use-block-selection.js +0 -169
  623. package/src/components/off-canvas-editor/use-inserted-block.js +0 -47
  624. package/src/components/off-canvas-editor/use-list-view-client-ids.js +0 -29
  625. package/src/components/off-canvas-editor/use-list-view-drop-zone.js +0 -260
  626. package/src/components/off-canvas-editor/use-list-view-expand-selected-item.js +0 -58
  627. package/src/components/off-canvas-editor/utils.js +0 -58
@@ -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":"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","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
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/utils.js"],"names":["getBlockPositionDescription","position","siblingCount","level","isClientIdSelected","clientId","selectedBlockClientIds","Array","isArray","length","indexOf","getCommonDepthClientIds","startId","endId","startParents","endParents","startPath","endPath","depth","Math","min","start","end"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;AAGO,MAAMA,2BAA2B,GAAG,CAAEC,QAAF,EAAYC,YAAZ,EAA0BC,KAA1B,KAC1C;AACC;AACA,cAAI,gCAAJ,CAFD,EAGCF,QAHD,EAICC,YAJD,EAKCC,KALD,CADM;AASP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMC,kBAAkB,GAAG,CAAEC,QAAF,EAAYC,sBAAZ,KACjCC,KAAK,CAACC,OAAN,CAAeF,sBAAf,KAA2CA,sBAAsB,CAACG,MAAlE,GACGH,sBAAsB,CAACI,OAAvB,CAAgCL,QAAhC,MAA+C,CAAC,CADnD,GAEGC,sBAAsB,KAAKD,QAHxB;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,SAASM,uBAAT,CACNC,OADM,EAENC,KAFM,EAGNC,YAHM,EAINC,UAJM,EAKL;AACD,QAAMC,SAAS,GAAG,CAAE,GAAGF,YAAL,EAAmBF,OAAnB,CAAlB;AACA,QAAMK,OAAO,GAAG,CAAE,GAAGF,UAAL,EAAiBF,KAAjB,CAAhB;AACA,QAAMK,KAAK,GAAGC,IAAI,CAACC,GAAL,CAAUJ,SAAS,CAACP,MAApB,EAA4BQ,OAAO,CAACR,MAApC,IAA+C,CAA7D;AACA,QAAMY,KAAK,GAAGL,SAAS,CAAEE,KAAF,CAAvB;AACA,QAAMI,GAAG,GAAGL,OAAO,CAAEC,KAAF,CAAnB;AAEA,SAAO;AACNG,IAAAA,KADM;AAENC,IAAAA;AAFM,GAAP;AAIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\n\nexport const getBlockPositionDescription = ( position, siblingCount, level ) =>\n\tsprintf(\n\t\t/* translators: 1: The numerical position of the block. 2: The total number of blocks. 3. The level of nesting for the block. */\n\t\t__( 'Block %1$d of %2$d, Level %3$d' ),\n\t\tposition,\n\t\tsiblingCount,\n\t\tlevel\n\t);\n\n/**\n * Returns true if the client ID occurs within the block selection or multi-selection,\n * or false otherwise.\n *\n * @param {string} clientId Block client ID.\n * @param {string|string[]} selectedBlockClientIds Selected block client ID, or an array of multi-selected blocks client IDs.\n *\n * @return {boolean} Whether the block is in multi-selection set.\n */\nexport const isClientIdSelected = ( clientId, selectedBlockClientIds ) =>\n\tArray.isArray( selectedBlockClientIds ) && selectedBlockClientIds.length\n\t\t? selectedBlockClientIds.indexOf( clientId ) !== -1\n\t\t: selectedBlockClientIds === clientId;\n\n/**\n * From a start and end clientId of potentially different nesting levels,\n * return the nearest-depth ids that have a common level of depth in the\n * nesting hierarchy. For multiple block selection, this ensure that the\n * selection is always at the same nesting level, and not split across\n * separate levels.\n *\n * @param {string} startId The first id of a selection.\n * @param {string} endId The end id of a selection, usually one that has been clicked on.\n * @param {string[]} startParents An array of ancestor ids for the start id, in descending order.\n * @param {string[]} endParents An array of ancestor ids for the end id, in descending order.\n * @return {Object} An object containing the start and end ids.\n */\nexport function getCommonDepthClientIds(\n\tstartId,\n\tendId,\n\tstartParents,\n\tendParents\n) {\n\tconst startPath = [ ...startParents, startId ];\n\tconst endPath = [ ...endParents, endId ];\n\tconst depth = Math.min( startPath.length, endPath.length ) - 1;\n\tconst start = startPath[ depth ];\n\tconst end = endPath[ depth ];\n\n\treturn {\n\t\tstart,\n\t\tend,\n\t};\n}\n"]}
@@ -1,60 +0,0 @@
1
- import { createElement } from "@wordpress/element";
2
-
3
- /**
4
- * External dependencies
5
- */
6
- import { View } from 'react-native';
7
- /**
8
- * WordPress dependencies
9
- */
10
-
11
- import { store as blockEditorStore } from '@wordpress/block-editor';
12
- import { useSelect } from '@wordpress/data';
13
- /**
14
- * Internal dependencies
15
- */
16
-
17
- import styles from './style.scss';
18
- import BlockListBlock from './block';
19
- /**
20
- * NOTE: This is a component currently used by the List block (V2)
21
- * It only passes the needed props for this block, if other blocks will use it
22
- * make sure you pass other props that might be required coming from:
23
- * components/inner-blocks/index.native.js
24
- */
25
-
26
- function BlockListCompact(props) {
27
- const {
28
- marginHorizontal = styles.defaultBlock.marginLeft,
29
- marginVertical = styles.defaultBlock.marginTop,
30
- rootClientId
31
- } = props;
32
- const {
33
- blockClientIds
34
- } = useSelect(select => {
35
- const {
36
- getBlockOrder
37
- } = select(blockEditorStore);
38
- const blockOrder = getBlockOrder(rootClientId);
39
- return {
40
- blockClientIds: blockOrder
41
- };
42
- }, [rootClientId]);
43
- const containerStyle = {
44
- marginVertical: -marginVertical,
45
- marginHorizontal: -marginHorizontal
46
- };
47
- return createElement(View, {
48
- style: containerStyle,
49
- testID: "block-list-wrapper"
50
- }, blockClientIds.map(currentClientId => createElement(BlockListBlock, {
51
- clientId: currentClientId,
52
- rootClientId: rootClientId,
53
- key: currentClientId,
54
- marginHorizontal: marginHorizontal,
55
- marginVertical: marginVertical
56
- })));
57
- }
58
-
59
- export default BlockListCompact;
60
- //# sourceMappingURL=block-list-compact.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-list/block-list-compact.native.js"],"names":["View","store","blockEditorStore","useSelect","styles","BlockListBlock","BlockListCompact","props","marginHorizontal","defaultBlock","marginLeft","marginVertical","marginTop","rootClientId","blockClientIds","select","getBlockOrder","blockOrder","containerStyle","map","currentClientId"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,cAArB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,cAAnB;AACA,OAAOC,cAAP,MAA2B,SAA3B;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASC,gBAAT,CAA2BC,KAA3B,EAAmC;AAClC,QAAM;AACLC,IAAAA,gBAAgB,GAAGJ,MAAM,CAACK,YAAP,CAAoBC,UADlC;AAELC,IAAAA,cAAc,GAAGP,MAAM,CAACK,YAAP,CAAoBG,SAFhC;AAGLC,IAAAA;AAHK,MAIFN,KAJJ;AAKA,QAAM;AAAEO,IAAAA;AAAF,MAAqBX,SAAS,CACjCY,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA;AAAF,QAAoBD,MAAM,CAAEb,gBAAF,CAAhC;AACA,UAAMe,UAAU,GAAGD,aAAa,CAAEH,YAAF,CAAhC;AAEA,WAAO;AACNC,MAAAA,cAAc,EAAEG;AADV,KAAP;AAGA,GARkC,EASnC,CAAEJ,YAAF,CATmC,CAApC;AAYA,QAAMK,cAAc,GAAG;AACtBP,IAAAA,cAAc,EAAE,CAACA,cADK;AAEtBH,IAAAA,gBAAgB,EAAE,CAACA;AAFG,GAAvB;AAKA,SACC,cAAC,IAAD;AAAM,IAAA,KAAK,EAAGU,cAAd;AAA+B,IAAA,MAAM,EAAC;AAAtC,KACGJ,cAAc,CAACK,GAAf,CAAsBC,eAAF,IACrB,cAAC,cAAD;AACC,IAAA,QAAQ,EAAGA,eADZ;AAEC,IAAA,YAAY,EAAGP,YAFhB;AAGC,IAAA,GAAG,EAAGO,eAHP;AAIC,IAAA,gBAAgB,EAAGZ,gBAJpB;AAKC,IAAA,cAAc,EAAGG;AALlB,IADC,CADH,CADD;AAaA;;AAED,eAAeL,gBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\nimport BlockListBlock from './block';\n\n/**\n * NOTE: This is a component currently used by the List block (V2)\n * It only passes the needed props for this block, if other blocks will use it\n * make sure you pass other props that might be required coming from:\n * components/inner-blocks/index.native.js\n */\n\nfunction BlockListCompact( props ) {\n\tconst {\n\t\tmarginHorizontal = styles.defaultBlock.marginLeft,\n\t\tmarginVertical = styles.defaultBlock.marginTop,\n\t\trootClientId,\n\t} = props;\n\tconst { blockClientIds } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockOrder } = select( blockEditorStore );\n\t\t\tconst blockOrder = getBlockOrder( rootClientId );\n\n\t\t\treturn {\n\t\t\t\tblockClientIds: blockOrder,\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\n\tconst containerStyle = {\n\t\tmarginVertical: -marginVertical,\n\t\tmarginHorizontal: -marginHorizontal,\n\t};\n\n\treturn (\n\t\t<View style={ containerStyle } testID=\"block-list-wrapper\">\n\t\t\t{ blockClientIds.map( ( currentClientId ) => (\n\t\t\t\t<BlockListBlock\n\t\t\t\t\tclientId={ currentClientId }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\tkey={ currentClientId }\n\t\t\t\t\tmarginHorizontal={ marginHorizontal }\n\t\t\t\t\tmarginVertical={ marginVertical }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</View>\n\t);\n}\n\nexport default BlockListCompact;\n"]}
@@ -1,108 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { createElement } from "@wordpress/element";
3
-
4
- /**
5
- * WordPress dependencies
6
- */
7
- import { useInstanceId } from '@wordpress/compose';
8
- import { speak } from '@wordpress/a11y';
9
- import { useSelect } from '@wordpress/data';
10
- import { forwardRef, useState, useEffect, useCallback } from '@wordpress/element';
11
- import { __, sprintf } from '@wordpress/i18n';
12
- /**
13
- * Internal dependencies
14
- */
15
-
16
- import { store as blockEditorStore } from '../../store';
17
- import useBlockDisplayTitle from '../block-title/use-block-display-title';
18
- import { ComposedPrivateInserter as PrivateInserter } from '../inserter';
19
- const prioritizedInserterBlocks = ['core/navigation-link/page', 'core/navigation-link'];
20
- export const Appender = forwardRef((_ref, ref) => {
21
- let {
22
- nestingLevel,
23
- blockCount,
24
- clientId,
25
- ...props
26
- } = _ref;
27
- const [insertedBlock, setInsertedBlock] = useState(null);
28
- const instanceId = useInstanceId(Appender);
29
- const {
30
- hideInserter
31
- } = useSelect(select => {
32
- const {
33
- getTemplateLock,
34
- __unstableGetEditorMode
35
- } = select(blockEditorStore);
36
- return {
37
- hideInserter: !!getTemplateLock(clientId) || __unstableGetEditorMode() === 'zoom-out'
38
- };
39
- }, [clientId]);
40
- const blockTitle = useBlockDisplayTitle({
41
- clientId,
42
- context: 'list-view'
43
- });
44
- const insertedBlockTitle = useBlockDisplayTitle({
45
- clientId: insertedBlock === null || insertedBlock === void 0 ? void 0 : insertedBlock.clientId,
46
- context: 'list-view'
47
- });
48
- useEffect(() => {
49
- if (!(insertedBlockTitle !== null && insertedBlockTitle !== void 0 && insertedBlockTitle.length)) {
50
- return;
51
- }
52
-
53
- speak(sprintf( // translators: %s: name of block being inserted (i.e. Paragraph, Image, Group etc)
54
- __('%s block inserted'), insertedBlockTitle), 'assertive');
55
- }, [insertedBlockTitle]);
56
- const orderInitialBlockItems = useCallback(items => {
57
- items.sort((_ref2, _ref3) => {
58
- let {
59
- id: aName
60
- } = _ref2;
61
- let {
62
- id: bName
63
- } = _ref3;
64
- // Sort block items according to `prioritizedInserterBlocks`.
65
- let aIndex = prioritizedInserterBlocks.indexOf(aName);
66
- let bIndex = prioritizedInserterBlocks.indexOf(bName); // All other block items should come after that.
67
-
68
- if (aIndex < 0) aIndex = prioritizedInserterBlocks.length;
69
- if (bIndex < 0) bIndex = prioritizedInserterBlocks.length;
70
- return aIndex - bIndex;
71
- });
72
- return items;
73
- }, []);
74
-
75
- if (hideInserter) {
76
- return null;
77
- }
78
-
79
- const descriptionId = `off-canvas-editor-appender__${instanceId}`;
80
- const description = sprintf(
81
- /* translators: 1: The name of the block. 2: The numerical position of the block. 3: The level of nesting for the block. */
82
- __('Append to %1$s block at position %2$d, Level %3$d'), blockTitle, blockCount + 1, nestingLevel);
83
- return createElement("div", {
84
- className: "offcanvas-editor-appender"
85
- }, createElement(PrivateInserter, _extends({
86
- ref: ref,
87
- rootClientId: clientId,
88
- position: "bottom right",
89
- isAppender: true,
90
- selectBlockOnInsert: false,
91
- shouldDirectInsert: false,
92
- __experimentalIsQuick: true
93
- }, props, {
94
- toggleProps: {
95
- 'aria-describedby': descriptionId
96
- },
97
- onSelectOrClose: maybeInsertedBlock => {
98
- if (maybeInsertedBlock !== null && maybeInsertedBlock !== void 0 && maybeInsertedBlock.clientId) {
99
- setInsertedBlock(maybeInsertedBlock);
100
- }
101
- },
102
- orderInitialBlockItems: orderInitialBlockItems
103
- })), createElement("div", {
104
- className: "offcanvas-editor-appender__description",
105
- id: descriptionId
106
- }, description));
107
- });
108
- //# sourceMappingURL=appender.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/appender.js"],"names":["useInstanceId","speak","useSelect","forwardRef","useState","useEffect","useCallback","__","sprintf","store","blockEditorStore","useBlockDisplayTitle","ComposedPrivateInserter","PrivateInserter","prioritizedInserterBlocks","Appender","ref","nestingLevel","blockCount","clientId","props","insertedBlock","setInsertedBlock","instanceId","hideInserter","select","getTemplateLock","__unstableGetEditorMode","blockTitle","context","insertedBlockTitle","length","orderInitialBlockItems","items","sort","id","aName","bName","aIndex","indexOf","bIndex","descriptionId","description","maybeInsertedBlock"],"mappings":"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","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tforwardRef,\n\tuseState,\n\tuseEffect,\n\tuseCallback,\n} from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDisplayTitle from '../block-title/use-block-display-title';\nimport { ComposedPrivateInserter as PrivateInserter } from '../inserter';\n\nconst prioritizedInserterBlocks = [\n\t'core/navigation-link/page',\n\t'core/navigation-link',\n];\n\nexport const Appender = forwardRef(\n\t( { nestingLevel, blockCount, clientId, ...props }, ref ) => {\n\t\tconst [ insertedBlock, setInsertedBlock ] = useState( null );\n\n\t\tconst instanceId = useInstanceId( Appender );\n\t\tconst { hideInserter } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { getTemplateLock, __unstableGetEditorMode } =\n\t\t\t\t\tselect( blockEditorStore );\n\n\t\t\t\treturn {\n\t\t\t\t\thideInserter:\n\t\t\t\t\t\t!! getTemplateLock( clientId ) ||\n\t\t\t\t\t\t__unstableGetEditorMode() === 'zoom-out',\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ clientId ]\n\t\t);\n\n\t\tconst blockTitle = useBlockDisplayTitle( {\n\t\t\tclientId,\n\t\t\tcontext: 'list-view',\n\t\t} );\n\n\t\tconst insertedBlockTitle = useBlockDisplayTitle( {\n\t\t\tclientId: insertedBlock?.clientId,\n\t\t\tcontext: 'list-view',\n\t\t} );\n\n\t\tuseEffect( () => {\n\t\t\tif ( ! insertedBlockTitle?.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tspeak(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: name of block being inserted (i.e. Paragraph, Image, Group etc)\n\t\t\t\t\t__( '%s block inserted' ),\n\t\t\t\t\tinsertedBlockTitle\n\t\t\t\t),\n\t\t\t\t'assertive'\n\t\t\t);\n\t\t}, [ insertedBlockTitle ] );\n\n\t\tconst orderInitialBlockItems = useCallback( ( items ) => {\n\t\t\titems.sort( ( { id: aName }, { id: bName } ) => {\n\t\t\t\t// Sort block items according to `prioritizedInserterBlocks`.\n\t\t\t\tlet aIndex = prioritizedInserterBlocks.indexOf( aName );\n\t\t\t\tlet bIndex = prioritizedInserterBlocks.indexOf( bName );\n\t\t\t\t// All other block items should come after that.\n\t\t\t\tif ( aIndex < 0 ) aIndex = prioritizedInserterBlocks.length;\n\t\t\t\tif ( bIndex < 0 ) bIndex = prioritizedInserterBlocks.length;\n\t\t\t\treturn aIndex - bIndex;\n\t\t\t} );\n\t\t\treturn items;\n\t\t}, [] );\n\n\t\tif ( hideInserter ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst descriptionId = `off-canvas-editor-appender__${ instanceId }`;\n\t\tconst description = sprintf(\n\t\t\t/* translators: 1: The name of the block. 2: The numerical position of the block. 3: The level of nesting for the block. */\n\t\t\t__( 'Append to %1$s block at position %2$d, Level %3$d' ),\n\t\t\tblockTitle,\n\t\t\tblockCount + 1,\n\t\t\tnestingLevel\n\t\t);\n\n\t\treturn (\n\t\t\t<div className=\"offcanvas-editor-appender\">\n\t\t\t\t<PrivateInserter\n\t\t\t\t\tref={ ref }\n\t\t\t\t\trootClientId={ clientId }\n\t\t\t\t\tposition=\"bottom right\"\n\t\t\t\t\tisAppender\n\t\t\t\t\tselectBlockOnInsert={ false }\n\t\t\t\t\tshouldDirectInsert={ false }\n\t\t\t\t\t__experimentalIsQuick\n\t\t\t\t\t{ ...props }\n\t\t\t\t\ttoggleProps={ { 'aria-describedby': descriptionId } }\n\t\t\t\t\tonSelectOrClose={ ( maybeInsertedBlock ) => {\n\t\t\t\t\t\tif ( maybeInsertedBlock?.clientId ) {\n\t\t\t\t\t\t\tsetInsertedBlock( maybeInsertedBlock );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\torderInitialBlockItems={ orderInitialBlockItems }\n\t\t\t\t/>\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"offcanvas-editor-appender__description\"\n\t\t\t\t\tid={ descriptionId }\n\t\t\t\t>\n\t\t\t\t\t{ description }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t);\n\t}\n);\n"]}