@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,128 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { createElement, Fragment } from "@wordpress/element";
3
-
4
- /**
5
- * WordPress dependencies
6
- */
7
- import { createBlock } from '@wordpress/blocks';
8
- import { addSubmenu, chevronUp, chevronDown, moreVertical } from '@wordpress/icons';
9
- import { DropdownMenu, MenuItem, MenuGroup } from '@wordpress/components';
10
- import { useDispatch, useSelect } from '@wordpress/data';
11
- import { __, sprintf } from '@wordpress/i18n';
12
- /**
13
- * Internal dependencies
14
- */
15
-
16
- import { store as blockEditorStore } from '../../store';
17
- import BlockTitle from '../block-title';
18
- import { useListViewContext } from './context';
19
- const POPOVER_PROPS = {
20
- className: 'block-editor-block-settings-menu__popover',
21
- position: 'bottom right',
22
- variant: 'toolbar'
23
- };
24
- const BLOCKS_THAT_CAN_BE_CONVERTED_TO_SUBMENU = ['core/navigation-link', 'core/navigation-submenu'];
25
-
26
- function AddSubmenuItem(_ref) {
27
- let {
28
- block,
29
- onClose
30
- } = _ref;
31
- const {
32
- expandedState,
33
- expand
34
- } = useListViewContext();
35
- const {
36
- insertBlock,
37
- replaceBlock,
38
- replaceInnerBlocks
39
- } = useDispatch(blockEditorStore);
40
- const clientId = block.clientId;
41
- const isDisabled = !BLOCKS_THAT_CAN_BE_CONVERTED_TO_SUBMENU.includes(block.name);
42
- return createElement(MenuItem, {
43
- icon: addSubmenu,
44
- disabled: isDisabled,
45
- onClick: () => {
46
- const updateSelectionOnInsert = false;
47
- const newLink = createBlock('core/navigation-link');
48
-
49
- if (block.name === 'core/navigation-submenu') {
50
- insertBlock(newLink, block.innerBlocks.length, clientId, updateSelectionOnInsert);
51
- } else {
52
- // Convert to a submenu if the block currently isn't one.
53
- const newSubmenu = createBlock('core/navigation-submenu', block.attributes, block.innerBlocks); // The following must happen as two independent actions.
54
- // Why? Because the offcanvas editor relies on the getLastInsertedBlocksClientIds
55
- // selector to determine which block is "active". As the UX needs the newLink to be
56
- // the "active" block it must be the last block to be inserted.
57
- // Therefore the Submenu is first created and **then** the newLink is inserted
58
- // thus ensuring it is the last inserted block.
59
-
60
- replaceBlock(clientId, newSubmenu);
61
- replaceInnerBlocks(newSubmenu.clientId, [newLink], updateSelectionOnInsert);
62
- }
63
-
64
- if (!expandedState[block.clientId]) {
65
- expand(block.clientId);
66
- }
67
-
68
- onClose();
69
- }
70
- }, __('Add submenu link'));
71
- }
72
-
73
- export default function LeafMoreMenu(props) {
74
- const {
75
- clientId,
76
- block
77
- } = props;
78
- const {
79
- moveBlocksDown,
80
- moveBlocksUp,
81
- removeBlocks
82
- } = useDispatch(blockEditorStore);
83
- const removeLabel = sprintf(
84
- /* translators: %s: block name */
85
- __('Remove %s'), BlockTitle({
86
- clientId,
87
- maximumLength: 25
88
- }));
89
- const rootClientId = useSelect(select => {
90
- const {
91
- getBlockRootClientId
92
- } = select(blockEditorStore);
93
- return getBlockRootClientId(clientId);
94
- }, [clientId]);
95
- return createElement(DropdownMenu, _extends({
96
- icon: moreVertical,
97
- label: __('Options'),
98
- className: "block-editor-block-settings-menu",
99
- popoverProps: POPOVER_PROPS,
100
- noIcons: true
101
- }, props), _ref2 => {
102
- let {
103
- onClose
104
- } = _ref2;
105
- return createElement(Fragment, null, createElement(MenuGroup, null, createElement(MenuItem, {
106
- icon: chevronUp,
107
- onClick: () => {
108
- moveBlocksUp([clientId], rootClientId);
109
- onClose();
110
- }
111
- }, __('Move up')), createElement(MenuItem, {
112
- icon: chevronDown,
113
- onClick: () => {
114
- moveBlocksDown([clientId], rootClientId);
115
- onClose();
116
- }
117
- }, __('Move down')), createElement(AddSubmenuItem, {
118
- block: block,
119
- onClose: onClose
120
- })), createElement(MenuGroup, null, createElement(MenuItem, {
121
- onClick: () => {
122
- removeBlocks([clientId], false);
123
- onClose();
124
- }
125
- }, removeLabel)));
126
- });
127
- }
128
- //# sourceMappingURL=leaf-more-menu.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/leaf-more-menu.js"],"names":["createBlock","addSubmenu","chevronUp","chevronDown","moreVertical","DropdownMenu","MenuItem","MenuGroup","useDispatch","useSelect","__","sprintf","store","blockEditorStore","BlockTitle","useListViewContext","POPOVER_PROPS","className","position","variant","BLOCKS_THAT_CAN_BE_CONVERTED_TO_SUBMENU","AddSubmenuItem","block","onClose","expandedState","expand","insertBlock","replaceBlock","replaceInnerBlocks","clientId","isDisabled","includes","name","updateSelectionOnInsert","newLink","innerBlocks","length","newSubmenu","attributes","LeafMoreMenu","props","moveBlocksDown","moveBlocksUp","removeBlocks","removeLabel","maximumLength","rootClientId","select","getBlockRootClientId"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,mBAA5B;AACA,SACCC,UADD,EAECC,SAFD,EAGCC,WAHD,EAICC,YAJD,QAKO,kBALP;AAMA,SAASC,YAAT,EAAuBC,QAAvB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AE,CAAE,SAAF,CAFX;AAGC,IAAA,SAAS,EAAC,kCAHX;AAIC,IAAA,YAAY,EAAGM,aAJhB;AAKC,IAAA,OAAO;AALR,KAMMwB,KANN,GAQG;AAAA,QAAE;AAAEjB,MAAAA;AAAF,KAAF;AAAA,WACD,8BACC,cAAC,SAAD,QACC,cAAC,QAAD;AACC,MAAA,IAAI,EAAGrB,SADR;AAEC,MAAA,OAAO,EAAG,MAAM;AACfwC,QAAAA,YAAY,CAAE,CAAEb,QAAF,CAAF,EAAgBiB,YAAhB,CAAZ;AACAvB,QAAAA,OAAO;AACP;AALF,OAOGb,EAAE,CAAE,SAAF,CAPL,CADD,EAUC,cAAC,QAAD;AACC,MAAA,IAAI,EAAGP,WADR;AAEC,MAAA,OAAO,EAAG,MAAM;AACfsC,QAAAA,cAAc,CAAE,CAAEZ,QAAF,CAAF,EAAgBiB,YAAhB,CAAd;AACAvB,QAAAA,OAAO;AACP;AALF,OAOGb,EAAE,CAAE,WAAF,CAPL,CAVD,EAmBC,cAAC,cAAD;AAAgB,MAAA,KAAK,EAAGY,KAAxB;AAAgC,MAAA,OAAO,EAAGC;AAA1C,MAnBD,CADD,EAsBC,cAAC,SAAD,QACC,cAAC,QAAD;AACC,MAAA,OAAO,EAAG,MAAM;AACfoB,QAAAA,YAAY,CAAE,CAAEd,QAAF,CAAF,EAAgB,KAAhB,CAAZ;AACAN,QAAAA,OAAO;AACP;AAJF,OAMGqB,WANH,CADD,CAtBD,CADC;AAAA,GARH,CADD;AA8CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport {\n\taddSubmenu,\n\tchevronUp,\n\tchevronDown,\n\tmoreVertical,\n} from '@wordpress/icons';\nimport { DropdownMenu, MenuItem, MenuGroup } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport BlockTitle from '../block-title';\nimport { useListViewContext } from './context';\n\nconst POPOVER_PROPS = {\n\tclassName: 'block-editor-block-settings-menu__popover',\n\tposition: 'bottom right',\n\tvariant: 'toolbar',\n};\n\nconst BLOCKS_THAT_CAN_BE_CONVERTED_TO_SUBMENU = [\n\t'core/navigation-link',\n\t'core/navigation-submenu',\n];\n\nfunction AddSubmenuItem( { block, onClose } ) {\n\tconst { expandedState, expand } = useListViewContext();\n\tconst { insertBlock, replaceBlock, replaceInnerBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst clientId = block.clientId;\n\tconst isDisabled = ! BLOCKS_THAT_CAN_BE_CONVERTED_TO_SUBMENU.includes(\n\t\tblock.name\n\t);\n\treturn (\n\t\t<MenuItem\n\t\t\ticon={ addSubmenu }\n\t\t\tdisabled={ isDisabled }\n\t\t\tonClick={ () => {\n\t\t\t\tconst updateSelectionOnInsert = false;\n\t\t\t\tconst newLink = createBlock( 'core/navigation-link' );\n\n\t\t\t\tif ( block.name === 'core/navigation-submenu' ) {\n\t\t\t\t\tinsertBlock(\n\t\t\t\t\t\tnewLink,\n\t\t\t\t\t\tblock.innerBlocks.length,\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\tupdateSelectionOnInsert\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t// Convert to a submenu if the block currently isn't one.\n\t\t\t\t\tconst newSubmenu = createBlock(\n\t\t\t\t\t\t'core/navigation-submenu',\n\t\t\t\t\t\tblock.attributes,\n\t\t\t\t\t\tblock.innerBlocks\n\t\t\t\t\t);\n\n\t\t\t\t\t// The following must happen as two independent actions.\n\t\t\t\t\t// Why? Because the offcanvas editor relies on the getLastInsertedBlocksClientIds\n\t\t\t\t\t// selector to determine which block is \"active\". As the UX needs the newLink to be\n\t\t\t\t\t// the \"active\" block it must be the last block to be inserted.\n\t\t\t\t\t// Therefore the Submenu is first created and **then** the newLink is inserted\n\t\t\t\t\t// thus ensuring it is the last inserted block.\n\t\t\t\t\treplaceBlock( clientId, newSubmenu );\n\n\t\t\t\t\treplaceInnerBlocks(\n\t\t\t\t\t\tnewSubmenu.clientId,\n\t\t\t\t\t\t[ newLink ],\n\t\t\t\t\t\tupdateSelectionOnInsert\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif ( ! expandedState[ block.clientId ] ) {\n\t\t\t\t\texpand( block.clientId );\n\t\t\t\t}\n\t\t\t\tonClose();\n\t\t\t} }\n\t\t>\n\t\t\t{ __( 'Add submenu link' ) }\n\t\t</MenuItem>\n\t);\n}\n\nexport default function LeafMoreMenu( props ) {\n\tconst { clientId, block } = props;\n\n\tconst { moveBlocksDown, moveBlocksUp, removeBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst removeLabel = sprintf(\n\t\t/* translators: %s: block name */\n\t\t__( 'Remove %s' ),\n\t\tBlockTitle( { clientId, maximumLength: 25 } )\n\t);\n\n\tconst rootClientId = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId } = select( blockEditorStore );\n\n\t\t\treturn getBlockRootClientId( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\ticon={ moreVertical }\n\t\t\tlabel={ __( 'Options' ) }\n\t\t\tclassName=\"block-editor-block-settings-menu\"\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tnoIcons\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\ticon={ chevronUp }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tmoveBlocksUp( [ clientId ], rootClientId );\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Move up' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\ticon={ chevronDown }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tmoveBlocksDown( [ clientId ], rootClientId );\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Move down' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t<AddSubmenuItem block={ block } onClose={ onClose } />\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tremoveBlocks( [ clientId ], false );\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ removeLabel }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"]}
@@ -1,45 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { createElement } from "@wordpress/element";
3
-
4
- /**
5
- * External dependencies
6
- */
7
- import { animated } from '@react-spring/web';
8
- import classnames from 'classnames';
9
- /**
10
- * WordPress dependencies
11
- */
12
-
13
- import { __experimentalTreeGridRow as TreeGridRow } from '@wordpress/components';
14
- /**
15
- * Internal dependencies
16
- */
17
-
18
- import useMovingAnimation from '../use-moving-animation';
19
- const AnimatedTreeGridRow = animated(TreeGridRow);
20
- export default function ListViewLeaf(_ref) {
21
- let {
22
- isSelected,
23
- position,
24
- level,
25
- rowCount,
26
- children,
27
- className,
28
- path,
29
- ...props
30
- } = _ref;
31
- const ref = useMovingAnimation({
32
- isSelected,
33
- adjustScrolling: false,
34
- enableAnimation: true,
35
- triggerAnimationOnChange: path
36
- });
37
- return createElement(AnimatedTreeGridRow, _extends({
38
- ref: ref,
39
- className: classnames('block-editor-list-view-leaf', 'offcanvas-editor-list-view-leaf', className),
40
- level: level,
41
- positionInSet: position,
42
- setSize: rowCount
43
- }, props), children);
44
- }
45
- //# sourceMappingURL=leaf.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/leaf.js"],"names":["animated","classnames","__experimentalTreeGridRow","TreeGridRow","useMovingAnimation","AnimatedTreeGridRow","ListViewLeaf","isSelected","position","level","rowCount","children","className","path","props","ref","adjustScrolling","enableAnimation","triggerAnimationOnChange"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,mBAAzB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,yBAAyB,IAAIC,WAAtC,QAAyD,uBAAzD;AAEA;AACA;AACA;;AACA,OAAOC,kBAAP,MAA+B,yBAA/B;AAEA,MAAMC,mBAAmB,GAAGL,QAAQ,CAAEG,WAAF,CAApC;AAEA,eAAe,SAASG,YAAT,OASX;AAAA,MATkC;AACrCC,IAAAA,UADqC;AAErCC,IAAAA,QAFqC;AAGrCC,IAAAA,KAHqC;AAIrCC,IAAAA,QAJqC;AAKrCC,IAAAA,QALqC;AAMrCC,IAAAA,SANqC;AAOrCC,IAAAA,IAPqC;AAQrC,OAAGC;AARkC,GASlC;AACH,QAAMC,GAAG,GAAGX,kBAAkB,CAAE;AAC/BG,IAAAA,UAD+B;AAE/BS,IAAAA,eAAe,EAAE,KAFc;AAG/BC,IAAAA,eAAe,EAAE,IAHc;AAI/BC,IAAAA,wBAAwB,EAAEL;AAJK,GAAF,CAA9B;AAOA,SACC,cAAC,mBAAD;AACC,IAAA,GAAG,EAAGE,GADP;AAEC,IAAA,SAAS,EAAGd,UAAU,CACrB,6BADqB,EAErB,iCAFqB,EAGrBW,SAHqB,CAFvB;AAOC,IAAA,KAAK,EAAGH,KAPT;AAQC,IAAA,aAAa,EAAGD,QARjB;AASC,IAAA,OAAO,EAAGE;AATX,KAUMI,KAVN,GAYGH,QAZH,CADD;AAgBA","sourcesContent":["/**\n * External dependencies\n */\nimport { animated } from '@react-spring/web';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __experimentalTreeGridRow as TreeGridRow } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport useMovingAnimation from '../use-moving-animation';\n\nconst AnimatedTreeGridRow = animated( TreeGridRow );\n\nexport default function ListViewLeaf( {\n\tisSelected,\n\tposition,\n\tlevel,\n\trowCount,\n\tchildren,\n\tclassName,\n\tpath,\n\t...props\n} ) {\n\tconst ref = useMovingAnimation( {\n\t\tisSelected,\n\t\tadjustScrolling: false,\n\t\tenableAnimation: true,\n\t\ttriggerAnimationOnChange: path,\n\t} );\n\n\treturn (\n\t\t<AnimatedTreeGridRow\n\t\t\tref={ ref }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-list-view-leaf',\n\t\t\t\t'offcanvas-editor-list-view-leaf',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\tlevel={ level }\n\t\t\tpositionInSet={ position }\n\t\t\tsetSize={ rowCount }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ children }\n\t\t</AnimatedTreeGridRow>\n\t);\n}\n"]}
@@ -1,166 +0,0 @@
1
- import { createElement } from "@wordpress/element";
2
- // Note: this file is copied directly from packages/block-library/src/navigation-link/link-ui.js
3
-
4
- /**
5
- * WordPress dependencies
6
- */
7
- import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
8
- import { Popover, Button } from '@wordpress/components';
9
- import { __ } from '@wordpress/i18n';
10
- import { switchToBlockType } from '@wordpress/blocks';
11
- import { useSelect, useDispatch } from '@wordpress/data';
12
- /**
13
- * Internal dependencies
14
- */
15
-
16
- import { store as blockEditorStore } from '../../store';
17
- import LinkControl from '../link-control';
18
- import BlockIcon from '../block-icon';
19
- /**
20
- * Given the Link block's type attribute, return the query params to give to
21
- * /wp/v2/search.
22
- *
23
- * @param {string} type Link block's type attribute.
24
- * @param {string} kind Link block's entity of kind (post-type|taxonomy)
25
- * @return {{ type?: string, subtype?: string }} Search query params.
26
- */
27
-
28
- export function getSuggestionsQuery(type, kind) {
29
- switch (type) {
30
- case 'post':
31
- case 'page':
32
- return {
33
- type: 'post',
34
- subtype: type
35
- };
36
-
37
- case 'category':
38
- return {
39
- type: 'term',
40
- subtype: 'category'
41
- };
42
-
43
- case 'tag':
44
- return {
45
- type: 'term',
46
- subtype: 'post_tag'
47
- };
48
-
49
- case 'post_format':
50
- return {
51
- type: 'post-format'
52
- };
53
-
54
- default:
55
- if (kind === 'taxonomy') {
56
- return {
57
- type: 'term',
58
- subtype: type
59
- };
60
- }
61
-
62
- if (kind === 'post-type') {
63
- return {
64
- type: 'post',
65
- subtype: type
66
- };
67
- }
68
-
69
- return {};
70
- }
71
- }
72
- /**
73
- * Add transforms to Link Control
74
- *
75
- * @param {Object} props Component props.
76
- * @param {string} props.clientId Block client ID.
77
- */
78
-
79
- function LinkControlTransforms(_ref) {
80
- let {
81
- clientId
82
- } = _ref;
83
- const {
84
- getBlock,
85
- blockTransforms
86
- } = useSelect(select => {
87
- const {
88
- getBlock: _getBlock,
89
- getBlockRootClientId,
90
- getBlockTransformItems
91
- } = select(blockEditorStore);
92
- return {
93
- getBlock: _getBlock,
94
- blockTransforms: getBlockTransformItems(_getBlock(clientId), getBlockRootClientId(clientId))
95
- };
96
- }, [clientId]);
97
- const {
98
- replaceBlock
99
- } = useDispatch(blockEditorStore);
100
- const featuredBlocks = ['core/page-list', 'core/site-logo', 'core/social-links', 'core/search'];
101
- const transforms = blockTransforms.filter(item => {
102
- return featuredBlocks.includes(item.name);
103
- });
104
-
105
- if (!(transforms !== null && transforms !== void 0 && transforms.length)) {
106
- return null;
107
- }
108
-
109
- if (!clientId) {
110
- return null;
111
- }
112
-
113
- return createElement("div", {
114
- className: "link-control-transform"
115
- }, createElement("h3", {
116
- className: "link-control-transform__subheading"
117
- }, __('Transform')), createElement("div", {
118
- className: "link-control-transform__items"
119
- }, transforms.map(item => {
120
- return createElement(Button, {
121
- key: `transform-${item.name}`,
122
- onClick: () => replaceBlock(clientId, switchToBlockType(getBlock(clientId), item.name)),
123
- className: "link-control-transform__item"
124
- }, createElement(BlockIcon, {
125
- icon: item.icon
126
- }), item.title);
127
- })));
128
- }
129
-
130
- export function LinkUI(props) {
131
- const {
132
- label,
133
- url,
134
- opensInNewTab,
135
- type,
136
- kind
137
- } = props.link;
138
- const link = {
139
- url,
140
- opensInNewTab,
141
- title: label && stripHTML(label)
142
- };
143
- return createElement(Popover, {
144
- placement: "bottom",
145
- onClose: props.onClose,
146
- anchor: props.anchor,
147
- shift: true
148
- }, createElement(LinkControl, {
149
- hasTextControl: true,
150
- hasRichPreviews: true,
151
- className: props.className,
152
- value: link,
153
- showInitialSuggestions: true,
154
- withCreateSuggestion: props.hasCreateSuggestion,
155
- noDirectEntry: !!type,
156
- noURLSuggestion: !!type,
157
- suggestionsQuery: getSuggestionsQuery(type, kind),
158
- onChange: props.onChange,
159
- onRemove: props.onRemove,
160
- onCancel: props.onCancel,
161
- renderControlBottom: !url ? () => createElement(LinkControlTransforms, {
162
- clientId: props.clientId
163
- }) : null
164
- }));
165
- }
166
- //# sourceMappingURL=link-ui.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/link-ui.js"],"names":["__unstableStripHTML","stripHTML","Popover","Button","__","switchToBlockType","useSelect","useDispatch","store","blockEditorStore","LinkControl","BlockIcon","getSuggestionsQuery","type","kind","subtype","LinkControlTransforms","clientId","getBlock","blockTransforms","select","_getBlock","getBlockRootClientId","getBlockTransformItems","replaceBlock","featuredBlocks","transforms","filter","item","includes","name","length","map","icon","title","LinkUI","props","label","url","opensInNewTab","link","onClose","anchor","className","hasCreateSuggestion","onChange","onRemove","onCancel"],"mappings":";AAAA;;AAEA;AACA;AACA;AACA,SAASA,mBAAmB,IAAIC,SAAhC,QAAiD,gBAAjD;AACA,SAASC,OAAT,EAAkBC,MAAlB,QAAgC,uBAAhC;AACA,SAASC,EAAT,QA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GF,KAAK,CAACnB;AADlB,MAFH,GAMG;AApBL,IAND,CADD;AAgCA","sourcesContent":["// Note: this file is copied directly from packages/block-library/src/navigation-link/link-ui.js\n\n/**\n * WordPress dependencies\n */\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { Popover, Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { switchToBlockType } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport LinkControl from '../link-control';\nimport BlockIcon from '../block-icon';\n\n/**\n * Given the Link block's type attribute, return the query params to give to\n * /wp/v2/search.\n *\n * @param {string} type Link block's type attribute.\n * @param {string} kind Link block's entity of kind (post-type|taxonomy)\n * @return {{ type?: string, subtype?: string }} Search query params.\n */\nexport function getSuggestionsQuery( type, kind ) {\n\tswitch ( type ) {\n\t\tcase 'post':\n\t\tcase 'page':\n\t\t\treturn { type: 'post', subtype: type };\n\t\tcase 'category':\n\t\t\treturn { type: 'term', subtype: 'category' };\n\t\tcase 'tag':\n\t\t\treturn { type: 'term', subtype: 'post_tag' };\n\t\tcase 'post_format':\n\t\t\treturn { type: 'post-format' };\n\t\tdefault:\n\t\t\tif ( kind === 'taxonomy' ) {\n\t\t\t\treturn { type: 'term', subtype: type };\n\t\t\t}\n\t\t\tif ( kind === 'post-type' ) {\n\t\t\t\treturn { type: 'post', subtype: type };\n\t\t\t}\n\t\t\treturn {};\n\t}\n}\n\n/**\n * Add transforms to Link Control\n *\n * @param {Object} props Component props.\n * @param {string} props.clientId Block client ID.\n */\nfunction LinkControlTransforms( { clientId } ) {\n\tconst { getBlock, blockTransforms } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlock: _getBlock,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockTransformItems,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\tgetBlock: _getBlock,\n\t\t\t\tblockTransforms: getBlockTransformItems(\n\t\t\t\t\t_getBlock( clientId ),\n\t\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { replaceBlock } = useDispatch( blockEditorStore );\n\n\tconst featuredBlocks = [\n\t\t'core/page-list',\n\t\t'core/site-logo',\n\t\t'core/social-links',\n\t\t'core/search',\n\t];\n\n\tconst transforms = blockTransforms.filter( ( item ) => {\n\t\treturn featuredBlocks.includes( item.name );\n\t} );\n\n\tif ( ! transforms?.length ) {\n\t\treturn null;\n\t}\n\n\tif ( ! clientId ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div className=\"link-control-transform\">\n\t\t\t<h3 className=\"link-control-transform__subheading\">\n\t\t\t\t{ __( 'Transform' ) }\n\t\t\t</h3>\n\t\t\t<div className=\"link-control-transform__items\">\n\t\t\t\t{ transforms.map( ( item ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ `transform-${ item.name }` }\n\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\treplaceBlock(\n\t\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\t\tswitchToBlockType(\n\t\t\t\t\t\t\t\t\t\tgetBlock( clientId ),\n\t\t\t\t\t\t\t\t\t\titem.name\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tclassName=\"link-control-transform__item\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockIcon icon={ item.icon } />\n\t\t\t\t\t\t\t{ item.title }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nexport function LinkUI( props ) {\n\tconst { label, url, opensInNewTab, type, kind } = props.link;\n\tconst link = {\n\t\turl,\n\t\topensInNewTab,\n\t\ttitle: label && stripHTML( label ),\n\t};\n\n\treturn (\n\t\t<Popover\n\t\t\tplacement=\"bottom\"\n\t\t\tonClose={ props.onClose }\n\t\t\tanchor={ props.anchor }\n\t\t\tshift\n\t\t>\n\t\t\t<LinkControl\n\t\t\t\thasTextControl\n\t\t\t\thasRichPreviews\n\t\t\t\tclassName={ props.className }\n\t\t\t\tvalue={ link }\n\t\t\t\tshowInitialSuggestions={ true }\n\t\t\t\twithCreateSuggestion={ props.hasCreateSuggestion }\n\t\t\t\tnoDirectEntry={ !! type }\n\t\t\t\tnoURLSuggestion={ !! type }\n\t\t\t\tsuggestionsQuery={ getSuggestionsQuery( type, kind ) }\n\t\t\t\tonChange={ props.onChange }\n\t\t\t\tonRemove={ props.onRemove }\n\t\t\t\tonCancel={ props.onCancel }\n\t\t\t\trenderControlBottom={\n\t\t\t\t\t! url\n\t\t\t\t\t\t? () => (\n\t\t\t\t\t\t\t\t<LinkControlTransforms\n\t\t\t\t\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: null\n\t\t\t\t}\n\t\t\t/>\n\t\t</Popover>\n\t);\n}\n"]}
@@ -1,97 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { escapeHTML } from '@wordpress/escape-html';
5
- import { safeDecodeURI } from '@wordpress/url';
6
- /**
7
- * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind
8
- */
9
-
10
- /**
11
- * Navigation Link Block Attributes
12
- *
13
- * @typedef {Object} WPNavigationLinkBlockAttributes
14
- *
15
- * @property {string} [label] Link text.
16
- * @property {WPNavigationLinkKind} [kind] Kind is used to differentiate between term and post ids to check post draft status.
17
- * @property {string} [type] The type such as post, page, tag, category and other custom types.
18
- * @property {string} [rel] The relationship of the linked URL.
19
- * @property {number} [id] A post or term id.
20
- * @property {boolean} [opensInNewTab] Sets link target to _blank when true.
21
- * @property {string} [url] Link href.
22
- * @property {string} [title] Link title attribute.
23
- */
24
-
25
- /**
26
- * Link Control onChange handler that updates block attributes when a setting is changed.
27
- *
28
- * @param {Object} updatedValue New block attributes to update.
29
- * @param {Function} setAttributes Block attribute update function.
30
- * @param {WPNavigationLinkBlockAttributes} blockAttributes Current block attributes.
31
- *
32
- */
33
-
34
- export const updateAttributes = function () {
35
- let updatedValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
36
- let setAttributes = arguments.length > 1 ? arguments[1] : undefined;
37
- let blockAttributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
38
- const {
39
- label: originalLabel = '',
40
- kind: originalKind = '',
41
- type: originalType = ''
42
- } = blockAttributes;
43
- const {
44
- title: newLabel = '',
45
- // the title of any provided Post.
46
- url: newUrl = '',
47
- opensInNewTab,
48
- id,
49
- kind: newKind = originalKind,
50
- type: newType = originalType
51
- } = updatedValue;
52
- const newLabelWithoutHttp = newLabel.replace(/http(s?):\/\//gi, '');
53
- const newUrlWithoutHttp = newUrl.replace(/http(s?):\/\//gi, '');
54
- const useNewLabel = newLabel && newLabel !== originalLabel && // LinkControl without the title field relies
55
- // on the check below. Specifically, it assumes that
56
- // the URL is the same as a title.
57
- // This logic a) looks suspicious and b) should really
58
- // live in the LinkControl and not here. It's a great
59
- // candidate for future refactoring.
60
- newLabelWithoutHttp !== newUrlWithoutHttp; // Unfortunately this causes the escaping model to be inverted.
61
- // The escaped content is stored in the block attributes (and ultimately in the database),
62
- // and then the raw data is "recovered" when outputting into the DOM.
63
- // It would be preferable to store the **raw** data in the block attributes and escape it in JS.
64
- // Why? Because there isn't one way to escape data. Depending on the context, you need to do
65
- // different transforms. It doesn't make sense to me to choose one of them for the purposes of storage.
66
- // See also:
67
- // - https://github.com/WordPress/gutenberg/pull/41063
68
- // - https://github.com/WordPress/gutenberg/pull/18617.
69
-
70
- const label = useNewLabel ? escapeHTML(newLabel) : originalLabel || escapeHTML(newUrlWithoutHttp); // In https://github.com/WordPress/gutenberg/pull/24670 we decided to use "tag" in favor of "post_tag"
71
-
72
- const type = newType === 'post_tag' ? 'tag' : newType.replace('-', '_');
73
- const isBuiltInType = ['post', 'page', 'tag', 'category'].indexOf(type) > -1;
74
- const isCustomLink = !newKind && !isBuiltInType || newKind === 'custom';
75
- const kind = isCustomLink ? 'custom' : newKind;
76
- setAttributes({ // Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.
77
- ...(newUrl && {
78
- url: encodeURI(safeDecodeURI(newUrl))
79
- }),
80
- ...(label && {
81
- label
82
- }),
83
- ...(undefined !== opensInNewTab && {
84
- opensInNewTab
85
- }),
86
- ...(id && Number.isInteger(id) && {
87
- id
88
- }),
89
- ...(kind && {
90
- kind
91
- }),
92
- ...(type && type !== 'URL' && {
93
- type
94
- })
95
- });
96
- };
97
- //# sourceMappingURL=update-attributes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/update-attributes.js"],"names":["escapeHTML","safeDecodeURI","updateAttributes","updatedValue","setAttributes","blockAttributes","label","originalLabel","kind","originalKind","type","originalType","title","newLabel","url","newUrl","opensInNewTab","id","newKind","newType","newLabelWithoutHttp","replace","newUrlWithoutHttp","useNewLabel","isBuiltInType","indexOf","isCustomLink","encodeURI","undefined","Number","isInteger"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,wBAA3B;AACA,SAASC,aAAT,QAA8B,gBAA9B;AAEA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,gBAAgB,GAAG,YAI3B;AAAA,MAHJC,YAGI,uEAHW,EAGX;AAAA,MAFJC,aAEI;AAAA,MADJC,eACI,uEADc,EACd;AACJ,QAAM;AACLC,IAAAA,KAAK,EAAEC,aAAa,GAAG,EADlB;AAELC,IAAAA,IAAI,EAAEC,YAAY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E,EACd;AACA,QAAKW,MAAM,IAAI;AAAED,MAAAA,GAAG,EAAEa,SAAS,CAAE1B,aAAa,CAAEc,MAAF,CAAf;AAAhB,KAAf,CAFc;AAGd,QAAKT,KAAK,IAAI;AAAEA,MAAAA;AAAF,KAAd,CAHc;AAId,QAAKsB,SAAS,KAAKZ,aAAd,IAA+B;AAAEA,MAAAA;AAAF,KAApC,CAJc;AAKd,QAAKC,EAAE,IAAIY,MAAM,CAACC,SAAP,CAAkBb,EAAlB,CAAN,IAAgC;AAAEA,MAAAA;AAAF,KAArC,CALc;AAMd,QAAKT,IAAI,IAAI;AAAEA,MAAAA;AAAF,KAAb,CANc;AAOd,QAAKE,IAAI,IAAIA,IAAI,KAAK,KAAjB,IAA0B;AAAEA,MAAAA;AAAF,KAA/B;AAPc,GAAF,CAAb;AASA,CAlEM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { escapeHTML } from '@wordpress/escape-html';\nimport { safeDecodeURI } from '@wordpress/url';\n\n/**\n * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind\n */\n/**\n * Navigation Link Block Attributes\n *\n * @typedef {Object} WPNavigationLinkBlockAttributes\n *\n * @property {string} [label] Link text.\n * @property {WPNavigationLinkKind} [kind] Kind is used to differentiate between term and post ids to check post draft status.\n * @property {string} [type] The type such as post, page, tag, category and other custom types.\n * @property {string} [rel] The relationship of the linked URL.\n * @property {number} [id] A post or term id.\n * @property {boolean} [opensInNewTab] Sets link target to _blank when true.\n * @property {string} [url] Link href.\n * @property {string} [title] Link title attribute.\n */\n/**\n * Link Control onChange handler that updates block attributes when a setting is changed.\n *\n * @param {Object} updatedValue New block attributes to update.\n * @param {Function} setAttributes Block attribute update function.\n * @param {WPNavigationLinkBlockAttributes} blockAttributes Current block attributes.\n *\n */\n\nexport const updateAttributes = (\n\tupdatedValue = {},\n\tsetAttributes,\n\tblockAttributes = {}\n) => {\n\tconst {\n\t\tlabel: originalLabel = '',\n\t\tkind: originalKind = '',\n\t\ttype: originalType = '',\n\t} = blockAttributes;\n\n\tconst {\n\t\ttitle: newLabel = '', // the title of any provided Post.\n\t\turl: newUrl = '',\n\t\topensInNewTab,\n\t\tid,\n\t\tkind: newKind = originalKind,\n\t\ttype: newType = originalType,\n\t} = updatedValue;\n\n\tconst newLabelWithoutHttp = newLabel.replace( /http(s?):\\/\\//gi, '' );\n\tconst newUrlWithoutHttp = newUrl.replace( /http(s?):\\/\\//gi, '' );\n\n\tconst useNewLabel =\n\t\tnewLabel &&\n\t\tnewLabel !== originalLabel &&\n\t\t// LinkControl without the title field relies\n\t\t// on the check below. Specifically, it assumes that\n\t\t// the URL is the same as a title.\n\t\t// This logic a) looks suspicious and b) should really\n\t\t// live in the LinkControl and not here. It's a great\n\t\t// candidate for future refactoring.\n\t\tnewLabelWithoutHttp !== newUrlWithoutHttp;\n\n\t// Unfortunately this causes the escaping model to be inverted.\n\t// The escaped content is stored in the block attributes (and ultimately in the database),\n\t// and then the raw data is \"recovered\" when outputting into the DOM.\n\t// It would be preferable to store the **raw** data in the block attributes and escape it in JS.\n\t// Why? Because there isn't one way to escape data. Depending on the context, you need to do\n\t// different transforms. It doesn't make sense to me to choose one of them for the purposes of storage.\n\t// See also:\n\t// - https://github.com/WordPress/gutenberg/pull/41063\n\t// - https://github.com/WordPress/gutenberg/pull/18617.\n\tconst label = useNewLabel\n\t\t? escapeHTML( newLabel )\n\t\t: originalLabel || escapeHTML( newUrlWithoutHttp );\n\n\t// In https://github.com/WordPress/gutenberg/pull/24670 we decided to use \"tag\" in favor of \"post_tag\"\n\tconst type = newType === 'post_tag' ? 'tag' : newType.replace( '-', '_' );\n\n\tconst isBuiltInType =\n\t\t[ 'post', 'page', 'tag', 'category' ].indexOf( type ) > -1;\n\n\tconst isCustomLink =\n\t\t( ! newKind && ! isBuiltInType ) || newKind === 'custom';\n\tconst kind = isCustomLink ? 'custom' : newKind;\n\n\tsetAttributes( {\n\t\t// Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.\n\t\t...( newUrl && { url: encodeURI( safeDecodeURI( newUrl ) ) } ),\n\t\t...( label && { label } ),\n\t\t...( undefined !== opensInNewTab && { opensInNewTab } ),\n\t\t...( id && Number.isInteger( id ) && { id } ),\n\t\t...( kind && { kind } ),\n\t\t...( type && type !== 'URL' && { type } ),\n\t} );\n};\n"]}
@@ -1,124 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { speak } from '@wordpress/a11y';
5
- import { __, sprintf } from '@wordpress/i18n';
6
- import { useDispatch, useSelect } from '@wordpress/data';
7
- import { useCallback } from '@wordpress/element';
8
- import { UP, DOWN, HOME, END } from '@wordpress/keycodes';
9
- import { store as blocksStore } from '@wordpress/blocks';
10
- /**
11
- * Internal dependencies
12
- */
13
-
14
- import { store as blockEditorStore } from '../../store';
15
- import { getCommonDepthClientIds } from './utils';
16
- export default function useBlockSelection() {
17
- const {
18
- clearSelectedBlock,
19
- multiSelect,
20
- selectBlock
21
- } = useDispatch(blockEditorStore);
22
- const {
23
- getBlockName,
24
- getBlockParents,
25
- getBlockSelectionStart,
26
- getBlockSelectionEnd,
27
- getSelectedBlockClientIds,
28
- hasMultiSelection,
29
- hasSelectedBlock
30
- } = useSelect(blockEditorStore);
31
- const {
32
- getBlockType
33
- } = useSelect(blocksStore);
34
- const updateBlockSelection = useCallback(async (event, clientId, destinationClientId) => {
35
- if (!(event !== null && event !== void 0 && event.shiftKey)) {
36
- selectBlock(clientId);
37
- return;
38
- } // To handle multiple block selection via the `SHIFT` key, prevent
39
- // the browser default behavior of opening the link in a new window.
40
-
41
-
42
- event.preventDefault();
43
- const isKeyPress = event.type === 'keydown' && (event.keyCode === UP || event.keyCode === DOWN || event.keyCode === HOME || event.keyCode === END); // Handle clicking on a block when no blocks are selected, and return early.
44
-
45
- if (!isKeyPress && !hasSelectedBlock() && !hasMultiSelection()) {
46
- selectBlock(clientId, null);
47
- return;
48
- }
49
-
50
- const selectedBlocks = getSelectedBlockClientIds();
51
- const clientIdWithParents = [...getBlockParents(clientId), clientId];
52
-
53
- if (isKeyPress && !selectedBlocks.some(blockId => clientIdWithParents.includes(blockId))) {
54
- // Ensure that shift-selecting blocks via the keyboard only
55
- // expands the current selection if focusing over already
56
- // selected blocks. Otherwise, clear the selection so that
57
- // a user can create a new selection entirely by keyboard.
58
- await clearSelectedBlock();
59
- }
60
-
61
- let startTarget = getBlockSelectionStart();
62
- let endTarget = clientId; // Handle keyboard behavior for selecting multiple blocks.
63
-
64
- if (isKeyPress) {
65
- if (!hasSelectedBlock() && !hasMultiSelection()) {
66
- // Set the starting point of the selection to the currently
67
- // focused block, if there are no blocks currently selected.
68
- // This ensures that as the selection is expanded or contracted,
69
- // the starting point of the selection is anchored to that block.
70
- startTarget = clientId;
71
- }
72
-
73
- if (destinationClientId) {
74
- // If the user presses UP or DOWN, we want to ensure that the block they're
75
- // moving to is the target for selection, and not the currently focused one.
76
- endTarget = destinationClientId;
77
- }
78
- }
79
-
80
- const startParents = getBlockParents(startTarget);
81
- const endParents = getBlockParents(endTarget);
82
- const {
83
- start,
84
- end
85
- } = getCommonDepthClientIds(startTarget, endTarget, startParents, endParents);
86
- await multiSelect(start, end, null); // Announce deselected block, or number of deselected blocks if
87
- // the total number of blocks deselected is greater than one.
88
-
89
- const updatedSelectedBlocks = getSelectedBlockClientIds(); // If the selection is greater than 1 and the Home or End keys
90
- // were used to generate the selection, then skip announcing the
91
- // deselected blocks.
92
-
93
- if ((event.keyCode === HOME || event.keyCode === END) && updatedSelectedBlocks.length > 1) {
94
- return;
95
- }
96
-
97
- const selectionDiff = selectedBlocks.filter(blockId => !updatedSelectedBlocks.includes(blockId));
98
- let label;
99
-
100
- if (selectionDiff.length === 1) {
101
- var _getBlockType;
102
-
103
- const title = (_getBlockType = getBlockType(getBlockName(selectionDiff[0]))) === null || _getBlockType === void 0 ? void 0 : _getBlockType.title;
104
-
105
- if (title) {
106
- label = sprintf(
107
- /* translators: %s: block name */
108
- __('%s deselected.'), title);
109
- }
110
- } else if (selectionDiff.length > 1) {
111
- label = sprintf(
112
- /* translators: %s: number of deselected blocks */
113
- __('%s blocks deselected.'), selectionDiff.length);
114
- }
115
-
116
- if (label) {
117
- speak(label);
118
- }
119
- }, [clearSelectedBlock, getBlockName, getBlockType, getBlockParents, getBlockSelectionStart, getBlockSelectionEnd, getSelectedBlockClientIds, hasMultiSelection, hasSelectedBlock, multiSelect, selectBlock]);
120
- return {
121
- updateBlockSelection
122
- };
123
- }
124
- //# 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":["speak","__","sprintf","useDispatch","useSelect","useCallback","UP","DOWN","HOME","END","store","blocksStore","blockEditorStore","getCommonDepthClientIds","useBlockSelection","clearSelectedBlock","multiSelect","selectBlock","getBlockName","getBlockParents","getBlockSelectionStart","getBlockSelectionEnd","getSelectedBlockClientIds","hasMultiSelection","hasSelectedBlock","getBlockType","updateBlockSelection","event","clientId","destinationClientId","shiftKey","preventDefault","isKeyPress","type","keyCode","selectedBlocks","clientIdWithParents","some","blockId","includes","startTarget","endTarget","startParents","endParents","start","end","updatedSelectedBlocks","length","selectionDiff","filter","label","title"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAT,QAAsB,iBAAtB;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,WAAT,QAA4B,oBAA5B;AACA,SAASC,EAAT,EAAaC,IAAb,EAAmBC,IAAnB,EAAyBC,GAAzB,QAAoC,qBAApC;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AAEA;AACA;AACA;;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,aAA1C;AACA,SAASC,uBAAT,QAAwC,SAAxC;AAEA,eAAe,SAASC,iBAAT,GAA6B;AAC3C,QAAM;AAAEC,IAAAA,kBAAF;AA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AAa,CAAE,CAAF,CAAf,CADa,CAAf,kDAAG,cAEXG,KAFH;;AAGA,UAAKA,KAAL,EAAa;AACZD,QAAAA,KAAK,GAAGhD,OAAO;AACd;AACAD,QAAAA,EAAE,CAAE,gBAAF,CAFY,EAGdkD,KAHc,CAAf;AAKA;AACD,KAXD,MAWO,IAAKH,aAAa,CAACD,MAAd,GAAuB,CAA5B,EAAgC;AACtCG,MAAAA,KAAK,GAAGhD,OAAO;AACd;AACAD,MAAAA,EAAE,CAAE,uBAAF,CAFY,EAGd+C,aAAa,CAACD,MAHA,CAAf;AAKA;;AAED,QAAKG,KAAL,EAAa;AACZlD,MAAAA,KAAK,CAAEkD,KAAF,CAAL;AACA;AACD,GAtHsC,EAuHvC,CACCnC,kBADD,EAECG,YAFD,EAGCO,YAHD,EAICN,eAJD,EAKCC,sBALD,EAMCC,oBAND,EAOCC,yBAPD,EAQCC,iBARD,EASCC,gBATD,EAUCR,WAVD,EAWCC,WAXD,CAvHuC,CAAxC;AAsIA,SAAO;AACNS,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"]}