@wordpress/block-editor 11.0.0 → 11.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (470) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/LICENSE.md +1 -1
  3. package/README.md +2 -1
  4. package/build/components/alignment-control/ui.js +1 -7
  5. package/build/components/alignment-control/ui.js.map +1 -1
  6. package/build/components/block-actions/index.js +9 -0
  7. package/build/components/block-actions/index.js.map +1 -1
  8. package/build/components/block-alignment-control/use-available-alignments.js +4 -3
  9. package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
  10. package/build/components/block-icon/index.js +4 -2
  11. package/build/components/block-icon/index.js.map +1 -1
  12. package/build/components/block-inspector/index.js +58 -5
  13. package/build/components/block-inspector/index.js.map +1 -1
  14. package/build/components/block-list-appender/index.js +46 -34
  15. package/build/components/block-list-appender/index.js.map +1 -1
  16. package/build/components/block-list-appender/index.native.js +39 -34
  17. package/build/components/block-list-appender/index.native.js.map +1 -1
  18. package/build/components/block-mobile-toolbar/block-actions-menu.native.js +18 -18
  19. package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  20. package/build/components/block-mobile-toolbar/index.native.js +1 -1
  21. package/build/components/block-mobile-toolbar/index.native.js.map +1 -1
  22. package/build/components/block-pattern-setup/index.js +14 -7
  23. package/build/components/block-pattern-setup/index.js.map +1 -1
  24. package/build/components/block-preview/auto.js +1 -4
  25. package/build/components/block-preview/auto.js.map +1 -1
  26. package/build/components/block-settings-menu/block-settings-dropdown.js +4 -1
  27. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  28. package/build/components/block-styles/index.js +3 -1
  29. package/build/components/block-styles/index.js.map +1 -1
  30. package/build/components/block-styles/index.native.js +1 -3
  31. package/build/components/block-styles/index.native.js.map +1 -1
  32. package/build/components/block-styles/utils.js +7 -10
  33. package/build/components/block-styles/utils.js.map +1 -1
  34. package/build/components/block-toolbar/index.native.js +6 -8
  35. package/build/components/block-toolbar/index.native.js.map +1 -1
  36. package/build/components/block-tools/selected-block-popover.js +1 -3
  37. package/build/components/block-tools/selected-block-popover.js.map +1 -1
  38. package/build/components/block-tools/use-block-toolbar-popover-props.js +43 -10
  39. package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  40. package/build/components/block-variation-picker/index.js +1 -1
  41. package/build/components/block-variation-picker/index.js.map +1 -1
  42. package/build/components/colors/utils.js +2 -6
  43. package/build/components/colors/utils.js.map +1 -1
  44. package/build/components/colors-gradients/control.js +0 -3
  45. package/build/components/colors-gradients/control.js.map +1 -1
  46. package/build/components/colors-gradients/dropdown.js +0 -2
  47. package/build/components/colors-gradients/dropdown.js.map +1 -1
  48. package/build/components/colors-gradients/panel-color-gradient-settings.js +2 -19
  49. package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  50. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -3
  51. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
  52. package/build/components/copy-handler/index.js +37 -9
  53. package/build/components/copy-handler/index.js.map +1 -1
  54. package/build/components/default-style-picker/index.js +1 -0
  55. package/build/components/default-style-picker/index.js.map +1 -1
  56. package/build/components/font-sizes/fluid-utils.js +5 -2
  57. package/build/components/font-sizes/fluid-utils.js.map +1 -1
  58. package/build/components/font-sizes/utils.js +10 -4
  59. package/build/components/font-sizes/utils.js.map +1 -1
  60. package/build/components/font-sizes/with-font-sizes.js +14 -12
  61. package/build/components/font-sizes/with-font-sizes.js.map +1 -1
  62. package/build/components/gradients/use-gradient.js +2 -8
  63. package/build/components/gradients/use-gradient.js.map +1 -1
  64. package/build/components/iframe/index.js +48 -101
  65. package/build/components/iframe/index.js.map +1 -1
  66. package/build/components/iframe/use-compatibility-styles.js +98 -0
  67. package/build/components/iframe/use-compatibility-styles.js.map +1 -0
  68. package/build/components/image-size-control/index.js +1 -0
  69. package/build/components/image-size-control/index.js.map +1 -1
  70. package/build/components/inner-blocks/index.js +6 -2
  71. package/build/components/inner-blocks/index.js.map +1 -1
  72. package/build/components/inserter/block-patterns-tab.js +4 -4
  73. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  74. package/build/components/inserter/hooks/use-insertion-point.js +4 -3
  75. package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
  76. package/build/components/inserter/index.js +16 -6
  77. package/build/components/inserter/index.js.map +1 -1
  78. package/build/components/inserter/media-tab/hooks.js +8 -5
  79. package/build/components/inserter/media-tab/hooks.js.map +1 -1
  80. package/build/components/inserter/menu.js +11 -5
  81. package/build/components/inserter/menu.js.map +1 -1
  82. package/build/components/inserter/quick-inserter.js +6 -3
  83. package/build/components/inserter/quick-inserter.js.map +1 -1
  84. package/build/components/inserter/search-items.js +15 -14
  85. package/build/components/inserter/search-items.js.map +1 -1
  86. package/build/components/inserter/search-results.js +4 -2
  87. package/build/components/inserter/search-results.js.map +1 -1
  88. package/build/components/inspector-controls/groups.js +3 -1
  89. package/build/components/inspector-controls/groups.js.map +1 -1
  90. package/build/components/inspector-controls-tabs/position-controls-panel.js +46 -0
  91. package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -0
  92. package/build/components/inspector-controls-tabs/settings-tab.js +3 -1
  93. package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -1
  94. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -11
  95. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  96. package/build/components/link-control/search-input.js +1 -0
  97. package/build/components/link-control/search-input.js.map +1 -1
  98. package/build/components/list-view/block-select-button.js +1 -1
  99. package/build/components/list-view/block-select-button.js.map +1 -1
  100. package/build/components/off-canvas-editor/appender.js +3 -44
  101. package/build/components/off-canvas-editor/appender.js.map +1 -1
  102. package/build/components/off-canvas-editor/block-contents.js +38 -5
  103. package/build/components/off-canvas-editor/block-contents.js.map +1 -1
  104. package/build/components/off-canvas-editor/block-select-button.js +3 -2
  105. package/build/components/off-canvas-editor/block-select-button.js.map +1 -1
  106. package/build/components/off-canvas-editor/block.js +51 -57
  107. package/build/components/off-canvas-editor/block.js.map +1 -1
  108. package/build/components/off-canvas-editor/index.js +12 -5
  109. package/build/components/off-canvas-editor/index.js.map +1 -1
  110. package/build/components/off-canvas-editor/use-inserted-block.js +58 -0
  111. package/build/components/off-canvas-editor/use-inserted-block.js.map +1 -0
  112. package/build/components/provider/index.js +3 -1
  113. package/build/components/provider/index.js.map +1 -1
  114. package/build/components/responsive-block-control/label.js.map +1 -1
  115. package/build/components/rich-text/format-edit.js +12 -10
  116. package/build/components/rich-text/format-edit.js.map +1 -1
  117. package/build/components/rich-text/index.js.map +1 -1
  118. package/build/components/rich-text/use-enter.js +4 -5
  119. package/build/components/rich-text/use-enter.js.map +1 -1
  120. package/build/components/rich-text/use-paste-handler.js +21 -12
  121. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  122. package/build/components/spacing-sizes-control/index.js +0 -1
  123. package/build/components/spacing-sizes-control/index.js.map +1 -1
  124. package/build/components/spacing-sizes-control/utils.js +1 -1
  125. package/build/components/spacing-sizes-control/utils.js.map +1 -1
  126. package/build/components/typewriter/index.js +1 -1
  127. package/build/components/typewriter/index.js.map +1 -1
  128. package/build/components/url-input/button.js +1 -0
  129. package/build/components/url-input/button.js.map +1 -1
  130. package/build/components/url-input/index.js +15 -1
  131. package/build/components/url-input/index.js.map +1 -1
  132. package/build/components/url-popover/image-url-input-ui.js +2 -2
  133. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  134. package/build/components/url-popover/link-editor.js +1 -0
  135. package/build/components/url-popover/link-editor.js.map +1 -1
  136. package/build/components/use-paste-styles/index.js +188 -0
  137. package/build/components/use-paste-styles/index.js.map +1 -0
  138. package/build/components/writing-flow/index.js +1 -1
  139. package/build/components/writing-flow/index.js.map +1 -1
  140. package/build/components/writing-flow/use-arrow-nav.js +22 -29
  141. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  142. package/build/hooks/border.js +0 -1
  143. package/build/hooks/border.js.map +1 -1
  144. package/build/hooks/color-panel.js +0 -1
  145. package/build/hooks/color-panel.js.map +1 -1
  146. package/build/hooks/color.js +1 -2
  147. package/build/hooks/color.js.map +1 -1
  148. package/build/hooks/font-family.js +4 -4
  149. package/build/hooks/font-family.js.map +1 -1
  150. package/build/hooks/font-size.js +5 -3
  151. package/build/hooks/font-size.js.map +1 -1
  152. package/build/hooks/index.js +2 -0
  153. package/build/hooks/index.js.map +1 -1
  154. package/build/hooks/metadata.js +1 -1
  155. package/build/hooks/metadata.js.map +1 -1
  156. package/build/hooks/position.js +376 -0
  157. package/build/hooks/position.js.map +1 -0
  158. package/build/hooks/supports.js +328 -0
  159. package/build/hooks/supports.js.map +1 -0
  160. package/build/hooks/use-typography-props.js +11 -8
  161. package/build/hooks/use-typography-props.js.map +1 -1
  162. package/build/store/reducer.js +27 -9
  163. package/build/store/reducer.js.map +1 -1
  164. package/build/store/selectors.js +9 -7
  165. package/build/store/selectors.js.map +1 -1
  166. package/build/utils/pasting.js +6 -11
  167. package/build/utils/pasting.js.map +1 -1
  168. package/build-module/components/alignment-control/ui.js +1 -6
  169. package/build-module/components/alignment-control/ui.js.map +1 -1
  170. package/build-module/components/block-actions/index.js +6 -0
  171. package/build-module/components/block-actions/index.js.map +1 -1
  172. package/build-module/components/block-alignment-control/use-available-alignments.js +4 -3
  173. package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
  174. package/build-module/components/block-icon/index.js +4 -2
  175. package/build-module/components/block-icon/index.js.map +1 -1
  176. package/build-module/components/block-inspector/index.js +58 -6
  177. package/build-module/components/block-inspector/index.js.map +1 -1
  178. package/build-module/components/block-list-appender/index.js +46 -34
  179. package/build-module/components/block-list-appender/index.js.map +1 -1
  180. package/build-module/components/block-list-appender/index.native.js +39 -32
  181. package/build-module/components/block-list-appender/index.native.js.map +1 -1
  182. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +18 -18
  183. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  184. package/build-module/components/block-mobile-toolbar/index.native.js +1 -1
  185. package/build-module/components/block-mobile-toolbar/index.native.js.map +1 -1
  186. package/build-module/components/block-pattern-setup/index.js +14 -7
  187. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  188. package/build-module/components/block-preview/auto.js +1 -4
  189. package/build-module/components/block-preview/auto.js.map +1 -1
  190. package/build-module/components/block-settings-menu/block-settings-dropdown.js +4 -1
  191. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  192. package/build-module/components/block-styles/index.js +2 -1
  193. package/build-module/components/block-styles/index.js.map +1 -1
  194. package/build-module/components/block-styles/index.native.js +1 -2
  195. package/build-module/components/block-styles/index.native.js.map +1 -1
  196. package/build-module/components/block-styles/utils.js +7 -9
  197. package/build-module/components/block-styles/utils.js.map +1 -1
  198. package/build-module/components/block-toolbar/index.native.js +6 -8
  199. package/build-module/components/block-toolbar/index.native.js.map +1 -1
  200. package/build-module/components/block-tools/selected-block-popover.js +1 -2
  201. package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
  202. package/build-module/components/block-tools/use-block-toolbar-popover-props.js +42 -11
  203. package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  204. package/build-module/components/block-variation-picker/index.js +1 -1
  205. package/build-module/components/block-variation-picker/index.js.map +1 -1
  206. package/build-module/components/colors/utils.js +3 -7
  207. package/build-module/components/colors/utils.js.map +1 -1
  208. package/build-module/components/colors-gradients/control.js +0 -3
  209. package/build-module/components/colors-gradients/control.js.map +1 -1
  210. package/build-module/components/colors-gradients/dropdown.js +0 -2
  211. package/build-module/components/colors-gradients/dropdown.js.map +1 -1
  212. package/build-module/components/colors-gradients/panel-color-gradient-settings.js +4 -19
  213. package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  214. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -2
  215. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
  216. package/build-module/components/copy-handler/index.js +38 -10
  217. package/build-module/components/copy-handler/index.js.map +1 -1
  218. package/build-module/components/default-style-picker/index.js +1 -0
  219. package/build-module/components/default-style-picker/index.js.map +1 -1
  220. package/build-module/components/font-sizes/fluid-utils.js +5 -2
  221. package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
  222. package/build-module/components/font-sizes/utils.js +11 -5
  223. package/build-module/components/font-sizes/utils.js.map +1 -1
  224. package/build-module/components/font-sizes/with-font-sizes.js +14 -11
  225. package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
  226. package/build-module/components/gradients/use-gradient.js +2 -7
  227. package/build-module/components/gradients/use-gradient.js.map +1 -1
  228. package/build-module/components/iframe/index.js +46 -102
  229. package/build-module/components/iframe/index.js.map +1 -1
  230. package/build-module/components/iframe/use-compatibility-styles.js +90 -0
  231. package/build-module/components/iframe/use-compatibility-styles.js.map +1 -0
  232. package/build-module/components/image-size-control/index.js +1 -0
  233. package/build-module/components/image-size-control/index.js.map +1 -1
  234. package/build-module/components/inner-blocks/index.js +6 -2
  235. package/build-module/components/inner-blocks/index.js.map +1 -1
  236. package/build-module/components/inserter/block-patterns-tab.js +4 -4
  237. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  238. package/build-module/components/inserter/hooks/use-insertion-point.js +4 -3
  239. package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
  240. package/build-module/components/inserter/index.js +16 -6
  241. package/build-module/components/inserter/index.js.map +1 -1
  242. package/build-module/components/inserter/media-tab/hooks.js +8 -5
  243. package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
  244. package/build-module/components/inserter/menu.js +11 -5
  245. package/build-module/components/inserter/menu.js.map +1 -1
  246. package/build-module/components/inserter/quick-inserter.js +6 -3
  247. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  248. package/build-module/components/inserter/search-items.js +15 -13
  249. package/build-module/components/inserter/search-items.js.map +1 -1
  250. package/build-module/components/inserter/search-results.js +4 -2
  251. package/build-module/components/inserter/search-results.js.map +1 -1
  252. package/build-module/components/inspector-controls/groups.js +3 -1
  253. package/build-module/components/inspector-controls/groups.js.map +1 -1
  254. package/build-module/components/inspector-controls-tabs/position-controls-panel.js +33 -0
  255. package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -0
  256. package/build-module/components/inspector-controls-tabs/settings-tab.js +2 -1
  257. package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -1
  258. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -11
  259. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  260. package/build-module/components/link-control/search-input.js +1 -0
  261. package/build-module/components/link-control/search-input.js.map +1 -1
  262. package/build-module/components/list-view/block-select-button.js +1 -1
  263. package/build-module/components/list-view/block-select-button.js.map +1 -1
  264. package/build-module/components/off-canvas-editor/appender.js +5 -44
  265. package/build-module/components/off-canvas-editor/appender.js.map +1 -1
  266. package/build-module/components/off-canvas-editor/block-contents.js +37 -7
  267. package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
  268. package/build-module/components/off-canvas-editor/block-select-button.js +3 -2
  269. package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -1
  270. package/build-module/components/off-canvas-editor/block.js +54 -60
  271. package/build-module/components/off-canvas-editor/block.js.map +1 -1
  272. package/build-module/components/off-canvas-editor/index.js +12 -5
  273. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  274. package/build-module/components/off-canvas-editor/use-inserted-block.js +47 -0
  275. package/build-module/components/off-canvas-editor/use-inserted-block.js.map +1 -0
  276. package/build-module/components/provider/index.js +3 -1
  277. package/build-module/components/provider/index.js.map +1 -1
  278. package/build-module/components/responsive-block-control/label.js +1 -2
  279. package/build-module/components/responsive-block-control/label.js.map +1 -1
  280. package/build-module/components/rich-text/format-edit.js +12 -9
  281. package/build-module/components/rich-text/format-edit.js.map +1 -1
  282. package/build-module/components/rich-text/index.js.map +1 -1
  283. package/build-module/components/rich-text/use-enter.js +4 -5
  284. package/build-module/components/rich-text/use-enter.js.map +1 -1
  285. package/build-module/components/rich-text/use-paste-handler.js +22 -12
  286. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  287. package/build-module/components/spacing-sizes-control/index.js +0 -1
  288. package/build-module/components/spacing-sizes-control/index.js.map +1 -1
  289. package/build-module/components/spacing-sizes-control/utils.js +1 -1
  290. package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
  291. package/build-module/components/typewriter/index.js +1 -1
  292. package/build-module/components/typewriter/index.js.map +1 -1
  293. package/build-module/components/url-input/button.js +1 -0
  294. package/build-module/components/url-input/button.js.map +1 -1
  295. package/build-module/components/url-input/index.js +14 -1
  296. package/build-module/components/url-input/index.js.map +1 -1
  297. package/build-module/components/url-popover/image-url-input-ui.js +3 -3
  298. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  299. package/build-module/components/url-popover/link-editor.js +1 -0
  300. package/build-module/components/url-popover/link-editor.js.map +1 -1
  301. package/build-module/components/use-paste-styles/index.js +174 -0
  302. package/build-module/components/use-paste-styles/index.js.map +1 -0
  303. package/build-module/components/writing-flow/index.js +1 -1
  304. package/build-module/components/writing-flow/index.js.map +1 -1
  305. package/build-module/components/writing-flow/use-arrow-nav.js +22 -29
  306. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  307. package/build-module/hooks/border.js +0 -1
  308. package/build-module/hooks/border.js.map +1 -1
  309. package/build-module/hooks/color-panel.js +0 -1
  310. package/build-module/hooks/color-panel.js.map +1 -1
  311. package/build-module/hooks/color.js +1 -2
  312. package/build-module/hooks/color.js.map +1 -1
  313. package/build-module/hooks/font-family.js +5 -5
  314. package/build-module/hooks/font-family.js.map +1 -1
  315. package/build-module/hooks/font-size.js +5 -3
  316. package/build-module/hooks/font-size.js.map +1 -1
  317. package/build-module/hooks/index.js +1 -0
  318. package/build-module/hooks/index.js.map +1 -1
  319. package/build-module/hooks/metadata.js +1 -1
  320. package/build-module/hooks/metadata.js.map +1 -1
  321. package/build-module/hooks/position.js +337 -0
  322. package/build-module/hooks/position.js.map +1 -0
  323. package/build-module/hooks/supports.js +257 -0
  324. package/build-module/hooks/supports.js.map +1 -0
  325. package/build-module/hooks/use-typography-props.js +11 -8
  326. package/build-module/hooks/use-typography-props.js.map +1 -1
  327. package/build-module/store/reducer.js +27 -8
  328. package/build-module/store/reducer.js.map +1 -1
  329. package/build-module/store/selectors.js +9 -7
  330. package/build-module/store/selectors.js.map +1 -1
  331. package/build-module/utils/pasting.js +6 -10
  332. package/build-module/utils/pasting.js.map +1 -1
  333. package/build-style/content-rtl.css +60 -3
  334. package/build-style/content.css +60 -3
  335. package/build-style/default-editor-styles-rtl.css +3 -3
  336. package/build-style/default-editor-styles.css +3 -3
  337. package/build-style/style-rtl.css +62 -69
  338. package/build-style/style.css +62 -69
  339. package/package.json +29 -29
  340. package/src/components/alignment-control/test/index.js +2 -0
  341. package/src/components/alignment-control/ui.js +1 -7
  342. package/src/components/block-actions/index.js +5 -0
  343. package/src/components/block-alignment-control/test/index.js +2 -0
  344. package/src/components/block-alignment-control/use-available-alignments.js +4 -3
  345. package/src/components/block-icon/index.js +4 -2
  346. package/src/components/block-icon/test/index.js +9 -5
  347. package/src/components/block-inspector/index.js +79 -4
  348. package/src/components/block-inspector/style.scss +7 -0
  349. package/src/components/block-list-appender/index.js +65 -54
  350. package/src/components/block-list-appender/index.native.js +45 -34
  351. package/src/components/block-mobile-toolbar/block-actions-menu.native.js +18 -22
  352. package/src/components/block-mobile-toolbar/index.native.js +1 -1
  353. package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +125 -0
  354. package/src/components/block-mobile-toolbar/test/block-actions-menu.native.js +439 -0
  355. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +42 -0
  356. package/src/components/block-mover/test/index.native.js +157 -1
  357. package/src/components/block-pattern-setup/index.js +15 -6
  358. package/src/components/block-pattern-setup/style.scss +29 -1
  359. package/src/components/block-preview/auto.js +2 -4
  360. package/src/components/block-settings-menu/block-settings-dropdown.js +4 -0
  361. package/src/components/block-styles/index.js +4 -1
  362. package/src/components/block-styles/index.native.js +1 -2
  363. package/src/components/block-styles/utils.js +5 -7
  364. package/src/components/block-switcher/test/index.js +3 -2
  365. package/src/components/block-toolbar/index.native.js +8 -11
  366. package/src/components/block-tools/selected-block-popover.js +1 -3
  367. package/src/components/block-tools/use-block-toolbar-popover-props.js +68 -12
  368. package/src/components/block-variation-picker/index.js +5 -1
  369. package/src/components/block-vertical-alignment-control/test/index.js +2 -0
  370. package/src/components/button-block-appender/{style.scss → content.scss} +0 -0
  371. package/src/components/colors/test/with-colors.js +2 -0
  372. package/src/components/colors/utils.js +5 -3
  373. package/src/components/colors-gradients/control.js +0 -7
  374. package/src/components/colors-gradients/dropdown.js +0 -2
  375. package/src/components/colors-gradients/panel-color-gradient-settings.js +4 -22
  376. package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -2
  377. package/src/components/copy-handler/index.js +53 -7
  378. package/src/components/default-block-appender/test/index.js +2 -0
  379. package/src/components/default-style-picker/index.js +1 -0
  380. package/src/components/font-sizes/fluid-utils.js +7 -1
  381. package/src/components/font-sizes/utils.js +5 -3
  382. package/src/components/font-sizes/with-font-sizes.js +36 -36
  383. package/src/components/gradients/use-gradient.js +2 -7
  384. package/src/components/iframe/index.js +60 -122
  385. package/src/components/iframe/use-compatibility-styles.js +101 -0
  386. package/src/components/image-size-control/index.js +1 -0
  387. package/src/components/image-size-control/test/index.js +147 -79
  388. package/src/components/inner-blocks/index.js +4 -2
  389. package/src/components/inserter/block-patterns-tab.js +7 -4
  390. package/src/components/inserter/hooks/use-insertion-point.js +3 -2
  391. package/src/components/inserter/index.js +61 -43
  392. package/src/components/inserter/media-tab/hooks.js +5 -4
  393. package/src/components/inserter/menu.js +8 -4
  394. package/src/components/inserter/quick-inserter.js +3 -0
  395. package/src/components/inserter/search-items.js +1 -2
  396. package/src/components/inserter/search-results.js +2 -0
  397. package/src/components/inserter/test/__snapshots__/index.native.js.snap +117 -0
  398. package/src/components/inserter/test/index.native.js +255 -1
  399. package/src/components/inspector-controls/groups.js +2 -0
  400. package/src/components/inspector-controls-tabs/position-controls-panel.js +37 -0
  401. package/src/components/inspector-controls-tabs/settings-tab.js +2 -0
  402. package/src/components/inspector-controls-tabs/style.scss +15 -0
  403. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +3 -8
  404. package/src/components/link-control/search-input.js +1 -0
  405. package/src/components/link-control/style.scss +1 -0
  406. package/src/components/link-control/test/index.js +18 -4
  407. package/src/components/list-view/block-select-button.js +1 -1
  408. package/src/components/list-view/style.scss +14 -10
  409. package/src/components/media-replace-flow/test/index.js +2 -0
  410. package/src/components/off-canvas-editor/appender.js +4 -49
  411. package/src/components/off-canvas-editor/block-contents.js +84 -23
  412. package/src/components/off-canvas-editor/block-select-button.js +6 -2
  413. package/src/components/off-canvas-editor/block.js +90 -105
  414. package/src/components/off-canvas-editor/index.js +21 -2
  415. package/src/components/off-canvas-editor/style.scss +5 -1
  416. package/src/components/off-canvas-editor/test/use-inserted-block.js +108 -0
  417. package/src/components/off-canvas-editor/use-inserted-block.js +47 -0
  418. package/src/components/provider/index.js +4 -1
  419. package/src/components/responsive-block-control/label.js +2 -3
  420. package/src/components/responsive-block-control/test/index.js +4 -2
  421. package/src/components/rich-text/format-edit.js +6 -10
  422. package/src/components/rich-text/index.js +1 -0
  423. package/src/components/rich-text/use-enter.js +4 -4
  424. package/src/components/rich-text/use-paste-handler.js +33 -14
  425. package/src/components/spacing-sizes-control/index.js +0 -1
  426. package/src/components/spacing-sizes-control/utils.js +1 -1
  427. package/src/components/typewriter/index.js +3 -1
  428. package/src/components/url-input/README.md +5 -0
  429. package/src/components/url-input/button.js +1 -0
  430. package/src/components/url-input/index.js +15 -1
  431. package/src/components/url-input/test/button.js +2 -0
  432. package/src/components/url-popover/image-url-input-ui.js +5 -4
  433. package/src/components/url-popover/link-editor.js +1 -0
  434. package/src/components/url-popover/test/index.js +21 -5
  435. package/src/components/use-paste-styles/index.js +230 -0
  436. package/src/components/warning/test/index.js +2 -0
  437. package/src/components/writing-flow/index.js +1 -1
  438. package/src/components/writing-flow/use-arrow-nav.js +20 -28
  439. package/src/content.scss +1 -0
  440. package/src/hooks/border.js +0 -1
  441. package/src/hooks/color-panel.js +0 -1
  442. package/src/hooks/color.js +0 -2
  443. package/src/hooks/font-family.js +3 -5
  444. package/src/hooks/font-size.js +13 -4
  445. package/src/hooks/index.js +1 -0
  446. package/src/hooks/metadata.js +1 -2
  447. package/src/hooks/position.js +375 -0
  448. package/src/hooks/position.scss +18 -0
  449. package/src/hooks/supports.js +302 -0
  450. package/src/hooks/test/__snapshots__/align.native.js.snap +73 -0
  451. package/src/hooks/test/align.native.js +133 -0
  452. package/src/hooks/test/use-typography-props.js +26 -0
  453. package/src/hooks/use-typography-props.js +15 -7
  454. package/src/store/reducer.js +20 -8
  455. package/src/store/selectors.js +7 -8
  456. package/src/store/test/reducer.js +45 -3
  457. package/src/store/test/selectors.js +12 -9
  458. package/src/style.scss +2 -1
  459. package/src/utils/pasting.js +3 -9
  460. package/tsconfig.tsbuildinfo +1 -1
  461. package/build/components/colors-gradients/use-common-single-multiple-selects.js +0 -21
  462. package/build/components/colors-gradients/use-common-single-multiple-selects.js.map +0 -1
  463. package/build/components/rich-text/file-paste-handler.js +0 -21
  464. package/build/components/rich-text/file-paste-handler.js.map +0 -1
  465. package/build-module/components/colors-gradients/use-common-single-multiple-selects.js +0 -11
  466. package/build-module/components/colors-gradients/use-common-single-multiple-selects.js.map +0 -1
  467. package/build-module/components/rich-text/file-paste-handler.js +0 -13
  468. package/build-module/components/rich-text/file-paste-handler.js.map +0 -1
  469. package/src/components/colors-gradients/use-common-single-multiple-selects.js +0 -11
  470. package/src/components/rich-text/file-paste-handler.js +0 -13
@@ -15,6 +15,8 @@ var _classnames = _interopRequireDefault(require("classnames"));
15
15
 
16
16
  var _domScrollIntoView = _interopRequireDefault(require("dom-scroll-into-view"));
17
17
 
18
+ var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
19
+
18
20
  var _i18n = require("@wordpress/i18n");
19
21
 
20
22
  var _keycodes = require("@wordpress/keycodes");
@@ -399,6 +401,8 @@ class URLInput extends _element.Component {
399
401
 
400
402
  renderControl() {
401
403
  const {
404
+ /** Start opting into the new margin-free styles that will become the default in a future version. */
405
+ __nextHasNoMarginBottom = false,
402
406
  label = null,
403
407
  className,
404
408
  isFullWidth,
@@ -447,7 +451,17 @@ class URLInput extends _element.Component {
447
451
  return renderControl(controlProps, inputProps, loading);
448
452
  }
449
453
 
450
- return (0, _element.createElement)(_components.BaseControl, controlProps, (0, _element.createElement)("input", inputProps), loading && (0, _element.createElement)(_components.Spinner, null));
454
+ if (!__nextHasNoMarginBottom) {
455
+ (0, _deprecated.default)('Bottom margin styles for wp.blockEditor.URLInput', {
456
+ since: '6.2',
457
+ version: '6.5',
458
+ hint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version'
459
+ });
460
+ }
461
+
462
+ return (0, _element.createElement)(_components.BaseControl, (0, _extends2.default)({
463
+ __nextHasNoMarginBottom: __nextHasNoMarginBottom
464
+ }, controlProps), (0, _element.createElement)("input", inputProps), loading && (0, _element.createElement)(_components.Spinner, null));
451
465
  }
452
466
 
453
467
  renderSuggestions() {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/url-input/index.js"],"names":["isFunction","maybeFunc","URLInput","Component","constructor","props","onChange","bind","onFocus","onKeyDown","selectLink","handleOnClick","bindSuggestionNode","autocompleteRef","inputRef","updateSuggestions","suggestionNodes","suggestionsRequest","state","suggestions","showSuggestions","isUpdatingSuggestions","suggestionsValue","selectedSuggestion","suggestionsListboxId","suggestionOptionIdPrefix","componentDidUpdate","prevProps","value","__experimentalShowInitialSuggestions","scrollingIntoView","current","onlyScrollIfNeeded","setTimeout","disableSuggestions","length","componentDidMount","shouldShowInitialSuggestions","componentWillUnmount","cancel","index","ref","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","__experimentalHandleURLSuggestions","handleURLSuggestions","isInitialSuggestions","trim","setState","loading","request","then","debouncedSpeak","catch","event","target","keyCode","UP","selectionStart","preventDefault","setSelectionRange","DOWN","ENTER","onSubmit","suggestion","previousIndex","nextIndex","TAB","speak","url","focus","getDerivedStateFromProps","instanceId","shouldShowSuggestions","hasValue","render","renderControl","renderSuggestions","label","className","isFullWidth","placeholder","__experimentalRenderControl","inputId","controlProps","id","inputProps","required","type","role","undefined","__experimentalRenderSuggestions","suggestionsListProps","buildSuggestionItemProps","tabIndex","isLoading","handleSuggestionClick","currentInputValue","map","title","withSafeTimeout","withSpokenMessages","withInstanceId","select","getSettings","blockEditorStore"],"mappings":";;;;;;;;;AAUA;;;;AAPA;;AACA;;AAKA;;AAEA;;AACA;;AAOA;;AAMA;;AACA;;AAKA;;AA/BA;AACA;AACA;;AAIA;AACA;AACA;;AAoBA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,UAAT,CAAqBC,SAArB,EAAiC;AAChC,SAAO,OAAOA,SAAP,KAAqB,UAA5B;AACA;;AAED,MAAMC,QAAN,SAAuBC,kBAAvB,CAAiC;AAChCC,EAAAA,WAAW,CAAEC,KAAF,EAAU;AACpB,UAAOA,KAAP;AAEA,SAAKC,QAAL,GAAgB,KAAKA,QAAL,CAAcC,IAAd,CAAoB,IAApB,CAAhB;AACA,SAAKC,OAAL,GAAe,KAAKA,OAAL,CAAaD,IAAb,CAAmB,IAAnB,CAAf;AACA,SAAKE,SAAL,GAAiB,KAAKA,SAAL,CAAeF,IAAf,CAAqB,IAArB,CAAjB;AACA,SAAKG,UAAL,GAAkB,KAAKA,UAAL,CAAgBH,IAAhB,CAAsB,IAAtB,CAAlB;AACA,SAAKI,aAAL,GAAqB,KAAKA,aAAL,CAAmBJ,IAAnB,CAAyB,IAAzB,CAArB;AACA,SAAKK,kBAAL,GAA0B,KAAKA,kBAAL,CAAwBL,IAAxB,C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xB,KAAd,KAClB,4BAAC,kBAAD,6BACMqD,wBAAwB,CAAE7B,UAAF,EAAcxB,KAAd,CAD9B;AAEC,MAAA,GAAG,EAAGwB,UAAU,CAACqB,EAFlB;AAGC,MAAA,SAAS,EAAG,yBACX,oCADW,EAEX;AACC,uBAAe7C,KAAK,KAAKjB;AAD1B,OAFW,CAHb;AASC,MAAA,OAAO,EAAG,MAAM,KAAKZ,aAAL,CAAoBqD,UAApB;AATjB,QAWGA,UAAU,CAACmC,KAXd,CADC,CAPH,CADD,CADD;AA2BA;;AAxgB+B;AA2gBjC;AACA;AACA;;;eACe,sBACdC,wBADc,EAEdC,8BAFc,EAGdC,uBAHc,EAId,sBAAY,CAAEC,MAAF,EAAUlG,KAAV,KAAqB;AAChC;AACA;AACA,MAAKL,UAAU,CAAEK,KAAK,CAACqC,kCAAR,CAAf,EAA8D;AAC7D;AACA;;AACD,QAAM;AAAE8D,IAAAA;AAAF,MAAkBD,MAAM,CAAEE,YAAF,CAA9B;AACA,SAAO;AACN/D,IAAAA,kCAAkC,EACjC8D,WAAW,GAAG9D;AAFT,GAAP;AAIA,CAXD,CAJc,EAgBZxC,QAhBY,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport scrollIntoView from 'dom-scroll-into-view';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf, _n } from '@wordpress/i18n';\nimport { Component, createRef } from '@wordpress/element';\nimport { UP, DOWN, ENTER, TAB } from '@wordpress/keycodes';\nimport {\n\tBaseControl,\n\tButton,\n\tSpinner,\n\twithSpokenMessages,\n\tPopover,\n} from '@wordpress/components';\nimport {\n\tcompose,\n\tdebounce,\n\twithInstanceId,\n\twithSafeTimeout,\n} from '@wordpress/compose';\nimport { withSelect } from '@wordpress/data';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Whether the argument is a function.\n *\n * @param {*} maybeFunc The argument to check.\n * @return {boolean} True if the argument is a function, false otherwise.\n */\nfunction isFunction( maybeFunc ) {\n\treturn typeof maybeFunc === 'function';\n}\n\nclass URLInput extends Component {\n\tconstructor( props ) {\n\t\tsuper( props );\n\n\t\tthis.onChange = this.onChange.bind( this );\n\t\tthis.onFocus = this.onFocus.bind( this );\n\t\tthis.onKeyDown = this.onKeyDown.bind( this );\n\t\tthis.selectLink = this.selectLink.bind( this );\n\t\tthis.handleOnClick = this.handleOnClick.bind( this );\n\t\tthis.bindSuggestionNode = this.bindSuggestionNode.bind( this );\n\t\tthis.autocompleteRef = props.autocompleteRef || createRef();\n\t\tthis.inputRef = createRef();\n\t\tthis.updateSuggestions = debounce(\n\t\t\tthis.updateSuggestions.bind( this ),\n\t\t\t200\n\t\t);\n\n\t\tthis.suggestionNodes = [];\n\n\t\tthis.suggestionsRequest = null;\n\n\t\tthis.state = {\n\t\t\tsuggestions: [],\n\t\t\tshowSuggestions: false,\n\t\t\tisUpdatingSuggestions: false,\n\t\t\tsuggestionsValue: null,\n\t\t\tselectedSuggestion: null,\n\t\t\tsuggestionsListboxId: '',\n\t\t\tsuggestionOptionIdPrefix: '',\n\t\t};\n\t}\n\n\tcomponentDidUpdate( prevProps ) {\n\t\tconst { showSuggestions, selectedSuggestion } = this.state;\n\t\tconst { value, __experimentalShowInitialSuggestions = false } =\n\t\t\tthis.props;\n\n\t\t// Only have to worry about scrolling selected suggestion into view\n\t\t// when already expanded.\n\t\tif (\n\t\t\tshowSuggestions &&\n\t\t\tselectedSuggestion !== null &&\n\t\t\tthis.suggestionNodes[ selectedSuggestion ] &&\n\t\t\t! this.scrollingIntoView\n\t\t) {\n\t\t\tthis.scrollingIntoView = true;\n\t\t\tscrollIntoView(\n\t\t\t\tthis.suggestionNodes[ selectedSuggestion ],\n\t\t\t\tthis.autocompleteRef.current,\n\t\t\t\t{\n\t\t\t\t\tonlyScrollIfNeeded: true,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tthis.props.setTimeout( () => {\n\t\t\t\tthis.scrollingIntoView = false;\n\t\t\t}, 100 );\n\t\t}\n\n\t\t// Update suggestions when the value changes.\n\t\tif (\n\t\t\tprevProps.value !== value &&\n\t\t\t! this.props.disableSuggestions &&\n\t\t\t! this.state.isUpdatingSuggestions\n\t\t) {\n\t\t\tif ( value?.length ) {\n\t\t\t\t// If the new value is not empty we need to update with suggestions for it.\n\t\t\t\tthis.updateSuggestions( value );\n\t\t\t} else if ( __experimentalShowInitialSuggestions ) {\n\t\t\t\t// If the new value is empty and we can show initial suggestions, then show initial suggestions.\n\t\t\t\tthis.updateSuggestions();\n\t\t\t}\n\t\t}\n\t}\n\n\tcomponentDidMount() {\n\t\tif ( this.shouldShowInitialSuggestions() ) {\n\t\t\tthis.updateSuggestions();\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\tthis.suggestionsRequest?.cancel?.();\n\t\tthis.suggestionsRequest = null;\n\t}\n\n\tbindSuggestionNode( index ) {\n\t\treturn ( ref ) => {\n\t\t\tthis.suggestionNodes[ index ] = ref;\n\t\t};\n\t}\n\n\tshouldShowInitialSuggestions() {\n\t\tconst { __experimentalShowInitialSuggestions = false, value } =\n\t\t\tthis.props;\n\t\treturn (\n\t\t\t__experimentalShowInitialSuggestions && ! ( value && value.length )\n\t\t);\n\t}\n\n\tupdateSuggestions( value = '' ) {\n\t\tconst {\n\t\t\t__experimentalFetchLinkSuggestions: fetchLinkSuggestions,\n\t\t\t__experimentalHandleURLSuggestions: handleURLSuggestions,\n\t\t} = this.props;\n\n\t\tif ( ! fetchLinkSuggestions ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Initial suggestions may only show if there is no value\n\t\t// (note: this includes whitespace).\n\t\tconst isInitialSuggestions = ! value?.length;\n\n\t\t// Trim only now we've determined whether or not it originally had a \"length\"\n\t\t// (even if that value was all whitespace).\n\t\tvalue = value.trim();\n\n\t\t// Allow a suggestions request if:\n\t\t// - there are at least 2 characters in the search input (except manual searches where\n\t\t// search input length is not required to trigger a fetch)\n\t\t// - this is a direct entry (eg: a URL)\n\t\tif (\n\t\t\t! isInitialSuggestions &&\n\t\t\t( value.length < 2 || ( ! handleURLSuggestions && isURL( value ) ) )\n\t\t) {\n\t\t\tthis.suggestionsRequest?.cancel?.();\n\t\t\tthis.suggestionsRequest = null;\n\n\t\t\tthis.setState( {\n\t\t\t\tsuggestions: [],\n\t\t\t\tshowSuggestions: false,\n\t\t\t\tsuggestionsValue: value,\n\t\t\t\tselectedSuggestion: null,\n\t\t\t\tloading: false,\n\t\t\t} );\n\n\t\t\treturn;\n\t\t}\n\n\t\tthis.setState( {\n\t\t\tisUpdatingSuggestions: true,\n\t\t\tselectedSuggestion: null,\n\t\t\tloading: true,\n\t\t} );\n\n\t\tconst request = fetchLinkSuggestions( value, {\n\t\t\tisInitialSuggestions,\n\t\t} );\n\n\t\trequest\n\t\t\t.then( ( suggestions ) => {\n\t\t\t\t// A fetch Promise doesn't have an abort option. It's mimicked by\n\t\t\t\t// comparing the request reference in on the instance, which is\n\t\t\t\t// reset or deleted on subsequent requests or unmounting.\n\t\t\t\tif ( this.suggestionsRequest !== request ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.setState( {\n\t\t\t\t\tsuggestions,\n\t\t\t\t\tisUpdatingSuggestions: false,\n\t\t\t\t\tsuggestionsValue: value,\n\t\t\t\t\tloading: false,\n\t\t\t\t\tshowSuggestions: !! suggestions.length,\n\t\t\t\t} );\n\n\t\t\t\tif ( !! suggestions.length ) {\n\t\t\t\t\tthis.props.debouncedSpeak(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %s: number of results. */\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'%d result found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\t'%d results found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\tsuggestions.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tsuggestions.length\n\t\t\t\t\t\t),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthis.props.debouncedSpeak(\n\t\t\t\t\t\t__( 'No results.' ),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.catch( () => {\n\t\t\t\tif ( this.suggestionsRequest !== request ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.setState( {\n\t\t\t\t\tisUpdatingSuggestions: false,\n\t\t\t\t\tloading: false,\n\t\t\t\t} );\n\t\t\t} );\n\n\t\t// Note that this assignment is handled *before* the async search request\n\t\t// as a Promise always resolves on the next tick of the event loop.\n\t\tthis.suggestionsRequest = request;\n\t}\n\n\tonChange( event ) {\n\t\tthis.props.onChange( event.target.value );\n\t}\n\n\tonFocus() {\n\t\tconst { suggestions } = this.state;\n\t\tconst { disableSuggestions, value } = this.props;\n\n\t\t// When opening the link editor, if there's a value present, we want to load the suggestions pane with the results for this input search value\n\t\t// Don't re-run the suggestions on focus if there are already suggestions present (prevents searching again when tabbing between the input and buttons)\n\t\tif (\n\t\t\tvalue &&\n\t\t\t! disableSuggestions &&\n\t\t\t! this.state.isUpdatingSuggestions &&\n\t\t\t! ( suggestions && suggestions.length )\n\t\t) {\n\t\t\t// Ensure the suggestions are updated with the current input value.\n\t\t\tthis.updateSuggestions( value );\n\t\t}\n\t}\n\n\tonKeyDown( event ) {\n\t\tconst { showSuggestions, selectedSuggestion, suggestions, loading } =\n\t\t\tthis.state;\n\n\t\t// If the suggestions are not shown or loading, we shouldn't handle the arrow keys\n\t\t// We shouldn't preventDefault to allow block arrow keys navigation.\n\t\tif ( ! showSuggestions || ! suggestions.length || loading ) {\n\t\t\t// In the Windows version of Firefox the up and down arrows don't move the caret\n\t\t\t// within an input field like they do for Mac Firefox/Chrome/Safari. This causes\n\t\t\t// a form of focus trapping that is disruptive to the user experience. This disruption\n\t\t\t// only happens if the caret is not in the first or last position in the text input.\n\t\t\t// See: https://github.com/WordPress/gutenberg/issues/5693#issuecomment-436684747\n\t\t\tswitch ( event.keyCode ) {\n\t\t\t\t// When UP is pressed, if the caret is at the start of the text, move it to the 0\n\t\t\t\t// position.\n\t\t\t\tcase UP: {\n\t\t\t\t\tif ( 0 !== event.target.selectionStart ) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\t// Set the input caret to position 0.\n\t\t\t\t\t\tevent.target.setSelectionRange( 0, 0 );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t// When DOWN is pressed, if the caret is not at the end of the text, move it to the\n\t\t\t\t// last position.\n\t\t\t\tcase DOWN: {\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.props.value.length !== event.target.selectionStart\n\t\t\t\t\t) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\t// Set the input caret to the last position.\n\t\t\t\t\t\tevent.target.setSelectionRange(\n\t\t\t\t\t\t\tthis.props.value.length,\n\t\t\t\t\t\t\tthis.props.value.length\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t// Submitting while loading should trigger onSubmit.\n\t\t\t\tcase ENTER: {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tif ( this.props.onSubmit ) {\n\t\t\t\t\t\tthis.props.onSubmit( null, event );\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst suggestion =\n\t\t\tthis.state.suggestions[ this.state.selectedSuggestion ];\n\n\t\tswitch ( event.keyCode ) {\n\t\t\tcase UP: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst previousIndex = ! selectedSuggestion\n\t\t\t\t\t? suggestions.length - 1\n\t\t\t\t\t: selectedSuggestion - 1;\n\t\t\t\tthis.setState( {\n\t\t\t\t\tselectedSuggestion: previousIndex,\n\t\t\t\t} );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase DOWN: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst nextIndex =\n\t\t\t\t\tselectedSuggestion === null ||\n\t\t\t\t\tselectedSuggestion === suggestions.length - 1\n\t\t\t\t\t\t? 0\n\t\t\t\t\t\t: selectedSuggestion + 1;\n\t\t\t\tthis.setState( {\n\t\t\t\t\tselectedSuggestion: nextIndex,\n\t\t\t\t} );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase TAB: {\n\t\t\t\tif ( this.state.selectedSuggestion !== null ) {\n\t\t\t\t\tthis.selectLink( suggestion );\n\t\t\t\t\t// Announce a link has been selected when tabbing away from the input field.\n\t\t\t\t\tthis.props.speak( __( 'Link selected.' ) );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ENTER: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( this.state.selectedSuggestion !== null ) {\n\t\t\t\t\tthis.selectLink( suggestion );\n\n\t\t\t\t\tif ( this.props.onSubmit ) {\n\t\t\t\t\t\tthis.props.onSubmit( suggestion, event );\n\t\t\t\t\t}\n\t\t\t\t} else if ( this.props.onSubmit ) {\n\t\t\t\t\tthis.props.onSubmit( null, event );\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tselectLink( suggestion ) {\n\t\tthis.props.onChange( suggestion.url, suggestion );\n\t\tthis.setState( {\n\t\t\tselectedSuggestion: null,\n\t\t\tshowSuggestions: false,\n\t\t} );\n\t}\n\n\thandleOnClick( suggestion ) {\n\t\tthis.selectLink( suggestion );\n\t\t// Move focus to the input field when a link suggestion is clicked.\n\t\tthis.inputRef.current.focus();\n\t}\n\n\tstatic getDerivedStateFromProps(\n\t\t{\n\t\t\tvalue,\n\t\t\tinstanceId,\n\t\t\tdisableSuggestions,\n\t\t\t__experimentalShowInitialSuggestions = false,\n\t\t},\n\t\t{ showSuggestions }\n\t) {\n\t\tlet shouldShowSuggestions = showSuggestions;\n\n\t\tconst hasValue = value && value.length;\n\n\t\tif ( ! __experimentalShowInitialSuggestions && ! hasValue ) {\n\t\t\tshouldShowSuggestions = false;\n\t\t}\n\n\t\tif ( disableSuggestions === true ) {\n\t\t\tshouldShowSuggestions = false;\n\t\t}\n\n\t\treturn {\n\t\t\tshowSuggestions: shouldShowSuggestions,\n\t\t\tsuggestionsListboxId: `block-editor-url-input-suggestions-${ instanceId }`,\n\t\t\tsuggestionOptionIdPrefix: `block-editor-url-input-suggestion-${ instanceId }`,\n\t\t};\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ this.renderControl() }\n\t\t\t\t{ this.renderSuggestions() }\n\t\t\t</>\n\t\t);\n\t}\n\n\trenderControl() {\n\t\tconst {\n\t\t\tlabel = null,\n\t\t\tclassName,\n\t\t\tisFullWidth,\n\t\t\tinstanceId,\n\t\t\tplaceholder = __( 'Paste URL or type to search' ),\n\t\t\t__experimentalRenderControl: renderControl,\n\t\t\tvalue = '',\n\t\t} = this.props;\n\n\t\tconst {\n\t\t\tloading,\n\t\t\tshowSuggestions,\n\t\t\tselectedSuggestion,\n\t\t\tsuggestionsListboxId,\n\t\t\tsuggestionOptionIdPrefix,\n\t\t} = this.state;\n\n\t\tconst inputId = `url-input-control-${ instanceId }`;\n\n\t\tconst controlProps = {\n\t\t\tid: inputId, // Passes attribute to label for the for attribute\n\t\t\tlabel,\n\t\t\tclassName: classnames( 'block-editor-url-input', className, {\n\t\t\t\t'is-full-width': isFullWidth,\n\t\t\t} ),\n\t\t};\n\n\t\tconst inputProps = {\n\t\t\tid: inputId,\n\t\t\tvalue,\n\t\t\trequired: true,\n\t\t\tclassName: 'block-editor-url-input__input',\n\t\t\ttype: 'text',\n\t\t\tonChange: this.onChange,\n\t\t\tonFocus: this.onFocus,\n\t\t\tplaceholder,\n\t\t\tonKeyDown: this.onKeyDown,\n\t\t\trole: 'combobox',\n\t\t\t'aria-label': label ? undefined : __( 'URL' ), // Ensure input always has an accessible label\n\t\t\t'aria-expanded': showSuggestions,\n\t\t\t'aria-autocomplete': 'list',\n\t\t\t'aria-controls': suggestionsListboxId,\n\t\t\t'aria-activedescendant':\n\t\t\t\tselectedSuggestion !== null\n\t\t\t\t\t? `${ suggestionOptionIdPrefix }-${ selectedSuggestion }`\n\t\t\t\t\t: undefined,\n\t\t\tref: this.inputRef,\n\t\t};\n\n\t\tif ( renderControl ) {\n\t\t\treturn renderControl( controlProps, inputProps, loading );\n\t\t}\n\n\t\treturn (\n\t\t\t<BaseControl { ...controlProps }>\n\t\t\t\t<input { ...inputProps } />\n\t\t\t\t{ loading && <Spinner /> }\n\t\t\t</BaseControl>\n\t\t);\n\t}\n\n\trenderSuggestions() {\n\t\tconst {\n\t\t\tclassName,\n\t\t\t__experimentalRenderSuggestions: renderSuggestions,\n\t\t} = this.props;\n\n\t\tconst {\n\t\t\tshowSuggestions,\n\t\t\tsuggestions,\n\t\t\tsuggestionsValue,\n\t\t\tselectedSuggestion,\n\t\t\tsuggestionsListboxId,\n\t\t\tsuggestionOptionIdPrefix,\n\t\t\tloading,\n\t\t} = this.state;\n\n\t\tif ( ! showSuggestions || suggestions.length === 0 ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst suggestionsListProps = {\n\t\t\tid: suggestionsListboxId,\n\t\t\tref: this.autocompleteRef,\n\t\t\trole: 'listbox',\n\t\t};\n\n\t\tconst buildSuggestionItemProps = ( suggestion, index ) => {\n\t\t\treturn {\n\t\t\t\trole: 'option',\n\t\t\t\ttabIndex: '-1',\n\t\t\t\tid: `${ suggestionOptionIdPrefix }-${ index }`,\n\t\t\t\tref: this.bindSuggestionNode( index ),\n\t\t\t\t'aria-selected': index === selectedSuggestion,\n\t\t\t};\n\t\t};\n\n\t\tif ( isFunction( renderSuggestions ) ) {\n\t\t\treturn renderSuggestions( {\n\t\t\t\tsuggestions,\n\t\t\t\tselectedSuggestion,\n\t\t\t\tsuggestionsListProps,\n\t\t\t\tbuildSuggestionItemProps,\n\t\t\t\tisLoading: loading,\n\t\t\t\thandleSuggestionClick: this.handleOnClick,\n\t\t\t\tisInitialSuggestions: ! suggestionsValue?.length,\n\t\t\t\tcurrentInputValue: suggestionsValue,\n\t\t\t} );\n\t\t}\n\n\t\treturn (\n\t\t\t<Popover placement=\"bottom\" focusOnMount={ false }>\n\t\t\t\t<div\n\t\t\t\t\t{ ...suggestionsListProps }\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'block-editor-url-input__suggestions',\n\t\t\t\t\t\t`${ className }__suggestions`\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t{ suggestions.map( ( suggestion, index ) => (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t{ ...buildSuggestionItemProps( suggestion, index ) }\n\t\t\t\t\t\t\tkey={ suggestion.id }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-url-input__suggestion',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-selected': index === selectedSuggestion,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tonClick={ () => this.handleOnClick( suggestion ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ suggestion.title }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) ) }\n\t\t\t\t</div>\n\t\t\t</Popover>\n\t\t);\n\t}\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-input/README.md\n */\nexport default compose(\n\twithSafeTimeout,\n\twithSpokenMessages,\n\twithInstanceId,\n\twithSelect( ( select, props ) => {\n\t\t// If a link suggestions handler is already provided then\n\t\t// bail.\n\t\tif ( isFunction( props.__experimentalFetchLinkSuggestions ) ) {\n\t\t\treturn;\n\t\t}\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\t__experimentalFetchLinkSuggestions:\n\t\t\t\tgetSettings().__experimentalFetchLinkSuggestions,\n\t\t};\n\t} )\n)( URLInput );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/url-input/index.js"],"names":["isFunction","maybeFunc","URLInput","Component","constructor","props","onChange","bind","onFocus","onKeyDown","selectLink","handleOnClick","bindSuggestionNode","autocompleteRef","inputRef","updateSuggestions","suggestionNodes","suggestionsRequest","state","suggestions","showSuggestions","isUpdatingSuggestions","suggestionsValue","selectedSuggestion","suggestionsListboxId","suggestionOptionIdPrefix","componentDidUpdate","prevProps","value","__experimentalShowInitialSuggestions","scrollingIntoView","current","onlyScrollIfNeeded","setTimeout","disableSuggestions","length","componentDidMount","shouldShowInitialSuggestions","componentWillUnmount","cancel","index","ref","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","__experimentalHandleURLSuggestions","handleURLSuggestions","isInitialSuggestions","trim","setState","loading","request","then","debouncedSpeak","catch","event","target","keyCode","UP","selectionStart","preventDefault","setSelectionRange","DOWN","ENTER","onSubmit","suggestion","previousIndex","nextIndex","TAB","speak","url","focus","getDerivedStateFromProps","instanceId","shouldShowSuggestions","hasValue","render","renderControl","renderSuggestions","__nextHasNoMarginBottom","label","className","isFullWidth","placeholder","__experimentalRenderControl","inputId","controlProps","id","inputProps","required","type","role","undefined","since","version","hint","__experimentalRenderSuggestions","suggestionsListProps","buildSuggestionItemProps","tabIndex","isLoading","handleSuggestionClick","currentInputValue","map","title","withSafeTimeout","withSpokenMessages","withInstanceId","select","getSettings","blockEditorStore"],"mappings":";;;;;;;;;AAWA;;;;AARA;;AACA;;AAKA;;AACA;;AAEA;;AACA;;AAOA;;AAMA;;AACA;;AAKA;;AAhCA;AACA;AACA;;AAIA;AACA;AACA;;AAqBA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,UAAT,CAAqBC,SAArB,EAAiC;AAChC,SAAO,OAAOA,SAAP,KAAqB,UAA5B;AACA;;AAED,MAAMC,QAAN,SAAuBC,kBAAvB,CAAiC;AAChCC,EAAAA,WAAW,CAAEC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AR,CAAf,EAA8D;AAC7D;AACA;;AACD,QAAM;AAAEkE,IAAAA;AAAF,MAAkBD,MAAM,CAAEE,YAAF,CAA9B;AACA,SAAO;AACNnE,IAAAA,kCAAkC,EACjCkE,WAAW,GAAGlE;AAFT,GAAP;AAIA,CAXD,CAJc,EAgBZxC,QAhBY,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport scrollIntoView from 'dom-scroll-into-view';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { __, sprintf, _n } from '@wordpress/i18n';\nimport { Component, createRef } from '@wordpress/element';\nimport { UP, DOWN, ENTER, TAB } from '@wordpress/keycodes';\nimport {\n\tBaseControl,\n\tButton,\n\tSpinner,\n\twithSpokenMessages,\n\tPopover,\n} from '@wordpress/components';\nimport {\n\tcompose,\n\tdebounce,\n\twithInstanceId,\n\twithSafeTimeout,\n} from '@wordpress/compose';\nimport { withSelect } from '@wordpress/data';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Whether the argument is a function.\n *\n * @param {*} maybeFunc The argument to check.\n * @return {boolean} True if the argument is a function, false otherwise.\n */\nfunction isFunction( maybeFunc ) {\n\treturn typeof maybeFunc === 'function';\n}\n\nclass URLInput extends Component {\n\tconstructor( props ) {\n\t\tsuper( props );\n\n\t\tthis.onChange = this.onChange.bind( this );\n\t\tthis.onFocus = this.onFocus.bind( this );\n\t\tthis.onKeyDown = this.onKeyDown.bind( this );\n\t\tthis.selectLink = this.selectLink.bind( this );\n\t\tthis.handleOnClick = this.handleOnClick.bind( this );\n\t\tthis.bindSuggestionNode = this.bindSuggestionNode.bind( this );\n\t\tthis.autocompleteRef = props.autocompleteRef || createRef();\n\t\tthis.inputRef = createRef();\n\t\tthis.updateSuggestions = debounce(\n\t\t\tthis.updateSuggestions.bind( this ),\n\t\t\t200\n\t\t);\n\n\t\tthis.suggestionNodes = [];\n\n\t\tthis.suggestionsRequest = null;\n\n\t\tthis.state = {\n\t\t\tsuggestions: [],\n\t\t\tshowSuggestions: false,\n\t\t\tisUpdatingSuggestions: false,\n\t\t\tsuggestionsValue: null,\n\t\t\tselectedSuggestion: null,\n\t\t\tsuggestionsListboxId: '',\n\t\t\tsuggestionOptionIdPrefix: '',\n\t\t};\n\t}\n\n\tcomponentDidUpdate( prevProps ) {\n\t\tconst { showSuggestions, selectedSuggestion } = this.state;\n\t\tconst { value, __experimentalShowInitialSuggestions = false } =\n\t\t\tthis.props;\n\n\t\t// Only have to worry about scrolling selected suggestion into view\n\t\t// when already expanded.\n\t\tif (\n\t\t\tshowSuggestions &&\n\t\t\tselectedSuggestion !== null &&\n\t\t\tthis.suggestionNodes[ selectedSuggestion ] &&\n\t\t\t! this.scrollingIntoView\n\t\t) {\n\t\t\tthis.scrollingIntoView = true;\n\t\t\tscrollIntoView(\n\t\t\t\tthis.suggestionNodes[ selectedSuggestion ],\n\t\t\t\tthis.autocompleteRef.current,\n\t\t\t\t{\n\t\t\t\t\tonlyScrollIfNeeded: true,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tthis.props.setTimeout( () => {\n\t\t\t\tthis.scrollingIntoView = false;\n\t\t\t}, 100 );\n\t\t}\n\n\t\t// Update suggestions when the value changes.\n\t\tif (\n\t\t\tprevProps.value !== value &&\n\t\t\t! this.props.disableSuggestions &&\n\t\t\t! this.state.isUpdatingSuggestions\n\t\t) {\n\t\t\tif ( value?.length ) {\n\t\t\t\t// If the new value is not empty we need to update with suggestions for it.\n\t\t\t\tthis.updateSuggestions( value );\n\t\t\t} else if ( __experimentalShowInitialSuggestions ) {\n\t\t\t\t// If the new value is empty and we can show initial suggestions, then show initial suggestions.\n\t\t\t\tthis.updateSuggestions();\n\t\t\t}\n\t\t}\n\t}\n\n\tcomponentDidMount() {\n\t\tif ( this.shouldShowInitialSuggestions() ) {\n\t\t\tthis.updateSuggestions();\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\tthis.suggestionsRequest?.cancel?.();\n\t\tthis.suggestionsRequest = null;\n\t}\n\n\tbindSuggestionNode( index ) {\n\t\treturn ( ref ) => {\n\t\t\tthis.suggestionNodes[ index ] = ref;\n\t\t};\n\t}\n\n\tshouldShowInitialSuggestions() {\n\t\tconst { __experimentalShowInitialSuggestions = false, value } =\n\t\t\tthis.props;\n\t\treturn (\n\t\t\t__experimentalShowInitialSuggestions && ! ( value && value.length )\n\t\t);\n\t}\n\n\tupdateSuggestions( value = '' ) {\n\t\tconst {\n\t\t\t__experimentalFetchLinkSuggestions: fetchLinkSuggestions,\n\t\t\t__experimentalHandleURLSuggestions: handleURLSuggestions,\n\t\t} = this.props;\n\n\t\tif ( ! fetchLinkSuggestions ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Initial suggestions may only show if there is no value\n\t\t// (note: this includes whitespace).\n\t\tconst isInitialSuggestions = ! value?.length;\n\n\t\t// Trim only now we've determined whether or not it originally had a \"length\"\n\t\t// (even if that value was all whitespace).\n\t\tvalue = value.trim();\n\n\t\t// Allow a suggestions request if:\n\t\t// - there are at least 2 characters in the search input (except manual searches where\n\t\t// search input length is not required to trigger a fetch)\n\t\t// - this is a direct entry (eg: a URL)\n\t\tif (\n\t\t\t! isInitialSuggestions &&\n\t\t\t( value.length < 2 || ( ! handleURLSuggestions && isURL( value ) ) )\n\t\t) {\n\t\t\tthis.suggestionsRequest?.cancel?.();\n\t\t\tthis.suggestionsRequest = null;\n\n\t\t\tthis.setState( {\n\t\t\t\tsuggestions: [],\n\t\t\t\tshowSuggestions: false,\n\t\t\t\tsuggestionsValue: value,\n\t\t\t\tselectedSuggestion: null,\n\t\t\t\tloading: false,\n\t\t\t} );\n\n\t\t\treturn;\n\t\t}\n\n\t\tthis.setState( {\n\t\t\tisUpdatingSuggestions: true,\n\t\t\tselectedSuggestion: null,\n\t\t\tloading: true,\n\t\t} );\n\n\t\tconst request = fetchLinkSuggestions( value, {\n\t\t\tisInitialSuggestions,\n\t\t} );\n\n\t\trequest\n\t\t\t.then( ( suggestions ) => {\n\t\t\t\t// A fetch Promise doesn't have an abort option. It's mimicked by\n\t\t\t\t// comparing the request reference in on the instance, which is\n\t\t\t\t// reset or deleted on subsequent requests or unmounting.\n\t\t\t\tif ( this.suggestionsRequest !== request ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.setState( {\n\t\t\t\t\tsuggestions,\n\t\t\t\t\tisUpdatingSuggestions: false,\n\t\t\t\t\tsuggestionsValue: value,\n\t\t\t\t\tloading: false,\n\t\t\t\t\tshowSuggestions: !! suggestions.length,\n\t\t\t\t} );\n\n\t\t\t\tif ( !! suggestions.length ) {\n\t\t\t\t\tthis.props.debouncedSpeak(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %s: number of results. */\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'%d result found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\t'%d results found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\tsuggestions.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tsuggestions.length\n\t\t\t\t\t\t),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthis.props.debouncedSpeak(\n\t\t\t\t\t\t__( 'No results.' ),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.catch( () => {\n\t\t\t\tif ( this.suggestionsRequest !== request ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.setState( {\n\t\t\t\t\tisUpdatingSuggestions: false,\n\t\t\t\t\tloading: false,\n\t\t\t\t} );\n\t\t\t} );\n\n\t\t// Note that this assignment is handled *before* the async search request\n\t\t// as a Promise always resolves on the next tick of the event loop.\n\t\tthis.suggestionsRequest = request;\n\t}\n\n\tonChange( event ) {\n\t\tthis.props.onChange( event.target.value );\n\t}\n\n\tonFocus() {\n\t\tconst { suggestions } = this.state;\n\t\tconst { disableSuggestions, value } = this.props;\n\n\t\t// When opening the link editor, if there's a value present, we want to load the suggestions pane with the results for this input search value\n\t\t// Don't re-run the suggestions on focus if there are already suggestions present (prevents searching again when tabbing between the input and buttons)\n\t\tif (\n\t\t\tvalue &&\n\t\t\t! disableSuggestions &&\n\t\t\t! this.state.isUpdatingSuggestions &&\n\t\t\t! ( suggestions && suggestions.length )\n\t\t) {\n\t\t\t// Ensure the suggestions are updated with the current input value.\n\t\t\tthis.updateSuggestions( value );\n\t\t}\n\t}\n\n\tonKeyDown( event ) {\n\t\tconst { showSuggestions, selectedSuggestion, suggestions, loading } =\n\t\t\tthis.state;\n\n\t\t// If the suggestions are not shown or loading, we shouldn't handle the arrow keys\n\t\t// We shouldn't preventDefault to allow block arrow keys navigation.\n\t\tif ( ! showSuggestions || ! suggestions.length || loading ) {\n\t\t\t// In the Windows version of Firefox the up and down arrows don't move the caret\n\t\t\t// within an input field like they do for Mac Firefox/Chrome/Safari. This causes\n\t\t\t// a form of focus trapping that is disruptive to the user experience. This disruption\n\t\t\t// only happens if the caret is not in the first or last position in the text input.\n\t\t\t// See: https://github.com/WordPress/gutenberg/issues/5693#issuecomment-436684747\n\t\t\tswitch ( event.keyCode ) {\n\t\t\t\t// When UP is pressed, if the caret is at the start of the text, move it to the 0\n\t\t\t\t// position.\n\t\t\t\tcase UP: {\n\t\t\t\t\tif ( 0 !== event.target.selectionStart ) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\t// Set the input caret to position 0.\n\t\t\t\t\t\tevent.target.setSelectionRange( 0, 0 );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t// When DOWN is pressed, if the caret is not at the end of the text, move it to the\n\t\t\t\t// last position.\n\t\t\t\tcase DOWN: {\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.props.value.length !== event.target.selectionStart\n\t\t\t\t\t) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\t// Set the input caret to the last position.\n\t\t\t\t\t\tevent.target.setSelectionRange(\n\t\t\t\t\t\t\tthis.props.value.length,\n\t\t\t\t\t\t\tthis.props.value.length\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t// Submitting while loading should trigger onSubmit.\n\t\t\t\tcase ENTER: {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tif ( this.props.onSubmit ) {\n\t\t\t\t\t\tthis.props.onSubmit( null, event );\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst suggestion =\n\t\t\tthis.state.suggestions[ this.state.selectedSuggestion ];\n\n\t\tswitch ( event.keyCode ) {\n\t\t\tcase UP: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst previousIndex = ! selectedSuggestion\n\t\t\t\t\t? suggestions.length - 1\n\t\t\t\t\t: selectedSuggestion - 1;\n\t\t\t\tthis.setState( {\n\t\t\t\t\tselectedSuggestion: previousIndex,\n\t\t\t\t} );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase DOWN: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst nextIndex =\n\t\t\t\t\tselectedSuggestion === null ||\n\t\t\t\t\tselectedSuggestion === suggestions.length - 1\n\t\t\t\t\t\t? 0\n\t\t\t\t\t\t: selectedSuggestion + 1;\n\t\t\t\tthis.setState( {\n\t\t\t\t\tselectedSuggestion: nextIndex,\n\t\t\t\t} );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase TAB: {\n\t\t\t\tif ( this.state.selectedSuggestion !== null ) {\n\t\t\t\t\tthis.selectLink( suggestion );\n\t\t\t\t\t// Announce a link has been selected when tabbing away from the input field.\n\t\t\t\t\tthis.props.speak( __( 'Link selected.' ) );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ENTER: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( this.state.selectedSuggestion !== null ) {\n\t\t\t\t\tthis.selectLink( suggestion );\n\n\t\t\t\t\tif ( this.props.onSubmit ) {\n\t\t\t\t\t\tthis.props.onSubmit( suggestion, event );\n\t\t\t\t\t}\n\t\t\t\t} else if ( this.props.onSubmit ) {\n\t\t\t\t\tthis.props.onSubmit( null, event );\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tselectLink( suggestion ) {\n\t\tthis.props.onChange( suggestion.url, suggestion );\n\t\tthis.setState( {\n\t\t\tselectedSuggestion: null,\n\t\t\tshowSuggestions: false,\n\t\t} );\n\t}\n\n\thandleOnClick( suggestion ) {\n\t\tthis.selectLink( suggestion );\n\t\t// Move focus to the input field when a link suggestion is clicked.\n\t\tthis.inputRef.current.focus();\n\t}\n\n\tstatic getDerivedStateFromProps(\n\t\t{\n\t\t\tvalue,\n\t\t\tinstanceId,\n\t\t\tdisableSuggestions,\n\t\t\t__experimentalShowInitialSuggestions = false,\n\t\t},\n\t\t{ showSuggestions }\n\t) {\n\t\tlet shouldShowSuggestions = showSuggestions;\n\n\t\tconst hasValue = value && value.length;\n\n\t\tif ( ! __experimentalShowInitialSuggestions && ! hasValue ) {\n\t\t\tshouldShowSuggestions = false;\n\t\t}\n\n\t\tif ( disableSuggestions === true ) {\n\t\t\tshouldShowSuggestions = false;\n\t\t}\n\n\t\treturn {\n\t\t\tshowSuggestions: shouldShowSuggestions,\n\t\t\tsuggestionsListboxId: `block-editor-url-input-suggestions-${ instanceId }`,\n\t\t\tsuggestionOptionIdPrefix: `block-editor-url-input-suggestion-${ instanceId }`,\n\t\t};\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ this.renderControl() }\n\t\t\t\t{ this.renderSuggestions() }\n\t\t\t</>\n\t\t);\n\t}\n\n\trenderControl() {\n\t\tconst {\n\t\t\t/** Start opting into the new margin-free styles that will become the default in a future version. */\n\t\t\t__nextHasNoMarginBottom = false,\n\t\t\tlabel = null,\n\t\t\tclassName,\n\t\t\tisFullWidth,\n\t\t\tinstanceId,\n\t\t\tplaceholder = __( 'Paste URL or type to search' ),\n\t\t\t__experimentalRenderControl: renderControl,\n\t\t\tvalue = '',\n\t\t} = this.props;\n\n\t\tconst {\n\t\t\tloading,\n\t\t\tshowSuggestions,\n\t\t\tselectedSuggestion,\n\t\t\tsuggestionsListboxId,\n\t\t\tsuggestionOptionIdPrefix,\n\t\t} = this.state;\n\n\t\tconst inputId = `url-input-control-${ instanceId }`;\n\n\t\tconst controlProps = {\n\t\t\tid: inputId, // Passes attribute to label for the for attribute\n\t\t\tlabel,\n\t\t\tclassName: classnames( 'block-editor-url-input', className, {\n\t\t\t\t'is-full-width': isFullWidth,\n\t\t\t} ),\n\t\t};\n\n\t\tconst inputProps = {\n\t\t\tid: inputId,\n\t\t\tvalue,\n\t\t\trequired: true,\n\t\t\tclassName: 'block-editor-url-input__input',\n\t\t\ttype: 'text',\n\t\t\tonChange: this.onChange,\n\t\t\tonFocus: this.onFocus,\n\t\t\tplaceholder,\n\t\t\tonKeyDown: this.onKeyDown,\n\t\t\trole: 'combobox',\n\t\t\t'aria-label': label ? undefined : __( 'URL' ), // Ensure input always has an accessible label\n\t\t\t'aria-expanded': showSuggestions,\n\t\t\t'aria-autocomplete': 'list',\n\t\t\t'aria-controls': suggestionsListboxId,\n\t\t\t'aria-activedescendant':\n\t\t\t\tselectedSuggestion !== null\n\t\t\t\t\t? `${ suggestionOptionIdPrefix }-${ selectedSuggestion }`\n\t\t\t\t\t: undefined,\n\t\t\tref: this.inputRef,\n\t\t};\n\n\t\tif ( renderControl ) {\n\t\t\treturn renderControl( controlProps, inputProps, loading );\n\t\t}\n\n\t\tif ( ! __nextHasNoMarginBottom ) {\n\t\t\tdeprecated( 'Bottom margin styles for wp.blockEditor.URLInput', {\n\t\t\t\tsince: '6.2',\n\t\t\t\tversion: '6.5',\n\t\t\t\thint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version',\n\t\t\t} );\n\t\t}\n\n\t\treturn (\n\t\t\t<BaseControl\n\t\t\t\t__nextHasNoMarginBottom={ __nextHasNoMarginBottom }\n\t\t\t\t{ ...controlProps }\n\t\t\t>\n\t\t\t\t<input { ...inputProps } />\n\t\t\t\t{ loading && <Spinner /> }\n\t\t\t</BaseControl>\n\t\t);\n\t}\n\n\trenderSuggestions() {\n\t\tconst {\n\t\t\tclassName,\n\t\t\t__experimentalRenderSuggestions: renderSuggestions,\n\t\t} = this.props;\n\n\t\tconst {\n\t\t\tshowSuggestions,\n\t\t\tsuggestions,\n\t\t\tsuggestionsValue,\n\t\t\tselectedSuggestion,\n\t\t\tsuggestionsListboxId,\n\t\t\tsuggestionOptionIdPrefix,\n\t\t\tloading,\n\t\t} = this.state;\n\n\t\tif ( ! showSuggestions || suggestions.length === 0 ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst suggestionsListProps = {\n\t\t\tid: suggestionsListboxId,\n\t\t\tref: this.autocompleteRef,\n\t\t\trole: 'listbox',\n\t\t};\n\n\t\tconst buildSuggestionItemProps = ( suggestion, index ) => {\n\t\t\treturn {\n\t\t\t\trole: 'option',\n\t\t\t\ttabIndex: '-1',\n\t\t\t\tid: `${ suggestionOptionIdPrefix }-${ index }`,\n\t\t\t\tref: this.bindSuggestionNode( index ),\n\t\t\t\t'aria-selected': index === selectedSuggestion,\n\t\t\t};\n\t\t};\n\n\t\tif ( isFunction( renderSuggestions ) ) {\n\t\t\treturn renderSuggestions( {\n\t\t\t\tsuggestions,\n\t\t\t\tselectedSuggestion,\n\t\t\t\tsuggestionsListProps,\n\t\t\t\tbuildSuggestionItemProps,\n\t\t\t\tisLoading: loading,\n\t\t\t\thandleSuggestionClick: this.handleOnClick,\n\t\t\t\tisInitialSuggestions: ! suggestionsValue?.length,\n\t\t\t\tcurrentInputValue: suggestionsValue,\n\t\t\t} );\n\t\t}\n\n\t\treturn (\n\t\t\t<Popover placement=\"bottom\" focusOnMount={ false }>\n\t\t\t\t<div\n\t\t\t\t\t{ ...suggestionsListProps }\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'block-editor-url-input__suggestions',\n\t\t\t\t\t\t`${ className }__suggestions`\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t{ suggestions.map( ( suggestion, index ) => (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t{ ...buildSuggestionItemProps( suggestion, index ) }\n\t\t\t\t\t\t\tkey={ suggestion.id }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-url-input__suggestion',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-selected': index === selectedSuggestion,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tonClick={ () => this.handleOnClick( suggestion ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ suggestion.title }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) ) }\n\t\t\t\t</div>\n\t\t\t</Popover>\n\t\t);\n\t}\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-input/README.md\n */\nexport default compose(\n\twithSafeTimeout,\n\twithSpokenMessages,\n\twithInstanceId,\n\twithSelect( ( select, props ) => {\n\t\t// If a link suggestions handler is already provided then\n\t\t// bail.\n\t\tif ( isFunction( props.__experimentalFetchLinkSuggestions ) ) {\n\t\t\treturn;\n\t\t}\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\t__experimentalFetchLinkSuggestions:\n\t\t\t\tgetSettings().__experimentalFetchLinkSuggestions,\n\t\t};\n\t} )\n)( URLInput );\n"]}
@@ -186,7 +186,7 @@ const ImageURLInputUI = _ref => {
186
186
  if (!value) {
187
187
  linkDestinationInput = LINK_DESTINATION_NONE;
188
188
  } else {
189
- linkDestinationInput = ((0, _lodash.find)(linkDestinations, destination => {
189
+ linkDestinationInput = (linkDestinations.find(destination => {
190
190
  return destination.url === value;
191
191
  }) || {
192
192
  linkDestination: LINK_DESTINATION_CUSTOM
@@ -230,7 +230,7 @@ const ImageURLInputUI = _ref => {
230
230
  onChange: onSetLinkClass
231
231
  }));
232
232
  const linkEditorValue = urlInput !== null ? urlInput : url;
233
- const urlLabel = ((0, _lodash.find)(getLinkDestinations(), ['linkDestination', linkDestination]) || {}).title;
233
+ const urlLabel = (getLinkDestinations().find(destination => destination.linkDestination === linkDestination) || {}).title;
234
234
  return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.ToolbarButton, {
235
235
  icon: _icons.link,
236
236
  className: "components-toolbar__control",
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/url-popover/image-url-input-ui.js"],"names":["LINK_DESTINATION_NONE","LINK_DESTINATION_CUSTOM","LINK_DESTINATION_MEDIA","LINK_DESTINATION_ATTACHMENT","NEW_TAB_REL","icon","ImageURLInputUI","linkDestination","onChangeUrl","url","mediaType","mediaUrl","mediaLink","linkTarget","linkClass","rel","isOpen","setIsOpen","popoverAnchor","setPopoverAnchor","openLinkUI","isEditingLink","setIsEditingLink","urlInput","setUrlInput","autocompleteRef","startEditLink","stopEditLink","closeLinkUI","getUpdatedLinkTargetSettings","value","newLinkTarget","undefined","updatedRel","rels","split","forEach","relVal","includes","push","join","filter","length","onFocusOutside","event","autocompleteElement","current","contains","target","onSubmitLinkChange","selectedDestination","getLinkDestinations","find","destination","href","preventDefault","onLinkRemove","linkDestinations","title","onSetHref","linkDestinationInput","onSetNewTab","updatedLinkTarget","onSetLinkRel","onSetLinkClass","advancedOptions","linkEditorValue","urlLabel","linkIcon","link","close"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AAUA;;AAKA;;AAzBA;AACA;AACA;;AAGA;AACA;AACA;;AAeA;AACA;AACA;AAGA,MAAMA,qBAAqB,GAA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G,YADR;AAEC,IAAA,KAAK,EAAG,cAAI,aAAJ,CAFT;AAGC,IAAA,OAAO,EAAGd;AAHX,IAPD,CAnCF,CAVF,CADD;AAgEA,CAzQD","sourcesContent":["/**\n * External dependencies\n */\nimport { find, map } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useState, useCallback } from '@wordpress/element';\nimport {\n\tToolbarButton,\n\tButton,\n\tNavigableMenu,\n\tMenuItem,\n\tToggleControl,\n\tTextControl,\n\tSVG,\n\tPath,\n} from '@wordpress/components';\nimport { link as linkIcon, close } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport URLPopover from './index';\n\nconst LINK_DESTINATION_NONE = 'none';\nconst LINK_DESTINATION_CUSTOM = 'custom';\nconst LINK_DESTINATION_MEDIA = 'media';\nconst LINK_DESTINATION_ATTACHMENT = 'attachment';\nconst NEW_TAB_REL = [ 'noreferrer', 'noopener' ];\n\nconst icon = (\n\t<SVG viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t<Path d=\"M0,0h24v24H0V0z\" fill=\"none\" />\n\t\t<Path d=\"m19 5v14h-14v-14h14m0-2h-14c-1.1 0-2 0.9-2 2v14c0 1.1 0.9 2 2 2h14c1.1 0 2-0.9 2-2v-14c0-1.1-0.9-2-2-2z\" />\n\t\t<Path d=\"m14.14 11.86l-3 3.87-2.14-2.59-3 3.86h12l-3.86-5.14z\" />\n\t</SVG>\n);\n\nconst ImageURLInputUI = ( {\n\tlinkDestination,\n\tonChangeUrl,\n\turl,\n\tmediaType = 'image',\n\tmediaUrl,\n\tmediaLink,\n\tlinkTarget,\n\tlinkClass,\n\trel,\n} ) => {\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst openLinkUI = useCallback( () => {\n\t\tsetIsOpen( true );\n\t} );\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState( false );\n\tconst [ urlInput, setUrlInput ] = useState( null );\n\n\tconst autocompleteRef = useRef( null );\n\n\tconst startEditLink = useCallback( () => {\n\t\tif (\n\t\t\tlinkDestination === LINK_DESTINATION_MEDIA ||\n\t\t\tlinkDestination === LINK_DESTINATION_ATTACHMENT\n\t\t) {\n\t\t\tsetUrlInput( '' );\n\t\t}\n\t\tsetIsEditingLink( true );\n\t} );\n\n\tconst stopEditLink = useCallback( () => {\n\t\tsetIsEditingLink( false );\n\t} );\n\n\tconst closeLinkUI = useCallback( () => {\n\t\tsetUrlInput( null );\n\t\tstopEditLink();\n\t\tsetIsOpen( false );\n\t} );\n\n\tconst getUpdatedLinkTargetSettings = ( value ) => {\n\t\tconst newLinkTarget = value ? '_blank' : undefined;\n\n\t\tlet updatedRel;\n\t\tif ( newLinkTarget ) {\n\t\t\tconst rels = ( rel ?? '' ).split( ' ' );\n\t\t\tNEW_TAB_REL.forEach( ( relVal ) => {\n\t\t\t\tif ( ! rels.includes( relVal ) ) {\n\t\t\t\t\trels.push( relVal );\n\t\t\t\t}\n\t\t\t} );\n\t\t\tupdatedRel = rels.join( ' ' );\n\t\t} else {\n\t\t\tconst rels = ( rel ?? '' )\n\t\t\t\t.split( ' ' )\n\t\t\t\t.filter(\n\t\t\t\t\t( relVal ) => NEW_TAB_REL.includes( relVal ) === false\n\t\t\t\t);\n\t\t\tupdatedRel = rels.length ? rels.join( ' ' ) : undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tlinkTarget: newLinkTarget,\n\t\t\trel: updatedRel,\n\t\t};\n\t};\n\n\tconst onFocusOutside = useCallback( () => {\n\t\treturn ( event ) => {\n\t\t\t// The autocomplete suggestions list renders in a separate popover (in a portal),\n\t\t\t// so onFocusOutside fails to detect that a click on a suggestion occurred in the\n\t\t\t// LinkContainer. Detect clicks on autocomplete suggestions using a ref here, and\n\t\t\t// return to avoid the popover being closed.\n\t\t\tconst autocompleteElement = autocompleteRef.current;\n\t\t\tif (\n\t\t\t\tautocompleteElement &&\n\t\t\t\tautocompleteElement.contains( event.target )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetIsOpen( false );\n\t\t\tsetUrlInput( null );\n\t\t\tstopEditLink();\n\t\t};\n\t} );\n\n\tconst onSubmitLinkChange = useCallback( () => {\n\t\treturn ( event ) => {\n\t\t\tif ( urlInput ) {\n\t\t\t\t// It is possible the entered URL actually matches a named link destination.\n\t\t\t\t// This check will ensure our link destination is correct.\n\t\t\t\tconst selectedDestination =\n\t\t\t\t\tgetLinkDestinations().find(\n\t\t\t\t\t\t( destination ) => destination.url === urlInput\n\t\t\t\t\t)?.linkDestination || LINK_DESTINATION_CUSTOM;\n\n\t\t\t\tonChangeUrl( {\n\t\t\t\t\thref: urlInput,\n\t\t\t\t\tlinkDestination: selectedDestination,\n\t\t\t\t} );\n\t\t\t}\n\t\t\tstopEditLink();\n\t\t\tsetUrlInput( null );\n\t\t\tevent.preventDefault();\n\t\t};\n\t} );\n\n\tconst onLinkRemove = useCallback( () => {\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: LINK_DESTINATION_NONE,\n\t\t\thref: '',\n\t\t} );\n\t} );\n\n\tconst getLinkDestinations = () => {\n\t\tconst linkDestinations = [\n\t\t\t{\n\t\t\t\tlinkDestination: LINK_DESTINATION_MEDIA,\n\t\t\t\ttitle: __( 'Media File' ),\n\t\t\t\turl: mediaType === 'image' ? mediaUrl : undefined,\n\t\t\t\ticon,\n\t\t\t},\n\t\t];\n\t\tif ( mediaType === 'image' && mediaLink ) {\n\t\t\tlinkDestinations.push( {\n\t\t\t\tlinkDestination: LINK_DESTINATION_ATTACHMENT,\n\t\t\t\ttitle: __( 'Attachment Page' ),\n\t\t\t\turl: mediaType === 'image' ? mediaLink : undefined,\n\t\t\t\ticon: (\n\t\t\t\t\t<SVG viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t\t\t\t\t<Path d=\"M0 0h24v24H0V0z\" fill=\"none\" />\n\t\t\t\t\t\t<Path d=\"M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zM6 20V4h7v5h5v11H6z\" />\n\t\t\t\t\t</SVG>\n\t\t\t\t),\n\t\t\t} );\n\t\t}\n\t\treturn linkDestinations;\n\t};\n\n\tconst onSetHref = ( value ) => {\n\t\tconst linkDestinations = getLinkDestinations();\n\t\tlet linkDestinationInput;\n\t\tif ( ! value ) {\n\t\t\tlinkDestinationInput = LINK_DESTINATION_NONE;\n\t\t} else {\n\t\t\tlinkDestinationInput = (\n\t\t\t\tfind( linkDestinations, ( destination ) => {\n\t\t\t\t\treturn destination.url === value;\n\t\t\t\t} ) || { linkDestination: LINK_DESTINATION_CUSTOM }\n\t\t\t).linkDestination;\n\t\t}\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: linkDestinationInput,\n\t\t\thref: value,\n\t\t} );\n\t};\n\n\tconst onSetNewTab = ( value ) => {\n\t\tconst updatedLinkTarget = getUpdatedLinkTargetSettings( value );\n\t\tonChangeUrl( updatedLinkTarget );\n\t};\n\n\tconst onSetLinkRel = ( value ) => {\n\t\tonChangeUrl( { rel: value } );\n\t};\n\n\tconst onSetLinkClass = ( value ) => {\n\t\tonChangeUrl( { linkClass: value } );\n\t};\n\n\tconst advancedOptions = (\n\t\t<>\n\t\t\t<ToggleControl\n\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\tonChange={ onSetNewTab }\n\t\t\t\tchecked={ linkTarget === '_blank' }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\tvalue={ rel ?? '' }\n\t\t\t\tonChange={ onSetLinkRel }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\tlabel={ __( 'Link CSS Class' ) }\n\t\t\t\tvalue={ linkClass || '' }\n\t\t\t\tonChange={ onSetLinkClass }\n\t\t\t/>\n\t\t</>\n\t);\n\n\tconst linkEditorValue = urlInput !== null ? urlInput : url;\n\n\tconst urlLabel = (\n\t\tfind( getLinkDestinations(), [ 'linkDestination', linkDestination ] ) ||\n\t\t{}\n\t).title;\n\n\treturn (\n\t\t<>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ linkIcon }\n\t\t\t\tclassName=\"components-toolbar__control\"\n\t\t\t\tlabel={ url ? __( 'Edit link' ) : __( 'Insert link' ) }\n\t\t\t\taria-expanded={ isOpen }\n\t\t\t\tonClick={ openLinkUI }\n\t\t\t\tref={ setPopoverAnchor }\n\t\t\t/>\n\t\t\t{ isOpen && (\n\t\t\t\t<URLPopover\n\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\tonFocusOutside={ onFocusOutside() }\n\t\t\t\t\tonClose={ closeLinkUI }\n\t\t\t\t\trenderSettings={ () => advancedOptions }\n\t\t\t\t\tadditionalControls={\n\t\t\t\t\t\t! linkEditorValue && (\n\t\t\t\t\t\t\t<NavigableMenu>\n\t\t\t\t\t\t\t\t{ map( getLinkDestinations(), ( link ) => (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tkey={ link.linkDestination }\n\t\t\t\t\t\t\t\t\t\ticon={ link.icon }\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetUrlInput( null );\n\t\t\t\t\t\t\t\t\t\t\tonSetHref( link.url );\n\t\t\t\t\t\t\t\t\t\t\tstopEditLink();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ link.title }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ ( ! url || isEditingLink ) && (\n\t\t\t\t\t\t<URLPopover.LinkEditor\n\t\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\t\t\tvalue={ linkEditorValue }\n\t\t\t\t\t\t\tonChangeInputValue={ setUrlInput }\n\t\t\t\t\t\t\tonSubmit={ onSubmitLinkChange() }\n\t\t\t\t\t\t\tautocompleteRef={ autocompleteRef }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ url && ! isEditingLink && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<URLPopover.LinkViewer\n\t\t\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\t\tonEditLinkClick={ startEditLink }\n\t\t\t\t\t\t\t\turlLabel={ urlLabel }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\ticon={ close }\n\t\t\t\t\t\t\t\tlabel={ __( 'Remove link' ) }\n\t\t\t\t\t\t\t\tonClick={ onLinkRemove }\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</URLPopover>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nexport { ImageURLInputUI as __experimentalImageURLInputUI };\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/url-popover/image-url-input-ui.js"],"names":["LINK_DESTINATION_NONE","LINK_DESTINATION_CUSTOM","LINK_DESTINATION_MEDIA","LINK_DESTINATION_ATTACHMENT","NEW_TAB_REL","icon","ImageURLInputUI","linkDestination","onChangeUrl","url","mediaType","mediaUrl","mediaLink","linkTarget","linkClass","rel","isOpen","setIsOpen","popoverAnchor","setPopoverAnchor","openLinkUI","isEditingLink","setIsEditingLink","urlInput","setUrlInput","autocompleteRef","startEditLink","stopEditLink","closeLinkUI","getUpdatedLinkTargetSettings","value","newLinkTarget","undefined","updatedRel","rels","split","forEach","relVal","includes","push","join","filter","length","onFocusOutside","event","autocompleteElement","current","contains","target","onSubmitLinkChange","selectedDestination","getLinkDestinations","find","destination","href","preventDefault","onLinkRemove","linkDestinations","title","onSetHref","linkDestinationInput","onSetNewTab","updatedLinkTarget","onSetLinkRel","onSetLinkClass","advancedOptions","linkEditorValue","urlLabel","linkIcon","link","close"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AAUA;;AAKA;;AAzBA;AACA;AACA;;AAGA;AACA;AACA;;AAeA;AACA;AACA;AAGA,MAAMA,qBAAqB,GAAG,MAA9B;AACA,MAAMC,uBAAuB,GAAG,QAAhC;AACA,MAAMC,sBAAsB,GAAG,OAA/B;AACA,MAAMC,2BAA2B,GAAG,YAApC;AACA,MAAMC,WAAW,GAAG,CAAE,YAAF,EAAgB,UAAhB,CAApB;AAEA,MAAMC,IAAI,GACT,4BAAC,eAAD;AAAK,EAAA,OAAO,EAAC,WAAb;AAAyB,EAAA,KAAK,EAAC;AAA/B,GACC,4BAAC,gBAAD;AAAM,EAAA,CAAC,EAAC,iBAAR;AAA0B,EAAA,IAAI,EAAC;AAA/B,EADD,EAEC,4BAAC,gBAAD;AAAM,EAAA,CAAC,EAAC;AAAR,EAFD,EAGC,4BAAC,gBAAD;AAAM,EAAA,CAAC,EAAC;AAAR,EAHD,CADD;;AAQA,MAAMC,eAAe,GAAG,QAUjB;AAAA,MAVmB;AACzBC,IAAAA,eADyB;AAEzBC,IAAAA,WAFyB;AAGzBC,IAAAA,GAHyB;AAIzBC,IAAAA,SAAS,GAAG,OAJa;AAKzBC,IAAAA,QALyB;AAMzBC,IAAAA,SANyB;AAOzBC,IAAAA,UAPyB;AAQzBC,IAAAA,SARyB;AASzBC,IAAAA;AATyB,GAUnB;AACN,QAAM,CAAEC,MAAF,EAAUC,SAAV,IAAwB,uBAAU,KAAV,CAA9B,CADM,CAEN;AACA;;AACA,QAAM,CAAEC,aAAF,EAAiBC,gBAAjB,IAAsC,uBAAU,IAAV,CAA5C;AACA,QAAMC,UAAU,GAAG,0BA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HtB;AAIC,IAAA,QAAQ,EAAGyB,kBAAkB,EAJ9B;AAKC,IAAA,eAAe,EAAGxB;AALnB,IA1BF,EAkCGhB,GAAG,IAAI,CAAEY,aAAT,IACD,qDACC,4BAAC,cAAD,CAAY,UAAZ;AACC,IAAA,SAAS,EAAC,qDADX;AAEC,IAAA,GAAG,EAAGZ,GAFP;AAGC,IAAA,eAAe,EAAGiB,aAHnB;AAIC,IAAA,QAAQ,EAAGyC;AAJZ,IADD,EAOC,4BAAC,kBAAD;AACC,IAAA,IAAI,EAAGG,YADR;AAEC,IAAA,KAAK,EAAG,cAAI,aAAJ,CAFT;AAGC,IAAA,OAAO,EAAGd;AAHX,IAPD,CAnCF,CAVF,CADD;AAgEA,CA1QD","sourcesContent":["/**\n * External dependencies\n */\nimport { map } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useState, useCallback } from '@wordpress/element';\nimport {\n\tToolbarButton,\n\tButton,\n\tNavigableMenu,\n\tMenuItem,\n\tToggleControl,\n\tTextControl,\n\tSVG,\n\tPath,\n} from '@wordpress/components';\nimport { link as linkIcon, close } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport URLPopover from './index';\n\nconst LINK_DESTINATION_NONE = 'none';\nconst LINK_DESTINATION_CUSTOM = 'custom';\nconst LINK_DESTINATION_MEDIA = 'media';\nconst LINK_DESTINATION_ATTACHMENT = 'attachment';\nconst NEW_TAB_REL = [ 'noreferrer', 'noopener' ];\n\nconst icon = (\n\t<SVG viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t<Path d=\"M0,0h24v24H0V0z\" fill=\"none\" />\n\t\t<Path d=\"m19 5v14h-14v-14h14m0-2h-14c-1.1 0-2 0.9-2 2v14c0 1.1 0.9 2 2 2h14c1.1 0 2-0.9 2-2v-14c0-1.1-0.9-2-2-2z\" />\n\t\t<Path d=\"m14.14 11.86l-3 3.87-2.14-2.59-3 3.86h12l-3.86-5.14z\" />\n\t</SVG>\n);\n\nconst ImageURLInputUI = ( {\n\tlinkDestination,\n\tonChangeUrl,\n\turl,\n\tmediaType = 'image',\n\tmediaUrl,\n\tmediaLink,\n\tlinkTarget,\n\tlinkClass,\n\trel,\n} ) => {\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst openLinkUI = useCallback( () => {\n\t\tsetIsOpen( true );\n\t} );\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState( false );\n\tconst [ urlInput, setUrlInput ] = useState( null );\n\n\tconst autocompleteRef = useRef( null );\n\n\tconst startEditLink = useCallback( () => {\n\t\tif (\n\t\t\tlinkDestination === LINK_DESTINATION_MEDIA ||\n\t\t\tlinkDestination === LINK_DESTINATION_ATTACHMENT\n\t\t) {\n\t\t\tsetUrlInput( '' );\n\t\t}\n\t\tsetIsEditingLink( true );\n\t} );\n\n\tconst stopEditLink = useCallback( () => {\n\t\tsetIsEditingLink( false );\n\t} );\n\n\tconst closeLinkUI = useCallback( () => {\n\t\tsetUrlInput( null );\n\t\tstopEditLink();\n\t\tsetIsOpen( false );\n\t} );\n\n\tconst getUpdatedLinkTargetSettings = ( value ) => {\n\t\tconst newLinkTarget = value ? '_blank' : undefined;\n\n\t\tlet updatedRel;\n\t\tif ( newLinkTarget ) {\n\t\t\tconst rels = ( rel ?? '' ).split( ' ' );\n\t\t\tNEW_TAB_REL.forEach( ( relVal ) => {\n\t\t\t\tif ( ! rels.includes( relVal ) ) {\n\t\t\t\t\trels.push( relVal );\n\t\t\t\t}\n\t\t\t} );\n\t\t\tupdatedRel = rels.join( ' ' );\n\t\t} else {\n\t\t\tconst rels = ( rel ?? '' )\n\t\t\t\t.split( ' ' )\n\t\t\t\t.filter(\n\t\t\t\t\t( relVal ) => NEW_TAB_REL.includes( relVal ) === false\n\t\t\t\t);\n\t\t\tupdatedRel = rels.length ? rels.join( ' ' ) : undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tlinkTarget: newLinkTarget,\n\t\t\trel: updatedRel,\n\t\t};\n\t};\n\n\tconst onFocusOutside = useCallback( () => {\n\t\treturn ( event ) => {\n\t\t\t// The autocomplete suggestions list renders in a separate popover (in a portal),\n\t\t\t// so onFocusOutside fails to detect that a click on a suggestion occurred in the\n\t\t\t// LinkContainer. Detect clicks on autocomplete suggestions using a ref here, and\n\t\t\t// return to avoid the popover being closed.\n\t\t\tconst autocompleteElement = autocompleteRef.current;\n\t\t\tif (\n\t\t\t\tautocompleteElement &&\n\t\t\t\tautocompleteElement.contains( event.target )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetIsOpen( false );\n\t\t\tsetUrlInput( null );\n\t\t\tstopEditLink();\n\t\t};\n\t} );\n\n\tconst onSubmitLinkChange = useCallback( () => {\n\t\treturn ( event ) => {\n\t\t\tif ( urlInput ) {\n\t\t\t\t// It is possible the entered URL actually matches a named link destination.\n\t\t\t\t// This check will ensure our link destination is correct.\n\t\t\t\tconst selectedDestination =\n\t\t\t\t\tgetLinkDestinations().find(\n\t\t\t\t\t\t( destination ) => destination.url === urlInput\n\t\t\t\t\t)?.linkDestination || LINK_DESTINATION_CUSTOM;\n\n\t\t\t\tonChangeUrl( {\n\t\t\t\t\thref: urlInput,\n\t\t\t\t\tlinkDestination: selectedDestination,\n\t\t\t\t} );\n\t\t\t}\n\t\t\tstopEditLink();\n\t\t\tsetUrlInput( null );\n\t\t\tevent.preventDefault();\n\t\t};\n\t} );\n\n\tconst onLinkRemove = useCallback( () => {\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: LINK_DESTINATION_NONE,\n\t\t\thref: '',\n\t\t} );\n\t} );\n\n\tconst getLinkDestinations = () => {\n\t\tconst linkDestinations = [\n\t\t\t{\n\t\t\t\tlinkDestination: LINK_DESTINATION_MEDIA,\n\t\t\t\ttitle: __( 'Media File' ),\n\t\t\t\turl: mediaType === 'image' ? mediaUrl : undefined,\n\t\t\t\ticon,\n\t\t\t},\n\t\t];\n\t\tif ( mediaType === 'image' && mediaLink ) {\n\t\t\tlinkDestinations.push( {\n\t\t\t\tlinkDestination: LINK_DESTINATION_ATTACHMENT,\n\t\t\t\ttitle: __( 'Attachment Page' ),\n\t\t\t\turl: mediaType === 'image' ? mediaLink : undefined,\n\t\t\t\ticon: (\n\t\t\t\t\t<SVG viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t\t\t\t\t<Path d=\"M0 0h24v24H0V0z\" fill=\"none\" />\n\t\t\t\t\t\t<Path d=\"M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zM6 20V4h7v5h5v11H6z\" />\n\t\t\t\t\t</SVG>\n\t\t\t\t),\n\t\t\t} );\n\t\t}\n\t\treturn linkDestinations;\n\t};\n\n\tconst onSetHref = ( value ) => {\n\t\tconst linkDestinations = getLinkDestinations();\n\t\tlet linkDestinationInput;\n\t\tif ( ! value ) {\n\t\t\tlinkDestinationInput = LINK_DESTINATION_NONE;\n\t\t} else {\n\t\t\tlinkDestinationInput = (\n\t\t\t\tlinkDestinations.find( ( destination ) => {\n\t\t\t\t\treturn destination.url === value;\n\t\t\t\t} ) || { linkDestination: LINK_DESTINATION_CUSTOM }\n\t\t\t).linkDestination;\n\t\t}\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: linkDestinationInput,\n\t\t\thref: value,\n\t\t} );\n\t};\n\n\tconst onSetNewTab = ( value ) => {\n\t\tconst updatedLinkTarget = getUpdatedLinkTargetSettings( value );\n\t\tonChangeUrl( updatedLinkTarget );\n\t};\n\n\tconst onSetLinkRel = ( value ) => {\n\t\tonChangeUrl( { rel: value } );\n\t};\n\n\tconst onSetLinkClass = ( value ) => {\n\t\tonChangeUrl( { linkClass: value } );\n\t};\n\n\tconst advancedOptions = (\n\t\t<>\n\t\t\t<ToggleControl\n\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\tonChange={ onSetNewTab }\n\t\t\t\tchecked={ linkTarget === '_blank' }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\tvalue={ rel ?? '' }\n\t\t\t\tonChange={ onSetLinkRel }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\tlabel={ __( 'Link CSS Class' ) }\n\t\t\t\tvalue={ linkClass || '' }\n\t\t\t\tonChange={ onSetLinkClass }\n\t\t\t/>\n\t\t</>\n\t);\n\n\tconst linkEditorValue = urlInput !== null ? urlInput : url;\n\n\tconst urlLabel = (\n\t\tgetLinkDestinations().find(\n\t\t\t( destination ) => destination.linkDestination === linkDestination\n\t\t) || {}\n\t).title;\n\n\treturn (\n\t\t<>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ linkIcon }\n\t\t\t\tclassName=\"components-toolbar__control\"\n\t\t\t\tlabel={ url ? __( 'Edit link' ) : __( 'Insert link' ) }\n\t\t\t\taria-expanded={ isOpen }\n\t\t\t\tonClick={ openLinkUI }\n\t\t\t\tref={ setPopoverAnchor }\n\t\t\t/>\n\t\t\t{ isOpen && (\n\t\t\t\t<URLPopover\n\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\tonFocusOutside={ onFocusOutside() }\n\t\t\t\t\tonClose={ closeLinkUI }\n\t\t\t\t\trenderSettings={ () => advancedOptions }\n\t\t\t\t\tadditionalControls={\n\t\t\t\t\t\t! linkEditorValue && (\n\t\t\t\t\t\t\t<NavigableMenu>\n\t\t\t\t\t\t\t\t{ map( getLinkDestinations(), ( link ) => (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tkey={ link.linkDestination }\n\t\t\t\t\t\t\t\t\t\ticon={ link.icon }\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetUrlInput( null );\n\t\t\t\t\t\t\t\t\t\t\tonSetHref( link.url );\n\t\t\t\t\t\t\t\t\t\t\tstopEditLink();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ link.title }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ ( ! url || isEditingLink ) && (\n\t\t\t\t\t\t<URLPopover.LinkEditor\n\t\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\t\t\tvalue={ linkEditorValue }\n\t\t\t\t\t\t\tonChangeInputValue={ setUrlInput }\n\t\t\t\t\t\t\tonSubmit={ onSubmitLinkChange() }\n\t\t\t\t\t\t\tautocompleteRef={ autocompleteRef }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ url && ! isEditingLink && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<URLPopover.LinkViewer\n\t\t\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\t\tonEditLinkClick={ startEditLink }\n\t\t\t\t\t\t\t\turlLabel={ urlLabel }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\ticon={ close }\n\t\t\t\t\t\t\t\tlabel={ __( 'Remove link' ) }\n\t\t\t\t\t\t\t\tonClick={ onLinkRemove }\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</URLPopover>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nexport { ImageURLInputUI as __experimentalImageURLInputUI };\n"]}
@@ -43,6 +43,7 @@ function LinkEditor(_ref) {
43
43
  return (0, _element.createElement)("form", (0, _extends2.default)({
44
44
  className: (0, _classnames.default)('block-editor-url-popover__link-editor', className)
45
45
  }, props), (0, _element.createElement)(_urlInput.default, {
46
+ __nextHasNoMarginBottom: true,
46
47
  value: value,
47
48
  onChange: onChangeInputValue,
48
49
  autocompleteRef: autocompleteRef
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/url-popover/link-editor.js"],"names":["LinkEditor","autocompleteRef","className","onChangeInputValue","value","props","keyboardReturn"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAKA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AAGe,SAASA,UAAT,OAMX;AAAA,MANgC;AACnCC,IAAAA,eADmC;AAEnCC,IAAAA,SAFmC;AAGnCC,IAAAA,kBAHmC;AAInCC,IAAAA,KAJmC;AAKnC,OAAGC;AALgC,GAMhC;AACH,SACC;AACC,IAAA,SAAS,EAAG,yBACX,uCADW,EAEXH,SAFW;AADb,KAKMG,KALN,GAOC,4BAAC,iBAAD;AACC,IAAA,KAAK,EAAGD,KADT;AAEC,IAAA,QAAQ,EAAGD,kBAFZ;AAGC,IAAA,eAAe,EAAGF;AAHnB,IAPD,EAYC,4BAAC,kBAAD;AACC,IAAA,IAAI,EAAGK,qBADR;AAEC,IAAA,KAAK,EAAG,cAAI,OAAJ,CAFT;AAGC,IAAA,IAAI,EAAC;AAHN,IAZD,CADD;AAoBA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { keyboardReturn } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport URLInput from '../url-input';\n\nexport default function LinkEditor( {\n\tautocompleteRef,\n\tclassName,\n\tonChangeInputValue,\n\tvalue,\n\t...props\n} ) {\n\treturn (\n\t\t<form\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-url-popover__link-editor',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t<URLInput\n\t\t\t\tvalue={ value }\n\t\t\t\tonChange={ onChangeInputValue }\n\t\t\t\tautocompleteRef={ autocompleteRef }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\ticon={ keyboardReturn }\n\t\t\t\tlabel={ __( 'Apply' ) }\n\t\t\t\ttype=\"submit\"\n\t\t\t/>\n\t\t</form>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/url-popover/link-editor.js"],"names":["LinkEditor","autocompleteRef","className","onChangeInputValue","value","props","keyboardReturn"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAKA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AAGe,SAASA,UAAT,OAMX;AAAA,MANgC;AACnCC,IAAAA,eADmC;AAEnCC,IAAAA,SAFmC;AAGnCC,IAAAA,kBAHmC;AAInCC,IAAAA,KAJmC;AAKnC,OAAGC;AALgC,GAMhC;AACH,SACC;AACC,IAAA,SAAS,EAAG,yBACX,uCADW,EAEXH,SAFW;AADb,KAKMG,KALN,GAOC,4BAAC,iBAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,KAAK,EAAGD,KAFT;AAGC,IAAA,QAAQ,EAAGD,kBAHZ;AAIC,IAAA,eAAe,EAAGF;AAJnB,IAPD,EAaC,4BAAC,kBAAD;AACC,IAAA,IAAI,EAAGK,qBADR;AAEC,IAAA,KAAK,EAAG,cAAI,OAAJ,CAFT;AAGC,IAAA,IAAI,EAAC;AAHN,IAbD,CADD;AAqBA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { keyboardReturn } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport URLInput from '../url-input';\n\nexport default function LinkEditor( {\n\tautocompleteRef,\n\tclassName,\n\tonChangeInputValue,\n\tvalue,\n\t...props\n} ) {\n\treturn (\n\t\t<form\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-url-popover__link-editor',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t<URLInput\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tvalue={ value }\n\t\t\t\tonChange={ onChangeInputValue }\n\t\t\t\tautocompleteRef={ autocompleteRef }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\ticon={ keyboardReturn }\n\t\t\t\tlabel={ __( 'Apply' ) }\n\t\t\t\ttype=\"submit\"\n\t\t\t/>\n\t\t</form>\n\t);\n}\n"]}
@@ -0,0 +1,188 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = usePasteStyles;
7
+
8
+ var _element = require("@wordpress/element");
9
+
10
+ var _blocks = require("@wordpress/blocks");
11
+
12
+ var _data = require("@wordpress/data");
13
+
14
+ var _notices = require("@wordpress/notices");
15
+
16
+ var _i18n = require("@wordpress/i18n");
17
+
18
+ var _store = require("../../store");
19
+
20
+ var _supports = require("../../hooks/supports");
21
+
22
+ /**
23
+ * WordPress dependencies
24
+ */
25
+
26
+ /**
27
+ * Internal dependencies
28
+ */
29
+
30
+ /**
31
+ * Determine if the copied text looks like serialized blocks or not.
32
+ * Since plain text will always get parsed into a freeform block,
33
+ * we check that if the parsed blocks is anything other than that.
34
+ *
35
+ * @param {string} text The copied text.
36
+ * @return {boolean} True if the text looks like serialized blocks, false otherwise.
37
+ */
38
+ function hasSerializedBlocks(text) {
39
+ try {
40
+ const blocks = (0, _blocks.parse)(text, {
41
+ __unstableSkipMigrationLogs: true,
42
+ __unstableSkipAutop: true
43
+ });
44
+
45
+ if (blocks.length === 1 && blocks[0].name === 'core/freeform') {
46
+ // It's likely that the text is just plain text and not serialized blocks.
47
+ return false;
48
+ }
49
+
50
+ return true;
51
+ } catch (err) {
52
+ // Parsing error, the text is not serialized blocks.
53
+ // (Even though that it technically won't happen)
54
+ return false;
55
+ }
56
+ }
57
+ /**
58
+ * Style attributes are attributes being added in `block-editor/src/hooks/*`.
59
+ * (Except for some unrelated to style like `anchor` or `settings`.)
60
+ * They generally represent the default block supports.
61
+ */
62
+
63
+
64
+ const STYLE_ATTRIBUTES = {
65
+ align: _supports.hasAlignSupport,
66
+ borderColor: nameOrType => (0, _supports.hasBorderSupport)(nameOrType, 'color'),
67
+ backgroundColor: _supports.hasBackgroundColorSupport,
68
+ textColor: _supports.hasTextColorSupport,
69
+ gradient: _supports.hasGradientSupport,
70
+ className: _supports.hasCustomClassNameSupport,
71
+ fontFamily: _supports.hasFontFamilySupport,
72
+ fontSize: _supports.hasFontSizeSupport,
73
+ layout: _supports.hasLayoutSupport,
74
+ style: _supports.hasStyleSupport
75
+ };
76
+ /**
77
+ * Get the "style attributes" from a given block to a target block.
78
+ *
79
+ * @param {WPBlock} sourceBlock The source block.
80
+ * @param {WPBlock} targetBlock The target block.
81
+ * @return {Object} the filtered attributes object.
82
+ */
83
+
84
+ function getStyleAttributes(sourceBlock, targetBlock) {
85
+ return Object.entries(STYLE_ATTRIBUTES).reduce((attributes, _ref) => {
86
+ let [attributeKey, hasSupport] = _ref;
87
+
88
+ // Only apply the attribute if both blocks support it.
89
+ if (hasSupport(sourceBlock.name) && hasSupport(targetBlock.name)) {
90
+ // Override attributes that are not present in the block to their defaults.
91
+ attributes[attributeKey] = sourceBlock.attributes[attributeKey];
92
+ }
93
+
94
+ return attributes;
95
+ }, {});
96
+ }
97
+ /**
98
+ * Update the target blocks with style attributes recursively.
99
+ *
100
+ * @param {WPBlock[]} targetBlocks The target blocks to be updated.
101
+ * @param {WPBlock[]} sourceBlocks The source blocks to get th style attributes from.
102
+ * @param {Function} updateBlockAttributes The function to update the attributes.
103
+ */
104
+
105
+
106
+ function recursivelyUpdateBlockAttributes(targetBlocks, sourceBlocks, updateBlockAttributes) {
107
+ for (let index = 0; index < Math.min(sourceBlocks.length, targetBlocks.length); index += 1) {
108
+ updateBlockAttributes(targetBlocks[index].clientId, getStyleAttributes(sourceBlocks[index], targetBlocks[index]));
109
+ recursivelyUpdateBlockAttributes(targetBlocks[index].innerBlocks, sourceBlocks[index].innerBlocks, updateBlockAttributes);
110
+ }
111
+ }
112
+ /**
113
+ * A hook to return a pasteStyles event function for handling pasting styles to blocks.
114
+ *
115
+ * @return {Function} A function to update the styles to the blocks.
116
+ */
117
+
118
+
119
+ function usePasteStyles() {
120
+ const registry = (0, _data.useRegistry)();
121
+ const {
122
+ updateBlockAttributes
123
+ } = (0, _data.useDispatch)(_store.store);
124
+ const {
125
+ createSuccessNotice,
126
+ createWarningNotice,
127
+ createErrorNotice
128
+ } = (0, _data.useDispatch)(_notices.store);
129
+ return (0, _element.useCallback)(async targetBlocks => {
130
+ let html = '';
131
+
132
+ try {
133
+ // `http:` sites won't have the clipboard property on navigator.
134
+ // (with the exception of localhost.)
135
+ if (!window.navigator.clipboard) {
136
+ createErrorNotice((0, _i18n.__)('Unable to paste styles. This feature is only available on secure (https) sites in supporting browsers.'), {
137
+ type: 'snackbar'
138
+ });
139
+ return;
140
+ }
141
+
142
+ html = await window.navigator.clipboard.readText();
143
+ } catch (error) {
144
+ // Possibly the permission is denied.
145
+ createErrorNotice((0, _i18n.__)('Unable to paste styles. Please allow browser clipboard permissions before continuing.'), {
146
+ type: 'snackbar'
147
+ });
148
+ return;
149
+ } // Abort if the copied text is empty or doesn't look like serialized blocks.
150
+
151
+
152
+ if (!html || !hasSerializedBlocks(html)) {
153
+ createWarningNotice((0, _i18n.__)("Unable to paste styles. Block styles couldn't be found within the copied content."), {
154
+ type: 'snackbar'
155
+ });
156
+ return;
157
+ }
158
+
159
+ const copiedBlocks = (0, _blocks.parse)(html);
160
+
161
+ if (copiedBlocks.length === 1) {
162
+ // Apply styles of the block to all the target blocks.
163
+ registry.batch(() => {
164
+ recursivelyUpdateBlockAttributes(targetBlocks, targetBlocks.map(() => copiedBlocks[0]), updateBlockAttributes);
165
+ });
166
+ } else {
167
+ registry.batch(() => {
168
+ recursivelyUpdateBlockAttributes(targetBlocks, copiedBlocks, updateBlockAttributes);
169
+ });
170
+ }
171
+
172
+ if (targetBlocks.length === 1) {
173
+ var _getBlockType;
174
+
175
+ const title = (_getBlockType = (0, _blocks.getBlockType)(targetBlocks[0].name)) === null || _getBlockType === void 0 ? void 0 : _getBlockType.title;
176
+ createSuccessNotice((0, _i18n.sprintf)( // Translators: Name of the block being pasted, e.g. "Paragraph".
177
+ (0, _i18n.__)('Pasted styles to %s.'), title), {
178
+ type: 'snackbar'
179
+ });
180
+ } else {
181
+ createSuccessNotice((0, _i18n.sprintf)( // Translators: The number of the blocks.
182
+ (0, _i18n.__)('Pasted styles to %d blocks.'), targetBlocks.length), {
183
+ type: 'snackbar'
184
+ });
185
+ }
186
+ }, [registry.batch, updateBlockAttributes, createSuccessNotice, createWarningNotice, createErrorNotice]);
187
+ }
188
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/use-paste-styles/index.js"],"names":["hasSerializedBlocks","text","blocks","__unstableSkipMigrationLogs","__unstableSkipAutop","length","name","err","STYLE_ATTRIBUTES","align","hasAlignSupport","borderColor","nameOrType","backgroundColor","hasBackgroundColorSupport","textColor","hasTextColorSupport","gradient","hasGradientSupport","className","hasCustomClassNameSupport","fontFamily","hasFontFamilySupport","fontSize","hasFontSizeSupport","layout","hasLayoutSupport","style","hasStyleSupport","getStyleAttributes","sourceBlock","targetBlock","Object","entries","reduce","attributes","attributeKey","hasSupport","recursivelyUpdateBlockAttributes","targetBlocks","sourceBlocks","updateBlockAttributes","index","Math","min","clientId","innerBlocks","usePasteStyles","registry","blockEditorStore","createSuccessNotice","createWarningNotice","createErrorNotice","noticesStore","html","window","navigator","clipboard","type","readText","error","copiedBlocks","batch","map","title"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAbA;AACA;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EN,QAAAA,IAAI,EAAE;AAAR,OANkB,CAAnB;AAQA,KAVD,MAUO;AACNR,MAAAA,mBAAmB,CAClB,oBACC;AACA,oBAAI,6BAAJ,CAFD,EAGCX,YAAY,CAAClC,MAHd,CADkB,EAMlB;AAAEqD,QAAAA,IAAI,EAAE;AAAR,OANkB,CAAnB;AAQA;AACD,GApFK,EAqFN,CACCV,QAAQ,CAACc,KADV,EAECrB,qBAFD,EAGCS,mBAHD,EAICC,mBAJD,EAKCC,iBALD,CArFM,CAAP;AA6FA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport { getBlockType, parse } from '@wordpress/blocks';\nimport { useDispatch, useRegistry } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport {\n\thasAlignSupport,\n\thasBorderSupport,\n\thasBackgroundColorSupport,\n\thasTextColorSupport,\n\thasGradientSupport,\n\thasCustomClassNameSupport,\n\thasFontFamilySupport,\n\thasFontSizeSupport,\n\thasLayoutSupport,\n\thasStyleSupport,\n} from '../../hooks/supports';\n\n/**\n * Determine if the copied text looks like serialized blocks or not.\n * Since plain text will always get parsed into a freeform block,\n * we check that if the parsed blocks is anything other than that.\n *\n * @param {string} text The copied text.\n * @return {boolean} True if the text looks like serialized blocks, false otherwise.\n */\nfunction hasSerializedBlocks( text ) {\n\ttry {\n\t\tconst blocks = parse( text, {\n\t\t\t__unstableSkipMigrationLogs: true,\n\t\t\t__unstableSkipAutop: true,\n\t\t} );\n\t\tif ( blocks.length === 1 && blocks[ 0 ].name === 'core/freeform' ) {\n\t\t\t// It's likely that the text is just plain text and not serialized blocks.\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t} catch ( err ) {\n\t\t// Parsing error, the text is not serialized blocks.\n\t\t// (Even though that it technically won't happen)\n\t\treturn false;\n\t}\n}\n\n/**\n * Style attributes are attributes being added in `block-editor/src/hooks/*`.\n * (Except for some unrelated to style like `anchor` or `settings`.)\n * They generally represent the default block supports.\n */\nconst STYLE_ATTRIBUTES = {\n\talign: hasAlignSupport,\n\tborderColor: ( nameOrType ) => hasBorderSupport( nameOrType, 'color' ),\n\tbackgroundColor: hasBackgroundColorSupport,\n\ttextColor: hasTextColorSupport,\n\tgradient: hasGradientSupport,\n\tclassName: hasCustomClassNameSupport,\n\tfontFamily: hasFontFamilySupport,\n\tfontSize: hasFontSizeSupport,\n\tlayout: hasLayoutSupport,\n\tstyle: hasStyleSupport,\n};\n\n/**\n * Get the \"style attributes\" from a given block to a target block.\n *\n * @param {WPBlock} sourceBlock The source block.\n * @param {WPBlock} targetBlock The target block.\n * @return {Object} the filtered attributes object.\n */\nfunction getStyleAttributes( sourceBlock, targetBlock ) {\n\treturn Object.entries( STYLE_ATTRIBUTES ).reduce(\n\t\t( attributes, [ attributeKey, hasSupport ] ) => {\n\t\t\t// Only apply the attribute if both blocks support it.\n\t\t\tif (\n\t\t\t\thasSupport( sourceBlock.name ) &&\n\t\t\t\thasSupport( targetBlock.name )\n\t\t\t) {\n\t\t\t\t// Override attributes that are not present in the block to their defaults.\n\t\t\t\tattributes[ attributeKey ] =\n\t\t\t\t\tsourceBlock.attributes[ attributeKey ];\n\t\t\t}\n\t\t\treturn attributes;\n\t\t},\n\t\t{}\n\t);\n}\n\n/**\n * Update the target blocks with style attributes recursively.\n *\n * @param {WPBlock[]} targetBlocks The target blocks to be updated.\n * @param {WPBlock[]} sourceBlocks The source blocks to get th style attributes from.\n * @param {Function} updateBlockAttributes The function to update the attributes.\n */\nfunction recursivelyUpdateBlockAttributes(\n\ttargetBlocks,\n\tsourceBlocks,\n\tupdateBlockAttributes\n) {\n\tfor (\n\t\tlet index = 0;\n\t\tindex < Math.min( sourceBlocks.length, targetBlocks.length );\n\t\tindex += 1\n\t) {\n\t\tupdateBlockAttributes(\n\t\t\ttargetBlocks[ index ].clientId,\n\t\t\tgetStyleAttributes( sourceBlocks[ index ], targetBlocks[ index ] )\n\t\t);\n\n\t\trecursivelyUpdateBlockAttributes(\n\t\t\ttargetBlocks[ index ].innerBlocks,\n\t\t\tsourceBlocks[ index ].innerBlocks,\n\t\t\tupdateBlockAttributes\n\t\t);\n\t}\n}\n\n/**\n * A hook to return a pasteStyles event function for handling pasting styles to blocks.\n *\n * @return {Function} A function to update the styles to the blocks.\n */\nexport default function usePasteStyles() {\n\tconst registry = useRegistry();\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst { createSuccessNotice, createWarningNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\treturn useCallback(\n\t\tasync ( targetBlocks ) => {\n\t\t\tlet html = '';\n\t\t\ttry {\n\t\t\t\t// `http:` sites won't have the clipboard property on navigator.\n\t\t\t\t// (with the exception of localhost.)\n\t\t\t\tif ( ! window.navigator.clipboard ) {\n\t\t\t\t\tcreateErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Unable to paste styles. This feature is only available on secure (https) sites in supporting browsers.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\thtml = await window.navigator.clipboard.readText();\n\t\t\t} catch ( error ) {\n\t\t\t\t// Possibly the permission is denied.\n\t\t\t\tcreateErrorNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t'Unable to paste styles. Please allow browser clipboard permissions before continuing.'\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Abort if the copied text is empty or doesn't look like serialized blocks.\n\t\t\tif ( ! html || ! hasSerializedBlocks( html ) ) {\n\t\t\t\tcreateWarningNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t\"Unable to paste styles. Block styles couldn't be found within the copied content.\"\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst copiedBlocks = parse( html );\n\n\t\t\tif ( copiedBlocks.length === 1 ) {\n\t\t\t\t// Apply styles of the block to all the target blocks.\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\trecursivelyUpdateBlockAttributes(\n\t\t\t\t\t\ttargetBlocks,\n\t\t\t\t\t\ttargetBlocks.map( () => copiedBlocks[ 0 ] ),\n\t\t\t\t\t\tupdateBlockAttributes\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\trecursivelyUpdateBlockAttributes(\n\t\t\t\t\t\ttargetBlocks,\n\t\t\t\t\t\tcopiedBlocks,\n\t\t\t\t\t\tupdateBlockAttributes\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tif ( targetBlocks.length === 1 ) {\n\t\t\t\tconst title = getBlockType( targetBlocks[ 0 ].name )?.title;\n\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t// Translators: Name of the block being pasted, e.g. \"Paragraph\".\n\t\t\t\t\t\t__( 'Pasted styles to %s.' ),\n\t\t\t\t\t\ttitle\n\t\t\t\t\t),\n\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t// Translators: The number of the blocks.\n\t\t\t\t\t\t__( 'Pasted styles to %d blocks.' ),\n\t\t\t\t\t\ttargetBlocks.length\n\t\t\t\t\t),\n\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tregistry.batch,\n\t\t\tupdateBlockAttributes,\n\t\t\tcreateSuccessNotice,\n\t\t\tcreateWarningNotice,\n\t\t\tcreateErrorNotice,\n\t\t]\n\t);\n}\n"]}
@@ -53,7 +53,7 @@ function useWritingFlow() {
53
53
  const [before, ref, after] = (0, _useTabNav.default)();
54
54
  const hasMultiSelection = (0, _data.useSelect)(select => select(_store.store).hasMultiSelection(), []);
55
55
  return [before, (0, _compose.useMergeRefs)([ref, (0, _useInput.default)(), (0, _useDragSelection.default)(), (0, _useSelectionObserver.default)(), (0, _useClickSelection.default)(), (0, _useMultiSelection.default)(), (0, _useSelectAll.default)(), (0, _useArrowNav.default)(), (0, _compose.useRefEffect)(node => {
56
- node.tabIndex = -1;
56
+ node.tabIndex = 0;
57
57
  node.contentEditable = hasMultiSelection;
58
58
 
59
59
  if (!hasMultiSelection) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/index.js"],"names":["useWritingFlow","before","ref","after","hasMultiSelection","select","blockEditorStore","node","tabIndex","contentEditable","classList","add","setAttribute","remove","removeAttribute","WritingFlow","forwardedRef","children","props","className"],"mappings":";;;;;;;;;;AAWA;;;;AARA;;AAKA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAxBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAWO,SAASA,cAAT,GAA0B;AAChC,QAAM,CAAEC,MAAF,EAAUC,GAAV,EAAeC,KAAf,IAAyB,yBAA/B;AACA,QAAMC,iBAAiB,GAAG,qBACvBC,MAAF,IAAcA,MAAM,CAAEC,YAAF,CAAN,CAA2BF,iBAA3B,EADW,EAEzB,EAFyB,CAA1B;AAKA,SAAO,CACNH,MADM,EAEN,2BAAc,CACbC,GADa,EAEb,wBAFa,EAGb,gCAHa,EAIb,oCAJa,EAKb,iCALa,EAMb,iCANa,EAOb,4BAPa,EAQb,2BARa,EASb,2BACGK,IAAF,IAAY;AACXA,IAAAA,IAAI,CAACC,QAAL,GAAgB,CAAC,CAAjB;AACAD,IAAAA,IAAI,CAACE,eAAL,GAAuBL,iBAAvB;;AAEA,QAAK,CAAEA,iBAAP,EAA2B;AAC1B;AACA;;AAEDG,IAAAA,IAAI,CAACG,SAAL,CAAeC,GAAf,CAAoB,qBAApB;AACAJ,IAAAA,IAAI,CAACK,YAAL,CACC,YADD,EAEC,cAAI,0BAAJ,CAFD;AAKA,WAAO,MAAM;AACZL,MAAAA,IAAI,CAACG,SAAL,CAAeG,MAAf,CAAuB,qBAAvB;AACAN,MAAAA,IAAI,CAACO,eAAL,CAAsB,YAAtB;AACA,KAHD;AAIA,GAnBF,EAoBC,CAAEV,iBAAF,CApBD,CATa,CAAd,CAFM,EAkCND,KAlCM,CAAP;AAoCA;;AAED,SAASY,WAAT,OAA8CC,YAA9C,EAA6D;AAAA,MAAvC;AAAEC,IAAAA,QAAF;AAAY,OAAGC;AAAf,GAAuC;AAC5D,QAAM,CAAEjB,MAAF,EAAUC,GAAV,EAAeC,KAAf,IAAyBH,cAAc,EAA7C;AACA,SACC,qDACGC,MADH,EAEC,8DACMiB,KADN;AAEC,IAAA,GAAG,EAAG,2BAAc,CAAEhB,GAAF,EAAOc,YAAP,CAAd,CAFP;AAGC,IAAA,SAAS,EAAG,yBACXE,KAAK,CAACC,SADK,EAEX,2BAFW;AAHb,MAQGF,QARH,CAFD,EAYGd,KAZH,CADD;AAgBA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;eACe,yBAAYY,WAAZ,C","sourcesContent":["/**\n * External dependencies\n */\nimport classNames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { useMergeRefs, useRefEffect } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useMultiSelection from './use-multi-selection';\nimport useTabNav from './use-tab-nav';\nimport useArrowNav from './use-arrow-nav';\nimport useSelectAll from './use-select-all';\nimport useDragSelection from './use-drag-selection';\nimport useSelectionObserver from './use-selection-observer';\nimport useClickSelection from './use-click-selection';\nimport useInput from './use-input';\nimport { store as blockEditorStore } from '../../store';\n\nexport function useWritingFlow() {\n\tconst [ before, ref, after ] = useTabNav();\n\tconst hasMultiSelection = useSelect(\n\t\t( select ) => select( blockEditorStore ).hasMultiSelection(),\n\t\t[]\n\t);\n\n\treturn [\n\t\tbefore,\n\t\tuseMergeRefs( [\n\t\t\tref,\n\t\t\tuseInput(),\n\t\t\tuseDragSelection(),\n\t\t\tuseSelectionObserver(),\n\t\t\tuseClickSelection(),\n\t\t\tuseMultiSelection(),\n\t\t\tuseSelectAll(),\n\t\t\tuseArrowNav(),\n\t\t\tuseRefEffect(\n\t\t\t\t( node ) => {\n\t\t\t\t\tnode.tabIndex = -1;\n\t\t\t\t\tnode.contentEditable = hasMultiSelection;\n\n\t\t\t\t\tif ( ! hasMultiSelection ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tnode.classList.add( 'has-multi-selection' );\n\t\t\t\t\tnode.setAttribute(\n\t\t\t\t\t\t'aria-label',\n\t\t\t\t\t\t__( 'Multiple selected blocks' )\n\t\t\t\t\t);\n\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tnode.classList.remove( 'has-multi-selection' );\n\t\t\t\t\t\tnode.removeAttribute( 'aria-label' );\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t[ hasMultiSelection ]\n\t\t\t),\n\t\t] ),\n\t\tafter,\n\t];\n}\n\nfunction WritingFlow( { children, ...props }, forwardedRef ) {\n\tconst [ before, ref, after ] = useWritingFlow();\n\treturn (\n\t\t<>\n\t\t\t{ before }\n\t\t\t<div\n\t\t\t\t{ ...props }\n\t\t\t\tref={ useMergeRefs( [ ref, forwardedRef ] ) }\n\t\t\t\tclassName={ classNames(\n\t\t\t\t\tprops.className,\n\t\t\t\t\t'block-editor-writing-flow'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t\t{ after }\n\t\t</>\n\t);\n}\n\n/**\n * Handles selection and navigation across blocks. This component should be\n * wrapped around BlockList.\n *\n * @param {Object} props Component properties.\n * @param {WPElement} props.children Children to be rendered.\n */\nexport default forwardRef( WritingFlow );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/index.js"],"names":["useWritingFlow","before","ref","after","hasMultiSelection","select","blockEditorStore","node","tabIndex","contentEditable","classList","add","setAttribute","remove","removeAttribute","WritingFlow","forwardedRef","children","props","className"],"mappings":";;;;;;;;;;AAWA;;;;AARA;;AAKA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAxBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAWO,SAASA,cAAT,GAA0B;AAChC,QAAM,CAAEC,MAAF,EAAUC,GAAV,EAAeC,KAAf,IAAyB,yBAA/B;AACA,QAAMC,iBAAiB,GAAG,qBACvBC,MAAF,IAAcA,MAAM,CAAEC,YAAF,CAAN,CAA2BF,iBAA3B,EADW,EAEzB,EAFyB,CAA1B;AAKA,SAAO,CACNH,MADM,EAEN,2BAAc,CACbC,GADa,EAEb,wBAFa,EAGb,gCAHa,EAIb,oCAJa,EAKb,iCALa,EAMb,iCANa,EAOb,4BAPa,EAQb,2BARa,EASb,2BACGK,IAAF,IAAY;AACXA,IAAAA,IAAI,CAACC,QAAL,GAAgB,CAAhB;AACAD,IAAAA,IAAI,CAACE,eAAL,GAAuBL,iBAAvB;;AAEA,QAAK,CAAEA,iBAAP,EAA2B;AAC1B;AACA;;AAEDG,IAAAA,IAAI,CAACG,SAAL,CAAeC,GAAf,CAAoB,qBAApB;AACAJ,IAAAA,IAAI,CAACK,YAAL,CACC,YADD,EAEC,cAAI,0BAAJ,CAFD;AAKA,WAAO,MAAM;AACZL,MAAAA,IAAI,CAACG,SAAL,CAAeG,MAAf,CAAuB,qBAAvB;AACAN,MAAAA,IAAI,CAACO,eAAL,CAAsB,YAAtB;AACA,KAHD;AAIA,GAnBF,EAoBC,CAAEV,iBAAF,CApBD,CATa,CAAd,CAFM,EAkCND,KAlCM,CAAP;AAoCA;;AAED,SAASY,WAAT,OAA8CC,YAA9C,EAA6D;AAAA,MAAvC;AAAEC,IAAAA,QAAF;AAAY,OAAGC;AAAf,GAAuC;AAC5D,QAAM,CAAEjB,MAAF,EAAUC,GAAV,EAAeC,KAAf,IAAyBH,cAAc,EAA7C;AACA,SACC,qDACGC,MADH,EAEC,8DACMiB,KADN;AAEC,IAAA,GAAG,EAAG,2BAAc,CAAEhB,GAAF,EAAOc,YAAP,CAAd,CAFP;AAGC,IAAA,SAAS,EAAG,yBACXE,KAAK,CAACC,SADK,EAEX,2BAFW;AAHb,MAQGF,QARH,CAFD,EAYGd,KAZH,CADD;AAgBA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;eACe,yBAAYY,WAAZ,C","sourcesContent":["/**\n * External dependencies\n */\nimport classNames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { useMergeRefs, useRefEffect } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useMultiSelection from './use-multi-selection';\nimport useTabNav from './use-tab-nav';\nimport useArrowNav from './use-arrow-nav';\nimport useSelectAll from './use-select-all';\nimport useDragSelection from './use-drag-selection';\nimport useSelectionObserver from './use-selection-observer';\nimport useClickSelection from './use-click-selection';\nimport useInput from './use-input';\nimport { store as blockEditorStore } from '../../store';\n\nexport function useWritingFlow() {\n\tconst [ before, ref, after ] = useTabNav();\n\tconst hasMultiSelection = useSelect(\n\t\t( select ) => select( blockEditorStore ).hasMultiSelection(),\n\t\t[]\n\t);\n\n\treturn [\n\t\tbefore,\n\t\tuseMergeRefs( [\n\t\t\tref,\n\t\t\tuseInput(),\n\t\t\tuseDragSelection(),\n\t\t\tuseSelectionObserver(),\n\t\t\tuseClickSelection(),\n\t\t\tuseMultiSelection(),\n\t\t\tuseSelectAll(),\n\t\t\tuseArrowNav(),\n\t\t\tuseRefEffect(\n\t\t\t\t( node ) => {\n\t\t\t\t\tnode.tabIndex = 0;\n\t\t\t\t\tnode.contentEditable = hasMultiSelection;\n\n\t\t\t\t\tif ( ! hasMultiSelection ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tnode.classList.add( 'has-multi-selection' );\n\t\t\t\t\tnode.setAttribute(\n\t\t\t\t\t\t'aria-label',\n\t\t\t\t\t\t__( 'Multiple selected blocks' )\n\t\t\t\t\t);\n\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tnode.classList.remove( 'has-multi-selection' );\n\t\t\t\t\t\tnode.removeAttribute( 'aria-label' );\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t[ hasMultiSelection ]\n\t\t\t),\n\t\t] ),\n\t\tafter,\n\t];\n}\n\nfunction WritingFlow( { children, ...props }, forwardedRef ) {\n\tconst [ before, ref, after ] = useWritingFlow();\n\treturn (\n\t\t<>\n\t\t\t{ before }\n\t\t\t<div\n\t\t\t\t{ ...props }\n\t\t\t\tref={ useMergeRefs( [ ref, forwardedRef ] ) }\n\t\t\t\tclassName={ classNames(\n\t\t\t\t\tprops.className,\n\t\t\t\t\t'block-editor-writing-flow'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t\t{ after }\n\t\t</>\n\t);\n}\n\n/**\n * Handles selection and navigation across blocks. This component should be\n * wrapped around BlockList.\n *\n * @param {Object} props Component properties.\n * @param {WPElement} props.children Children to be rendered.\n */\nexport default forwardRef( WritingFlow );\n"]}