@wordpress/block-editor 9.2.0 → 9.5.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 (693) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +1 -8
  3. package/build/autocompleters/block.js +3 -1
  4. package/build/autocompleters/block.js.map +1 -1
  5. package/build/components/block-actions/index.js.map +1 -1
  6. package/build/components/block-alignment-control/ui.js.map +1 -1
  7. package/build/components/block-alignment-matrix-control/index.js +3 -7
  8. package/build/components/block-alignment-matrix-control/index.js.map +1 -1
  9. package/build/components/block-breadcrumb/index.js.map +1 -1
  10. package/build/components/block-content-overlay/index.js.map +1 -1
  11. package/build/components/block-context/index.js.map +1 -1
  12. package/build/components/block-controls/hook.js.map +1 -1
  13. package/build/components/block-draggable/index.js.map +1 -1
  14. package/build/components/block-draggable/index.native.js.map +1 -1
  15. package/build/components/block-list/block-invalid-warning.native.js +54 -6
  16. package/build/components/block-list/block-invalid-warning.native.js.map +1 -1
  17. package/build/components/block-list/block-list-item.native.js.map +1 -1
  18. package/build/components/block-list/block-selection-button.native.js.map +1 -1
  19. package/build/components/block-list/block.js +2 -2
  20. package/build/components/block-list/block.js.map +1 -1
  21. package/build/components/block-list/block.native.js +2 -1
  22. package/build/components/block-list/block.native.js.map +1 -1
  23. package/build/components/block-list/index.js.map +1 -1
  24. package/build/components/block-list/index.native.js +4 -3
  25. package/build/components/block-list/index.native.js.map +1 -1
  26. package/build/components/block-list/layout.js +20 -5
  27. package/build/components/block-list/layout.js.map +1 -1
  28. package/build/components/block-list/use-block-props/index.js.map +1 -1
  29. package/build/components/block-list/use-block-props/use-block-class-names.js +5 -2
  30. package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  31. package/build/components/block-list/use-block-props/use-block-custom-class-name.js.map +1 -1
  32. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
  33. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  34. package/build/components/block-list-appender/index.js.map +1 -1
  35. package/build/components/block-list-appender/index.native.js.map +1 -1
  36. package/build/components/block-lock/modal.js +35 -5
  37. package/build/components/block-lock/modal.js.map +1 -1
  38. package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  39. package/build/components/block-mover/button.js.map +1 -1
  40. package/build/components/block-mover/index.native.js.map +1 -1
  41. package/build/components/block-parent-selector/index.js.map +1 -1
  42. package/build/components/block-pattern-setup/index.js +8 -26
  43. package/build/components/block-pattern-setup/index.js.map +1 -1
  44. package/build/components/block-pattern-setup/setup-toolbar.js +3 -8
  45. package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  46. package/build/components/block-popover/inbetween.js +1 -1
  47. package/build/components/block-popover/inbetween.js.map +1 -1
  48. package/build/components/block-popover/index.js +1 -1
  49. package/build/components/block-popover/index.js.map +1 -1
  50. package/build/components/block-preview/auto.js +21 -5
  51. package/build/components/block-preview/auto.js.map +1 -1
  52. package/build/components/block-selection-clearer/index.js.map +1 -1
  53. package/build/components/block-settings-menu/block-edit-visually-button.js +70 -0
  54. package/build/components/block-settings-menu/block-edit-visually-button.js.map +1 -0
  55. package/build/components/block-settings-menu/block-mode-toggle.js +4 -8
  56. package/build/components/block-settings-menu/block-mode-toggle.js.map +1 -1
  57. package/build/components/block-settings-menu/block-settings-dropdown.js +10 -4
  58. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  59. package/build/components/block-settings-menu/index.js +6 -2
  60. package/build/components/block-settings-menu/index.js.map +1 -1
  61. package/build/components/block-settings-menu-controls/index.js +4 -1
  62. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  63. package/build/components/block-styles/index.js +6 -3
  64. package/build/components/block-styles/index.js.map +1 -1
  65. package/build/components/block-styles/menu-items.js +3 -7
  66. package/build/components/block-styles/menu-items.js.map +1 -1
  67. package/build/components/block-styles/preview.native.js +3 -1
  68. package/build/components/block-styles/preview.native.js.map +1 -1
  69. package/build/components/block-switcher/block-transformations-menu.js.map +1 -1
  70. package/build/components/block-switcher/index.js +7 -1
  71. package/build/components/block-switcher/index.js.map +1 -1
  72. package/build/components/block-title/index.js +8 -2
  73. package/build/components/block-title/index.js.map +1 -1
  74. package/build/components/block-title/use-block-display-title.js +15 -15
  75. package/build/components/block-title/use-block-display-title.js.map +1 -1
  76. package/build/components/block-toolbar/index.native.js.map +1 -1
  77. package/build/components/block-toolbar/utils.js +5 -8
  78. package/build/components/block-toolbar/utils.js.map +1 -1
  79. package/build/components/block-tools/block-contextual-toolbar.js +1 -1
  80. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  81. package/build/components/block-tools/index.js.map +1 -1
  82. package/build/components/block-types-list/index.native.js.map +1 -1
  83. package/build/components/block-variation-transforms/index.js.map +1 -1
  84. package/build/components/border-radius-control/index.js +2 -0
  85. package/build/components/border-radius-control/index.js.map +1 -1
  86. package/build/components/color-style-selector/index.js.map +1 -1
  87. package/build/components/colors/with-colors.js +1 -1
  88. package/build/components/colors/with-colors.js.map +1 -1
  89. package/build/components/colors-gradients/control.js +45 -39
  90. package/build/components/colors-gradients/control.js.map +1 -1
  91. package/build/components/colors-gradients/dropdown.js +2 -1
  92. package/build/components/colors-gradients/dropdown.js.map +1 -1
  93. package/build/components/convert-to-group-buttons/toolbar.js.map +1 -1
  94. package/build/components/copy-handler/index.js +17 -1
  95. package/build/components/copy-handler/index.js.map +1 -1
  96. package/build/components/date-format-picker/index.js +1 -1
  97. package/build/components/date-format-picker/index.js.map +1 -1
  98. package/build/components/default-block-appender/index.js.map +1 -1
  99. package/build/components/default-block-appender/index.native.js.map +1 -1
  100. package/build/components/default-style-picker/index.js.map +1 -1
  101. package/build/components/duotone/components.js +145 -0
  102. package/build/components/duotone/components.js.map +1 -0
  103. package/build/components/duotone/index.js +40 -0
  104. package/build/components/duotone/index.js.map +1 -0
  105. package/build/components/duotone/utils.js +38 -0
  106. package/build/components/duotone/utils.js.map +1 -0
  107. package/build/components/duotone-control/index.js +17 -5
  108. package/build/components/duotone-control/index.js.map +1 -1
  109. package/build/components/font-sizes/with-font-sizes.js.map +1 -1
  110. package/build/components/iframe/index.js +19 -6
  111. package/build/components/iframe/index.js.map +1 -1
  112. package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  113. package/build/components/image-size-control/index.js +3 -1
  114. package/build/components/image-size-control/index.js.map +1 -1
  115. package/build/components/index.js +32 -0
  116. package/build/components/index.js.map +1 -1
  117. package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  118. package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  119. package/build/components/inserter/block-types-tab.native.js.map +1 -1
  120. package/build/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
  121. package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
  122. package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
  123. package/build/components/inserter/index.js +3 -3
  124. package/build/components/inserter/index.js.map +1 -1
  125. package/build/components/inserter/index.native.js.map +1 -1
  126. package/build/components/inserter/library.js +3 -7
  127. package/build/components/inserter/library.js.map +1 -1
  128. package/build/components/inserter/menu.js.map +1 -1
  129. package/build/components/inserter/menu.native.js.map +1 -1
  130. package/build/components/inserter/no-results.native.js.map +1 -1
  131. package/build/components/inserter/quick-inserter.js.map +1 -1
  132. package/build/components/inserter/search-items.js +1 -1
  133. package/build/components/inserter/search-items.js.map +1 -1
  134. package/build/components/inserter/search-results.native.js.map +1 -1
  135. package/build/components/inspector-popover-header/index.js +56 -0
  136. package/build/components/inspector-popover-header/index.js.map +1 -0
  137. package/build/components/line-height-control/index.js.map +1 -1
  138. package/build/components/link-control/index.js +5 -5
  139. package/build/components/link-control/index.js.map +1 -1
  140. package/build/components/link-control/search-create-button.js +1 -3
  141. package/build/components/link-control/search-create-button.js.map +1 -1
  142. package/build/components/link-control/search-input.js +5 -3
  143. package/build/components/link-control/search-input.js.map +1 -1
  144. package/build/components/link-control/settings-drawer.js +3 -7
  145. package/build/components/link-control/settings-drawer.js.map +1 -1
  146. package/build/components/link-control/use-search-handler.js.map +1 -1
  147. package/build/components/list-view/block-contents.js.map +1 -1
  148. package/build/components/list-view/block-select-button.js +15 -7
  149. package/build/components/list-view/block-select-button.js.map +1 -1
  150. package/build/components/list-view/branch.js.map +1 -1
  151. package/build/components/list-view/drop-indicator.js +1 -1
  152. package/build/components/list-view/drop-indicator.js.map +1 -1
  153. package/build/components/list-view/index.js.map +1 -1
  154. package/build/components/list-view/use-block-selection.js.map +1 -1
  155. package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
  156. package/build/components/list-view/utils.js +1 -7
  157. package/build/components/list-view/utils.js.map +1 -1
  158. package/build/components/media-placeholder/index.js +18 -6
  159. package/build/components/media-placeholder/index.js.map +1 -1
  160. package/build/components/media-placeholder/index.native.js +4 -4
  161. package/build/components/media-placeholder/index.native.js.map +1 -1
  162. package/build/components/media-replace-flow/index.js +25 -17
  163. package/build/components/media-replace-flow/index.js.map +1 -1
  164. package/build/components/media-upload/index.native.js +1 -1
  165. package/build/components/media-upload/index.native.js.map +1 -1
  166. package/build/components/navigable-toolbar/index.js.map +1 -1
  167. package/build/components/plain-text/index.native.js.map +1 -1
  168. package/build/components/preview-options/index.js +4 -0
  169. package/build/components/preview-options/index.js.map +1 -1
  170. package/build/components/provider/use-block-sync.js +5 -3
  171. package/build/components/provider/use-block-sync.js.map +1 -1
  172. package/build/components/publish-date-time-picker/index.js +17 -16
  173. package/build/components/publish-date-time-picker/index.js.map +1 -1
  174. package/build/components/rich-text/embed-handler-picker.native.js +4 -8
  175. package/build/components/rich-text/embed-handler-picker.native.js.map +1 -1
  176. package/build/components/rich-text/index.js.map +1 -1
  177. package/build/components/rich-text/use-format-types.js.map +1 -1
  178. package/build/components/rich-text/use-input-rules.js +4 -13
  179. package/build/components/rich-text/use-input-rules.js.map +1 -1
  180. package/build/components/rich-text/use-mark-persistent.js.map +1 -1
  181. package/build/components/rich-text/use-paste-handler.js +20 -5
  182. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  183. package/build/components/skip-to-selected-block/index.js.map +1 -1
  184. package/build/components/ungroup-button/index.native.js +3 -7
  185. package/build/components/ungroup-button/index.native.js.map +1 -1
  186. package/build/components/url-input/index.js +14 -3
  187. package/build/components/url-input/index.js.map +1 -1
  188. package/build/components/url-popover/index.js +2 -1
  189. package/build/components/url-popover/index.js.map +1 -1
  190. package/build/components/use-block-display-information/index.js.map +1 -1
  191. package/build/components/use-block-drop-zone/index.js.map +1 -1
  192. package/build/components/use-block-drop-zone/index.native.js.map +1 -1
  193. package/build/components/use-display-block-controls/index.native.js.map +1 -1
  194. package/build/components/use-on-block-drop/index.js.map +1 -1
  195. package/build/components/use-on-block-drop/index.native.js.map +1 -1
  196. package/build/components/use-setting/index.js.map +1 -1
  197. package/build/components/writing-flow/use-arrow-nav.js +46 -14
  198. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  199. package/build/components/writing-flow/use-click-selection.js.map +1 -1
  200. package/build/components/writing-flow/use-drag-selection.js.map +1 -1
  201. package/build/components/writing-flow/use-multi-selection.js +3 -47
  202. package/build/components/writing-flow/use-multi-selection.js.map +1 -1
  203. package/build/components/writing-flow/use-select-all.js.map +1 -1
  204. package/build/components/writing-flow/use-selection-observer.js +1 -3
  205. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  206. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  207. package/build/elements/index.js +11 -3
  208. package/build/elements/index.js.map +1 -1
  209. package/build/hooks/aria-label.js +71 -0
  210. package/build/hooks/aria-label.js.map +1 -0
  211. package/build/hooks/color-panel.js.map +1 -1
  212. package/build/hooks/color-panel.native.js.map +1 -1
  213. package/build/hooks/color.js +2 -4
  214. package/build/hooks/color.js.map +1 -1
  215. package/build/hooks/duotone.js +33 -160
  216. package/build/hooks/duotone.js.map +1 -1
  217. package/build/hooks/font-family.js.map +1 -1
  218. package/build/hooks/gap.js.map +1 -1
  219. package/build/hooks/index.js +11 -7
  220. package/build/hooks/index.js.map +1 -1
  221. package/build/hooks/layout.js +74 -8
  222. package/build/hooks/layout.js.map +1 -1
  223. package/build/hooks/utils.js +5 -3
  224. package/build/hooks/utils.js.map +1 -1
  225. package/build/index.js +7 -7
  226. package/build/index.js.map +1 -1
  227. package/build/layouts/flex.js +42 -38
  228. package/build/layouts/flex.js.map +1 -1
  229. package/build/layouts/flow.js +10 -35
  230. package/build/layouts/flow.js.map +1 -1
  231. package/build/layouts/utils.js +35 -3
  232. package/build/layouts/utils.js.map +1 -1
  233. package/build/store/actions.js +24 -31
  234. package/build/store/actions.js.map +1 -1
  235. package/build/store/index.js +0 -4
  236. package/build/store/index.js.map +1 -1
  237. package/build/store/reducer.js +23 -12
  238. package/build/store/reducer.js.map +1 -1
  239. package/build/store/selectors.js +4 -4
  240. package/build/store/selectors.js.map +1 -1
  241. package/build/utils/pasting.js.map +1 -1
  242. package/build/utils/selection.js +34 -0
  243. package/build/utils/selection.js.map +1 -0
  244. package/build/utils/transform-styles/transforms/wrap.js.map +1 -1
  245. package/build-module/autocompleters/block.js +4 -1
  246. package/build-module/autocompleters/block.js.map +1 -1
  247. package/build-module/components/block-actions/index.js.map +1 -1
  248. package/build-module/components/block-alignment-control/ui.js.map +1 -1
  249. package/build-module/components/block-alignment-matrix-control/index.js +2 -5
  250. package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
  251. package/build-module/components/block-breadcrumb/index.js.map +1 -1
  252. package/build-module/components/block-content-overlay/index.js.map +1 -1
  253. package/build-module/components/block-context/index.js.map +1 -1
  254. package/build-module/components/block-controls/hook.js.map +1 -1
  255. package/build-module/components/block-draggable/index.js.map +1 -1
  256. package/build-module/components/block-draggable/index.native.js.map +1 -1
  257. package/build-module/components/block-list/block-invalid-warning.native.js +50 -6
  258. package/build-module/components/block-list/block-invalid-warning.native.js.map +1 -1
  259. package/build-module/components/block-list/block-list-item.native.js.map +1 -1
  260. package/build-module/components/block-list/block-selection-button.native.js.map +1 -1
  261. package/build-module/components/block-list/block.js +2 -2
  262. package/build-module/components/block-list/block.js.map +1 -1
  263. package/build-module/components/block-list/block.native.js +2 -1
  264. package/build-module/components/block-list/block.native.js.map +1 -1
  265. package/build-module/components/block-list/index.js.map +1 -1
  266. package/build-module/components/block-list/index.native.js +3 -1
  267. package/build-module/components/block-list/index.native.js.map +1 -1
  268. package/build-module/components/block-list/layout.js +19 -4
  269. package/build-module/components/block-list/layout.js.map +1 -1
  270. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  271. package/build-module/components/block-list/use-block-props/use-block-class-names.js +5 -2
  272. package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  273. package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js.map +1 -1
  274. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
  275. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  276. package/build-module/components/block-list-appender/index.js.map +1 -1
  277. package/build-module/components/block-list-appender/index.native.js.map +1 -1
  278. package/build-module/components/block-lock/modal.js +37 -6
  279. package/build-module/components/block-lock/modal.js.map +1 -1
  280. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  281. package/build-module/components/block-mover/button.js.map +1 -1
  282. package/build-module/components/block-mover/index.native.js.map +1 -1
  283. package/build-module/components/block-parent-selector/index.js.map +1 -1
  284. package/build-module/components/block-pattern-setup/index.js +9 -27
  285. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  286. package/build-module/components/block-pattern-setup/setup-toolbar.js +3 -8
  287. package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  288. package/build-module/components/block-popover/inbetween.js +1 -1
  289. package/build-module/components/block-popover/inbetween.js.map +1 -1
  290. package/build-module/components/block-popover/index.js +1 -1
  291. package/build-module/components/block-popover/index.js.map +1 -1
  292. package/build-module/components/block-preview/auto.js +20 -5
  293. package/build-module/components/block-preview/auto.js.map +1 -1
  294. package/build-module/components/block-selection-clearer/index.js.map +1 -1
  295. package/build-module/components/block-settings-menu/block-edit-visually-button.js +56 -0
  296. package/build-module/components/block-settings-menu/block-edit-visually-button.js.map +1 -0
  297. package/build-module/components/block-settings-menu/block-mode-toggle.js +4 -6
  298. package/build-module/components/block-settings-menu/block-mode-toggle.js.map +1 -1
  299. package/build-module/components/block-settings-menu/block-settings-dropdown.js +10 -3
  300. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  301. package/build-module/components/block-settings-menu/index.js +6 -3
  302. package/build-module/components/block-settings-menu/index.js.map +1 -1
  303. package/build-module/components/block-settings-menu-controls/index.js +5 -2
  304. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  305. package/build-module/components/block-styles/index.js +5 -2
  306. package/build-module/components/block-styles/index.js.map +1 -1
  307. package/build-module/components/block-styles/menu-items.js +3 -5
  308. package/build-module/components/block-styles/menu-items.js.map +1 -1
  309. package/build-module/components/block-styles/preview.native.js +3 -2
  310. package/build-module/components/block-styles/preview.native.js.map +1 -1
  311. package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
  312. package/build-module/components/block-switcher/index.js +7 -1
  313. package/build-module/components/block-switcher/index.js.map +1 -1
  314. package/build-module/components/block-title/index.js +8 -2
  315. package/build-module/components/block-title/index.js.map +1 -1
  316. package/build-module/components/block-title/use-block-display-title.js +15 -14
  317. package/build-module/components/block-title/use-block-display-title.js.map +1 -1
  318. package/build-module/components/block-toolbar/index.native.js.map +1 -1
  319. package/build-module/components/block-toolbar/utils.js +3 -5
  320. package/build-module/components/block-toolbar/utils.js.map +1 -1
  321. package/build-module/components/block-tools/block-contextual-toolbar.js +1 -1
  322. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  323. package/build-module/components/block-tools/index.js.map +1 -1
  324. package/build-module/components/block-types-list/index.native.js.map +1 -1
  325. package/build-module/components/block-variation-transforms/index.js.map +1 -1
  326. package/build-module/components/border-radius-control/index.js +2 -0
  327. package/build-module/components/border-radius-control/index.js.map +1 -1
  328. package/build-module/components/color-style-selector/index.js.map +1 -1
  329. package/build-module/components/colors/with-colors.js +2 -2
  330. package/build-module/components/colors/with-colors.js.map +1 -1
  331. package/build-module/components/colors-gradients/control.js +46 -40
  332. package/build-module/components/colors-gradients/control.js.map +1 -1
  333. package/build-module/components/colors-gradients/dropdown.js +2 -1
  334. package/build-module/components/colors-gradients/dropdown.js.map +1 -1
  335. package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -1
  336. package/build-module/components/copy-handler/index.js +18 -2
  337. package/build-module/components/copy-handler/index.js.map +1 -1
  338. package/build-module/components/date-format-picker/index.js +1 -1
  339. package/build-module/components/date-format-picker/index.js.map +1 -1
  340. package/build-module/components/default-block-appender/index.js.map +1 -1
  341. package/build-module/components/default-block-appender/index.native.js.map +1 -1
  342. package/build-module/components/default-style-picker/index.js.map +1 -1
  343. package/build-module/components/duotone/components.js +130 -0
  344. package/build-module/components/duotone/components.js.map +1 -0
  345. package/build-module/components/duotone/index.js +3 -0
  346. package/build-module/components/duotone/index.js.map +1 -0
  347. package/build-module/components/duotone/utils.js +30 -0
  348. package/build-module/components/duotone/utils.js.map +1 -0
  349. package/build-module/components/duotone-control/index.js +18 -6
  350. package/build-module/components/duotone-control/index.js.map +1 -1
  351. package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
  352. package/build-module/components/iframe/index.js +19 -6
  353. package/build-module/components/iframe/index.js.map +1 -1
  354. package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  355. package/build-module/components/image-size-control/index.js +4 -1
  356. package/build-module/components/image-size-control/index.js.map +1 -1
  357. package/build-module/components/index.js +3 -0
  358. package/build-module/components/index.js.map +1 -1
  359. package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  360. package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  361. package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
  362. package/build-module/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
  363. package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
  364. package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
  365. package/build-module/components/inserter/index.js +3 -2
  366. package/build-module/components/inserter/index.js.map +1 -1
  367. package/build-module/components/inserter/index.native.js.map +1 -1
  368. package/build-module/components/inserter/library.js +2 -5
  369. package/build-module/components/inserter/library.js.map +1 -1
  370. package/build-module/components/inserter/menu.js.map +1 -1
  371. package/build-module/components/inserter/menu.native.js.map +1 -1
  372. package/build-module/components/inserter/no-results.native.js.map +1 -1
  373. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  374. package/build-module/components/inserter/search-items.js +2 -2
  375. package/build-module/components/inserter/search-items.js.map +1 -1
  376. package/build-module/components/inserter/search-results.native.js.map +1 -1
  377. package/build-module/components/inspector-popover-header/index.js +46 -0
  378. package/build-module/components/inspector-popover-header/index.js.map +1 -0
  379. package/build-module/components/line-height-control/index.js.map +1 -1
  380. package/build-module/components/link-control/index.js +3 -2
  381. package/build-module/components/link-control/index.js.map +1 -1
  382. package/build-module/components/link-control/search-create-button.js +1 -2
  383. package/build-module/components/link-control/search-create-button.js.map +1 -1
  384. package/build-module/components/link-control/search-input.js +3 -1
  385. package/build-module/components/link-control/search-input.js.map +1 -1
  386. package/build-module/components/link-control/settings-drawer.js +2 -5
  387. package/build-module/components/link-control/settings-drawer.js.map +1 -1
  388. package/build-module/components/link-control/use-search-handler.js.map +1 -1
  389. package/build-module/components/list-view/block-contents.js.map +1 -1
  390. package/build-module/components/list-view/block-select-button.js +16 -8
  391. package/build-module/components/list-view/block-select-button.js.map +1 -1
  392. package/build-module/components/list-view/branch.js.map +1 -1
  393. package/build-module/components/list-view/drop-indicator.js +1 -1
  394. package/build-module/components/list-view/drop-indicator.js.map +1 -1
  395. package/build-module/components/list-view/index.js.map +1 -1
  396. package/build-module/components/list-view/use-block-selection.js.map +1 -1
  397. package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
  398. package/build-module/components/list-view/utils.js +1 -6
  399. package/build-module/components/list-view/utils.js.map +1 -1
  400. package/build-module/components/media-placeholder/index.js +16 -3
  401. package/build-module/components/media-placeholder/index.js.map +1 -1
  402. package/build-module/components/media-placeholder/index.native.js +5 -3
  403. package/build-module/components/media-placeholder/index.native.js.map +1 -1
  404. package/build-module/components/media-replace-flow/index.js +27 -18
  405. package/build-module/components/media-replace-flow/index.js.map +1 -1
  406. package/build-module/components/media-upload/index.native.js +1 -1
  407. package/build-module/components/media-upload/index.native.js.map +1 -1
  408. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  409. package/build-module/components/plain-text/index.native.js.map +1 -1
  410. package/build-module/components/preview-options/index.js +4 -0
  411. package/build-module/components/preview-options/index.js.map +1 -1
  412. package/build-module/components/provider/use-block-sync.js +4 -1
  413. package/build-module/components/provider/use-block-sync.js.map +1 -1
  414. package/build-module/components/publish-date-time-picker/index.js +16 -16
  415. package/build-module/components/publish-date-time-picker/index.js.map +1 -1
  416. package/build-module/components/rich-text/embed-handler-picker.native.js +3 -5
  417. package/build-module/components/rich-text/embed-handler-picker.native.js.map +1 -1
  418. package/build-module/components/rich-text/index.js.map +1 -1
  419. package/build-module/components/rich-text/use-format-types.js.map +1 -1
  420. package/build-module/components/rich-text/use-input-rules.js +3 -11
  421. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  422. package/build-module/components/rich-text/use-mark-persistent.js.map +1 -1
  423. package/build-module/components/rich-text/use-paste-handler.js +20 -5
  424. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  425. package/build-module/components/skip-to-selected-block/index.js.map +1 -1
  426. package/build-module/components/ungroup-button/index.native.js +3 -5
  427. package/build-module/components/ungroup-button/index.native.js.map +1 -1
  428. package/build-module/components/url-input/index.js +11 -1
  429. package/build-module/components/url-input/index.js.map +1 -1
  430. package/build-module/components/url-popover/index.js +2 -1
  431. package/build-module/components/url-popover/index.js.map +1 -1
  432. package/build-module/components/use-block-display-information/index.js.map +1 -1
  433. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  434. package/build-module/components/use-block-drop-zone/index.native.js.map +1 -1
  435. package/build-module/components/use-display-block-controls/index.native.js.map +1 -1
  436. package/build-module/components/use-on-block-drop/index.js.map +1 -1
  437. package/build-module/components/use-on-block-drop/index.native.js.map +1 -1
  438. package/build-module/components/use-setting/index.js.map +1 -1
  439. package/build-module/components/writing-flow/use-arrow-nav.js +47 -14
  440. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  441. package/build-module/components/writing-flow/use-click-selection.js.map +1 -1
  442. package/build-module/components/writing-flow/use-drag-selection.js.map +1 -1
  443. package/build-module/components/writing-flow/use-multi-selection.js +3 -45
  444. package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
  445. package/build-module/components/writing-flow/use-select-all.js.map +1 -1
  446. package/build-module/components/writing-flow/use-selection-observer.js +1 -3
  447. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  448. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  449. package/build-module/elements/index.js +7 -1
  450. package/build-module/elements/index.js.map +1 -1
  451. package/build-module/hooks/aria-label.js +59 -0
  452. package/build-module/hooks/aria-label.js.map +1 -0
  453. package/build-module/hooks/color-panel.js.map +1 -1
  454. package/build-module/hooks/color-panel.native.js.map +1 -1
  455. package/build-module/hooks/color.js +2 -3
  456. package/build-module/hooks/color.js.map +1 -1
  457. package/build-module/hooks/duotone.js +22 -140
  458. package/build-module/hooks/duotone.js.map +1 -1
  459. package/build-module/hooks/font-family.js.map +1 -1
  460. package/build-module/hooks/gap.js.map +1 -1
  461. package/build-module/hooks/index.js +2 -1
  462. package/build-module/hooks/index.js.map +1 -1
  463. package/build-module/hooks/layout.js +76 -10
  464. package/build-module/hooks/layout.js.map +1 -1
  465. package/build-module/hooks/utils.js +5 -2
  466. package/build-module/hooks/utils.js.map +1 -1
  467. package/build-module/index.js +1 -1
  468. package/build-module/index.js.map +1 -1
  469. package/build-module/layouts/flex.js +43 -35
  470. package/build-module/layouts/flex.js.map +1 -1
  471. package/build-module/layouts/flow.js +11 -36
  472. package/build-module/layouts/flow.js.map +1 -1
  473. package/build-module/layouts/utils.js +33 -3
  474. package/build-module/layouts/utils.js.map +1 -1
  475. package/build-module/store/actions.js +14 -20
  476. package/build-module/store/actions.js.map +1 -1
  477. package/build-module/store/index.js +0 -4
  478. package/build-module/store/index.js.map +1 -1
  479. package/build-module/store/reducer.js +23 -11
  480. package/build-module/store/reducer.js.map +1 -1
  481. package/build-module/store/selectors.js +5 -5
  482. package/build-module/store/selectors.js.map +1 -1
  483. package/build-module/utils/pasting.js.map +1 -1
  484. package/build-module/utils/selection.js +24 -0
  485. package/build-module/utils/selection.js.map +1 -0
  486. package/build-module/utils/transform-styles/transforms/wrap.js.map +1 -1
  487. package/build-style/style-rtl.css +57 -34
  488. package/build-style/style.css +57 -34
  489. package/package.json +28 -28
  490. package/src/autocompleters/block.js +2 -1
  491. package/src/components/block-actions/index.js +2 -3
  492. package/src/components/block-alignment-control/ui.js +4 -6
  493. package/src/components/block-alignment-matrix-control/index.js +2 -4
  494. package/src/components/block-breadcrumb/index.js +2 -5
  495. package/src/components/block-compare/test/block-view.js +2 -1
  496. package/src/components/block-content-overlay/index.js +2 -5
  497. package/src/components/block-context/index.js +4 -4
  498. package/src/components/block-controls/hook.js +2 -3
  499. package/src/components/block-draggable/index.js +6 -13
  500. package/src/components/block-draggable/index.native.js +6 -14
  501. package/src/components/block-draggable/test/helpers.native.js +3 -3
  502. package/src/components/block-draggable/test/index.native.js +12 -15
  503. package/src/components/block-edit/test/edit.js +2 -1
  504. package/src/components/block-list/block-invalid-warning.native.js +42 -7
  505. package/src/components/block-list/block-list-item.native.js +4 -12
  506. package/src/components/block-list/block-selection-button.native.js +2 -3
  507. package/src/components/block-list/block.js +10 -12
  508. package/src/components/block-list/block.native.js +11 -15
  509. package/src/components/block-list/index.js +2 -3
  510. package/src/components/block-list/index.native.js +13 -22
  511. package/src/components/block-list/layout.js +15 -3
  512. package/src/components/block-list/style.scss +2 -2
  513. package/src/components/block-list/test/block-list-context.native.js +8 -16
  514. package/src/components/block-list/use-block-props/index.js +6 -3
  515. package/src/components/block-list/use-block-props/use-block-class-names.js +5 -1
  516. package/src/components/block-list/use-block-props/use-block-custom-class-name.js +2 -3
  517. package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +2 -3
  518. package/src/components/block-list/use-in-between-inserter.js +2 -3
  519. package/src/components/block-list-appender/index.js +2 -5
  520. package/src/components/block-list-appender/index.native.js +2 -3
  521. package/src/components/block-lock/modal.js +42 -4
  522. package/src/components/block-lock/style.scss +10 -0
  523. package/src/components/block-mobile-toolbar/block-actions-menu.native.js +4 -6
  524. package/src/components/block-mover/button.js +2 -3
  525. package/src/components/block-mover/index.native.js +4 -6
  526. package/src/components/block-parent-selector/index.js +2 -3
  527. package/src/components/block-pattern-setup/index.js +5 -27
  528. package/src/components/block-pattern-setup/setup-toolbar.js +2 -9
  529. package/src/components/block-pattern-setup/style.scss +4 -2
  530. package/src/components/block-popover/inbetween.js +1 -1
  531. package/src/components/block-popover/index.js +1 -1
  532. package/src/components/block-preview/auto.js +21 -11
  533. package/src/components/block-selection-clearer/index.js +2 -3
  534. package/src/components/block-settings-menu/block-edit-visually-button.js +52 -0
  535. package/src/components/block-settings-menu/block-mode-toggle.js +5 -8
  536. package/src/components/block-settings-menu/block-settings-dropdown.js +13 -9
  537. package/src/components/block-settings-menu/index.js +15 -11
  538. package/src/components/block-settings-menu-controls/index.js +3 -2
  539. package/src/components/block-styles/index.js +3 -1
  540. package/src/components/block-styles/menu-items.js +2 -5
  541. package/src/components/block-styles/preview.native.js +3 -2
  542. package/src/components/block-switcher/block-transformations-menu.js +2 -4
  543. package/src/components/block-switcher/index.js +7 -1
  544. package/src/components/block-title/index.js +3 -2
  545. package/src/components/block-title/use-block-display-title.js +20 -12
  546. package/src/components/block-toolbar/index.native.js +2 -5
  547. package/src/components/block-toolbar/utils.js +3 -11
  548. package/src/components/block-tools/block-contextual-toolbar.js +5 -6
  549. package/src/components/block-tools/index.js +2 -3
  550. package/src/components/block-types-list/index.native.js +2 -4
  551. package/src/components/block-variation-transforms/index.js +4 -6
  552. package/src/components/border-radius-control/index.js +2 -0
  553. package/src/components/color-palette/test/control.js +2 -1
  554. package/src/components/color-style-selector/index.js +27 -28
  555. package/src/components/colors/test/with-colors.js +14 -14
  556. package/src/components/colors/with-colors.js +10 -14
  557. package/src/components/colors-gradients/control.js +77 -65
  558. package/src/components/colors-gradients/dropdown.js +22 -16
  559. package/src/components/colors-gradients/style.scss +4 -0
  560. package/src/components/colors-gradients/test/control.js +25 -32
  561. package/src/components/convert-to-group-buttons/toolbar.js +2 -6
  562. package/src/components/copy-handler/README.md +7 -2
  563. package/src/components/copy-handler/index.js +26 -6
  564. package/src/components/date-format-picker/index.js +1 -0
  565. package/src/components/default-block-appender/index.js +4 -6
  566. package/src/components/default-block-appender/index.native.js +4 -9
  567. package/src/components/default-style-picker/index.js +20 -21
  568. package/src/components/duotone/components.js +133 -0
  569. package/src/components/duotone/index.js +7 -0
  570. package/src/components/duotone/utils.js +25 -0
  571. package/src/components/duotone-control/index.js +12 -7
  572. package/src/components/duotone-control/style.scss +5 -0
  573. package/src/components/font-sizes/with-font-sizes.js +2 -3
  574. package/src/components/iframe/index.js +25 -6
  575. package/src/components/image-editor/aspect-ratio-dropdown.js +2 -6
  576. package/src/components/image-size-control/index.js +4 -7
  577. package/src/components/index.js +3 -0
  578. package/src/components/inner-blocks/use-inner-block-template-sync.js +2 -3
  579. package/src/components/inner-blocks/use-nested-settings-update.js +6 -9
  580. package/src/components/inserter/block-types-tab.native.js +2 -3
  581. package/src/components/inserter/hooks/use-block-type-impressions.native.js +2 -3
  582. package/src/components/inserter/hooks/use-insertion-point.js +3 -2
  583. package/src/components/inserter/hooks/use-patterns-state.js +4 -5
  584. package/src/components/inserter/index.js +7 -11
  585. package/src/components/inserter/index.native.js +6 -11
  586. package/src/components/inserter/library.js +2 -5
  587. package/src/components/inserter/menu.js +14 -19
  588. package/src/components/inserter/menu.native.js +8 -6
  589. package/src/components/inserter/no-results.native.js +2 -1
  590. package/src/components/inserter/quick-inserter.js +2 -3
  591. package/src/components/inserter/search-items.js +6 -6
  592. package/src/components/inserter/search-results.native.js +4 -6
  593. package/src/components/inserter/style.scss +1 -1
  594. package/src/components/inspector-popover-header/README.md +76 -0
  595. package/src/components/inspector-popover-header/index.js +56 -0
  596. package/src/components/inspector-popover-header/style.scss +16 -0
  597. package/src/components/line-height-control/index.js +1 -2
  598. package/src/components/link-control/index.js +5 -4
  599. package/src/components/link-control/search-create-button.js +4 -2
  600. package/src/components/link-control/search-input.js +3 -1
  601. package/src/components/link-control/settings-drawer.js +2 -5
  602. package/src/components/link-control/test/fixtures/index.js +5 -7
  603. package/src/components/link-control/test/index.js +85 -106
  604. package/src/components/link-control/use-search-handler.js +2 -2
  605. package/src/components/list-view/block-contents.js +2 -4
  606. package/src/components/list-view/block-select-button.js +29 -14
  607. package/src/components/list-view/branch.js +22 -23
  608. package/src/components/list-view/drop-indicator.js +1 -1
  609. package/src/components/list-view/index.js +4 -8
  610. package/src/components/list-view/style.scss +18 -4
  611. package/src/components/list-view/use-block-selection.js +5 -5
  612. package/src/components/list-view/use-list-view-drop-zone.js +2 -1
  613. package/src/components/list-view/utils.js +1 -6
  614. package/src/components/media-placeholder/index.js +22 -1
  615. package/src/components/media-placeholder/index.native.js +9 -5
  616. package/src/components/media-replace-flow/index.js +78 -56
  617. package/src/components/media-replace-flow/test/index.js +14 -4
  618. package/src/components/media-upload/README.md +8 -0
  619. package/src/components/media-upload/index.native.js +1 -1
  620. package/src/components/navigable-toolbar/index.js +1 -2
  621. package/src/components/panel-color-settings/test/index.js +2 -1
  622. package/src/components/plain-text/index.native.js +2 -6
  623. package/src/components/preview-options/index.js +4 -0
  624. package/src/components/provider/use-block-sync.js +5 -2
  625. package/src/components/publish-date-time-picker/README.md +1 -1
  626. package/src/components/publish-date-time-picker/index.js +18 -27
  627. package/src/components/responsive-block-control/README.md +3 -1
  628. package/src/components/responsive-block-control/test/index.js +4 -4
  629. package/src/components/rich-text/embed-handler-picker.native.js +2 -5
  630. package/src/components/rich-text/index.js +7 -4
  631. package/src/components/rich-text/use-format-types.js +16 -16
  632. package/src/components/rich-text/use-input-rules.js +6 -15
  633. package/src/components/rich-text/use-mark-persistent.js +2 -3
  634. package/src/components/rich-text/use-paste-handler.js +17 -5
  635. package/src/components/skip-to-selected-block/index.js +2 -3
  636. package/src/components/ungroup-button/index.native.js +4 -8
  637. package/src/components/url-input/index.js +21 -20
  638. package/src/components/url-popover/index.js +1 -0
  639. package/src/components/url-popover/test/__snapshots__/index.js.snap +3 -0
  640. package/src/components/use-block-display-information/index.js +4 -6
  641. package/src/components/use-block-drop-zone/index.js +2 -3
  642. package/src/components/use-block-drop-zone/index.native.js +2 -4
  643. package/src/components/use-block-drop-zone/test/index.js +22 -23
  644. package/src/components/use-display-block-controls/index.native.js +2 -3
  645. package/src/components/use-no-recursive-renders/test/use-no-recursive-renders.js +2 -3
  646. package/src/components/use-on-block-drop/index.js +2 -5
  647. package/src/components/use-on-block-drop/index.native.js +4 -8
  648. package/src/components/use-setting/index.js +8 -6
  649. package/src/components/writing-flow/test/index.js +22 -4
  650. package/src/components/writing-flow/use-arrow-nav.js +54 -11
  651. package/src/components/writing-flow/use-click-selection.js +2 -5
  652. package/src/components/writing-flow/use-drag-selection.js +6 -9
  653. package/src/components/writing-flow/use-multi-selection.js +1 -50
  654. package/src/components/writing-flow/use-select-all.js +2 -5
  655. package/src/components/writing-flow/use-selection-observer.js +6 -9
  656. package/src/components/writing-flow/use-tab-nav.js +2 -5
  657. package/src/elements/index.js +8 -1
  658. package/src/elements/test/index.js +18 -0
  659. package/src/hooks/aria-label.js +67 -0
  660. package/src/hooks/color-panel.js +4 -4
  661. package/src/hooks/color-panel.native.js +2 -2
  662. package/src/hooks/color.js +12 -5
  663. package/src/hooks/duotone.js +18 -139
  664. package/src/hooks/font-family.js +4 -2
  665. package/src/hooks/gap.js +2 -3
  666. package/src/hooks/index.js +2 -1
  667. package/src/hooks/layout.js +102 -15
  668. package/src/hooks/test/align.js +2 -1
  669. package/src/hooks/test/generated-class-name.js +2 -5
  670. package/src/hooks/test/utils.js +2 -5
  671. package/src/hooks/utils.js +7 -3
  672. package/src/index.js +1 -1
  673. package/src/layouts/flex.js +49 -43
  674. package/src/layouts/flow.js +14 -35
  675. package/src/layouts/test/flex.js +21 -0
  676. package/src/layouts/test/flow.js +21 -0
  677. package/src/layouts/test/utils.js +138 -0
  678. package/src/layouts/utils.js +44 -3
  679. package/src/store/actions.js +763 -733
  680. package/src/store/index.js +0 -4
  681. package/src/store/reducer.js +208 -184
  682. package/src/store/selectors.js +57 -58
  683. package/src/store/test/actions.js +2 -1
  684. package/src/store/test/reducer.js +140 -10
  685. package/src/store/test/selectors.js +20 -27
  686. package/src/style.scss +1 -1
  687. package/src/utils/pasting.js +3 -3
  688. package/src/utils/selection.js +26 -0
  689. package/src/utils/test/selection.js +39 -0
  690. package/src/utils/transform-styles/transforms/wrap.js +30 -28
  691. package/tsconfig.json +2 -1
  692. package/tsconfig.tsbuildinfo +1 -1
  693. package/src/components/publish-date-time-picker/style.scss +0 -20
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/use-mark-persistent.js"],"names":["useMarkPersistent","html","value","previousText","hasActiveFormats","activeFormats","length","__unstableMarkLastChangeAsPersistent","blockEditorStore","current","text","timeout","window","setTimeout","clearTimeout"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAGO,SAASA,iBAAT,OAA8C;AAAA,MAAlB;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,GAAkB;AACpD,QAAMC,YAAY,GAAG,sBAArB;AACA,QAAMC,gBAAgB,GACrBF,KAAK,CAACG,aAAN,IAAuB,CAAC,CAAEH,KAAK,CAACG,aAAN,CAAoBC,MAD/C;AAEA,QAAM;AAAEC,IAAAA;AAAF,MAA2C,uBAChDC,YADgD,CAAjD,CAJoD,CAQpD;;AACA,gCAAiB,MAAM;AACtB;AACA,QAAK,CAAEL,YAAY,CAACM,OAApB,EAA8B;AAC7BN,MAAAA,YAAY,CAACM,OAAb,GAAuBP,KAAK,CAACQ,IAA7B;AACA;AACA,KALqB,CAOtB;AACA;;;AACA,QAAKP,YAAY,CAACM,OAAb,KAAyBP,KAAK,CAACQ,IAApC,EAA2C;AAC1C,YAAMC,OAAO,GAAGC,MAAM,CAACC,UAAP,CAAmB,MAAM;AACxCN,QAAAA,oCAAoC;AACpC,OAFe,EAEb,IAFa,CAAhB;AAGAJ,MAAAA,YAAY,CAACM,OAAb,GAAuBP,KAAK,CAACQ,IAA7B;AACA,aAAO,MAAM;AACZE,QAAAA,MAAM,CAACE,YAAP,CAAqBH,OAArB;AACA,OAFD;AAGA;;AAEDJ,IAAAA,oCAAoC;AACpC,GApBD,EAoBG,CAAEN,IAAF,EAAQG,gBAAR,CApBH;AAqBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useLayoutEffect, useRef } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nexport function useMarkPersistent( { html, value } ) {\n\tconst previousText = useRef();\n\tconst hasActiveFormats =\n\t\tvalue.activeFormats && !! value.activeFormats.length;\n\tconst { __unstableMarkLastChangeAsPersistent } = useDispatch(\n\t\tblockEditorStore\n\t);\n\n\t// Must be set synchronously to make sure it applies to the last change.\n\tuseLayoutEffect( () => {\n\t\t// Ignore mount.\n\t\tif ( ! previousText.current ) {\n\t\t\tpreviousText.current = value.text;\n\t\t\treturn;\n\t\t}\n\n\t\t// Text input, so don't create an undo level for every character.\n\t\t// Create an undo level after 1 second of no input.\n\t\tif ( previousText.current !== value.text ) {\n\t\t\tconst timeout = window.setTimeout( () => {\n\t\t\t\t__unstableMarkLastChangeAsPersistent();\n\t\t\t}, 1000 );\n\t\t\tpreviousText.current = value.text;\n\t\t\treturn () => {\n\t\t\t\twindow.clearTimeout( timeout );\n\t\t\t};\n\t\t}\n\n\t\t__unstableMarkLastChangeAsPersistent();\n\t}, [ html, hasActiveFormats ] );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/use-mark-persistent.js"],"names":["useMarkPersistent","html","value","previousText","hasActiveFormats","activeFormats","length","__unstableMarkLastChangeAsPersistent","blockEditorStore","current","text","timeout","window","setTimeout","clearTimeout"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAGO,SAASA,iBAAT,OAA8C;AAAA,MAAlB;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,GAAkB;AACpD,QAAMC,YAAY,GAAG,sBAArB;AACA,QAAMC,gBAAgB,GACrBF,KAAK,CAACG,aAAN,IAAuB,CAAC,CAAEH,KAAK,CAACG,aAAN,CAAoBC,MAD/C;AAEA,QAAM;AAAEC,IAAAA;AAAF,MACL,uBAAaC,YAAb,CADD,CAJoD,CAOpD;;AACA,gCAAiB,MAAM;AACtB;AACA,QAAK,CAAEL,YAAY,CAACM,OAApB,EAA8B;AAC7BN,MAAAA,YAAY,CAACM,OAAb,GAAuBP,KAAK,CAACQ,IAA7B;AACA;AACA,KALqB,CAOtB;AACA;;;AACA,QAAKP,YAAY,CAACM,OAAb,KAAyBP,KAAK,CAACQ,IAApC,EAA2C;AAC1C,YAAMC,OAAO,GAAGC,MAAM,CAACC,UAAP,CAAmB,MAAM;AACxCN,QAAAA,oCAAoC;AACpC,OAFe,EAEb,IAFa,CAAhB;AAGAJ,MAAAA,YAAY,CAACM,OAAb,GAAuBP,KAAK,CAACQ,IAA7B;AACA,aAAO,MAAM;AACZE,QAAAA,MAAM,CAACE,YAAP,CAAqBH,OAArB;AACA,OAFD;AAGA;;AAEDJ,IAAAA,oCAAoC;AACpC,GApBD,EAoBG,CAAEN,IAAF,EAAQG,gBAAR,CApBH;AAqBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useLayoutEffect, useRef } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nexport function useMarkPersistent( { html, value } ) {\n\tconst previousText = useRef();\n\tconst hasActiveFormats =\n\t\tvalue.activeFormats && !! value.activeFormats.length;\n\tconst { __unstableMarkLastChangeAsPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Must be set synchronously to make sure it applies to the last change.\n\tuseLayoutEffect( () => {\n\t\t// Ignore mount.\n\t\tif ( ! previousText.current ) {\n\t\t\tpreviousText.current = value.text;\n\t\t\treturn;\n\t\t}\n\n\t\t// Text input, so don't create an undo level for every character.\n\t\t// Create an undo level after 1 second of no input.\n\t\tif ( previousText.current !== value.text ) {\n\t\t\tconst timeout = window.setTimeout( () => {\n\t\t\t\t__unstableMarkLastChangeAsPersistent();\n\t\t\t}, 1000 );\n\t\t\tpreviousText.current = value.text;\n\t\t\treturn () => {\n\t\t\t\twindow.clearTimeout( timeout );\n\t\t\t};\n\t\t}\n\n\t\t__unstableMarkLastChangeAsPersistent();\n\t}, [ html, hasActiveFormats ] );\n}\n"]}
@@ -245,8 +245,8 @@ function usePasteHandler(props) {
245
245
  }, []);
246
246
  }
247
247
  /**
248
- * Normalizes a given string of HTML to remove the Windows specific "Fragment" comments
249
- * and any preceeding and trailing whitespace.
248
+ * Normalizes a given string of HTML to remove the Windows-specific "Fragment"
249
+ * comments and any preceeding and trailing content.
250
250
  *
251
251
  * @param {string} html the html to be normalized
252
252
  * @return {string} the normalized html
@@ -254,9 +254,24 @@ function usePasteHandler(props) {
254
254
 
255
255
 
256
256
  function removeWindowsFragments(html) {
257
- const startReg = /.*<!--StartFragment-->/s;
258
- const endReg = /<!--EndFragment-->.*/s;
259
- return html.replace(startReg, '').replace(endReg, '');
257
+ const startStr = '<!--StartFragment-->';
258
+ const startIdx = html.indexOf(startStr);
259
+
260
+ if (startIdx > -1) {
261
+ html = html.substring(startIdx + startStr.length);
262
+ } else {
263
+ // No point looking for EndFragment
264
+ return html;
265
+ }
266
+
267
+ const endStr = '<!--EndFragment-->';
268
+ const endIdx = html.indexOf(endStr);
269
+
270
+ if (endIdx > -1) {
271
+ html = html.substring(0, endIdx);
272
+ }
273
+
274
+ return html;
260
275
  }
261
276
  /**
262
277
  * Removes the charset meta tag inserted by Chromium.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/use-paste-handler.js"],"names":["adjustLines","value","isMultiline","LINE_SEPARATOR","RegExp","usePasteHandler","props","propsRef","current","element","_onPaste","event","isSelected","disableFormats","onChange","formatTypes","tagName","onReplace","onSplit","onSplitMiddle","__unstableEmbedURLOnPaste","multilineTag","preserveWhiteSpace","pastePlainText","clipboardData","plainText","html","getData","error1","error2","removeWindowsFragments","removeCharsetMetaTag","preventDefault","window","console","log","transformed","reduce","accumlator","__unstablePasteRule","files","isInternal","pastedMultilineTag","undefined","pastedValue","multilineWrapperTags","activeFormats","text","length","content","HTML","mode","pastedBlocks","trim","valueToInsert","addEventListener","removeEventListener","startReg","endReg","replace","metaTag","startsWith","slice"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAOA;;AAKA;;AACA;;AACA;;AACA;;AAtBA;AACA;AACA;;AAcA;AACA;AACA;;AAMA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,WAAT,CAAsBC,KAAtB,EAA6BC,WAA7B,EAA2C;AAC1C,MAAKA,WAAL,EAAmB;AAClB,WAAO,uBAASD,KAAT,EAAgB,MAAhB,EAAwBE,mCAAxB,CAAP;AACA;;AAED,SAAO,uBAASF,KAAT,EAAgB,IAAIG,MAAJ,CAAYD,mCAAZ,EAA4B,GAA5B,CAAhB,EAAmD,IAAnD,CAAP;AACA;;AAEM,SAASE,eAAT,CAA0BC,KAA1B,EAAkC;AACxC,QAAMC,QAAQ,GAAG,qBAAQD,KAAR,CAAjB;AACAC,EAAAA,QAAQ,CAACC,OAAT,GAAmBF,KAAnB;AACA,SAAO,2BA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A;;;AACA,SAASoB,sBAAT,CAAiCJ,IAAjC,EAAwC;AACvC,QAAM+B,QAAQ,GAAG,yBAAjB;AACA,QAAMC,MAAM,GAAG,uBAAf;AAEA,SAAOhC,IAAI,CAACiC,OAAL,CAAcF,QAAd,EAAwB,EAAxB,EAA6BE,OAA7B,CAAsCD,MAAtC,EAA8C,EAA9C,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAAS3B,oBAAT,CAA+BL,IAA/B,EAAsC;AACrC,QAAMkC,OAAO,GAAI,wBAAjB;;AAEA,MAAKlC,IAAI,CAACmC,UAAL,CAAiBD,OAAjB,CAAL,EAAkC;AACjC,WAAOlC,IAAI,CAACoC,KAAL,CAAYF,OAAO,CAACZ,MAApB,CAAP;AACA;;AAED,SAAOtB,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\nimport { pasteHandler } from '@wordpress/blocks';\nimport {\n\tisEmpty,\n\tinsert,\n\tcreate,\n\treplace,\n\t__UNSTABLE_LINE_SEPARATOR as LINE_SEPARATOR,\n} from '@wordpress/rich-text';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { filePasteHandler } from './file-paste-handler';\nimport { addActiveFormats, isShortcode } from './utils';\nimport { splitValue } from './split-value';\nimport { shouldDismissPastedFiles } from '../../utils/pasting';\n\n/** @typedef {import('@wordpress/rich-text').RichTextValue} RichTextValue */\n\n/**\n * Replaces line separators with line breaks if not multiline.\n * Replaces line breaks with line separators if multiline.\n *\n * @param {RichTextValue} value Value to adjust.\n * @param {boolean} isMultiline Whether to adjust to multiline or not.\n *\n * @return {RichTextValue} Adjusted value.\n */\nfunction adjustLines( value, isMultiline ) {\n\tif ( isMultiline ) {\n\t\treturn replace( value, /\\n+/g, LINE_SEPARATOR );\n\t}\n\n\treturn replace( value, new RegExp( LINE_SEPARATOR, 'g' ), '\\n' );\n}\n\nexport function usePasteHandler( props ) {\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\treturn useRefEffect( ( element ) => {\n\t\tfunction _onPaste( event ) {\n\t\t\tconst {\n\t\t\t\tisSelected,\n\t\t\t\tdisableFormats,\n\t\t\t\tonChange,\n\t\t\t\tvalue,\n\t\t\t\tformatTypes,\n\t\t\t\ttagName,\n\t\t\t\tonReplace,\n\t\t\t\tonSplit,\n\t\t\t\tonSplitMiddle,\n\t\t\t\t__unstableEmbedURLOnPaste,\n\t\t\t\tmultilineTag,\n\t\t\t\tpreserveWhiteSpace,\n\t\t\t\tpastePlainText,\n\t\t\t} = propsRef.current;\n\n\t\t\tif ( ! isSelected ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { clipboardData } = event;\n\n\t\t\tlet plainText = '';\n\t\t\tlet html = '';\n\n\t\t\t// IE11 only supports `Text` as an argument for `getData` and will\n\t\t\t// otherwise throw an invalid argument error, so we try the standard\n\t\t\t// arguments first, then fallback to `Text` if they fail.\n\t\t\ttry {\n\t\t\t\tplainText = clipboardData.getData( 'text/plain' );\n\t\t\t\thtml = clipboardData.getData( 'text/html' );\n\t\t\t} catch ( error1 ) {\n\t\t\t\ttry {\n\t\t\t\t\thtml = clipboardData.getData( 'Text' );\n\t\t\t\t} catch ( error2 ) {\n\t\t\t\t\t// Some browsers like UC Browser paste plain text by default and\n\t\t\t\t\t// don't support clipboardData at all, so allow default\n\t\t\t\t\t// behaviour.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Remove Windows-specific metadata appended within copied HTML text.\n\t\t\thtml = removeWindowsFragments( html );\n\n\t\t\t// Strip meta tag.\n\t\t\thtml = removeCharsetMetaTag( html );\n\n\t\t\tevent.preventDefault();\n\n\t\t\t// Allows us to ask for this information when we get a report.\n\t\t\twindow.console.log( 'Received HTML:\\n\\n', html );\n\t\t\twindow.console.log( 'Received plain text:\\n\\n', plainText );\n\n\t\t\tif ( disableFormats ) {\n\t\t\t\tonChange( insert( value, plainText ) );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst transformed = formatTypes.reduce(\n\t\t\t\t( accumlator, { __unstablePasteRule } ) => {\n\t\t\t\t\t// Only allow one transform.\n\t\t\t\t\tif ( __unstablePasteRule && accumlator === value ) {\n\t\t\t\t\t\taccumlator = __unstablePasteRule( value, {\n\t\t\t\t\t\t\thtml,\n\t\t\t\t\t\t\tplainText,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn accumlator;\n\t\t\t\t},\n\t\t\t\tvalue\n\t\t\t);\n\n\t\t\tif ( transformed !== value ) {\n\t\t\t\tonChange( transformed );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst files = [ ...getFilesFromDataTransfer( clipboardData ) ];\n\t\t\tconst isInternal = clipboardData.getData( 'rich-text' ) === 'true';\n\n\t\t\t// If the data comes from a rich text instance, we can directly use it\n\t\t\t// without filtering the data. The filters are only meant for externally\n\t\t\t// pasted content and remove inline styles.\n\t\t\tif ( isInternal ) {\n\t\t\t\tconst pastedMultilineTag =\n\t\t\t\t\tclipboardData.getData( 'rich-text-multi-line-tag' ) ||\n\t\t\t\t\tundefined;\n\t\t\t\tlet pastedValue = create( {\n\t\t\t\t\thtml,\n\t\t\t\t\tmultilineTag: pastedMultilineTag,\n\t\t\t\t\tmultilineWrapperTags:\n\t\t\t\t\t\tpastedMultilineTag === 'li'\n\t\t\t\t\t\t\t? [ 'ul', 'ol' ]\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\tpreserveWhiteSpace,\n\t\t\t\t} );\n\t\t\t\tpastedValue = adjustLines( pastedValue, !! multilineTag );\n\t\t\t\taddActiveFormats( pastedValue, value.activeFormats );\n\t\t\t\tonChange( insert( value, pastedValue ) );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( pastePlainText ) {\n\t\t\t\tonChange( insert( value, create( { text: plainText } ) ) );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Process any attached files, unless we infer that the files in\n\t\t\t// question are redundant \"screenshots\" of the actual HTML payload,\n\t\t\t// as created by certain office-type programs.\n\t\t\t//\n\t\t\t// @see shouldDismissPastedFiles\n\t\t\tif (\n\t\t\t\tfiles?.length &&\n\t\t\t\t! shouldDismissPastedFiles( files, html, plainText )\n\t\t\t) {\n\t\t\t\tconst content = pasteHandler( {\n\t\t\t\t\tHTML: filePasteHandler( files ),\n\t\t\t\t\tmode: 'BLOCKS',\n\t\t\t\t\ttagName,\n\t\t\t\t\tpreserveWhiteSpace,\n\t\t\t\t} );\n\n\t\t\t\t// Allows us to ask for this information when we get a report.\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\twindow.console.log( 'Received items:\\n\\n', files );\n\n\t\t\t\tif ( onReplace && isEmpty( value ) ) {\n\t\t\t\t\tonReplace( content );\n\t\t\t\t} else {\n\t\t\t\t\tsplitValue( {\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tpastedBlocks: content,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonSplitMiddle,\n\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet mode = onReplace && onSplit ? 'AUTO' : 'INLINE';\n\n\t\t\t// Force the blocks mode when the user is pasting\n\t\t\t// on a new line & the content resembles a shortcode.\n\t\t\t// Otherwise it's going to be detected as inline\n\t\t\t// and the shortcode won't be replaced.\n\t\t\tif (\n\t\t\t\tmode === 'AUTO' &&\n\t\t\t\tisEmpty( value ) &&\n\t\t\t\tisShortcode( plainText )\n\t\t\t) {\n\t\t\t\tmode = 'BLOCKS';\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t__unstableEmbedURLOnPaste &&\n\t\t\t\tisEmpty( value ) &&\n\t\t\t\tisURL( plainText.trim() )\n\t\t\t) {\n\t\t\t\tmode = 'BLOCKS';\n\t\t\t}\n\n\t\t\tconst content = pasteHandler( {\n\t\t\t\tHTML: html,\n\t\t\t\tplainText,\n\t\t\t\tmode,\n\t\t\t\ttagName,\n\t\t\t\tpreserveWhiteSpace,\n\t\t\t} );\n\n\t\t\tif ( typeof content === 'string' ) {\n\t\t\t\tlet valueToInsert = create( { html: content } );\n\n\t\t\t\t// If the content should be multiline, we should process text\n\t\t\t\t// separated by a line break as separate lines.\n\t\t\t\tvalueToInsert = adjustLines( valueToInsert, !! multilineTag );\n\n\t\t\t\taddActiveFormats( valueToInsert, value.activeFormats );\n\t\t\t\tonChange( insert( value, valueToInsert ) );\n\t\t\t} else if ( content.length > 0 ) {\n\t\t\t\tif ( onReplace && isEmpty( value ) ) {\n\t\t\t\t\tonReplace( content, content.length - 1, -1 );\n\t\t\t\t} else {\n\t\t\t\t\tsplitValue( {\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tpastedBlocks: content,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonSplitMiddle,\n\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\telement.addEventListener( 'paste', _onPaste );\n\t\treturn () => {\n\t\t\telement.removeEventListener( 'paste', _onPaste );\n\t\t};\n\t}, [] );\n}\n\n/**\n * Normalizes a given string of HTML to remove the Windows specific \"Fragment\" comments\n * and any preceeding and trailing whitespace.\n *\n * @param {string} html the html to be normalized\n * @return {string} the normalized html\n */\nfunction removeWindowsFragments( html ) {\n\tconst startReg = /.*<!--StartFragment-->/s;\n\tconst endReg = /<!--EndFragment-->.*/s;\n\n\treturn html.replace( startReg, '' ).replace( endReg, '' );\n}\n\n/**\n * Removes the charset meta tag inserted by Chromium.\n * See:\n * - https://github.com/WordPress/gutenberg/issues/33585\n * - https://bugs.chromium.org/p/chromium/issues/detail?id=1264616#c4\n *\n * @param {string} html the html to be stripped of the meta tag.\n * @return {string} the cleaned html\n */\nfunction removeCharsetMetaTag( html ) {\n\tconst metaTag = `<meta charset='utf-8'>`;\n\n\tif ( html.startsWith( metaTag ) ) {\n\t\treturn html.slice( metaTag.length );\n\t}\n\n\treturn html;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/use-paste-handler.js"],"names":["adjustLines","value","isMultiline","LINE_SEPARATOR","RegExp","usePasteHandler","props","propsRef","current","element","_onPaste","event","isSelected","disableFormats","onChange","formatTypes","tagName","onReplace","onSplit","onSplitMiddle","__unstableEmbedURLOnPaste","multilineTag","preserveWhiteSpace","pastePlainText","clipboardData","plainText","html","getData","error1","error2","removeWindowsFragments","removeCharsetMetaTag","preventDefault","window","console","log","transformed","reduce","accumlator","__unstablePasteRule","files","isInternal","pastedMultilineTag","undefined","pastedValue","multilineWrapperTags","activeFormats","text","length","content","HTML","mode","pastedBlocks","trim","valueToInsert","addEventListener","removeEventListener","startStr","startIdx","indexOf","substring","endStr","endIdx","metaTag","startsWith","slice"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAOA;;AAKA;;AACA;;AACA;;AACA;;AAtBA;AACA;AACA;;AAcA;AACA;AACA;;AAMA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,WAAT,CAAsBC,KAAtB,EAA6BC,WAA7B,EAA2C;AAC1C,MAAKA,WAAL,EAAmB;AAClB,WAAO,uBAASD,KAAT,EAAgB,MAAhB,EAAwBE,mCAAxB,CAAP;AACA;;AAED,SAAO,uBAASF,KAAT,EAAgB,IAAIG,MAAJ,CAAYD,mCAAZ,EAA4B,GAA5B,CAAhB,EAAmD,IAAnD,CAAP;AACA;;AAEM,SAASE,eAAT,CAA0BC,KAA1B,EAAkC;AACxC,QAAMC,QAAQ,GAAG,qBAAQD,KAAR,CAAjB;AACAC,EAAAA,QAAQ,CAACC,OAAT,GAAmBF,KAAnB;AACA,SAAO,2BAAgBG,OAAF,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ASoB,sBAAT,CAAiCJ,IAAjC,EAAwC;AACvC,QAAM+B,QAAQ,GAAG,sBAAjB;AACA,QAAMC,QAAQ,GAAGhC,IAAI,CAACiC,OAAL,CAAcF,QAAd,CAAjB;;AACA,MAAKC,QAAQ,GAAG,CAAC,CAAjB,EAAqB;AACpBhC,IAAAA,IAAI,GAAGA,IAAI,CAACkC,SAAL,CAAgBF,QAAQ,GAAGD,QAAQ,CAACT,MAApC,CAAP;AACA,GAFD,MAEO;AACN;AACA,WAAOtB,IAAP;AACA;;AAED,QAAMmC,MAAM,GAAG,oBAAf;AACA,QAAMC,MAAM,GAAGpC,IAAI,CAACiC,OAAL,CAAcE,MAAd,CAAf;;AACA,MAAKC,MAAM,GAAG,CAAC,CAAf,EAAmB;AAClBpC,IAAAA,IAAI,GAAGA,IAAI,CAACkC,SAAL,CAAgB,CAAhB,EAAmBE,MAAnB,CAAP;AACA;;AAED,SAAOpC,IAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASK,oBAAT,CAA+BL,IAA/B,EAAsC;AACrC,QAAMqC,OAAO,GAAI,wBAAjB;;AAEA,MAAKrC,IAAI,CAACsC,UAAL,CAAiBD,OAAjB,CAAL,EAAkC;AACjC,WAAOrC,IAAI,CAACuC,KAAL,CAAYF,OAAO,CAACf,MAApB,CAAP;AACA;;AAED,SAAOtB,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\nimport { pasteHandler } from '@wordpress/blocks';\nimport {\n\tisEmpty,\n\tinsert,\n\tcreate,\n\treplace,\n\t__UNSTABLE_LINE_SEPARATOR as LINE_SEPARATOR,\n} from '@wordpress/rich-text';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { filePasteHandler } from './file-paste-handler';\nimport { addActiveFormats, isShortcode } from './utils';\nimport { splitValue } from './split-value';\nimport { shouldDismissPastedFiles } from '../../utils/pasting';\n\n/** @typedef {import('@wordpress/rich-text').RichTextValue} RichTextValue */\n\n/**\n * Replaces line separators with line breaks if not multiline.\n * Replaces line breaks with line separators if multiline.\n *\n * @param {RichTextValue} value Value to adjust.\n * @param {boolean} isMultiline Whether to adjust to multiline or not.\n *\n * @return {RichTextValue} Adjusted value.\n */\nfunction adjustLines( value, isMultiline ) {\n\tif ( isMultiline ) {\n\t\treturn replace( value, /\\n+/g, LINE_SEPARATOR );\n\t}\n\n\treturn replace( value, new RegExp( LINE_SEPARATOR, 'g' ), '\\n' );\n}\n\nexport function usePasteHandler( props ) {\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\treturn useRefEffect( ( element ) => {\n\t\tfunction _onPaste( event ) {\n\t\t\tconst {\n\t\t\t\tisSelected,\n\t\t\t\tdisableFormats,\n\t\t\t\tonChange,\n\t\t\t\tvalue,\n\t\t\t\tformatTypes,\n\t\t\t\ttagName,\n\t\t\t\tonReplace,\n\t\t\t\tonSplit,\n\t\t\t\tonSplitMiddle,\n\t\t\t\t__unstableEmbedURLOnPaste,\n\t\t\t\tmultilineTag,\n\t\t\t\tpreserveWhiteSpace,\n\t\t\t\tpastePlainText,\n\t\t\t} = propsRef.current;\n\n\t\t\tif ( ! isSelected ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { clipboardData } = event;\n\n\t\t\tlet plainText = '';\n\t\t\tlet html = '';\n\n\t\t\t// IE11 only supports `Text` as an argument for `getData` and will\n\t\t\t// otherwise throw an invalid argument error, so we try the standard\n\t\t\t// arguments first, then fallback to `Text` if they fail.\n\t\t\ttry {\n\t\t\t\tplainText = clipboardData.getData( 'text/plain' );\n\t\t\t\thtml = clipboardData.getData( 'text/html' );\n\t\t\t} catch ( error1 ) {\n\t\t\t\ttry {\n\t\t\t\t\thtml = clipboardData.getData( 'Text' );\n\t\t\t\t} catch ( error2 ) {\n\t\t\t\t\t// Some browsers like UC Browser paste plain text by default and\n\t\t\t\t\t// don't support clipboardData at all, so allow default\n\t\t\t\t\t// behaviour.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Remove Windows-specific metadata appended within copied HTML text.\n\t\t\thtml = removeWindowsFragments( html );\n\n\t\t\t// Strip meta tag.\n\t\t\thtml = removeCharsetMetaTag( html );\n\n\t\t\tevent.preventDefault();\n\n\t\t\t// Allows us to ask for this information when we get a report.\n\t\t\twindow.console.log( 'Received HTML:\\n\\n', html );\n\t\t\twindow.console.log( 'Received plain text:\\n\\n', plainText );\n\n\t\t\tif ( disableFormats ) {\n\t\t\t\tonChange( insert( value, plainText ) );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst transformed = formatTypes.reduce(\n\t\t\t\t( accumlator, { __unstablePasteRule } ) => {\n\t\t\t\t\t// Only allow one transform.\n\t\t\t\t\tif ( __unstablePasteRule && accumlator === value ) {\n\t\t\t\t\t\taccumlator = __unstablePasteRule( value, {\n\t\t\t\t\t\t\thtml,\n\t\t\t\t\t\t\tplainText,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn accumlator;\n\t\t\t\t},\n\t\t\t\tvalue\n\t\t\t);\n\n\t\t\tif ( transformed !== value ) {\n\t\t\t\tonChange( transformed );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst files = [ ...getFilesFromDataTransfer( clipboardData ) ];\n\t\t\tconst isInternal = clipboardData.getData( 'rich-text' ) === 'true';\n\n\t\t\t// If the data comes from a rich text instance, we can directly use it\n\t\t\t// without filtering the data. The filters are only meant for externally\n\t\t\t// pasted content and remove inline styles.\n\t\t\tif ( isInternal ) {\n\t\t\t\tconst pastedMultilineTag =\n\t\t\t\t\tclipboardData.getData( 'rich-text-multi-line-tag' ) ||\n\t\t\t\t\tundefined;\n\t\t\t\tlet pastedValue = create( {\n\t\t\t\t\thtml,\n\t\t\t\t\tmultilineTag: pastedMultilineTag,\n\t\t\t\t\tmultilineWrapperTags:\n\t\t\t\t\t\tpastedMultilineTag === 'li'\n\t\t\t\t\t\t\t? [ 'ul', 'ol' ]\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\tpreserveWhiteSpace,\n\t\t\t\t} );\n\t\t\t\tpastedValue = adjustLines( pastedValue, !! multilineTag );\n\t\t\t\taddActiveFormats( pastedValue, value.activeFormats );\n\t\t\t\tonChange( insert( value, pastedValue ) );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( pastePlainText ) {\n\t\t\t\tonChange( insert( value, create( { text: plainText } ) ) );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Process any attached files, unless we infer that the files in\n\t\t\t// question are redundant \"screenshots\" of the actual HTML payload,\n\t\t\t// as created by certain office-type programs.\n\t\t\t//\n\t\t\t// @see shouldDismissPastedFiles\n\t\t\tif (\n\t\t\t\tfiles?.length &&\n\t\t\t\t! shouldDismissPastedFiles( files, html, plainText )\n\t\t\t) {\n\t\t\t\tconst content = pasteHandler( {\n\t\t\t\t\tHTML: filePasteHandler( files ),\n\t\t\t\t\tmode: 'BLOCKS',\n\t\t\t\t\ttagName,\n\t\t\t\t\tpreserveWhiteSpace,\n\t\t\t\t} );\n\n\t\t\t\t// Allows us to ask for this information when we get a report.\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\twindow.console.log( 'Received items:\\n\\n', files );\n\n\t\t\t\tif ( onReplace && isEmpty( value ) ) {\n\t\t\t\t\tonReplace( content );\n\t\t\t\t} else {\n\t\t\t\t\tsplitValue( {\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tpastedBlocks: content,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonSplitMiddle,\n\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet mode = onReplace && onSplit ? 'AUTO' : 'INLINE';\n\n\t\t\t// Force the blocks mode when the user is pasting\n\t\t\t// on a new line & the content resembles a shortcode.\n\t\t\t// Otherwise it's going to be detected as inline\n\t\t\t// and the shortcode won't be replaced.\n\t\t\tif (\n\t\t\t\tmode === 'AUTO' &&\n\t\t\t\tisEmpty( value ) &&\n\t\t\t\tisShortcode( plainText )\n\t\t\t) {\n\t\t\t\tmode = 'BLOCKS';\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t__unstableEmbedURLOnPaste &&\n\t\t\t\tisEmpty( value ) &&\n\t\t\t\tisURL( plainText.trim() )\n\t\t\t) {\n\t\t\t\tmode = 'BLOCKS';\n\t\t\t}\n\n\t\t\tconst content = pasteHandler( {\n\t\t\t\tHTML: html,\n\t\t\t\tplainText,\n\t\t\t\tmode,\n\t\t\t\ttagName,\n\t\t\t\tpreserveWhiteSpace,\n\t\t\t} );\n\n\t\t\tif ( typeof content === 'string' ) {\n\t\t\t\tlet valueToInsert = create( { html: content } );\n\n\t\t\t\t// If the content should be multiline, we should process text\n\t\t\t\t// separated by a line break as separate lines.\n\t\t\t\tvalueToInsert = adjustLines( valueToInsert, !! multilineTag );\n\n\t\t\t\taddActiveFormats( valueToInsert, value.activeFormats );\n\t\t\t\tonChange( insert( value, valueToInsert ) );\n\t\t\t} else if ( content.length > 0 ) {\n\t\t\t\tif ( onReplace && isEmpty( value ) ) {\n\t\t\t\t\tonReplace( content, content.length - 1, -1 );\n\t\t\t\t} else {\n\t\t\t\t\tsplitValue( {\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tpastedBlocks: content,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonSplitMiddle,\n\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\telement.addEventListener( 'paste', _onPaste );\n\t\treturn () => {\n\t\t\telement.removeEventListener( 'paste', _onPaste );\n\t\t};\n\t}, [] );\n}\n\n/**\n * Normalizes a given string of HTML to remove the Windows-specific \"Fragment\"\n * comments and any preceeding and trailing content.\n *\n * @param {string} html the html to be normalized\n * @return {string} the normalized html\n */\nfunction removeWindowsFragments( html ) {\n\tconst startStr = '<!--StartFragment-->';\n\tconst startIdx = html.indexOf( startStr );\n\tif ( startIdx > -1 ) {\n\t\thtml = html.substring( startIdx + startStr.length );\n\t} else {\n\t\t// No point looking for EndFragment\n\t\treturn html;\n\t}\n\n\tconst endStr = '<!--EndFragment-->';\n\tconst endIdx = html.indexOf( endStr );\n\tif ( endIdx > -1 ) {\n\t\thtml = html.substring( 0, endIdx );\n\t}\n\n\treturn html;\n}\n\n/**\n * Removes the charset meta tag inserted by Chromium.\n * See:\n * - https://github.com/WordPress/gutenberg/issues/33585\n * - https://bugs.chromium.org/p/chromium/issues/detail?id=1264616#c4\n *\n * @param {string} html the html to be stripped of the meta tag.\n * @return {string} the cleaned html\n */\nfunction removeCharsetMetaTag( html ) {\n\tconst metaTag = `<meta charset='utf-8'>`;\n\n\tif ( html.startsWith( metaTag ) ) {\n\t\treturn html.slice( metaTag.length );\n\t}\n\n\treturn html;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/skip-to-selected-block/index.js"],"names":["SkipToSelectedBlock","selectedBlockClientId","ref","onClick","current","focus","select","blockEditorStore","getBlockSelectionStart"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AAXA;AACA;AACA;;AAKA;AACA;AACA;AAIA,MAAMA,mBAAmB,GAAG,QAAiC;AAAA,MAA/B;AAAEC,IAAAA;AAAF,GAA+B;AAC5D,QAAMC,GAAG,GAAG,yCAAaD,qBAAb,CAAZ;;AACA,QAAME,OAAO,GAAG,MAAM;AACrBD,IAAAA,GAAG,CAACE,OAAJ,CAAYC,KAAZ;AACA,GAFD;;AAIA,SAAOJ,qBAAqB,GAC3B,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,WADT;AAEC,IAAA,SAAS,EAAC,qCAFX;AAGC,IAAA,OAAO,EAAGE;AAHX,KAKG,cAAI,4BAAJ,CALH,CAD2B,GAQxB,IARJ;AASA,CAfD;AAiBA;AACA;AACA;;;eACe,sBAAcG,MAAF,IAAc;AACxC,SAAO;AACNL,IAAAA,qBAAqB,EAAEK,MAAM,CAC5BC,YAD4B,CAAN,CAErBC,sBAFqB;AADjB,GAAP;AAKA,CANc,EAMVR,mBANU,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { withSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockRef as useBlockRef } from '../block-list/use-block-props/use-block-refs';\n\nconst SkipToSelectedBlock = ( { selectedBlockClientId } ) => {\n\tconst ref = useBlockRef( selectedBlockClientId );\n\tconst onClick = () => {\n\t\tref.current.focus();\n\t};\n\n\treturn selectedBlockClientId ? (\n\t\t<Button\n\t\t\tvariant=\"secondary\"\n\t\t\tclassName=\"block-editor-skip-to-selected-block\"\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ __( 'Skip to the selected block' ) }\n\t\t</Button>\n\t) : null;\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/skip-to-selected-block/README.md\n */\nexport default withSelect( ( select ) => {\n\treturn {\n\t\tselectedBlockClientId: select(\n\t\t\tblockEditorStore\n\t\t).getBlockSelectionStart(),\n\t};\n} )( SkipToSelectedBlock );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/skip-to-selected-block/index.js"],"names":["SkipToSelectedBlock","selectedBlockClientId","ref","onClick","current","focus","select","blockEditorStore","getBlockSelectionStart"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AAXA;AACA;AACA;;AAKA;AACA;AACA;AAIA,MAAMA,mBAAmB,GAAG,QAAiC;AAAA,MAA/B;AAAEC,IAAAA;AAAF,GAA+B;AAC5D,QAAMC,GAAG,GAAG,yCAAaD,qBAAb,CAAZ;;AACA,QAAME,OAAO,GAAG,MAAM;AACrBD,IAAAA,GAAG,CAACE,OAAJ,CAAYC,KAAZ;AACA,GAFD;;AAIA,SAAOJ,qBAAqB,GAC3B,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,WADT;AAEC,IAAA,SAAS,EAAC,qCAFX;AAGC,IAAA,OAAO,EAAGE;AAHX,KAKG,cAAI,4BAAJ,CALH,CAD2B,GAQxB,IARJ;AASA,CAfD;AAiBA;AACA;AACA;;;eACe,sBAAcG,MAAF,IAAc;AACxC,SAAO;AACNL,IAAAA,qBAAqB,EACpBK,MAAM,CAAEC,YAAF,CAAN,CAA2BC,sBAA3B;AAFK,GAAP;AAIA,CALc,EAKVR,mBALU,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { withSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockRef as useBlockRef } from '../block-list/use-block-props/use-block-refs';\n\nconst SkipToSelectedBlock = ( { selectedBlockClientId } ) => {\n\tconst ref = useBlockRef( selectedBlockClientId );\n\tconst onClick = () => {\n\t\tref.current.focus();\n\t};\n\n\treturn selectedBlockClientId ? (\n\t\t<Button\n\t\t\tvariant=\"secondary\"\n\t\t\tclassName=\"block-editor-skip-to-selected-block\"\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ __( 'Skip to the selected block' ) }\n\t\t</Button>\n\t) : null;\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/skip-to-selected-block/README.md\n */\nexport default withSelect( ( select ) => {\n\treturn {\n\t\tselectedBlockClientId:\n\t\t\tselect( blockEditorStore ).getBlockSelectionStart(),\n\t};\n} )( SkipToSelectedBlock );\n"]}
@@ -10,8 +10,6 @@ exports.default = void 0;
10
10
 
11
11
  var _element = require("@wordpress/element");
12
12
 
13
- var _lodash = require("lodash");
14
-
15
13
  var _blocks = require("@wordpress/blocks");
16
14
 
17
15
  var _components = require("@wordpress/components");
@@ -26,10 +24,6 @@ var _icon = _interopRequireDefault(require("./icon"));
26
24
 
27
25
  var _store = require("../../store");
28
26
 
29
- /**
30
- * External dependencies
31
- */
32
-
33
27
  /**
34
28
  * WordPress dependencies
35
29
  */
@@ -37,6 +31,8 @@ var _store = require("../../store");
37
31
  /**
38
32
  * Internal dependencies
39
33
  */
34
+ const noop = () => {};
35
+
40
36
  function UngroupButton(_ref) {
41
37
  let {
42
38
  onConvertFromGroup,
@@ -76,7 +72,7 @@ var _default = (0, _compose.compose)([(0, _data.withSelect)(select => {
76
72
  let {
77
73
  clientId,
78
74
  innerBlocks,
79
- onToggle = _lodash.noop
75
+ onToggle = noop
80
76
  } = _ref2;
81
77
  const {
82
78
  replaceBlocks
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/ungroup-button/index.native.js"],"names":["UngroupButton","onConvertFromGroup","isUngroupable","UngroupIcon","select","getSelectedBlockClientId","getBlock","blockEditorStore","getGroupingBlockName","blocksStore","selectedId","selectedBlock","groupingBlockName","innerBlocks","length","name","clientId","dispatch","onToggle","noop","replaceBlocks"],"mappings":";;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;AAIO,SAASA,aAAT,OAAwE;AAAA,MAAhD;AAAEC,IAAAA,kBAAF;AAAsBC,IAAAA,aAAa,GAAG;AAAtC,GAAgD;;AAC9E,MAAK,CAAEA,aAAP,EAAuB;AACtB,WAAO,IAAP;AACA;;AACD,SACC,4BAAC,wBAAD,QACC,4BAAC,yBAAD;AACC,IAAA,KAAK,EAAG,cAAI,SAAJ,CADT;AAEC,IAAA,IAAI,EAAGC,aAFR;AAGC,IAAA,OAAO,EAAGF;AAHX,IADD,CADD;AASA;;eAEc,sBAAS,CACvB,sBAAcG,MAAF,IAAc;AACzB,QAAM;AAAEC,IAAAA,wBAAF;AAA4BC,IAAAA;AAA5B,MAAyCF,MAAM,CACpDG,YADoD,CAArD;AAIA,QAAM;AAAEC,IAAAA;AAAF,MAA2BJ,MAAM,CAAEK,aAAF,CAAvC;AAEA,QAAMC,UAAU,GAAGL,wBAAwB,EAA3C;AACA,QAAMM,aAAa,GAAGL,QAAQ,CAAEI,UAAF,CAA9B;AAEA,QAAME,iBAAiB,GAAGJ,oBAAoB,EAA9C;AAEA,QAAMN,aAAa,GAClBS,aAAa,IACbA,aAAa,CAACE,WADd,IAEA,CAAC,CAAEF,aAAa,CAACE,WAAd,CAA0BC,MAF7B,IAGAH,aAAa,CAACI,IAAd,KAAuBH,iBAJxB;AAKA,QAAMC,WAAW,GAAGX,aAAa,GAAGS,aAAa,CAACE,WAAjB,GAA+B,EAAhE;AAEA,SAAO;AACNX,IAAAA,aADM;AAENc,IAAAA,QAAQ,EAAEN,UAFJ;AAGNG,IAAAA;AAHM,GAAP;AAKA,CAxBD,CADuB,EA0BvB,wBAAc,CAAEI,QAAF,YAA4D;AAAA,MAAhD;AAAED,IAAAA,QAAF;AAAYH,IAAAA,WAAZ;AAAyBK,IAAAA,QAAQ,GAAGC;AAApC,GAAgD;AACzE,QAAM;AAAEC,IAAAA;AAAF,MAAoBH,QAAQ,CAAEV,YAAF,CAAlC;AAEA,SAAO;AACNN,IAAAA,kBAAkB,GAAG;AACpB,UAAK,CAAEY,WAAW,CAACC,MAAnB,EAA4B;AAC3B;AACA;;AAEDM,MAAAA,aAAa,CAAEJ,QAAF,EAAYH,WAAZ,CAAb;AAEAK,MAAAA,QAAQ;AACR;;AATK,GAAP;AAWA,CAdD,CA1BuB,CAAT,EAyCVlB,aAzCU,C","sourcesContent":["/**\n * External dependencies\n */\nimport { noop } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { ToolbarGroup, ToolbarButton } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport UngroupIcon from './icon';\nimport { store as blockEditorStore } from '../../store';\n\nexport function UngroupButton( { onConvertFromGroup, isUngroupable = false } ) {\n\tif ( ! isUngroupable ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<ToolbarGroup>\n\t\t\t<ToolbarButton\n\t\t\t\ttitle={ __( 'Ungroup' ) }\n\t\t\t\ticon={ UngroupIcon }\n\t\t\t\tonClick={ onConvertFromGroup }\n\t\t\t/>\n\t\t</ToolbarGroup>\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst { getSelectedBlockClientId, getBlock } = select(\n\t\t\tblockEditorStore\n\t\t);\n\n\t\tconst { getGroupingBlockName } = select( blocksStore );\n\n\t\tconst selectedId = getSelectedBlockClientId();\n\t\tconst selectedBlock = getBlock( selectedId );\n\n\t\tconst groupingBlockName = getGroupingBlockName();\n\n\t\tconst isUngroupable =\n\t\t\tselectedBlock &&\n\t\t\tselectedBlock.innerBlocks &&\n\t\t\t!! selectedBlock.innerBlocks.length &&\n\t\t\tselectedBlock.name === groupingBlockName;\n\t\tconst innerBlocks = isUngroupable ? selectedBlock.innerBlocks : [];\n\n\t\treturn {\n\t\t\tisUngroupable,\n\t\t\tclientId: selectedId,\n\t\t\tinnerBlocks,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch, { clientId, innerBlocks, onToggle = noop } ) => {\n\t\tconst { replaceBlocks } = dispatch( blockEditorStore );\n\n\t\treturn {\n\t\t\tonConvertFromGroup() {\n\t\t\t\tif ( ! innerBlocks.length ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\treplaceBlocks( clientId, innerBlocks );\n\n\t\t\t\tonToggle();\n\t\t\t},\n\t\t};\n\t} ),\n] )( UngroupButton );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/ungroup-button/index.native.js"],"names":["noop","UngroupButton","onConvertFromGroup","isUngroupable","UngroupIcon","select","getSelectedBlockClientId","getBlock","blockEditorStore","getGroupingBlockName","blocksStore","selectedId","selectedBlock","groupingBlockName","innerBlocks","length","name","clientId","dispatch","onToggle","replaceBlocks"],"mappings":";;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAbA;AACA;AACA;;AAOA;AACA;AACA;AAIA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEO,SAASC,aAAT,OAAwE;AAAA,MAAhD;AAAEC,IAAAA,kBAAF;AAAsBC,IAAAA,aAAa,GAAG;AAAtC,GAAgD;;AAC9E,MAAK,CAAEA,aAAP,EAAuB;AACtB,WAAO,IAAP;AACA;;AACD,SACC,4BAAC,wBAAD,QACC,4BAAC,yBAAD;AACC,IAAA,KAAK,EAAG,cAAI,SAAJ,CADT;AAEC,IAAA,IAAI,EAAGC,aAFR;AAGC,IAAA,OAAO,EAAGF;AAHX,IADD,CADD;AASA;;eAEc,sBAAS,CACvB,sBAAcG,MAAF,IAAc;AACzB,QAAM;AAAEC,IAAAA,wBAAF;AAA4BC,IAAAA;AAA5B,MACLF,MAAM,CAAEG,YAAF,CADP;AAGA,QAAM;AAAEC,IAAAA;AAAF,MAA2BJ,MAAM,CAAEK,aAAF,CAAvC;AAEA,QAAMC,UAAU,GAAGL,wBAAwB,EAA3C;AACA,QAAMM,aAAa,GAAGL,QAAQ,CAAEI,UAAF,CAA9B;AAEA,QAAME,iBAAiB,GAAGJ,oBAAoB,EAA9C;AAEA,QAAMN,aAAa,GAClBS,aAAa,IACbA,aAAa,CAACE,WADd,IAEA,CAAC,CAAEF,aAAa,CAACE,WAAd,CAA0BC,MAF7B,IAGAH,aAAa,CAACI,IAAd,KAAuBH,iBAJxB;AAKA,QAAMC,WAAW,GAAGX,aAAa,GAAGS,aAAa,CAACE,WAAjB,GAA+B,EAAhE;AAEA,SAAO;AACNX,IAAAA,aADM;AAENc,IAAAA,QAAQ,EAAEN,UAFJ;AAGNG,IAAAA;AAHM,GAAP;AAKA,CAvBD,CADuB,EAyBvB,wBAAc,CAAEI,QAAF,YAA4D;AAAA,MAAhD;AAAED,IAAAA,QAAF;AAAYH,IAAAA,WAAZ;AAAyBK,IAAAA,QAAQ,GAAGnB;AAApC,GAAgD;AACzE,QAAM;AAAEoB,IAAAA;AAAF,MAAoBF,QAAQ,CAAEV,YAAF,CAAlC;AAEA,SAAO;AACNN,IAAAA,kBAAkB,GAAG;AACpB,UAAK,CAAEY,WAAW,CAACC,MAAnB,EAA4B;AAC3B;AACA;;AAEDK,MAAAA,aAAa,CAAEH,QAAF,EAAYH,WAAZ,CAAb;AAEAK,MAAAA,QAAQ;AACR;;AATK,GAAP;AAWA,CAdD,CAzBuB,CAAT,EAwCVlB,aAxCU,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { ToolbarGroup, ToolbarButton } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport UngroupIcon from './icon';\nimport { store as blockEditorStore } from '../../store';\n\nconst noop = () => {};\n\nexport function UngroupButton( { onConvertFromGroup, isUngroupable = false } ) {\n\tif ( ! isUngroupable ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<ToolbarGroup>\n\t\t\t<ToolbarButton\n\t\t\t\ttitle={ __( 'Ungroup' ) }\n\t\t\t\ticon={ UngroupIcon }\n\t\t\t\tonClick={ onConvertFromGroup }\n\t\t\t/>\n\t\t</ToolbarGroup>\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst { getSelectedBlockClientId, getBlock } =\n\t\t\tselect( blockEditorStore );\n\n\t\tconst { getGroupingBlockName } = select( blocksStore );\n\n\t\tconst selectedId = getSelectedBlockClientId();\n\t\tconst selectedBlock = getBlock( selectedId );\n\n\t\tconst groupingBlockName = getGroupingBlockName();\n\n\t\tconst isUngroupable =\n\t\t\tselectedBlock &&\n\t\t\tselectedBlock.innerBlocks &&\n\t\t\t!! selectedBlock.innerBlocks.length &&\n\t\t\tselectedBlock.name === groupingBlockName;\n\t\tconst innerBlocks = isUngroupable ? selectedBlock.innerBlocks : [];\n\n\t\treturn {\n\t\t\tisUngroupable,\n\t\t\tclientId: selectedId,\n\t\t\tinnerBlocks,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch, { clientId, innerBlocks, onToggle = noop } ) => {\n\t\tconst { replaceBlocks } = dispatch( blockEditorStore );\n\n\t\treturn {\n\t\t\tonConvertFromGroup() {\n\t\t\t\tif ( ! innerBlocks.length ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\treplaceBlocks( clientId, innerBlocks );\n\n\t\t\t\tonToggle();\n\t\t\t},\n\t\t};\n\t} ),\n] )( UngroupButton );\n"]}
@@ -42,6 +42,17 @@ var _store = require("../../store");
42
42
  /**
43
43
  * Internal dependencies
44
44
  */
45
+
46
+ /**
47
+ * Whether the argument is a function.
48
+ *
49
+ * @param {*} maybeFunc The argument to check.
50
+ * @return {boolean} True if the argument is a function, false otherwise.
51
+ */
52
+ function isFunction(maybeFunc) {
53
+ return typeof maybeFunc === 'function';
54
+ }
55
+
45
56
  class URLInput extends _element.Component {
46
57
  constructor(props) {
47
58
  super(props);
@@ -470,7 +481,7 @@ class URLInput extends _element.Component {
470
481
  };
471
482
  };
472
483
 
473
- if ((0, _lodash.isFunction)(renderSuggestions) && showSuggestions && !!suggestions.length) {
484
+ if (isFunction(renderSuggestions) && showSuggestions && !!suggestions.length) {
474
485
  return renderSuggestions({
475
486
  suggestions,
476
487
  selectedSuggestion,
@@ -482,7 +493,7 @@ class URLInput extends _element.Component {
482
493
  });
483
494
  }
484
495
 
485
- if (!(0, _lodash.isFunction)(renderSuggestions) && showSuggestions && !!suggestions.length) {
496
+ if (!isFunction(renderSuggestions) && showSuggestions && !!suggestions.length) {
486
497
  return (0, _element.createElement)(_components.Popover, {
487
498
  position: "bottom",
488
499
  focusOnMount: false
@@ -509,7 +520,7 @@ class URLInput extends _element.Component {
509
520
  var _default = (0, _compose.compose)(_compose.withSafeTimeout, _components.withSpokenMessages, _compose.withInstanceId, (0, _data.withSelect)((select, props) => {
510
521
  // If a link suggestions handler is already provided then
511
522
  // bail.
512
- if ((0, _lodash.isFunction)(props.__experimentalFetchLinkSuggestions)) {
523
+ if (isFunction(props.__experimentalFetchLinkSuggestions)) {
513
524
  return;
514
525
  }
515
526
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/url-input/index.js"],"names":["URLInput","Component","constructor","props","onChange","bind","onFocus","onKeyDown","selectLink","handleOnClick","bindSuggestionNode","autocompleteRef","inputRef","updateSuggestions","suggestionNodes","isUpdatingSuggestions","state","suggestions","showSuggestions","selectedSuggestion","suggestionsListboxId","suggestionOptionIdPrefix","componentDidUpdate","prevProps","value","__experimentalShowInitialSuggestions","scrollingIntoView","current","onlyScrollIfNeeded","setTimeout","disableSuggestions","length","componentDidMount","shouldShowInitialSuggestions","componentWillUnmount","suggestionsRequest","cancel","index","ref","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","__experimentalHandleURLSuggestions","handleURLSuggestions","isInitialSuggestions","trim","setState","loading","request","then","debouncedSpeak","catch","event","inputValue","target","keyCode","UP","selectionStart","preventDefault","setSelectionRange","DOWN","ENTER","onSubmit","suggestion","previousIndex","nextIndex","TAB","speak","url","focus","getDerivedStateFromProps","instanceId","shouldShowSuggestions","hasValue","render","renderControl","renderSuggestions","label","className","isFullWidth","placeholder","__experimentalRenderControl","inputId","controlProps","id","inputProps","required","type","role","undefined","__experimentalRenderSuggestions","suggestionsListProps","buildSuggestionItemProps","tabIndex","isLoading","handleSuggestionClick","map","title","withSafeTimeout","withSpokenMessages","withInstanceId","select","getSettings","blockEditorStore"],"mappings":";;;;;;;;;AAWA;;;;AARA;;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E,YAAF,CAA9B;AACA,SAAO;AACN/D,IAAAA,kCAAkC,EAAE8D,WAAW,GAC7C9D;AAFI,GAAP;AAIA,CAXD,CAJc,EAgBZvC,QAhBY,C","sourcesContent":["/**\n * External dependencies\n */\nimport { debounce, isFunction } from 'lodash';\nimport classnames from 'classnames';\nimport scrollIntoView from 'dom-scroll-into-view';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf, _n } from '@wordpress/i18n';\nimport { Component, createRef } from '@wordpress/element';\nimport { UP, DOWN, ENTER, TAB } from '@wordpress/keycodes';\nimport {\n\tBaseControl,\n\tButton,\n\tSpinner,\n\twithSpokenMessages,\n\tPopover,\n} from '@wordpress/components';\nimport { withInstanceId, withSafeTimeout, compose } from '@wordpress/compose';\nimport { withSelect } from '@wordpress/data';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nclass URLInput extends Component {\n\tconstructor( props ) {\n\t\tsuper( props );\n\n\t\tthis.onChange = this.onChange.bind( this );\n\t\tthis.onFocus = this.onFocus.bind( this );\n\t\tthis.onKeyDown = this.onKeyDown.bind( this );\n\t\tthis.selectLink = this.selectLink.bind( this );\n\t\tthis.handleOnClick = this.handleOnClick.bind( this );\n\t\tthis.bindSuggestionNode = this.bindSuggestionNode.bind( this );\n\t\tthis.autocompleteRef = props.autocompleteRef || createRef();\n\t\tthis.inputRef = createRef();\n\t\tthis.updateSuggestions = debounce(\n\t\t\tthis.updateSuggestions.bind( this ),\n\t\t\t200\n\t\t);\n\n\t\tthis.suggestionNodes = [];\n\n\t\tthis.isUpdatingSuggestions = false;\n\n\t\tthis.state = {\n\t\t\tsuggestions: [],\n\t\t\tshowSuggestions: false,\n\t\t\tselectedSuggestion: null,\n\n\t\t\tsuggestionsListboxId: '',\n\t\t\tsuggestionOptionIdPrefix: '',\n\t\t};\n\t}\n\n\tcomponentDidUpdate( prevProps ) {\n\t\tconst { showSuggestions, selectedSuggestion } = this.state;\n\t\tconst {\n\t\t\tvalue,\n\t\t\t__experimentalShowInitialSuggestions = false,\n\t\t} = this.props;\n\n\t\t// Only have to worry about scrolling selected suggestion into view\n\t\t// when already expanded.\n\t\tif (\n\t\t\tshowSuggestions &&\n\t\t\tselectedSuggestion !== null &&\n\t\t\tthis.suggestionNodes[ selectedSuggestion ] &&\n\t\t\t! this.scrollingIntoView\n\t\t) {\n\t\t\tthis.scrollingIntoView = true;\n\t\t\tscrollIntoView(\n\t\t\t\tthis.suggestionNodes[ selectedSuggestion ],\n\t\t\t\tthis.autocompleteRef.current,\n\t\t\t\t{\n\t\t\t\t\tonlyScrollIfNeeded: true,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tthis.props.setTimeout( () => {\n\t\t\t\tthis.scrollingIntoView = false;\n\t\t\t}, 100 );\n\t\t}\n\n\t\t// Update suggestions when the value changes.\n\t\tif (\n\t\t\tprevProps.value !== value &&\n\t\t\t! this.props.disableSuggestions &&\n\t\t\t! this.isUpdatingSuggestions\n\t\t) {\n\t\t\tif ( value?.length ) {\n\t\t\t\t// If the new value is not empty we need to update with suggestions for it.\n\t\t\t\tthis.updateSuggestions( value );\n\t\t\t} else if ( __experimentalShowInitialSuggestions ) {\n\t\t\t\t// If the new value is empty and we can show initial suggestions, then show initial suggestions.\n\t\t\t\tthis.updateSuggestions();\n\t\t\t}\n\t\t}\n\t}\n\n\tcomponentDidMount() {\n\t\tif ( this.shouldShowInitialSuggestions() ) {\n\t\t\tthis.updateSuggestions();\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\tthis.suggestionsRequest?.cancel?.();\n\t\tdelete this.suggestionsRequest;\n\t}\n\n\tbindSuggestionNode( index ) {\n\t\treturn ( ref ) => {\n\t\t\tthis.suggestionNodes[ index ] = ref;\n\t\t};\n\t}\n\n\tshouldShowInitialSuggestions() {\n\t\tconst { suggestions } = this.state;\n\t\tconst {\n\t\t\t__experimentalShowInitialSuggestions = false,\n\t\t\tvalue,\n\t\t} = this.props;\n\t\treturn (\n\t\t\t! this.isUpdatingSuggestions &&\n\t\t\t__experimentalShowInitialSuggestions &&\n\t\t\t! ( value && value.length ) &&\n\t\t\t! ( suggestions && suggestions.length )\n\t\t);\n\t}\n\n\tupdateSuggestions( value = '' ) {\n\t\tconst {\n\t\t\t__experimentalFetchLinkSuggestions: fetchLinkSuggestions,\n\t\t\t__experimentalHandleURLSuggestions: handleURLSuggestions,\n\t\t} = this.props;\n\n\t\tif ( ! fetchLinkSuggestions ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Initial suggestions may only show if there is no value\n\t\t// (note: this includes whitespace).\n\t\tconst isInitialSuggestions = ! value?.length;\n\n\t\t// Trim only now we've determined whether or not it originally had a \"length\"\n\t\t// (even if that value was all whitespace).\n\t\tvalue = value.trim();\n\n\t\t// Allow a suggestions request if:\n\t\t// - there are at least 2 characters in the search input (except manual searches where\n\t\t// search input length is not required to trigger a fetch)\n\t\t// - this is a direct entry (eg: a URL)\n\t\tif (\n\t\t\t! isInitialSuggestions &&\n\t\t\t( value.length < 2 || ( ! handleURLSuggestions && isURL( value ) ) )\n\t\t) {\n\t\t\tthis.setState( {\n\t\t\t\tshowSuggestions: false,\n\t\t\t\tselectedSuggestion: null,\n\t\t\t\tloading: false,\n\t\t\t} );\n\n\t\t\treturn;\n\t\t}\n\n\t\tthis.isUpdatingSuggestions = true;\n\n\t\tthis.setState( {\n\t\t\tselectedSuggestion: null,\n\t\t\tloading: true,\n\t\t} );\n\n\t\tconst request = fetchLinkSuggestions( value, {\n\t\t\tisInitialSuggestions,\n\t\t} );\n\n\t\trequest\n\t\t\t.then( ( suggestions ) => {\n\t\t\t\t// A fetch Promise doesn't have an abort option. It's mimicked by\n\t\t\t\t// comparing the request reference in on the instance, which is\n\t\t\t\t// reset or deleted on subsequent requests or unmounting.\n\t\t\t\tif ( this.suggestionsRequest !== request ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.setState( {\n\t\t\t\t\tsuggestions,\n\t\t\t\t\tloading: false,\n\t\t\t\t\tshowSuggestions: !! suggestions.length,\n\t\t\t\t} );\n\n\t\t\t\tif ( !! suggestions.length ) {\n\t\t\t\t\tthis.props.debouncedSpeak(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %s: number of results. */\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'%d result found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\t'%d results found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\tsuggestions.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tsuggestions.length\n\t\t\t\t\t\t),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthis.props.debouncedSpeak(\n\t\t\t\t\t\t__( 'No results.' ),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthis.isUpdatingSuggestions = false;\n\t\t\t} )\n\t\t\t.catch( () => {\n\t\t\t\tif ( this.suggestionsRequest === request ) {\n\t\t\t\t\tthis.setState( {\n\t\t\t\t\t\tloading: false,\n\t\t\t\t\t} );\n\t\t\t\t\tthis.isUpdatingSuggestions = false;\n\t\t\t\t}\n\t\t\t} );\n\n\t\t// Note that this assignment is handled *before* the async search request\n\t\t// as a Promise always resolves on the next tick of the event loop.\n\t\tthis.suggestionsRequest = request;\n\t}\n\n\tonChange( event ) {\n\t\tconst inputValue = event.target.value;\n\n\t\tthis.props.onChange( inputValue );\n\t\tif ( ! this.props.disableSuggestions ) {\n\t\t\tthis.updateSuggestions( inputValue );\n\t\t}\n\t}\n\n\tonFocus() {\n\t\tconst { suggestions } = this.state;\n\t\tconst { disableSuggestions, value } = this.props;\n\n\t\t// When opening the link editor, if there's a value present, we want to load the suggestions pane with the results for this input search value\n\t\t// Don't re-run the suggestions on focus if there are already suggestions present (prevents searching again when tabbing between the input and buttons)\n\t\tif (\n\t\t\tvalue &&\n\t\t\t! disableSuggestions &&\n\t\t\t! this.isUpdatingSuggestions &&\n\t\t\t! ( suggestions && suggestions.length )\n\t\t) {\n\t\t\t// Ensure the suggestions are updated with the current input value.\n\t\t\tthis.updateSuggestions( value );\n\t\t}\n\t}\n\n\tonKeyDown( event ) {\n\t\tconst {\n\t\t\tshowSuggestions,\n\t\t\tselectedSuggestion,\n\t\t\tsuggestions,\n\t\t\tloading,\n\t\t} = this.state;\n\n\t\t// If the suggestions are not shown or loading, we shouldn't handle the arrow keys\n\t\t// We shouldn't preventDefault to allow block arrow keys navigation.\n\t\tif ( ! showSuggestions || ! suggestions.length || loading ) {\n\t\t\t// In the Windows version of Firefox the up and down arrows don't move the caret\n\t\t\t// within an input field like they do for Mac Firefox/Chrome/Safari. This causes\n\t\t\t// a form of focus trapping that is disruptive to the user experience. This disruption\n\t\t\t// only happens if the caret is not in the first or last position in the text input.\n\t\t\t// See: https://github.com/WordPress/gutenberg/issues/5693#issuecomment-436684747\n\t\t\tswitch ( event.keyCode ) {\n\t\t\t\t// When UP is pressed, if the caret is at the start of the text, move it to the 0\n\t\t\t\t// position.\n\t\t\t\tcase UP: {\n\t\t\t\t\tif ( 0 !== event.target.selectionStart ) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\t// Set the input caret to position 0.\n\t\t\t\t\t\tevent.target.setSelectionRange( 0, 0 );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t// When DOWN is pressed, if the caret is not at the end of the text, move it to the\n\t\t\t\t// last position.\n\t\t\t\tcase DOWN: {\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.props.value.length !== event.target.selectionStart\n\t\t\t\t\t) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\t// Set the input caret to the last position.\n\t\t\t\t\t\tevent.target.setSelectionRange(\n\t\t\t\t\t\t\tthis.props.value.length,\n\t\t\t\t\t\t\tthis.props.value.length\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t// Submitting while loading should trigger onSubmit.\n\t\t\t\tcase ENTER: {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tif ( this.props.onSubmit ) {\n\t\t\t\t\t\tthis.props.onSubmit( null, event );\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst suggestion = this.state.suggestions[\n\t\t\tthis.state.selectedSuggestion\n\t\t];\n\n\t\tswitch ( event.keyCode ) {\n\t\t\tcase UP: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst previousIndex = ! selectedSuggestion\n\t\t\t\t\t? suggestions.length - 1\n\t\t\t\t\t: selectedSuggestion - 1;\n\t\t\t\tthis.setState( {\n\t\t\t\t\tselectedSuggestion: previousIndex,\n\t\t\t\t} );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase DOWN: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst nextIndex =\n\t\t\t\t\tselectedSuggestion === null ||\n\t\t\t\t\tselectedSuggestion === suggestions.length - 1\n\t\t\t\t\t\t? 0\n\t\t\t\t\t\t: selectedSuggestion + 1;\n\t\t\t\tthis.setState( {\n\t\t\t\t\tselectedSuggestion: nextIndex,\n\t\t\t\t} );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase TAB: {\n\t\t\t\tif ( this.state.selectedSuggestion !== null ) {\n\t\t\t\t\tthis.selectLink( suggestion );\n\t\t\t\t\t// Announce a link has been selected when tabbing away from the input field.\n\t\t\t\t\tthis.props.speak( __( 'Link selected.' ) );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ENTER: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( this.state.selectedSuggestion !== null ) {\n\t\t\t\t\tthis.selectLink( suggestion );\n\n\t\t\t\t\tif ( this.props.onSubmit ) {\n\t\t\t\t\t\tthis.props.onSubmit( suggestion, event );\n\t\t\t\t\t}\n\t\t\t\t} else if ( this.props.onSubmit ) {\n\t\t\t\t\tthis.props.onSubmit( null, event );\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tselectLink( suggestion ) {\n\t\tthis.props.onChange( suggestion.url, suggestion );\n\t\tthis.setState( {\n\t\t\tselectedSuggestion: null,\n\t\t\tshowSuggestions: false,\n\t\t} );\n\t}\n\n\thandleOnClick( suggestion ) {\n\t\tthis.selectLink( suggestion );\n\t\t// Move focus to the input field when a link suggestion is clicked.\n\t\tthis.inputRef.current.focus();\n\t}\n\n\tstatic getDerivedStateFromProps(\n\t\t{\n\t\t\tvalue,\n\t\t\tinstanceId,\n\t\t\tdisableSuggestions,\n\t\t\t__experimentalShowInitialSuggestions = false,\n\t\t},\n\t\t{ showSuggestions }\n\t) {\n\t\tlet shouldShowSuggestions = showSuggestions;\n\n\t\tconst hasValue = value && value.length;\n\n\t\tif ( ! __experimentalShowInitialSuggestions && ! hasValue ) {\n\t\t\tshouldShowSuggestions = false;\n\t\t}\n\n\t\tif ( disableSuggestions === true ) {\n\t\t\tshouldShowSuggestions = false;\n\t\t}\n\n\t\treturn {\n\t\t\tshowSuggestions: shouldShowSuggestions,\n\t\t\tsuggestionsListboxId: `block-editor-url-input-suggestions-${ instanceId }`,\n\t\t\tsuggestionOptionIdPrefix: `block-editor-url-input-suggestion-${ instanceId }`,\n\t\t};\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ this.renderControl() }\n\t\t\t\t{ this.renderSuggestions() }\n\t\t\t</>\n\t\t);\n\t}\n\n\trenderControl() {\n\t\tconst {\n\t\t\tlabel = null,\n\t\t\tclassName,\n\t\t\tisFullWidth,\n\t\t\tinstanceId,\n\t\t\tplaceholder = __( 'Paste URL or type to search' ),\n\t\t\t__experimentalRenderControl: renderControl,\n\t\t\tvalue = '',\n\t\t} = this.props;\n\n\t\tconst {\n\t\t\tloading,\n\t\t\tshowSuggestions,\n\t\t\tselectedSuggestion,\n\t\t\tsuggestionsListboxId,\n\t\t\tsuggestionOptionIdPrefix,\n\t\t} = this.state;\n\n\t\tconst inputId = `url-input-control-${ instanceId }`;\n\n\t\tconst controlProps = {\n\t\t\tid: inputId, // Passes attribute to label for the for attribute\n\t\t\tlabel,\n\t\t\tclassName: classnames( 'block-editor-url-input', className, {\n\t\t\t\t'is-full-width': isFullWidth,\n\t\t\t} ),\n\t\t};\n\n\t\tconst inputProps = {\n\t\t\tid: inputId,\n\t\t\tvalue,\n\t\t\trequired: true,\n\t\t\tclassName: 'block-editor-url-input__input',\n\t\t\ttype: 'text',\n\t\t\tonChange: this.onChange,\n\t\t\tonFocus: this.onFocus,\n\t\t\tplaceholder,\n\t\t\tonKeyDown: this.onKeyDown,\n\t\t\trole: 'combobox',\n\t\t\t'aria-label': label ? undefined : __( 'URL' ), // Ensure input always has an accessible label\n\t\t\t'aria-expanded': showSuggestions,\n\t\t\t'aria-autocomplete': 'list',\n\t\t\t'aria-owns': suggestionsListboxId,\n\t\t\t'aria-activedescendant':\n\t\t\t\tselectedSuggestion !== null\n\t\t\t\t\t? `${ suggestionOptionIdPrefix }-${ selectedSuggestion }`\n\t\t\t\t\t: undefined,\n\t\t\tref: this.inputRef,\n\t\t};\n\n\t\tif ( renderControl ) {\n\t\t\treturn renderControl( controlProps, inputProps, loading );\n\t\t}\n\n\t\treturn (\n\t\t\t<BaseControl { ...controlProps }>\n\t\t\t\t<input { ...inputProps } />\n\t\t\t\t{ loading && <Spinner /> }\n\t\t\t</BaseControl>\n\t\t);\n\t}\n\n\trenderSuggestions() {\n\t\tconst {\n\t\t\tclassName,\n\t\t\t__experimentalRenderSuggestions: renderSuggestions,\n\t\t\tvalue = '',\n\t\t\t__experimentalShowInitialSuggestions = false,\n\t\t} = this.props;\n\n\t\tconst {\n\t\t\tshowSuggestions,\n\t\t\tsuggestions,\n\t\t\tselectedSuggestion,\n\t\t\tsuggestionsListboxId,\n\t\t\tsuggestionOptionIdPrefix,\n\t\t\tloading,\n\t\t} = this.state;\n\n\t\tconst suggestionsListProps = {\n\t\t\tid: suggestionsListboxId,\n\t\t\tref: this.autocompleteRef,\n\t\t\trole: 'listbox',\n\t\t};\n\n\t\tconst buildSuggestionItemProps = ( suggestion, index ) => {\n\t\t\treturn {\n\t\t\t\trole: 'option',\n\t\t\t\ttabIndex: '-1',\n\t\t\t\tid: `${ suggestionOptionIdPrefix }-${ index }`,\n\t\t\t\tref: this.bindSuggestionNode( index ),\n\t\t\t\t'aria-selected': index === selectedSuggestion,\n\t\t\t};\n\t\t};\n\n\t\tif (\n\t\t\tisFunction( renderSuggestions ) &&\n\t\t\tshowSuggestions &&\n\t\t\t!! suggestions.length\n\t\t) {\n\t\t\treturn renderSuggestions( {\n\t\t\t\tsuggestions,\n\t\t\t\tselectedSuggestion,\n\t\t\t\tsuggestionsListProps,\n\t\t\t\tbuildSuggestionItemProps,\n\t\t\t\tisLoading: loading,\n\t\t\t\thandleSuggestionClick: this.handleOnClick,\n\t\t\t\tisInitialSuggestions:\n\t\t\t\t\t__experimentalShowInitialSuggestions &&\n\t\t\t\t\t! ( value && value.length ),\n\t\t\t} );\n\t\t}\n\n\t\tif (\n\t\t\t! isFunction( renderSuggestions ) &&\n\t\t\tshowSuggestions &&\n\t\t\t!! suggestions.length\n\t\t) {\n\t\t\treturn (\n\t\t\t\t<Popover position=\"bottom\" focusOnMount={ false }>\n\t\t\t\t\t<div\n\t\t\t\t\t\t{ ...suggestionsListProps }\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-url-input__suggestions',\n\t\t\t\t\t\t\t`${ className }__suggestions`\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ suggestions.map( ( suggestion, index ) => (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t{ ...buildSuggestionItemProps(\n\t\t\t\t\t\t\t\t\tsuggestion,\n\t\t\t\t\t\t\t\t\tindex\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tkey={ suggestion.id }\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t'block-editor-url-input__suggestion',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t'is-selected':\n\t\t\t\t\t\t\t\t\t\t\tindex === selectedSuggestion,\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\tonClick={ () =>\n\t\t\t\t\t\t\t\t\tthis.handleOnClick( suggestion )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ suggestion.title }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</div>\n\t\t\t\t</Popover>\n\t\t\t);\n\t\t}\n\t\treturn null;\n\t}\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-input/README.md\n */\nexport default compose(\n\twithSafeTimeout,\n\twithSpokenMessages,\n\twithInstanceId,\n\twithSelect( ( select, props ) => {\n\t\t// If a link suggestions handler is already provided then\n\t\t// bail.\n\t\tif ( isFunction( props.__experimentalFetchLinkSuggestions ) ) {\n\t\t\treturn;\n\t\t}\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\t__experimentalFetchLinkSuggestions: getSettings()\n\t\t\t\t.__experimentalFetchLinkSuggestions,\n\t\t};\n\t} )\n)( URLInput );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/url-input/index.js"],"names":["isFunction","maybeFunc","URLInput","Component","constructor","props","onChange","bind","onFocus","onKeyDown","selectLink","handleOnClick","bindSuggestionNode","autocompleteRef","inputRef","updateSuggestions","suggestionNodes","isUpdatingSuggestions","state","suggestions","showSuggestions","selectedSuggestion","suggestionsListboxId","suggestionOptionIdPrefix","componentDidUpdate","prevProps","value","__experimentalShowInitialSuggestions","scrollingIntoView","current","onlyScrollIfNeeded","setTimeout","disableSuggestions","length","componentDidMount","shouldShowInitialSuggestions","componentWillUnmount","suggestionsRequest","cancel","index","ref","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","__experimentalHandleURLSuggestions","handleURLSuggestions","isInitialSuggestions","trim","setState","loading","request","then","debouncedSpeak","catch","event","inputValue","target","keyCode","UP","selectionStart","preventDefault","setSelectionRange","DOWN","ENTER","onSubmit","suggestion","previousIndex","nextIndex","TAB","speak","url","focus","getDerivedStateFromProps","instanceId","shouldShowSuggestions","hasValue","render","renderControl","renderSuggestions","label","className","isFullWidth","placeholder","__experimentalRenderControl","inputId","controlProps","id","inputProps","required","type","role","undefined","__experimentalRenderSuggestions","suggestionsListProps","buildSuggestionItemProps","tabIndex","isLoading","handleSuggestionClick","map","title","withSafeTimeout","withSpokenMessages","withInstanceId","select","getSettings","blockEditorStore"],"mappings":";;;;;;;;;AAWA;;;;AARA;;AACA;;AACA;;AAKA;;AAEA;;AACA;;AAOA;;AACA;;AACA;;AAKA;;AA3BA;AACA;AACA;;AAKA;AACA;AACA;;AAeA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,UAAT,CAAqBC,SAArB,EAAiC;AAChC,SAAO,OAAOA,SAAP,KAAqB,UAA5B;AACA;;AAED,MAAMC,QAAN,SAAuBC,kBAAvB,CAAiC;AAChCC,EAAAA,WAAW,CAAEC,KAAF,EAAU;AACpB,UAAOA,KAAP;AAEA,SAAKC,QAAL,GAAgB,KAAKA,QAAL,CAAcC,IAAd,CAAoB,IAApB,CAAhB;AACA,SAAKC,OAAL,GAAe,KAAKA,OAAL,CAAaD,IAAb,CAAmB,IAAnB,CAAf;AACA,SAAKE,SAAL,GAAiB,KAAKA,SAAL,CAAeF,IAAf,CAAqB,IAArB,CAAjB;AACA,SAAKG,UAAL,GAAkB,KAAKA,UAAL,CAAgBH,IAAhB,CAAsB,IAAtB,CAAlB;AACA,SAAKI,aAAL,GAA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AA,SAAS,EAAG,yBACX,qCADW,EAEV,GAAGb,SAAW,eAFJ;AAFb,UAOG5D,WAAW,CAAC8E,GAAZ,CAAiB,CAAEjC,UAAF,EAAczB,KAAd,KAClB,4BAAC,kBAAD,6BACMsD,wBAAwB,CAC5B7B,UAD4B,EAE5BzB,KAF4B,CAD9B;AAKC,QAAA,GAAG,EAAGyB,UAAU,CAACqB,EALlB;AAMC,QAAA,SAAS,EAAG,yBACX,oCADW,EAEX;AACC,yBACC9C,KAAK,KAAKlB;AAFZ,SAFW,CANb;AAaC,QAAA,OAAO,EAAG,MACT,KAAKV,aAAL,CAAoBqD,UAApB;AAdF,UAiBGA,UAAU,CAACkC,KAjBd,CADC,CAPH,CADD,CADD;AAiCA;;AACD,WAAO,IAAP;AACA;;AAxhB+B;AA2hBjC;AACA;AACA;;;eACe,sBACdC,wBADc,EAEdC,8BAFc,EAGdC,uBAHc,EAId,sBAAY,CAAEC,MAAF,EAAUjG,KAAV,KAAqB;AAChC;AACA;AACA,MAAKL,UAAU,CAAEK,KAAK,CAACoC,kCAAR,CAAf,EAA8D;AAC7D;AACA;;AACD,QAAM;AAAE8D,IAAAA;AAAF,MAAkBD,MAAM,CAAEE,YAAF,CAA9B;AACA,SAAO;AACN/D,IAAAA,kCAAkC,EACjC8D,WAAW,GAAG9D;AAFT,GAAP;AAIA,CAXD,CAJc,EAgBZvC,QAhBY,C","sourcesContent":["/**\n * External dependencies\n */\nimport { debounce } from 'lodash';\nimport classnames from 'classnames';\nimport scrollIntoView from 'dom-scroll-into-view';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf, _n } from '@wordpress/i18n';\nimport { Component, createRef } from '@wordpress/element';\nimport { UP, DOWN, ENTER, TAB } from '@wordpress/keycodes';\nimport {\n\tBaseControl,\n\tButton,\n\tSpinner,\n\twithSpokenMessages,\n\tPopover,\n} from '@wordpress/components';\nimport { withInstanceId, withSafeTimeout, compose } from '@wordpress/compose';\nimport { withSelect } from '@wordpress/data';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Whether the argument is a function.\n *\n * @param {*} maybeFunc The argument to check.\n * @return {boolean} True if the argument is a function, false otherwise.\n */\nfunction isFunction( maybeFunc ) {\n\treturn typeof maybeFunc === 'function';\n}\n\nclass URLInput extends Component {\n\tconstructor( props ) {\n\t\tsuper( props );\n\n\t\tthis.onChange = this.onChange.bind( this );\n\t\tthis.onFocus = this.onFocus.bind( this );\n\t\tthis.onKeyDown = this.onKeyDown.bind( this );\n\t\tthis.selectLink = this.selectLink.bind( this );\n\t\tthis.handleOnClick = this.handleOnClick.bind( this );\n\t\tthis.bindSuggestionNode = this.bindSuggestionNode.bind( this );\n\t\tthis.autocompleteRef = props.autocompleteRef || createRef();\n\t\tthis.inputRef = createRef();\n\t\tthis.updateSuggestions = debounce(\n\t\t\tthis.updateSuggestions.bind( this ),\n\t\t\t200\n\t\t);\n\n\t\tthis.suggestionNodes = [];\n\n\t\tthis.isUpdatingSuggestions = false;\n\n\t\tthis.state = {\n\t\t\tsuggestions: [],\n\t\t\tshowSuggestions: false,\n\t\t\tselectedSuggestion: null,\n\n\t\t\tsuggestionsListboxId: '',\n\t\t\tsuggestionOptionIdPrefix: '',\n\t\t};\n\t}\n\n\tcomponentDidUpdate( prevProps ) {\n\t\tconst { showSuggestions, selectedSuggestion } = this.state;\n\t\tconst { value, __experimentalShowInitialSuggestions = false } =\n\t\t\tthis.props;\n\n\t\t// Only have to worry about scrolling selected suggestion into view\n\t\t// when already expanded.\n\t\tif (\n\t\t\tshowSuggestions &&\n\t\t\tselectedSuggestion !== null &&\n\t\t\tthis.suggestionNodes[ selectedSuggestion ] &&\n\t\t\t! this.scrollingIntoView\n\t\t) {\n\t\t\tthis.scrollingIntoView = true;\n\t\t\tscrollIntoView(\n\t\t\t\tthis.suggestionNodes[ selectedSuggestion ],\n\t\t\t\tthis.autocompleteRef.current,\n\t\t\t\t{\n\t\t\t\t\tonlyScrollIfNeeded: true,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tthis.props.setTimeout( () => {\n\t\t\t\tthis.scrollingIntoView = false;\n\t\t\t}, 100 );\n\t\t}\n\n\t\t// Update suggestions when the value changes.\n\t\tif (\n\t\t\tprevProps.value !== value &&\n\t\t\t! this.props.disableSuggestions &&\n\t\t\t! this.isUpdatingSuggestions\n\t\t) {\n\t\t\tif ( value?.length ) {\n\t\t\t\t// If the new value is not empty we need to update with suggestions for it.\n\t\t\t\tthis.updateSuggestions( value );\n\t\t\t} else if ( __experimentalShowInitialSuggestions ) {\n\t\t\t\t// If the new value is empty and we can show initial suggestions, then show initial suggestions.\n\t\t\t\tthis.updateSuggestions();\n\t\t\t}\n\t\t}\n\t}\n\n\tcomponentDidMount() {\n\t\tif ( this.shouldShowInitialSuggestions() ) {\n\t\t\tthis.updateSuggestions();\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\tthis.suggestionsRequest?.cancel?.();\n\t\tdelete this.suggestionsRequest;\n\t}\n\n\tbindSuggestionNode( index ) {\n\t\treturn ( ref ) => {\n\t\t\tthis.suggestionNodes[ index ] = ref;\n\t\t};\n\t}\n\n\tshouldShowInitialSuggestions() {\n\t\tconst { suggestions } = this.state;\n\t\tconst { __experimentalShowInitialSuggestions = false, value } =\n\t\t\tthis.props;\n\t\treturn (\n\t\t\t! this.isUpdatingSuggestions &&\n\t\t\t__experimentalShowInitialSuggestions &&\n\t\t\t! ( value && value.length ) &&\n\t\t\t! ( suggestions && suggestions.length )\n\t\t);\n\t}\n\n\tupdateSuggestions( value = '' ) {\n\t\tconst {\n\t\t\t__experimentalFetchLinkSuggestions: fetchLinkSuggestions,\n\t\t\t__experimentalHandleURLSuggestions: handleURLSuggestions,\n\t\t} = this.props;\n\n\t\tif ( ! fetchLinkSuggestions ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Initial suggestions may only show if there is no value\n\t\t// (note: this includes whitespace).\n\t\tconst isInitialSuggestions = ! value?.length;\n\n\t\t// Trim only now we've determined whether or not it originally had a \"length\"\n\t\t// (even if that value was all whitespace).\n\t\tvalue = value.trim();\n\n\t\t// Allow a suggestions request if:\n\t\t// - there are at least 2 characters in the search input (except manual searches where\n\t\t// search input length is not required to trigger a fetch)\n\t\t// - this is a direct entry (eg: a URL)\n\t\tif (\n\t\t\t! isInitialSuggestions &&\n\t\t\t( value.length < 2 || ( ! handleURLSuggestions && isURL( value ) ) )\n\t\t) {\n\t\t\tthis.setState( {\n\t\t\t\tshowSuggestions: false,\n\t\t\t\tselectedSuggestion: null,\n\t\t\t\tloading: false,\n\t\t\t} );\n\n\t\t\treturn;\n\t\t}\n\n\t\tthis.isUpdatingSuggestions = true;\n\n\t\tthis.setState( {\n\t\t\tselectedSuggestion: null,\n\t\t\tloading: true,\n\t\t} );\n\n\t\tconst request = fetchLinkSuggestions( value, {\n\t\t\tisInitialSuggestions,\n\t\t} );\n\n\t\trequest\n\t\t\t.then( ( suggestions ) => {\n\t\t\t\t// A fetch Promise doesn't have an abort option. It's mimicked by\n\t\t\t\t// comparing the request reference in on the instance, which is\n\t\t\t\t// reset or deleted on subsequent requests or unmounting.\n\t\t\t\tif ( this.suggestionsRequest !== request ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.setState( {\n\t\t\t\t\tsuggestions,\n\t\t\t\t\tloading: false,\n\t\t\t\t\tshowSuggestions: !! suggestions.length,\n\t\t\t\t} );\n\n\t\t\t\tif ( !! suggestions.length ) {\n\t\t\t\t\tthis.props.debouncedSpeak(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %s: number of results. */\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'%d result found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\t'%d results found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\tsuggestions.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tsuggestions.length\n\t\t\t\t\t\t),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthis.props.debouncedSpeak(\n\t\t\t\t\t\t__( 'No results.' ),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthis.isUpdatingSuggestions = false;\n\t\t\t} )\n\t\t\t.catch( () => {\n\t\t\t\tif ( this.suggestionsRequest === request ) {\n\t\t\t\t\tthis.setState( {\n\t\t\t\t\t\tloading: false,\n\t\t\t\t\t} );\n\t\t\t\t\tthis.isUpdatingSuggestions = false;\n\t\t\t\t}\n\t\t\t} );\n\n\t\t// Note that this assignment is handled *before* the async search request\n\t\t// as a Promise always resolves on the next tick of the event loop.\n\t\tthis.suggestionsRequest = request;\n\t}\n\n\tonChange( event ) {\n\t\tconst inputValue = event.target.value;\n\n\t\tthis.props.onChange( inputValue );\n\t\tif ( ! this.props.disableSuggestions ) {\n\t\t\tthis.updateSuggestions( inputValue );\n\t\t}\n\t}\n\n\tonFocus() {\n\t\tconst { suggestions } = this.state;\n\t\tconst { disableSuggestions, value } = this.props;\n\n\t\t// When opening the link editor, if there's a value present, we want to load the suggestions pane with the results for this input search value\n\t\t// Don't re-run the suggestions on focus if there are already suggestions present (prevents searching again when tabbing between the input and buttons)\n\t\tif (\n\t\t\tvalue &&\n\t\t\t! disableSuggestions &&\n\t\t\t! this.isUpdatingSuggestions &&\n\t\t\t! ( suggestions && suggestions.length )\n\t\t) {\n\t\t\t// Ensure the suggestions are updated with the current input value.\n\t\t\tthis.updateSuggestions( value );\n\t\t}\n\t}\n\n\tonKeyDown( event ) {\n\t\tconst { showSuggestions, selectedSuggestion, suggestions, loading } =\n\t\t\tthis.state;\n\n\t\t// If the suggestions are not shown or loading, we shouldn't handle the arrow keys\n\t\t// We shouldn't preventDefault to allow block arrow keys navigation.\n\t\tif ( ! showSuggestions || ! suggestions.length || loading ) {\n\t\t\t// In the Windows version of Firefox the up and down arrows don't move the caret\n\t\t\t// within an input field like they do for Mac Firefox/Chrome/Safari. This causes\n\t\t\t// a form of focus trapping that is disruptive to the user experience. This disruption\n\t\t\t// only happens if the caret is not in the first or last position in the text input.\n\t\t\t// See: https://github.com/WordPress/gutenberg/issues/5693#issuecomment-436684747\n\t\t\tswitch ( event.keyCode ) {\n\t\t\t\t// When UP is pressed, if the caret is at the start of the text, move it to the 0\n\t\t\t\t// position.\n\t\t\t\tcase UP: {\n\t\t\t\t\tif ( 0 !== event.target.selectionStart ) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\t// Set the input caret to position 0.\n\t\t\t\t\t\tevent.target.setSelectionRange( 0, 0 );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t// When DOWN is pressed, if the caret is not at the end of the text, move it to the\n\t\t\t\t// last position.\n\t\t\t\tcase DOWN: {\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.props.value.length !== event.target.selectionStart\n\t\t\t\t\t) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\t// Set the input caret to the last position.\n\t\t\t\t\t\tevent.target.setSelectionRange(\n\t\t\t\t\t\t\tthis.props.value.length,\n\t\t\t\t\t\t\tthis.props.value.length\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t// Submitting while loading should trigger onSubmit.\n\t\t\t\tcase ENTER: {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tif ( this.props.onSubmit ) {\n\t\t\t\t\t\tthis.props.onSubmit( null, event );\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst suggestion =\n\t\t\tthis.state.suggestions[ this.state.selectedSuggestion ];\n\n\t\tswitch ( event.keyCode ) {\n\t\t\tcase UP: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst previousIndex = ! selectedSuggestion\n\t\t\t\t\t? suggestions.length - 1\n\t\t\t\t\t: selectedSuggestion - 1;\n\t\t\t\tthis.setState( {\n\t\t\t\t\tselectedSuggestion: previousIndex,\n\t\t\t\t} );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase DOWN: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst nextIndex =\n\t\t\t\t\tselectedSuggestion === null ||\n\t\t\t\t\tselectedSuggestion === suggestions.length - 1\n\t\t\t\t\t\t? 0\n\t\t\t\t\t\t: selectedSuggestion + 1;\n\t\t\t\tthis.setState( {\n\t\t\t\t\tselectedSuggestion: nextIndex,\n\t\t\t\t} );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase TAB: {\n\t\t\t\tif ( this.state.selectedSuggestion !== null ) {\n\t\t\t\t\tthis.selectLink( suggestion );\n\t\t\t\t\t// Announce a link has been selected when tabbing away from the input field.\n\t\t\t\t\tthis.props.speak( __( 'Link selected.' ) );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ENTER: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( this.state.selectedSuggestion !== null ) {\n\t\t\t\t\tthis.selectLink( suggestion );\n\n\t\t\t\t\tif ( this.props.onSubmit ) {\n\t\t\t\t\t\tthis.props.onSubmit( suggestion, event );\n\t\t\t\t\t}\n\t\t\t\t} else if ( this.props.onSubmit ) {\n\t\t\t\t\tthis.props.onSubmit( null, event );\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tselectLink( suggestion ) {\n\t\tthis.props.onChange( suggestion.url, suggestion );\n\t\tthis.setState( {\n\t\t\tselectedSuggestion: null,\n\t\t\tshowSuggestions: false,\n\t\t} );\n\t}\n\n\thandleOnClick( suggestion ) {\n\t\tthis.selectLink( suggestion );\n\t\t// Move focus to the input field when a link suggestion is clicked.\n\t\tthis.inputRef.current.focus();\n\t}\n\n\tstatic getDerivedStateFromProps(\n\t\t{\n\t\t\tvalue,\n\t\t\tinstanceId,\n\t\t\tdisableSuggestions,\n\t\t\t__experimentalShowInitialSuggestions = false,\n\t\t},\n\t\t{ showSuggestions }\n\t) {\n\t\tlet shouldShowSuggestions = showSuggestions;\n\n\t\tconst hasValue = value && value.length;\n\n\t\tif ( ! __experimentalShowInitialSuggestions && ! hasValue ) {\n\t\t\tshouldShowSuggestions = false;\n\t\t}\n\n\t\tif ( disableSuggestions === true ) {\n\t\t\tshouldShowSuggestions = false;\n\t\t}\n\n\t\treturn {\n\t\t\tshowSuggestions: shouldShowSuggestions,\n\t\t\tsuggestionsListboxId: `block-editor-url-input-suggestions-${ instanceId }`,\n\t\t\tsuggestionOptionIdPrefix: `block-editor-url-input-suggestion-${ instanceId }`,\n\t\t};\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ this.renderControl() }\n\t\t\t\t{ this.renderSuggestions() }\n\t\t\t</>\n\t\t);\n\t}\n\n\trenderControl() {\n\t\tconst {\n\t\t\tlabel = null,\n\t\t\tclassName,\n\t\t\tisFullWidth,\n\t\t\tinstanceId,\n\t\t\tplaceholder = __( 'Paste URL or type to search' ),\n\t\t\t__experimentalRenderControl: renderControl,\n\t\t\tvalue = '',\n\t\t} = this.props;\n\n\t\tconst {\n\t\t\tloading,\n\t\t\tshowSuggestions,\n\t\t\tselectedSuggestion,\n\t\t\tsuggestionsListboxId,\n\t\t\tsuggestionOptionIdPrefix,\n\t\t} = this.state;\n\n\t\tconst inputId = `url-input-control-${ instanceId }`;\n\n\t\tconst controlProps = {\n\t\t\tid: inputId, // Passes attribute to label for the for attribute\n\t\t\tlabel,\n\t\t\tclassName: classnames( 'block-editor-url-input', className, {\n\t\t\t\t'is-full-width': isFullWidth,\n\t\t\t} ),\n\t\t};\n\n\t\tconst inputProps = {\n\t\t\tid: inputId,\n\t\t\tvalue,\n\t\t\trequired: true,\n\t\t\tclassName: 'block-editor-url-input__input',\n\t\t\ttype: 'text',\n\t\t\tonChange: this.onChange,\n\t\t\tonFocus: this.onFocus,\n\t\t\tplaceholder,\n\t\t\tonKeyDown: this.onKeyDown,\n\t\t\trole: 'combobox',\n\t\t\t'aria-label': label ? undefined : __( 'URL' ), // Ensure input always has an accessible label\n\t\t\t'aria-expanded': showSuggestions,\n\t\t\t'aria-autocomplete': 'list',\n\t\t\t'aria-owns': suggestionsListboxId,\n\t\t\t'aria-activedescendant':\n\t\t\t\tselectedSuggestion !== null\n\t\t\t\t\t? `${ suggestionOptionIdPrefix }-${ selectedSuggestion }`\n\t\t\t\t\t: undefined,\n\t\t\tref: this.inputRef,\n\t\t};\n\n\t\tif ( renderControl ) {\n\t\t\treturn renderControl( controlProps, inputProps, loading );\n\t\t}\n\n\t\treturn (\n\t\t\t<BaseControl { ...controlProps }>\n\t\t\t\t<input { ...inputProps } />\n\t\t\t\t{ loading && <Spinner /> }\n\t\t\t</BaseControl>\n\t\t);\n\t}\n\n\trenderSuggestions() {\n\t\tconst {\n\t\t\tclassName,\n\t\t\t__experimentalRenderSuggestions: renderSuggestions,\n\t\t\tvalue = '',\n\t\t\t__experimentalShowInitialSuggestions = false,\n\t\t} = this.props;\n\n\t\tconst {\n\t\t\tshowSuggestions,\n\t\t\tsuggestions,\n\t\t\tselectedSuggestion,\n\t\t\tsuggestionsListboxId,\n\t\t\tsuggestionOptionIdPrefix,\n\t\t\tloading,\n\t\t} = this.state;\n\n\t\tconst suggestionsListProps = {\n\t\t\tid: suggestionsListboxId,\n\t\t\tref: this.autocompleteRef,\n\t\t\trole: 'listbox',\n\t\t};\n\n\t\tconst buildSuggestionItemProps = ( suggestion, index ) => {\n\t\t\treturn {\n\t\t\t\trole: 'option',\n\t\t\t\ttabIndex: '-1',\n\t\t\t\tid: `${ suggestionOptionIdPrefix }-${ index }`,\n\t\t\t\tref: this.bindSuggestionNode( index ),\n\t\t\t\t'aria-selected': index === selectedSuggestion,\n\t\t\t};\n\t\t};\n\n\t\tif (\n\t\t\tisFunction( renderSuggestions ) &&\n\t\t\tshowSuggestions &&\n\t\t\t!! suggestions.length\n\t\t) {\n\t\t\treturn renderSuggestions( {\n\t\t\t\tsuggestions,\n\t\t\t\tselectedSuggestion,\n\t\t\t\tsuggestionsListProps,\n\t\t\t\tbuildSuggestionItemProps,\n\t\t\t\tisLoading: loading,\n\t\t\t\thandleSuggestionClick: this.handleOnClick,\n\t\t\t\tisInitialSuggestions:\n\t\t\t\t\t__experimentalShowInitialSuggestions &&\n\t\t\t\t\t! ( value && value.length ),\n\t\t\t} );\n\t\t}\n\n\t\tif (\n\t\t\t! isFunction( renderSuggestions ) &&\n\t\t\tshowSuggestions &&\n\t\t\t!! suggestions.length\n\t\t) {\n\t\t\treturn (\n\t\t\t\t<Popover position=\"bottom\" focusOnMount={ false }>\n\t\t\t\t\t<div\n\t\t\t\t\t\t{ ...suggestionsListProps }\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-url-input__suggestions',\n\t\t\t\t\t\t\t`${ className }__suggestions`\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ suggestions.map( ( suggestion, index ) => (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t{ ...buildSuggestionItemProps(\n\t\t\t\t\t\t\t\t\tsuggestion,\n\t\t\t\t\t\t\t\t\tindex\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tkey={ suggestion.id }\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t'block-editor-url-input__suggestion',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t'is-selected':\n\t\t\t\t\t\t\t\t\t\t\tindex === selectedSuggestion,\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\tonClick={ () =>\n\t\t\t\t\t\t\t\t\tthis.handleOnClick( suggestion )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ suggestion.title }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</div>\n\t\t\t\t</Popover>\n\t\t\t);\n\t\t}\n\t\treturn null;\n\t}\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-input/README.md\n */\nexport default compose(\n\twithSafeTimeout,\n\twithSpokenMessages,\n\twithInstanceId,\n\twithSelect( ( select, props ) => {\n\t\t// If a link suggestions handler is already provided then\n\t\t// bail.\n\t\tif ( isFunction( props.__experimentalFetchLinkSuggestions ) ) {\n\t\t\treturn;\n\t\t}\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\t__experimentalFetchLinkSuggestions:\n\t\t\t\tgetSettings().__experimentalFetchLinkSuggestions,\n\t\t};\n\t} )\n)( URLInput );\n"]}
@@ -47,7 +47,8 @@ function URLPopover(_ref) {
47
47
  return (0, _element.createElement)(_components.Popover, (0, _extends2.default)({
48
48
  className: "block-editor-url-popover",
49
49
  focusOnMount: focusOnMount,
50
- position: position
50
+ position: position,
51
+ __unstableShift: true
51
52
  }, popoverProps), (0, _element.createElement)("div", {
52
53
  className: "block-editor-url-popover__input-container"
53
54
  }, (0, _element.createElement)("div", {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/url-popover/index.js"],"names":["URLPopover","additionalControls","children","renderSettings","position","focusOnMount","popoverProps","isSettingsExpanded","setIsSettingsExpanded","showSettings","toggleSettingsVisibility","chevronDown","LinkEditor","LinkViewer"],"mappings":";;;;;;;;;AAIA;;;;AADA;;AAEA;;AACA;;AAKA;;AACA;;AAZA;AACA;AACA;;AAMA;AACA;AACA;AAIA,SAASA,UAAT,OAOI;AAAA,MAPiB;AACpBC,IAAAA,kBADoB;AAEpBC,IAAAA,QAFoB;AAGpBC,IAAAA,cAHoB;AAIpBC,IAAAA,QAAQ,GAAG,eAJS;AAKpBC,IAAAA,YAAY,GAAG,cALK;AAMpB,OAAGC;AANiB,GAOjB;AACH,QAAM,CAAEC,kBAAF,EAAsBC,qBAAtB,IAAgD,uBAAU,KAAV,CAAtD;AAEA,QAAMC,YAAY,GAAG,CAAC,CAAEN,cAAH,IAAqBI,kBAA1C;;AAEA,QAAMG,wBAAwB,GAAG,MAAM;AACtCF,IAAAA,qBAAqB,CAAE,CAAED,kBAAJ,CAArB;AACA,GAFD;;AAIA,SACC,4BAAC,mBAAD;AACC,IAAA,SAAS,EAAC,0BADX;AAEC,IAAA,YAAY,EAAGF,YAFhB;AAGC,IAAA,QAAQ,EAAGD;AAHZ,KAIME,YAJN,GAMC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGJ,QADH,EAEG,CAAC,CAAEC,cAAH,IACD,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,2CADX;AAEC,IAAA,IAAI,EAAGQ,kBAFR;AAGC,IAAA,KAAK,EAAG,cAAI,eAAJ,CAHT;AAIC,IAAA,OAAO,EAAGD,wBAJX;AAKC,qBAAgBH;AALjB,IAHF,CADD,EAaGE,YAAY,IACb;AAAK,IAAA,SAAS,EAAC;AAAf,KACGN,cAAc,EADjB,CAdF,CAND,EAyBGF,kBAAkB,IAAI,CAAEQ,YAAxB,IACD;AAAK,IAAA,SAAS,EAAC;AAAf,KACGR,kBADH,CA1BF,CADD;AAiCA;;AAEDD,UAAU,CAACY,UAAX,GAAwBA,mBAAxB;AAEAZ,UAAU,CAACa,UAAX,GAAwBA,mBAAxB;AAEA;AACA;AACA;;eACeb,U","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { Button, Popover } from '@wordpress/components';\nimport { chevronDown } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport LinkViewer from './link-viewer';\nimport LinkEditor from './link-editor';\n\nfunction URLPopover( {\n\tadditionalControls,\n\tchildren,\n\trenderSettings,\n\tposition = 'bottom center',\n\tfocusOnMount = 'firstElement',\n\t...popoverProps\n} ) {\n\tconst [ isSettingsExpanded, setIsSettingsExpanded ] = useState( false );\n\n\tconst showSettings = !! renderSettings && isSettingsExpanded;\n\n\tconst toggleSettingsVisibility = () => {\n\t\tsetIsSettingsExpanded( ! isSettingsExpanded );\n\t};\n\n\treturn (\n\t\t<Popover\n\t\t\tclassName=\"block-editor-url-popover\"\n\t\t\tfocusOnMount={ focusOnMount }\n\t\t\tposition={ position }\n\t\t\t{ ...popoverProps }\n\t\t>\n\t\t\t<div className=\"block-editor-url-popover__input-container\">\n\t\t\t\t<div className=\"block-editor-url-popover__row\">\n\t\t\t\t\t{ children }\n\t\t\t\t\t{ !! renderSettings && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName=\"block-editor-url-popover__settings-toggle\"\n\t\t\t\t\t\t\ticon={ chevronDown }\n\t\t\t\t\t\t\tlabel={ __( 'Link settings' ) }\n\t\t\t\t\t\t\tonClick={ toggleSettingsVisibility }\n\t\t\t\t\t\t\taria-expanded={ isSettingsExpanded }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t{ showSettings && (\n\t\t\t\t\t<div className=\"block-editor-url-popover__row block-editor-url-popover__settings\">\n\t\t\t\t\t\t{ renderSettings() }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t{ additionalControls && ! showSettings && (\n\t\t\t\t<div className=\"block-editor-url-popover__additional-controls\">\n\t\t\t\t\t{ additionalControls }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</Popover>\n\t);\n}\n\nURLPopover.LinkEditor = LinkEditor;\n\nURLPopover.LinkViewer = LinkViewer;\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-popover/README.md\n */\nexport default URLPopover;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/url-popover/index.js"],"names":["URLPopover","additionalControls","children","renderSettings","position","focusOnMount","popoverProps","isSetting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UAAU,CAACY,UAAX,GAAwBA,mBAAxB;AAEAZ,UAAU,CAACa,UAAX,GAAwBA,mBAAxB;AAEA;AACA;AACA;;eACeb,U","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { Button, Popover } from '@wordpress/components';\nimport { chevronDown } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport LinkViewer from './link-viewer';\nimport LinkEditor from './link-editor';\n\nfunction URLPopover( {\n\tadditionalControls,\n\tchildren,\n\trenderSettings,\n\tposition = 'bottom center',\n\tfocusOnMount = 'firstElement',\n\t...popoverProps\n} ) {\n\tconst [ isSettingsExpanded, setIsSettingsExpanded ] = useState( false );\n\n\tconst showSettings = !! renderSettings && isSettingsExpanded;\n\n\tconst toggleSettingsVisibility = () => {\n\t\tsetIsSettingsExpanded( ! isSettingsExpanded );\n\t};\n\n\treturn (\n\t\t<Popover\n\t\t\tclassName=\"block-editor-url-popover\"\n\t\t\tfocusOnMount={ focusOnMount }\n\t\t\tposition={ position }\n\t\t\t__unstableShift\n\t\t\t{ ...popoverProps }\n\t\t>\n\t\t\t<div className=\"block-editor-url-popover__input-container\">\n\t\t\t\t<div className=\"block-editor-url-popover__row\">\n\t\t\t\t\t{ children }\n\t\t\t\t\t{ !! renderSettings && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName=\"block-editor-url-popover__settings-toggle\"\n\t\t\t\t\t\t\ticon={ chevronDown }\n\t\t\t\t\t\t\tlabel={ __( 'Link settings' ) }\n\t\t\t\t\t\t\tonClick={ toggleSettingsVisibility }\n\t\t\t\t\t\t\taria-expanded={ isSettingsExpanded }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t{ showSettings && (\n\t\t\t\t\t<div className=\"block-editor-url-popover__row block-editor-url-popover__settings\">\n\t\t\t\t\t\t{ renderSettings() }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t{ additionalControls && ! showSettings && (\n\t\t\t\t<div className=\"block-editor-url-popover__additional-controls\">\n\t\t\t\t\t{ additionalControls }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</Popover>\n\t);\n}\n\nURLPopover.LinkEditor = LinkEditor;\n\nURLPopover.LinkViewer = LinkViewer;\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-popover/README.md\n */\nexport default URLPopover;\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/use-block-display-information/index.js"],"names":["useBlockDisplayInformation","clientId","select","getBlockName","getBlockAttributes","blockEditorStore","getBlockType","getActiveBlockVariation","blocksStore","blockName","blockType","attributes","match","blockTypeInfo","title","icon","description","anchor"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEe,SAASA,0BAAT,CAAqCC,QAArC,EAAgD;AAC9D,SAAO,qBACJC,MAAF,IAAc;AACb,QAAK,CAAED,QAAP,EAAkB,OAAO,IAAP;AAClB,UAAM;AAAEE,MAAAA,YAAF;AAAgBC,MAAAA;AAAhB,QAAuCF,MAAM,CAClDG,YADkD,CAAnD;AAGA,UAAM;AAAEC,MAAAA,YAAF;AAAgBC,MAAAA;AAAhB,QAA4CL,MAAM,CACvDM,aADuD,CAAxD;AAGA,UAAMC,SAAS,GAAGN,YAAY,CAAEF,QAAF,CAA9B;AACA,UAAMS,SAAS,GAAGJ,YAAY,CAAEG,SAAF,CAA9B;AACA,QAAK,CAAEC,SAAP,EAAmB,OAAO,IAAP;AACnB,UAAMC,UAAU,GAAGP,kBAAkB,CAAEH,QAAF,CAArC;AACA,UAAMW,KAAK,GAAGL,uBAAuB,CAAEE,SAAF,EAAaE,UAAb,CAArC;AACA,UAAME,aAAa,GAAG;AACrBC,MAAAA,KAAK,EAAEJ,SAAS,CAACI,KADI;AAErBC,MAAAA,IAAI,EAAEL,SAAS,CAACK,IAFK;AAGrBC,MAAAA,WAAW,EAAEN,SAAS,CAACM,WAHF;AAIrBC,MAAAA,MAAM,EAAEN,UAAF,aAAEA,UAAF,uBAAEA,UAAU,CAAEM;AAJC,KAAtB;AAMA,QAAK,CAAEL,KAAP,EAAe,OAAOC,aAAP;AAEf,WAAO;AACNC,MAAAA,KAAK,EAAEF,KAAK,CAACE,KAAN,IAAeJ,SAAS,CAACI,KAD1B;AAENC,MAAAA,IAAI,EAAEH,KAAK,CAACG,IAAN,IAAcL,SAAS,CAACK,IAFxB;AAGNC,MAAAA,WAAW,EAAEJ,KAAK,CAACI,WAAN,IAAqBN,SAAS,CAACM,WAHtC;AAINC,MAAAA,MAAM,EAAEN,UAAF,aAAEA,UAAF,uBAAEA,UAAU,CAAEM;AAJd,KAAP;AAMA,GA5BK,EA6BN,CAAEhB,QAAF,CA7BM,CAAP;AA+BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('@wordpress/blocks').WPIcon} WPIcon */\n\n/**\n * Contains basic block's information for display reasons.\n *\n * @typedef {Object} WPBlockDisplayInformation\n *\n * @property {string} title Human-readable block type label.\n * @property {WPIcon} icon Block type icon.\n * @property {string} description A detailed block type description.\n * @property {string} anchor HTML anchor.\n */\n\n/**\n * Hook used to try to find a matching block variation and return\n * the appropriate information for display reasons. In order to\n * to try to find a match we need to things:\n * 1. Block's client id to extract it's current attributes.\n * 2. A block variation should have set `isActive` prop to a proper function.\n *\n * If for any reason a block variaton match cannot be found,\n * the returned information come from the Block Type.\n * If no blockType is found with the provided clientId, returns null.\n *\n * @param {string} clientId Block's client id.\n * @return {?WPBlockDisplayInformation} Block's display information, or `null` when the block or its type not found.\n */\n\nexport default function useBlockDisplayInformation( clientId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) return null;\n\t\t\tconst { getBlockName, getBlockAttributes } = select(\n\t\t\t\tblockEditorStore\n\t\t\t);\n\t\t\tconst { getBlockType, getActiveBlockVariation } = select(\n\t\t\t\tblocksStore\n\t\t\t);\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( blockName );\n\t\t\tif ( ! blockType ) return null;\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\t\t\tconst match = getActiveBlockVariation( blockName, attributes );\n\t\t\tconst blockTypeInfo = {\n\t\t\t\ttitle: blockType.title,\n\t\t\t\ticon: blockType.icon,\n\t\t\t\tdescription: blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t};\n\t\t\tif ( ! match ) return blockTypeInfo;\n\n\t\t\treturn {\n\t\t\t\ttitle: match.title || blockType.title,\n\t\t\t\ticon: match.icon || blockType.icon,\n\t\t\t\tdescription: match.description || blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/use-block-display-information/index.js"],"names":["useBlockDisplayInformation","clientId","select","getBlockName","getBlockAttributes","blockEditorStore","getBlockType","getActiveBlockVariation","blocksStore","blockName","blockType","attributes","match","blockTypeInfo","title","icon","description","anchor"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEe,SAASA,0BAAT,CAAqCC,QAArC,EAAgD;AAC9D,SAAO,qBACJC,MAAF,IAAc;AACb,QAAK,CAAED,QAAP,EAAkB,OAAO,IAAP;AAClB,UAAM;AAAEE,MAAAA,YAAF;AAAgBC,MAAAA;AAAhB,QACLF,MAAM,CAAEG,YAAF,CADP;AAEA,UAAM;AAAEC,MAAAA,YAAF;AAAgBC,MAAAA;AAAhB,QACLL,MAAM,CAAEM,aAAF,CADP;AAEA,UAAMC,SAAS,GAAGN,YAAY,CAAEF,QAAF,CAA9B;AACA,UAAMS,SAAS,GAAGJ,YAAY,CAAEG,SAAF,CAA9B;AACA,QAAK,CAAEC,SAAP,EAAmB,OAAO,IAAP;AACnB,UAAMC,UAAU,GAAGP,kBAAkB,CAAEH,QAAF,CAArC;AACA,UAAMW,KAAK,GAAGL,uBAAuB,CAAEE,SAAF,EAAaE,UAAb,CAArC;AACA,UAAME,aAAa,GAAG;AACrBC,MAAAA,KAAK,EAAEJ,SAAS,CAACI,KADI;AAErBC,MAAAA,IAAI,EAAEL,SAAS,CAACK,IAFK;AAGrBC,MAAAA,WAAW,EAAEN,SAAS,CAACM,WAHF;AAIrBC,MAAAA,MAAM,EAAEN,UAAF,aAAEA,UAAF,uBAAEA,UAAU,CAAEM;AAJC,KAAtB;AAMA,QAAK,CAAEL,KAAP,EAAe,OAAOC,aAAP;AAEf,WAAO;AACNC,MAAAA,KAAK,EAAEF,KAAK,CAACE,KAAN,IAAeJ,SAAS,CAACI,KAD1B;AAENC,MAAAA,IAAI,EAAEH,KAAK,CAACG,IAAN,IAAcL,SAAS,CAACK,IAFxB;AAGNC,MAAAA,WAAW,EAAEJ,KAAK,CAACI,WAAN,IAAqBN,SAAS,CAACM,WAHtC;AAINC,MAAAA,MAAM,EAAEN,UAAF,aAAEA,UAAF,uBAAEA,UAAU,CAAEM;AAJd,KAAP;AAMA,GA1BK,EA2BN,CAAEhB,QAAF,CA3BM,CAAP;AA6BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('@wordpress/blocks').WPIcon} WPIcon */\n\n/**\n * Contains basic block's information for display reasons.\n *\n * @typedef {Object} WPBlockDisplayInformation\n *\n * @property {string} title Human-readable block type label.\n * @property {WPIcon} icon Block type icon.\n * @property {string} description A detailed block type description.\n * @property {string} anchor HTML anchor.\n */\n\n/**\n * Hook used to try to find a matching block variation and return\n * the appropriate information for display reasons. In order to\n * to try to find a match we need to things:\n * 1. Block's client id to extract it's current attributes.\n * 2. A block variation should have set `isActive` prop to a proper function.\n *\n * If for any reason a block variaton match cannot be found,\n * the returned information come from the Block Type.\n * If no blockType is found with the provided clientId, returns null.\n *\n * @param {string} clientId Block's client id.\n * @return {?WPBlockDisplayInformation} Block's display information, or `null` when the block or its type not found.\n */\n\nexport default function useBlockDisplayInformation( clientId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) return null;\n\t\t\tconst { getBlockName, getBlockAttributes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { getBlockType, getActiveBlockVariation } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( blockName );\n\t\t\tif ( ! blockType ) return null;\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\t\t\tconst match = getActiveBlockVariation( blockName, attributes );\n\t\t\tconst blockTypeInfo = {\n\t\t\t\ttitle: blockType.title,\n\t\t\t\ticon: blockType.icon,\n\t\t\t\tdescription: blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t};\n\t\t\tif ( ! match ) return blockTypeInfo;\n\n\t\t\treturn {\n\t\t\t\ttitle: match.title || blockType.title,\n\t\t\t\ticon: match.icon || blockType.icon,\n\t\t\t\tdescription: match.description || blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/use-block-drop-zone/index.js"],"names":["getNearestBlockIndex","elements","position","orientation","allowedEdges","isRightToLeft","candidateIndex","candidateDistance","forEach","element","index","rect","getBoundingClientRect","distance","edge","undefined","isTrailingEdge","offset","useBlockDropZone","rootClientId","targetRootClientId","targetBlockIndex","setTargetBlockIndex","isLockedAll","select","getTemplateLock","blockEditorStore","getBlockListSettings","showInsertionPoint","hideInsertionPoint","onBlockDrop","throttled","event","currentTarget","blockElements","Array","from","children","filter","classList","contains","targetIndex","x","clientX","y","clientY","isDisabled","onDrop","onDragOver","onDragLeave","cancel","onDragEnd"],"mappings":";;;;;;;;;;AAGA;;AACA;;AACA;;AAIA;;AAKA;;AACA;;AACA;;AAhBA;AACA;AACA;;AASA;AACA;AACA;;AAKA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,oBAAT,CAA+BC,QAA/B,EAAyCC,QAAzC,EAAmDC,WAAnD,EAAiE;AACvE,QAAMC,YAAY,GACjBD,WAAW,KAAK,YAAhB,GACG,CAAE,MAAF,EAAU,OAAV,CADH,GAEG,CAAE,KAAF,EAAS,QAAT,CAHJ;AAKA,QAAME,aAAa,GAAG,kBAAtB;AAEA,MAAIC,cAAJ;AACA,MAAIC,iBAAJ;AAEAN,EAAAA,QAAQ,CAACO,OAAT,CAAkB,CAAEC,OAAF,EAAWC,KAAX,KAAsB;AACvC,UAAMC,IAAI,GAAGF,OAAO,CAACG,qBAAR,EAAb;AACA,UAAM,CAAEC,QAAF,EAAYC,IAAZ,IAAqB,oCAC1BZ,QAD0B,EAE1BS,IAF0B,EAG1BP,YAH0B,CAA3B;;AAMA,QAAKG,iBAAiB,KAAKQ,SAAtB,IAAmCF,QAAQ,GAAGN,iBAAnD,EAAuE;AACtE;AACA;AACA;AACA;AACA,YAAMS,cAAc,GACnBF,IAAI,KAAK,QAAT,IACE,CAAET,aAAF,IAAmBS,IAAI,KAAK,OAD9B,IAEET,aAAa,IAAIS,IAAI,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X;AAAoBC,MAAAA,CAAC,EAAEZ,KAAK,CAACa;AAA7B,KAFuC,2BAGvClB,oBAAoB,CAAEP,kBAAF,CAHmB,0DAGvC,sBAA4CjB,WAHL,CAAxC;AAMAmB,IAAAA,mBAAmB,CAAEmB,WAAW,KAAK1B,SAAhB,GAA4B,CAA5B,GAAgC0B,WAAlC,CAAnB;;AAEA,QAAKA,WAAW,KAAK,IAArB,EAA4B;AAC3Bb,MAAAA,kBAAkB,CAAER,kBAAF,EAAsBqB,WAAtB,CAAlB;AACA;AACD,GAhBD,EAgBG,EAhBH,CADiB,EAkBjB,GAlBiB,CAAlB;AAqBA,SAAO,wCAAa;AACnBK,IAAAA,UAAU,EAAEvB,WADO;AAEnBwB,IAAAA,MAAM,EAAEjB,WAFW;;AAGnBkB,IAAAA,UAAU,CAAEhB,KAAF,EAAU;AACnB;AACA;AACA;AACAD,MAAAA,SAAS,CAAEC,KAAF,EAASA,KAAK,CAACC,aAAf,CAAT;AACA,KARkB;;AASnBgB,IAAAA,WAAW,GAAG;AACblB,MAAAA,SAAS,CAACmB,MAAV;AACArB,MAAAA,kBAAkB;AAClBP,MAAAA,mBAAmB,CAAE,IAAF,CAAnB;AACA,KAbkB;;AAcnB6B,IAAAA,SAAS,GAAG;AACXpB,MAAAA,SAAS,CAACmB,MAAV;AACArB,MAAAA,kBAAkB;AAClBP,MAAAA,mBAAmB,CAAE,IAAF,CAAnB;AACA;;AAlBkB,GAAb,CAAP;AAoBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useCallback, useState } from '@wordpress/element';\nimport {\n\tuseThrottle,\n\t__experimentalUseDropZone as useDropZone,\n} from '@wordpress/compose';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport useOnBlockDrop from '../use-on-block-drop';\nimport { getDistanceToNearestEdge } from '../../utils/math';\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('../../utils/math').WPPoint} WPPoint */\n\n/**\n * The orientation of a block list.\n *\n * @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation\n */\n\n/**\n * Given a list of block DOM elements finds the index that a block should be dropped\n * at.\n *\n * @param {Element[]} elements Array of DOM elements that represent each block in a block list.\n * @param {WPPoint} position The position of the item being dragged.\n * @param {WPBlockListOrientation} orientation The orientation of a block list.\n *\n * @return {number|undefined} The block index that's closest to the drag position.\n */\nexport function getNearestBlockIndex( elements, position, orientation ) {\n\tconst allowedEdges =\n\t\torientation === 'horizontal'\n\t\t\t? [ 'left', 'right' ]\n\t\t\t: [ 'top', 'bottom' ];\n\n\tconst isRightToLeft = isRTL();\n\n\tlet candidateIndex;\n\tlet candidateDistance;\n\n\telements.forEach( ( element, index ) => {\n\t\tconst rect = element.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge(\n\t\t\tposition,\n\t\t\trect,\n\t\t\tallowedEdges\n\t\t);\n\n\t\tif ( candidateDistance === undefined || distance < candidateDistance ) {\n\t\t\t// If the user is dropping to the trailing edge of the block\n\t\t\t// add 1 to the index to represent dragging after.\n\t\t\t// Take RTL languages into account where the left edge is\n\t\t\t// the trailing edge.\n\t\t\tconst isTrailingEdge =\n\t\t\t\tedge === 'bottom' ||\n\t\t\t\t( ! isRightToLeft && edge === 'right' ) ||\n\t\t\t\t( isRightToLeft && edge === 'left' );\n\t\t\tconst offset = isTrailingEdge ? 1 : 0;\n\n\t\t\t// Update the currently known best candidate.\n\t\t\tcandidateDistance = distance;\n\t\t\tcandidateIndex = index + offset;\n\t\t}\n\t} );\n\n\treturn candidateIndex;\n}\n\n/**\n * @typedef {Object} WPBlockDropZoneConfig\n * @property {string} rootClientId The root client id for the block list.\n */\n\n/**\n * A React hook that can be used to make a block list handle drag and drop.\n *\n * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.\n */\nexport default function useBlockDropZone( {\n\t// An undefined value represents a top-level block. Default to an empty\n\t// string for this so that `targetRootClientId` can be easily compared to\n\t// values returned by the `getRootBlockClientId` selector, which also uses\n\t// an empty string to represent top-level blocks.\n\trootClientId: targetRootClientId = '',\n} = {} ) {\n\tconst [ targetBlockIndex, setTargetBlockIndex ] = useState( null );\n\n\tconst isLockedAll = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getTemplateLock } = select( blockEditorStore );\n\t\t\treturn getTemplateLock( targetRootClientId ) === 'all';\n\t\t},\n\t\t[ targetRootClientId ]\n\t);\n\n\tconst { getBlockListSettings } = useSelect( blockEditorStore );\n\tconst { showInsertionPoint, hideInsertionPoint } = useDispatch(\n\t\tblockEditorStore\n\t);\n\n\tconst onBlockDrop = useOnBlockDrop( targetRootClientId, targetBlockIndex );\n\tconst throttled = useThrottle(\n\t\tuseCallback( ( event, currentTarget ) => {\n\t\t\tconst blockElements = Array.from( currentTarget.children ).filter(\n\t\t\t\t// Ensure the element is a block. It should have the `wp-block` class.\n\t\t\t\t( element ) => element.classList.contains( 'wp-block' )\n\t\t\t);\n\t\t\tconst targetIndex = getNearestBlockIndex(\n\t\t\t\tblockElements,\n\t\t\t\t{ x: event.clientX, y: event.clientY },\n\t\t\t\tgetBlockListSettings( targetRootClientId )?.orientation\n\t\t\t);\n\n\t\t\tsetTargetBlockIndex( targetIndex === undefined ? 0 : targetIndex );\n\n\t\t\tif ( targetIndex !== null ) {\n\t\t\t\tshowInsertionPoint( targetRootClientId, targetIndex );\n\t\t\t}\n\t\t}, [] ),\n\t\t200\n\t);\n\n\treturn useDropZone( {\n\t\tisDisabled: isLockedAll,\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\tonDragLeave() {\n\t\t\tthrottled.cancel();\n\t\t\thideInsertionPoint();\n\t\t\tsetTargetBlockIndex( null );\n\t\t},\n\t\tonDragEnd() {\n\t\t\tthrottled.cancel();\n\t\t\thideInsertionPoint();\n\t\t\tsetTargetBlockIndex( null );\n\t\t},\n\t} );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/use-block-drop-zone/index.js"],"names":["getNearestBlockIndex","elements","position","orientation","allowedEdges","isRightToLeft","candidateIndex","candidateDistance","forEach","element","index","rect","getBoundingClientRect","distance","edge","undefined","isTrailingEdge","offset","useBlockDropZone","rootClientId","targetRootClientId","targetBlockIndex","setTargetBlockIndex","isLockedAll","select","getTemplateLock","blockEditorStore","getBlockListSettings","showInsertionPoint","hideInsertionPoint","onBlockDrop","throttled","event","currentTarget","blockElements","Array","from","children","filter","classList","contains","targetIndex","x","clientX","y","clientY","isDisabled","onDrop","onDragOver","onDragLeave","cancel","onDragEnd"],"mappings":";;;;;;;;;;AAGA;;AACA;;AACA;;AAIA;;AAKA;;AACA;;AACA;;AAhBA;AACA;AACA;;AASA;AACA;AACA;;AAKA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,oBAAT,CAA+BC,QAA/B,EAAyCC,QAAzC,EAAmDC,WAAnD,EAAiE;AACvE,QAAMC,YAAY,GACjBD,WAAW,KAAK,YAAhB,GACG,CAAE,MAAF,EAAU,OAAV,CADH,GAEG,CAAE,KAAF,EAAS,QAAT,CAHJ;AAKA,QAAME,aAAa,GAAG,kBAAtB;AAEA,MAAIC,cAAJ;AACA,MAAIC,iBAAJ;AAEAN,EAAAA,QAAQ,CAACO,OAAT,CAAkB,CAAEC,OAAF,EAAWC,KAAX,KAAsB;AACvC,UAAMC,IAAI,GAAGF,OAAO,CAACG,qBAAR,EAAb;AACA,UAAM,CAAEC,QAAF,EAAYC,IAAZ,IAAqB,oCAC1BZ,QAD0B,EAE1BS,IAF0B,EAG1BP,YAH0B,CAA3B;;AAMA,QAAKG,iBAAiB,KAAKQ,SAAtB,IAAmCF,QAAQ,G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AAR,CAAkBC,QAAlB,CAA4B,UAA5B,CAFM,CAAtB;AAIA,UAAMC,WAAW,GAAGzC,oBAAoB,CACvCkC,aADuC,EAEvC;AAAEQ,MAAAA,CAAC,EAAEV,KAAK,CAACW,OAAX;AAAoBC,MAAAA,CAAC,EAAEZ,KAAK,CAACa;AAA7B,KAFuC,2BAGvClB,oBAAoB,CAAEP,kBAAF,CAHmB,0DAGvC,sBAA4CjB,WAHL,CAAxC;AAMAmB,IAAAA,mBAAmB,CAAEmB,WAAW,KAAK1B,SAAhB,GAA4B,CAA5B,GAAgC0B,WAAlC,CAAnB;;AAEA,QAAKA,WAAW,KAAK,IAArB,EAA4B;AAC3Bb,MAAAA,kBAAkB,CAAER,kBAAF,EAAsBqB,WAAtB,CAAlB;AACA;AACD,GAhBD,EAgBG,EAhBH,CADiB,EAkBjB,GAlBiB,CAAlB;AAqBA,SAAO,wCAAa;AACnBK,IAAAA,UAAU,EAAEvB,WADO;AAEnBwB,IAAAA,MAAM,EAAEjB,WAFW;;AAGnBkB,IAAAA,UAAU,CAAEhB,KAAF,EAAU;AACnB;AACA;AACA;AACAD,MAAAA,SAAS,CAAEC,KAAF,EAASA,KAAK,CAACC,aAAf,CAAT;AACA,KARkB;;AASnBgB,IAAAA,WAAW,GAAG;AACblB,MAAAA,SAAS,CAACmB,MAAV;AACArB,MAAAA,kBAAkB;AAClBP,MAAAA,mBAAmB,CAAE,IAAF,CAAnB;AACA,KAbkB;;AAcnB6B,IAAAA,SAAS,GAAG;AACXpB,MAAAA,SAAS,CAACmB,MAAV;AACArB,MAAAA,kBAAkB;AAClBP,MAAAA,mBAAmB,CAAE,IAAF,CAAnB;AACA;;AAlBkB,GAAb,CAAP;AAoBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useCallback, useState } from '@wordpress/element';\nimport {\n\tuseThrottle,\n\t__experimentalUseDropZone as useDropZone,\n} from '@wordpress/compose';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport useOnBlockDrop from '../use-on-block-drop';\nimport { getDistanceToNearestEdge } from '../../utils/math';\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('../../utils/math').WPPoint} WPPoint */\n\n/**\n * The orientation of a block list.\n *\n * @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation\n */\n\n/**\n * Given a list of block DOM elements finds the index that a block should be dropped\n * at.\n *\n * @param {Element[]} elements Array of DOM elements that represent each block in a block list.\n * @param {WPPoint} position The position of the item being dragged.\n * @param {WPBlockListOrientation} orientation The orientation of a block list.\n *\n * @return {number|undefined} The block index that's closest to the drag position.\n */\nexport function getNearestBlockIndex( elements, position, orientation ) {\n\tconst allowedEdges =\n\t\torientation === 'horizontal'\n\t\t\t? [ 'left', 'right' ]\n\t\t\t: [ 'top', 'bottom' ];\n\n\tconst isRightToLeft = isRTL();\n\n\tlet candidateIndex;\n\tlet candidateDistance;\n\n\telements.forEach( ( element, index ) => {\n\t\tconst rect = element.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge(\n\t\t\tposition,\n\t\t\trect,\n\t\t\tallowedEdges\n\t\t);\n\n\t\tif ( candidateDistance === undefined || distance < candidateDistance ) {\n\t\t\t// If the user is dropping to the trailing edge of the block\n\t\t\t// add 1 to the index to represent dragging after.\n\t\t\t// Take RTL languages into account where the left edge is\n\t\t\t// the trailing edge.\n\t\t\tconst isTrailingEdge =\n\t\t\t\tedge === 'bottom' ||\n\t\t\t\t( ! isRightToLeft && edge === 'right' ) ||\n\t\t\t\t( isRightToLeft && edge === 'left' );\n\t\t\tconst offset = isTrailingEdge ? 1 : 0;\n\n\t\t\t// Update the currently known best candidate.\n\t\t\tcandidateDistance = distance;\n\t\t\tcandidateIndex = index + offset;\n\t\t}\n\t} );\n\n\treturn candidateIndex;\n}\n\n/**\n * @typedef {Object} WPBlockDropZoneConfig\n * @property {string} rootClientId The root client id for the block list.\n */\n\n/**\n * A React hook that can be used to make a block list handle drag and drop.\n *\n * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.\n */\nexport default function useBlockDropZone( {\n\t// An undefined value represents a top-level block. Default to an empty\n\t// string for this so that `targetRootClientId` can be easily compared to\n\t// values returned by the `getRootBlockClientId` selector, which also uses\n\t// an empty string to represent top-level blocks.\n\trootClientId: targetRootClientId = '',\n} = {} ) {\n\tconst [ targetBlockIndex, setTargetBlockIndex ] = useState( null );\n\n\tconst isLockedAll = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getTemplateLock } = select( blockEditorStore );\n\t\t\treturn getTemplateLock( targetRootClientId ) === 'all';\n\t\t},\n\t\t[ targetRootClientId ]\n\t);\n\n\tconst { getBlockListSettings } = useSelect( blockEditorStore );\n\tconst { showInsertionPoint, hideInsertionPoint } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst onBlockDrop = useOnBlockDrop( targetRootClientId, targetBlockIndex );\n\tconst throttled = useThrottle(\n\t\tuseCallback( ( event, currentTarget ) => {\n\t\t\tconst blockElements = Array.from( currentTarget.children ).filter(\n\t\t\t\t// Ensure the element is a block. It should have the `wp-block` class.\n\t\t\t\t( element ) => element.classList.contains( 'wp-block' )\n\t\t\t);\n\t\t\tconst targetIndex = getNearestBlockIndex(\n\t\t\t\tblockElements,\n\t\t\t\t{ x: event.clientX, y: event.clientY },\n\t\t\t\tgetBlockListSettings( targetRootClientId )?.orientation\n\t\t\t);\n\n\t\t\tsetTargetBlockIndex( targetIndex === undefined ? 0 : targetIndex );\n\n\t\t\tif ( targetIndex !== null ) {\n\t\t\t\tshowInsertionPoint( targetRootClientId, targetIndex );\n\t\t\t}\n\t\t}, [] ),\n\t\t200\n\t);\n\n\treturn useDropZone( {\n\t\tisDisabled: isLockedAll,\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\tonDragLeave() {\n\t\t\tthrottled.cancel();\n\t\t\thideInsertionPoint();\n\t\t\tsetTargetBlockIndex( null );\n\t\t},\n\t\tonDragEnd() {\n\t\t\tthrottled.cancel();\n\t\t\thideInsertionPoint();\n\t\t\tsetTargetBlockIndex( null );\n\t\t},\n\t} );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/use-block-drop-zone/index.native.js"],"names":["getNearestBlockIndex","blocksLayouts","position","orientation","isRTL","allowedEdges","isRightToLeft","candidateIndex","candidateDistance","forEach","element","index","x","y","width","height","rect","top","right","bottom","left","distance","edge","undefined","isTrailingEdge","offset","useBlockDropZone","rootClientId","targetRootClientId","targetBlockIndex","getBlockListSettings","getSettings","blockEditorStore","getBlockLayoutsOrderedByYCoord","getSortedBlocksLayouts","current","onBlockDrop","throttled","event","sortedBlockLayouts","targetIndex","value","onBlockDragOver","onBlockDragEnd","cancel"],"mappings":";;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAMA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,oBAAT,CACNC,aADM,EAENC,QAFM,EAGNC,WAHM,EAINC,KAJM,EAKL;AACD,QAAMC,YAAY,GACjBF,WAAW,KAAK,YAAhB,GACG,CAAE,MAAF,EAAU,OAAV,CADH,GAEG,CAAE,KAAF,EAAS,QAAT,CAHJ;AAKA,QAAMG,aAAa,GAAGF,KAAtB;AAEA,MAAIG,cAAJ;AACA,MAAIC,iBAAJ,CATC,CAWD;;AACAP,EAAAA,aAAa,CAACQ,OAAd,CAAuB,CAAEC,OAAF,EAAWC,KAAX,KAAsB;AAC5C,UAAM;AAAEC,MAAAA,CAAF;AAAKC,MAAA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AAhC,EAAuC;AACtCL,QAAAA,WAAW,CAAE,EACZ,GAAGE,KADS;AAEZV,UAAAA,kBAFY;AAGZC,UAAAA,gBAAgB,EAAEA,gBAAgB,CAACY;AAHvB,SAAF,CAAX;AAKA;AACD,KAhBK;AAiBNZ,IAAAA;AAjBM,GAAP;AAmBA","sourcesContent":["/**\n * External dependencies\n */\nimport { useSharedValue } from 'react-native-reanimated';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\nimport { useThrottle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { useBlockListContext } from '../block-list/block-list-context';\nimport { getDistanceToNearestEdge } from '../../utils/math';\nimport useOnBlockDrop from '../use-on-block-drop';\n\n/** @typedef {import('../../utils/math').WPPoint} WPPoint */\n\n/**\n * The orientation of a block list.\n *\n * @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation\n */\n\n/**\n * Given a list of blocks layouts finds the index that a block should be dropped at.\n *\n * @param {Object} blocksLayouts Blocks layouts object.\n * @param {WPPoint} position The position of the item being dragged.\n * @param {WPBlockListOrientation} orientation The orientation of a block list.\n * @param {boolean} isRTL Check if current locale is RTL.\n *\n * @return {number|undefined} The block index that's closest to the drag position.\n */\nexport function getNearestBlockIndex(\n\tblocksLayouts,\n\tposition,\n\torientation,\n\tisRTL\n) {\n\tconst allowedEdges =\n\t\torientation === 'horizontal'\n\t\t\t? [ 'left', 'right' ]\n\t\t\t: [ 'top', 'bottom' ];\n\n\tconst isRightToLeft = isRTL;\n\n\tlet candidateIndex;\n\tlet candidateDistance;\n\n\t// Only enabled for root level blocks.\n\tblocksLayouts.forEach( ( element, index ) => {\n\t\tconst { x, y, width, height } = element;\n\t\tconst rect = {\n\t\t\tx: element.x,\n\t\t\ty: element.y,\n\t\t\ttop: y,\n\t\t\tright: x + width,\n\t\t\tbottom: y + height,\n\t\t\tleft: x,\n\t\t\twidth,\n\t\t\theight,\n\t\t};\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge(\n\t\t\tposition,\n\t\t\trect,\n\t\t\tallowedEdges\n\t\t);\n\n\t\tif ( candidateDistance === undefined || distance < candidateDistance ) {\n\t\t\t// If the user is dropping to the trailing edge of the block\n\t\t\t// add 1 to the index to represent dragging after.\n\t\t\t// Take RTL languages into account where the left edge is\n\t\t\t// the trailing edge.\n\t\t\tconst isTrailingEdge =\n\t\t\t\tedge === 'bottom' ||\n\t\t\t\t( ! isRightToLeft && edge === 'right' ) ||\n\t\t\t\t( isRightToLeft && edge === 'left' );\n\t\t\tconst offset = isTrailingEdge ? 1 : 0;\n\n\t\t\t// Update the currently known best candidate.\n\t\t\tcandidateDistance = distance;\n\t\t\tcandidateIndex = index + offset;\n\t\t}\n\t} );\n\treturn candidateIndex;\n}\n\n/**\n * @typedef {Object} WPBlockDropZoneConfig\n * @property {string} rootClientId The root client id for the block list.\n */\n\n/**\n * A React hook that can be used to make a block list handle drag and drop.\n *\n * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.\n *\n * @return {Object} An object that contains `targetBlockIndex` and the event\n * handlers `onBlockDragOver`, `onBlockDragEnd` and `onBlockDrop`.\n */\nexport default function useBlockDropZone( {\n\t// An undefined value represents a top-level block. Default to an empty\n\t// string for this so that `targetRootClientId` can be easily compared to\n\t// values returned by the `getRootBlockClientId` selector, which also uses\n\t// an empty string to represent top-level blocks.\n\trootClientId: targetRootClientId = '',\n} = {} ) {\n\tconst targetBlockIndex = useSharedValue( null );\n\n\tconst { getBlockListSettings, getSettings } = useSelect( blockEditorStore );\n\tconst {\n\t\tblocksLayouts,\n\t\tgetBlockLayoutsOrderedByYCoord,\n\t} = useBlockListContext();\n\n\tconst getSortedBlocksLayouts = useCallback( () => {\n\t\treturn getBlockLayoutsOrderedByYCoord( blocksLayouts.current );\n\t}, [ blocksLayouts.current ] );\n\n\tconst isRTL = getSettings().isRTL;\n\n\tconst onBlockDrop = useOnBlockDrop();\n\n\tconst throttled = useThrottle(\n\t\tuseCallback(\n\t\t\t( event ) => {\n\t\t\t\tconst sortedBlockLayouts = getSortedBlocksLayouts();\n\n\t\t\t\tconst targetIndex = getNearestBlockIndex(\n\t\t\t\t\tsortedBlockLayouts,\n\t\t\t\t\t{ x: event.x, y: event.y },\n\t\t\t\t\tgetBlockListSettings( targetRootClientId )?.orientation,\n\t\t\t\t\tisRTL\n\t\t\t\t);\n\t\t\t\tif ( targetIndex !== null ) {\n\t\t\t\t\ttargetBlockIndex.value = targetIndex ?? 0;\n\t\t\t\t}\n\t\t\t},\n\t\t\t[\n\t\t\t\tgetSortedBlocksLayouts,\n\t\t\t\tgetNearestBlockIndex,\n\t\t\t\tgetBlockListSettings,\n\t\t\t\ttargetBlockIndex,\n\t\t\t]\n\t\t),\n\t\t200\n\t);\n\n\treturn {\n\t\tonBlockDragOver( event ) {\n\t\t\tthrottled( event );\n\t\t},\n\t\tonBlockDragEnd() {\n\t\t\tthrottled.cancel();\n\t\t\ttargetBlockIndex.value = null;\n\t\t},\n\t\tonBlockDrop: ( event ) => {\n\t\t\tif ( targetBlockIndex.value !== null ) {\n\t\t\t\tonBlockDrop( {\n\t\t\t\t\t...event,\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\ttargetBlockIndex: targetBlockIndex.value,\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\ttargetBlockIndex,\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/use-block-drop-zone/index.native.js"],"names":["getNearestBlockIndex","blocksLayouts","position","orientation","isRTL","allowedEdges","isRightToLeft","candidateIndex","candidateDistance","forEach","element","index","x","y","width","height","rect","top","right","bottom","left","distance","edge","undefined","isTrailingEdge","offset","useBlockDropZone","rootClientId","targetRootClientId","targetBlockIndex","getBlockListSettings","getSettings","blockEditorStore","getBlockLayoutsOrderedByYCoord","getSortedBlocksLayouts","current","onBlockDrop","throttled","event","sortedBlockLayouts","targetIndex","value","onBlockDragOver","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AF,CAHmB,0DAGvC,sBAA4CzB,WAHL,EAIvCC,KAJuC,CAAxC;;AAMA,QAAKoC,WAAW,KAAK,IAArB,EAA4B;AAC3BX,MAAAA,gBAAgB,CAACY,KAAjB,GAAyBD,WAAzB,aAAyBA,WAAzB,cAAyBA,WAAzB,GAAwC,CAAxC;AACA;AACD,GAbF,EAcC,CACCN,sBADD,EAEClC,oBAFD,EAGC8B,oBAHD,EAICD,gBAJD,CAdD,CADiB,EAsBjB,GAtBiB,CAAlB;AAyBA,SAAO;AACNa,IAAAA,eAAe,CAAEJ,KAAF,EAAU;AACxBD,MAAAA,SAAS,CAAEC,KAAF,CAAT;AACA,KAHK;;AAINK,IAAAA,cAAc,GAAG;AAChBN,MAAAA,SAAS,CAACO,MAAV;AACAf,MAAAA,gBAAgB,CAACY,KAAjB,GAAyB,IAAzB;AACA,KAPK;;AAQNL,IAAAA,WAAW,EAAIE,KAAF,IAAa;AACzB,UAAKT,gBAAgB,CAACY,KAAjB,KAA2B,IAAhC,EAAuC;AACtCL,QAAAA,WAAW,CAAE,EACZ,GAAGE,KADS;AAEZV,UAAAA,kBAFY;AAGZC,UAAAA,gBAAgB,EAAEA,gBAAgB,CAACY;AAHvB,SAAF,CAAX;AAKA;AACD,KAhBK;AAiBNZ,IAAAA;AAjBM,GAAP;AAmBA","sourcesContent":["/**\n * External dependencies\n */\nimport { useSharedValue } from 'react-native-reanimated';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\nimport { useThrottle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { useBlockListContext } from '../block-list/block-list-context';\nimport { getDistanceToNearestEdge } from '../../utils/math';\nimport useOnBlockDrop from '../use-on-block-drop';\n\n/** @typedef {import('../../utils/math').WPPoint} WPPoint */\n\n/**\n * The orientation of a block list.\n *\n * @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation\n */\n\n/**\n * Given a list of blocks layouts finds the index that a block should be dropped at.\n *\n * @param {Object} blocksLayouts Blocks layouts object.\n * @param {WPPoint} position The position of the item being dragged.\n * @param {WPBlockListOrientation} orientation The orientation of a block list.\n * @param {boolean} isRTL Check if current locale is RTL.\n *\n * @return {number|undefined} The block index that's closest to the drag position.\n */\nexport function getNearestBlockIndex(\n\tblocksLayouts,\n\tposition,\n\torientation,\n\tisRTL\n) {\n\tconst allowedEdges =\n\t\torientation === 'horizontal'\n\t\t\t? [ 'left', 'right' ]\n\t\t\t: [ 'top', 'bottom' ];\n\n\tconst isRightToLeft = isRTL;\n\n\tlet candidateIndex;\n\tlet candidateDistance;\n\n\t// Only enabled for root level blocks.\n\tblocksLayouts.forEach( ( element, index ) => {\n\t\tconst { x, y, width, height } = element;\n\t\tconst rect = {\n\t\t\tx: element.x,\n\t\t\ty: element.y,\n\t\t\ttop: y,\n\t\t\tright: x + width,\n\t\t\tbottom: y + height,\n\t\t\tleft: x,\n\t\t\twidth,\n\t\t\theight,\n\t\t};\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge(\n\t\t\tposition,\n\t\t\trect,\n\t\t\tallowedEdges\n\t\t);\n\n\t\tif ( candidateDistance === undefined || distance < candidateDistance ) {\n\t\t\t// If the user is dropping to the trailing edge of the block\n\t\t\t// add 1 to the index to represent dragging after.\n\t\t\t// Take RTL languages into account where the left edge is\n\t\t\t// the trailing edge.\n\t\t\tconst isTrailingEdge =\n\t\t\t\tedge === 'bottom' ||\n\t\t\t\t( ! isRightToLeft && edge === 'right' ) ||\n\t\t\t\t( isRightToLeft && edge === 'left' );\n\t\t\tconst offset = isTrailingEdge ? 1 : 0;\n\n\t\t\t// Update the currently known best candidate.\n\t\t\tcandidateDistance = distance;\n\t\t\tcandidateIndex = index + offset;\n\t\t}\n\t} );\n\treturn candidateIndex;\n}\n\n/**\n * @typedef {Object} WPBlockDropZoneConfig\n * @property {string} rootClientId The root client id for the block list.\n */\n\n/**\n * A React hook that can be used to make a block list handle drag and drop.\n *\n * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.\n *\n * @return {Object} An object that contains `targetBlockIndex` and the event\n * handlers `onBlockDragOver`, `onBlockDragEnd` and `onBlockDrop`.\n */\nexport default function useBlockDropZone( {\n\t// An undefined value represents a top-level block. Default to an empty\n\t// string for this so that `targetRootClientId` can be easily compared to\n\t// values returned by the `getRootBlockClientId` selector, which also uses\n\t// an empty string to represent top-level blocks.\n\trootClientId: targetRootClientId = '',\n} = {} ) {\n\tconst targetBlockIndex = useSharedValue( null );\n\n\tconst { getBlockListSettings, getSettings } = useSelect( blockEditorStore );\n\tconst { blocksLayouts, getBlockLayoutsOrderedByYCoord } =\n\t\tuseBlockListContext();\n\n\tconst getSortedBlocksLayouts = useCallback( () => {\n\t\treturn getBlockLayoutsOrderedByYCoord( blocksLayouts.current );\n\t}, [ blocksLayouts.current ] );\n\n\tconst isRTL = getSettings().isRTL;\n\n\tconst onBlockDrop = useOnBlockDrop();\n\n\tconst throttled = useThrottle(\n\t\tuseCallback(\n\t\t\t( event ) => {\n\t\t\t\tconst sortedBlockLayouts = getSortedBlocksLayouts();\n\n\t\t\t\tconst targetIndex = getNearestBlockIndex(\n\t\t\t\t\tsortedBlockLayouts,\n\t\t\t\t\t{ x: event.x, y: event.y },\n\t\t\t\t\tgetBlockListSettings( targetRootClientId )?.orientation,\n\t\t\t\t\tisRTL\n\t\t\t\t);\n\t\t\t\tif ( targetIndex !== null ) {\n\t\t\t\t\ttargetBlockIndex.value = targetIndex ?? 0;\n\t\t\t\t}\n\t\t\t},\n\t\t\t[\n\t\t\t\tgetSortedBlocksLayouts,\n\t\t\t\tgetNearestBlockIndex,\n\t\t\t\tgetBlockListSettings,\n\t\t\t\ttargetBlockIndex,\n\t\t\t]\n\t\t),\n\t\t200\n\t);\n\n\treturn {\n\t\tonBlockDragOver( event ) {\n\t\t\tthrottled( event );\n\t\t},\n\t\tonBlockDragEnd() {\n\t\t\tthrottled.cancel();\n\t\t\ttargetBlockIndex.value = null;\n\t\t},\n\t\tonBlockDrop: ( event ) => {\n\t\t\tif ( targetBlockIndex.value !== null ) {\n\t\t\t\tonBlockDrop( {\n\t\t\t\t\t...event,\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\ttargetBlockIndex: targetBlockIndex.value,\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\ttargetBlockIndex,\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/use-display-block-controls/index.native.js"],"names":["useDisplayBlockControls","isSelected","clientId","name","select","getBlockName","getBlockRootClientId","blockEditorStore","parentId","parentBlockName","hideControls"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;AAIe,SAASA,uBAAT,GAAmC;AACjD,QAAM;AAAEC,IAAAA,UAAF;AAAcC,IAAAA,QAAd;AAAwBC,IAAAA;AAAxB,MAAiC,mCAAvC;AACA,SAAO,qBACJC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,YAAF;AAAgBC,MAAAA;AAAhB,QAAyCF,MAAM,CACpDG,YADoD,CAArD;AAIA,UAAMC,QAAQ,GAAGF,oBAAoB,CAAEJ,QAAF,CAArC;AACA,UAAMO,eAAe,GAAGJ,YAAY,CAAEG,QAAF,CAApC;AAEA,UAAME,YAAY,GAAG,6BACpBD,eADoB,EAEpB,sCAFoB,EAGpB,KAHoB,CAArB;;AAMA,QAAK,CAAEC,YAAF,IAAkBT,UAAvB,EAAoC;AACnC,aAAO,IAAP;AACA;;AAED,WAAO,KAAP;AACA,GApBK,EAqBN,CAAEC,QAAF,EAAYD,UAAZ,EAAwBE,IAAxB,CArBM,CAAP;AAuBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit/context';\nimport { store as blockEditorStore } from '../../store';\n\nexport default function useDisplayBlockControls() {\n\tconst { isSelected, clientId, name } = useBlockEditContext();\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockName, getBlockRootClientId } = select(\n\t\t\t\tblockEditorStore\n\t\t\t);\n\n\t\t\tconst parentId = getBlockRootClientId( clientId );\n\t\t\tconst parentBlockName = getBlockName( parentId );\n\n\t\t\tconst hideControls = hasBlockSupport(\n\t\t\t\tparentBlockName,\n\t\t\t\t'__experimentalHideChildBlockControls',\n\t\t\t\tfalse\n\t\t\t);\n\n\t\t\tif ( ! hideControls && isSelected ) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t},\n\t\t[ clientId, isSelected, name ]\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/use-display-block-controls/index.native.js"],"names":["useDisplayBlockControls","isSelected","clientId","name","select","getBlockName","getBlockRootClientId","blockEditorStore","parentId","parentBlockName","hideControls"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;AAIe,SAASA,uBAAT,GAAmC;AACjD,QAAM;AAAEC,IAAAA,UAAF;AAAcC,IAAAA,QAAd;AAAwBC,IAAAA;AAAxB,MAAiC,mCAAvC;AACA,SAAO,qBACJC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,YAAF;AAAgBC,MAAAA;AAAhB,QACLF,MAAM,CAAEG,YAAF,CADP;AAGA,UAAMC,QAAQ,GAAGF,oBAAoB,CAAEJ,QAAF,CAArC;AACA,UAAMO,eAAe,GAAGJ,YAAY,CAAEG,QAAF,CAApC;AAEA,UAAME,YAAY,GAAG,6BACpBD,eADoB,EAEpB,sCAFoB,EAGpB,KAHoB,CAArB;;AAMA,QAAK,CAAEC,YAAF,IAAkBT,UAAvB,EAAoC;AACnC,aAAO,IAAP;AACA;;AAED,WAAO,KAAP;AACA,GAnBK,EAoBN,CAAEC,QAAF,EAAYD,UAAZ,EAAwBE,IAAxB,CApBM,CAAP;AAsBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit/context';\nimport { store as blockEditorStore } from '../../store';\n\nexport default function useDisplayBlockControls() {\n\tconst { isSelected, clientId, name } = useBlockEditContext();\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockName, getBlockRootClientId } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\tconst parentId = getBlockRootClientId( clientId );\n\t\t\tconst parentBlockName = getBlockName( parentId );\n\n\t\t\tconst hideControls = hasBlockSupport(\n\t\t\t\tparentBlockName,\n\t\t\t\t'__experimentalHideChildBlockControls',\n\t\t\t\tfalse\n\t\t\t);\n\n\t\t\tif ( ! hideControls && isSelected ) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t},\n\t\t[ clientId, isSelected, name ]\n\t);\n}\n"]}