@wordpress/block-editor 12.4.0 → 12.6.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 (524) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +1 -0
  3. package/build/components/block-draggable/index.js +6 -3
  4. package/build/components/block-draggable/index.js.map +1 -1
  5. package/build/components/block-draggable/index.native.js +2 -2
  6. package/build/components/block-draggable/index.native.js.map +1 -1
  7. package/build/components/block-edit/edit.js +25 -13
  8. package/build/components/block-edit/edit.js.map +1 -1
  9. package/build/components/block-heading-level-dropdown/heading-level-icon.js +10 -2
  10. package/build/components/block-heading-level-dropdown/heading-level-icon.js.map +1 -1
  11. package/build/components/block-heading-level-dropdown/index.native.js +4 -3
  12. package/build/components/block-heading-level-dropdown/index.native.js.map +1 -1
  13. package/build/components/block-list/block-outline.native.js +14 -18
  14. package/build/components/block-list/block-outline.native.js.map +1 -1
  15. package/build/components/block-list/block.native.js +21 -42
  16. package/build/components/block-list/block.native.js.map +1 -1
  17. package/build/components/block-lock/toolbar.js +25 -6
  18. package/build/components/block-lock/toolbar.js.map +1 -1
  19. package/build/components/block-mover/index.native.js +1 -1
  20. package/build/components/block-mover/index.native.js.map +1 -1
  21. package/build/components/block-parent-selector/index.js +8 -5
  22. package/build/components/block-parent-selector/index.js.map +1 -1
  23. package/build/components/block-removal-warning-modal/index.js +15 -25
  24. package/build/components/block-removal-warning-modal/index.js.map +1 -1
  25. package/build/components/block-settings/button.native.js +2 -2
  26. package/build/components/block-settings/button.native.js.map +1 -1
  27. package/build/components/{block-mobile-toolbar/block-actions-menu.native.js → block-toolbar/block-toolbar-menu.native.js} +10 -11
  28. package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -0
  29. package/build/components/block-toolbar/index.js +12 -8
  30. package/build/components/block-toolbar/index.js.map +1 -1
  31. package/build/components/block-toolbar/index.native.js +62 -3
  32. package/build/components/block-toolbar/index.native.js.map +1 -1
  33. package/build/components/block-tools/block-contextual-toolbar.js +7 -11
  34. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  35. package/build/components/colors-gradients/control.js +4 -2
  36. package/build/components/colors-gradients/control.js.map +1 -1
  37. package/build/components/dimensions-tool/aspect-ratio-tool.js +99 -0
  38. package/build/components/dimensions-tool/aspect-ratio-tool.js.map +1 -0
  39. package/build/components/dimensions-tool/index.js +207 -0
  40. package/build/components/dimensions-tool/index.js.map +1 -0
  41. package/build/components/dimensions-tool/scale-tool.js +111 -0
  42. package/build/components/dimensions-tool/scale-tool.js.map +1 -0
  43. package/build/components/dimensions-tool/width-height-tool.js +125 -0
  44. package/build/components/dimensions-tool/width-height-tool.js.map +1 -0
  45. package/build/components/global-styles/color-panel.js +22 -16
  46. package/build/components/global-styles/color-panel.js.map +1 -1
  47. package/build/components/global-styles/dimensions-panel.js +13 -2
  48. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  49. package/build/components/global-styles/filters-panel.js +1 -1
  50. package/build/components/global-styles/filters-panel.js.map +1 -1
  51. package/build/components/global-styles/get-block-css-selector.js +4 -8
  52. package/build/components/global-styles/get-block-css-selector.js.map +1 -1
  53. package/build/components/global-styles/hooks.js +15 -25
  54. package/build/components/global-styles/hooks.js.map +1 -1
  55. package/build/components/global-styles/typography-panel.js +52 -5
  56. package/build/components/global-styles/typography-panel.js.map +1 -1
  57. package/build/components/global-styles/use-global-styles-output.js +12 -18
  58. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  59. package/build/components/global-styles/utils.js +6 -6
  60. package/build/components/global-styles/utils.js.map +1 -1
  61. package/build/components/iframe/index.js +36 -48
  62. package/build/components/iframe/index.js.map +1 -1
  63. package/build/components/iframe/use-compatibility-styles.js +5 -0
  64. package/build/components/iframe/use-compatibility-styles.js.map +1 -1
  65. package/build/components/image-editor/aspect-ratio-dropdown.js +1 -1
  66. package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  67. package/build/components/image-editor/use-save-image.js +1 -2
  68. package/build/components/image-editor/use-save-image.js.map +1 -1
  69. package/build/components/image-size-control/index.js +6 -0
  70. package/build/components/image-size-control/index.js.map +1 -1
  71. package/build/components/index.js +9 -0
  72. package/build/components/index.js.map +1 -1
  73. package/build/components/inner-blocks/index.js +3 -1
  74. package/build/components/inner-blocks/index.js.map +1 -1
  75. package/build/components/inner-blocks/index.native.js +3 -1
  76. package/build/components/inner-blocks/index.native.js.map +1 -1
  77. package/build/components/inner-blocks/use-nested-settings-update.js +33 -7
  78. package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  79. package/build/components/inserter/block-patterns-explorer/patterns-list.js +2 -2
  80. package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
  81. package/build/components/inserter/block-patterns-tab.js +7 -35
  82. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  83. package/build/components/inserter/hooks/use-block-types-state.js +3 -4
  84. package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
  85. package/build/components/inserter/hooks/use-patterns-state.js +9 -3
  86. package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
  87. package/build/components/inserter/index.js +2 -4
  88. package/build/components/inserter/index.js.map +1 -1
  89. package/build/components/inserter/index.native.js +21 -32
  90. package/build/components/inserter/index.native.js.map +1 -1
  91. package/build/components/inserter/media-tab/hooks.js +2 -21
  92. package/build/components/inserter/media-tab/hooks.js.map +1 -1
  93. package/build/components/inserter/reusable-block-rename-hint.js +82 -0
  94. package/build/components/inserter/reusable-block-rename-hint.js.map +1 -0
  95. package/build/components/inserter/reusable-blocks-tab.js +6 -2
  96. package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
  97. package/build/components/inserter/reusable-blocks-tab.native.js +2 -2
  98. package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  99. package/build/components/inserter/tabs.native.js +1 -1
  100. package/build/components/inserter/tabs.native.js.map +1 -1
  101. package/build/components/inserter-draggable-blocks/index.js +9 -1
  102. package/build/components/inserter-draggable-blocks/index.js.map +1 -1
  103. package/build/components/link-control/constants.js +1 -1
  104. package/build/components/link-control/constants.js.map +1 -1
  105. package/build/components/link-control/index.js +21 -16
  106. package/build/components/link-control/index.js.map +1 -1
  107. package/build/components/link-control/search-create-button.js +5 -21
  108. package/build/components/link-control/search-create-button.js.map +1 -1
  109. package/build/components/link-control/search-input.js +4 -4
  110. package/build/components/link-control/search-input.js.map +1 -1
  111. package/build/components/link-control/search-item.js +13 -30
  112. package/build/components/link-control/search-item.js.map +1 -1
  113. package/build/components/link-control/search-results.js +2 -2
  114. package/build/components/link-control/search-results.js.map +1 -1
  115. package/build/components/link-control/settings-drawer.js +2 -3
  116. package/build/components/link-control/settings-drawer.js.map +1 -1
  117. package/build/components/list-view/appender.js +2 -6
  118. package/build/components/list-view/appender.js.map +1 -1
  119. package/build/components/list-view/use-list-view-client-ids.js +2 -2
  120. package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
  121. package/build/components/media-placeholder/index.native.js +65 -31
  122. package/build/components/media-placeholder/index.native.js.map +1 -1
  123. package/build/components/preview-options/index.js +2 -2
  124. package/build/components/preview-options/index.js.map +1 -1
  125. package/build/components/provider/index.js +5 -2
  126. package/build/components/provider/index.js.map +1 -1
  127. package/build/components/provider/use-block-sync.js +21 -0
  128. package/build/components/provider/use-block-sync.js.map +1 -1
  129. package/build/components/resolution-tool/index.js +55 -0
  130. package/build/components/resolution-tool/index.js.map +1 -0
  131. package/build/components/rich-text/content.js +0 -36
  132. package/build/components/rich-text/content.js.map +1 -1
  133. package/build/components/rich-text/get-rich-text-values.js +118 -0
  134. package/build/components/rich-text/get-rich-text-values.js.map +1 -0
  135. package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
  136. package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
  137. package/build/components/spacing-sizes-control/input-controls/axial.js +6 -2
  138. package/build/components/spacing-sizes-control/input-controls/axial.js.map +1 -1
  139. package/build/components/spacing-sizes-control/input-controls/separated.js +5 -1
  140. package/build/components/spacing-sizes-control/input-controls/separated.js.map +1 -1
  141. package/build/components/spacing-sizes-control/input-controls/single.js +5 -1
  142. package/build/components/spacing-sizes-control/input-controls/single.js.map +1 -1
  143. package/build/components/spacing-sizes-control/utils.js +1 -1
  144. package/build/components/spacing-sizes-control/utils.js.map +1 -1
  145. package/build/components/url-input/index.js +4 -2
  146. package/build/components/url-input/index.js.map +1 -1
  147. package/build/components/use-block-display-information/index.js +7 -3
  148. package/build/components/use-block-display-information/index.js.map +1 -1
  149. package/build/components/use-block-drop-zone/index.native.js +49 -8
  150. package/build/components/use-block-drop-zone/index.native.js.map +1 -1
  151. package/build/components/use-setting/index.js +5 -9
  152. package/build/components/use-setting/index.js.map +1 -1
  153. package/build/components/writing-flow/use-tab-nav.js +10 -27
  154. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  155. package/build/components/writing-mode-control/index.js +70 -0
  156. package/build/components/writing-mode-control/index.js.map +1 -0
  157. package/build/hooks/behaviors.js +25 -20
  158. package/build/hooks/behaviors.js.map +1 -1
  159. package/build/hooks/margin.js +1 -1
  160. package/build/hooks/margin.js.map +1 -1
  161. package/build/hooks/padding.js +1 -1
  162. package/build/hooks/padding.js.map +1 -1
  163. package/build/hooks/supports.js +7 -1
  164. package/build/hooks/supports.js.map +1 -1
  165. package/build/hooks/typography.js +2 -1
  166. package/build/hooks/typography.js.map +1 -1
  167. package/build/hooks/utils.js +5 -9
  168. package/build/hooks/utils.js.map +1 -1
  169. package/build/private-apis.js +16 -3
  170. package/build/private-apis.js.map +1 -1
  171. package/build/private-apis.native.js +3 -0
  172. package/build/private-apis.native.js.map +1 -1
  173. package/build/store/actions.js +196 -2
  174. package/build/store/actions.js.map +1 -1
  175. package/build/store/defaults.js +1 -0
  176. package/build/store/defaults.js.map +1 -1
  177. package/build/store/index.js +10 -1
  178. package/build/store/index.js.map +1 -1
  179. package/build/store/private-actions.js +46 -40
  180. package/build/store/private-actions.js.map +1 -1
  181. package/build/store/private-selectors.js +8 -9
  182. package/build/store/private-selectors.js.map +1 -1
  183. package/build/store/reducer.js +22 -9
  184. package/build/store/reducer.js.map +1 -1
  185. package/build/store/selectors.js +52 -23
  186. package/build/store/selectors.js.map +1 -1
  187. package/build/utils/object.js +38 -2
  188. package/build/utils/object.js.map +1 -1
  189. package/build-module/components/block-draggable/index.js +6 -3
  190. package/build-module/components/block-draggable/index.js.map +1 -1
  191. package/build-module/components/block-draggable/index.native.js +2 -2
  192. package/build-module/components/block-draggable/index.native.js.map +1 -1
  193. package/build-module/components/block-edit/edit.js +27 -10
  194. package/build-module/components/block-edit/edit.js.map +1 -1
  195. package/build-module/components/block-heading-level-dropdown/heading-level-icon.js +9 -2
  196. package/build-module/components/block-heading-level-dropdown/heading-level-icon.js.map +1 -1
  197. package/build-module/components/block-heading-level-dropdown/index.native.js +4 -3
  198. package/build-module/components/block-heading-level-dropdown/index.native.js.map +1 -1
  199. package/build-module/components/block-list/block-outline.native.js +14 -18
  200. package/build-module/components/block-list/block-outline.native.js.map +1 -1
  201. package/build-module/components/block-list/block.native.js +24 -43
  202. package/build-module/components/block-list/block.native.js.map +1 -1
  203. package/build-module/components/block-lock/toolbar.js +25 -7
  204. package/build-module/components/block-lock/toolbar.js.map +1 -1
  205. package/build-module/components/block-mover/index.native.js +3 -3
  206. package/build-module/components/block-mover/index.native.js.map +1 -1
  207. package/build-module/components/block-parent-selector/index.js +7 -5
  208. package/build-module/components/block-parent-selector/index.js.map +1 -1
  209. package/build-module/components/block-removal-warning-modal/index.js +17 -24
  210. package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
  211. package/build-module/components/block-settings/button.native.js +3 -3
  212. package/build-module/components/block-settings/button.native.js.map +1 -1
  213. package/build-module/components/{block-mobile-toolbar/block-actions-menu.native.js → block-toolbar/block-toolbar-menu.native.js} +13 -13
  214. package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -0
  215. package/build-module/components/block-toolbar/index.js +12 -8
  216. package/build-module/components/block-toolbar/index.js.map +1 -1
  217. package/build-module/components/block-toolbar/index.native.js +60 -4
  218. package/build-module/components/block-toolbar/index.native.js.map +1 -1
  219. package/build-module/components/block-tools/block-contextual-toolbar.js +8 -11
  220. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  221. package/build-module/components/colors-gradients/control.js +3 -2
  222. package/build-module/components/colors-gradients/control.js.map +1 -1
  223. package/build-module/components/dimensions-tool/aspect-ratio-tool.js +87 -0
  224. package/build-module/components/dimensions-tool/aspect-ratio-tool.js.map +1 -0
  225. package/build-module/components/dimensions-tool/index.js +195 -0
  226. package/build-module/components/dimensions-tool/index.js.map +1 -0
  227. package/build-module/components/dimensions-tool/scale-tool.js +103 -0
  228. package/build-module/components/dimensions-tool/scale-tool.js.map +1 -0
  229. package/build-module/components/dimensions-tool/width-height-tool.js +122 -0
  230. package/build-module/components/dimensions-tool/width-height-tool.js.map +1 -0
  231. package/build-module/components/global-styles/color-panel.js +22 -16
  232. package/build-module/components/global-styles/color-panel.js.map +1 -1
  233. package/build-module/components/global-styles/dimensions-panel.js +13 -2
  234. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  235. package/build-module/components/global-styles/filters-panel.js +2 -2
  236. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  237. package/build-module/components/global-styles/get-block-css-selector.js +4 -8
  238. package/build-module/components/global-styles/get-block-css-selector.js.map +1 -1
  239. package/build-module/components/global-styles/hooks.js +14 -24
  240. package/build-module/components/global-styles/hooks.js.map +1 -1
  241. package/build-module/components/global-styles/typography-panel.js +51 -5
  242. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  243. package/build-module/components/global-styles/use-global-styles-output.js +13 -18
  244. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  245. package/build-module/components/global-styles/utils.js +5 -5
  246. package/build-module/components/global-styles/utils.js.map +1 -1
  247. package/build-module/components/iframe/index.js +37 -49
  248. package/build-module/components/iframe/index.js.map +1 -1
  249. package/build-module/components/iframe/use-compatibility-styles.js +5 -0
  250. package/build-module/components/iframe/use-compatibility-styles.js.map +1 -1
  251. package/build-module/components/image-editor/aspect-ratio-dropdown.js +1 -1
  252. package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  253. package/build-module/components/image-editor/use-save-image.js +1 -2
  254. package/build-module/components/image-editor/use-save-image.js.map +1 -1
  255. package/build-module/components/image-size-control/index.js +5 -0
  256. package/build-module/components/image-size-control/index.js.map +1 -1
  257. package/build-module/components/index.js +1 -0
  258. package/build-module/components/index.js.map +1 -1
  259. package/build-module/components/inner-blocks/index.js +3 -1
  260. package/build-module/components/inner-blocks/index.js.map +1 -1
  261. package/build-module/components/inner-blocks/index.native.js +3 -1
  262. package/build-module/components/inner-blocks/index.native.js.map +1 -1
  263. package/build-module/components/inner-blocks/use-nested-settings-update.js +30 -7
  264. package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  265. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js +2 -2
  266. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
  267. package/build-module/components/inserter/block-patterns-tab.js +7 -33
  268. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  269. package/build-module/components/inserter/hooks/use-block-types-state.js +3 -4
  270. package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
  271. package/build-module/components/inserter/hooks/use-patterns-state.js +9 -3
  272. package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
  273. package/build-module/components/inserter/index.js +2 -4
  274. package/build-module/components/inserter/index.js.map +1 -1
  275. package/build-module/components/inserter/index.native.js +22 -33
  276. package/build-module/components/inserter/index.native.js.map +1 -1
  277. package/build-module/components/inserter/media-tab/hooks.js +2 -21
  278. package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
  279. package/build-module/components/inserter/reusable-block-rename-hint.js +67 -0
  280. package/build-module/components/inserter/reusable-block-rename-hint.js.map +1 -0
  281. package/build-module/components/inserter/reusable-blocks-tab.js +5 -2
  282. package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
  283. package/build-module/components/inserter/reusable-blocks-tab.native.js +2 -2
  284. package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  285. package/build-module/components/inserter/tabs.native.js +1 -1
  286. package/build-module/components/inserter/tabs.native.js.map +1 -1
  287. package/build-module/components/inserter-draggable-blocks/index.js +9 -2
  288. package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
  289. package/build-module/components/link-control/constants.js +1 -1
  290. package/build-module/components/link-control/constants.js.map +1 -1
  291. package/build-module/components/link-control/index.js +21 -16
  292. package/build-module/components/link-control/index.js.map +1 -1
  293. package/build-module/components/link-control/search-create-button.js +7 -20
  294. package/build-module/components/link-control/search-create-button.js.map +1 -1
  295. package/build-module/components/link-control/search-input.js +4 -4
  296. package/build-module/components/link-control/search-input.js.map +1 -1
  297. package/build-module/components/link-control/search-item.js +14 -28
  298. package/build-module/components/link-control/search-item.js.map +1 -1
  299. package/build-module/components/link-control/search-results.js +3 -3
  300. package/build-module/components/link-control/search-results.js.map +1 -1
  301. package/build-module/components/link-control/settings-drawer.js +4 -5
  302. package/build-module/components/link-control/settings-drawer.js.map +1 -1
  303. package/build-module/components/list-view/appender.js +2 -6
  304. package/build-module/components/list-view/appender.js.map +1 -1
  305. package/build-module/components/list-view/use-list-view-client-ids.js +2 -2
  306. package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
  307. package/build-module/components/media-placeholder/index.native.js +66 -33
  308. package/build-module/components/media-placeholder/index.native.js.map +1 -1
  309. package/build-module/components/preview-options/index.js +2 -2
  310. package/build-module/components/preview-options/index.js.map +1 -1
  311. package/build-module/components/provider/index.js +5 -2
  312. package/build-module/components/provider/index.js.map +1 -1
  313. package/build-module/components/provider/use-block-sync.js +21 -0
  314. package/build-module/components/provider/use-block-sync.js.map +1 -1
  315. package/build-module/components/resolution-tool/index.js +45 -0
  316. package/build-module/components/resolution-tool/index.js.map +1 -0
  317. package/build-module/components/rich-text/content.js +1 -36
  318. package/build-module/components/rich-text/content.js.map +1 -1
  319. package/build-module/components/rich-text/get-rich-text-values.js +105 -0
  320. package/build-module/components/rich-text/get-rich-text-values.js.map +1 -0
  321. package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
  322. package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
  323. package/build-module/components/spacing-sizes-control/input-controls/axial.js +7 -3
  324. package/build-module/components/spacing-sizes-control/input-controls/axial.js.map +1 -1
  325. package/build-module/components/spacing-sizes-control/input-controls/separated.js +6 -2
  326. package/build-module/components/spacing-sizes-control/input-controls/separated.js.map +1 -1
  327. package/build-module/components/spacing-sizes-control/input-controls/single.js +6 -2
  328. package/build-module/components/spacing-sizes-control/input-controls/single.js.map +1 -1
  329. package/build-module/components/spacing-sizes-control/utils.js +1 -1
  330. package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
  331. package/build-module/components/url-input/index.js +4 -2
  332. package/build-module/components/url-input/index.js.map +1 -1
  333. package/build-module/components/use-block-display-information/index.js +7 -3
  334. package/build-module/components/use-block-display-information/index.js.map +1 -1
  335. package/build-module/components/use-block-drop-zone/index.native.js +50 -8
  336. package/build-module/components/use-block-drop-zone/index.native.js.map +1 -1
  337. package/build-module/components/use-setting/index.js +5 -9
  338. package/build-module/components/use-setting/index.js.map +1 -1
  339. package/build-module/components/writing-flow/use-tab-nav.js +8 -26
  340. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  341. package/build-module/components/writing-mode-control/index.js +57 -0
  342. package/build-module/components/writing-mode-control/index.js.map +1 -0
  343. package/build-module/hooks/behaviors.js +26 -20
  344. package/build-module/hooks/behaviors.js.map +1 -1
  345. package/build-module/hooks/margin.js +1 -1
  346. package/build-module/hooks/margin.js.map +1 -1
  347. package/build-module/hooks/padding.js +1 -1
  348. package/build-module/hooks/padding.js.map +1 -1
  349. package/build-module/hooks/supports.js +7 -1
  350. package/build-module/hooks/supports.js.map +1 -1
  351. package/build-module/hooks/typography.js +2 -1
  352. package/build-module/hooks/typography.js.map +1 -1
  353. package/build-module/hooks/utils.js +6 -9
  354. package/build-module/hooks/utils.js.map +1 -1
  355. package/build-module/private-apis.js +11 -2
  356. package/build-module/private-apis.js.map +1 -1
  357. package/build-module/private-apis.native.js +2 -0
  358. package/build-module/private-apis.native.js.map +1 -1
  359. package/build-module/store/actions.js +193 -3
  360. package/build-module/store/actions.js.map +1 -1
  361. package/build-module/store/defaults.js +1 -0
  362. package/build-module/store/defaults.js.map +1 -1
  363. package/build-module/store/index.js +10 -1
  364. package/build-module/store/index.js.map +1 -1
  365. package/build-module/store/private-actions.js +45 -36
  366. package/build-module/store/private-actions.js.map +1 -1
  367. package/build-module/store/private-selectors.js +5 -5
  368. package/build-module/store/private-selectors.js.map +1 -1
  369. package/build-module/store/reducer.js +22 -9
  370. package/build-module/store/reducer.js.map +1 -1
  371. package/build-module/store/selectors.js +49 -21
  372. package/build-module/store/selectors.js.map +1 -1
  373. package/build-module/utils/object.js +34 -2
  374. package/build-module/utils/object.js.map +1 -1
  375. package/build-style/content-rtl.css +4 -0
  376. package/build-style/content.css +4 -0
  377. package/build-style/style-rtl.css +137 -129
  378. package/build-style/style.css +137 -129
  379. package/package.json +33 -32
  380. package/src/components/alignment-control/test/__snapshots__/index.js.snap +6 -6
  381. package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +5 -5
  382. package/src/components/block-controls/README.md +89 -0
  383. package/src/components/block-draggable/index.js +13 -4
  384. package/src/components/block-draggable/index.native.js +7 -3
  385. package/src/components/block-draggable/style.scss +1 -0
  386. package/src/components/block-draggable/test/index.native.js +0 -54
  387. package/src/components/block-edit/edit.js +26 -9
  388. package/src/components/block-edit/test/edit.js +1 -1
  389. package/src/components/block-heading-level-dropdown/heading-level-icon.js +6 -1
  390. package/src/components/block-heading-level-dropdown/index.native.js +8 -4
  391. package/src/components/block-inspector/style.scss +2 -1
  392. package/src/components/block-list/block-outline.native.js +26 -25
  393. package/src/components/block-list/block.native.js +24 -38
  394. package/src/components/block-list/block.native.scss +18 -40
  395. package/src/components/block-list/style.native.scss +3 -3
  396. package/src/components/block-lock/toolbar.js +34 -6
  397. package/src/components/block-mover/index.native.js +3 -3
  398. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +16 -6
  399. package/src/components/block-parent-selector/index.js +13 -8
  400. package/src/components/block-removal-warning-modal/index.js +17 -33
  401. package/src/components/block-settings/button.native.js +12 -6
  402. package/src/components/{block-mobile-toolbar/block-actions-menu.native.js → block-toolbar/block-toolbar-menu.native.js} +19 -18
  403. package/src/components/block-toolbar/index.js +11 -9
  404. package/src/components/block-toolbar/index.native.js +86 -6
  405. package/src/components/{block-mobile-toolbar/test/block-actions-menu.native.js → block-toolbar/test/block-toolbar-menu.native.js} +20 -54
  406. package/src/components/block-toolbar/test/index.native.js +42 -0
  407. package/src/components/block-tools/block-contextual-toolbar.js +5 -11
  408. package/src/components/block-tools/style.scss +73 -26
  409. package/src/components/button-block-appender/styles.native.scss +2 -2
  410. package/src/components/caption/README.md +49 -0
  411. package/src/components/colors-gradients/control.js +3 -2
  412. package/src/components/default-block-appender/content.scss +11 -0
  413. package/src/components/dimensions-tool/aspect-ratio-tool.js +124 -0
  414. package/src/components/dimensions-tool/index.js +212 -0
  415. package/src/components/dimensions-tool/scale-tool.js +124 -0
  416. package/src/components/dimensions-tool/stories/aspect-ratio-tool.js +52 -0
  417. package/src/components/dimensions-tool/stories/index.js +54 -0
  418. package/src/components/dimensions-tool/stories/scale-tool.js +48 -0
  419. package/src/components/dimensions-tool/stories/width-height-tool.js +54 -0
  420. package/src/components/dimensions-tool/test/index.js +641 -0
  421. package/src/components/dimensions-tool/width-height-tool.js +113 -0
  422. package/src/components/font-family/README.md +71 -0
  423. package/src/components/global-styles/color-panel.js +24 -17
  424. package/src/components/global-styles/dimensions-panel.js +8 -2
  425. package/src/components/global-styles/filters-panel.js +2 -2
  426. package/src/components/global-styles/get-block-css-selector.js +5 -9
  427. package/src/components/global-styles/hooks.js +22 -26
  428. package/src/components/global-styles/typography-panel.js +57 -5
  429. package/src/components/global-styles/use-global-styles-output.js +36 -18
  430. package/src/components/global-styles/utils.js +15 -6
  431. package/src/components/iframe/index.js +30 -56
  432. package/src/components/iframe/use-compatibility-styles.js +5 -0
  433. package/src/components/image-editor/aspect-ratio-dropdown.js +1 -1
  434. package/src/components/image-editor/use-save-image.js +0 -1
  435. package/src/components/image-size-control/index.js +6 -0
  436. package/src/components/index.js +1 -0
  437. package/src/components/inner-blocks/README.md +10 -0
  438. package/src/components/inner-blocks/index.js +4 -0
  439. package/src/components/inner-blocks/index.native.js +4 -0
  440. package/src/components/inner-blocks/use-nested-settings-update.js +32 -5
  441. package/src/components/inserter/block-patterns-explorer/patterns-list.js +8 -2
  442. package/src/components/inserter/block-patterns-tab.js +8 -56
  443. package/src/components/inserter/hooks/use-block-types-state.js +3 -4
  444. package/src/components/inserter/hooks/use-patterns-state.js +35 -19
  445. package/src/components/inserter/index.js +2 -3
  446. package/src/components/inserter/index.native.js +17 -36
  447. package/src/components/inserter/media-tab/hooks.js +2 -22
  448. package/src/components/inserter/reusable-block-rename-hint.js +69 -0
  449. package/src/components/inserter/reusable-blocks-tab.js +5 -1
  450. package/src/components/inserter/reusable-blocks-tab.native.js +2 -2
  451. package/src/components/inserter/style.native.scss +10 -15
  452. package/src/components/inserter/style.scss +28 -0
  453. package/src/components/inserter/tabs.native.js +5 -1
  454. package/src/components/inserter-draggable-blocks/index.js +13 -2
  455. package/src/components/link-control/constants.js +1 -1
  456. package/src/components/link-control/index.js +36 -29
  457. package/src/components/link-control/search-create-button.js +8 -26
  458. package/src/components/link-control/search-input.js +4 -3
  459. package/src/components/link-control/search-item.js +21 -43
  460. package/src/components/link-control/search-results.js +48 -46
  461. package/src/components/link-control/settings-drawer.js +6 -5
  462. package/src/components/link-control/style.scss +58 -123
  463. package/src/components/link-control/test/index.js +161 -123
  464. package/src/components/list-view/appender.js +5 -6
  465. package/src/components/list-view/style.scss +1 -2
  466. package/src/components/list-view/use-list-view-client-ids.js +2 -2
  467. package/src/components/media-placeholder/index.native.js +108 -59
  468. package/src/components/media-placeholder/styles.native.scss +59 -24
  469. package/src/components/media-replace-flow/test/index.js +1 -1
  470. package/src/components/panel-color-settings/README.md +98 -0
  471. package/src/components/preview-options/README.md +18 -17
  472. package/src/components/preview-options/index.js +2 -2
  473. package/src/components/provider/index.js +9 -2
  474. package/src/components/provider/test/use-block-sync.js +21 -6
  475. package/src/components/provider/use-block-sync.js +19 -0
  476. package/src/components/recursion-provider/README.md +101 -0
  477. package/src/components/resolution-tool/index.js +56 -0
  478. package/src/components/resolution-tool/stories/index.js +48 -0
  479. package/src/components/rich-text/content.js +1 -46
  480. package/src/components/rich-text/get-rich-text-values.js +105 -0
  481. package/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
  482. package/src/components/spacing-sizes-control/input-controls/axial.js +17 -2
  483. package/src/components/spacing-sizes-control/input-controls/separated.js +17 -2
  484. package/src/components/spacing-sizes-control/input-controls/single.js +12 -2
  485. package/src/components/spacing-sizes-control/utils.js +1 -1
  486. package/src/components/text-transform-control/README.md +44 -0
  487. package/src/components/url-input/index.js +2 -0
  488. package/src/components/use-block-display-information/index.js +12 -5
  489. package/src/components/use-block-drop-zone/index.native.js +65 -28
  490. package/src/components/use-setting/index.js +8 -8
  491. package/src/components/writing-flow/use-tab-nav.js +10 -33
  492. package/src/components/writing-mode-control/index.js +68 -0
  493. package/src/components/writing-mode-control/style.scss +18 -0
  494. package/src/hooks/behaviors.js +25 -16
  495. package/src/hooks/margin.js +4 -1
  496. package/src/hooks/padding.js +4 -1
  497. package/src/hooks/supports.js +7 -0
  498. package/src/hooks/typography.js +2 -0
  499. package/src/hooks/utils.js +8 -7
  500. package/src/private-apis.js +13 -1
  501. package/src/private-apis.native.js +2 -0
  502. package/src/store/actions.js +195 -3
  503. package/src/store/defaults.js +1 -0
  504. package/src/store/index.js +10 -0
  505. package/src/store/private-actions.js +39 -39
  506. package/src/store/private-selectors.js +5 -8
  507. package/src/store/reducer.js +22 -9
  508. package/src/store/selectors.js +87 -25
  509. package/src/store/test/actions.js +114 -0
  510. package/src/store/test/private-actions.js +56 -0
  511. package/src/store/test/private-selectors.js +5 -5
  512. package/src/store/test/reducer.js +14 -7
  513. package/src/store/test/selectors.js +1 -1
  514. package/src/utils/object.js +32 -2
  515. package/src/utils/test/object.js +36 -0
  516. package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +0 -1
  517. package/build/components/block-mobile-toolbar/index.native.js +0 -135
  518. package/build/components/block-mobile-toolbar/index.native.js.map +0 -1
  519. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +0 -1
  520. package/build-module/components/block-mobile-toolbar/index.native.js +0 -116
  521. package/build-module/components/block-mobile-toolbar/index.native.js.map +0 -1
  522. package/src/components/block-mobile-toolbar/index.native.js +0 -127
  523. package/src/components/block-mobile-toolbar/style.native.scss +0 -16
  524. /package/src/components/{block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap → block-toolbar/test/__snapshots__/block-toolbar-menu.native.js.snap} +0 -0
@@ -36,11 +36,11 @@ function ReusableBlocksTab({
36
36
  items
37
37
  })];
38
38
  return createElement(BlockTypesList, {
39
- name: "ReusableBlocks",
39
+ name: "SyncedPatterns",
40
40
  sections: sections,
41
41
  onSelect: onSelect,
42
42
  listProps: listProps,
43
- label: __('Reusable blocks')
43
+ label: __('Synced patterns')
44
44
  });
45
45
  }
46
46
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/inserter/reusable-blocks-tab.native.js"],"names":["useSelect","__","BlockTypesList","store","blockEditorStore","createInserterSection","filterInserterItems","ReusableBlocksTab","onSelect","rootClientId","listProps","items","select","getInserterItems","allItems","onlyReusable","sections","key"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,qBAA3B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,qBAAT,EAAgCC,mBAAhC,QAA2D,SAA3D;;AAEA,SAASC,iBAAT,CAA4B;AAAEC,EAAAA,QAAF;AAAYC,EAAAA,YAAZ;AAA0BC,EAAAA;AAA1B,CAA5B,EAAoE;AACnE,QAAM;AAAEC,IAAAA;AAAF,MAAYX,SAAS,CACxBY,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA;AAAF,QAAuBD,MAAM,CAAER,gBAAF,CAAnC;AACA,UAAMU,QAAQ,GAAGD,gBAAgB,CAAEJ,YAAF,CAAjC;AAEA,WAAO;AACNE,MAAAA,KAAK,EAAEL,mBAAmB,CAAEQ,QAAF,EAAY;AAAEC,QAAAA,YAAY,EAAE;AAAhB,OAAZ;AADpB,KAAP;AAGA,GARyB,EAS1B,CAAEN,YAAF,CAT0B,CAA3B;AAYA,QAAMO,QAAQ,GAAG,CAAEX,qBAAqB,CAAE;AAAEY,IAAAA,GAAG,EAAE,WAAP;AAAoBN,IAAAA;AAApB,GAAF,CAAvB,CAAjB;AAEA,SACC,cAAC,cAAD;AACC,IAAA,IAAI,EAAC,gBADN;AAEC,IAAA,QAAQ,EAAGK,QAFZ;AAGC,IAAA,QAAQ,EAAGR,QAHZ;AAIC,IAAA,SAAS,EAAGE,SAJb;AAKC,IAAA,KAAK,EAAGT,EAAE,CAAE,iBAAF;AALX,IADD;AASA;;AAED,eAAeM,iBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockTypesList from '../block-types-list';\nimport { store as blockEditorStore } from '../../store';\nimport { createInserterSection, filterInserterItems } from './utils';\n\nfunction ReusableBlocksTab( { onSelect, rootClientId, listProps } ) {\n\tconst { items } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getInserterItems } = select( blockEditorStore );\n\t\t\tconst allItems = getInserterItems( rootClientId );\n\n\t\t\treturn {\n\t\t\t\titems: filterInserterItems( allItems, { onlyReusable: true } ),\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\n\tconst sections = [ createInserterSection( { key: 'reuseable', items } ) ];\n\n\treturn (\n\t\t<BlockTypesList\n\t\t\tname=\"ReusableBlocks\"\n\t\t\tsections={ sections }\n\t\t\tonSelect={ onSelect }\n\t\t\tlistProps={ listProps }\n\t\t\tlabel={ __( 'Reusable blocks' ) }\n\t\t/>\n\t);\n}\n\nexport default ReusableBlocksTab;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/inserter/reusable-blocks-tab.native.js"],"names":["useSelect","__","BlockTypesList","store","blockEditorStore","createInserterSection","filterInserterItems","ReusableBlocksTab","onSelect","rootClientId","listProps","items","select","getInserterItems","allItems","onlyReusable","sections","key"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,qBAA3B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,qBAAT,EAAgCC,mBAAhC,QAA2D,SAA3D;;AAEA,SAASC,iBAAT,CAA4B;AAAEC,EAAAA,QAAF;AAAYC,EAAAA,YAAZ;AAA0BC,EAAAA;AAA1B,CAA5B,EAAoE;AACnE,QAAM;AAAEC,IAAAA;AAAF,MAAYX,SAAS,CACxBY,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA;AAAF,QAAuBD,MAAM,CAAER,gBAAF,CAAnC;AACA,UAAMU,QAAQ,GAAGD,gBAAgB,CAAEJ,YAAF,CAAjC;AAEA,WAAO;AACNE,MAAAA,KAAK,EAAEL,mBAAmB,CAAEQ,QAAF,EAAY;AAAEC,QAAAA,YAAY,EAAE;AAAhB,OAAZ;AADpB,KAAP;AAGA,GARyB,EAS1B,CAAEN,YAAF,CAT0B,CAA3B;AAYA,QAAMO,QAAQ,GAAG,CAAEX,qBAAqB,CAAE;AAAEY,IAAAA,GAAG,EAAE,WAAP;AAAoBN,IAAAA;AAApB,GAAF,CAAvB,CAAjB;AAEA,SACC,cAAC,cAAD;AACC,IAAA,IAAI,EAAC,gBADN;AAEC,IAAA,QAAQ,EAAGK,QAFZ;AAGC,IAAA,QAAQ,EAAGR,QAHZ;AAIC,IAAA,SAAS,EAAGE,SAJb;AAKC,IAAA,KAAK,EAAGT,EAAE,CAAE,iBAAF;AALX,IADD;AASA;;AAED,eAAeM,iBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockTypesList from '../block-types-list';\nimport { store as blockEditorStore } from '../../store';\nimport { createInserterSection, filterInserterItems } from './utils';\n\nfunction ReusableBlocksTab( { onSelect, rootClientId, listProps } ) {\n\tconst { items } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getInserterItems } = select( blockEditorStore );\n\t\t\tconst allItems = getInserterItems( rootClientId );\n\n\t\t\treturn {\n\t\t\t\titems: filterInserterItems( allItems, { onlyReusable: true } ),\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\n\tconst sections = [ createInserterSection( { key: 'reuseable', items } ) ];\n\n\treturn (\n\t\t<BlockTypesList\n\t\t\tname=\"SyncedPatterns\"\n\t\t\tsections={ sections }\n\t\t\tonSelect={ onSelect }\n\t\t\tlistProps={ listProps }\n\t\t\tlabel={ __( 'Synced patterns' ) }\n\t\t/>\n\t);\n}\n\nexport default ReusableBlocksTab;\n"]}
@@ -129,7 +129,7 @@ InserterTabs.getTabs = () => [{
129
129
  component: BlockTypesTab
130
130
  }, {
131
131
  name: 'reusable',
132
- title: __('Reusable'),
132
+ title: __('Synced patterns'),
133
133
  component: ReusableBlocksTab
134
134
  }];
135
135
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/inserter/tabs.native.js"],"names":["Animated","View","useCallback","useEffect","useMemo","useRef","useState","__","SegmentedControl","BlockTypesTab","ReusableBlocksTab","styles","TAB_ANIMATION_DURATION","InserterTabs","listProps","onSelect","rootClientId","showReusableBlocks","tabIndex","tabAnimation","Value","current","lastScrollEvents","wrapperWidth","setWrapperWidth","onScroll","event","nativeEvent","onWrapperLayout","layout","width","timing","duration","toValue","useNativeDriver","start","lastScrollEvent","tabs","tabKeys","filteredTabs","getTabs","filter","name","keys","translateX","length","interpolate","inputRange","outputRange","map","key","containerStyle","transform","component","TabComponent","index","TabsControl","onChangeTab","segments","title","segmentHandler","selectedTab","tabTitles","indexOf","Control"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,IAAnB,QAA+B,cAA/B;AAEA;AACA;AACA;;AACA,SACCC,WADD,EAECC,SAFD,EAGCC,OAHD,EAICC,MAJD,EAKCC,QALD,QAMO,oBANP;AAOA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,gBAAT,QAAiC,uBAAjC;AAEA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,OAAOC,iBAAP,MAA8B,uBAA9B;AACA,OAAOC,MAAP,MAAmB,cAAnB;AAEA,MAAMC,sBAAsB,GAAG,GAA/B;;AAEA,SAASC,YAAT,CAAuB;AACtBC,EAAAA,SADsB;AAEtBC,EAAAA,QAFsB;AAGtBC,EAAAA,YAHsB;AAItBC,EAAAA,kBAJsB;AAKtBC,EAAAA;AALsB,CAAvB,EAMI;AACH,QAAMC,YAAY,GAAGd,MAAM,CAAE,IAAIL,QAAQ,CAACoB,KAAb,CAAoB,CAApB,CAAF,CAAN,CAAkCC,OAAvD;AACA,QAAMC,gBAAgB,GAAGjB,MAAM,CAAE,EAAF,CAAN,CAAagB,OAAtC;AACA,QAAM,CAAEE,YAAF,EAAgBC,eAAhB,IAAoClB,QAAQ,CAAE,CAAF,CAAlD;;AAEA,WAASmB,QAAT,CAAmBC,KAAnB,EAA2B;AAC1BJ,IAAAA,gBA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AAAA;AAAF,KAAF,KAAgBzB,kBAAkB,IAAIyB,IAAI,KAAK,UAD3B,CAArB;AAGA,WAAOH,YAAY,CAACU,GAAb,CAAkB,CAAE;AAAEU,MAAAA;AAAF,KAAF,KAAiBA,KAAnC,CAAP;AACA,GALuB,EAKrB,CAAE1C,kBAAF,CALqB,CAAxB;AAOA,QAAM2C,cAAc,GAAG1D,WAAW,CAC/B2D,WAAF,IAAmB;AAClB,UAAMC,SAAS,GAAGzB,IAAI,CAACY,GAAL,CAAU,CAAE;AAAEU,MAAAA;AAAF,KAAF,KAAiBA,KAA3B,CAAlB;AACAF,IAAAA,WAAW,CAAEK,SAAS,CAACC,OAAV,CAAmBF,WAAnB,CAAF,CAAX;AACA,GAJgC,EAKjC,CAAEJ,WAAF,CALiC,CAAlC;AAQA,SAAOC,QAAQ,CAACb,MAAT,GAAkB,CAAlB,GACN,cAAC,gBAAD;AACC,IAAA,QAAQ,EAAGa,QADZ;AAEC,IAAA,cAAc,EAAGE;AAFlB,IADM,GAKH,IALJ;AAMA;;AAED/C,YAAY,CAACmD,OAAb,GAAuBR,WAAvB;;AAEA3C,YAAY,CAAC2B,OAAb,GAAuB,MAAM,CAC5B;AAAEE,EAAAA,IAAI,EAAE,QAAR;AAAkBiB,EAAAA,KAAK,EAAEpD,EAAE,CAAE,QAAF,CAA3B;AAAyC8C,EAAAA,SAAS,EAAE5C;AAApD,CAD4B,EAE5B;AAAEiC,EAAAA,IAAI,EAAE,UAAR;AAAoBiB,EAAAA,KAAK,EAAEpD,EAAE,CAAE,UAAF,CAA7B;AAA6C8C,EAAAA,SAAS,EAAE3C;AAAxD,CAF4B,CAA7B;;AAKA,eAAeG,YAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { Animated, View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { SegmentedControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockTypesTab from './block-types-tab';\nimport ReusableBlocksTab from './reusable-blocks-tab';\nimport styles from './style.scss';\n\nconst TAB_ANIMATION_DURATION = 250;\n\nfunction InserterTabs( {\n\tlistProps,\n\tonSelect,\n\trootClientId,\n\tshowReusableBlocks,\n\ttabIndex,\n} ) {\n\tconst tabAnimation = useRef( new Animated.Value( 0 ) ).current;\n\tconst lastScrollEvents = useRef( [] ).current;\n\tconst [ wrapperWidth, setWrapperWidth ] = useState( 0 );\n\n\tfunction onScroll( event ) {\n\t\tlastScrollEvents[ tabIndex ] = event.nativeEvent;\n\t\tlistProps.onScroll( event );\n\t}\n\n\tconst onWrapperLayout = useCallback(\n\t\t( { nativeEvent } ) => {\n\t\t\tsetWrapperWidth( nativeEvent.layout.width );\n\t\t},\n\t\t[ setWrapperWidth ]\n\t);\n\n\tuseEffect( () => {\n\t\tAnimated.timing( tabAnimation, {\n\t\t\tduration: TAB_ANIMATION_DURATION,\n\t\t\ttoValue: tabIndex,\n\t\t\tuseNativeDriver: true,\n\t\t} ).start();\n\n\t\t// Notify upstream with the last scroll event of the current tab.\n\t\tconst lastScrollEvent = lastScrollEvents[ tabIndex ];\n\t\tif ( lastScrollEvent ) {\n\t\t\tlistProps.onScroll( { nativeEvent: lastScrollEvent } );\n\t\t}\n\t}, [ tabIndex ] );\n\n\tconst { tabs, tabKeys } = useMemo( () => {\n\t\tconst filteredTabs = InserterTabs.getTabs().filter(\n\t\t\t( { name } ) => showReusableBlocks || name !== 'reusable'\n\t\t);\n\t\treturn {\n\t\t\ttabs: filteredTabs,\n\t\t\ttabKeys: [ ...filteredTabs.keys() ],\n\t\t};\n\t}, [ showReusableBlocks ] );\n\n\tconst translateX = useMemo(\n\t\t() =>\n\t\t\ttabKeys.length > 1\n\t\t\t\t? tabAnimation.interpolate( {\n\t\t\t\t\t\tinputRange: tabKeys,\n\t\t\t\t\t\toutputRange: tabKeys.map(\n\t\t\t\t\t\t\t( key ) => key * -wrapperWidth\n\t\t\t\t\t\t),\n\t\t\t\t } )\n\t\t\t\t: tabAnimation,\n\t\t[ tabAnimation, tabKeys, wrapperWidth ]\n\t);\n\n\tconst containerStyle = [\n\t\tstyles[ 'inserter-tabs__container' ],\n\t\t{\n\t\t\twidth: wrapperWidth * tabKeys.length,\n\t\t\ttransform: [ { translateX } ],\n\t\t},\n\t];\n\n\treturn (\n\t\t<View\n\t\t\tstyle={ styles[ 'inserter-tabs__wrapper' ] }\n\t\t\tonLayout={ onWrapperLayout }\n\t\t>\n\t\t\t<Animated.View style={ containerStyle }>\n\t\t\t\t{ tabs.map( ( { component: TabComponent }, index ) => (\n\t\t\t\t\t<View key={ `tab-${ index }` }>\n\t\t\t\t\t\t<TabComponent\n\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t\tlistProps={ { ...listProps, onScroll } }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\t\t\t\t) ) }\n\t\t\t</Animated.View>\n\t\t</View>\n\t);\n}\n\nfunction TabsControl( { onChangeTab, showReusableBlocks } ) {\n\tconst tabs = InserterTabs.getTabs();\n\tconst segments = useMemo( () => {\n\t\tconst filteredTabs = tabs.filter(\n\t\t\t( { name } ) => showReusableBlocks || name !== 'reusable'\n\t\t);\n\t\treturn filteredTabs.map( ( { title } ) => title );\n\t}, [ showReusableBlocks ] );\n\n\tconst segmentHandler = useCallback(\n\t\t( selectedTab ) => {\n\t\t\tconst tabTitles = tabs.map( ( { title } ) => title );\n\t\t\tonChangeTab( tabTitles.indexOf( selectedTab ) );\n\t\t},\n\t\t[ onChangeTab ]\n\t);\n\n\treturn segments.length > 1 ? (\n\t\t<SegmentedControl\n\t\t\tsegments={ segments }\n\t\t\tsegmentHandler={ segmentHandler }\n\t\t/>\n\t) : null;\n}\n\nInserterTabs.Control = TabsControl;\n\nInserterTabs.getTabs = () => [\n\t{ name: 'blocks', title: __( 'Blocks' ), component: BlockTypesTab },\n\t{ name: 'reusable', title: __( 'Reusable' ), component: ReusableBlocksTab },\n];\n\nexport default InserterTabs;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/inserter/tabs.native.js"],"names":["Animated","View","useCallback","useEffect","useMemo","useRef","useState","__","SegmentedControl","BlockTypesTab","ReusableBlocksTab","styles","TAB_ANIMATION_DURATION","InserterTabs","listProps","onSelect","rootClientId","showReusableBlocks","tabIndex","tabAnimation","Value","current","lastScrollEvents","wrapperWidth","setWrapperWidth","onScroll","event","nativeEvent","onWrapperLayout","layout","width","timing","duration","toValue","useNativeDriver","start","lastScrollEvent","tabs","tabKeys","filteredTabs","getTabs","filter","name","keys","translateX","length","interpolate","inputRange","outputRange","map","key","containerStyle","transform","component","TabComponent","index","TabsControl","onChangeTab","segments","title","segmentHandler","selectedTab","tabTitles","indexOf","Control"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,IAAnB,QAA+B,cAA/B;AAEA;AACA;AACA;;AACA,SACCC,WADD,EAECC,SAFD,EAGCC,OAHD,EAICC,MAJD,EAKCC,QALD,QAMO,oBANP;AAOA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,gBAAT,QAAiC,uBAAjC;AAEA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,OAAOC,iBAAP,MAA8B,uBAA9B;AACA,OAAOC,MAAP,MAAmB,cAAnB;AAEA,MAAMC,sBAAsB,GAAG,GAA/B;;AAEA,SAASC,YAAT,CAAuB;AACtBC,EAAAA,SADsB;AAEtBC,EAAAA,QAFsB;AAGtBC,EAAAA,YAHsB;AAItBC,EAAAA,kBAJsB;AAKtBC,EAAAA;AALsB,CAAvB,EAMI;AACH,QAAMC,YAAY,GAAGd,MAAM,CAAE,IAAIL,QAAQ,CAACoB,KAAb,CAAoB,CAApB,CAAF,CAAN,CAAkCC,OAAvD;AACA,QAAMC,gBAAgB,GAAGjB,MAAM,CAAE,EA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ated, View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { SegmentedControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockTypesTab from './block-types-tab';\nimport ReusableBlocksTab from './reusable-blocks-tab';\nimport styles from './style.scss';\n\nconst TAB_ANIMATION_DURATION = 250;\n\nfunction InserterTabs( {\n\tlistProps,\n\tonSelect,\n\trootClientId,\n\tshowReusableBlocks,\n\ttabIndex,\n} ) {\n\tconst tabAnimation = useRef( new Animated.Value( 0 ) ).current;\n\tconst lastScrollEvents = useRef( [] ).current;\n\tconst [ wrapperWidth, setWrapperWidth ] = useState( 0 );\n\n\tfunction onScroll( event ) {\n\t\tlastScrollEvents[ tabIndex ] = event.nativeEvent;\n\t\tlistProps.onScroll( event );\n\t}\n\n\tconst onWrapperLayout = useCallback(\n\t\t( { nativeEvent } ) => {\n\t\t\tsetWrapperWidth( nativeEvent.layout.width );\n\t\t},\n\t\t[ setWrapperWidth ]\n\t);\n\n\tuseEffect( () => {\n\t\tAnimated.timing( tabAnimation, {\n\t\t\tduration: TAB_ANIMATION_DURATION,\n\t\t\ttoValue: tabIndex,\n\t\t\tuseNativeDriver: true,\n\t\t} ).start();\n\n\t\t// Notify upstream with the last scroll event of the current tab.\n\t\tconst lastScrollEvent = lastScrollEvents[ tabIndex ];\n\t\tif ( lastScrollEvent ) {\n\t\t\tlistProps.onScroll( { nativeEvent: lastScrollEvent } );\n\t\t}\n\t}, [ tabIndex ] );\n\n\tconst { tabs, tabKeys } = useMemo( () => {\n\t\tconst filteredTabs = InserterTabs.getTabs().filter(\n\t\t\t( { name } ) => showReusableBlocks || name !== 'reusable'\n\t\t);\n\t\treturn {\n\t\t\ttabs: filteredTabs,\n\t\t\ttabKeys: [ ...filteredTabs.keys() ],\n\t\t};\n\t}, [ showReusableBlocks ] );\n\n\tconst translateX = useMemo(\n\t\t() =>\n\t\t\ttabKeys.length > 1\n\t\t\t\t? tabAnimation.interpolate( {\n\t\t\t\t\t\tinputRange: tabKeys,\n\t\t\t\t\t\toutputRange: tabKeys.map(\n\t\t\t\t\t\t\t( key ) => key * -wrapperWidth\n\t\t\t\t\t\t),\n\t\t\t\t } )\n\t\t\t\t: tabAnimation,\n\t\t[ tabAnimation, tabKeys, wrapperWidth ]\n\t);\n\n\tconst containerStyle = [\n\t\tstyles[ 'inserter-tabs__container' ],\n\t\t{\n\t\t\twidth: wrapperWidth * tabKeys.length,\n\t\t\ttransform: [ { translateX } ],\n\t\t},\n\t];\n\n\treturn (\n\t\t<View\n\t\t\tstyle={ styles[ 'inserter-tabs__wrapper' ] }\n\t\t\tonLayout={ onWrapperLayout }\n\t\t>\n\t\t\t<Animated.View style={ containerStyle }>\n\t\t\t\t{ tabs.map( ( { component: TabComponent }, index ) => (\n\t\t\t\t\t<View key={ `tab-${ index }` }>\n\t\t\t\t\t\t<TabComponent\n\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t\tlistProps={ { ...listProps, onScroll } }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\t\t\t\t) ) }\n\t\t\t</Animated.View>\n\t\t</View>\n\t);\n}\n\nfunction TabsControl( { onChangeTab, showReusableBlocks } ) {\n\tconst tabs = InserterTabs.getTabs();\n\tconst segments = useMemo( () => {\n\t\tconst filteredTabs = tabs.filter(\n\t\t\t( { name } ) => showReusableBlocks || name !== 'reusable'\n\t\t);\n\t\treturn filteredTabs.map( ( { title } ) => title );\n\t}, [ showReusableBlocks ] );\n\n\tconst segmentHandler = useCallback(\n\t\t( selectedTab ) => {\n\t\t\tconst tabTitles = tabs.map( ( { title } ) => title );\n\t\t\tonChangeTab( tabTitles.indexOf( selectedTab ) );\n\t\t},\n\t\t[ onChangeTab ]\n\t);\n\n\treturn segments.length > 1 ? (\n\t\t<SegmentedControl\n\t\t\tsegments={ segments }\n\t\t\tsegmentHandler={ segmentHandler }\n\t\t/>\n\t) : null;\n}\n\nInserterTabs.Control = TabsControl;\n\nInserterTabs.getTabs = () => [\n\t{ name: 'blocks', title: __( 'Blocks' ), component: BlockTypesTab },\n\t{\n\t\tname: 'reusable',\n\t\ttitle: __( 'Synced patterns' ),\n\t\tcomponent: ReusableBlocksTab,\n\t},\n];\n\nexport default InserterTabs;\n"]}
@@ -4,7 +4,8 @@ import { createElement } from "@wordpress/element";
4
4
  * WordPress dependencies
5
5
  */
6
6
  import { Draggable } from '@wordpress/components';
7
- import { serialize } from '@wordpress/blocks';
7
+ import { serialize, store as blocksStore } from '@wordpress/blocks';
8
+ import { useSelect } from '@wordpress/data';
8
9
  /**
9
10
  * Internal dependencies
10
11
  */
@@ -22,6 +23,12 @@ const InserterDraggableBlocks = ({
22
23
  type: 'inserter',
23
24
  blocks
24
25
  };
26
+ const blockTypeIcon = useSelect(select => {
27
+ const {
28
+ getBlockType
29
+ } = select(blocksStore);
30
+ return blocks.length === 1 && getBlockType(blocks[0].name)?.icon;
31
+ }, [blocks]);
25
32
  return createElement(Draggable, {
26
33
  __experimentalTransferDataType: "wp-blocks",
27
34
  transferData: transferData,
@@ -30,7 +37,7 @@ const InserterDraggableBlocks = ({
30
37
  },
31
38
  __experimentalDragComponent: createElement(BlockDraggableChip, {
32
39
  count: blocks.length,
33
- icon: icon,
40
+ icon: icon || !isPattern && blockTypeIcon,
34
41
  isPattern: isPattern
35
42
  })
36
43
  }, ({
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/inserter-draggable-blocks/index.js"],"names":["Draggable","serialize","BlockDraggableChip","InserterDraggableBlocks","isEnabled","blocks","icon","children","isPattern","transferData","type","event","dataTransfer","setData","length","onDraggableStart","onDraggableEnd","draggable","onDragStart","undefined","onDragEnd"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,uBAA1B;AACA,SAASC,SAAT,QAA0B,mBAA1B;AACA;AACA;AACA;;AACA,OAAOC,kBAAP,MAA+B,mCAA/B;;AAEA,MAAMC,uBAAuB,GAAG,CAAE;AACjCC,EAAAA,SADiC;AAEjCC,EAAAA,MAFiC;AAGjCC,EAAAA,IAHiC;AAIjCC,EAAAA,QAJiC;AAKjCC,EAAAA;AALiC,CAAF,KAMzB;AACN,QAAMC,YAAY,GAAG;AACpBC,IAAAA,IAAI,EAAE,UADc;AAEpBL,IAAAA;AAFoB,GAArB;AAKA,SACC,cAAC,SAAD;AACC,IAAA,8BAA8B,EAAC,WADhC;AAEC,IAAA,YAAY,EAAGI,YAFhB;AAGC,IAAA,WAAW,EAAKE,KAAF,IAAa;AAC1BA,MAAAA,KAAK,CAACC,YAAN,CAAmBC,OAAnB,CAA4B,WAA5B,EAAyCZ,SAAS,CAAEI,MAAF,CAAlD;AACA,KALF;AAMC,IAAA,2BAA2B,EAC1B,cAAC,kBAAD;AACC,MAAA,KAAK,EAAGA,MAAM,CAACS,MADhB;AAEC,MAAA,IAAI,EAAGR,IAFR;AAGC,MAAA,SAAS,EAAGE;AAHb;AAPF,KAcG,CAAE;AAAEO,IAAAA,gBAAF;AAAoBC,IAAAA;AAApB,GAAF,KAA4C;AAC7C,WAAOT,QAAQ,CAAE;AAChBU,MAAAA,SAAS,EAAEb,SADK;AAEhBc,MAAAA,WAAW,EAAEd,SAAS,GAAGW,gBAAH,GAAsBI,SAF5B;AAGhBC,MAAAA,SAAS,EAAEhB,SAAS,GAAGY,cAAH,GAAoBG;AAHxB,KAAF,CAAf;AAKA,GApBF,CADD;AAwBA,CApCD;;AAsCA,eAAehB,uBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Draggable } from '@wordpress/components';\nimport { serialize } from '@wordpress/blocks';\n/**\n * Internal dependencies\n */\nimport BlockDraggableChip from '../block-draggable/draggable-chip';\n\nconst InserterDraggableBlocks = ( {\n\tisEnabled,\n\tblocks,\n\ticon,\n\tchildren,\n\tisPattern,\n} ) => {\n\tconst transferData = {\n\t\ttype: 'inserter',\n\t\tblocks,\n\t};\n\n\treturn (\n\t\t<Draggable\n\t\t\t__experimentalTransferDataType=\"wp-blocks\"\n\t\t\ttransferData={ transferData }\n\t\t\tonDragStart={ ( event ) => {\n\t\t\t\tevent.dataTransfer.setData( 'text/html', serialize( blocks ) );\n\t\t\t} }\n\t\t\t__experimentalDragComponent={\n\t\t\t\t<BlockDraggableChip\n\t\t\t\t\tcount={ blocks.length }\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tisPattern={ isPattern }\n\t\t\t\t/>\n\t\t\t}\n\t\t>\n\t\t\t{ ( { onDraggableStart, onDraggableEnd } ) => {\n\t\t\t\treturn children( {\n\t\t\t\t\tdraggable: isEnabled,\n\t\t\t\t\tonDragStart: isEnabled ? onDraggableStart : undefined,\n\t\t\t\t\tonDragEnd: isEnabled ? onDraggableEnd : undefined,\n\t\t\t\t} );\n\t\t\t} }\n\t\t</Draggable>\n\t);\n};\n\nexport default InserterDraggableBlocks;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/inserter-draggable-blocks/index.js"],"names":["Draggable","serialize","store","blocksStore","useSelect","BlockDraggableChip","InserterDraggableBlocks","isEnabled","blocks","icon","children","isPattern","transferData","type","blockTypeIcon","select","getBlockType","length","name","event","dataTransfer","setData","onDraggableStart","onDraggableEnd","draggable","onDragStart","undefined","onDragEnd"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,uBAA1B;AACA,SAASC,SAAT,EAAoBC,KAAK,IAAIC,WAA7B,QAAgD,mBAAhD;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA;AACA;AACA;;AACA,OAAOC,kBAAP,MAA+B,mCAA/B;;AAEA,MAAMC,uBAAuB,GAAG,CAAE;AACjCC,EAAAA,SADiC;AAEjCC,EAAAA,MAFiC;AAGjCC,EAAAA,IAHiC;AAIjCC,EAAAA,QAJiC;AAKjCC,EAAAA;AALiC,CAAF,KAMzB;AACN,QAAMC,YAAY,GAAG;AACpBC,IAAAA,IAAI,EAAE,UADc;AAEpBL,IAAAA;AAFoB,GAArB;AAKA,QAAMM,aAAa,GAAGV,SAAS,CAC5BW,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA;AAAF,QAAmBD,MAAM,CAAEZ,WAAF,CAA/B;AACA,WACCK,MAAM,CAACS,MAAP,KAAkB,CAAlB,IAAuBD,YAAY,CAAER,MAAM,CAAE,CAAF,CAAN,CAAYU,IAAd,CAAZ,EAAkCT,IAD1D;AAGA,GAN6B,EAO9B,CAAED,MAAF,CAP8B,CAA/B;AAUA,SACC,cAAC,SAAD;AACC,IAAA,8BAA8B,EAAC,WADhC;AAEC,IAAA,YAAY,EAAGI,YAFhB;AAGC,IAAA,WAAW,EAAKO,KAAF,IAAa;AAC1BA,MAAAA,KAAK,CAACC,YAAN,CAAmBC,OAAnB,CAA4B,WAA5B,EAAyCpB,SAAS,CAAEO,MAAF,CAAlD;AACA,KALF;AAMC,IAAA,2BAA2B,EAC1B,cAAC,kBAAD;AACC,MAAA,KAAK,EAAGA,MAAM,CAACS,MADhB;AAEC,MAAA,IAAI,EAAGR,IAAI,IAAM,CAAEE,SAAF,IAAeG,aAFjC;AAGC,MAAA,SAAS,EAAGH;AAHb;AAPF,KAcG,CAAE;AAAEW,IAAAA,gBAAF;AAAoBC,IAAAA;AAApB,GAAF,KAA4C;AAC7C,WAAOb,QAAQ,CAAE;AAChBc,MAAAA,SAAS,EAAEjB,SADK;AAEhBkB,MAAAA,WAAW,EAAElB,SAAS,GAAGe,gBAAH,GAAsBI,SAF5B;AAGhBC,MAAAA,SAAS,EAAEpB,SAAS,GAAGgB,cAAH,GAAoBG;AAHxB,KAAF,CAAf;AAKA,GApBF,CADD;AAwBA,CA9CD;;AAgDA,eAAepB,uBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Draggable } from '@wordpress/components';\nimport { serialize, store as blocksStore } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\n/**\n * Internal dependencies\n */\nimport BlockDraggableChip from '../block-draggable/draggable-chip';\n\nconst InserterDraggableBlocks = ( {\n\tisEnabled,\n\tblocks,\n\ticon,\n\tchildren,\n\tisPattern,\n} ) => {\n\tconst transferData = {\n\t\ttype: 'inserter',\n\t\tblocks,\n\t};\n\n\tconst blockTypeIcon = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockType } = select( blocksStore );\n\t\t\treturn (\n\t\t\t\tblocks.length === 1 && getBlockType( blocks[ 0 ].name )?.icon\n\t\t\t);\n\t\t},\n\t\t[ blocks ]\n\t);\n\n\treturn (\n\t\t<Draggable\n\t\t\t__experimentalTransferDataType=\"wp-blocks\"\n\t\t\ttransferData={ transferData }\n\t\t\tonDragStart={ ( event ) => {\n\t\t\t\tevent.dataTransfer.setData( 'text/html', serialize( blocks ) );\n\t\t\t} }\n\t\t\t__experimentalDragComponent={\n\t\t\t\t<BlockDraggableChip\n\t\t\t\t\tcount={ blocks.length }\n\t\t\t\t\ticon={ icon || ( ! isPattern && blockTypeIcon ) }\n\t\t\t\t\tisPattern={ isPattern }\n\t\t\t\t/>\n\t\t\t}\n\t\t>\n\t\t\t{ ( { onDraggableStart, onDraggableEnd } ) => {\n\t\t\t\treturn children( {\n\t\t\t\t\tdraggable: isEnabled,\n\t\t\t\t\tonDragStart: isEnabled ? onDraggableStart : undefined,\n\t\t\t\t\tonDragEnd: isEnabled ? onDraggableEnd : undefined,\n\t\t\t\t} );\n\t\t\t} }\n\t\t</Draggable>\n\t);\n};\n\nexport default InserterDraggableBlocks;\n"]}
@@ -7,7 +7,7 @@ import { __ } from '@wordpress/i18n'; // Used as a unique identifier for the "Cr
7
7
 
8
8
  export const CREATE_TYPE = '__CREATE__';
9
9
  export const TEL_TYPE = 'tel';
10
- export const URL_TYPE = 'URL';
10
+ export const URL_TYPE = 'link';
11
11
  export const MAILTO_TYPE = 'mailto';
12
12
  export const INTERNAL_TYPE = 'internal';
13
13
  export const LINK_ENTRY_TYPES = [URL_TYPE, MAILTO_TYPE, TEL_TYPE, INTERNAL_TYPE];
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/constants.js"],"names":["__","CREATE_TYPE","TEL_TYPE","URL_TYPE","MAILTO_TYPE","INTERNAL_TYPE","LINK_ENTRY_TYPES","DEFAULT_LINK_SETTINGS","id","title"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB,C,CAEA;AACA;AACA;;AACA,OAAO,MAAMC,WAAW,GAAG,YAApB;AACP,OAAO,MAAMC,QAAQ,GAAG,KAAjB;AACP,OAAO,MAAMC,QAAQ,GAAG,KAAjB;AACP,OAAO,MAAMC,WAAW,GAAG,QAApB;AACP,OAAO,MAAMC,aAAa,GAAG,UAAtB;AAEP,OAAO,MAAMC,gBAAgB,GAAG,CAC/BH,QAD+B,EAE/BC,WAF+B,EAG/BF,QAH+B,EAI/BG,aAJ+B,CAAzB;AAOP,OAAO,MAAME,qBAAqB,GAAG,CACpC;AACCC,EAAAA,EAAE,EAAE,eADL;AAECC,EAAAA,KAAK,EAAET,EAAE,CAAE,iBAAF;AAFV,CADoC,CAA9B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n// Used as a unique identifier for the \"Create\" option within search results.\n// Used to help distinguish the \"Create\" suggestion within the search results in\n// order to handle it as a unique case.\nexport const CREATE_TYPE = '__CREATE__';\nexport const TEL_TYPE = 'tel';\nexport const URL_TYPE = 'URL';\nexport const MAILTO_TYPE = 'mailto';\nexport const INTERNAL_TYPE = 'internal';\n\nexport const LINK_ENTRY_TYPES = [\n\tURL_TYPE,\n\tMAILTO_TYPE,\n\tTEL_TYPE,\n\tINTERNAL_TYPE,\n];\n\nexport const DEFAULT_LINK_SETTINGS = [\n\t{\n\t\tid: 'opensInNewTab',\n\t\ttitle: __( 'Open in new tab' ),\n\t},\n];\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/constants.js"],"names":["__","CREATE_TYPE","TEL_TYPE","URL_TYPE","MAILTO_TYPE","INTERNAL_TYPE","LINK_ENTRY_TYPES","DEFAULT_LINK_SETTINGS","id","title"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB,C,CAEA;AACA;AACA;;AACA,OAAO,MAAMC,WAAW,GAAG,YAApB;AACP,OAAO,MAAMC,QAAQ,GAAG,KAAjB;AACP,OAAO,MAAMC,QAAQ,GAAG,MAAjB;AACP,OAAO,MAAMC,WAAW,GAAG,QAApB;AACP,OAAO,MAAMC,aAAa,GAAG,UAAtB;AAEP,OAAO,MAAMC,gBAAgB,GAAG,CAC/BH,QAD+B,EAE/BC,WAF+B,EAG/BF,QAH+B,EAI/BG,aAJ+B,CAAzB;AAOP,OAAO,MAAME,qBAAqB,GAAG,CACpC;AACCC,EAAAA,EAAE,EAAE,eADL;AAECC,EAAAA,KAAK,EAAET,EAAE,CAAE,iBAAF;AAFV,CADoC,CAA9B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n// Used as a unique identifier for the \"Create\" option within search results.\n// Used to help distinguish the \"Create\" suggestion within the search results in\n// order to handle it as a unique case.\nexport const CREATE_TYPE = '__CREATE__';\nexport const TEL_TYPE = 'tel';\nexport const URL_TYPE = 'link';\nexport const MAILTO_TYPE = 'mailto';\nexport const INTERNAL_TYPE = 'internal';\n\nexport const LINK_ENTRY_TYPES = [\n\tURL_TYPE,\n\tMAILTO_TYPE,\n\tTEL_TYPE,\n\tINTERNAL_TYPE,\n];\n\nexport const DEFAULT_LINK_SETTINGS = [\n\t{\n\t\tid: 'opensInNewTab',\n\t\ttitle: __( 'Open in new tab' ),\n\t},\n];\n"]}
@@ -260,7 +260,8 @@ function LinkControl({
260
260
  const currentUrlInputValue = propInputValue || internalControlValue?.url || '';
261
261
  const currentInputIsEmpty = !currentUrlInputValue?.trim()?.length;
262
262
  const shownUnlinkControl = onRemove && value && !isEditingLink && !isCreatingPage;
263
- const showSettings = !!settings?.length; // Only show text control once a URL value has been committed
263
+ const showSettings = !!settings?.length && isEditingLink && hasLinkValue;
264
+ const showActions = isEditingLink && hasLinkValue; // Only show text control once a URL value has been committed
264
265
  // and it isn't just empty whitespace.
265
266
  // See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.
266
267
 
@@ -278,7 +279,16 @@ function LinkControl({
278
279
  'block-editor-link-control__search-input-wrapper': true,
279
280
  'has-text-control': showTextControl
280
281
  })
281
- }, createElement(LinkControlSearchInput, {
282
+ }, showTextControl && createElement(TextControl, {
283
+ __nextHasNoMarginBottom: true,
284
+ ref: textInputRef,
285
+ className: "block-editor-link-control__field block-editor-link-control__text-content",
286
+ label: __('Text'),
287
+ value: internalControlValue?.title,
288
+ onChange: setInternalTextInputValue,
289
+ onKeyDown: handleSubmitWithEnter,
290
+ size: "__unstable-large"
291
+ }), createElement(LinkControlSearchInput, {
282
292
  currentLink: value,
283
293
  className: "block-editor-link-control__field block-editor-link-control__search-input",
284
294
  placeholder: searchInputPlaceholder,
@@ -293,15 +303,7 @@ function LinkControl({
293
303
  suggestionsQuery: suggestionsQuery,
294
304
  withURLSuggestion: !noURLSuggestion,
295
305
  createSuggestionButtonText: createSuggestionButtonText,
296
- useLabel: showTextControl
297
- }), showTextControl && createElement(TextControl, {
298
- __nextHasNoMarginBottom: true,
299
- ref: textInputRef,
300
- className: "block-editor-link-control__field block-editor-link-control__text-content",
301
- label: __('Text'),
302
- value: internalControlValue?.title,
303
- onChange: setInternalTextInputValue,
304
- onKeyDown: handleSubmitWithEnter
306
+ hideLabelFromVision: !showTextControl
305
307
  })), errorMessage && createElement(Notice, {
306
308
  className: "block-editor-link-control__search-error",
307
309
  status: "error",
@@ -313,17 +315,20 @@ function LinkControl({
313
315
  onEditClick: () => setIsEditingLink(true),
314
316
  hasRichPreviews: hasRichPreviews,
315
317
  hasUnlinkControl: shownUnlinkControl,
316
- onRemove: onRemove
317
- }), isEditing && createElement("div", {
318
+ onRemove: () => {
319
+ onRemove();
320
+ setIsEditingLink(true);
321
+ }
322
+ }), showSettings && createElement("div", {
318
323
  className: "block-editor-link-control__tools"
319
- }, showSettings && createElement(LinkControlSettingsDrawer, {
324
+ }, !currentInputIsEmpty && createElement(LinkControlSettingsDrawer, {
320
325
  settingsOpen: settingsOpen,
321
326
  setSettingsOpen: setSettingsOpen
322
327
  }, createElement(LinkSettings, {
323
328
  value: internalControlValue,
324
329
  settings: settings,
325
330
  onChange: createSetInternalSettingValueHandler(settingsKeys)
326
- })), createElement("div", {
331
+ }))), showActions && createElement("div", {
327
332
  className: "block-editor-link-control__search-actions"
328
333
  }, createElement(Button, {
329
334
  variant: "primary",
@@ -333,7 +338,7 @@ function LinkControl({
333
338
  }, __('Save')), createElement(Button, {
334
339
  variant: "tertiary",
335
340
  onClick: handleCancel
336
- }, __('Cancel')))), renderControlBottom && renderControlBottom());
341
+ }, __('Cancel'))), renderControlBottom && renderControlBottom());
337
342
  }
338
343
 
339
344
  LinkControl.ViewerFill = ViewerFill;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/index.js"],"names":["classnames","Button","Spinner","Notice","TextControl","__","useRef","useState","useEffect","focus","ENTER","isShallowEqualObjects","LinkControlSettingsDrawer","LinkControlSearchInput","LinkPreview","LinkSettings","useCreatePage","useInternalValue","ViewerFill","DEFAULT_LINK_SETTINGS","noop","LinkControl","searchInputPlaceholder","value","settings","onChange","onRemove","onCancel","noDirectEntry","showSuggestions","showInitialSuggestions","forceIsEditingLink","createSuggestion","withCreateSuggestion","inputValue","propInputValue","suggestionsQuery","noURLSuggestion","createSuggestionButtonText","hasRichPreviews","hasTextControl","renderControlBottom","undefined","isMounting","wrapperNode","textInputRef","isEndingEditWithFocus","settingsKeys","map","id","settingsOpen","setSettingsOpen","internalControlValue","setInternalControlValue","setInternalURLInputValue","setInternalTextInputValue","createSetInternalSettingValueHandler","valueHasChanges","isEditingLink","setIsEditingLink","url","createPage","isCreatingPage","errorMessage","current","nextFocusTarget","focusable","find","hasLinkValue","trim","length","stopEditing","contains","ownerDocument","activeElement","handleSelectSuggestion","updatedValue","nonSettingsChanges","Object","keys","reduce","acc","key","includes","title","handleSubmit","currentUrlInputValue","handleSubmitWithEnter","event","keyCode","currentInputIsEmpty","preventDefault","resetInternalValues","handleCancel","stopPropagation","shownUnlinkControl","showSettings","showTextControl","isEditing","isDisabled"],"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,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,EAAiBC,QAAjB,EAA2BC,SAA3B,QAA4C,oBAA5C;AACA,SAASC,KAAT,QAAsB,gBAAtB;AACA,SAASC,KAAT,QAAsB,qBAAtB;AACA,SAASC,qBAAT,QAAsC,6BAAtC;AAEA;AACA;AACA;;AACA,OAAOC,yBAAP,MAAsC,mBAAtC;AACA,OAAOC,sBAAP,MAAmC,gBAAnC;AACA,OAAOC,WAAP,MAAwB,gBAAxB;AACA,OAAOC,YAAP,MAAyB,YAAzB;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,OAAOC,gBAAP,MAA6B,sBAA7B;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;AACA;;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AFT;AAGC,IAAA,WAAW,EAAG,MAAMoC,gBAAgB,CAAE,IAAF,CAHrC;AAIC,IAAA,eAAe,EAAGpB,eAJnB;AAKC,IAAA,gBAAgB,EAAGwD,kBALpB;AAMC,IAAA,QAAQ,EAAGrE;AANZ,IA/DF,EAyEGwE,SAAS,IACV;AAAK,IAAA,SAAS,EAAC;AAAf,KACGF,YAAY,IACb,cAAC,yBAAD;AACC,IAAA,YAAY,EAAG9C,YADhB;AAEC,IAAA,eAAe,EAAGC;AAFnB,KAIC,cAAC,YAAD;AACC,IAAA,KAAK,EAAGC,oBADT;AAEC,IAAA,QAAQ,EAAG5B,QAFZ;AAGC,IAAA,QAAQ,EAAGgC,oCAAoC,CAC9CT,YAD8C;AAHhD,IAJD,CAFF,EAgBC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,OAAO,EAAGoD,UAAU,GAAG/E,IAAH,GAAUiE,YAF/B;AAGC,IAAA,SAAS,EAAC,0CAHX;AAIC,qBAAgBc;AAJjB,KAMG9F,EAAE,CAAE,MAAF,CANL,CADD,EASC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,UAAhB;AAA2B,IAAA,OAAO,EAAGwF;AAArC,KACGxF,EAAE,CAAE,QAAF,CADL,CATD,CAhBD,CA1EF,EA0GGoC,mBAAmB,IAAIA,mBAAmB,EA1G7C,CADD;AA8GA;;AAEDpB,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 { __ } from '@wordpress/i18n';\nimport { useRef, useState, useEffect } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport { ENTER } from '@wordpress/keycodes';\nimport { isShallowEqualObjects } from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport LinkControlSettingsDrawer from './settings-drawer';\nimport LinkControlSearchInput from './search-input';\nimport LinkPreview from './link-preview';\nimport LinkSettings from './settings';\nimport useCreatePage from './use-create-page';\nimport useInternalValue from './use-internal-value';\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 {boolean=} hasTextControl Whether to add a text field to the UI to update the value.title.\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\tonCancel,\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\tconst isEndingEditWithFocus = useRef( false );\n\n\tconst settingsKeys = settings.map( ( { id } ) => id );\n\n\tconst [ settingsOpen, setSettingsOpen ] = useState( false );\n\n\tconst [\n\t\tinternalControlValue,\n\t\tsetInternalControlValue,\n\t\tsetInternalURLInputValue,\n\t\tsetInternalTextInputValue,\n\t\tcreateSetInternalSettingValueHandler,\n\t] = useInternalValue( value );\n\n\tconst valueHasChanges =\n\t\tvalue && ! isShallowEqualObjects( internalControlValue, value );\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState(\n\t\tforceIsEditingLink !== undefined\n\t\t\t? forceIsEditingLink\n\t\t\t: ! value || ! value.url\n\t);\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\t// Todo: bug if the missing dep is introduced. Will need a fix.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\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\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 )[ 0 ] ||\n\t\t\twrapperNode.current;\n\n\t\tnextFocusTarget.focus();\n\n\t\tisEndingEditWithFocus.current = false;\n\t}, [ isEditingLink, isCreatingPage ] );\n\n\tconst hasLinkValue = value?.url?.trim()?.length > 0;\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\tconst stopEditing = () => {\n\t\tisEndingEditWithFocus.current = !! wrapperNode.current?.contains(\n\t\t\twrapperNode.current.ownerDocument.activeElement\n\t\t);\n\n\t\tsetSettingsOpen( false );\n\t\tsetIsEditingLink( false );\n\t};\n\n\tconst handleSelectSuggestion = ( updatedValue ) => {\n\t\t// Suggestions may contains \"settings\" values (e.g. `opensInNewTab`)\n\t\t// which should not overide any existing settings values set by the\n\t\t// user. This filters out any settings values from the suggestion.\n\t\tconst nonSettingsChanges = Object.keys( updatedValue ).reduce(\n\t\t\t( acc, key ) => {\n\t\t\t\tif ( ! settingsKeys.includes( key ) ) {\n\t\t\t\t\tacc[ key ] = updatedValue[ key ];\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\tonChange( {\n\t\t\t...internalControlValue,\n\t\t\t...nonSettingsChanges,\n\t\t\t// As title is not a setting, it must be manually applied\n\t\t\t// in such a way as to preserve the users changes over\n\t\t\t// any \"title\" value provided by the \"suggestion\".\n\t\t\ttitle: internalControlValue?.title || updatedValue?.title,\n\t\t} );\n\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmit = () => {\n\t\tif ( valueHasChanges ) {\n\t\t\t// Submit the original value with new stored values applied\n\t\t\t// on top. URL is a special case as it may also be a prop.\n\t\t\tonChange( {\n\t\t\t\t...value,\n\t\t\t\t...internalControlValue,\n\t\t\t\turl: currentUrlInputValue,\n\t\t\t} );\n\t\t}\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmitWithEnter = ( event ) => {\n\t\tconst { keyCode } = event;\n\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 resetInternalValues = () => {\n\t\tsetInternalControlValue( value );\n\t};\n\n\tconst handleCancel = ( event ) => {\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\n\t\t// Ensure that any unsubmitted input changes are reset.\n\t\tresetInternalValues();\n\n\t\tif ( hasLinkValue ) {\n\t\t\t// If there is a link then exist editing mode and show preview.\n\t\t\tstopEditing();\n\t\t} else {\n\t\t\t// If there is no link value, then remove the link entirely.\n\t\t\tonRemove?.();\n\t\t}\n\n\t\tonCancel?.();\n\t};\n\n\tconst currentUrlInputValue =\n\t\tpropInputValue || internalControlValue?.url || '';\n\n\tconst currentInputIsEmpty = ! currentUrlInputValue?.trim()?.length;\n\n\tconst shownUnlinkControl =\n\t\tonRemove && value && ! isEditingLink && ! isCreatingPage;\n\n\tconst showSettings = !! 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 = hasLinkValue && hasTextControl;\n\n\tconst isEditing = ( isEditingLink || ! value ) && ! isCreatingPage;\n\tconst isDisabled = ! valueHasChanges || currentInputIsEmpty;\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{ isEditing && (\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<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={ currentUrlInputValue }\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={ setInternalURLInputValue }\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{ showTextControl && (\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\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={ internalControlValue?.title }\n\t\t\t\t\t\t\t\tonChange={ setInternalTextInputValue }\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\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{ isEditing && (\n\t\t\t\t<div className=\"block-editor-link-control__tools\">\n\t\t\t\t\t{ showSettings && (\n\t\t\t\t\t\t<LinkControlSettingsDrawer\n\t\t\t\t\t\t\tsettingsOpen={ settingsOpen }\n\t\t\t\t\t\t\tsetSettingsOpen={ setSettingsOpen }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<LinkSettings\n\t\t\t\t\t\t\t\tvalue={ internalControlValue }\n\t\t\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\t\t\tonChange={ createSetInternalSettingValueHandler(\n\t\t\t\t\t\t\t\t\tsettingsKeys\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</LinkControlSettingsDrawer>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<div className=\"block-editor-link-control__search-actions\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tonClick={ isDisabled ? noop : handleSubmit }\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-submit\"\n\t\t\t\t\t\t\taria-disabled={ isDisabled }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ handleCancel }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t) }\n\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","__","useRef","useState","useEffect","focus","ENTER","isShallowEqualObjects","LinkControlSettingsDrawer","LinkControlSearchInput","LinkPreview","LinkSettings","useCreatePage","useInternalValue","ViewerFill","DEFAULT_LINK_SETTINGS","noop","LinkControl","searchInputPlaceholder","value","settings","onChange","onRemove","onCancel","noDirectEntry","showSuggestions","showInitialSuggestions","forceIsEditingLink","createSuggestion","withCreateSuggestion","inputValue","propInputValue","suggestionsQuery","noURLSuggestion","createSuggestionButtonText","hasRichPreviews","hasTextControl","renderControlBottom","undefined","isMounting","wrapperNode","textInputRef","isEndingEditWithFocus","settingsKeys","map","id","settingsOpen","setSettingsOpen","internalControlValue","setInternalControlValue","setInternalURLInputValue","setInternalTextInputValue","createSetInternalSettingValueHandler","valueHasChanges","isEditingLink","setIsEditingLink","url","createPage","isCreatingPage","errorMessage","current","nextFocusTarget","focusable","find","hasLinkValue","trim","length","stopEditing","contains","ownerDocument","activeElement","handleSelectSuggestion","updatedValue","nonSettingsChanges","Object","keys","reduce","acc","key","includes","title","handleSubmit","currentUrlInputValue","handleSubmitWithEnter","event","keyCode","currentInputIsEmpty","preventDefault","resetInternalValues","handleCancel","stopPropagation","shownUnlinkControl","showSettings","showActions","showTextControl","isEditing","isDisabled"],"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,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,EAAiBC,QAAjB,EAA2BC,SAA3B,QAA4C,oBAA5C;AACA,SAASC,KAAT,QAAsB,gBAAtB;AACA,SAASC,KAAT,QAAsB,qBAAtB;AACA,SAASC,qBAAT,QAAsC,6BAAtC;AAEA;AACA;AACA;;AACA,OAAOC,yBAAP,MAAsC,mBAAtC;AACA,OAAOC,sBAAP,MAAmC,gBAAnC;AACA,OAAOC,WAAP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,SAAS,EAAC;AAAf,KACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,OAAO,EAAGG,UAAU,GAAGhF,IAAH,GAAUiE,YAF/B;AAGC,IAAA,SAAS,EAAC,0CAHX;AAIC,qBAAgBe;AAJjB,KAMG/F,EAAE,CAAE,MAAF,CANL,CADD,EASC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,UAAhB;AAA2B,IAAA,OAAO,EAAGwF;AAArC,KACGxF,EAAE,CAAE,QAAF,CADL,CATD,CAjGF,EAgHGoC,mBAAmB,IAAIA,mBAAmB,EAhH7C,CADD;AAoHA;;AAEDpB,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 { __ } from '@wordpress/i18n';\nimport { useRef, useState, useEffect } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport { ENTER } from '@wordpress/keycodes';\nimport { isShallowEqualObjects } from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport LinkControlSettingsDrawer from './settings-drawer';\nimport LinkControlSearchInput from './search-input';\nimport LinkPreview from './link-preview';\nimport LinkSettings from './settings';\nimport useCreatePage from './use-create-page';\nimport useInternalValue from './use-internal-value';\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 {boolean=} hasTextControl Whether to add a text field to the UI to update the value.title.\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\tonCancel,\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\tconst isEndingEditWithFocus = useRef( false );\n\n\tconst settingsKeys = settings.map( ( { id } ) => id );\n\n\tconst [ settingsOpen, setSettingsOpen ] = useState( false );\n\n\tconst [\n\t\tinternalControlValue,\n\t\tsetInternalControlValue,\n\t\tsetInternalURLInputValue,\n\t\tsetInternalTextInputValue,\n\t\tcreateSetInternalSettingValueHandler,\n\t] = useInternalValue( value );\n\n\tconst valueHasChanges =\n\t\tvalue && ! isShallowEqualObjects( internalControlValue, value );\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState(\n\t\tforceIsEditingLink !== undefined\n\t\t\t? forceIsEditingLink\n\t\t\t: ! value || ! value.url\n\t);\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\t// Todo: bug if the missing dep is introduced. Will need a fix.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\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\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 )[ 0 ] ||\n\t\t\twrapperNode.current;\n\n\t\tnextFocusTarget.focus();\n\n\t\tisEndingEditWithFocus.current = false;\n\t}, [ isEditingLink, isCreatingPage ] );\n\n\tconst hasLinkValue = value?.url?.trim()?.length > 0;\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\tconst stopEditing = () => {\n\t\tisEndingEditWithFocus.current = !! wrapperNode.current?.contains(\n\t\t\twrapperNode.current.ownerDocument.activeElement\n\t\t);\n\n\t\tsetSettingsOpen( false );\n\t\tsetIsEditingLink( false );\n\t};\n\n\tconst handleSelectSuggestion = ( updatedValue ) => {\n\t\t// Suggestions may contains \"settings\" values (e.g. `opensInNewTab`)\n\t\t// which should not overide any existing settings values set by the\n\t\t// user. This filters out any settings values from the suggestion.\n\t\tconst nonSettingsChanges = Object.keys( updatedValue ).reduce(\n\t\t\t( acc, key ) => {\n\t\t\t\tif ( ! settingsKeys.includes( key ) ) {\n\t\t\t\t\tacc[ key ] = updatedValue[ key ];\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\tonChange( {\n\t\t\t...internalControlValue,\n\t\t\t...nonSettingsChanges,\n\t\t\t// As title is not a setting, it must be manually applied\n\t\t\t// in such a way as to preserve the users changes over\n\t\t\t// any \"title\" value provided by the \"suggestion\".\n\t\t\ttitle: internalControlValue?.title || updatedValue?.title,\n\t\t} );\n\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmit = () => {\n\t\tif ( valueHasChanges ) {\n\t\t\t// Submit the original value with new stored values applied\n\t\t\t// on top. URL is a special case as it may also be a prop.\n\t\t\tonChange( {\n\t\t\t\t...value,\n\t\t\t\t...internalControlValue,\n\t\t\t\turl: currentUrlInputValue,\n\t\t\t} );\n\t\t}\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmitWithEnter = ( event ) => {\n\t\tconst { keyCode } = event;\n\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 resetInternalValues = () => {\n\t\tsetInternalControlValue( value );\n\t};\n\n\tconst handleCancel = ( event ) => {\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\n\t\t// Ensure that any unsubmitted input changes are reset.\n\t\tresetInternalValues();\n\n\t\tif ( hasLinkValue ) {\n\t\t\t// If there is a link then exist editing mode and show preview.\n\t\t\tstopEditing();\n\t\t} else {\n\t\t\t// If there is no link value, then remove the link entirely.\n\t\t\tonRemove?.();\n\t\t}\n\n\t\tonCancel?.();\n\t};\n\n\tconst currentUrlInputValue =\n\t\tpropInputValue || internalControlValue?.url || '';\n\n\tconst currentInputIsEmpty = ! currentUrlInputValue?.trim()?.length;\n\n\tconst shownUnlinkControl =\n\t\tonRemove && value && ! isEditingLink && ! isCreatingPage;\n\n\tconst showSettings = !! settings?.length && isEditingLink && hasLinkValue;\n\tconst showActions = isEditingLink && hasLinkValue;\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 = hasLinkValue && hasTextControl;\n\n\tconst isEditing = ( isEditingLink || ! value ) && ! isCreatingPage;\n\tconst isDisabled = ! valueHasChanges || currentInputIsEmpty;\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{ isEditing && (\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\t__nextHasNoMarginBottom\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={ internalControlValue?.title }\n\t\t\t\t\t\t\t\tonChange={ setInternalTextInputValue }\n\t\t\t\t\t\t\t\tonKeyDown={ handleSubmitWithEnter }\n\t\t\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\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={ currentUrlInputValue }\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={ setInternalURLInputValue }\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\thideLabelFromVision={ ! showTextControl }\n\t\t\t\t\t\t/>\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={ () => {\n\t\t\t\t\t\tonRemove();\n\t\t\t\t\t\tsetIsEditingLink( true );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ showSettings && (\n\t\t\t\t<div className=\"block-editor-link-control__tools\">\n\t\t\t\t\t{ ! currentInputIsEmpty && (\n\t\t\t\t\t\t<LinkControlSettingsDrawer\n\t\t\t\t\t\t\tsettingsOpen={ settingsOpen }\n\t\t\t\t\t\t\tsetSettingsOpen={ setSettingsOpen }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<LinkSettings\n\t\t\t\t\t\t\t\tvalue={ internalControlValue }\n\t\t\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\t\t\tonChange={ createSetInternalSettingValueHandler(\n\t\t\t\t\t\t\t\t\tsettingsKeys\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</LinkControlSettingsDrawer>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ showActions && (\n\t\t\t\t<div className=\"block-editor-link-control__search-actions\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ isDisabled ? noop : handleSubmit }\n\t\t\t\t\t\tclassName=\"block-editor-link-control__search-submit\"\n\t\t\t\t\t\taria-disabled={ isDisabled }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button variant=\"tertiary\" onClick={ handleCancel }>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ renderControlBottom && renderControlBottom() }\n\t\t</div>\n\t);\n}\n\nLinkControl.ViewerFill = ViewerFill;\n\nexport default LinkControl;\n"]}
@@ -1,22 +1,16 @@
1
1
  import { createElement } from "@wordpress/element";
2
2
 
3
- /**
4
- * External dependencies
5
- */
6
- import classnames from 'classnames';
7
3
  /**
8
4
  * WordPress dependencies
9
5
  */
10
-
11
6
  import { __, sprintf } from '@wordpress/i18n';
12
- import { Button } from '@wordpress/components';
7
+ import { MenuItem } from '@wordpress/components';
13
8
  import { createInterpolateElement } from '@wordpress/element';
14
- import { Icon, plus } from '@wordpress/icons';
9
+ import { plus } from '@wordpress/icons';
15
10
  export const LinkControlSearchCreate = ({
16
11
  searchTerm,
17
12
  onClick,
18
13
  itemProps,
19
- isSelected,
20
14
  buttonText
21
15
  }) => {
22
16
  if (!searchTerm) {
@@ -35,19 +29,12 @@ export const LinkControlSearchCreate = ({
35
29
  });
36
30
  }
37
31
 
38
- return createElement(Button, { ...itemProps,
39
- className: classnames('block-editor-link-control__search-create block-editor-link-control__search-item', {
40
- 'is-selected': isSelected
41
- }),
32
+ return createElement(MenuItem, { ...itemProps,
33
+ iconPosition: "left",
34
+ icon: plus,
35
+ className: "block-editor-link-control__search-item",
42
36
  onClick: onClick
43
- }, createElement(Icon, {
44
- className: "block-editor-link-control__search-item-icon",
45
- icon: plus
46
- }), createElement("span", {
47
- className: "block-editor-link-control__search-item-header"
48
- }, createElement("span", {
49
- className: "block-editor-link-control__search-item-title"
50
- }, text)));
37
+ }, text);
51
38
  };
52
39
  export default LinkControlSearchCreate;
53
40
  //# sourceMappingURL=search-create-button.js.map
@@ -1 +1 @@
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,CAAE;AACxCC,EAAAA,UADwC;AAExCC,EAAAA,OAFwC;AAGxCC,EAAAA,SAHwC;AAIxCC,EAAAA,UAJwC;AAKxCC,EAAAA;AALwC,CAAF,KAMhC;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,OACMJ,SADN;AAEC,IAAA,SAAS,EAAGV,UAAU,CACrB,iFADqB,EAErB;AACC,qBAAeW;AADhB,KAFqB,CAFvB;AAQC,IAAA,OAAO,EAAGF;AARX,KAUC,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"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-create-button.js"],"names":["__","sprintf","MenuItem","createInterpolateElement","plus","LinkControlSearchCreate","searchTerm","onClick","itemProps","buttonText","text","mark"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,QAAT,QAAyB,uBAAzB;AACA,SAASC,wBAAT,QAAyC,oBAAzC;AACA,SAASC,IAAT,QAAqB,kBAArB;AAEA,OAAO,MAAMC,uBAAuB,GAAG,CAAE;AACxCC,EAAAA,UADwC;AAExCC,EAAAA,OAFwC;AAGxCC,EAAAA,SAHwC;AAIxCC,EAAAA;AAJwC,CAAF,KAKhC;AACN,MAAK,CAAEH,UAAP,EAAoB;AACnB,WAAO,IAAP;AACA;;AAED,MAAII,IAAJ;;AACA,MAAKD,UAAL,EAAkB;AACjBC,IAAAA,IAAI,GACH,OAAOD,UAAP,KAAsB,UAAtB,GACGA,UAAU,CAAEH,UAAF,CADb,GAEGG,UAHJ;AAIA,GALD,MAKO;AACNC,IAAAA,IAAI,GAAGP,wBAAwB,CAC9BF,OAAO;AACN;AACAD,IAAAA,EAAE,CAAE,yBAAF,CAFI,EAGNM,UAHM,CADuB,EAM9B;AAAEK,MAAAA,IAAI,EAAE;AAAR,KAN8B,CAA/B;AAQA;;AAED,SACC,cAAC,QAAD,OACMH,SADN;AAEC,IAAA,YAAY,EAAC,MAFd;AAGC,IAAA,IAAI,EAAGJ,IAHR;AAIC,IAAA,SAAS,EAAC,wCAJX;AAKC,IAAA,OAAO,EAAGG;AALX,KAOGG,IAPH,CADD;AAWA,CAtCM;AAwCP,eAAeL,uBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { MenuItem } from '@wordpress/components';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { plus } from '@wordpress/icons';\n\nexport const LinkControlSearchCreate = ( {\n\tsearchTerm,\n\tonClick,\n\titemProps,\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<MenuItem\n\t\t\t{ ...itemProps }\n\t\t\ticonPosition=\"left\"\n\t\t\ticon={ plus }\n\t\t\tclassName=\"block-editor-link-control__search-item\"\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ text }\n\t\t</MenuItem>\n\t);\n};\n\nexport default LinkControlSearchCreate;\n"]}
@@ -45,7 +45,7 @@ const LinkControlSearchInput = forwardRef(({
45
45
  suggestionsQuery = {},
46
46
  withURLSuggestion = true,
47
47
  createSuggestionButtonText,
48
- useLabel = false
48
+ hideLabelFromVision = false
49
49
  }, ref) => {
50
50
  const genericSearchHandler = useSearchHandler(suggestionsQuery, allowDirectEntry, withCreateSuggestion, withURLSuggestion);
51
51
  const searchHandler = showSuggestions ? fetchSuggestions || genericSearchHandler : noopSearchHandler;
@@ -107,15 +107,15 @@ const LinkControlSearchInput = forwardRef(({
107
107
  }
108
108
  };
109
109
 
110
- const inputClasses = classnames(className, {
111
- 'has-no-label': !useLabel
110
+ const inputClasses = classnames(className, {// 'has-no-label': ! hideLabelFromVision,
112
111
  });
113
112
  return createElement("div", {
114
113
  className: "block-editor-link-control__search-input-container"
115
114
  }, createElement(URLInput, {
116
115
  disableSuggestions: currentLink?.url === value,
117
116
  __nextHasNoMarginBottom: true,
118
- label: useLabel ? 'URL' : undefined,
117
+ label: __('Link'),
118
+ hideLabelFromVision: hideLabelFromVision,
119
119
  className: inputClasses,
120
120
  value: value,
121
121
  onChange: onInputChange,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-input.js"],"names":["classnames","useInstanceId","forwardRef","useState","__","URLInput","LinkControlSearchResults","CREATE_TYPE","useSearchHandler","noopSearchHandler","Promise","resolve","noop","LinkControlSearchInput","value","children","currentLink","className","placeholder","withCreateSuggestion","onCreateSuggestion","onChange","onSelect","showSuggestions","renderSuggestions","props","fetchSuggestions","allowDirectEntry","showInitialSuggestions","suggestionsQuery","withURLSuggestion","createSuggestionButtonText","useLabel","ref","genericSearchHandler","searchHandler","instanceId","focusedSuggestion","setFocusedSuggestion","onInputChange","selection","suggestion","handleRenderSuggestions","handleSuggestionClick","onSuggestionSelected","selectedSuggestion","type","title","url","e","Object","keys","length","id","restLinkProps","inputClasses","undefined","event","hasSuggestion","trim","preventDefault"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,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,QAA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 '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\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\tconst { id, url, ...restLinkProps } = currentLink ?? {};\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{ ...restLinkProps, ...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\tdisableSuggestions={ currentLink?.url === value }\n\t\t\t\t\t__nextHasNoMarginBottom\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":["classnames","useInstanceId","forwardRef","useState","__","URLInput","LinkControlSearchResults","CREATE_TYPE","useSearchHandler","noopSearchHandler","Promise","resolve","noop","LinkControlSearchInput","value","children","currentLink","className","placeholder","withCreateSuggestion","onCreateSuggestion","onChange","onSelect","showSuggestions","renderSuggestions","props","fetchSuggestions","allowDirectEntry","showInitialSuggestions","suggestionsQuery","withURLSuggestion","createSuggestionButtonText","hideLabelFromVision","ref","genericSearchHandler","searchHandler","instanceId","focusedSuggestion","setFocusedSuggestion","onInputChange","selection","suggestion","handleRenderSuggestions","handleSuggestionClick","onSuggestionSelected","selectedSuggestion","type","title","url","e","Object","keys","length","id","restLinkProps","inputClasses","event","hasSuggestion","trim","preventDefault"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,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,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,MAAMC,sBAAsB,GAAGX,UAAU,CACxC,CACC;AACCY,EAAAA,KADD;AAECC,EAAAA,QAFD;AAGCC,EAAAA,WAAW,GAAG,EAHf;AAICC,EAAAA,SAAS,GAAG,IAJb;AAKCC,EAAAA,WAAW,GAAG,IALf;AAMCC,EAAAA,oBAAoB,GAAG,KANxB;AAOCC,EAAAA,kBAAkB,GAAGR,IAPtB;AAQCS,EAAAA,QAAQ,GAAGT,IARZ;AASCU,EAAAA,QAAQ,GAAGV,IATZ;AAUCW,EAAAA,eAAe,GAAG,IAVnB;AAWCC,EAAAA,iBAAiB,GAAKC,KAAF,IACnB,cAAC,wBAAD,OAA+BA;AAA/B,IAZF;AAcCC,EAAAA,gBAAgB,GAAG,IAdpB;AAeCC,EAAAA,gBA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aC,IAAA,kCAAkC,EAAG,IAbtC;AAcC,IAAA,oCAAoC,EACnCP,sBAfF;AAiBC,IAAA,QAAQ,EAAG,CAAEa,UAAF,EAAce,KAAd,KAAyB;AACnC,YAAMC,aAAa,GAAGhB,UAAU,IAAIJ,iBAApC,CADmC,CAGnC;AACA;;AACA,UAAK,CAAEoB,aAAF,IAAmB,CAAE3C,KAAK,EAAE4C,IAAP,IAAeN,MAAzC,EAAkD;AACjDI,QAAAA,KAAK,CAACG,cAAN;AACA,OAFD,MAEO;AACNf,QAAAA,oBAAoB,CACnBa,aAAa,IAAI;AAAET,UAAAA,GAAG,EAAElC;AAAP,SADE,CAApB;AAGA;AACD,KA7BF;AA8BC,IAAA,GAAG,EAAGmB;AA9BP,IADD,EAiCGlB,QAjCH,CADD;AAqCA,CAxIuC,CAAzC;AA2IA,eAAeF,sBAAf","sourcesContent":["/**\n * External dependencies\n */\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\thideLabelFromVision = 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\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\tconst { id, url, ...restLinkProps } = currentLink ?? {};\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{ ...restLinkProps, ...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': ! hideLabelFromVision,\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\tdisableSuggestions={ currentLink?.url === value }\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\t\thideLabelFromVision={ hideLabelFromVision }\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,18 +1,13 @@
1
1
  import { createElement } from "@wordpress/element";
2
2
 
3
- /**
4
- * External dependencies
5
- */
6
- import classnames from 'classnames';
7
3
  /**
8
4
  * WordPress dependencies
9
5
  */
10
-
11
- import { safeDecodeURI, filterURLForDisplay } from '@wordpress/url';
12
6
  import { __ } from '@wordpress/i18n';
13
- import { Button, TextHighlight } from '@wordpress/components';
7
+ import { MenuItem, TextHighlight } from '@wordpress/components';
14
8
  import { Icon, globe, page, tag, postList, category, file } from '@wordpress/icons';
15
9
  import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
10
+ import { safeDecodeURI, filterURLForDisplay } from '@wordpress/url';
16
11
  const ICONS_MAP = {
17
12
  post: postList,
18
13
  page,
@@ -46,36 +41,27 @@ function SearchItemIcon({
46
41
  export const LinkControlSearchItem = ({
47
42
  itemProps,
48
43
  suggestion,
49
- isSelected = false,
44
+ searchTerm,
50
45
  onClick,
51
46
  isURL = false,
52
- searchTerm = '',
53
47
  shouldShowType = false
54
48
  }) => {
55
- return createElement(Button, { ...itemProps,
49
+ const info = isURL ? __('Press ENTER to add this link') : filterURLForDisplay(safeDecodeURI(suggestion?.url), 24);
50
+ return createElement(MenuItem, { ...itemProps,
51
+ info: info,
52
+ iconPosition: "left",
53
+ icon: createElement(SearchItemIcon, {
54
+ suggestion: suggestion,
55
+ isURL: isURL
56
+ }),
56
57
  onClick: onClick,
57
- className: classnames('block-editor-link-control__search-item', {
58
- 'is-selected': isSelected,
59
- 'is-url': isURL,
60
- 'is-entity': !isURL
61
- })
62
- }, createElement(SearchItemIcon, {
63
- suggestion: suggestion,
64
- isURL: isURL
65
- }), createElement("span", {
66
- className: "block-editor-link-control__search-item-header"
67
- }, createElement("span", {
68
- className: "block-editor-link-control__search-item-title"
58
+ shortcut: shouldShowType && getVisualTypeName(suggestion),
59
+ className: "block-editor-link-control__search-item"
69
60
  }, createElement(TextHighlight // The component expects a plain text string.
70
61
  , {
71
62
  text: stripHTML(suggestion.title),
72
63
  highlight: searchTerm
73
- })), createElement("span", {
74
- "aria-hidden": !isURL,
75
- className: "block-editor-link-control__search-item-info"
76
- }, !isURL && (filterURLForDisplay(safeDecodeURI(suggestion.url)) || ''), isURL && __('Press ENTER to add this link'))), shouldShowType && suggestion.type && createElement("span", {
77
- className: "block-editor-link-control__search-item-type"
78
- }, getVisualTypeName(suggestion)));
64
+ }));
79
65
  };
80
66
 
81
67
  function getVisualTypeName(suggestion) {