@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
@@ -0,0 +1,46 @@
1
+ import { createElement } from "@wordpress/element";
2
+
3
+ /**
4
+ * WordPress dependencies
5
+ */
6
+ import { __experimentalVStack as VStack, __experimentalHStack as HStack, __experimentalHeading as Heading, __experimentalSpacer as Spacer, Button, __experimentalText as Text } from '@wordpress/components';
7
+ import { closeSmall } from '@wordpress/icons';
8
+ import { __ } from '@wordpress/i18n';
9
+ export default function InspectorPopoverHeader(_ref) {
10
+ let {
11
+ title,
12
+ help,
13
+ actions = [],
14
+ onClose
15
+ } = _ref;
16
+ return createElement(VStack, {
17
+ className: "block-editor-inspector-popover-header",
18
+ spacing: 4
19
+ }, createElement(HStack, {
20
+ alignment: "center"
21
+ }, createElement(Heading, {
22
+ className: "block-editor-inspector-popover-header__heading",
23
+ level: 2,
24
+ size: 13
25
+ }, title), createElement(Spacer, null), actions.map(_ref2 => {
26
+ let {
27
+ label,
28
+ icon,
29
+ onClick
30
+ } = _ref2;
31
+ return createElement(Button, {
32
+ key: label,
33
+ className: "block-editor-inspector-popover-header__action",
34
+ label: label,
35
+ icon: icon,
36
+ variant: !icon && 'tertiary',
37
+ onClick: onClick
38
+ }, !icon && label);
39
+ }), onClose && createElement(Button, {
40
+ className: "block-editor-inspector-popover-header__action",
41
+ label: __('Close'),
42
+ icon: closeSmall,
43
+ onClick: onClose
44
+ })), help && createElement(Text, null, help));
45
+ }
46
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/inspector-popover-header/index.js"],"names":["__experimentalVStack","VStack","__experimentalHStack","HStack","__experimentalHeading","Heading","__experimentalSpacer","Spacer","Button","__experimentalText","Text","closeSmall","__","InspectorPopoverHeader","title","help","actions","onClose","map","label","icon","onClick"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,oBAAoB,IAAIC,MADzB,EAECC,oBAAoB,IAAIC,MAFzB,EAGCC,qBAAqB,IAAIC,OAH1B,EAICC,oBAAoB,IAAIC,MAJzB,EAKCC,MALD,EAMCC,kBAAkB,IAAIC,IANvB,QAOO,uBAPP;AAQA,SAASC,UAAT,QAA2B,kBAA3B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA,eAAe,SAASC,sBAAT,OAKX;AAAA,MAL4C;AAC/CC,IAAAA,KAD+C;AAE/CC,IAAAA,IAF+C;AAG/CC,IAAAA,OAAO,GAAG,EAHqC;AAI/CC,IAAAA;AAJ+C,GAK5C;AACH,SACC,cAAC,MAAD;AAAQ,IAAA,SAAS,EAAC,uCAAlB;AAA0D,IAAA,OAAO,EAAG;AAApE,KACC,cAAC,MAAD;AAAQ,IAAA,SAAS,EAAC;AAAlB,KACC,cAAC,OAAD;AACC,IAAA,SAAS,EAAC,gDADX;AAEC,IAAA,KAAK,EAAG,CAFT;AAGC,IAAA,IAAI,EAAG;AAHR,KAKGH,KALH,CADD,EAQC,cAAC,MAAD,OARD,EASGE,OAAO,CAACE,GAAR,CAAa;AAAA,QAAE;AAAEC,MAAAA,KAAF;AAASC,MAAAA,IAAT;AAAeC,MAAAA;AAAf,KAAF;AAAA,WACd,cAAC,MAAD;AACC,MAAA,GAAG,EAAGF,KADP;AAEC,MAAA,SAAS,EAAC,+CAFX;AAGC,MAAA,KAAK,EAAGA,KAHT;AAIC,MAAA,IAAI,EAAGC,IAJR;AAKC,MAAA,OAAO,EAAG,CAAEA,IAAF,IAAU,UALrB;AAMC,MAAA,OAAO,EAAGC;AANX,OAQG,CAAED,IAAF,IAAUD,KARb,CADc;AAAA,GAAb,CATH,EAqBGF,OAAO,IACR,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,+CADX;AAEC,IAAA,KAAK,EAAGL,EAAE,CAAE,OAAF,CAFX;AAGC,IAAA,IAAI,EAAGD,UAHR;AAIC,IAAA,OAAO,EAAGM;AAJX,IAtBF,CADD,EA+BGF,IAAI,IAAI,cAAC,IAAD,QAAQA,IAAR,CA/BX,CADD;AAmCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n\t__experimentalHeading as Heading,\n\t__experimentalSpacer as Spacer,\n\tButton,\n\t__experimentalText as Text,\n} from '@wordpress/components';\nimport { closeSmall } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\nexport default function InspectorPopoverHeader( {\n\ttitle,\n\thelp,\n\tactions = [],\n\tonClose,\n} ) {\n\treturn (\n\t\t<VStack className=\"block-editor-inspector-popover-header\" spacing={ 4 }>\n\t\t\t<HStack alignment=\"center\">\n\t\t\t\t<Heading\n\t\t\t\t\tclassName=\"block-editor-inspector-popover-header__heading\"\n\t\t\t\t\tlevel={ 2 }\n\t\t\t\t\tsize={ 13 }\n\t\t\t\t>\n\t\t\t\t\t{ title }\n\t\t\t\t</Heading>\n\t\t\t\t<Spacer />\n\t\t\t\t{ actions.map( ( { label, icon, onClick } ) => (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\tclassName=\"block-editor-inspector-popover-header__action\"\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\tvariant={ ! icon && 'tertiary' }\n\t\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ! icon && label }\n\t\t\t\t\t</Button>\n\t\t\t\t) ) }\n\t\t\t\t{ onClose && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"block-editor-inspector-popover-header__action\"\n\t\t\t\t\t\tlabel={ __( 'Close' ) }\n\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t\t{ help && <Text>{ help }</Text> }\n\t\t</VStack>\n\t);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/line-height-control/index.js"],"names":["deprecated","__","__experimentalNumberControl","NumberControl","BASE_DEFAULT_VALUE","RESET_VALUE","STEP","isLineHeightDefined","LineHeightControl","value","lineHeight","onChange","__nextHasNoMarginBottom","__unstableInputWidth","isDefined","adjustNextValue","nextValue","wasTypedOrPasted","stateReducer","state","action","includes","payload","event","nativeEvent","inputType","since","version","hint","deprecatedStyles","undefined","marginBottom"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,uBAAvB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,2BAA2B,IAAIC,aAAxC,QAA6D,uBAA7D;AAEA;AACA;AACA;;AACA,SACCC,kBADD,EAECC,WAFD,EAGCC,IAHD,EAICC,mBAJD,QAKO,SALP;;AAOA,MAAMC,iBAAiB,GAAG,QAMnB;AAAA,MANqB;AAC3BC,IAAAA,KAAK,EAAEC,UADoB;AAE3BC,IAAAA,QAF2B;;AAG3B;AACAC,IAAAA,uBAAuB,GAAG,KAJC;AAK3BC,IAAAA,oBAAoB,GAAG;A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,IAAAA,YAAY,EAAE;AAAhB,GAFH;AAIA,SACC;AACC,IAAA,SAAS,EAAC,kCADX;AAEC,IAAA,KAAK,EAAGF;AAFT,KAIC,cAAC,aAAD;AACC,IAAA,oBAAoB,EAAGhB,oBADxB;AAEC,IAAA,sBAAsB,EAAGK,YAF1B;AAGC,IAAA,QAAQ,EAAGP,QAHZ;AAIC,IAAA,KAAK,EAAGV,EAAE,CAAE,aAAF,CAJX;AAKC,IAAA,WAAW,EAAGG,kBALf;AAMC,IAAA,IAAI,EAAGE,IANR;AAOC,IAAA,KAAK,EAAGG,KAPT;AAQC,IAAA,GAAG,EAAG;AARP,IAJD,CADD;AAiBA,CAtFD;AAwFA;AACA;AACA;;;AACA,eAAeD,iBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalNumberControl as NumberControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBASE_DEFAULT_VALUE,\n\tRESET_VALUE,\n\tSTEP,\n\tisLineHeightDefined,\n} from './utils';\n\nconst LineHeightControl = ( {\n\tvalue: lineHeight,\n\tonChange,\n\t/** Start opting into the new margin-free styles that will become the default in a future version. */\n\t__nextHasNoMarginBottom = false,\n\t__unstableInputWidth = '60px',\n} ) => {\n\tconst isDefined = isLineHeightDefined( lineHeight );\n\n\tconst adjustNextValue = ( nextValue, wasTypedOrPasted ) => {\n\t\t// Set the next value without modification if lineHeight has been defined.\n\t\tif ( isDefined ) return nextValue;\n\n\t\t/**\n\t\t * The following logic handles the initial step up/down action\n\t\t * (from an undefined value state) so that the next values are better suited for\n\t\t * line-height rendering. For example, the first step up should immediately\n\t\t * go to 1.6, rather than the normally expected 0.1.\n\t\t *\n\t\t * Step up/down actions can be triggered by keydowns of the up/down arrow keys,\n\t\t * or by clicking the spin buttons.\n\t\t */\n\t\tswitch ( `${ nextValue }` ) {\n\t\t\tcase `${ STEP }`:\n\t\t\t\t// Increment by step value.\n\t\t\t\treturn BASE_DEFAULT_VALUE + STEP;\n\t\t\tcase '0': {\n\t\t\t\t// This means the user explicitly input '0', rather than stepped down\n\t\t\t\t// from an undefined value state.\n\t\t\t\tif ( wasTypedOrPasted ) return nextValue;\n\t\t\t\t// Decrement by step value.\n\t\t\t\treturn BASE_DEFAULT_VALUE - STEP;\n\t\t\t}\n\t\t\tcase '':\n\t\t\t\treturn BASE_DEFAULT_VALUE;\n\t\t\tdefault:\n\t\t\t\treturn nextValue;\n\t\t}\n\t};\n\n\tconst stateReducer = ( state, action ) => {\n\t\t// Be careful when changing this — cross-browser behavior of the\n\t\t// `inputType` field in `input` events are inconsistent.\n\t\t// For example, Firefox emits an input event with inputType=\"insertReplacementText\"\n\t\t// on spin button clicks, while other browsers do not even emit an input event.\n\t\tconst wasTypedOrPasted = [ 'insertText', 'insertFromPaste' ].includes(\n\t\t\taction.payload.event.nativeEvent?.inputType\n\t\t);\n\t\tconst value = adjustNextValue( state.value, wasTypedOrPasted );\n\t\treturn { ...state, value };\n\t};\n\n\tconst value = isDefined ? lineHeight : RESET_VALUE;\n\n\tif ( ! __nextHasNoMarginBottom ) {\n\t\tdeprecated(\n\t\t\t'Bottom margin styles for wp.blockEditor.LineHeightControl',\n\t\t\t{\n\t\t\t\tsince: '6.0',\n\t\t\t\tversion: '6.4',\n\t\t\t\thint:\n\t\t\t\t\t'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version',\n\t\t\t}\n\t\t);\n\t}\n\tconst deprecatedStyles = __nextHasNoMarginBottom\n\t\t? undefined\n\t\t: { marginBottom: 24 };\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"block-editor-line-height-control\"\n\t\t\tstyle={ deprecatedStyles }\n\t\t>\n\t\t\t<NumberControl\n\t\t\t\t__unstableInputWidth={ __unstableInputWidth }\n\t\t\t\t__unstableStateReducer={ stateReducer }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tlabel={ __( 'Line height' ) }\n\t\t\t\tplaceholder={ BASE_DEFAULT_VALUE }\n\t\t\t\tstep={ STEP }\n\t\t\t\tvalue={ value }\n\t\t\t\tmin={ 0 }\n\t\t\t/>\n\t\t</div>\n\t);\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/line-height-control/README.md\n */\nexport default LineHeightControl;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/line-height-control/index.js"],"names":["deprecated","__","__experimentalNumberControl","NumberControl","BASE_DEFAULT_VALUE","RESET_VALUE","STEP","isLineHeightDefined","LineHeightControl","value","lineHeight","onChange","__nextHasNoMarginBottom","__unstableInputWidth","isDefined","adjustNextValue","nextValue","wasTypedOrPasted","stateReducer","state","action","includes","payload","event","nativeEvent","inputType","since","version","hint","deprecatedStyles","undefined","marginBottom"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,uBAAvB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,2BAA2B,IAAIC,aAAxC,QAA6D,uBAA7D;AAEA;AACA;AACA;;AACA,SACCC,kBADD,EAECC,WAFD,EAGCC,IAHD,EAICC,mBAJD,QAKO,SALP;;AAOA,MAAMC,iBAAiB,GAAG,QAMnB;AAAA,MANqB;AAC3BC,IAAAA,KAAK,EAAEC,UADoB;AAE3BC,IAAAA,QAF2B;;AAG3B;AACAC,IAAAA,uBAAuB,GAAG,KAJC;AAK3BC,IAAAA,oBAAoB,GAAG;AALI,GAMrB;AACN,QAAMC,SAAS,GAAGP,mBAAmB,CAAEG,UAAF,CAArC;;AAEA,QAAMK,eAAe,GAAG,CAAEC,SAAF,EAAaC,gBAAb,KAAmC;AAC1D;AACA,QAAKH,SAAL,EAAiB,OAAOE,SAAP;AAEjB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACE,YAAU,GAAGA,SAAW,EAAxB;AACC,WAAM,GAAGV,IAAM,EAAf;AACC;AACA,eAAOF,kBAAkB,GAAGE,IAA5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AAA,IAAI,EAAGE,IANR;AAOC,IAAA,KAAK,EAAGG,KAPT;AAQC,IAAA,GAAG,EAAG;AARP,IAJD,CADD;AAiBA,CArFD;AAuFA;AACA;AACA;;;AACA,eAAeD,iBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalNumberControl as NumberControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBASE_DEFAULT_VALUE,\n\tRESET_VALUE,\n\tSTEP,\n\tisLineHeightDefined,\n} from './utils';\n\nconst LineHeightControl = ( {\n\tvalue: lineHeight,\n\tonChange,\n\t/** Start opting into the new margin-free styles that will become the default in a future version. */\n\t__nextHasNoMarginBottom = false,\n\t__unstableInputWidth = '60px',\n} ) => {\n\tconst isDefined = isLineHeightDefined( lineHeight );\n\n\tconst adjustNextValue = ( nextValue, wasTypedOrPasted ) => {\n\t\t// Set the next value without modification if lineHeight has been defined.\n\t\tif ( isDefined ) return nextValue;\n\n\t\t/**\n\t\t * The following logic handles the initial step up/down action\n\t\t * (from an undefined value state) so that the next values are better suited for\n\t\t * line-height rendering. For example, the first step up should immediately\n\t\t * go to 1.6, rather than the normally expected 0.1.\n\t\t *\n\t\t * Step up/down actions can be triggered by keydowns of the up/down arrow keys,\n\t\t * or by clicking the spin buttons.\n\t\t */\n\t\tswitch ( `${ nextValue }` ) {\n\t\t\tcase `${ STEP }`:\n\t\t\t\t// Increment by step value.\n\t\t\t\treturn BASE_DEFAULT_VALUE + STEP;\n\t\t\tcase '0': {\n\t\t\t\t// This means the user explicitly input '0', rather than stepped down\n\t\t\t\t// from an undefined value state.\n\t\t\t\tif ( wasTypedOrPasted ) return nextValue;\n\t\t\t\t// Decrement by step value.\n\t\t\t\treturn BASE_DEFAULT_VALUE - STEP;\n\t\t\t}\n\t\t\tcase '':\n\t\t\t\treturn BASE_DEFAULT_VALUE;\n\t\t\tdefault:\n\t\t\t\treturn nextValue;\n\t\t}\n\t};\n\n\tconst stateReducer = ( state, action ) => {\n\t\t// Be careful when changing this — cross-browser behavior of the\n\t\t// `inputType` field in `input` events are inconsistent.\n\t\t// For example, Firefox emits an input event with inputType=\"insertReplacementText\"\n\t\t// on spin button clicks, while other browsers do not even emit an input event.\n\t\tconst wasTypedOrPasted = [ 'insertText', 'insertFromPaste' ].includes(\n\t\t\taction.payload.event.nativeEvent?.inputType\n\t\t);\n\t\tconst value = adjustNextValue( state.value, wasTypedOrPasted );\n\t\treturn { ...state, value };\n\t};\n\n\tconst value = isDefined ? lineHeight : RESET_VALUE;\n\n\tif ( ! __nextHasNoMarginBottom ) {\n\t\tdeprecated(\n\t\t\t'Bottom margin styles for wp.blockEditor.LineHeightControl',\n\t\t\t{\n\t\t\t\tsince: '6.0',\n\t\t\t\tversion: '6.4',\n\t\t\t\thint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version',\n\t\t\t}\n\t\t);\n\t}\n\tconst deprecatedStyles = __nextHasNoMarginBottom\n\t\t? undefined\n\t\t: { marginBottom: 24 };\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"block-editor-line-height-control\"\n\t\t\tstyle={ deprecatedStyles }\n\t\t>\n\t\t\t<NumberControl\n\t\t\t\t__unstableInputWidth={ __unstableInputWidth }\n\t\t\t\t__unstableStateReducer={ stateReducer }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tlabel={ __( 'Line height' ) }\n\t\t\t\tplaceholder={ BASE_DEFAULT_VALUE }\n\t\t\t\tstep={ STEP }\n\t\t\t\tvalue={ value }\n\t\t\t\tmin={ 0 }\n\t\t\t/>\n\t\t</div>\n\t);\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/line-height-control/README.md\n */\nexport default LineHeightControl;\n"]}
@@ -3,7 +3,6 @@ import { createElement, Fragment } from "@wordpress/element";
3
3
  /**
4
4
  * External dependencies
5
5
  */
6
- import { noop } from 'lodash';
7
6
  import classnames from 'classnames';
8
7
  /**
9
8
  * WordPress dependencies
@@ -100,6 +99,7 @@ import { DEFAULT_LINK_SETTINGS } from './constants';
100
99
  * @property {Function} renderControlBottom Optional controls to be rendered at the bottom of the component.
101
100
  */
102
101
 
102
+ const noop = () => {};
103
103
  /**
104
104
  * Renders a link control. A link control is a controlled input which maintains
105
105
  * a value associated with a link (HTML anchor element) and relevant settings
@@ -108,6 +108,7 @@ import { DEFAULT_LINK_SETTINGS } from './constants';
108
108
  * @param {WPLinkControlProps} props Component props.
109
109
  */
110
110
 
111
+
111
112
  function LinkControl(_ref) {
112
113
  var _currentInputValue$tr, _value$url, _value$url$trim;
113
114
 
@@ -218,7 +219,7 @@ function LinkControl(_ref) {
218
219
 
219
220
  const handleSubmit = () => {
220
221
  if (currentInputValue !== (value === null || value === void 0 ? void 0 : value.url) || internalTextValue !== (value === null || value === void 0 ? void 0 : value.title)) {
221
- onChange({
222
+ onChange({ ...value,
222
223
  url: currentInputValue,
223
224
  title: internalTextValue
224
225
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/index.js"],"names":["noop","classnames","Button","Spinner","Notice","TextControl","keyboardReturn","__","useRef","useState","useEffect","focus","ENTER","LinkControlSettingsDrawer","LinkControlSearchInput","LinkPreview","useCreatePage","ViewerFill","DEFAULT_LINK_SETTINGS","LinkControl","searchInputPlaceholder","value","settings","onChange","onRemove","noDirectEntry","showSuggestions","showInitialSuggestions","forceIsEditingLink","createSuggestion","withCreateSuggestion","inputValue","propInputValue","suggestionsQuery","noURLSuggestion","createSuggestionButtonText","hasRichPreviews","hasTextControl","renderControlBottom","undefined","isMounting","wrapperNode","textInputRef","internalInputValue","setInternalInputValue","url","internalTextValue","setInternalTextValue","title","currentInputValue","isEditingLink","setIsEditingLink","isEndingEditWithFocus","currentInputIsEmpty","trim","length","createPage","isCreatingPage","errorMessage","current","whichFocusTargetIndex","nextFocusTarget","focusable","find","stopEditing","contains","ownerDocument","activeElement","handleSelectSuggestion","updatedValue","handleSubmit","handleSubmitWithEnter","event","keyCode","preventDefault","shownUnlinkControl","showSettingsDrawer","showTextControl"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,EAAiBC,OAAjB,EAA0BC,MAA1B,EAAkCC,WAAlC,QAAqD,uBAArD;AACA,SAASC,cAAT,QAA+B,kBAA/B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,EAAiBC,QAAjB,EAA2BC,SAA3B,QAA4C,oBAA5C;AACA,SAASC,KAAT,QAAsB,gBAAtB;AACA,SAASC,KAAT,QAAsB,qBAAtB;AAEA;AACA;AACA;;AACA,OAAOC,yBAAP,MAAsC,mBAAtC;AACA,OAAOC,sBAAP,MAAmC,gBAAnC;AACA,OAAOC,WAAP,MAAwB,gBAAxB;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,SAASC,UAAT,QAA2B,eAA3B;AACA,SAASC,qBAAT,QAAsC,aAAtC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AACA;AACA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,WAAT,OAmBI;AAAA;;AAAA,MAnBkB;AACrBC,IAAAA,sBADqB;AAErBC,IAAAA,KAFqB;AAGrBC,IAAAA,QAAQ,GAAGJ,qBAHU;AAIrBK,IAAAA,QAAQ,GAAGvB,IAJU;AAKrBwB,I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;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,yBAAD;AACC,IAAA,KAAK,EAAGvD,KADT;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,QAAQ,EAAGC;AAHZ,IADD,CApFF,EA4FGe,mBAAmB,IAAIA,mBAAmB,EA5F7C,CADD;AAgGA;;AAEDnB,WAAW,CAACF,UAAZ,GAAyBA,UAAzB;AAEA,eAAeE,WAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { noop } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button, Spinner, Notice, TextControl } from '@wordpress/components';\nimport { keyboardReturn } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useState, useEffect } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport { ENTER } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport LinkControlSettingsDrawer from './settings-drawer';\nimport LinkControlSearchInput from './search-input';\nimport LinkPreview from './link-preview';\nimport useCreatePage from './use-create-page';\nimport { ViewerFill } from './viewer-slot';\nimport { DEFAULT_LINK_SETTINGS } from './constants';\n\n/**\n * Default properties associated with a link control value.\n *\n * @typedef WPLinkControlDefaultValue\n *\n * @property {string} url Link URL.\n * @property {string=} title Link title.\n * @property {boolean=} opensInNewTab Whether link should open in a new browser\n * tab. This value is only assigned if not\n * providing a custom `settings` prop.\n */\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Custom settings values associated with a link.\n *\n * @typedef {{[setting:string]:any}} WPLinkControlSettingsValue\n */\n/* eslint-enable */\n\n/**\n * Custom settings values associated with a link.\n *\n * @typedef WPLinkControlSetting\n *\n * @property {string} id Identifier to use as property for setting value.\n * @property {string} title Human-readable label to show in user interface.\n */\n\n/**\n * Properties associated with a link control value, composed as a union of the\n * default properties and any custom settings values.\n *\n * @typedef {WPLinkControlDefaultValue&WPLinkControlSettingsValue} WPLinkControlValue\n */\n\n/** @typedef {(nextValue:WPLinkControlValue)=>void} WPLinkControlOnChangeProp */\n\n/**\n * Properties associated with a search suggestion used within the LinkControl.\n *\n * @typedef WPLinkControlSuggestion\n *\n * @property {string} id Identifier to use to uniquely identify the suggestion.\n * @property {string} type Identifies the type of the suggestion (eg: `post`,\n * `page`, `url`...etc)\n * @property {string} title Human-readable label to show in user interface.\n * @property {string} url A URL for the suggestion.\n */\n\n/** @typedef {(title:string)=>WPLinkControlSuggestion} WPLinkControlCreateSuggestionProp */\n\n/**\n * @typedef WPLinkControlProps\n *\n * @property {(WPLinkControlSetting[])=} settings An array of settings objects. Each object will used to\n * render a `ToggleControl` for that setting.\n * @property {boolean=} forceIsEditingLink If passed as either `true` or `false`, controls the\n * internal editing state of the component to respective\n * show or not show the URL input field.\n * @property {WPLinkControlValue=} value Current link value.\n * @property {WPLinkControlOnChangeProp=} onChange Value change handler, called with the updated value if\n * the user selects a new link or updates settings.\n * @property {boolean=} noDirectEntry Whether to allow turning a URL-like search query directly into a link.\n * @property {boolean=} showSuggestions Whether to present suggestions when typing the URL.\n * @property {boolean=} showInitialSuggestions Whether to present initial suggestions immediately.\n * @property {boolean=} withCreateSuggestion Whether to allow creation of link value from suggestion.\n * @property {Object=} suggestionsQuery Query parameters to pass along to wp.blockEditor.__experimentalFetchLinkSuggestions.\n * @property {boolean=} noURLSuggestion Whether to add a fallback suggestion which treats the search query as a URL.\n * @property {string|Function|undefined} createSuggestionButtonText The text to use in the button that calls createSuggestion.\n * @property {Function} renderControlBottom Optional controls to be rendered at the bottom of the component.\n */\n\n/**\n * Renders a link control. A link control is a controlled input which maintains\n * a value associated with a link (HTML anchor element) and relevant settings\n * for how that link is expected to behave.\n *\n * @param {WPLinkControlProps} props Component props.\n */\nfunction LinkControl( {\n\tsearchInputPlaceholder,\n\tvalue,\n\tsettings = DEFAULT_LINK_SETTINGS,\n\tonChange = noop,\n\tonRemove,\n\tnoDirectEntry = false,\n\tshowSuggestions = true,\n\tshowInitialSuggestions,\n\tforceIsEditingLink,\n\tcreateSuggestion,\n\twithCreateSuggestion,\n\tinputValue: propInputValue = '',\n\tsuggestionsQuery = {},\n\tnoURLSuggestion = false,\n\tcreateSuggestionButtonText,\n\thasRichPreviews = false,\n\thasTextControl = false,\n\trenderControlBottom = null,\n} ) {\n\tif ( withCreateSuggestion === undefined && createSuggestion ) {\n\t\twithCreateSuggestion = true;\n\t}\n\n\tconst isMounting = useRef( true );\n\tconst wrapperNode = useRef();\n\tconst textInputRef = useRef();\n\n\tconst [ internalInputValue, setInternalInputValue ] = useState(\n\t\tvalue?.url || ''\n\t);\n\tconst [ internalTextValue, setInternalTextValue ] = useState(\n\t\tvalue?.title || ''\n\t);\n\tconst currentInputValue = propInputValue || internalInputValue;\n\tconst [ isEditingLink, setIsEditingLink ] = useState(\n\t\tforceIsEditingLink !== undefined\n\t\t\t? forceIsEditingLink\n\t\t\t: ! value || ! value.url\n\t);\n\tconst isEndingEditWithFocus = useRef( false );\n\n\tconst currentInputIsEmpty = ! currentInputValue?.trim()?.length;\n\n\tconst { createPage, isCreatingPage, errorMessage } = useCreatePage(\n\t\tcreateSuggestion\n\t);\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tforceIsEditingLink !== undefined &&\n\t\t\tforceIsEditingLink !== isEditingLink\n\t\t) {\n\t\t\tsetIsEditingLink( forceIsEditingLink );\n\t\t}\n\t}, [ forceIsEditingLink ] );\n\n\tuseEffect( () => {\n\t\t// We don't auto focus into the Link UI on mount\n\t\t// because otherwise using the keyboard to select text\n\t\t// *within* the link format is not possible.\n\t\tif ( isMounting.current ) {\n\t\t\tisMounting.current = false;\n\t\t\treturn;\n\t\t}\n\t\t// Unless we are mounting, we always want to focus either:\n\t\t// - the URL input\n\t\t// - the first focusable element in the Link UI.\n\t\t// But in editing mode if there is a text input present then\n\t\t// the URL input is at index 1. If not then it is at index 0.\n\t\tconst whichFocusTargetIndex = textInputRef?.current ? 1 : 0;\n\n\t\t// Scenario - when:\n\t\t// - switching between editable and non editable LinkControl\n\t\t// - clicking on a link\n\t\t// ...then move focus to the *first* element to avoid focus loss\n\t\t// and to ensure focus is *within* the Link UI.\n\t\tconst nextFocusTarget =\n\t\t\tfocus.focusable.find( wrapperNode.current )[\n\t\t\t\twhichFocusTargetIndex\n\t\t\t] || wrapperNode.current;\n\n\t\tnextFocusTarget.focus();\n\n\t\tisEndingEditWithFocus.current = false;\n\t}, [ isEditingLink, isCreatingPage ] );\n\n\tuseEffect( () => {\n\t\t/**\n\t\t * If the value's `text` property changes then sync this\n\t\t * back up with state.\n\t\t */\n\t\tif ( value?.title && value.title !== internalTextValue ) {\n\t\t\tsetInternalTextValue( value.title );\n\t\t}\n\n\t\t/**\n\t\t * Update the state value internalInputValue if the url value changes\n\t\t * for example when clicking on another anchor\n\t\t */\n\t\tif ( value?.url ) {\n\t\t\tsetInternalInputValue( value.url );\n\t\t}\n\t}, [ value ] );\n\n\t/**\n\t * Cancels editing state and marks that focus may need to be restored after\n\t * the next render, if focus was within the wrapper when editing finished.\n\t */\n\tfunction stopEditing() {\n\t\tisEndingEditWithFocus.current = !! wrapperNode.current?.contains(\n\t\t\twrapperNode.current.ownerDocument.activeElement\n\t\t);\n\n\t\tsetIsEditingLink( false );\n\t}\n\n\tconst handleSelectSuggestion = ( updatedValue ) => {\n\t\tonChange( {\n\t\t\t...updatedValue,\n\t\t\ttitle: internalTextValue || updatedValue?.title,\n\t\t} );\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmit = () => {\n\t\tif (\n\t\t\tcurrentInputValue !== value?.url ||\n\t\t\tinternalTextValue !== value?.title\n\t\t) {\n\t\t\tonChange( {\n\t\t\t\turl: currentInputValue,\n\t\t\t\ttitle: internalTextValue,\n\t\t\t} );\n\t\t}\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmitWithEnter = ( event ) => {\n\t\tconst { keyCode } = event;\n\t\tif (\n\t\t\tkeyCode === ENTER &&\n\t\t\t! currentInputIsEmpty // Disallow submitting empty values.\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t\thandleSubmit();\n\t\t}\n\t};\n\n\tconst shownUnlinkControl =\n\t\tonRemove && value && ! isEditingLink && ! isCreatingPage;\n\n\tconst showSettingsDrawer = !! settings?.length;\n\n\t// Only show text control once a URL value has been committed\n\t// and it isn't just empty whitespace.\n\t// See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.\n\tconst showTextControl = value?.url?.trim()?.length > 0 && hasTextControl;\n\n\treturn (\n\t\t<div\n\t\t\ttabIndex={ -1 }\n\t\t\tref={ wrapperNode }\n\t\t\tclassName=\"block-editor-link-control\"\n\t\t>\n\t\t\t{ isCreatingPage && (\n\t\t\t\t<div className=\"block-editor-link-control__loading\">\n\t\t\t\t\t<Spinner /> { __( 'Creating' ) }…\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ ( isEditingLink || ! value ) && ! isCreatingPage && (\n\t\t\t\t<>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames( {\n\t\t\t\t\t\t\t'block-editor-link-control__search-input-wrapper': true,\n\t\t\t\t\t\t\t'has-text-control': showTextControl,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ showTextControl && (\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\tref={ textInputRef }\n\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__text-content\"\n\t\t\t\t\t\t\t\tlabel=\"Text\"\n\t\t\t\t\t\t\t\tvalue={ internalTextValue }\n\t\t\t\t\t\t\t\tonChange={ setInternalTextValue }\n\t\t\t\t\t\t\t\tonKeyDown={ handleSubmitWithEnter }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t<LinkControlSearchInput\n\t\t\t\t\t\t\tcurrentLink={ value }\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__search-input\"\n\t\t\t\t\t\t\tplaceholder={ searchInputPlaceholder }\n\t\t\t\t\t\t\tvalue={ currentInputValue }\n\t\t\t\t\t\t\twithCreateSuggestion={ withCreateSuggestion }\n\t\t\t\t\t\t\tonCreateSuggestion={ createPage }\n\t\t\t\t\t\t\tonChange={ setInternalInputValue }\n\t\t\t\t\t\t\tonSelect={ handleSelectSuggestion }\n\t\t\t\t\t\t\tshowInitialSuggestions={ showInitialSuggestions }\n\t\t\t\t\t\t\tallowDirectEntry={ ! noDirectEntry }\n\t\t\t\t\t\t\tshowSuggestions={ showSuggestions }\n\t\t\t\t\t\t\tsuggestionsQuery={ suggestionsQuery }\n\t\t\t\t\t\t\twithURLSuggestion={ ! noURLSuggestion }\n\t\t\t\t\t\t\tcreateSuggestionButtonText={\n\t\t\t\t\t\t\t\tcreateSuggestionButtonText\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tuseLabel={ showTextControl }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div className=\"block-editor-link-control__search-actions\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tonClick={ handleSubmit }\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Submit' ) }\n\t\t\t\t\t\t\t\t\ticon={ keyboardReturn }\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-submit\"\n\t\t\t\t\t\t\t\t\tdisabled={ currentInputIsEmpty } // Disallow submitting empty values.\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</LinkControlSearchInput>\n\t\t\t\t\t</div>\n\t\t\t\t\t{ errorMessage && (\n\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-error\"\n\t\t\t\t\t\t\tstatus=\"error\"\n\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ errorMessage }\n\t\t\t\t\t\t</Notice>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ value && ! isEditingLink && ! isCreatingPage && (\n\t\t\t\t<LinkPreview\n\t\t\t\t\tkey={ value?.url } // force remount when URL changes to avoid race conditions for rich previews\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonEditClick={ () => setIsEditingLink( true ) }\n\t\t\t\t\thasRichPreviews={ hasRichPreviews }\n\t\t\t\t\thasUnlinkControl={ shownUnlinkControl }\n\t\t\t\t\tonRemove={ onRemove }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ showSettingsDrawer && (\n\t\t\t\t<div className=\"block-editor-link-control__tools\">\n\t\t\t\t\t<LinkControlSettingsDrawer\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ renderControlBottom && renderControlBottom() }\n\t\t</div>\n\t);\n}\n\nLinkControl.ViewerFill = ViewerFill;\n\nexport default LinkControl;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/index.js"],"names":["classnames","Button","Spinner","Notice","TextControl","keyboardReturn","__","useRef","useState","useEffect","focus","ENTER","LinkControlSettingsDrawer","LinkControlSearchInput","LinkPreview","useCreatePage","ViewerFill","DEFAULT_LINK_SETTINGS","noop","LinkControl","searchInputPlaceholder","value","settings","onChange","onRemove","noDirectEntry","showSuggestions","showInitialSuggestions","forceIsEditingLink","createSuggestion","withCreateSuggestion","inputValue","propInputValue","suggestionsQuery","noURLSuggestion","createSuggestionButtonText","hasRichPreviews","hasTextControl","renderControlBottom","undefined","isMounting","wrapperNode","textInputRef","internalInputValue","setInternalInputValue","url","internalTextValue","setInternalTextValue","title","currentInputValue","isEditingLink","setIsEditingLink","isEndingEditWithFocus","currentInputIsEmpty","trim","length","createPage","isCreatingPage","errorMessage","current","whichFocusTargetIndex","nextFocusTarget","focusable","find","stopEditing","contains","ownerDocument","activeElement","handleSelectSuggestion","updatedValue","handleSubmit","handleSubmitWithEnter","event","keyCode","preventDefault","shownUnlinkControl","showSettingsDrawer","showTextControl"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,EAAiBC,OAAjB,EAA0BC,MAA1B,EAAkCC,WAAlC,QAAqD,uBAArD;AACA,SAASC,cAAT,QAA+B,kBAA/B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,EAAiBC,QAAjB,EAA2BC,SAA3B,QAA4C,oBAA5C;AACA,SAASC,KAAT,QAAsB,gBAAtB;AACA,SAASC,KAAT,QAAsB,qBAAtB;AAEA;AACA;AACA;;AACA,OAAOC,yBAAP,MAAsC,mBAAtC;AACA,OAAOC,sBAAP,MAAmC,gBAAnC;AACA,OAAOC,WAAP,MAAwB,gBAAxB;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,SAASC,UAAT,QAA2B,eAA3B;AACA,SAASC,qBAAT,QAAsC,aAAtC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AACA;AACA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,WAAT,OAmBI;AAAA;;AAAA,MAnBkB;AACrBC,IAAAA,sBADqB;AAErBC,IAAAA,KAFqB;AAGrBC,IAAAA,QAAQ,GAAGL,qBAHU;AAIrBM,IAAAA,QAAQ,GAAGL,IAJU;AAKrBM,IAAAA,QALqB;AAMrBC,IAAAA,aAAa,GAAG,KANK;AAOrBC,IAAAA,e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;AACC,IAAA,KAAK,EAAGvD,KADT;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,QAAQ,EAAGC;AAHZ,IADD,CApFF,EA4FGe,mBAAmB,IAAIA,mBAAmB,EA5F7C,CADD;AAgGA;;AAEDnB,WAAW,CAACH,UAAZ,GAAyBA,UAAzB;AAEA,eAAeG,WAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button, Spinner, Notice, TextControl } from '@wordpress/components';\nimport { keyboardReturn } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useState, useEffect } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport { ENTER } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport LinkControlSettingsDrawer from './settings-drawer';\nimport LinkControlSearchInput from './search-input';\nimport LinkPreview from './link-preview';\nimport useCreatePage from './use-create-page';\nimport { ViewerFill } from './viewer-slot';\nimport { DEFAULT_LINK_SETTINGS } from './constants';\n\n/**\n * Default properties associated with a link control value.\n *\n * @typedef WPLinkControlDefaultValue\n *\n * @property {string} url Link URL.\n * @property {string=} title Link title.\n * @property {boolean=} opensInNewTab Whether link should open in a new browser\n * tab. This value is only assigned if not\n * providing a custom `settings` prop.\n */\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Custom settings values associated with a link.\n *\n * @typedef {{[setting:string]:any}} WPLinkControlSettingsValue\n */\n/* eslint-enable */\n\n/**\n * Custom settings values associated with a link.\n *\n * @typedef WPLinkControlSetting\n *\n * @property {string} id Identifier to use as property for setting value.\n * @property {string} title Human-readable label to show in user interface.\n */\n\n/**\n * Properties associated with a link control value, composed as a union of the\n * default properties and any custom settings values.\n *\n * @typedef {WPLinkControlDefaultValue&WPLinkControlSettingsValue} WPLinkControlValue\n */\n\n/** @typedef {(nextValue:WPLinkControlValue)=>void} WPLinkControlOnChangeProp */\n\n/**\n * Properties associated with a search suggestion used within the LinkControl.\n *\n * @typedef WPLinkControlSuggestion\n *\n * @property {string} id Identifier to use to uniquely identify the suggestion.\n * @property {string} type Identifies the type of the suggestion (eg: `post`,\n * `page`, `url`...etc)\n * @property {string} title Human-readable label to show in user interface.\n * @property {string} url A URL for the suggestion.\n */\n\n/** @typedef {(title:string)=>WPLinkControlSuggestion} WPLinkControlCreateSuggestionProp */\n\n/**\n * @typedef WPLinkControlProps\n *\n * @property {(WPLinkControlSetting[])=} settings An array of settings objects. Each object will used to\n * render a `ToggleControl` for that setting.\n * @property {boolean=} forceIsEditingLink If passed as either `true` or `false`, controls the\n * internal editing state of the component to respective\n * show or not show the URL input field.\n * @property {WPLinkControlValue=} value Current link value.\n * @property {WPLinkControlOnChangeProp=} onChange Value change handler, called with the updated value if\n * the user selects a new link or updates settings.\n * @property {boolean=} noDirectEntry Whether to allow turning a URL-like search query directly into a link.\n * @property {boolean=} showSuggestions Whether to present suggestions when typing the URL.\n * @property {boolean=} showInitialSuggestions Whether to present initial suggestions immediately.\n * @property {boolean=} withCreateSuggestion Whether to allow creation of link value from suggestion.\n * @property {Object=} suggestionsQuery Query parameters to pass along to wp.blockEditor.__experimentalFetchLinkSuggestions.\n * @property {boolean=} noURLSuggestion Whether to add a fallback suggestion which treats the search query as a URL.\n * @property {string|Function|undefined} createSuggestionButtonText The text to use in the button that calls createSuggestion.\n * @property {Function} renderControlBottom Optional controls to be rendered at the bottom of the component.\n */\n\nconst noop = () => {};\n\n/**\n * Renders a link control. A link control is a controlled input which maintains\n * a value associated with a link (HTML anchor element) and relevant settings\n * for how that link is expected to behave.\n *\n * @param {WPLinkControlProps} props Component props.\n */\nfunction LinkControl( {\n\tsearchInputPlaceholder,\n\tvalue,\n\tsettings = DEFAULT_LINK_SETTINGS,\n\tonChange = noop,\n\tonRemove,\n\tnoDirectEntry = false,\n\tshowSuggestions = true,\n\tshowInitialSuggestions,\n\tforceIsEditingLink,\n\tcreateSuggestion,\n\twithCreateSuggestion,\n\tinputValue: propInputValue = '',\n\tsuggestionsQuery = {},\n\tnoURLSuggestion = false,\n\tcreateSuggestionButtonText,\n\thasRichPreviews = false,\n\thasTextControl = false,\n\trenderControlBottom = null,\n} ) {\n\tif ( withCreateSuggestion === undefined && createSuggestion ) {\n\t\twithCreateSuggestion = true;\n\t}\n\n\tconst isMounting = useRef( true );\n\tconst wrapperNode = useRef();\n\tconst textInputRef = useRef();\n\n\tconst [ internalInputValue, setInternalInputValue ] = useState(\n\t\tvalue?.url || ''\n\t);\n\tconst [ internalTextValue, setInternalTextValue ] = useState(\n\t\tvalue?.title || ''\n\t);\n\tconst currentInputValue = propInputValue || internalInputValue;\n\tconst [ isEditingLink, setIsEditingLink ] = useState(\n\t\tforceIsEditingLink !== undefined\n\t\t\t? forceIsEditingLink\n\t\t\t: ! value || ! value.url\n\t);\n\tconst isEndingEditWithFocus = useRef( false );\n\n\tconst currentInputIsEmpty = ! currentInputValue?.trim()?.length;\n\n\tconst { createPage, isCreatingPage, errorMessage } =\n\t\tuseCreatePage( createSuggestion );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tforceIsEditingLink !== undefined &&\n\t\t\tforceIsEditingLink !== isEditingLink\n\t\t) {\n\t\t\tsetIsEditingLink( forceIsEditingLink );\n\t\t}\n\t}, [ forceIsEditingLink ] );\n\n\tuseEffect( () => {\n\t\t// We don't auto focus into the Link UI on mount\n\t\t// because otherwise using the keyboard to select text\n\t\t// *within* the link format is not possible.\n\t\tif ( isMounting.current ) {\n\t\t\tisMounting.current = false;\n\t\t\treturn;\n\t\t}\n\t\t// Unless we are mounting, we always want to focus either:\n\t\t// - the URL input\n\t\t// - the first focusable element in the Link UI.\n\t\t// But in editing mode if there is a text input present then\n\t\t// the URL input is at index 1. If not then it is at index 0.\n\t\tconst whichFocusTargetIndex = textInputRef?.current ? 1 : 0;\n\n\t\t// Scenario - when:\n\t\t// - switching between editable and non editable LinkControl\n\t\t// - clicking on a link\n\t\t// ...then move focus to the *first* element to avoid focus loss\n\t\t// and to ensure focus is *within* the Link UI.\n\t\tconst nextFocusTarget =\n\t\t\tfocus.focusable.find( wrapperNode.current )[\n\t\t\t\twhichFocusTargetIndex\n\t\t\t] || wrapperNode.current;\n\n\t\tnextFocusTarget.focus();\n\n\t\tisEndingEditWithFocus.current = false;\n\t}, [ isEditingLink, isCreatingPage ] );\n\n\tuseEffect( () => {\n\t\t/**\n\t\t * If the value's `text` property changes then sync this\n\t\t * back up with state.\n\t\t */\n\t\tif ( value?.title && value.title !== internalTextValue ) {\n\t\t\tsetInternalTextValue( value.title );\n\t\t}\n\n\t\t/**\n\t\t * Update the state value internalInputValue if the url value changes\n\t\t * for example when clicking on another anchor\n\t\t */\n\t\tif ( value?.url ) {\n\t\t\tsetInternalInputValue( value.url );\n\t\t}\n\t}, [ value ] );\n\n\t/**\n\t * Cancels editing state and marks that focus may need to be restored after\n\t * the next render, if focus was within the wrapper when editing finished.\n\t */\n\tfunction stopEditing() {\n\t\tisEndingEditWithFocus.current = !! wrapperNode.current?.contains(\n\t\t\twrapperNode.current.ownerDocument.activeElement\n\t\t);\n\n\t\tsetIsEditingLink( false );\n\t}\n\n\tconst handleSelectSuggestion = ( updatedValue ) => {\n\t\tonChange( {\n\t\t\t...updatedValue,\n\t\t\ttitle: internalTextValue || updatedValue?.title,\n\t\t} );\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmit = () => {\n\t\tif (\n\t\t\tcurrentInputValue !== value?.url ||\n\t\t\tinternalTextValue !== value?.title\n\t\t) {\n\t\t\tonChange( {\n\t\t\t\t...value,\n\t\t\t\turl: currentInputValue,\n\t\t\t\ttitle: internalTextValue,\n\t\t\t} );\n\t\t}\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmitWithEnter = ( event ) => {\n\t\tconst { keyCode } = event;\n\t\tif (\n\t\t\tkeyCode === ENTER &&\n\t\t\t! currentInputIsEmpty // Disallow submitting empty values.\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t\thandleSubmit();\n\t\t}\n\t};\n\n\tconst shownUnlinkControl =\n\t\tonRemove && value && ! isEditingLink && ! isCreatingPage;\n\n\tconst showSettingsDrawer = !! settings?.length;\n\n\t// Only show text control once a URL value has been committed\n\t// and it isn't just empty whitespace.\n\t// See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.\n\tconst showTextControl = value?.url?.trim()?.length > 0 && hasTextControl;\n\n\treturn (\n\t\t<div\n\t\t\ttabIndex={ -1 }\n\t\t\tref={ wrapperNode }\n\t\t\tclassName=\"block-editor-link-control\"\n\t\t>\n\t\t\t{ isCreatingPage && (\n\t\t\t\t<div className=\"block-editor-link-control__loading\">\n\t\t\t\t\t<Spinner /> { __( 'Creating' ) }…\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ ( isEditingLink || ! value ) && ! isCreatingPage && (\n\t\t\t\t<>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames( {\n\t\t\t\t\t\t\t'block-editor-link-control__search-input-wrapper': true,\n\t\t\t\t\t\t\t'has-text-control': showTextControl,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ showTextControl && (\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\tref={ textInputRef }\n\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__text-content\"\n\t\t\t\t\t\t\t\tlabel=\"Text\"\n\t\t\t\t\t\t\t\tvalue={ internalTextValue }\n\t\t\t\t\t\t\t\tonChange={ setInternalTextValue }\n\t\t\t\t\t\t\t\tonKeyDown={ handleSubmitWithEnter }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t<LinkControlSearchInput\n\t\t\t\t\t\t\tcurrentLink={ value }\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__search-input\"\n\t\t\t\t\t\t\tplaceholder={ searchInputPlaceholder }\n\t\t\t\t\t\t\tvalue={ currentInputValue }\n\t\t\t\t\t\t\twithCreateSuggestion={ withCreateSuggestion }\n\t\t\t\t\t\t\tonCreateSuggestion={ createPage }\n\t\t\t\t\t\t\tonChange={ setInternalInputValue }\n\t\t\t\t\t\t\tonSelect={ handleSelectSuggestion }\n\t\t\t\t\t\t\tshowInitialSuggestions={ showInitialSuggestions }\n\t\t\t\t\t\t\tallowDirectEntry={ ! noDirectEntry }\n\t\t\t\t\t\t\tshowSuggestions={ showSuggestions }\n\t\t\t\t\t\t\tsuggestionsQuery={ suggestionsQuery }\n\t\t\t\t\t\t\twithURLSuggestion={ ! noURLSuggestion }\n\t\t\t\t\t\t\tcreateSuggestionButtonText={\n\t\t\t\t\t\t\t\tcreateSuggestionButtonText\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tuseLabel={ showTextControl }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div className=\"block-editor-link-control__search-actions\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tonClick={ handleSubmit }\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Submit' ) }\n\t\t\t\t\t\t\t\t\ticon={ keyboardReturn }\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-submit\"\n\t\t\t\t\t\t\t\t\tdisabled={ currentInputIsEmpty } // Disallow submitting empty values.\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</LinkControlSearchInput>\n\t\t\t\t\t</div>\n\t\t\t\t\t{ errorMessage && (\n\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-error\"\n\t\t\t\t\t\t\tstatus=\"error\"\n\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ errorMessage }\n\t\t\t\t\t\t</Notice>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ value && ! isEditingLink && ! isCreatingPage && (\n\t\t\t\t<LinkPreview\n\t\t\t\t\tkey={ value?.url } // force remount when URL changes to avoid race conditions for rich previews\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonEditClick={ () => setIsEditingLink( true ) }\n\t\t\t\t\thasRichPreviews={ hasRichPreviews }\n\t\t\t\t\thasUnlinkControl={ shownUnlinkControl }\n\t\t\t\t\tonRemove={ onRemove }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ showSettingsDrawer && (\n\t\t\t\t<div className=\"block-editor-link-control__tools\">\n\t\t\t\t\t<LinkControlSettingsDrawer\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ renderControlBottom && renderControlBottom() }\n\t\t</div>\n\t);\n}\n\nLinkControl.ViewerFill = ViewerFill;\n\nexport default LinkControl;\n"]}
@@ -5,7 +5,6 @@ import { createElement } from "@wordpress/element";
5
5
  * External dependencies
6
6
  */
7
7
  import classnames from 'classnames';
8
- import { isFunction } from 'lodash';
9
8
  /**
10
9
  * WordPress dependencies
11
10
  */
@@ -30,7 +29,7 @@ export const LinkControlSearchCreate = _ref => {
30
29
  let text;
31
30
 
32
31
  if (buttonText) {
33
- text = isFunction(buttonText) ? buttonText(searchTerm) : buttonText;
32
+ text = typeof buttonText === 'function' ? buttonText(searchTerm) : buttonText;
34
33
  } else {
35
34
  text = createInterpolateElement(sprintf(
36
35
  /* translators: %s: search term. */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-create-button.js"],"names":["classnames","isFunction","__","sprintf","Button","createInterpolateElement","Icon","plus","LinkControlSearchCreate","searchTerm","onClick","itemProps","isSelected","buttonText","text","mark"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,UAAT,QAA2B,QAA3B;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,wBAAT,QAAyC,oBAAzC;AACA,SAASC,IAAT,EAAeC,IAAf,QAA2B,kBAA3B;AAEA,OAAO,MAAMC,uBAAuB,GAAG,QAMhC;AAAA,MANkC;AACxCC,IAAAA,UADwC;AAExCC,IAAAA,OAFwC;AAGxCC,IAAAA,SAHwC;AAIxCC,IAAAA,UAJwC;AAKxCC,IAAAA;AALwC,GAMlC;;AACN,MAAK,CAAEJ,UAAP,EAAoB;AACnB,WAAO,IAAP;AACA;;AAED,MAAIK,IAAJ;;AACA,MAAKD,UAAL,EAAkB;AACjBC,IAAAA,IAAI,GAAGb,UAAU,CAAEY,UAAF,CAAV,GAA2BA,UAAU,CAAEJ,UAAF,CAArC,GAAsDI,UAA7D;AACA,GAFD,MAEO;AACNC,IAAAA,IAAI,GAAGT,wBAAwB,CAC9BF,OAAO;AACN;AACAD,IAAAA,EAAE,CAAE,yBAAF,CAFI,EAGNO,UAHM,CADuB,EAM9B;AAAEM,MAAAA,IAAI,EAAE;AAAR,KAN8B,CAA/B;AAQA;;AAED,SACC,cAAC,MAAD,eACMJ,SADN;AAEC,IAAA,SAAS,EAAGX,UAAU,CACrB,iFADqB,EAErB;AACC,qBAAeY;AADhB,KAFqB,CAFvB;AAQC,IAAA,OAAO,EAAGF;AARX,MAUC,cAAC,IAAD;AACC,IAAA,SAAS,EAAC,6CADX;AAEC,IAAA,IAAI,EAAGH;AAFR,IAVD,EAeC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACGO,IADH,CADD,CAfD,CADD;AAuBA,CAhDM;AAkDP,eAAeN,uBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { isFunction } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { Icon, plus } from '@wordpress/icons';\n\nexport const LinkControlSearchCreate = ( {\n\tsearchTerm,\n\tonClick,\n\titemProps,\n\tisSelected,\n\tbuttonText,\n} ) => {\n\tif ( ! searchTerm ) {\n\t\treturn null;\n\t}\n\n\tlet text;\n\tif ( buttonText ) {\n\t\ttext = isFunction( buttonText ) ? buttonText( searchTerm ) : buttonText;\n\t} else {\n\t\ttext = createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: search term. */\n\t\t\t\t__( 'Create: <mark>%s</mark>' ),\n\t\t\t\tsearchTerm\n\t\t\t),\n\t\t\t{ mark: <mark /> }\n\t\t);\n\t}\n\n\treturn (\n\t\t<Button\n\t\t\t{ ...itemProps }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-link-control__search-create block-editor-link-control__search-item',\n\t\t\t\t{\n\t\t\t\t\t'is-selected': isSelected,\n\t\t\t\t}\n\t\t\t) }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t<Icon\n\t\t\t\tclassName=\"block-editor-link-control__search-item-icon\"\n\t\t\t\ticon={ plus }\n\t\t\t/>\n\n\t\t\t<span className=\"block-editor-link-control__search-item-header\">\n\t\t\t\t<span className=\"block-editor-link-control__search-item-title\">\n\t\t\t\t\t{ text }\n\t\t\t\t</span>\n\t\t\t</span>\n\t\t</Button>\n\t);\n};\n\nexport default LinkControlSearchCreate;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-create-button.js"],"names":["classnames","__","sprintf","Button","createInterpolateElement","Icon","plus","LinkControlSearchCreate","searchTerm","onClick","itemProps","isSelected","buttonText","text","mark"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,wBAAT,QAAyC,oBAAzC;AACA,SAASC,IAAT,EAAeC,IAAf,QAA2B,kBAA3B;AAEA,OAAO,MAAMC,uBAAuB,GAAG,QAMhC;AAAA,MANkC;AACxCC,IAAAA,UADwC;AAExCC,IAAAA,OAFwC;AAGxCC,IAAAA,SAHwC;AAIxCC,IAAAA,UAJwC;AAKxCC,IAAAA;AALwC,GAMlC;;AACN,MAAK,CAAEJ,UAAP,EAAoB;AACnB,WAAO,IAAP;AACA;;AAED,MAAIK,IAAJ;;AACA,MAAKD,UAAL,EAAkB;AACjBC,IAAAA,IAAI,GACH,OAAOD,UAAP,KAAsB,UAAtB,GACGA,UAAU,CAAEJ,UAAF,CADb,GAEGI,UAHJ;AAIA,GALD,MAKO;AACNC,IAAAA,IAAI,GAAGT,wBAAwB,CAC9BF,OAAO;AACN;AACAD,IAAAA,EAAE,CAAE,yBAAF,CAFI,EAGNO,UAHM,CADuB,EAM9B;AAAEM,MAAAA,IAAI,EAAE;AAAR,KAN8B,CAA/B;AAQA;;AAED,SACC,cAAC,MAAD,eACMJ,SADN;AAEC,IAAA,SAAS,EAAGV,UAAU,CACrB,iFADqB,EAErB;AACC,qBAAeW;AADhB,KAFqB,CAFvB;AAQC,IAAA,OAAO,EAAGF;AARX,MAUC,cAAC,IAAD;AACC,IAAA,SAAS,EAAC,6CADX;AAEC,IAAA,IAAI,EAAGH;AAFR,IAVD,EAeC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACGO,IADH,CADD,CAfD,CADD;AAuBA,CAnDM;AAqDP,eAAeN,uBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { Icon, plus } from '@wordpress/icons';\n\nexport const LinkControlSearchCreate = ( {\n\tsearchTerm,\n\tonClick,\n\titemProps,\n\tisSelected,\n\tbuttonText,\n} ) => {\n\tif ( ! searchTerm ) {\n\t\treturn null;\n\t}\n\n\tlet text;\n\tif ( buttonText ) {\n\t\ttext =\n\t\t\ttypeof buttonText === 'function'\n\t\t\t\t? buttonText( searchTerm )\n\t\t\t\t: buttonText;\n\t} else {\n\t\ttext = createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: search term. */\n\t\t\t\t__( 'Create: <mark>%s</mark>' ),\n\t\t\t\tsearchTerm\n\t\t\t),\n\t\t\t{ mark: <mark /> }\n\t\t);\n\t}\n\n\treturn (\n\t\t<Button\n\t\t\t{ ...itemProps }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-link-control__search-create block-editor-link-control__search-item',\n\t\t\t\t{\n\t\t\t\t\t'is-selected': isSelected,\n\t\t\t\t}\n\t\t\t) }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t<Icon\n\t\t\t\tclassName=\"block-editor-link-control__search-item-icon\"\n\t\t\t\ticon={ plus }\n\t\t\t/>\n\n\t\t\t<span className=\"block-editor-link-control__search-item-header\">\n\t\t\t\t<span className=\"block-editor-link-control__search-item-title\">\n\t\t\t\t\t{ text }\n\t\t\t\t</span>\n\t\t\t</span>\n\t\t</Button>\n\t);\n};\n\nexport default LinkControlSearchCreate;\n"]}
@@ -3,7 +3,7 @@ import { createElement } from "@wordpress/element";
3
3
  /**
4
4
  * External dependencies
5
5
  */
6
- import { noop, omit } from 'lodash';
6
+ import { omit } from 'lodash';
7
7
  import classnames from 'classnames';
8
8
  /**
9
9
  * WordPress dependencies
@@ -25,6 +25,8 @@ import useSearchHandler from './use-search-handler'; // Must be a function as ot
25
25
 
26
26
  const noopSearchHandler = () => Promise.resolve([]);
27
27
 
28
+ const noop = () => {};
29
+
28
30
  const LinkControlSearchInput = forwardRef((_ref, ref) => {
29
31
  let {
30
32
  value,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-input.js"],"names":["noop","omit","classnames","useInstanceId","forwardRef","useState","__","URLInput","LinkControlSearchResults","CREATE_TYPE","useSearchHandler","noopSearchHandler","Promise","resolve","LinkControlSearchInput","ref","value","children","currentLink","className","placeholder","withCreateSuggestion","onCreateSuggestion","onChange","onSelect","showSuggestions","renderSuggestions","props","fetchSuggestions","allowDirectEntry","showInitialSuggestions","suggestionsQuery","withURLSuggestion","createSuggestionButtonText","useLabel","genericSearchHandler","searchHandler","instanceId","focusedSuggestion","setFocusedSuggestion","onInputChange","selection","suggestion","handleRenderSuggestions","currentInputValue","handleSuggestionClick","onSuggestionSelected","selectedSuggestion","type","title","url","e","Object","keys","length","inputClasses","undefined","event","hasSuggestion","trim","preventDefault"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,EAAeC,IAAf,QAA2B,QAA3B;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA;AACA;AACA;;AACA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,UAAT,EAAqBC,QAArB,QAAqC,oBAArC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,QAAyB,KAAzB;AACA,OAAOC,wBAAP,MAAqC,kBAArC;AACA,SAASC,WAAT,QAA4B,aAA5B;AACA,OAAOC,gBAAP,MAA6B,sBAA7B,C,CAEA;AACA;AACA;;AACA,MAAMC,iBAAiB,GAAG,MAAMC,OAAO,CAACC,OAAR,CAAiB,EAAjB,CAAhC;;AAEA,MAAMC,sBAAsB,GAAGV,UAAU,CACxC,OAuBCW,GAvBD,KAwBK;AAAA,MAvBJ;AACCC,IAAAA,KADD;AAECC,IAAAA,QAFD;AAGCC,IAAAA,WAAW,GAAG,EAHf;AAICC,IAAAA,SAAS,GAAG,IAJb;AAKCC,IAAAA,WAAW,GAAG,IALf;AAMCC,IAAAA,oBAAoB,GAAG,KANxB;AAOCC,IAAAA,kBAAkB,GAAGtB,IAPtB;AAQCuB,IAAAA,QAAQ,GAAGvB,IARZ;AASCwB,IAAAA,QAAQ,GAAGxB,IATZ;AAUCyB,IAAAA,eAAe,GAAG,IAVnB;AAWCC,IAAAA,iBA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CAAoC,EACnCN,sBAZF;AAcC,IAAA,QAAQ,EAAG,CAAEY,UAAF,EAAce,KAAd,KAAyB;AAAA;;AACnC,YAAMC,aAAa,GAAGhB,UAAU,IAAIJ,iBAApC,CADmC,CAGnC;AACA;;AACA,UAAK,CAAEoB,aAAF,IAAmB,EAAE1C,KAAF,aAAEA,KAAF,8BAAEA,KAAK,CAAE2C,IAAP,EAAF,wCAAE,YAAeL,MAAjB,CAAxB,EAAkD;AACjDG,QAAAA,KAAK,CAACG,cAAN;AACA,OAFD,MAEO;AACNd,QAAAA,oBAAoB,CACnBY,aAAa,IAAI;AAAER,UAAAA,GAAG,EAAElC;AAAP,SADE,CAApB;AAGA;AACD,KA1BF;AA2BC,IAAA,GAAG,EAAGD;AA3BP,IADD,EA8BGE,QA9BH,CADD;AAkCA,CArIuC,CAAzC;AAwIA,eAAeH,sBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { noop, omit } from 'lodash';\nimport classnames from 'classnames';\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { forwardRef, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { URLInput } from '../';\nimport LinkControlSearchResults from './search-results';\nimport { CREATE_TYPE } from './constants';\nimport useSearchHandler from './use-search-handler';\n\n// Must be a function as otherwise URLInput will default\n// to the fetchLinkSuggestions passed in block editor settings\n// which will cause an unintended http request.\nconst noopSearchHandler = () => Promise.resolve( [] );\n\nconst LinkControlSearchInput = forwardRef(\n\t(\n\t\t{\n\t\t\tvalue,\n\t\t\tchildren,\n\t\t\tcurrentLink = {},\n\t\t\tclassName = null,\n\t\t\tplaceholder = null,\n\t\t\twithCreateSuggestion = false,\n\t\t\tonCreateSuggestion = noop,\n\t\t\tonChange = noop,\n\t\t\tonSelect = noop,\n\t\t\tshowSuggestions = true,\n\t\t\trenderSuggestions = ( props ) => (\n\t\t\t\t<LinkControlSearchResults { ...props } />\n\t\t\t),\n\t\t\tfetchSuggestions = null,\n\t\t\tallowDirectEntry = true,\n\t\t\tshowInitialSuggestions = false,\n\t\t\tsuggestionsQuery = {},\n\t\t\twithURLSuggestion = true,\n\t\t\tcreateSuggestionButtonText,\n\t\t\tuseLabel = false,\n\t\t},\n\t\tref\n\t) => {\n\t\tconst genericSearchHandler = useSearchHandler(\n\t\t\tsuggestionsQuery,\n\t\t\tallowDirectEntry,\n\t\t\twithCreateSuggestion,\n\t\t\twithURLSuggestion\n\t\t);\n\n\t\tconst searchHandler = showSuggestions\n\t\t\t? fetchSuggestions || genericSearchHandler\n\t\t\t: noopSearchHandler;\n\n\t\tconst instanceId = useInstanceId( LinkControlSearchInput );\n\t\tconst [ focusedSuggestion, setFocusedSuggestion ] = useState();\n\n\t\t/**\n\t\t * Handles the user moving between different suggestions. Does not handle\n\t\t * choosing an individual item.\n\t\t *\n\t\t * @param {string} selection the url of the selected suggestion.\n\t\t * @param {Object} suggestion the suggestion object.\n\t\t */\n\t\tconst onInputChange = ( selection, suggestion ) => {\n\t\t\tonChange( selection );\n\t\t\tsetFocusedSuggestion( suggestion );\n\t\t};\n\n\t\tconst handleRenderSuggestions = ( props ) =>\n\t\t\trenderSuggestions( {\n\t\t\t\t...props,\n\t\t\t\tinstanceId,\n\t\t\t\twithCreateSuggestion,\n\t\t\t\tcurrentInputValue: value,\n\t\t\t\tcreateSuggestionButtonText,\n\t\t\t\tsuggestionsQuery,\n\t\t\t\thandleSuggestionClick: ( suggestion ) => {\n\t\t\t\t\tif ( props.handleSuggestionClick ) {\n\t\t\t\t\t\tprops.handleSuggestionClick( suggestion );\n\t\t\t\t\t}\n\t\t\t\t\tonSuggestionSelected( suggestion );\n\t\t\t\t},\n\t\t\t} );\n\n\t\tconst onSuggestionSelected = async ( selectedSuggestion ) => {\n\t\t\tlet suggestion = selectedSuggestion;\n\t\t\tif ( CREATE_TYPE === selectedSuggestion.type ) {\n\t\t\t\t// Create a new page and call onSelect with the output from the onCreateSuggestion callback.\n\t\t\t\ttry {\n\t\t\t\t\tsuggestion = await onCreateSuggestion(\n\t\t\t\t\t\tselectedSuggestion.title\n\t\t\t\t\t);\n\t\t\t\t\tif ( suggestion?.url ) {\n\t\t\t\t\t\tonSelect( suggestion );\n\t\t\t\t\t}\n\t\t\t\t} catch ( e ) {}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tallowDirectEntry ||\n\t\t\t\t( suggestion && Object.keys( suggestion ).length >= 1 )\n\t\t\t) {\n\t\t\t\tonSelect(\n\t\t\t\t\t// Some direct entries don't have types or IDs, and we still need to clear the previous ones.\n\t\t\t\t\t{ ...omit( currentLink, 'id', 'url' ), ...suggestion },\n\t\t\t\t\tsuggestion\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst inputClasses = classnames( className, {\n\t\t\t'has-no-label': ! useLabel,\n\t\t} );\n\n\t\treturn (\n\t\t\t<div className=\"block-editor-link-control__search-input-container\">\n\t\t\t\t<URLInput\n\t\t\t\t\tlabel={ useLabel ? 'URL' : undefined }\n\t\t\t\t\tclassName={ inputClasses }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onInputChange }\n\t\t\t\t\tplaceholder={ placeholder ?? __( 'Search or type url' ) }\n\t\t\t\t\t__experimentalRenderSuggestions={\n\t\t\t\t\t\tshowSuggestions ? handleRenderSuggestions : null\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalFetchLinkSuggestions={ searchHandler }\n\t\t\t\t\t__experimentalHandleURLSuggestions={ true }\n\t\t\t\t\t__experimentalShowInitialSuggestions={\n\t\t\t\t\t\tshowInitialSuggestions\n\t\t\t\t\t}\n\t\t\t\t\tonSubmit={ ( suggestion, event ) => {\n\t\t\t\t\t\tconst hasSuggestion = suggestion || focusedSuggestion;\n\n\t\t\t\t\t\t// If there is no suggestion and the value (ie: any manually entered URL) is empty\n\t\t\t\t\t\t// then don't allow submission otherwise we get empty links.\n\t\t\t\t\t\tif ( ! hasSuggestion && ! value?.trim()?.length ) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tonSuggestionSelected(\n\t\t\t\t\t\t\t\thasSuggestion || { url: value }\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tref={ ref }\n\t\t\t\t/>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t);\n\t}\n);\n\nexport default LinkControlSearchInput;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-input.js"],"names":["omit","classnames","useInstanceId","forwardRef","useState","__","URLInput","LinkControlSearchResults","CREATE_TYPE","useSearchHandler","noopSearchHandler","Promise","resolve","noop","LinkControlSearchInput","ref","value","children","currentLink","className","placeholder","withCreateSuggestion","onCreateSuggestion","onChange","onSelect","showSuggestions","renderSuggestions","props","fetchSuggestions","allowDirectEntry","showInitialSuggestions","suggestionsQuery","withURLSuggestion","createSuggestionButtonText","useLabel","genericSearchHandler","searchHandler","instanceId","focusedSuggestion","setFocusedSuggestion","onInputChange","selection","suggestion","handleRenderSuggestions","currentInputValue","handleSuggestionClick","onSuggestionSelected","selectedSuggestion","type","title","url","e","Object","keys","length","inputClasses","undefined","event","hasSuggestion","trim","preventDefault"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA;AACA;AACA;;AACA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,UAAT,EAAqBC,QAArB,QAAqC,oBAArC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,QAAyB,KAAzB;AACA,OAAOC,wBAAP,MAAqC,kBAArC;AACA,SAASC,WAAT,QAA4B,aAA5B;AACA,OAAOC,gBAAP,MAA6B,sBAA7B,C,CAEA;AACA;AACA;;AACA,MAAMC,iBAAiB,GAAG,MAAMC,OAAO,CAACC,OAAR,CAAiB,EAAjB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/B;AAIA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,QAAD;AACC,IAAA,KAAK,EAAGA,QAAQ,GAAG,KAAH,GAAWsB,SAD5B;AAEC,IAAA,SAAS,EAAGD,YAFb;AAGC,IAAA,KAAK,EAAGvC,KAHT;AAIC,IAAA,QAAQ,EAAGwB,aAJZ;AAKC,IAAA,WAAW,EAAGpB,WAAH,aAAGA,WAAH,cAAGA,WAAH,GAAkBf,EAAE,CAAE,oBAAF,CALhC;AAMC,IAAA,+BAA+B,EAC9BoB,eAAe,GAAGkB,uBAAH,GAA6B,IAP9C;AASC,IAAA,kCAAkC,EAAGP,aATtC;AAUC,IAAA,kCAAkC,EAAG,IAVtC;AAWC,IAAA,oCAAoC,EACnCN,sBAZF;AAcC,IAAA,QAAQ,EAAG,CAAEY,UAAF,EAAce,KAAd,KAAyB;AAAA;;AACnC,YAAMC,aAAa,GAAGhB,UAAU,IAAIJ,iBAApC,CADmC,CAGnC;AACA;;AACA,UAAK,CAAEoB,aAAF,IAAmB,EAAE1C,KAAF,aAAEA,KAAF,8BAAEA,KAAK,CAAE2C,IAAP,EAAF,wCAAE,YAAeL,MAAjB,CAAxB,EAAkD;AACjDG,QAAAA,KAAK,CAACG,cAAN;AACA,OAFD,MAEO;AACNd,QAAAA,oBAAoB,CACnBY,aAAa,IAAI;AAAER,UAAAA,GAAG,EAAElC;AAAP,SADE,CAApB;AAGA;AACD,KA1BF;AA2BC,IAAA,GAAG,EAAGD;AA3BP,IADD,EA8BGE,QA9BH,CADD;AAkCA,CArIuC,CAAzC;AAwIA,eAAeH,sBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { omit } from 'lodash';\nimport classnames from 'classnames';\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { forwardRef, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { URLInput } from '../';\nimport LinkControlSearchResults from './search-results';\nimport { CREATE_TYPE } from './constants';\nimport useSearchHandler from './use-search-handler';\n\n// Must be a function as otherwise URLInput will default\n// to the fetchLinkSuggestions passed in block editor settings\n// which will cause an unintended http request.\nconst noopSearchHandler = () => Promise.resolve( [] );\n\nconst noop = () => {};\n\nconst LinkControlSearchInput = forwardRef(\n\t(\n\t\t{\n\t\t\tvalue,\n\t\t\tchildren,\n\t\t\tcurrentLink = {},\n\t\t\tclassName = null,\n\t\t\tplaceholder = null,\n\t\t\twithCreateSuggestion = false,\n\t\t\tonCreateSuggestion = noop,\n\t\t\tonChange = noop,\n\t\t\tonSelect = noop,\n\t\t\tshowSuggestions = true,\n\t\t\trenderSuggestions = ( props ) => (\n\t\t\t\t<LinkControlSearchResults { ...props } />\n\t\t\t),\n\t\t\tfetchSuggestions = null,\n\t\t\tallowDirectEntry = true,\n\t\t\tshowInitialSuggestions = false,\n\t\t\tsuggestionsQuery = {},\n\t\t\twithURLSuggestion = true,\n\t\t\tcreateSuggestionButtonText,\n\t\t\tuseLabel = false,\n\t\t},\n\t\tref\n\t) => {\n\t\tconst genericSearchHandler = useSearchHandler(\n\t\t\tsuggestionsQuery,\n\t\t\tallowDirectEntry,\n\t\t\twithCreateSuggestion,\n\t\t\twithURLSuggestion\n\t\t);\n\n\t\tconst searchHandler = showSuggestions\n\t\t\t? fetchSuggestions || genericSearchHandler\n\t\t\t: noopSearchHandler;\n\n\t\tconst instanceId = useInstanceId( LinkControlSearchInput );\n\t\tconst [ focusedSuggestion, setFocusedSuggestion ] = useState();\n\n\t\t/**\n\t\t * Handles the user moving between different suggestions. Does not handle\n\t\t * choosing an individual item.\n\t\t *\n\t\t * @param {string} selection the url of the selected suggestion.\n\t\t * @param {Object} suggestion the suggestion object.\n\t\t */\n\t\tconst onInputChange = ( selection, suggestion ) => {\n\t\t\tonChange( selection );\n\t\t\tsetFocusedSuggestion( suggestion );\n\t\t};\n\n\t\tconst handleRenderSuggestions = ( props ) =>\n\t\t\trenderSuggestions( {\n\t\t\t\t...props,\n\t\t\t\tinstanceId,\n\t\t\t\twithCreateSuggestion,\n\t\t\t\tcurrentInputValue: value,\n\t\t\t\tcreateSuggestionButtonText,\n\t\t\t\tsuggestionsQuery,\n\t\t\t\thandleSuggestionClick: ( suggestion ) => {\n\t\t\t\t\tif ( props.handleSuggestionClick ) {\n\t\t\t\t\t\tprops.handleSuggestionClick( suggestion );\n\t\t\t\t\t}\n\t\t\t\t\tonSuggestionSelected( suggestion );\n\t\t\t\t},\n\t\t\t} );\n\n\t\tconst onSuggestionSelected = async ( selectedSuggestion ) => {\n\t\t\tlet suggestion = selectedSuggestion;\n\t\t\tif ( CREATE_TYPE === selectedSuggestion.type ) {\n\t\t\t\t// Create a new page and call onSelect with the output from the onCreateSuggestion callback.\n\t\t\t\ttry {\n\t\t\t\t\tsuggestion = await onCreateSuggestion(\n\t\t\t\t\t\tselectedSuggestion.title\n\t\t\t\t\t);\n\t\t\t\t\tif ( suggestion?.url ) {\n\t\t\t\t\t\tonSelect( suggestion );\n\t\t\t\t\t}\n\t\t\t\t} catch ( e ) {}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tallowDirectEntry ||\n\t\t\t\t( suggestion && Object.keys( suggestion ).length >= 1 )\n\t\t\t) {\n\t\t\t\tonSelect(\n\t\t\t\t\t// Some direct entries don't have types or IDs, and we still need to clear the previous ones.\n\t\t\t\t\t{ ...omit( currentLink, 'id', 'url' ), ...suggestion },\n\t\t\t\t\tsuggestion\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst inputClasses = classnames( className, {\n\t\t\t'has-no-label': ! useLabel,\n\t\t} );\n\n\t\treturn (\n\t\t\t<div className=\"block-editor-link-control__search-input-container\">\n\t\t\t\t<URLInput\n\t\t\t\t\tlabel={ useLabel ? 'URL' : undefined }\n\t\t\t\t\tclassName={ inputClasses }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onInputChange }\n\t\t\t\t\tplaceholder={ placeholder ?? __( 'Search or type url' ) }\n\t\t\t\t\t__experimentalRenderSuggestions={\n\t\t\t\t\t\tshowSuggestions ? handleRenderSuggestions : null\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalFetchLinkSuggestions={ searchHandler }\n\t\t\t\t\t__experimentalHandleURLSuggestions={ true }\n\t\t\t\t\t__experimentalShowInitialSuggestions={\n\t\t\t\t\t\tshowInitialSuggestions\n\t\t\t\t\t}\n\t\t\t\t\tonSubmit={ ( suggestion, event ) => {\n\t\t\t\t\t\tconst hasSuggestion = suggestion || focusedSuggestion;\n\n\t\t\t\t\t\t// If there is no suggestion and the value (ie: any manually entered URL) is empty\n\t\t\t\t\t\t// then don't allow submission otherwise we get empty links.\n\t\t\t\t\t\tif ( ! hasSuggestion && ! value?.trim()?.length ) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tonSuggestionSelected(\n\t\t\t\t\t\t\t\thasSuggestion || { url: value }\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tref={ ref }\n\t\t\t\t/>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t);\n\t}\n);\n\nexport default LinkControlSearchInput;\n"]}
@@ -1,16 +1,13 @@
1
1
  import { createElement } from "@wordpress/element";
2
2
 
3
- /**
4
- * External dependencies
5
- */
6
- import { noop } from 'lodash';
7
3
  /**
8
4
  * WordPress dependencies
9
5
  */
10
-
11
6
  import { __ } from '@wordpress/i18n';
12
7
  import { ToggleControl, VisuallyHidden } from '@wordpress/components';
13
8
 
9
+ const noop = () => {};
10
+
14
11
  const LinkControlSettingsDrawer = _ref => {
15
12
  let {
16
13
  value,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/settings-drawer.js"],"names":["noop","__","ToggleControl","VisuallyHidden","LinkControlSettingsDrawer","value","onChange","settings","length","handleSettingChange","setting","newValue","id","theSettings","map","title"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,aAAT,EAAwBC,cAAxB,QAA8C,uBAA9C;;AAEA,MAAMC,yBAAyB,GAAG,QAA4C;AAAA,MAA1C;AAAEC,IAAAA,KAAF;AAASC,IAAAA,QAAQ,GAAGN,IAApB;AAA0BO,IAAAA;AAA1B,GAA0C;;AAC7E,MAAK,CAAEA,QAAF,IAAc,CAAEA,QAAQ,CAACC,MAA9B,EAAuC;AACtC,WAAO,IAAP;AACA;;AAED,QAAMC,mBAAmB,GAAKC,OAAF,IAAiBC,QAAF,IAAgB;AAC1DL,IAAAA,QAAQ,CAAE,EACT,GAAGD,KADM;AAET,OAAEK,OAAO,CAACE,EAAV,GAAgBD;AAFP,KAAF,CAAR;AAIA,GALD;;AAOA,QAAME,WAAW,GAAGN,QAAQ,CAACO,GAAT,CAAgBJ,OAAF,IACjC,cAAC,aAAD;AACC,IAAA,SAAS,EAAC,oCADX;AAEC,IAAA,GAAG,EAAGA,OAAO,CAACE,EAFf;AAGC,IAAA,KAAK,EAAGF,OAAO,CAACK,KAHjB;AAIC,IAAA,QAAQ,EAAGN,mBAAmB,CAAEC,OAAF,CAJ/B;AAKC,IAAA,OAAO,EAAGL,KAAK,GAAG,CAAC,CAAEA,KAAK,CAAEK,OAAO,CAACE,EAAV,CAAX,GAA4B;AAL5C,IADmB,CAApB;AAUA,SACC;AAAU,IAAA,SAAS,EAAC;AAApB,KACC,cAAC,cAAD;AAAgB,IAAA,EAAE,EAAC;AAAnB,KACGX,EAAE,CAAE,kCAAF,CADL,CADD,EAIGY,WAJH,CADD;AAQA,CA9BD;;AAgCA,eAAeT,yBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { noop } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { ToggleControl, VisuallyHidden } from '@wordpress/components';\n\nconst LinkControlSettingsDrawer = ( { value, onChange = noop, settings } ) => {\n\tif ( ! settings || ! settings.length ) {\n\t\treturn null;\n\t}\n\n\tconst handleSettingChange = ( setting ) => ( newValue ) => {\n\t\tonChange( {\n\t\t\t...value,\n\t\t\t[ setting.id ]: newValue,\n\t\t} );\n\t};\n\n\tconst theSettings = settings.map( ( setting ) => (\n\t\t<ToggleControl\n\t\t\tclassName=\"block-editor-link-control__setting\"\n\t\t\tkey={ setting.id }\n\t\t\tlabel={ setting.title }\n\t\t\tonChange={ handleSettingChange( setting ) }\n\t\t\tchecked={ value ? !! value[ setting.id ] : false }\n\t\t/>\n\t) );\n\n\treturn (\n\t\t<fieldset className=\"block-editor-link-control__settings\">\n\t\t\t<VisuallyHidden as=\"legend\">\n\t\t\t\t{ __( 'Currently selected link settings' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t{ theSettings }\n\t\t</fieldset>\n\t);\n};\n\nexport default LinkControlSettingsDrawer;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/settings-drawer.js"],"names":["__","ToggleControl","VisuallyHidden","noop","LinkControlSettingsDrawer","value","onChange","settings","length","handleSettingChange","setting","newValue","id","theSettings","map","title"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,aAAT,EAAwBC,cAAxB,QAA8C,uBAA9C;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,MAAMC,yBAAyB,GAAG,QAA4C;AAAA,MAA1C;AAAEC,IAAAA,KAAF;AAASC,IAAAA,QAAQ,GAAGH,IAApB;AAA0BI,IAAAA;AAA1B,GAA0C;;AAC7E,MAAK,CAAEA,QAAF,IAAc,CAAEA,QAAQ,CAACC,MAA9B,EAAuC;AACtC,WAAO,IAAP;AACA;;AAED,QAAMC,mBAAmB,GAAKC,OAAF,IAAiBC,QAAF,IAAgB;AAC1DL,IAAAA,QAAQ,CAAE,EACT,GAAGD,KADM;AAET,OAAEK,OAAO,CAACE,EAAV,GAAgBD;AAFP,KAAF,CAAR;AAIA,GALD;;AAOA,QAAME,WAAW,GAAGN,QAAQ,CAACO,GAAT,CAAgBJ,OAAF,IACjC,cAAC,aAAD;AACC,IAAA,SAAS,EAAC,oCADX;AAEC,IAAA,GAAG,EAAGA,OAAO,CAACE,EAFf;AAGC,IAAA,KAAK,EAAGF,OAAO,CAACK,KAHjB;AAIC,IAAA,QAAQ,EAAGN,mBAAmB,CAAEC,OAAF,CAJ/B;AAKC,IAAA,OAAO,EAAGL,KAAK,GAAG,CAAC,CAAEA,KAAK,CAAEK,OAAO,CAACE,EAAV,CAAX,GAA4B;AAL5C,IADmB,CAApB;AAUA,SACC;AAAU,IAAA,SAAS,EAAC;AAApB,KACC,cAAC,cAAD;AAAgB,IAAA,EAAE,EAAC;AAAnB,KACGZ,EAAE,CAAE,kCAAF,CADL,CADD,EAIGa,WAJH,CADD;AAQA,CA9BD;;AAgCA,eAAeT,yBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { ToggleControl, VisuallyHidden } from '@wordpress/components';\n\nconst noop = () => {};\n\nconst LinkControlSettingsDrawer = ( { value, onChange = noop, settings } ) => {\n\tif ( ! settings || ! settings.length ) {\n\t\treturn null;\n\t}\n\n\tconst handleSettingChange = ( setting ) => ( newValue ) => {\n\t\tonChange( {\n\t\t\t...value,\n\t\t\t[ setting.id ]: newValue,\n\t\t} );\n\t};\n\n\tconst theSettings = settings.map( ( setting ) => (\n\t\t<ToggleControl\n\t\t\tclassName=\"block-editor-link-control__setting\"\n\t\t\tkey={ setting.id }\n\t\t\tlabel={ setting.title }\n\t\t\tonChange={ handleSettingChange( setting ) }\n\t\t\tchecked={ value ? !! value[ setting.id ] : false }\n\t\t/>\n\t) );\n\n\treturn (\n\t\t<fieldset className=\"block-editor-link-control__settings\">\n\t\t\t<VisuallyHidden as=\"legend\">\n\t\t\t\t{ __( 'Currently selected link settings' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t{ theSettings }\n\t\t</fieldset>\n\t);\n};\n\nexport default LinkControlSettingsDrawer;\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/use-search-handler.js"],"names":["getProtocol","prependHTTP","useCallback","useSelect","startsWith","isURLLike","CREATE_TYPE","TEL_TYPE","MAILTO_TYPE","INTERNAL_TYPE","URL_TYPE","store","blockEditorStore","handleNoop","Promise","resolve","handleDirectEntry","val","type","protocol","includes","id","title","url","handleEntitySearch","suggestionsQuery","fetchSearchSuggestions","directEntryHandler","withCreateSuggestion","withURLSuggestion","pageOnFront","isInitialSuggestions","resultsIncludeFrontPage","results","all","map","result","Number","isFrontPage","couldBeURL","concat","useSearchHandler","allowDirectEntry","select","getSettings","__experimentalFetchLinkSuggestions"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,WAAtB,QAAyC,gBAAzC;AACA,SAASC,WAAT,QAA4B,oBAA5B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,SAASC,UAAT,QAA2B,QAA3B;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,eAAtB;AACA,SACCC,WADD,EAECC,QAFD,EAGCC,WAHD,EAICC,aAJD,EAKCC,QALD,QAMO,aANP;AAOA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA,OAAO,MAAMC,UAAU,GAAG,MAAMC,OAAO,CAACC,OAAR,CAAiB,EAAjB,CAAzB;AAEP,OAAO,MAAMC,iBAAiB,GAAKC,GAAF,IAAW;AAC3C,MAAIC,IAAI,GAAGR,QAAX;AAEA,QAAMS,QAAQ,GAAGnB,WAAW,CAAEiB,GAAF,CAAX,IAAsB,EAAvC;;AAEA,MAAKE,QAAQ,CAACC,QAAT,CAAmB,QAAnB,CAAL,EAAqC;AACpCF,IAAAA,IAAI,GAAGV,WAAP;AACA;;AAED,MAAKW,QAAQ,CAACC,QAAT,CAAmB,KAAnB,CAAL,EAAkC;AACjCF,I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JU,kBAAkB,CAAEV,GAAF,EAAO;AAAEc,MAAAA;AAAF,KAAP,CADd,GAEJP,kBAAkB,CAClBP,GADkB,EAElB,EAAE,GAAGQ,gBAAL;AAAuBM,MAAAA;AAAvB,KAFkB,EAGlBL,sBAHkB,EAIlBC,kBAJkB,EAKlBC,oBALkB,EAMlBC,iBANkB,EAOlBC,WAPkB,CAFrB;AAWA,GAbgB,EAcjB,CAAEH,kBAAF,EAAsBD,sBAAtB,EAA8CE,oBAA9C,CAdiB,CAAlB;AAgBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getProtocol, prependHTTP } from '@wordpress/url';\nimport { useCallback } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * External dependencies\n */\nimport { startsWith } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport isURLLike from './is-url-like';\nimport {\n\tCREATE_TYPE,\n\tTEL_TYPE,\n\tMAILTO_TYPE,\n\tINTERNAL_TYPE,\n\tURL_TYPE,\n} from './constants';\nimport { store as blockEditorStore } from '../../store';\n\nexport const handleNoop = () => Promise.resolve( [] );\n\nexport const handleDirectEntry = ( val ) => {\n\tlet type = URL_TYPE;\n\n\tconst protocol = getProtocol( val ) || '';\n\n\tif ( protocol.includes( 'mailto' ) ) {\n\t\ttype = MAILTO_TYPE;\n\t}\n\n\tif ( protocol.includes( 'tel' ) ) {\n\t\ttype = TEL_TYPE;\n\t}\n\n\tif ( startsWith( val, '#' ) ) {\n\t\ttype = INTERNAL_TYPE;\n\t}\n\n\treturn Promise.resolve( [\n\t\t{\n\t\t\tid: val,\n\t\t\ttitle: val,\n\t\t\turl: type === 'URL' ? prependHTTP( val ) : val,\n\t\t\ttype,\n\t\t},\n\t] );\n};\n\nconst handleEntitySearch = async (\n\tval,\n\tsuggestionsQuery,\n\tfetchSearchSuggestions,\n\tdirectEntryHandler,\n\twithCreateSuggestion,\n\twithURLSuggestion,\n\tpageOnFront\n) => {\n\tconst { isInitialSuggestions } = suggestionsQuery;\n\tlet resultsIncludeFrontPage = false;\n\n\tlet results = await Promise.all( [\n\t\tfetchSearchSuggestions( val, suggestionsQuery ),\n\t\tdirectEntryHandler( val ),\n\t] );\n\n\t// Identify front page and update type to match.\n\tresults[ 0 ] = results[ 0 ].map( ( result ) => {\n\t\tif ( Number( result.id ) === pageOnFront ) {\n\t\t\tresultsIncludeFrontPage = true;\n\t\t\tresult.isFrontPage = true;\n\t\t\treturn result;\n\t\t}\n\n\t\treturn result;\n\t} );\n\n\tconst couldBeURL = ! val.includes( ' ' );\n\n\t// If it's potentially a URL search then concat on a URL search suggestion\n\t// just for good measure. That way once the actual results run out we always\n\t// have a URL option to fallback on.\n\tif (\n\t\t! resultsIncludeFrontPage &&\n\t\tcouldBeURL &&\n\t\twithURLSuggestion &&\n\t\t! isInitialSuggestions\n\t) {\n\t\tresults = results[ 0 ].concat( results[ 1 ] );\n\t} else {\n\t\tresults = results[ 0 ];\n\t}\n\n\t// If displaying initial suggestions just return plain results.\n\tif ( isInitialSuggestions ) {\n\t\treturn results;\n\t}\n\n\t// Here we append a faux suggestion to represent a \"CREATE\" option. This\n\t// is detected in the rendering of the search results and handled as a\n\t// special case. This is currently necessary because the suggestions\n\t// dropdown will only appear if there are valid suggestions and\n\t// therefore unless the create option is a suggestion it will not\n\t// display in scenarios where there are no results returned from the\n\t// API. In addition promoting CREATE to a first class suggestion affords\n\t// the a11y benefits afforded by `URLInput` to all suggestions (eg:\n\t// keyboard handling, ARIA roles...etc).\n\t//\n\t// Note also that the value of the `title` and `url` properties must correspond\n\t// to the text value of the `<input>`. This is because `title` is used\n\t// when creating the suggestion. Similarly `url` is used when using keyboard to select\n\t// the suggestion (the <form> `onSubmit` handler falls-back to `url`).\n\treturn isURLLike( val ) || ! withCreateSuggestion\n\t\t? results\n\t\t: results.concat( {\n\t\t\t\t// the `id` prop is intentionally ommitted here because it\n\t\t\t\t// is never exposed as part of the component's public API.\n\t\t\t\t// see: https://github.com/WordPress/gutenberg/pull/19775#discussion_r378931316.\n\t\t\t\ttitle: val, // Must match the existing `<input>`s text value.\n\t\t\t\turl: val, // Must match the existing `<input>`s text value.\n\t\t\t\ttype: CREATE_TYPE,\n\t\t } );\n};\n\nexport default function useSearchHandler(\n\tsuggestionsQuery,\n\tallowDirectEntry,\n\twithCreateSuggestion,\n\twithURLSuggestion\n) {\n\tconst { fetchSearchSuggestions, pageOnFront } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\n\t\treturn {\n\t\t\tpageOnFront: getSettings().pageOnFront,\n\t\t\tfetchSearchSuggestions: getSettings()\n\t\t\t\t.__experimentalFetchLinkSuggestions,\n\t\t};\n\t}, [] );\n\n\tconst directEntryHandler = allowDirectEntry\n\t\t? handleDirectEntry\n\t\t: handleNoop;\n\n\treturn useCallback(\n\t\t( val, { isInitialSuggestions } ) => {\n\t\t\treturn isURLLike( val )\n\t\t\t\t? directEntryHandler( val, { isInitialSuggestions } )\n\t\t\t\t: handleEntitySearch(\n\t\t\t\t\t\tval,\n\t\t\t\t\t\t{ ...suggestionsQuery, isInitialSuggestions },\n\t\t\t\t\t\tfetchSearchSuggestions,\n\t\t\t\t\t\tdirectEntryHandler,\n\t\t\t\t\t\twithCreateSuggestion,\n\t\t\t\t\t\twithURLSuggestion,\n\t\t\t\t\t\tpageOnFront\n\t\t\t\t );\n\t\t},\n\t\t[ directEntryHandler, fetchSearchSuggestions, withCreateSuggestion ]\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/use-search-handler.js"],"names":["getProtocol","prependHTTP","useCallback","useSelect","startsWith","isURLLike","CREATE_TYPE","TEL_TYPE","MAILTO_TYPE","INTERNAL_TYPE","URL_TYPE","store","blockEditorStore","handleNoop","Promise","resolve","handleDirectEntry","val","type","protocol","includes","id","title","url","handleEntitySearch","suggestionsQuery","fetchSearchSuggestions","directEntryHandler","withCreateSuggestion","withURLSuggestion","pageOnFront","isInitialSuggestions","resultsIncludeFrontPage","results","all","map","result","Number","isFrontPage","couldBeURL","concat","useSearchHandler","allowDirectEntry","select","getSettings","__experimentalFetchLinkSuggestions"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,WAAtB,QAAyC,gBAAzC;AACA,SAASC,WAAT,QAA4B,oBAA5B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,SAASC,UAAT,QAA2B,QAA3B;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,eAAtB;AACA,SACCC,WADD,EAECC,QAFD,EAGCC,WAHD,EAICC,aAJD,EAKCC,QALD,QAMO,aANP;AAOA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA,OAAO,MAAMC,UAAU,GAAG,MAAMC,OAAO,CAACC,OAAR,CAAiB,EAAjB,CAAzB;AAEP,OAAO,MAAMC,iBAAiB,GAAKC,GAAF,IAAW;AAC3C,MAAIC,IAAI,GAAGR,QAAX;AAEA,QAAMS,QAAQ,GAAGnB,WAAW,CAAEiB,GAAF,CAAX,IAAsB,EAAvC;;AAEA,MAAKE,QAAQ,CAACC,QAAT,CAAmB,QAAnB,CAAL,EAAqC;AACpCF,IAAAA,IAAI,GAAGV,WAAP;AACA;;AAED,MAAKW,QAAQ,CAACC,QAAT,CAAmB,KAAnB,CAAL,EAAkC;AACjCF,IAAAA,IAAI,GAAGX,QAAP;AACA;;AAED,MAAKH,UAAU,CAAEa,GAAF,EAAO,GAAP,CAAf,EAA8B;AAC7BC,IAAAA,IAAI,GAAGT,aAAP;AACA;;AAED,SAAOK,OAAO,CAACC,OAAR,CAAiB,CACvB;AACCM,IAAAA,EAAE,EAAEJ,GADL;AAECK,IAAAA,KAAK,EAAEL,GAFR;AAGCM,IAAAA,GAAG,EAAEL,IAAI,KAAK,KAAT,GAAiBjB,WAAW,CAAEgB,GAAF,CAA5B,GAAsCA,GAH5C;AAICC,IAAAA;AAJD,GADuB,CAAjB,CAAP;AAQA,CAzBM;;AA2BP,MAAMM,kBA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AF,CAAT,IAAoB,CAAEW,oBAAtB,GACJK,OADI,GAEJA,OAAO,CAACO,MAAR,CAAgB;AAChB;AACA;AACA;AACAlB,IAAAA,KAAK,EAAEL,GAJS;AAIJ;AACZM,IAAAA,GAAG,EAAEN,GALW;AAKN;AACVC,IAAAA,IAAI,EAAEZ;AANU,GAAhB,CAFH;AAUA,CAzED;;AA2EA,eAAe,SAASmC,gBAAT,CACdhB,gBADc,EAEdiB,gBAFc,EAGdd,oBAHc,EAIdC,iBAJc,EAKb;AACD,QAAM;AAAEH,IAAAA,sBAAF;AAA0BI,IAAAA;AAA1B,MAA0C3B,SAAS,CAAIwC,MAAF,IAAc;AACxE,UAAM;AAAEC,MAAAA;AAAF,QAAkBD,MAAM,CAAE/B,gBAAF,CAA9B;AAEA,WAAO;AACNkB,MAAAA,WAAW,EAAEc,WAAW,GAAGd,WADrB;AAENJ,MAAAA,sBAAsB,EACrBkB,WAAW,GAAGC;AAHT,KAAP;AAKA,GARwD,EAQtD,EARsD,CAAzD;AAUA,QAAMlB,kBAAkB,GAAGe,gBAAgB,GACxC1B,iBADwC,GAExCH,UAFH;AAIA,SAAOX,WAAW,CACjB,CAAEe,GAAF,WAAqC;AAAA,QAA9B;AAAEc,MAAAA;AAAF,KAA8B;AACpC,WAAO1B,SAAS,CAAEY,GAAF,CAAT,GACJU,kBAAkB,CAAEV,GAAF,EAAO;AAAEc,MAAAA;AAAF,KAAP,CADd,GAEJP,kBAAkB,CAClBP,GADkB,EAElB,EAAE,GAAGQ,gBAAL;AAAuBM,MAAAA;AAAvB,KAFkB,EAGlBL,sBAHkB,EAIlBC,kBAJkB,EAKlBC,oBALkB,EAMlBC,iBANkB,EAOlBC,WAPkB,CAFrB;AAWA,GAbgB,EAcjB,CAAEH,kBAAF,EAAsBD,sBAAtB,EAA8CE,oBAA9C,CAdiB,CAAlB;AAgBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getProtocol, prependHTTP } from '@wordpress/url';\nimport { useCallback } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * External dependencies\n */\nimport { startsWith } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport isURLLike from './is-url-like';\nimport {\n\tCREATE_TYPE,\n\tTEL_TYPE,\n\tMAILTO_TYPE,\n\tINTERNAL_TYPE,\n\tURL_TYPE,\n} from './constants';\nimport { store as blockEditorStore } from '../../store';\n\nexport const handleNoop = () => Promise.resolve( [] );\n\nexport const handleDirectEntry = ( val ) => {\n\tlet type = URL_TYPE;\n\n\tconst protocol = getProtocol( val ) || '';\n\n\tif ( protocol.includes( 'mailto' ) ) {\n\t\ttype = MAILTO_TYPE;\n\t}\n\n\tif ( protocol.includes( 'tel' ) ) {\n\t\ttype = TEL_TYPE;\n\t}\n\n\tif ( startsWith( val, '#' ) ) {\n\t\ttype = INTERNAL_TYPE;\n\t}\n\n\treturn Promise.resolve( [\n\t\t{\n\t\t\tid: val,\n\t\t\ttitle: val,\n\t\t\turl: type === 'URL' ? prependHTTP( val ) : val,\n\t\t\ttype,\n\t\t},\n\t] );\n};\n\nconst handleEntitySearch = async (\n\tval,\n\tsuggestionsQuery,\n\tfetchSearchSuggestions,\n\tdirectEntryHandler,\n\twithCreateSuggestion,\n\twithURLSuggestion,\n\tpageOnFront\n) => {\n\tconst { isInitialSuggestions } = suggestionsQuery;\n\tlet resultsIncludeFrontPage = false;\n\n\tlet results = await Promise.all( [\n\t\tfetchSearchSuggestions( val, suggestionsQuery ),\n\t\tdirectEntryHandler( val ),\n\t] );\n\n\t// Identify front page and update type to match.\n\tresults[ 0 ] = results[ 0 ].map( ( result ) => {\n\t\tif ( Number( result.id ) === pageOnFront ) {\n\t\t\tresultsIncludeFrontPage = true;\n\t\t\tresult.isFrontPage = true;\n\t\t\treturn result;\n\t\t}\n\n\t\treturn result;\n\t} );\n\n\tconst couldBeURL = ! val.includes( ' ' );\n\n\t// If it's potentially a URL search then concat on a URL search suggestion\n\t// just for good measure. That way once the actual results run out we always\n\t// have a URL option to fallback on.\n\tif (\n\t\t! resultsIncludeFrontPage &&\n\t\tcouldBeURL &&\n\t\twithURLSuggestion &&\n\t\t! isInitialSuggestions\n\t) {\n\t\tresults = results[ 0 ].concat( results[ 1 ] );\n\t} else {\n\t\tresults = results[ 0 ];\n\t}\n\n\t// If displaying initial suggestions just return plain results.\n\tif ( isInitialSuggestions ) {\n\t\treturn results;\n\t}\n\n\t// Here we append a faux suggestion to represent a \"CREATE\" option. This\n\t// is detected in the rendering of the search results and handled as a\n\t// special case. This is currently necessary because the suggestions\n\t// dropdown will only appear if there are valid suggestions and\n\t// therefore unless the create option is a suggestion it will not\n\t// display in scenarios where there are no results returned from the\n\t// API. In addition promoting CREATE to a first class suggestion affords\n\t// the a11y benefits afforded by `URLInput` to all suggestions (eg:\n\t// keyboard handling, ARIA roles...etc).\n\t//\n\t// Note also that the value of the `title` and `url` properties must correspond\n\t// to the text value of the `<input>`. This is because `title` is used\n\t// when creating the suggestion. Similarly `url` is used when using keyboard to select\n\t// the suggestion (the <form> `onSubmit` handler falls-back to `url`).\n\treturn isURLLike( val ) || ! withCreateSuggestion\n\t\t? results\n\t\t: results.concat( {\n\t\t\t\t// the `id` prop is intentionally ommitted here because it\n\t\t\t\t// is never exposed as part of the component's public API.\n\t\t\t\t// see: https://github.com/WordPress/gutenberg/pull/19775#discussion_r378931316.\n\t\t\t\ttitle: val, // Must match the existing `<input>`s text value.\n\t\t\t\turl: val, // Must match the existing `<input>`s text value.\n\t\t\t\ttype: CREATE_TYPE,\n\t\t } );\n};\n\nexport default function useSearchHandler(\n\tsuggestionsQuery,\n\tallowDirectEntry,\n\twithCreateSuggestion,\n\twithURLSuggestion\n) {\n\tconst { fetchSearchSuggestions, pageOnFront } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\n\t\treturn {\n\t\t\tpageOnFront: getSettings().pageOnFront,\n\t\t\tfetchSearchSuggestions:\n\t\t\t\tgetSettings().__experimentalFetchLinkSuggestions,\n\t\t};\n\t}, [] );\n\n\tconst directEntryHandler = allowDirectEntry\n\t\t? handleDirectEntry\n\t\t: handleNoop;\n\n\treturn useCallback(\n\t\t( val, { isInitialSuggestions } ) => {\n\t\t\treturn isURLLike( val )\n\t\t\t\t? directEntryHandler( val, { isInitialSuggestions } )\n\t\t\t\t: handleEntitySearch(\n\t\t\t\t\t\tval,\n\t\t\t\t\t\t{ ...suggestionsQuery, isInitialSuggestions },\n\t\t\t\t\t\tfetchSearchSuggestions,\n\t\t\t\t\t\tdirectEntryHandler,\n\t\t\t\t\t\twithCreateSuggestion,\n\t\t\t\t\t\twithURLSuggestion,\n\t\t\t\t\t\tpageOnFront\n\t\t\t\t );\n\t\t},\n\t\t[ directEntryHandler, fetchSearchSuggestions, withCreateSuggestion ]\n\t);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block-contents.js"],"names":["classnames","useSelect","forwardRef","ListViewBlockSelectButton","BlockDraggable","store","blockEditorStore","ListViewBlockContents","ref","onClick","onToggleExpanded","block","isSelected","position","siblingBlockCount","level","isExpanded","selectedClientIds","props","clientId","blockMovingClientId","selectedBlockInBlockEditor","select","hasBlockMovingClientId","getSelectedBlockClientId","isBlockMoveTarget","className","draggableClientIds","includes","draggable","onDragStart","onDragEnd"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,UAAT,QAA2B,oBAA3B;AAEA;AACA;AACA;;AACA,OAAOC,yBAAP,MAAsC,uBAAtC;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA,MAAMC,qBAAqB,GAAGL,UAAU,CACvC,OAaCM,GAbD,KAcK;AAAA,MAbJ;AACCC,IAAAA,OADD;AAECC,IAAAA,gBAFD;AAGCC,IAAAA,KAHD;AAICC,IAAAA,UAJD;AAKCC,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,KATT;AAUC,MAAA,SAAS,EAAGc,SAVb;AAWC,MAAA,WAAW,EAAGC,WAXf;AAYC,MAAA,SAAS,EAAGC,SAZb;AAaC,MAAA,UAAU,EAAGf;AAbd,OAcME,KAdN,EADC;AAAA,GADH,CADD;AAsBA,CArEsC,CAAxC;AAwEA,eAAeX,qBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ListViewBlockSelectButton from './block-select-button';\nimport BlockDraggable from '../block-draggable';\nimport { store as blockEditorStore } from '../../store';\n\nconst ListViewBlockContents = forwardRef(\n\t(\n\t\t{\n\t\t\tonClick,\n\t\t\tonToggleExpanded,\n\t\t\tblock,\n\t\t\tisSelected,\n\t\t\tposition,\n\t\t\tsiblingBlockCount,\n\t\t\tlevel,\n\t\t\tisExpanded,\n\t\t\tselectedClientIds,\n\t\t\t...props\n\t\t},\n\t\tref\n\t) => {\n\t\tconst { clientId } = block;\n\n\t\tconst { blockMovingClientId, selectedBlockInBlockEditor } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\thasBlockMovingClientId,\n\t\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\t} = select( blockEditorStore );\n\t\t\t\treturn {\n\t\t\t\t\tblockMovingClientId: hasBlockMovingClientId(),\n\t\t\t\t\tselectedBlockInBlockEditor: getSelectedBlockClientId(),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ clientId ]\n\t\t);\n\n\t\tconst isBlockMoveTarget =\n\t\t\tblockMovingClientId && selectedBlockInBlockEditor === clientId;\n\n\t\tconst className = classnames( 'block-editor-list-view-block-contents', {\n\t\t\t'is-dropping-before': isBlockMoveTarget,\n\t\t} );\n\n\t\t// Only include all selected blocks if the currently clicked on block\n\t\t// is one of the selected blocks. This ensures that if a user attempts\n\t\t// to drag a block that isn't part of the selection, they're still able\n\t\t// to drag it and rearrange its position.\n\t\tconst draggableClientIds = selectedClientIds.includes( clientId )\n\t\t\t? selectedClientIds\n\t\t\t: [ clientId ];\n\n\t\treturn (\n\t\t\t<BlockDraggable clientIds={ draggableClientIds }>\n\t\t\t\t{ ( { draggable, onDragStart, onDragEnd } ) => (\n\t\t\t\t\t<ListViewBlockSelectButton\n\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\t\tonToggleExpanded={ onToggleExpanded }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\tsiblingBlockCount={ siblingBlockCount }\n\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\tdraggable={ draggable }\n\t\t\t\t\t\tonDragStart={ onDragStart }\n\t\t\t\t\t\tonDragEnd={ onDragEnd }\n\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockDraggable>\n\t\t);\n\t}\n);\n\nexport default ListViewBlockContents;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block-contents.js"],"names":["classnames","useSelect","forwardRef","ListViewBlockSelectButton","BlockDraggable","store","blockEditorStore","ListViewBlockContents","ref","onClick","onToggleExpanded","block","isSelected","position","siblingBlockCount","level","isExpanded","selectedClientIds","props","clientId","blockMovingClientId","selectedBlockInBlockEditor","select","hasBlockMovingClientId","getSelectedBlockClientId","isBlockMoveTarget","className","draggableClientIds","includes","draggable","onDragStart","onDragEnd"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,UAAT,QAA2B,oBAA3B;AAEA;AACA;AACA;;AACA,OAAOC,yBAAP,MAAsC,uBAAtC;AAC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AAS,EAAGkB,SAFb;AAGC,MAAA,KAAK,EAAGf,KAHT;AAIC,MAAA,OAAO,EAAGF,OAJX;AAKC,MAAA,gBAAgB,EAAGC,gBALpB;AAMC,MAAA,UAAU,EAAGE,UANd;AAOC,MAAA,QAAQ,EAAGC,QAPZ;AAQC,MAAA,iBAAiB,EAAGC,iBARrB;AASC,MAAA,KAAK,EAAGC,KATT;AAUC,MAAA,SAAS,EAAGc,SAVb;AAWC,MAAA,WAAW,EAAGC,WAXf;AAYC,MAAA,SAAS,EAAGC,SAZb;AAaC,MAAA,UAAU,EAAGf;AAbd,OAcME,KAdN,EADC;AAAA,GADH,CADD;AAsBA,CAnEsC,CAAxC;AAsEA,eAAeX,qBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ListViewBlockSelectButton from './block-select-button';\nimport BlockDraggable from '../block-draggable';\nimport { store as blockEditorStore } from '../../store';\n\nconst ListViewBlockContents = forwardRef(\n\t(\n\t\t{\n\t\t\tonClick,\n\t\t\tonToggleExpanded,\n\t\t\tblock,\n\t\t\tisSelected,\n\t\t\tposition,\n\t\t\tsiblingBlockCount,\n\t\t\tlevel,\n\t\t\tisExpanded,\n\t\t\tselectedClientIds,\n\t\t\t...props\n\t\t},\n\t\tref\n\t) => {\n\t\tconst { clientId } = block;\n\n\t\tconst { blockMovingClientId, selectedBlockInBlockEditor } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { hasBlockMovingClientId, getSelectedBlockClientId } =\n\t\t\t\t\tselect( blockEditorStore );\n\t\t\t\treturn {\n\t\t\t\t\tblockMovingClientId: hasBlockMovingClientId(),\n\t\t\t\t\tselectedBlockInBlockEditor: getSelectedBlockClientId(),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ clientId ]\n\t\t);\n\n\t\tconst isBlockMoveTarget =\n\t\t\tblockMovingClientId && selectedBlockInBlockEditor === clientId;\n\n\t\tconst className = classnames( 'block-editor-list-view-block-contents', {\n\t\t\t'is-dropping-before': isBlockMoveTarget,\n\t\t} );\n\n\t\t// Only include all selected blocks if the currently clicked on block\n\t\t// is one of the selected blocks. This ensures that if a user attempts\n\t\t// to drag a block that isn't part of the selection, they're still able\n\t\t// to drag it and rearrange its position.\n\t\tconst draggableClientIds = selectedClientIds.includes( clientId )\n\t\t\t? selectedClientIds\n\t\t\t: [ clientId ];\n\n\t\treturn (\n\t\t\t<BlockDraggable clientIds={ draggableClientIds }>\n\t\t\t\t{ ( { draggable, onDragStart, onDragEnd } ) => (\n\t\t\t\t\t<ListViewBlockSelectButton\n\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\t\tonToggleExpanded={ onToggleExpanded }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\tsiblingBlockCount={ siblingBlockCount }\n\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\tdraggable={ draggable }\n\t\t\t\t\t\tonDragStart={ onDragStart }\n\t\t\t\t\t\tonDragEnd={ onDragEnd }\n\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockDraggable>\n\t\t);\n\t}\n);\n\nexport default ListViewBlockContents;\n"]}
@@ -8,7 +8,7 @@ import classnames from 'classnames';
8
8
  * WordPress dependencies
9
9
  */
10
10
 
11
- import { Button } from '@wordpress/components';
11
+ import { Button, __experimentalHStack as HStack, __experimentalTruncate as Truncate } from '@wordpress/components';
12
12
  import { forwardRef } from '@wordpress/element';
13
13
  import { Icon, lock } from '@wordpress/icons';
14
14
  import { SPACE, ENTER } from '@wordpress/keycodes';
@@ -18,7 +18,7 @@ import { SPACE, ENTER } from '@wordpress/keycodes';
18
18
 
19
19
  import BlockIcon from '../block-icon';
20
20
  import useBlockDisplayInformation from '../use-block-display-information';
21
- import BlockTitle from '../block-title';
21
+ import useBlockDisplayTitle from '../block-title/use-block-display-title';
22
22
  import ListViewExpander from './expander';
23
23
  import { useBlockLock } from '../block-lock';
24
24
 
@@ -37,6 +37,10 @@ function ListViewBlockSelectButton(_ref, ref) {
37
37
  draggable
38
38
  } = _ref;
39
39
  const blockInformation = useBlockDisplayInformation(clientId);
40
+ const blockTitle = useBlockDisplayTitle({
41
+ clientId,
42
+ context: 'list-view'
43
+ });
40
44
  const {
41
45
  isLocked
42
46
  } = useBlockLock(clientId); // The `href` attribute triggers the browser's native HTML drag operations.
@@ -72,18 +76,22 @@ function ListViewBlockSelectButton(_ref, ref) {
72
76
  }), createElement(BlockIcon, {
73
77
  icon: blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon,
74
78
  showColors: true
75
- }), createElement("span", {
79
+ }), createElement(HStack, {
80
+ alignment: "center",
81
+ className: "block-editor-list-view-block-select-button__label-wrapper",
82
+ justify: "flex-start",
83
+ spacing: 1
84
+ }, createElement("span", {
76
85
  className: "block-editor-list-view-block-select-button__title"
77
- }, createElement(BlockTitle, {
78
- clientId: clientId,
79
- maximumLength: 35
80
- })), (blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.anchor) && createElement("span", {
86
+ }, createElement(Truncate, {
87
+ ellipsizeMode: "auto"
88
+ }, blockTitle)), (blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.anchor) && createElement("span", {
81
89
  className: "block-editor-list-view-block-select-button__anchor"
82
90
  }, blockInformation.anchor), isLocked && createElement("span", {
83
91
  className: "block-editor-list-view-block-select-button__lock"
84
92
  }, createElement(Icon, {
85
93
  icon: lock
86
- }))));
94
+ })))));
87
95
  }
88
96
 
89
97
  export default forwardRef(ListViewBlockSelectButton);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block-select-button.js"],"names":["classnames","Button","forwardRef","Icon","lock","SPACE","ENTER","BlockIcon","useBlockDisplayInformation","BlockTitle","ListViewExpander","useBlockLock","ListViewBlockSelectButton","ref","className","block","clientId","onClick","onToggleExpanded","tabIndex","onFocus","onDragStart","onDragEnd","draggable","blockInformation","isLocked","onDragStartHandler","event","dataTransfer","clearData","onKeyDownHandler","keyCode","icon","anchor"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,UAAT,QAA2B,oBAA3B;AACA,SAASC,IAAT,EAAeC,IAAf,QAA2B,kBAA3B;AACA,SAASC,KAAT,EAAgBC,KAAhB,QAA6B,qBAA7B;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,eAAtB;AACA,OAAOC,0BAAP,MAAuC,kCAAvC;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AACA,OAAOC,gBAAP,MAA6B,YAA7B;AACA,SAASC,YAAT,QAA6B,eAA7B;;AAEA,SAASC,yBAAT,OAYCC,GAZD,EAaE;AAAA,MAZD;AACCC,IAAAA,SADD;AAECC,IAAAA,KAAK,EAAE;AAAEC,MAAAA;AAAF,KAFR;AAGCC,IAAAA,OAHD;AAICC,IAAAA,gBAJD;AAKCC,IAAAA,QALD;AAMCC,IAAAA,OAND;AAOCC,IAAAA,WAPD;AAQCC,IAAAA,SARD;AASCC,IAAAA;AATD,GAYC;AACD,QAAMC,gBAAgB,GAAGhB,0BAA0B,CAAEQ,QAAF,CAAnD;AACA,QAAM;AAAES,IAAAA;AAAF,MAAed,YAAY,CAAEK,QAAF,CAAjC,CAFC,CAID;AACA;AACA;AACA;;AACA,QAAMU,kBAAkB,GAAKC,KAAF,IAAa;AACvCA,IAAAA,KAAK,CAACC,YAAN,CAAmBC,SAAnB;AACAR,IAAAA,WAAW,SAAX,IAAAA,WAAW,WAAX,YAAAA,WAAW,CAAIM,KAAJ,CAAX;A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,UAAU,CAAEU,yBAAF,CAAzB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { forwardRef } from '@wordpress/element';\nimport { Icon, lock } from '@wordpress/icons';\nimport { SPACE, ENTER } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport BlockTitle from '../block-title';\nimport ListViewExpander from './expander';\nimport { useBlockLock } from '../block-lock';\n\nfunction ListViewBlockSelectButton(\n\t{\n\t\tclassName,\n\t\tblock: { clientId },\n\t\tonClick,\n\t\tonToggleExpanded,\n\t\ttabIndex,\n\t\tonFocus,\n\t\tonDragStart,\n\t\tonDragEnd,\n\t\tdraggable,\n\t},\n\tref\n) {\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst { isLocked } = useBlockLock( clientId );\n\n\t// The `href` attribute triggers the browser's native HTML drag operations.\n\t// When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.\n\t// We need to clear any HTML drag data to prevent `pasteHandler` from firing\n\t// inside the `useOnBlockDrop` hook.\n\tconst onDragStartHandler = ( event ) => {\n\t\tevent.dataTransfer.clearData();\n\t\tonDragStart?.( event );\n\t};\n\n\tfunction onKeyDownHandler( event ) {\n\t\tif ( event.keyCode === ENTER || event.keyCode === SPACE ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-list-view-block-select-button',\n\t\t\t\t\tclassName\n\t\t\t\t) }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tonKeyDown={ onKeyDownHandler }\n\t\t\t\tref={ ref }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\tonFocus={ onFocus }\n\t\t\t\tonDragStart={ onDragStartHandler }\n\t\t\t\tonDragEnd={ onDragEnd }\n\t\t\t\tdraggable={ draggable }\n\t\t\t\thref={ `#block-${ clientId }` }\n\t\t\t\taria-hidden={ true }\n\t\t\t>\n\t\t\t\t<ListViewExpander onClick={ onToggleExpanded } />\n\t\t\t\t<BlockIcon icon={ blockInformation?.icon } showColors />\n\t\t\t\t<span className=\"block-editor-list-view-block-select-button__title\">\n\t\t\t\t\t<BlockTitle clientId={ clientId } maximumLength={ 35 } />\n\t\t\t\t</span>\n\t\t\t\t{ blockInformation?.anchor && (\n\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__anchor\">\n\t\t\t\t\t\t{ blockInformation.anchor }\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t{ isLocked && (\n\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__lock\">\n\t\t\t\t\t\t<Icon icon={ lock } />\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t</Button>\n\t\t</>\n\t);\n}\n\nexport default forwardRef( ListViewBlockSelectButton );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block-select-button.js"],"names":["classnames","Button","__experimentalHStack","HStack","__experimentalTruncate","Truncate","forwardRef","Icon","lock","SPACE","ENTER","BlockIcon","useBlockDisplayInformation","useBlockDisplayTitle","ListViewExpander","useBlockLock","ListViewBlockSelectButton","ref","className","block","clientId","onClick","onToggleExpanded","tabIndex","onFocus","onDragStart","onDragEnd","draggable","blockInformation","blockTitle","context","isLocked","onDragStartHandler","event","dataTransfer","clearData","onKeyDownHandler","keyCode","icon","anchor"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,MADD,EAECC,oBAAoB,IAAIC,MAFzB,EAGCC,sBAAsB,IAAIC,QAH3B,QAIO,uBAJP;AAKA,SAASC,UAAT,QAA2B,oBAA3B;AACA,SAASC,IAAT,EAAeC,IAAf,QAA2B,kBAA3B;AACA,SAASC,KAAT,EAAgBC,KAAhB,QAA6B,qBAA7B;AAEA;A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C,IAAA,GAAG,EAAGnB,GAPP;AAQC,IAAA,QAAQ,EAAGM,QARZ;AASC,IAAA,OAAO,EAAGC,OATX;AAUC,IAAA,WAAW,EAAGQ,kBAVf;AAWC,IAAA,SAAS,EAAGN,SAXb;AAYC,IAAA,SAAS,EAAGC,SAZb;AAaC,IAAA,IAAI,EAAI,UAAUP,QAAU,EAb7B;AAcC,mBAAc;AAdf,KAgBC,cAAC,gBAAD;AAAkB,IAAA,OAAO,EAAGE;AAA5B,IAhBD,EAiBC,cAAC,SAAD;AAAW,IAAA,IAAI,EAAGM,gBAAH,aAAGA,gBAAH,uBAAGA,gBAAgB,CAAEU,IAApC;AAA2C,IAAA,UAAU;AAArD,IAjBD,EAkBC,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,QADX;AAEC,IAAA,SAAS,EAAC,2DAFX;AAGC,IAAA,OAAO,EAAC,YAHT;AAIC,IAAA,OAAO,EAAG;AAJX,KAMC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACC,cAAC,QAAD;AAAU,IAAA,aAAa,EAAC;AAAxB,KAAiCT,UAAjC,CADD,CAND,EASG,CAAAD,gBAAgB,SAAhB,IAAAA,gBAAgB,WAAhB,YAAAA,gBAAgB,CAAEW,MAAlB,KACD;AAAM,IAAA,SAAS,EAAC;AAAhB,KACGX,gBAAgB,CAACW,MADpB,CAVF,EAcGR,QAAQ,IACT;AAAM,IAAA,SAAS,EAAC;AAAhB,KACC,cAAC,IAAD;AAAM,IAAA,IAAI,EAAGvB;AAAb,IADD,CAfF,CAlBD,CADD,CADD;AA2CA;;AAED,eAAeF,UAAU,CAAEU,yBAAF,CAAzB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalTruncate as Truncate,\n} from '@wordpress/components';\nimport { forwardRef } from '@wordpress/element';\nimport { Icon, lock } from '@wordpress/icons';\nimport { SPACE, ENTER } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport useBlockDisplayTitle from '../block-title/use-block-display-title';\nimport ListViewExpander from './expander';\nimport { useBlockLock } from '../block-lock';\n\nfunction ListViewBlockSelectButton(\n\t{\n\t\tclassName,\n\t\tblock: { clientId },\n\t\tonClick,\n\t\tonToggleExpanded,\n\t\ttabIndex,\n\t\tonFocus,\n\t\tonDragStart,\n\t\tonDragEnd,\n\t\tdraggable,\n\t},\n\tref\n) {\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst blockTitle = useBlockDisplayTitle( {\n\t\tclientId,\n\t\tcontext: 'list-view',\n\t} );\n\tconst { isLocked } = useBlockLock( clientId );\n\n\t// The `href` attribute triggers the browser's native HTML drag operations.\n\t// When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.\n\t// We need to clear any HTML drag data to prevent `pasteHandler` from firing\n\t// inside the `useOnBlockDrop` hook.\n\tconst onDragStartHandler = ( event ) => {\n\t\tevent.dataTransfer.clearData();\n\t\tonDragStart?.( event );\n\t};\n\n\tfunction onKeyDownHandler( event ) {\n\t\tif ( event.keyCode === ENTER || event.keyCode === SPACE ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-list-view-block-select-button',\n\t\t\t\t\tclassName\n\t\t\t\t) }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tonKeyDown={ onKeyDownHandler }\n\t\t\t\tref={ ref }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\tonFocus={ onFocus }\n\t\t\t\tonDragStart={ onDragStartHandler }\n\t\t\t\tonDragEnd={ onDragEnd }\n\t\t\t\tdraggable={ draggable }\n\t\t\t\thref={ `#block-${ clientId }` }\n\t\t\t\taria-hidden={ true }\n\t\t\t>\n\t\t\t\t<ListViewExpander onClick={ onToggleExpanded } />\n\t\t\t\t<BlockIcon icon={ blockInformation?.icon } showColors />\n\t\t\t\t<HStack\n\t\t\t\t\talignment=\"center\"\n\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__label-wrapper\"\n\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\tspacing={ 1 }\n\t\t\t\t>\n\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__title\">\n\t\t\t\t\t\t<Truncate ellipsizeMode=\"auto\">{ blockTitle }</Truncate>\n\t\t\t\t\t</span>\n\t\t\t\t\t{ blockInformation?.anchor && (\n\t\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__anchor\">\n\t\t\t\t\t\t\t{ blockInformation.anchor }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isLocked && (\n\t\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__lock\">\n\t\t\t\t\t\t\t<Icon icon={ lock } />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t</HStack>\n\t\t\t</Button>\n\t\t</>\n\t);\n}\n\nexport default forwardRef( ListViewBlockSelectButton );\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/list-view/branch.js"],"names":["compact","memo","AsyncModeProvider","ListViewBlock","useListViewContext","isClientIdSelected","countBlocks","block","expandedState","draggedClientIds","isExpandedByDefault","isDragged","includes","clientId","isExpanded","innerBlocks","reduce","countReducer","count","length","ListViewBranch","props","blocks","selectBlock","showBlockMovers","selectedClientIds","level","path","isBranchSelected","listPosition","fixedListWindow","filteredBlocks","blockCount","nextPosition","map","index","itemInView","blockInView","position","updatedPath","hasNestedBlocks","shouldExpand","undefined","showBlock","isSelected","isSelectedBranch","defaultProps"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;;AACA,SAASC,IAAT,QAAqB,oBAArB;AACA,SAASC,iBAAT,QAAkC,iBAAlC;AAEA;AACA;AACA;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AA,WAAW,EAAGQ,WAFf;AAGC,MAAA,eAAe,EAAGC,eAHnB;AAIC,MAAA,KAAK,EAAGE,KAAK,GAAG,CAJjB;AAKC,MAAA,IAAI,EAAGa,WALR;AAMC,MAAA,YAAY,EAAGN,YAAY,GAAG,CAN/B;AAOC,MAAA,eAAe,EAAGH,eAPnB;AAQC,MAAA,gBAAgB,EAAGe,gBARpB;AASC,MAAA,iBAAiB,EAAGpB,iBATrB;AAUC,MAAA,UAAU,EAAGX;AAVd,MAzBF,CADD;AAyCA,GA/EC,CADH,CADD;AAoFA;;AAEDM,cAAc,CAAC0B,YAAf,GAA8B;AAC7BvB,EAAAA,WAAW,EAAE,MAAM,CAAE;AADQ,CAA9B;AAIA,eAAetB,IAAI,CAAEmB,cAAF,CAAnB","sourcesContent":["/**\n * External dependencies\n */\nimport { compact } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { memo } from '@wordpress/element';\nimport { AsyncModeProvider } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport ListViewBlock from './block';\nimport { useListViewContext } from './context';\nimport { isClientIdSelected } from './utils';\n\n/**\n * Given a block, returns the total number of blocks in that subtree. This is used to help determine\n * the list position of a block.\n *\n * When a block is collapsed, we do not count their children as part of that total. In the current drag\n * implementation dragged blocks and their children are not counted.\n *\n * @param {Object} block block tree\n * @param {Object} expandedState state that notes which branches are collapsed\n * @param {Array} draggedClientIds a list of dragged client ids\n * @param {boolean} isExpandedByDefault flag to determine the default fallback expanded state.\n * @return {number} block count\n */\nfunction countBlocks(\n\tblock,\n\texpandedState,\n\tdraggedClientIds,\n\tisExpandedByDefault\n) {\n\tconst isDragged = draggedClientIds?.includes( block.clientId );\n\tif ( isDragged ) {\n\t\treturn 0;\n\t}\n\tconst isExpanded = expandedState[ block.clientId ] ?? isExpandedByDefault;\n\n\tif ( isExpanded ) {\n\t\treturn (\n\t\t\t1 +\n\t\t\tblock.innerBlocks.reduce(\n\t\t\t\tcountReducer(\n\t\t\t\t\texpandedState,\n\t\t\t\t\tdraggedClientIds,\n\t\t\t\t\tisExpandedByDefault\n\t\t\t\t),\n\t\t\t\t0\n\t\t\t)\n\t\t);\n\t}\n\treturn 1;\n}\nconst countReducer = (\n\texpandedState,\n\tdraggedClientIds,\n\tisExpandedByDefault\n) => ( count, block ) => {\n\tconst isDragged = draggedClientIds?.includes( block.clientId );\n\tif ( isDragged ) {\n\t\treturn count;\n\t}\n\tconst isExpanded = expandedState[ block.clientId ] ?? isExpandedByDefault;\n\tif ( isExpanded && block.innerBlocks.length > 0 ) {\n\t\treturn (\n\t\t\tcount +\n\t\t\tcountBlocks(\n\t\t\t\tblock,\n\t\t\t\texpandedState,\n\t\t\t\tdraggedClientIds,\n\t\t\t\tisExpandedByDefault\n\t\t\t)\n\t\t);\n\t}\n\treturn count + 1;\n};\n\nfunction ListViewBranch( props ) {\n\tconst {\n\t\tblocks,\n\t\tselectBlock,\n\t\tshowBlockMovers,\n\t\tselectedClientIds,\n\t\tlevel = 1,\n\t\tpath = '',\n\t\tisBranchSelected = false,\n\t\tlistPosition = 0,\n\t\tfixedListWindow,\n\t\tisExpanded,\n\t} = props;\n\n\tconst { expandedState, draggedClientIds } = useListViewContext();\n\n\tconst filteredBlocks = compact( blocks );\n\tconst blockCount = filteredBlocks.length;\n\tlet nextPosition = listPosition;\n\n\treturn (\n\t\t<>\n\t\t\t{ filteredBlocks.map( ( block, index ) => {\n\t\t\t\tconst { clientId, innerBlocks } = block;\n\n\t\t\t\tif ( index > 0 ) {\n\t\t\t\t\tnextPosition += countBlocks(\n\t\t\t\t\t\tfilteredBlocks[ index - 1 ],\n\t\t\t\t\t\texpandedState,\n\t\t\t\t\t\tdraggedClientIds,\n\t\t\t\t\t\tisExpanded\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst { itemInView } = fixedListWindow;\n\t\t\t\tconst blockInView = itemInView( nextPosition );\n\n\t\t\t\tconst position = index + 1;\n\t\t\t\tconst updatedPath =\n\t\t\t\t\tpath.length > 0\n\t\t\t\t\t\t? `${ path }_${ position }`\n\t\t\t\t\t\t: `${ position }`;\n\t\t\t\tconst hasNestedBlocks = !! innerBlocks?.length;\n\n\t\t\t\tconst shouldExpand = hasNestedBlocks\n\t\t\t\t\t? expandedState[ clientId ] ?? isExpanded\n\t\t\t\t\t: undefined;\n\n\t\t\t\tconst isDragged = !! draggedClientIds?.includes( clientId );\n\n\t\t\t\tconst showBlock = isDragged || blockInView;\n\n\t\t\t\t// Make updates to the selected or dragged blocks synchronous,\n\t\t\t\t// but asynchronous for any other block.\n\t\t\t\tconst isSelected = isClientIdSelected(\n\t\t\t\t\tclientId,\n\t\t\t\t\tselectedClientIds\n\t\t\t\t);\n\t\t\t\tconst isSelectedBranch =\n\t\t\t\t\tisBranchSelected || ( isSelected && hasNestedBlocks );\n\t\t\t\treturn (\n\t\t\t\t\t<AsyncModeProvider key={ clientId } value={ ! isSelected }>\n\t\t\t\t\t\t{ showBlock && (\n\t\t\t\t\t\t\t<ListViewBlock\n\t\t\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\t\t\tselectBlock={ selectBlock }\n\t\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\t\tisBranchSelected={ isSelectedBranch }\n\t\t\t\t\t\t\t\tisDragged={ isDragged }\n\t\t\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\t\t\trowCount={ blockCount }\n\t\t\t\t\t\t\t\tsiblingBlockCount={ blockCount }\n\t\t\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\t\t\tpath={ updatedPath }\n\t\t\t\t\t\t\t\tisExpanded={ shouldExpand }\n\t\t\t\t\t\t\t\tlistPosition={ nextPosition }\n\t\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! showBlock && (\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td className=\"block-editor-list-view-placeholder\" />\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ hasNestedBlocks && shouldExpand && ! isDragged && (\n\t\t\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\t\t\tblocks={ innerBlocks }\n\t\t\t\t\t\t\t\tselectBlock={ selectBlock }\n\t\t\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\t\t\tlevel={ level + 1 }\n\t\t\t\t\t\t\t\tpath={ updatedPath }\n\t\t\t\t\t\t\t\tlistPosition={ nextPosition + 1 }\n\t\t\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\t\t\tisBranchSelected={ isSelectedBranch }\n\t\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</AsyncModeProvider>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n\nListViewBranch.defaultProps = {\n\tselectBlock: () => {},\n};\n\nexport default memo( ListViewBranch );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/list-view/branch.js"],"names":["compact","memo","AsyncModeProvider","ListViewBlock","useListViewContext","isClientIdSelected","countBlocks","block","expandedState","draggedClientIds","isExpandedByDefault","isDragged","includes","clientId","isExpanded","innerBlocks","reduce","countReducer","count","length","ListViewBranch","props","blocks","selectBlock","showBlockMovers","selectedClientIds","level","path","isBranchSelected","listPosition","fixedListWindow","filteredBlocks","blockCount","nextPosition","map","index","itemInView","blockInView","position","updatedPath","hasNestedBlocks","shouldExpand","undefined","showBlock","isSelected","isSelectedBranch","defaultProps"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;;AACA,SAASC,IAAT,QAAqB,oBAArB;AACA,SAASC,iBAAT,QAAkC,iB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ADV;AAEC,MAAA,WAAW,EAAGQ,WAFf;AAGC,MAAA,eAAe,EAAGC,eAHnB;AAIC,MAAA,KAAK,EAAGE,KAAK,GAAG,CAJjB;AAKC,MAAA,IAAI,EAAGa,WALR;AAMC,MAAA,YAAY,EAAGN,YAAY,GAAG,CAN/B;AAOC,MAAA,eAAe,EAAGH,eAPnB;AAQC,MAAA,gBAAgB,EAAGe,gBARpB;AASC,MAAA,iBAAiB,EAAGpB,iBATrB;AAUC,MAAA,UAAU,EAAGX;AAVd,MAzBF,CADD;AAyCA,GA/EC,CADH,CADD;AAoFA;;AAEDM,cAAc,CAAC0B,YAAf,GAA8B;AAC7BvB,EAAAA,WAAW,EAAE,MAAM,CAAE;AADQ,CAA9B;AAIA,eAAetB,IAAI,CAAEmB,cAAF,CAAnB","sourcesContent":["/**\n * External dependencies\n */\nimport { compact } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { memo } from '@wordpress/element';\nimport { AsyncModeProvider } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport ListViewBlock from './block';\nimport { useListViewContext } from './context';\nimport { isClientIdSelected } from './utils';\n\n/**\n * Given a block, returns the total number of blocks in that subtree. This is used to help determine\n * the list position of a block.\n *\n * When a block is collapsed, we do not count their children as part of that total. In the current drag\n * implementation dragged blocks and their children are not counted.\n *\n * @param {Object} block block tree\n * @param {Object} expandedState state that notes which branches are collapsed\n * @param {Array} draggedClientIds a list of dragged client ids\n * @param {boolean} isExpandedByDefault flag to determine the default fallback expanded state.\n * @return {number} block count\n */\nfunction countBlocks(\n\tblock,\n\texpandedState,\n\tdraggedClientIds,\n\tisExpandedByDefault\n) {\n\tconst isDragged = draggedClientIds?.includes( block.clientId );\n\tif ( isDragged ) {\n\t\treturn 0;\n\t}\n\tconst isExpanded = expandedState[ block.clientId ] ?? isExpandedByDefault;\n\n\tif ( isExpanded ) {\n\t\treturn (\n\t\t\t1 +\n\t\t\tblock.innerBlocks.reduce(\n\t\t\t\tcountReducer(\n\t\t\t\t\texpandedState,\n\t\t\t\t\tdraggedClientIds,\n\t\t\t\t\tisExpandedByDefault\n\t\t\t\t),\n\t\t\t\t0\n\t\t\t)\n\t\t);\n\t}\n\treturn 1;\n}\nconst countReducer =\n\t( expandedState, draggedClientIds, isExpandedByDefault ) =>\n\t( count, block ) => {\n\t\tconst isDragged = draggedClientIds?.includes( block.clientId );\n\t\tif ( isDragged ) {\n\t\t\treturn count;\n\t\t}\n\t\tconst isExpanded =\n\t\t\texpandedState[ block.clientId ] ?? isExpandedByDefault;\n\t\tif ( isExpanded && block.innerBlocks.length > 0 ) {\n\t\t\treturn (\n\t\t\t\tcount +\n\t\t\t\tcountBlocks(\n\t\t\t\t\tblock,\n\t\t\t\t\texpandedState,\n\t\t\t\t\tdraggedClientIds,\n\t\t\t\t\tisExpandedByDefault\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\treturn count + 1;\n\t};\n\nfunction ListViewBranch( props ) {\n\tconst {\n\t\tblocks,\n\t\tselectBlock,\n\t\tshowBlockMovers,\n\t\tselectedClientIds,\n\t\tlevel = 1,\n\t\tpath = '',\n\t\tisBranchSelected = false,\n\t\tlistPosition = 0,\n\t\tfixedListWindow,\n\t\tisExpanded,\n\t} = props;\n\n\tconst { expandedState, draggedClientIds } = useListViewContext();\n\n\tconst filteredBlocks = compact( blocks );\n\tconst blockCount = filteredBlocks.length;\n\tlet nextPosition = listPosition;\n\n\treturn (\n\t\t<>\n\t\t\t{ filteredBlocks.map( ( block, index ) => {\n\t\t\t\tconst { clientId, innerBlocks } = block;\n\n\t\t\t\tif ( index > 0 ) {\n\t\t\t\t\tnextPosition += countBlocks(\n\t\t\t\t\t\tfilteredBlocks[ index - 1 ],\n\t\t\t\t\t\texpandedState,\n\t\t\t\t\t\tdraggedClientIds,\n\t\t\t\t\t\tisExpanded\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst { itemInView } = fixedListWindow;\n\t\t\t\tconst blockInView = itemInView( nextPosition );\n\n\t\t\t\tconst position = index + 1;\n\t\t\t\tconst updatedPath =\n\t\t\t\t\tpath.length > 0\n\t\t\t\t\t\t? `${ path }_${ position }`\n\t\t\t\t\t\t: `${ position }`;\n\t\t\t\tconst hasNestedBlocks = !! innerBlocks?.length;\n\n\t\t\t\tconst shouldExpand = hasNestedBlocks\n\t\t\t\t\t? expandedState[ clientId ] ?? isExpanded\n\t\t\t\t\t: undefined;\n\n\t\t\t\tconst isDragged = !! draggedClientIds?.includes( clientId );\n\n\t\t\t\tconst showBlock = isDragged || blockInView;\n\n\t\t\t\t// Make updates to the selected or dragged blocks synchronous,\n\t\t\t\t// but asynchronous for any other block.\n\t\t\t\tconst isSelected = isClientIdSelected(\n\t\t\t\t\tclientId,\n\t\t\t\t\tselectedClientIds\n\t\t\t\t);\n\t\t\t\tconst isSelectedBranch =\n\t\t\t\t\tisBranchSelected || ( isSelected && hasNestedBlocks );\n\t\t\t\treturn (\n\t\t\t\t\t<AsyncModeProvider key={ clientId } value={ ! isSelected }>\n\t\t\t\t\t\t{ showBlock && (\n\t\t\t\t\t\t\t<ListViewBlock\n\t\t\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\t\t\tselectBlock={ selectBlock }\n\t\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\t\tisBranchSelected={ isSelectedBranch }\n\t\t\t\t\t\t\t\tisDragged={ isDragged }\n\t\t\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\t\t\trowCount={ blockCount }\n\t\t\t\t\t\t\t\tsiblingBlockCount={ blockCount }\n\t\t\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\t\t\tpath={ updatedPath }\n\t\t\t\t\t\t\t\tisExpanded={ shouldExpand }\n\t\t\t\t\t\t\t\tlistPosition={ nextPosition }\n\t\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! showBlock && (\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td className=\"block-editor-list-view-placeholder\" />\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ hasNestedBlocks && shouldExpand && ! isDragged && (\n\t\t\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\t\t\tblocks={ innerBlocks }\n\t\t\t\t\t\t\t\tselectBlock={ selectBlock }\n\t\t\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\t\t\tlevel={ level + 1 }\n\t\t\t\t\t\t\t\tpath={ updatedPath }\n\t\t\t\t\t\t\t\tlistPosition={ nextPosition + 1 }\n\t\t\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\t\t\tisBranchSelected={ isSelectedBranch }\n\t\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</AsyncModeProvider>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n\nListViewBranch.defaultProps = {\n\tselectBlock: () => {},\n};\n\nexport default memo( ListViewBranch );\n"]}