@wordpress/block-editor 11.3.6 → 11.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (357) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/build/components/block-lock/modal.js +1 -0
  3. package/build/components/block-lock/modal.js.map +1 -1
  4. package/build/components/block-popover/inbetween.js +10 -33
  5. package/build/components/block-popover/inbetween.js.map +1 -1
  6. package/build/components/block-settings-menu/block-settings-dropdown.js +2 -2
  7. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  8. package/build/components/block-styles/index.js +2 -1
  9. package/build/components/block-styles/index.js.map +1 -1
  10. package/build/components/block-types-list/index.native.js +2 -0
  11. package/build/components/block-types-list/index.native.js.map +1 -1
  12. package/build/components/child-layout-control/index.js +107 -0
  13. package/build/components/child-layout-control/index.js.map +1 -0
  14. package/build/components/colors-gradients/control.js +6 -3
  15. package/build/components/colors-gradients/control.js.map +1 -1
  16. package/build/components/date-format-picker/index.js +3 -3
  17. package/build/components/date-format-picker/index.js.map +1 -1
  18. package/build/components/font-appearance-control/index.js +0 -3
  19. package/build/components/font-appearance-control/index.js.map +1 -1
  20. package/build/components/global-styles/dimensions-panel.js +594 -0
  21. package/build/components/global-styles/dimensions-panel.js.map +1 -0
  22. package/build/components/global-styles/hooks.js +142 -45
  23. package/build/components/global-styles/hooks.js.map +1 -1
  24. package/build/components/global-styles/index.js +38 -0
  25. package/build/components/global-styles/index.js.map +1 -1
  26. package/build/components/global-styles/typography-panel.js +434 -0
  27. package/build/components/global-styles/typography-panel.js.map +1 -0
  28. package/build/components/global-styles/use-global-styles-output.js +7 -3
  29. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  30. package/build/components/global-styles/utils.js +2 -0
  31. package/build/components/global-styles/utils.js.map +1 -1
  32. package/build/components/iframe/index.js +17 -11
  33. package/build/components/iframe/index.js.map +1 -1
  34. package/build/components/image-editor/aspect-ratio-dropdown.js +2 -1
  35. package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  36. package/build/components/image-size-control/index.js +6 -11
  37. package/build/components/image-size-control/index.js.map +1 -1
  38. package/build/components/index.native.js +23 -0
  39. package/build/components/index.native.js.map +1 -1
  40. package/build/components/inserter/block-patterns-tab.js +9 -15
  41. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  42. package/build/components/inserter/block-types-tab.native.js +4 -1
  43. package/build/components/inserter/block-types-tab.native.js.map +1 -1
  44. package/build/components/inserter/reusable-blocks-tab.native.js +4 -1
  45. package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  46. package/build/components/inserter/search-results.native.js +4 -1
  47. package/build/components/inserter/search-results.native.js.map +1 -1
  48. package/build/components/inspector-controls/block-support-tools-panel.js +1 -1
  49. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  50. package/build/components/inspector-controls/fill.js +38 -9
  51. package/build/components/inspector-controls/fill.js.map +1 -1
  52. package/build/components/link-control/index.js +55 -28
  53. package/build/components/link-control/index.js.map +1 -1
  54. package/build/components/link-control/settings-drawer.js +72 -30
  55. package/build/components/link-control/settings-drawer.js.map +1 -1
  56. package/build/components/link-control/settings.js +53 -0
  57. package/build/components/link-control/settings.js.map +1 -0
  58. package/build/components/list-view/block.js +4 -2
  59. package/build/components/list-view/block.js.map +1 -1
  60. package/build/components/list-view/expander.js +2 -1
  61. package/build/components/list-view/expander.js.map +1 -1
  62. package/build/components/list-view/index.js +6 -1
  63. package/build/components/list-view/index.js.map +1 -1
  64. package/build/components/off-canvas-editor/appender.js +5 -10
  65. package/build/components/off-canvas-editor/appender.js.map +1 -1
  66. package/build/components/off-canvas-editor/block-contents.js +3 -2
  67. package/build/components/off-canvas-editor/block-contents.js.map +1 -1
  68. package/build/components/off-canvas-editor/branch.js +1 -0
  69. package/build/components/off-canvas-editor/branch.js.map +1 -1
  70. package/build/components/off-canvas-editor/index.js +7 -3
  71. package/build/components/off-canvas-editor/index.js.map +1 -1
  72. package/build/components/off-canvas-editor/leaf-more-menu.js +24 -4
  73. package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
  74. package/build/components/off-canvas-editor/link-ui.js +2 -0
  75. package/build/components/off-canvas-editor/link-ui.js.map +1 -1
  76. package/build/components/responsive-block-control/index.js +1 -0
  77. package/build/components/responsive-block-control/index.js.map +1 -1
  78. package/build/components/rich-text/index.js +9 -45
  79. package/build/components/rich-text/index.js.map +1 -1
  80. package/build/components/rich-text/use-delete.js +73 -0
  81. package/build/components/rich-text/use-delete.js.map +1 -0
  82. package/build/components/rich-text/use-input-rules.js +14 -6
  83. package/build/components/rich-text/use-input-rules.js.map +1 -1
  84. package/build/components/url-input/index.js +2 -2
  85. package/build/components/url-input/index.js.map +1 -1
  86. package/build/components/writing-flow/use-selection-observer.js +4 -1
  87. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  88. package/build/hooks/align.js +3 -1
  89. package/build/hooks/align.js.map +1 -1
  90. package/build/hooks/dimensions.js +78 -190
  91. package/build/hooks/dimensions.js.map +1 -1
  92. package/build/hooks/duotone.js +94 -25
  93. package/build/hooks/duotone.js.map +1 -1
  94. package/build/hooks/font-family.js +2 -76
  95. package/build/hooks/font-family.js.map +1 -1
  96. package/build/hooks/font-size.js +3 -51
  97. package/build/hooks/font-size.js.map +1 -1
  98. package/build/hooks/gap.js +0 -201
  99. package/build/hooks/gap.js.map +1 -1
  100. package/build/hooks/index.js +2 -0
  101. package/build/hooks/index.js.map +1 -1
  102. package/build/hooks/layout.js +14 -5
  103. package/build/hooks/layout.js.map +1 -1
  104. package/build/hooks/line-height.js +0 -42
  105. package/build/hooks/line-height.js.map +1 -1
  106. package/build/hooks/margin.js +7 -163
  107. package/build/hooks/margin.js.map +1 -1
  108. package/build/hooks/padding.js +7 -163
  109. package/build/hooks/padding.js.map +1 -1
  110. package/build/hooks/typography.js +98 -128
  111. package/build/hooks/typography.js.map +1 -1
  112. package/build/hooks/utils.js +75 -0
  113. package/build/hooks/utils.js.map +1 -1
  114. package/build/layouts/flex.js +1 -0
  115. package/build/layouts/flex.js.map +1 -1
  116. package/build/store/actions.js +24 -12
  117. package/build/store/actions.js.map +1 -1
  118. package/build/store/reducer.js +53 -47
  119. package/build/store/reducer.js.map +1 -1
  120. package/build/store/selectors.js +22 -1
  121. package/build/store/selectors.js.map +1 -1
  122. package/build/utils/parse-css-unit-to-px.js +36 -3
  123. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  124. package/build-module/components/block-lock/modal.js +1 -0
  125. package/build-module/components/block-lock/modal.js.map +1 -1
  126. package/build-module/components/block-popover/inbetween.js +10 -33
  127. package/build-module/components/block-popover/inbetween.js.map +1 -1
  128. package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
  129. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  130. package/build-module/components/block-styles/index.js +2 -1
  131. package/build-module/components/block-styles/index.js.map +1 -1
  132. package/build-module/components/block-types-list/index.native.js +2 -0
  133. package/build-module/components/block-types-list/index.native.js.map +1 -1
  134. package/build-module/components/child-layout-control/index.js +98 -0
  135. package/build-module/components/child-layout-control/index.js.map +1 -0
  136. package/build-module/components/colors-gradients/control.js +6 -3
  137. package/build-module/components/colors-gradients/control.js.map +1 -1
  138. package/build-module/components/date-format-picker/index.js +4 -4
  139. package/build-module/components/date-format-picker/index.js.map +1 -1
  140. package/build-module/components/font-appearance-control/index.js +2 -1
  141. package/build-module/components/font-appearance-control/index.js.map +1 -1
  142. package/build-module/components/global-styles/dimensions-panel.js +574 -0
  143. package/build-module/components/global-styles/dimensions-panel.js.map +1 -0
  144. package/build-module/components/global-styles/hooks.js +138 -46
  145. package/build-module/components/global-styles/hooks.js.map +1 -1
  146. package/build-module/components/global-styles/index.js +3 -1
  147. package/build-module/components/global-styles/index.js.map +1 -1
  148. package/build-module/components/global-styles/typography-panel.js +415 -0
  149. package/build-module/components/global-styles/typography-panel.js.map +1 -0
  150. package/build-module/components/global-styles/use-global-styles-output.js +7 -3
  151. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  152. package/build-module/components/global-styles/utils.js +2 -0
  153. package/build-module/components/global-styles/utils.js.map +1 -1
  154. package/build-module/components/iframe/index.js +17 -11
  155. package/build-module/components/iframe/index.js.map +1 -1
  156. package/build-module/components/image-editor/aspect-ratio-dropdown.js +2 -1
  157. package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  158. package/build-module/components/image-size-control/index.js +7 -12
  159. package/build-module/components/image-size-control/index.js.map +1 -1
  160. package/build-module/components/index.native.js +2 -1
  161. package/build-module/components/index.native.js.map +1 -1
  162. package/build-module/components/inserter/block-patterns-tab.js +9 -15
  163. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  164. package/build-module/components/inserter/block-types-tab.native.js +3 -1
  165. package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
  166. package/build-module/components/inserter/reusable-blocks-tab.native.js +3 -1
  167. package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  168. package/build-module/components/inserter/search-results.native.js +3 -1
  169. package/build-module/components/inserter/search-results.native.js.map +1 -1
  170. package/build-module/components/inspector-controls/block-support-tools-panel.js +1 -1
  171. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  172. package/build-module/components/inspector-controls/fill.js +39 -9
  173. package/build-module/components/inspector-controls/fill.js.map +1 -1
  174. package/build-module/components/link-control/index.js +56 -28
  175. package/build-module/components/link-control/index.js.map +1 -1
  176. package/build-module/components/link-control/settings-drawer.js +68 -30
  177. package/build-module/components/link-control/settings-drawer.js.map +1 -1
  178. package/build-module/components/link-control/settings.js +44 -0
  179. package/build-module/components/link-control/settings.js.map +1 -0
  180. package/build-module/components/list-view/block.js +4 -2
  181. package/build-module/components/list-view/block.js.map +1 -1
  182. package/build-module/components/list-view/expander.js +2 -1
  183. package/build-module/components/list-view/expander.js.map +1 -1
  184. package/build-module/components/list-view/index.js +6 -1
  185. package/build-module/components/list-view/index.js.map +1 -1
  186. package/build-module/components/off-canvas-editor/appender.js +5 -10
  187. package/build-module/components/off-canvas-editor/appender.js.map +1 -1
  188. package/build-module/components/off-canvas-editor/block-contents.js +3 -2
  189. package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
  190. package/build-module/components/off-canvas-editor/branch.js +1 -0
  191. package/build-module/components/off-canvas-editor/branch.js.map +1 -1
  192. package/build-module/components/off-canvas-editor/index.js +7 -3
  193. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  194. package/build-module/components/off-canvas-editor/leaf-more-menu.js +27 -7
  195. package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
  196. package/build-module/components/off-canvas-editor/link-ui.js +2 -0
  197. package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
  198. package/build-module/components/responsive-block-control/index.js +1 -0
  199. package/build-module/components/responsive-block-control/index.js.map +1 -1
  200. package/build-module/components/rich-text/index.js +9 -45
  201. package/build-module/components/rich-text/index.js.map +1 -1
  202. package/build-module/components/rich-text/use-delete.js +62 -0
  203. package/build-module/components/rich-text/use-delete.js.map +1 -0
  204. package/build-module/components/rich-text/use-input-rules.js +14 -6
  205. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  206. package/build-module/components/url-input/index.js +2 -2
  207. package/build-module/components/url-input/index.js.map +1 -1
  208. package/build-module/components/writing-flow/use-selection-observer.js +4 -1
  209. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  210. package/build-module/hooks/align.js +3 -1
  211. package/build-module/hooks/align.js.map +1 -1
  212. package/build-module/hooks/dimensions.js +81 -187
  213. package/build-module/hooks/dimensions.js.map +1 -1
  214. package/build-module/hooks/duotone.js +86 -24
  215. package/build-module/hooks/duotone.js.map +1 -1
  216. package/build-module/hooks/font-family.js +3 -69
  217. package/build-module/hooks/font-family.js.map +1 -1
  218. package/build-module/hooks/font-size.js +6 -47
  219. package/build-module/hooks/font-size.js.map +1 -1
  220. package/build-module/hooks/gap.js +0 -182
  221. package/build-module/hooks/gap.js.map +1 -1
  222. package/build-module/hooks/index.js +1 -0
  223. package/build-module/hooks/index.js.map +1 -1
  224. package/build-module/hooks/layout.js +14 -5
  225. package/build-module/hooks/layout.js.map +1 -1
  226. package/build-module/hooks/line-height.js +0 -38
  227. package/build-module/hooks/line-height.js.map +1 -1
  228. package/build-module/hooks/margin.js +4 -143
  229. package/build-module/hooks/margin.js.map +1 -1
  230. package/build-module/hooks/padding.js +4 -143
  231. package/build-module/hooks/padding.js.map +1 -1
  232. package/build-module/hooks/typography.js +97 -123
  233. package/build-module/hooks/typography.js.map +1 -1
  234. package/build-module/hooks/utils.js +70 -0
  235. package/build-module/hooks/utils.js.map +1 -1
  236. package/build-module/layouts/flex.js +1 -0
  237. package/build-module/layouts/flex.js.map +1 -1
  238. package/build-module/store/actions.js +24 -12
  239. package/build-module/store/actions.js.map +1 -1
  240. package/build-module/store/reducer.js +53 -45
  241. package/build-module/store/reducer.js.map +1 -1
  242. package/build-module/store/selectors.js +22 -1
  243. package/build-module/store/selectors.js.map +1 -1
  244. package/build-module/utils/parse-css-unit-to-px.js +36 -3
  245. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  246. package/build-style/style-rtl.css +54 -64
  247. package/build-style/style.css +54 -64
  248. package/package.json +31 -31
  249. package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +24 -24
  250. package/src/components/block-lock/modal.js +1 -0
  251. package/src/components/block-lock/style.scss +0 -9
  252. package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +20 -20
  253. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +15 -15
  254. package/src/components/block-popover/inbetween.js +21 -53
  255. package/src/components/block-settings-menu/block-settings-dropdown.js +4 -1
  256. package/src/components/block-styles/index.js +5 -1
  257. package/src/components/block-types-list/index.native.js +2 -0
  258. package/src/components/child-layout-control/index.js +106 -0
  259. package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
  260. package/src/components/colors-gradients/control.js +3 -0
  261. package/src/components/date-format-picker/index.js +6 -8
  262. package/src/components/date-format-picker/style.scss +0 -5
  263. package/src/components/font-appearance-control/index.js +1 -1
  264. package/src/components/global-styles/dimensions-panel.js +627 -0
  265. package/src/components/global-styles/hooks.js +229 -66
  266. package/src/components/global-styles/index.js +9 -0
  267. package/src/components/global-styles/typography-panel.js +428 -0
  268. package/src/components/global-styles/use-global-styles-output.js +10 -5
  269. package/src/components/global-styles/utils.js +2 -0
  270. package/src/components/iframe/index.js +20 -18
  271. package/src/components/image-editor/aspect-ratio-dropdown.js +1 -0
  272. package/src/components/image-size-control/index.js +10 -12
  273. package/src/components/image-size-control/style.scss +3 -21
  274. package/src/components/index.native.js +5 -0
  275. package/src/components/inner-blocks/test/__snapshots__/index.js.snap +1 -1
  276. package/src/components/inserter/block-patterns-tab.js +9 -23
  277. package/src/components/inserter/block-types-tab.native.js +2 -0
  278. package/src/components/inserter/reusable-blocks-tab.native.js +2 -0
  279. package/src/components/inserter/search-results.native.js +2 -0
  280. package/src/components/inserter/test/__snapshots__/index.native.js.snap +15 -15
  281. package/src/components/inspector-controls/block-support-tools-panel.js +0 -1
  282. package/src/components/inspector-controls/fill.js +32 -8
  283. package/src/components/link-control/index.js +69 -34
  284. package/src/components/link-control/settings-drawer.js +85 -29
  285. package/src/components/link-control/settings.js +42 -0
  286. package/src/components/link-control/style.scss +63 -37
  287. package/src/components/link-control/test/index.js +347 -9
  288. package/src/components/list-view/block.js +7 -1
  289. package/src/components/list-view/expander.js +1 -0
  290. package/src/components/list-view/index.js +5 -0
  291. package/src/components/media-replace-flow/style.scss +7 -9
  292. package/src/components/media-replace-flow/test/index.js +1 -1
  293. package/src/components/off-canvas-editor/appender.js +13 -16
  294. package/src/components/off-canvas-editor/block-contents.js +2 -1
  295. package/src/components/off-canvas-editor/branch.js +1 -0
  296. package/src/components/off-canvas-editor/index.js +8 -2
  297. package/src/components/off-canvas-editor/leaf-more-menu.js +52 -15
  298. package/src/components/off-canvas-editor/link-ui.js +2 -0
  299. package/src/components/responsive-block-control/index.js +1 -0
  300. package/src/components/rich-text/index.js +8 -46
  301. package/src/components/rich-text/use-delete.js +59 -0
  302. package/src/components/rich-text/use-input-rules.js +13 -5
  303. package/src/components/url-input/index.js +3 -2
  304. package/src/components/url-popover/stories/index.js +1 -0
  305. package/src/components/writing-flow/use-selection-observer.js +5 -1
  306. package/src/hooks/align.js +1 -1
  307. package/src/hooks/dimensions.js +97 -269
  308. package/src/hooks/duotone.js +100 -30
  309. package/src/hooks/font-family.js +0 -58
  310. package/src/hooks/font-size.js +1 -36
  311. package/src/hooks/gap.js +0 -201
  312. package/src/hooks/index.js +1 -0
  313. package/src/hooks/layout.js +19 -6
  314. package/src/hooks/line-height.js +0 -33
  315. package/src/hooks/margin.js +1 -164
  316. package/src/hooks/padding.js +1 -163
  317. package/src/hooks/test/__snapshots__/align.native.js.snap +24 -24
  318. package/src/hooks/test/duotone.js +102 -0
  319. package/src/hooks/typography.js +112 -213
  320. package/src/hooks/utils.js +90 -0
  321. package/src/layouts/flex.js +1 -0
  322. package/src/store/actions.js +12 -4
  323. package/src/store/reducer.js +68 -43
  324. package/src/store/selectors.js +20 -1
  325. package/src/store/test/actions.js +4 -2
  326. package/src/utils/parse-css-unit-to-px.js +35 -5
  327. package/src/utils/test/parse-css-unit-to-px.js +12 -0
  328. package/build/hooks/child-layout.js +0 -213
  329. package/build/hooks/child-layout.js.map +0 -1
  330. package/build/hooks/font-appearance.js +0 -188
  331. package/build/hooks/font-appearance.js.map +0 -1
  332. package/build/hooks/letter-spacing.js +0 -129
  333. package/build/hooks/letter-spacing.js.map +0 -1
  334. package/build/hooks/min-height.js +0 -139
  335. package/build/hooks/min-height.js.map +0 -1
  336. package/build/hooks/text-decoration.js +0 -130
  337. package/build/hooks/text-decoration.js.map +0 -1
  338. package/build/hooks/text-transform.js +0 -130
  339. package/build/hooks/text-transform.js.map +0 -1
  340. package/build-module/hooks/child-layout.js +0 -193
  341. package/build-module/hooks/child-layout.js.map +0 -1
  342. package/build-module/hooks/font-appearance.js +0 -161
  343. package/build-module/hooks/font-appearance.js.map +0 -1
  344. package/build-module/hooks/letter-spacing.js +0 -107
  345. package/build-module/hooks/letter-spacing.js.map +0 -1
  346. package/build-module/hooks/min-height.js +0 -116
  347. package/build-module/hooks/min-height.js.map +0 -1
  348. package/build-module/hooks/text-decoration.js +0 -108
  349. package/build-module/hooks/text-decoration.js.map +0 -1
  350. package/build-module/hooks/text-transform.js +0 -108
  351. package/build-module/hooks/text-transform.js.map +0 -1
  352. package/src/hooks/child-layout.js +0 -195
  353. package/src/hooks/font-appearance.js +0 -146
  354. package/src/hooks/letter-spacing.js +0 -101
  355. package/src/hooks/min-height.js +0 -104
  356. package/src/hooks/text-decoration.js +0 -102
  357. package/src/hooks/text-transform.js +0 -101
@@ -38,7 +38,8 @@ function InspectorControlsFill(_ref) {
38
38
  let {
39
39
  children,
40
40
  group = 'default',
41
- __experimentalGroup
41
+ __experimentalGroup,
42
+ resetAllFilter
42
43
  } = _ref;
43
44
 
44
45
  if (__experimentalGroup) {
@@ -65,14 +66,42 @@ function InspectorControlsFill(_ref) {
65
66
  return (0, _element.createElement)(_components.__experimentalStyleProvider, {
66
67
  document: document
67
68
  }, (0, _element.createElement)(Fill, null, fillProps => {
68
- // Children passed to InspectorControlsFill will not have
69
- // access to any React Context whose Provider is part of
70
- // the InspectorControlsSlot tree. So we re-create the
71
- // Provider in this subtree.
72
- const value = !(0, _lodash.isEmpty)(fillProps) ? fillProps : null;
73
- return (0, _element.createElement)(_components.__experimentalToolsPanelContext.Provider, {
74
- value: value
75
- }, children);
69
+ return (0, _element.createElement)(ToolsPanelInspectorControl, {
70
+ fillProps: fillProps,
71
+ children: children,
72
+ resetAllFilter: resetAllFilter
73
+ });
76
74
  }));
77
75
  }
76
+
77
+ function ToolsPanelInspectorControl(_ref2) {
78
+ let {
79
+ children,
80
+ resetAllFilter,
81
+ fillProps
82
+ } = _ref2;
83
+ const {
84
+ registerResetAllFilter,
85
+ deregisterResetAllFilter
86
+ } = fillProps;
87
+ (0, _element.useEffect)(() => {
88
+ if (resetAllFilter && registerResetAllFilter) {
89
+ registerResetAllFilter(resetAllFilter);
90
+ }
91
+
92
+ return () => {
93
+ if (resetAllFilter && deregisterResetAllFilter) {
94
+ deregisterResetAllFilter(resetAllFilter);
95
+ }
96
+ };
97
+ }, [resetAllFilter, registerResetAllFilter, deregisterResetAllFilter]); // Children passed to InspectorControlsFill will not have
98
+ // access to any React Context whose Provider is part of
99
+ // the InspectorControlsSlot tree. So we re-create the
100
+ // Provider in this subtree.
101
+
102
+ const value = !(0, _lodash.isEmpty)(fillProps) ? fillProps : null;
103
+ return (0, _element.createElement)(_components.__experimentalToolsPanelContext.Provider, {
104
+ value: value
105
+ }, children);
106
+ }
78
107
  //# sourceMappingURL=fill.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/fill.js"],"names":["InspectorControlsFill","children","group","__experimentalGroup","since","version","alternative","isDisplayed","Fill","groups","document","fillProps","value"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AAIA;;AACA;;AAKA;;AACA;;AAnBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;AAIe,SAASA,qBAAT,OAIX;AAAA;;AAAA,MAJ2C;AAC9CC,IAAAA,QAD8C;AAE9CC,IAAAA,KAAK,GAAG,SAFsC;AAG9CC,IAAAA;AAH8C,GAI3C;;AACH,MAAKA,mBAAL,EAA2B;AAC1B,6BACC,2DADD,EAEC;AACCC,MAAAA,KAAK,EAAE,KADR;AAECC,MAAAA,OAAO,EAAE,KAFV;AAGCC,MAAAA,WAAW,EAAE;AAHd,KAFD;AAQAJ,IAAAA,KAAK,GAAGC,mBAAR;AACA;;AAED,QAAMI,WAAW,GAAG,uCAApB;AACA,QAAMC,IAAI,oBAAGC,gBAAQP,KAAR,CAAH,kDAAG,cAAiBM,IAA9B;;AACA,MAAK,CAAEA,IAAP,EAAc;AACb,mHAAU,mCAAmCN,KAAO,aAApD;AACA,WAAO,IAAP;AACA;;AACD,MAAK,CAAEK,WAAP,EAAqB;AACpB,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,uCAAD;AAAe,IAAA,QAAQ,EAAGG;AAA1B,KACC,4BAAC,IAAD,QACKC,SAAF,IAAiB;AAClB;AACA;AACA;AACA;AACA,UAAMC,KAAK,GAAG,CAAE,qBAASD,SAAT,CAAF,GAAyBA,SAAzB,GAAqC,IAAnD;AACA,WACC,4BAAC,2CAAD,CAAmB,QAAnB;AAA4B,MAAA,KAAK,EAAGC;AAApC,OACGX,QADH,CADD;AAKA,GAZF,CADD,CADD;AAkBA","sourcesContent":["/**\n * External dependencies\n */\nimport { isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalStyleProvider as StyleProvider,\n\t__experimentalToolsPanelContext as ToolsPanelContext,\n} from '@wordpress/components';\nimport warning from '@wordpress/warning';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport useDisplayBlockControls from '../use-display-block-controls';\nimport groups from './groups';\n\nexport default function InspectorControlsFill( {\n\tchildren,\n\tgroup = 'default',\n\t__experimentalGroup,\n} ) {\n\tif ( __experimentalGroup ) {\n\t\tdeprecated(\n\t\t\t'`__experimentalGroup` property in `InspectorControlsFill`',\n\t\t\t{\n\t\t\t\tsince: '6.2',\n\t\t\t\tversion: '6.4',\n\t\t\t\talternative: '`group`',\n\t\t\t}\n\t\t);\n\t\tgroup = __experimentalGroup;\n\t}\n\n\tconst isDisplayed = useDisplayBlockControls();\n\tconst Fill = groups[ group ]?.Fill;\n\tif ( ! Fill ) {\n\t\twarning( `Unknown InspectorControl group \"${ group }\" provided.` );\n\t\treturn null;\n\t}\n\tif ( ! isDisplayed ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<StyleProvider document={ document }>\n\t\t\t<Fill>\n\t\t\t\t{ ( fillProps ) => {\n\t\t\t\t\t// Children passed to InspectorControlsFill will not have\n\t\t\t\t\t// access to any React Context whose Provider is part of\n\t\t\t\t\t// the InspectorControlsSlot tree. So we re-create the\n\t\t\t\t\t// Provider in this subtree.\n\t\t\t\t\tconst value = ! isEmpty( fillProps ) ? fillProps : null;\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<ToolsPanelContext.Provider value={ value }>\n\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t</ToolsPanelContext.Provider>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t</Fill>\n\t\t</StyleProvider>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/fill.js"],"names":["InspectorControlsFill","children","group","__experimentalGroup","resetAllFilter","since","version","alternative","isDisplayed","Fill","groups","document","fillProps","ToolsPanelInspectorControl","registerResetAllFilter","deregisterResetAllFilter","value"],"mappings":";;;;;;;;;AAcA;;AAXA;;AAKA;;AAIA;;AACA;;AAMA;;AACA;;AApBA;AACA;AACA;;AAGA;AACA;AACA;;AASA;AACA;AACA;AAIe,SAASA,qBAAT,OAKX;AAAA;;AAAA,MAL2C;AAC9CC,IAAAA,QAD8C;AAE9CC,IAAAA,KAAK,GAAG,SAFsC;AAG9CC,IAAAA,mBAH8C;AAI9CC,IAAAA;AAJ8C,GAK3C;;AACH,MAAKD,mBAAL,EAA2B;AAC1B,6BACC,2DADD,EAEC;AACCE,MAAAA,KAAK,EAAE,KADR;AAECC,MAAAA,OAAO,EAAE,KAFV;AAGCC,MAAAA,WAAW,EAAE;AAHd,KAFD;AAQAL,IAAAA,KAAK,GAAGC,mBAAR;AACA;;AAED,QAAMK,WAAW,GAAG,uCAApB;AACA,QAAMC,IAAI,oBAAGC,gBAAQR,KAAR,CAAH,kDAAG,cAAiBO,IAA9B;;AACA,MAAK,CAAEA,IAAP,EAAc;AACb,mHAAU,mCAAmCP,KAAO,aAApD;AACA,WAAO,IAAP;AACA;;AACD,MAAK,CAAEM,WAAP,EAAqB;AACpB,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,uCAAD;AAAe,IAAA,QAAQ,EAAGG;AAA1B,KACC,4BAAC,IAAD,QACKC,SAAF,IAAiB;AAClB,WACC,4BAAC,0BAAD;AACC,MAAA,SAAS,EAAGA,SADb;AAEC,MAAA,QAAQ,EAAGX,QAFZ;AAGC,MAAA,cAAc,EAAGG;AAHlB,MADD;AAOA,GATF,CADD,CADD;AAeA;;AAED,SAASS,0BAAT,QAA+E;AAAA,MAA1C;AAAEZ,IAAAA,QAAF;AAAYG,IAAAA,cAAZ;AAA4BQ,IAAAA;AAA5B,GAA0C;AAC9E,QAAM;AAAEE,IAAAA,sBAAF;AAA0BC,IAAAA;AAA1B,MAAuDH,SAA7D;AACA,0BAAW,MAAM;AAChB,QAAKR,cAAc,IAAIU,sBAAvB,EAAgD;AAC/CA,MAAAA,sBAAsB,CAAEV,cAAF,CAAtB;AACA;;AACD,WAAO,MAAM;AACZ,UAAKA,cAAc,IAAIW,wBAAvB,EAAkD;AACjDA,QAAAA,wBAAwB,CAAEX,cAAF,CAAxB;AACA;AACD,KAJD;AAKA,GATD,EASG,CAAEA,cAAF,EAAkBU,sBAAlB,EAA0CC,wBAA1C,CATH,EAF8E,CAa9E;AACA;AACA;AACA;;AACA,QAAMC,KAAK,GAAG,CAAE,qBAASJ,SAAT,CAAF,GAAyBA,SAAzB,GAAqC,IAAnD;AACA,SACC,4BAAC,2CAAD,CAAmB,QAAnB;AAA4B,IAAA,KAAK,EAAGI;AAApC,KACGf,QADH,CADD;AAKA","sourcesContent":["/**\n * External dependencies\n */\nimport { isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalStyleProvider as StyleProvider,\n\t__experimentalToolsPanelContext as ToolsPanelContext,\n} from '@wordpress/components';\nimport warning from '@wordpress/warning';\nimport deprecated from '@wordpress/deprecated';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useDisplayBlockControls from '../use-display-block-controls';\nimport groups from './groups';\n\nexport default function InspectorControlsFill( {\n\tchildren,\n\tgroup = 'default',\n\t__experimentalGroup,\n\tresetAllFilter,\n} ) {\n\tif ( __experimentalGroup ) {\n\t\tdeprecated(\n\t\t\t'`__experimentalGroup` property in `InspectorControlsFill`',\n\t\t\t{\n\t\t\t\tsince: '6.2',\n\t\t\t\tversion: '6.4',\n\t\t\t\talternative: '`group`',\n\t\t\t}\n\t\t);\n\t\tgroup = __experimentalGroup;\n\t}\n\n\tconst isDisplayed = useDisplayBlockControls();\n\tconst Fill = groups[ group ]?.Fill;\n\tif ( ! Fill ) {\n\t\twarning( `Unknown InspectorControl group \"${ group }\" provided.` );\n\t\treturn null;\n\t}\n\tif ( ! isDisplayed ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<StyleProvider document={ document }>\n\t\t\t<Fill>\n\t\t\t\t{ ( fillProps ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<ToolsPanelInspectorControl\n\t\t\t\t\t\t\tfillProps={ fillProps }\n\t\t\t\t\t\t\tchildren={ children }\n\t\t\t\t\t\t\tresetAllFilter={ resetAllFilter }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t</Fill>\n\t\t</StyleProvider>\n\t);\n}\n\nfunction ToolsPanelInspectorControl( { children, resetAllFilter, fillProps } ) {\n\tconst { registerResetAllFilter, deregisterResetAllFilter } = fillProps;\n\tuseEffect( () => {\n\t\tif ( resetAllFilter && registerResetAllFilter ) {\n\t\t\tregisterResetAllFilter( resetAllFilter );\n\t\t}\n\t\treturn () => {\n\t\t\tif ( resetAllFilter && deregisterResetAllFilter ) {\n\t\t\t\tderegisterResetAllFilter( resetAllFilter );\n\t\t\t}\n\t\t};\n\t}, [ resetAllFilter, registerResetAllFilter, deregisterResetAllFilter ] );\n\n\t// Children passed to InspectorControlsFill will not have\n\t// access to any React Context whose Provider is part of\n\t// the InspectorControlsSlot tree. So we re-create the\n\t// Provider in this subtree.\n\tconst value = ! isEmpty( fillProps ) ? fillProps : null;\n\treturn (\n\t\t<ToolsPanelContext.Provider value={ value }>\n\t\t\t{ children }\n\t\t</ToolsPanelContext.Provider>\n\t);\n}\n"]}
@@ -13,8 +13,6 @@ var _classnames = _interopRequireDefault(require("classnames"));
13
13
 
14
14
  var _components = require("@wordpress/components");
15
15
 
16
- var _icons = require("@wordpress/icons");
17
-
18
16
  var _i18n = require("@wordpress/i18n");
19
17
 
20
18
  var _dom = require("@wordpress/dom");
@@ -133,7 +131,7 @@ const noop = () => {};
133
131
 
134
132
 
135
133
  function LinkControl(_ref) {
136
- var _currentUrlInputValue, _value$url, _value$url$trim;
134
+ var _value$url, _value$url$trim, _currentUrlInputValue;
137
135
 
138
136
  let {
139
137
  searchInputPlaceholder,
@@ -141,6 +139,7 @@ function LinkControl(_ref) {
141
139
  settings = _constants.DEFAULT_LINK_SETTINGS,
142
140
  onChange = noop,
143
141
  onRemove,
142
+ onCancel,
144
143
  noDirectEntry = false,
145
144
  showSuggestions = true,
146
145
  showInitialSuggestions,
@@ -164,6 +163,7 @@ function LinkControl(_ref) {
164
163
  const wrapperNode = (0, _element.useRef)();
165
164
  const textInputRef = (0, _element.useRef)();
166
165
  const isEndingEditWithFocus = (0, _element.useRef)(false);
166
+ const [settingsOpen, setSettingsOpen] = (0, _element.useState)(false);
167
167
  const [internalUrlInputValue, setInternalUrlInputValue] = (0, _useInternalInputValue.default)((value === null || value === void 0 ? void 0 : value.url) || '');
168
168
  const [internalTextInputValue, setInternalTextInputValue] = (0, _useInternalInputValue.default)((value === null || value === void 0 ? void 0 : value.title) || '');
169
169
  const [isEditingLink, setIsEditingLink] = (0, _element.useState)(forceIsEditingLink !== undefined ? forceIsEditingLink : !value || !value.url);
@@ -201,6 +201,7 @@ function LinkControl(_ref) {
201
201
  nextFocusTarget.focus();
202
202
  isEndingEditWithFocus.current = false;
203
203
  }, [isEditingLink, isCreatingPage]);
204
+ const hasLinkValue = (value === null || value === void 0 ? void 0 : (_value$url = value.url) === null || _value$url === void 0 ? void 0 : (_value$url$trim = _value$url.trim()) === null || _value$url$trim === void 0 ? void 0 : _value$url$trim.length) > 0;
204
205
  /**
205
206
  * Cancels editing state and marks that focus may need to be restored after
206
207
  * the next render, if focus was within the wrapper when editing finished.
@@ -210,6 +211,7 @@ function LinkControl(_ref) {
210
211
  var _wrapperNode$current;
211
212
 
212
213
  isEndingEditWithFocus.current = !!((_wrapperNode$current = wrapperNode.current) !== null && _wrapperNode$current !== void 0 && _wrapperNode$current.contains(wrapperNode.current.ownerDocument.activeElement));
214
+ setSettingsOpen(false);
213
215
  setIsEditingLink(false);
214
216
  };
215
217
 
@@ -243,34 +245,49 @@ function LinkControl(_ref) {
243
245
  }
244
246
  };
245
247
 
248
+ const resetInternalValues = () => {
249
+ setInternalUrlInputValue(value === null || value === void 0 ? void 0 : value.url);
250
+ setInternalTextInputValue(value === null || value === void 0 ? void 0 : value.title);
251
+ };
252
+
253
+ const handleCancel = event => {
254
+ event.preventDefault();
255
+ event.stopPropagation(); // Ensure that any unsubmitted input changes are reset.
256
+
257
+ resetInternalValues();
258
+
259
+ if (hasLinkValue) {
260
+ // If there is a link then exist editing mode and show preview.
261
+ stopEditing();
262
+ } else {
263
+ // If there is no link value, then remove the link entirely.
264
+ onRemove === null || onRemove === void 0 ? void 0 : onRemove();
265
+ }
266
+
267
+ onCancel === null || onCancel === void 0 ? void 0 : onCancel();
268
+ };
269
+
246
270
  const currentUrlInputValue = propInputValue || internalUrlInputValue;
247
271
  const currentInputIsEmpty = !(currentUrlInputValue !== null && currentUrlInputValue !== void 0 && (_currentUrlInputValue = currentUrlInputValue.trim()) !== null && _currentUrlInputValue !== void 0 && _currentUrlInputValue.length);
248
272
  const shownUnlinkControl = onRemove && value && !isEditingLink && !isCreatingPage;
249
- const showSettingsDrawer = !!(settings !== null && settings !== void 0 && settings.length); // Only show text control once a URL value has been committed
273
+ const showSettings = !!(settings !== null && settings !== void 0 && settings.length); // Only show text control once a URL value has been committed
250
274
  // and it isn't just empty whitespace.
251
275
  // See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.
252
276
 
253
- const showTextControl = (value === null || value === void 0 ? void 0 : (_value$url = value.url) === null || _value$url === void 0 ? void 0 : (_value$url$trim = _value$url.trim()) === null || _value$url$trim === void 0 ? void 0 : _value$url$trim.length) > 0 && hasTextControl;
277
+ const showTextControl = hasLinkValue && hasTextControl;
278
+ const isEditing = (isEditingLink || !value) && !isCreatingPage;
254
279
  return (0, _element.createElement)("div", {
255
280
  tabIndex: -1,
256
281
  ref: wrapperNode,
257
282
  className: "block-editor-link-control"
258
283
  }, isCreatingPage && (0, _element.createElement)("div", {
259
284
  className: "block-editor-link-control__loading"
260
- }, (0, _element.createElement)(_components.Spinner, null), " ", (0, _i18n.__)('Creating'), "\u2026"), (isEditingLink || !value) && !isCreatingPage && (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)("div", {
285
+ }, (0, _element.createElement)(_components.Spinner, null), " ", (0, _i18n.__)('Creating'), "\u2026"), isEditing && (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)("div", {
261
286
  className: (0, _classnames.default)({
262
287
  'block-editor-link-control__search-input-wrapper': true,
263
288
  'has-text-control': showTextControl
264
289
  })
265
- }, showTextControl && (0, _element.createElement)(_components.TextControl, {
266
- __nextHasNoMarginBottom: true,
267
- ref: textInputRef,
268
- className: "block-editor-link-control__field block-editor-link-control__text-content",
269
- label: "Text",
270
- value: internalTextInputValue,
271
- onChange: setInternalTextInputValue,
272
- onKeyDown: handleSubmitWithEnter
273
- }), (0, _element.createElement)(_searchInput.default, {
290
+ }, (0, _element.createElement)(_searchInput.default, {
274
291
  currentLink: value,
275
292
  className: "block-editor-link-control__field block-editor-link-control__search-input",
276
293
  placeholder: searchInputPlaceholder,
@@ -286,16 +303,7 @@ function LinkControl(_ref) {
286
303
  withURLSuggestion: !noURLSuggestion,
287
304
  createSuggestionButtonText: createSuggestionButtonText,
288
305
  useLabel: showTextControl
289
- }, (0, _element.createElement)("div", {
290
- className: "block-editor-link-control__search-actions"
291
- }, (0, _element.createElement)(_components.Button, {
292
- onClick: handleSubmit,
293
- label: (0, _i18n.__)('Submit'),
294
- icon: _icons.keyboardReturn,
295
- className: "block-editor-link-control__search-submit",
296
- disabled: currentInputIsEmpty // Disallow submitting empty values.
297
-
298
- })))), errorMessage && (0, _element.createElement)(_components.Notice, {
306
+ })), errorMessage && (0, _element.createElement)(_components.Notice, {
299
307
  className: "block-editor-link-control__search-error",
300
308
  status: "error",
301
309
  isDismissible: false
@@ -307,13 +315,32 @@ function LinkControl(_ref) {
307
315
  hasRichPreviews: hasRichPreviews,
308
316
  hasUnlinkControl: shownUnlinkControl,
309
317
  onRemove: onRemove
310
- }), showSettingsDrawer && (0, _element.createElement)("div", {
318
+ }), isEditing && (0, _element.createElement)("div", {
311
319
  className: "block-editor-link-control__tools"
312
- }, (0, _element.createElement)(_settingsDrawer.default, {
320
+ }, (showSettings || showTextControl) && (0, _element.createElement)(_settingsDrawer.default, {
321
+ settingsOpen: settingsOpen,
322
+ setSettingsOpen: setSettingsOpen,
323
+ showTextControl: showTextControl,
324
+ showSettings: showSettings,
325
+ textInputRef: textInputRef,
326
+ internalTextInputValue: internalTextInputValue,
327
+ setInternalTextInputValue: setInternalTextInputValue,
328
+ handleSubmitWithEnter: handleSubmitWithEnter,
313
329
  value: value,
314
330
  settings: settings,
315
331
  onChange: onChange
316
- })), renderControlBottom && renderControlBottom());
332
+ }), (0, _element.createElement)("div", {
333
+ className: "block-editor-link-control__search-actions"
334
+ }, (0, _element.createElement)(_components.Button, {
335
+ variant: "primary",
336
+ onClick: handleSubmit,
337
+ className: "xblock-editor-link-control__search-submit",
338
+ disabled: currentInputIsEmpty // Disallow submitting empty values.
339
+
340
+ }, (0, _i18n.__)('Apply')), (0, _element.createElement)(_components.Button, {
341
+ variant: "tertiary",
342
+ onClick: handleCancel
343
+ }, (0, _i18n.__)('Cancel')))), renderControlBottom && renderControlBottom());
317
344
  }
318
345
 
319
346
  LinkControl.ViewerFill = _viewerSlot.ViewerFill;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/index.js"],"names":["noop","LinkControl","searchInputPlaceholder","value","settings","DEFAULT_LINK_SETTINGS","onChange","onRemove","noDirectEntry","showSuggestions","showInitialSuggestions","forceIsEditingLink","createSuggestion","withCreateSuggestion","inputValue","propInputValue","suggestionsQuery","noURLSuggestion","createSuggestionButtonText","hasRichPreviews","hasTextControl","renderControlBottom","undefined","isMounting","wrapperNode","textInputRef","isEndingEditWithFocus","internalUrlInputValue","setInternalUrlInputValue","url","internalTextInputValue","setInternalTextInputValue","title","isEditingLink","setIsEditingLink","createPage","isCreatingPage","errorMessage","current","whichFocusTargetIndex","nextFocusTarget","focus","focusable","find","stopEditing","contains","ownerDocument","activeElement","handleSelectSuggestion","updatedValue","handleSubmit","currentUrlInputValue","handleSubmitWithEnter","event","keyCode","ENTER","currentInputIsEmpty","preventDefault","trim","length","shownUnlinkControl","showSettingsDrawer","showTextControl","keyboardReturn","ViewerFill"],"mappings":";;;;;;;;;AAWA;;AARA;;AAKA;;AACA;;AACA;;AAEA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAxBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AACA;AACA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,WAAT,OAmBI;AAAA;;AAAA,MAnBkB;AACrBC,IAAAA,sB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Z,KAmBC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAGZ,YADX;AAEC,IAAA,KAAK,EAAG,cAAI,QAAJ,CAFT;AAGC,IAAA,IAAI,EAAGa,qBAHR;AAIC,IAAA,SAAS,EAAC,0CAJX;AAKC,IAAA,QAAQ,EAAGP,mBALZ,CAKkC;;AALlC,IADD,CAnBD,CAlBD,CADD,EAiDGnB,YAAY,IACb,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,yCADX;AAEC,IAAA,MAAM,EAAC,OAFR;AAGC,IAAA,aAAa,EAAG;AAHjB,KAKGA,YALH,CAlDF,CAZF,EAyEGlC,KAAK,IAAI,CAAE8B,aAAX,IAA4B,CAAEG,cAA9B,IACD,4BAAC,oBAAD;AACC,IAAA,GAAG,EAAGjC,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAE0B,GADd,CACoB;AADpB;AAEC,IAAA,KAAK,EAAG1B,KAFT;AAGC,IAAA,WAAW,EAAG,MAAM+B,gBAAgB,CAAE,IAAF,CAHrC;AAIC,IAAA,eAAe,EAAGf,eAJnB;AAKC,IAAA,gBAAgB,EAAGyC,kBALpB;AAMC,IAAA,QAAQ,EAAGrD;AANZ,IA1EF,EAoFGsD,kBAAkB,IACnB;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,uBAAD;AACC,IAAA,KAAK,EAAG1D,KADT;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,QAAQ,EAAGE;AAHZ,IADD,CArFF,EA6FGe,mBAAmB,IAAIA,mBAAmB,EA7F7C,CADD;AAiGA;;AAEDpB,WAAW,CAAC+D,UAAZ,GAAyBA,sBAAzB;eAEe/D,W","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button, Spinner, Notice, TextControl } from '@wordpress/components';\nimport { keyboardReturn } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useState, useEffect } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport { ENTER } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport LinkControlSettingsDrawer from './settings-drawer';\nimport LinkControlSearchInput from './search-input';\nimport LinkPreview from './link-preview';\nimport useCreatePage from './use-create-page';\nimport useInternalInputValue from './use-internal-input-value';\nimport { ViewerFill } from './viewer-slot';\nimport { DEFAULT_LINK_SETTINGS } from './constants';\n\n/**\n * Default properties associated with a link control value.\n *\n * @typedef WPLinkControlDefaultValue\n *\n * @property {string} url Link URL.\n * @property {string=} title Link title.\n * @property {boolean=} opensInNewTab Whether link should open in a new browser\n * tab. This value is only assigned if not\n * providing a custom `settings` prop.\n */\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Custom settings values associated with a link.\n *\n * @typedef {{[setting:string]:any}} WPLinkControlSettingsValue\n */\n/* eslint-enable */\n\n/**\n * Custom settings values associated with a link.\n *\n * @typedef WPLinkControlSetting\n *\n * @property {string} id Identifier to use as property for setting value.\n * @property {string} title Human-readable label to show in user interface.\n */\n\n/**\n * Properties associated with a link control value, composed as a union of the\n * default properties and any custom settings values.\n *\n * @typedef {WPLinkControlDefaultValue&WPLinkControlSettingsValue} WPLinkControlValue\n */\n\n/** @typedef {(nextValue:WPLinkControlValue)=>void} WPLinkControlOnChangeProp */\n\n/**\n * Properties associated with a search suggestion used within the LinkControl.\n *\n * @typedef WPLinkControlSuggestion\n *\n * @property {string} id Identifier to use to uniquely identify the suggestion.\n * @property {string} type Identifies the type of the suggestion (eg: `post`,\n * `page`, `url`...etc)\n * @property {string} title Human-readable label to show in user interface.\n * @property {string} url A URL for the suggestion.\n */\n\n/** @typedef {(title:string)=>WPLinkControlSuggestion} WPLinkControlCreateSuggestionProp */\n\n/**\n * @typedef WPLinkControlProps\n *\n * @property {(WPLinkControlSetting[])=} settings An array of settings objects. Each object will used to\n * render a `ToggleControl` for that setting.\n * @property {boolean=} forceIsEditingLink If passed as either `true` or `false`, controls the\n * internal editing state of the component to respective\n * show or not show the URL input field.\n * @property {WPLinkControlValue=} value Current link value.\n * @property {WPLinkControlOnChangeProp=} onChange Value change handler, called with the updated value if\n * the user selects a new link or updates settings.\n * @property {boolean=} noDirectEntry Whether to allow turning a URL-like search query directly into a link.\n * @property {boolean=} showSuggestions Whether to present suggestions when typing the URL.\n * @property {boolean=} showInitialSuggestions Whether to present initial suggestions immediately.\n * @property {boolean=} withCreateSuggestion Whether to allow creation of link value from suggestion.\n * @property {Object=} suggestionsQuery Query parameters to pass along to wp.blockEditor.__experimentalFetchLinkSuggestions.\n * @property {boolean=} noURLSuggestion Whether to add a fallback suggestion which treats the search query as a URL.\n * @property {boolean=} hasTextControl Whether to add a text field to the UI to update the value.title.\n * @property {string|Function|undefined} createSuggestionButtonText The text to use in the button that calls createSuggestion.\n * @property {Function} renderControlBottom Optional controls to be rendered at the bottom of the component.\n */\n\nconst noop = () => {};\n\n/**\n * Renders a link control. A link control is a controlled input which maintains\n * a value associated with a link (HTML anchor element) and relevant settings\n * for how that link is expected to behave.\n *\n * @param {WPLinkControlProps} props Component props.\n */\nfunction LinkControl( {\n\tsearchInputPlaceholder,\n\tvalue,\n\tsettings = DEFAULT_LINK_SETTINGS,\n\tonChange = noop,\n\tonRemove,\n\tnoDirectEntry = false,\n\tshowSuggestions = true,\n\tshowInitialSuggestions,\n\tforceIsEditingLink,\n\tcreateSuggestion,\n\twithCreateSuggestion,\n\tinputValue: propInputValue = '',\n\tsuggestionsQuery = {},\n\tnoURLSuggestion = false,\n\tcreateSuggestionButtonText,\n\thasRichPreviews = false,\n\thasTextControl = false,\n\trenderControlBottom = null,\n} ) {\n\tif ( withCreateSuggestion === undefined && createSuggestion ) {\n\t\twithCreateSuggestion = true;\n\t}\n\n\tconst isMounting = useRef( true );\n\tconst wrapperNode = useRef();\n\tconst textInputRef = useRef();\n\tconst isEndingEditWithFocus = useRef( false );\n\n\tconst [ internalUrlInputValue, setInternalUrlInputValue ] =\n\t\tuseInternalInputValue( value?.url || '' );\n\n\tconst [ internalTextInputValue, setInternalTextInputValue ] =\n\t\tuseInternalInputValue( value?.title || '' );\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState(\n\t\tforceIsEditingLink !== undefined\n\t\t\t? forceIsEditingLink\n\t\t\t: ! value || ! value.url\n\t);\n\n\tconst { createPage, isCreatingPage, errorMessage } =\n\t\tuseCreatePage( createSuggestion );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tforceIsEditingLink !== undefined &&\n\t\t\tforceIsEditingLink !== isEditingLink\n\t\t) {\n\t\t\tsetIsEditingLink( forceIsEditingLink );\n\t\t}\n\t}, [ forceIsEditingLink ] );\n\n\tuseEffect( () => {\n\t\t// We don't auto focus into the Link UI on mount\n\t\t// because otherwise using the keyboard to select text\n\t\t// *within* the link format is not possible.\n\t\tif ( isMounting.current ) {\n\t\t\tisMounting.current = false;\n\t\t\treturn;\n\t\t}\n\t\t// Unless we are mounting, we always want to focus either:\n\t\t// - the URL input\n\t\t// - the first focusable element in the Link UI.\n\t\t// But in editing mode if there is a text input present then\n\t\t// the URL input is at index 1. If not then it is at index 0.\n\t\tconst whichFocusTargetIndex = textInputRef?.current ? 1 : 0;\n\n\t\t// Scenario - when:\n\t\t// - switching between editable and non editable LinkControl\n\t\t// - clicking on a link\n\t\t// ...then move focus to the *first* element to avoid focus loss\n\t\t// and to ensure focus is *within* the Link UI.\n\t\tconst nextFocusTarget =\n\t\t\tfocus.focusable.find( wrapperNode.current )[\n\t\t\t\twhichFocusTargetIndex\n\t\t\t] || wrapperNode.current;\n\n\t\tnextFocusTarget.focus();\n\n\t\tisEndingEditWithFocus.current = false;\n\t}, [ isEditingLink, isCreatingPage ] );\n\n\t/**\n\t * Cancels editing state and marks that focus may need to be restored after\n\t * the next render, if focus was within the wrapper when editing finished.\n\t */\n\tconst stopEditing = () => {\n\t\tisEndingEditWithFocus.current = !! wrapperNode.current?.contains(\n\t\t\twrapperNode.current.ownerDocument.activeElement\n\t\t);\n\n\t\tsetIsEditingLink( false );\n\t};\n\n\tconst handleSelectSuggestion = ( updatedValue ) => {\n\t\tonChange( {\n\t\t\t...updatedValue,\n\t\t\ttitle: internalTextInputValue || updatedValue?.title,\n\t\t} );\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmit = () => {\n\t\tif (\n\t\t\tcurrentUrlInputValue !== value?.url ||\n\t\t\tinternalTextInputValue !== value?.title\n\t\t) {\n\t\t\tonChange( {\n\t\t\t\t...value,\n\t\t\t\turl: currentUrlInputValue,\n\t\t\t\ttitle: internalTextInputValue,\n\t\t\t} );\n\t\t}\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmitWithEnter = ( event ) => {\n\t\tconst { keyCode } = event;\n\t\tif (\n\t\t\tkeyCode === ENTER &&\n\t\t\t! currentInputIsEmpty // Disallow submitting empty values.\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t\thandleSubmit();\n\t\t}\n\t};\n\n\tconst currentUrlInputValue = propInputValue || internalUrlInputValue;\n\n\tconst currentInputIsEmpty = ! currentUrlInputValue?.trim()?.length;\n\n\tconst shownUnlinkControl =\n\t\tonRemove && value && ! isEditingLink && ! isCreatingPage;\n\n\tconst showSettingsDrawer = !! settings?.length;\n\n\t// Only show text control once a URL value has been committed\n\t// and it isn't just empty whitespace.\n\t// See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.\n\tconst showTextControl = value?.url?.trim()?.length > 0 && hasTextControl;\n\n\treturn (\n\t\t<div\n\t\t\ttabIndex={ -1 }\n\t\t\tref={ wrapperNode }\n\t\t\tclassName=\"block-editor-link-control\"\n\t\t>\n\t\t\t{ isCreatingPage && (\n\t\t\t\t<div className=\"block-editor-link-control__loading\">\n\t\t\t\t\t<Spinner /> { __( 'Creating' ) }…\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ ( isEditingLink || ! value ) && ! isCreatingPage && (\n\t\t\t\t<>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames( {\n\t\t\t\t\t\t\t'block-editor-link-control__search-input-wrapper': true,\n\t\t\t\t\t\t\t'has-text-control': showTextControl,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ showTextControl && (\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tref={ textInputRef }\n\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__text-content\"\n\t\t\t\t\t\t\t\tlabel=\"Text\"\n\t\t\t\t\t\t\t\tvalue={ internalTextInputValue }\n\t\t\t\t\t\t\t\tonChange={ setInternalTextInputValue }\n\t\t\t\t\t\t\t\tonKeyDown={ handleSubmitWithEnter }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t<LinkControlSearchInput\n\t\t\t\t\t\t\tcurrentLink={ value }\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__search-input\"\n\t\t\t\t\t\t\tplaceholder={ searchInputPlaceholder }\n\t\t\t\t\t\t\tvalue={ currentUrlInputValue }\n\t\t\t\t\t\t\twithCreateSuggestion={ withCreateSuggestion }\n\t\t\t\t\t\t\tonCreateSuggestion={ createPage }\n\t\t\t\t\t\t\tonChange={ setInternalUrlInputValue }\n\t\t\t\t\t\t\tonSelect={ handleSelectSuggestion }\n\t\t\t\t\t\t\tshowInitialSuggestions={ showInitialSuggestions }\n\t\t\t\t\t\t\tallowDirectEntry={ ! noDirectEntry }\n\t\t\t\t\t\t\tshowSuggestions={ showSuggestions }\n\t\t\t\t\t\t\tsuggestionsQuery={ suggestionsQuery }\n\t\t\t\t\t\t\twithURLSuggestion={ ! noURLSuggestion }\n\t\t\t\t\t\t\tcreateSuggestionButtonText={\n\t\t\t\t\t\t\t\tcreateSuggestionButtonText\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tuseLabel={ showTextControl }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div className=\"block-editor-link-control__search-actions\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tonClick={ handleSubmit }\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Submit' ) }\n\t\t\t\t\t\t\t\t\ticon={ keyboardReturn }\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-submit\"\n\t\t\t\t\t\t\t\t\tdisabled={ currentInputIsEmpty } // Disallow submitting empty values.\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</LinkControlSearchInput>\n\t\t\t\t\t</div>\n\t\t\t\t\t{ errorMessage && (\n\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-error\"\n\t\t\t\t\t\t\tstatus=\"error\"\n\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ errorMessage }\n\t\t\t\t\t\t</Notice>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ value && ! isEditingLink && ! isCreatingPage && (\n\t\t\t\t<LinkPreview\n\t\t\t\t\tkey={ value?.url } // force remount when URL changes to avoid race conditions for rich previews\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonEditClick={ () => setIsEditingLink( true ) }\n\t\t\t\t\thasRichPreviews={ hasRichPreviews }\n\t\t\t\t\thasUnlinkControl={ shownUnlinkControl }\n\t\t\t\t\tonRemove={ onRemove }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ showSettingsDrawer && (\n\t\t\t\t<div className=\"block-editor-link-control__tools\">\n\t\t\t\t\t<LinkControlSettingsDrawer\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ renderControlBottom && renderControlBottom() }\n\t\t</div>\n\t);\n}\n\nLinkControl.ViewerFill = ViewerFill;\n\nexport default LinkControl;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/index.js"],"names":["noop","LinkControl","searchInputPlaceholder","value","settings","DEFAULT_LINK_SETTINGS","onChange","onRemove","onCancel","noDirectEntry","showSuggestions","showInitialSuggestions","forceIsEditingLink","createSuggestion","withCreateSuggestion","inputValue","propInputValue","suggestionsQuery","noURLSuggestion","createSuggestionButtonText","hasRichPreviews","hasTextControl","renderControlBottom","undefined","isMounting","wrapperNode","textInputRef","isEndingEditWithFocus","settingsOpen","setSettingsOpen","internalUrlInputValue","setInternalUrlInputValue","url","internalTextInputValue","setInternalTextInputValue","title","isEditingLink","setIsEditingLink","createPage","isCreatingPage","errorMessage","current","whichFocusTargetIndex","nextFocusTarget","focus","focusable","find","hasLinkValue","trim","length","stopEditing","contains","ownerDocument","activeElement","handleSelectSuggestion","updatedValue","handleSubmit","currentUrlInputValue","handleSubmitWithEnter","event","keyCode","ENTER","currentInputIsEmpty","preventDefault","resetInternalValues","handleCancel","stopPropagation","shownUnlinkControl","showSettings","showTextControl","isEditing","ViewerFill"],"mappings":";;;;;;;;;AAUA;;AAPA;;AAKA;;AACA;;AAEA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAvBA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AACA;AACA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;AAEA;A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AAIC,eAAlB,KACD,4BAAC,uBAAD;AACC,IAAA,YAAY,EAAGzC,YADhB;AAEC,IAAA,eAAe,EAAGC,eAFnB;AAGC,IAAA,eAAe,EAAGwC,eAHnB;AAIC,IAAA,YAAY,EAAGD,YAJhB;AAKC,IAAA,YAAY,EAAG1C,YALhB;AAMC,IAAA,sBAAsB,EAAGO,sBAN1B;AAOC,IAAA,yBAAyB,EACxBC,yBARF;AAUC,IAAA,qBAAqB,EAAGwB,qBAVzB;AAWC,IAAA,KAAK,EAAGvD,KAXT;AAYC,IAAA,QAAQ,EAAGC,QAZZ;AAaC,IAAA,QAAQ,EAAGE;AAbZ,IAFF,EAmBC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,OAAO,EAAGkD,YAFX;AAGC,IAAA,SAAS,EAAC,2CAHX;AAIC,IAAA,QAAQ,EAAGM,mBAJZ,CAIkC;;AAJlC,KAMG,cAAI,OAAJ,CANH,CADD,EASC,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,UAAhB;AAA2B,IAAA,OAAO,EAAGG;AAArC,KACG,cAAI,QAAJ,CADH,CATD,CAnBD,CA/DF,EAkGG3C,mBAAmB,IAAIA,mBAAmB,EAlG7C,CADD;AAsGA;;AAEDrB,WAAW,CAACsE,UAAZ,GAAyBA,sBAAzB;eAEetE,W","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button, Spinner, Notice } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useState, useEffect } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport { ENTER } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport LinkControlSettingsDrawer from './settings-drawer';\nimport LinkControlSearchInput from './search-input';\nimport LinkPreview from './link-preview';\nimport useCreatePage from './use-create-page';\nimport useInternalInputValue from './use-internal-input-value';\nimport { ViewerFill } from './viewer-slot';\nimport { DEFAULT_LINK_SETTINGS } from './constants';\n\n/**\n * Default properties associated with a link control value.\n *\n * @typedef WPLinkControlDefaultValue\n *\n * @property {string} url Link URL.\n * @property {string=} title Link title.\n * @property {boolean=} opensInNewTab Whether link should open in a new browser\n * tab. This value is only assigned if not\n * providing a custom `settings` prop.\n */\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Custom settings values associated with a link.\n *\n * @typedef {{[setting:string]:any}} WPLinkControlSettingsValue\n */\n/* eslint-enable */\n\n/**\n * Custom settings values associated with a link.\n *\n * @typedef WPLinkControlSetting\n *\n * @property {string} id Identifier to use as property for setting value.\n * @property {string} title Human-readable label to show in user interface.\n */\n\n/**\n * Properties associated with a link control value, composed as a union of the\n * default properties and any custom settings values.\n *\n * @typedef {WPLinkControlDefaultValue&WPLinkControlSettingsValue} WPLinkControlValue\n */\n\n/** @typedef {(nextValue:WPLinkControlValue)=>void} WPLinkControlOnChangeProp */\n\n/**\n * Properties associated with a search suggestion used within the LinkControl.\n *\n * @typedef WPLinkControlSuggestion\n *\n * @property {string} id Identifier to use to uniquely identify the suggestion.\n * @property {string} type Identifies the type of the suggestion (eg: `post`,\n * `page`, `url`...etc)\n * @property {string} title Human-readable label to show in user interface.\n * @property {string} url A URL for the suggestion.\n */\n\n/** @typedef {(title:string)=>WPLinkControlSuggestion} WPLinkControlCreateSuggestionProp */\n\n/**\n * @typedef WPLinkControlProps\n *\n * @property {(WPLinkControlSetting[])=} settings An array of settings objects. Each object will used to\n * render a `ToggleControl` for that setting.\n * @property {boolean=} forceIsEditingLink If passed as either `true` or `false`, controls the\n * internal editing state of the component to respective\n * show or not show the URL input field.\n * @property {WPLinkControlValue=} value Current link value.\n * @property {WPLinkControlOnChangeProp=} onChange Value change handler, called with the updated value if\n * the user selects a new link or updates settings.\n * @property {boolean=} noDirectEntry Whether to allow turning a URL-like search query directly into a link.\n * @property {boolean=} showSuggestions Whether to present suggestions when typing the URL.\n * @property {boolean=} showInitialSuggestions Whether to present initial suggestions immediately.\n * @property {boolean=} withCreateSuggestion Whether to allow creation of link value from suggestion.\n * @property {Object=} suggestionsQuery Query parameters to pass along to wp.blockEditor.__experimentalFetchLinkSuggestions.\n * @property {boolean=} noURLSuggestion Whether to add a fallback suggestion which treats the search query as a URL.\n * @property {boolean=} hasTextControl Whether to add a text field to the UI to update the value.title.\n * @property {string|Function|undefined} createSuggestionButtonText The text to use in the button that calls createSuggestion.\n * @property {Function} renderControlBottom Optional controls to be rendered at the bottom of the component.\n */\n\nconst noop = () => {};\n\n/**\n * Renders a link control. A link control is a controlled input which maintains\n * a value associated with a link (HTML anchor element) and relevant settings\n * for how that link is expected to behave.\n *\n * @param {WPLinkControlProps} props Component props.\n */\nfunction LinkControl( {\n\tsearchInputPlaceholder,\n\tvalue,\n\tsettings = DEFAULT_LINK_SETTINGS,\n\tonChange = noop,\n\tonRemove,\n\tonCancel,\n\tnoDirectEntry = false,\n\tshowSuggestions = true,\n\tshowInitialSuggestions,\n\tforceIsEditingLink,\n\tcreateSuggestion,\n\twithCreateSuggestion,\n\tinputValue: propInputValue = '',\n\tsuggestionsQuery = {},\n\tnoURLSuggestion = false,\n\tcreateSuggestionButtonText,\n\thasRichPreviews = false,\n\thasTextControl = false,\n\trenderControlBottom = null,\n} ) {\n\tif ( withCreateSuggestion === undefined && createSuggestion ) {\n\t\twithCreateSuggestion = true;\n\t}\n\n\tconst isMounting = useRef( true );\n\tconst wrapperNode = useRef();\n\tconst textInputRef = useRef();\n\tconst isEndingEditWithFocus = useRef( false );\n\n\tconst [ settingsOpen, setSettingsOpen ] = useState( false );\n\n\tconst [ internalUrlInputValue, setInternalUrlInputValue ] =\n\t\tuseInternalInputValue( value?.url || '' );\n\n\tconst [ internalTextInputValue, setInternalTextInputValue ] =\n\t\tuseInternalInputValue( value?.title || '' );\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState(\n\t\tforceIsEditingLink !== undefined\n\t\t\t? forceIsEditingLink\n\t\t\t: ! value || ! value.url\n\t);\n\n\tconst { createPage, isCreatingPage, errorMessage } =\n\t\tuseCreatePage( createSuggestion );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tforceIsEditingLink !== undefined &&\n\t\t\tforceIsEditingLink !== isEditingLink\n\t\t) {\n\t\t\tsetIsEditingLink( forceIsEditingLink );\n\t\t}\n\t}, [ forceIsEditingLink ] );\n\n\tuseEffect( () => {\n\t\t// We don't auto focus into the Link UI on mount\n\t\t// because otherwise using the keyboard to select text\n\t\t// *within* the link format is not possible.\n\t\tif ( isMounting.current ) {\n\t\t\tisMounting.current = false;\n\t\t\treturn;\n\t\t}\n\t\t// Unless we are mounting, we always want to focus either:\n\t\t// - the URL input\n\t\t// - the first focusable element in the Link UI.\n\t\t// But in editing mode if there is a text input present then\n\t\t// the URL input is at index 1. If not then it is at index 0.\n\t\tconst whichFocusTargetIndex = textInputRef?.current ? 1 : 0;\n\n\t\t// Scenario - when:\n\t\t// - switching between editable and non editable LinkControl\n\t\t// - clicking on a link\n\t\t// ...then move focus to the *first* element to avoid focus loss\n\t\t// and to ensure focus is *within* the Link UI.\n\t\tconst nextFocusTarget =\n\t\t\tfocus.focusable.find( wrapperNode.current )[\n\t\t\t\twhichFocusTargetIndex\n\t\t\t] || wrapperNode.current;\n\n\t\tnextFocusTarget.focus();\n\n\t\tisEndingEditWithFocus.current = false;\n\t}, [ isEditingLink, isCreatingPage ] );\n\n\tconst hasLinkValue = value?.url?.trim()?.length > 0;\n\n\t/**\n\t * Cancels editing state and marks that focus may need to be restored after\n\t * the next render, if focus was within the wrapper when editing finished.\n\t */\n\tconst stopEditing = () => {\n\t\tisEndingEditWithFocus.current = !! wrapperNode.current?.contains(\n\t\t\twrapperNode.current.ownerDocument.activeElement\n\t\t);\n\n\t\tsetSettingsOpen( false );\n\t\tsetIsEditingLink( false );\n\t};\n\n\tconst handleSelectSuggestion = ( updatedValue ) => {\n\t\tonChange( {\n\t\t\t...updatedValue,\n\t\t\ttitle: internalTextInputValue || updatedValue?.title,\n\t\t} );\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmit = () => {\n\t\tif (\n\t\t\tcurrentUrlInputValue !== value?.url ||\n\t\t\tinternalTextInputValue !== value?.title\n\t\t) {\n\t\t\tonChange( {\n\t\t\t\t...value,\n\t\t\t\turl: currentUrlInputValue,\n\t\t\t\ttitle: internalTextInputValue,\n\t\t\t} );\n\t\t}\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmitWithEnter = ( event ) => {\n\t\tconst { keyCode } = event;\n\t\tif (\n\t\t\tkeyCode === ENTER &&\n\t\t\t! currentInputIsEmpty // Disallow submitting empty values.\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t\thandleSubmit();\n\t\t}\n\t};\n\n\tconst resetInternalValues = () => {\n\t\tsetInternalUrlInputValue( value?.url );\n\t\tsetInternalTextInputValue( value?.title );\n\t};\n\n\tconst handleCancel = ( event ) => {\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\n\t\t// Ensure that any unsubmitted input changes are reset.\n\t\tresetInternalValues();\n\n\t\tif ( hasLinkValue ) {\n\t\t\t// If there is a link then exist editing mode and show preview.\n\t\t\tstopEditing();\n\t\t} else {\n\t\t\t// If there is no link value, then remove the link entirely.\n\t\t\tonRemove?.();\n\t\t}\n\n\t\tonCancel?.();\n\t};\n\n\tconst currentUrlInputValue = propInputValue || internalUrlInputValue;\n\n\tconst currentInputIsEmpty = ! currentUrlInputValue?.trim()?.length;\n\n\tconst shownUnlinkControl =\n\t\tonRemove && value && ! isEditingLink && ! isCreatingPage;\n\n\tconst showSettings = !! settings?.length;\n\n\t// Only show text control once a URL value has been committed\n\t// and it isn't just empty whitespace.\n\t// See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.\n\tconst showTextControl = hasLinkValue && hasTextControl;\n\n\tconst isEditing = ( isEditingLink || ! value ) && ! isCreatingPage;\n\n\treturn (\n\t\t<div\n\t\t\ttabIndex={ -1 }\n\t\t\tref={ wrapperNode }\n\t\t\tclassName=\"block-editor-link-control\"\n\t\t>\n\t\t\t{ isCreatingPage && (\n\t\t\t\t<div className=\"block-editor-link-control__loading\">\n\t\t\t\t\t<Spinner /> { __( 'Creating' ) }…\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ isEditing && (\n\t\t\t\t<>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames( {\n\t\t\t\t\t\t\t'block-editor-link-control__search-input-wrapper': true,\n\t\t\t\t\t\t\t'has-text-control': showTextControl,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<LinkControlSearchInput\n\t\t\t\t\t\t\tcurrentLink={ value }\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__search-input\"\n\t\t\t\t\t\t\tplaceholder={ searchInputPlaceholder }\n\t\t\t\t\t\t\tvalue={ currentUrlInputValue }\n\t\t\t\t\t\t\twithCreateSuggestion={ withCreateSuggestion }\n\t\t\t\t\t\t\tonCreateSuggestion={ createPage }\n\t\t\t\t\t\t\tonChange={ setInternalUrlInputValue }\n\t\t\t\t\t\t\tonSelect={ handleSelectSuggestion }\n\t\t\t\t\t\t\tshowInitialSuggestions={ showInitialSuggestions }\n\t\t\t\t\t\t\tallowDirectEntry={ ! noDirectEntry }\n\t\t\t\t\t\t\tshowSuggestions={ showSuggestions }\n\t\t\t\t\t\t\tsuggestionsQuery={ suggestionsQuery }\n\t\t\t\t\t\t\twithURLSuggestion={ ! noURLSuggestion }\n\t\t\t\t\t\t\tcreateSuggestionButtonText={\n\t\t\t\t\t\t\t\tcreateSuggestionButtonText\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tuseLabel={ showTextControl }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t{ errorMessage && (\n\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-error\"\n\t\t\t\t\t\t\tstatus=\"error\"\n\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ errorMessage }\n\t\t\t\t\t\t</Notice>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ value && ! isEditingLink && ! isCreatingPage && (\n\t\t\t\t<LinkPreview\n\t\t\t\t\tkey={ value?.url } // force remount when URL changes to avoid race conditions for rich previews\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonEditClick={ () => setIsEditingLink( true ) }\n\t\t\t\t\thasRichPreviews={ hasRichPreviews }\n\t\t\t\t\thasUnlinkControl={ shownUnlinkControl }\n\t\t\t\t\tonRemove={ onRemove }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ isEditing && (\n\t\t\t\t<div className=\"block-editor-link-control__tools\">\n\t\t\t\t\t{ ( showSettings || showTextControl ) && (\n\t\t\t\t\t\t<LinkControlSettingsDrawer\n\t\t\t\t\t\t\tsettingsOpen={ settingsOpen }\n\t\t\t\t\t\t\tsetSettingsOpen={ setSettingsOpen }\n\t\t\t\t\t\t\tshowTextControl={ showTextControl }\n\t\t\t\t\t\t\tshowSettings={ showSettings }\n\t\t\t\t\t\t\ttextInputRef={ textInputRef }\n\t\t\t\t\t\t\tinternalTextInputValue={ internalTextInputValue }\n\t\t\t\t\t\t\tsetInternalTextInputValue={\n\t\t\t\t\t\t\t\tsetInternalTextInputValue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\thandleSubmitWithEnter={ handleSubmitWithEnter }\n\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<div className=\"block-editor-link-control__search-actions\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tonClick={ handleSubmit }\n\t\t\t\t\t\t\tclassName=\"xblock-editor-link-control__search-submit\"\n\t\t\t\t\t\t\tdisabled={ currentInputIsEmpty } // Disallow submitting empty values.\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Apply' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ handleCancel }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ renderControlBottom && renderControlBottom() }\n\t\t</div>\n\t);\n}\n\nLinkControl.ViewerFill = ViewerFill;\n\nexport default LinkControl;\n"]}
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
@@ -7,46 +9,86 @@ exports.default = void 0;
7
9
 
8
10
  var _element = require("@wordpress/element");
9
11
 
12
+ var _components = require("@wordpress/components");
13
+
14
+ var _icons = require("@wordpress/icons");
15
+
16
+ var _compose = require("@wordpress/compose");
17
+
10
18
  var _i18n = require("@wordpress/i18n");
11
19
 
12
- var _components = require("@wordpress/components");
20
+ var _settings = _interopRequireDefault(require("./settings"));
13
21
 
14
22
  /**
15
23
  * WordPress dependencies
16
24
  */
17
- const noop = () => {};
18
25
 
19
- const LinkControlSettingsDrawer = _ref => {
26
+ /**
27
+ * Internal dependencies
28
+ */
29
+ function LinkSettingsDrawer(_ref) {
20
30
  let {
31
+ settingsOpen,
32
+ setSettingsOpen,
33
+ showTextControl,
34
+ showSettings,
35
+ textInputRef,
36
+ internalTextInputValue,
37
+ setInternalTextInputValue,
38
+ handleSubmitWithEnter,
21
39
  value,
22
- onChange = noop,
23
- settings
40
+ settings,
41
+ onChange
24
42
  } = _ref;
43
+ const prefersReducedMotion = (0, _compose.useReducedMotion)();
44
+ const MaybeAnimatePresence = prefersReducedMotion ? _element.Fragment : _components.__unstableAnimatePresence;
45
+ const MaybeMotionDiv = prefersReducedMotion ? 'div' : _components.__unstableMotion.div;
46
+ const id = (0, _compose.useInstanceId)(LinkSettingsDrawer);
47
+ const settingsDrawerId = `link-control-settings-drawer-${id}`;
48
+ return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.Button, {
49
+ className: "block-editor-link-control__drawer-toggle",
50
+ "aria-expanded": settingsOpen,
51
+ onClick: () => setSettingsOpen(!settingsOpen),
52
+ icon: _icons.settings,
53
+ label: (0, _i18n.__)('Link Settings'),
54
+ "aria-controls": settingsDrawerId
55
+ }), (0, _element.createElement)(MaybeAnimatePresence, null, settingsOpen && (0, _element.createElement)(MaybeMotionDiv, {
56
+ className: "block-editor-link-control__drawer",
57
+ hidden: !settingsOpen,
58
+ id: settingsDrawerId,
59
+ initial: "collapsed",
60
+ animate: "open",
61
+ exit: "collapsed",
62
+ variants: {
63
+ open: {
64
+ opacity: 1,
65
+ height: 'auto'
66
+ },
67
+ collapsed: {
68
+ opacity: 0,
69
+ height: 0
70
+ }
71
+ },
72
+ transition: {
73
+ duration: 0.1
74
+ }
75
+ }, (0, _element.createElement)("div", {
76
+ className: "block-editor-link-control__drawer-inner"
77
+ }, showTextControl && (0, _element.createElement)(_components.TextControl, {
78
+ __nextHasNoMarginBottom: true,
79
+ ref: textInputRef,
80
+ className: "block-editor-link-control__setting block-editor-link-control__text-content",
81
+ label: "Text",
82
+ value: internalTextInputValue,
83
+ onChange: setInternalTextInputValue,
84
+ onKeyDown: handleSubmitWithEnter
85
+ }), showSettings && (0, _element.createElement)(_settings.default, {
86
+ value: value,
87
+ settings: settings,
88
+ onChange: onChange
89
+ })))));
90
+ }
25
91
 
26
- if (!settings || !settings.length) {
27
- return null;
28
- }
29
-
30
- const handleSettingChange = setting => newValue => {
31
- onChange({ ...value,
32
- [setting.id]: newValue
33
- });
34
- };
35
-
36
- const theSettings = settings.map(setting => (0, _element.createElement)(_components.ToggleControl, {
37
- className: "block-editor-link-control__setting",
38
- key: setting.id,
39
- label: setting.title,
40
- onChange: handleSettingChange(setting),
41
- checked: value ? !!value[setting.id] : false
42
- }));
43
- return (0, _element.createElement)("fieldset", {
44
- className: "block-editor-link-control__settings"
45
- }, (0, _element.createElement)(_components.VisuallyHidden, {
46
- as: "legend"
47
- }, (0, _i18n.__)('Currently selected link settings')), theSettings);
48
- };
49
-
50
- var _default = LinkControlSettingsDrawer;
92
+ var _default = LinkSettingsDrawer;
51
93
  exports.default = _default;
52
94
  //# sourceMappingURL=settings-drawer.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/settings-drawer.js"],"names":["noop","LinkControlSettingsDrawer","value","onChange","settings","length","handleSettingChange","setting","newValue","id","theSettings","map","title"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,MAAMC,yBAAyB,GAAG,QAA4C;AAAA,MAA1C;AAAEC,IAAAA,KAAF;AAASC,IAAAA,QAAQ,GAAGH,IAApB;AAA0BI,IAAAA;AAA1B,GAA0C;;AAC7E,MAAK,CAAEA,QAAF,IAAc,CAAEA,QAAQ,CAACC,MAA9B,EAAuC;AACtC,WAAO,IAAP;AACA;;AAED,QAAMC,mBAAmB,GAAKC,OAAF,IAAiBC,QAAF,IAAgB;AAC1DL,IAAAA,QAAQ,CAAE,EACT,GAAGD,KADM;AAET,OAAEK,OAAO,CAACE,EAAV,GAAgBD;AAFP,KAAF,CAAR;AAIA,GALD;;AAOA,QAAME,WAAW,GAAGN,QAAQ,CAACO,GAAT,CAAgBJ,OAAF,IACjC,4BAAC,yBAAD;AACC,IAAA,SAAS,EAAC,oCADX;AAEC,IAAA,GAAG,EAAGA,OAAO,CAACE,EAFf;AAGC,IAAA,KAAK,EAAGF,OAAO,CAACK,KAHjB;AAIC,IAAA,QAAQ,EAAGN,mBAAmB,CAAEC,OAAF,CAJ/B;AAKC,IAAA,OAAO,EAAGL,KAAK,GAAG,CAAC,CAAEA,KAAK,CAAEK,OAAO,CAACE,EAAV,CAAX,GAA4B;AAL5C,IADmB,CAApB;AAUA,SACC;AAAU,IAAA,SAAS,EAAC;AAApB,KACC,4BAAC,0BAAD;AAAgB,IAAA,EAAE,EAAC;AAAnB,KACG,cAAI,kCAAJ,CADH,CADD,EAIGC,WAJH,CADD;AAQA,CA9BD;;eAgCeT,yB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { ToggleControl, VisuallyHidden } from '@wordpress/components';\n\nconst noop = () => {};\n\nconst LinkControlSettingsDrawer = ( { value, onChange = noop, settings } ) => {\n\tif ( ! settings || ! settings.length ) {\n\t\treturn null;\n\t}\n\n\tconst handleSettingChange = ( setting ) => ( newValue ) => {\n\t\tonChange( {\n\t\t\t...value,\n\t\t\t[ setting.id ]: newValue,\n\t\t} );\n\t};\n\n\tconst theSettings = settings.map( ( setting ) => (\n\t\t<ToggleControl\n\t\t\tclassName=\"block-editor-link-control__setting\"\n\t\t\tkey={ setting.id }\n\t\t\tlabel={ setting.title }\n\t\t\tonChange={ handleSettingChange( setting ) }\n\t\t\tchecked={ value ? !! value[ setting.id ] : false }\n\t\t/>\n\t) );\n\n\treturn (\n\t\t<fieldset className=\"block-editor-link-control__settings\">\n\t\t\t<VisuallyHidden as=\"legend\">\n\t\t\t\t{ __( 'Currently selected link settings' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t{ theSettings }\n\t\t</fieldset>\n\t);\n};\n\nexport default LinkControlSettingsDrawer;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/settings-drawer.js"],"names":["LinkSettingsDrawer","settingsOpen","setSettingsOpen","showTextControl","showSettings","textInputRef","internalTextInputValue","setInternalTextInputValue","handleSubmitWithEnter","value","settings","onChange","prefersReducedMotion","MaybeAnimatePresence","Fragment","AnimatePresence","MaybeMotionDiv","motion","div","id","settingsDrawerId","settingsIcon","open","opacity","height","collapsed","duration"],"mappings":";;;;;;;;;AAYA;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AM,EAAE;AAAtB,OADI;AAEVC,MAAAA,SAAS,EAAE;AAAEF,QAAAA,OAAO,EAAE,CAAX;AAAcC,QAAAA,MAAM,EAAE;AAAtB;AAFD,KAPZ;AAWC,IAAA,UAAU,EAAG;AACZE,MAAAA,QAAQ,EAAE;AADE;AAXd,KAeC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGvB,eAAe,IAChB,4BAAC,uBAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,GAAG,EAAGE,YAFP;AAGC,IAAA,SAAS,EAAC,4EAHX;AAIC,IAAA,KAAK,EAAC,MAJP;AAKC,IAAA,KAAK,EAAGC,sBALT;AAMC,IAAA,QAAQ,EAAGC,yBANZ;AAOC,IAAA,SAAS,EAAGC;AAPb,IAFF,EAYGJ,YAAY,IACb,4BAAC,iBAAD;AACC,IAAA,KAAK,EAAGK,KADT;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,QAAQ,EAAGC;AAHZ,IAbF,CAfD,CAFF,CATD,CADD;AAoDA;;eAEcX,kB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tTextControl,\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n} from '@wordpress/components';\nimport { settings as settingsIcon } from '@wordpress/icons';\nimport { useReducedMotion, useInstanceId } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { Fragment } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Settings from './settings';\n\nfunction LinkSettingsDrawer( {\n\tsettingsOpen,\n\tsetSettingsOpen,\n\tshowTextControl,\n\tshowSettings,\n\ttextInputRef,\n\tinternalTextInputValue,\n\tsetInternalTextInputValue,\n\thandleSubmitWithEnter,\n\tvalue,\n\tsettings,\n\tonChange,\n} ) {\n\tconst prefersReducedMotion = useReducedMotion();\n\tconst MaybeAnimatePresence = prefersReducedMotion\n\t\t? Fragment\n\t\t: AnimatePresence;\n\tconst MaybeMotionDiv = prefersReducedMotion ? 'div' : motion.div;\n\n\tconst id = useInstanceId( LinkSettingsDrawer );\n\n\tconst settingsDrawerId = `link-control-settings-drawer-${ id }`;\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tclassName=\"block-editor-link-control__drawer-toggle\"\n\t\t\t\taria-expanded={ settingsOpen }\n\t\t\t\tonClick={ () => setSettingsOpen( ! settingsOpen ) }\n\t\t\t\ticon={ settingsIcon }\n\t\t\t\tlabel={ __( 'Link Settings' ) }\n\t\t\t\taria-controls={ settingsDrawerId }\n\t\t\t/>\n\t\t\t<MaybeAnimatePresence>\n\t\t\t\t{ settingsOpen && (\n\t\t\t\t\t<MaybeMotionDiv\n\t\t\t\t\t\tclassName=\"block-editor-link-control__drawer\"\n\t\t\t\t\t\thidden={ ! settingsOpen }\n\t\t\t\t\t\tid={ settingsDrawerId }\n\t\t\t\t\t\tinitial=\"collapsed\"\n\t\t\t\t\t\tanimate=\"open\"\n\t\t\t\t\t\texit=\"collapsed\"\n\t\t\t\t\t\tvariants={ {\n\t\t\t\t\t\t\topen: { opacity: 1, height: 'auto' },\n\t\t\t\t\t\t\tcollapsed: { opacity: 0, height: 0 },\n\t\t\t\t\t\t} }\n\t\t\t\t\t\ttransition={ {\n\t\t\t\t\t\t\tduration: 0.1,\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t<div className=\"block-editor-link-control__drawer-inner\">\n\t\t\t\t\t\t\t{ showTextControl && (\n\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\tref={ textInputRef }\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__setting block-editor-link-control__text-content\"\n\t\t\t\t\t\t\t\t\tlabel=\"Text\"\n\t\t\t\t\t\t\t\t\tvalue={ internalTextInputValue }\n\t\t\t\t\t\t\t\t\tonChange={ setInternalTextInputValue }\n\t\t\t\t\t\t\t\t\tonKeyDown={ handleSubmitWithEnter }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ showSettings && (\n\t\t\t\t\t\t\t\t<Settings\n\t\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</MaybeMotionDiv>\n\t\t\t\t) }\n\t\t\t</MaybeAnimatePresence>\n\t\t</>\n\t);\n}\n\nexport default LinkSettingsDrawer;\n"]}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _element = require("@wordpress/element");
9
+
10
+ var _i18n = require("@wordpress/i18n");
11
+
12
+ var _components = require("@wordpress/components");
13
+
14
+ /**
15
+ * WordPress dependencies
16
+ */
17
+ const noop = () => {};
18
+
19
+ const LinkControlSettings = _ref => {
20
+ let {
21
+ value,
22
+ onChange = noop,
23
+ settings
24
+ } = _ref;
25
+
26
+ if (!settings || !settings.length) {
27
+ return null;
28
+ }
29
+
30
+ const handleSettingChange = setting => newValue => {
31
+ onChange({ ...value,
32
+ [setting.id]: newValue
33
+ });
34
+ };
35
+
36
+ const theSettings = settings.map(setting => (0, _element.createElement)(_components.ToggleControl, {
37
+ __nextHasNoMarginBottom: true,
38
+ className: "block-editor-link-control__setting",
39
+ key: setting.id,
40
+ label: setting.title,
41
+ onChange: handleSettingChange(setting),
42
+ checked: value ? !!value[setting.id] : false
43
+ }));
44
+ return (0, _element.createElement)("fieldset", {
45
+ className: "block-editor-link-control__settings"
46
+ }, (0, _element.createElement)(_components.VisuallyHidden, {
47
+ as: "legend"
48
+ }, (0, _i18n.__)('Currently selected link settings')), theSettings);
49
+ };
50
+
51
+ var _default = LinkControlSettings;
52
+ exports.default = _default;
53
+ //# sourceMappingURL=settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/settings.js"],"names":["noop","LinkControlSettings","value","onChange","settings","length","handleSettingChange","setting","newValue","id","theSettings","map","title"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,MAAMC,mBAAmB,GAAG,QAA4C;AAAA,MAA1C;AAAEC,IAAAA,KAAF;AAASC,IAAAA,QAAQ,GAAGH,IAApB;AAA0BI,IAAAA;AAA1B,GAA0C;;AACvE,MAAK,CAAEA,QAAF,IAAc,CAAEA,QAAQ,CAACC,MAA9B,EAAuC;AACtC,WAAO,IAAP;AACA;;AAED,QAAMC,mBAAmB,GAAKC,OAAF,IAAiBC,QAAF,IAAgB;AAC1DL,IAAAA,QAAQ,CAAE,EACT,GAAGD,KADM;AAET,OAAEK,OAAO,CAACE,EAAV,GAAgBD;AAFP,KAAF,CAAR;AAIA,GALD;;AAOA,QAAME,WAAW,GAAGN,QAAQ,CAACO,GAAT,CAAgBJ,OAAF,IACjC,4BAAC,yBAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,SAAS,EAAC,oCAFX;AAGC,IAAA,GAAG,EAAGA,OAAO,CAACE,EAHf;AAIC,IAAA,KAAK,EAAGF,OAAO,CAACK,KAJjB;AAKC,IAAA,QAAQ,EAAGN,mBAAmB,CAAEC,OAAF,CAL/B;AAMC,IAAA,OAAO,EAAGL,KAAK,GAAG,CAAC,CAAEA,KAAK,CAAEK,OAAO,CAACE,EAAV,CAAX,GAA4B;AAN5C,IADmB,CAApB;AAWA,SACC;AAAU,IAAA,SAAS,EAAC;AAApB,KACC,4BAAC,0BAAD;AAAgB,IAAA,EAAE,EAAC;AAAnB,KACG,cAAI,kCAAJ,CADH,CADD,EAIGC,WAJH,CADD;AAQA,CA/BD;;eAiCeT,mB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { ToggleControl, VisuallyHidden } from '@wordpress/components';\n\nconst noop = () => {};\n\nconst LinkControlSettings = ( { value, onChange = noop, settings } ) => {\n\tif ( ! settings || ! settings.length ) {\n\t\treturn null;\n\t}\n\n\tconst handleSettingChange = ( setting ) => ( newValue ) => {\n\t\tonChange( {\n\t\t\t...value,\n\t\t\t[ setting.id ]: newValue,\n\t\t} );\n\t};\n\n\tconst theSettings = settings.map( ( setting ) => (\n\t\t<ToggleControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\tclassName=\"block-editor-link-control__setting\"\n\t\t\tkey={ setting.id }\n\t\t\tlabel={ setting.title }\n\t\t\tonChange={ handleSettingChange( setting ) }\n\t\t\tchecked={ value ? !! value[ setting.id ] : false }\n\t\t/>\n\t) );\n\n\treturn (\n\t\t<fieldset className=\"block-editor-link-control__settings\">\n\t\t\t<VisuallyHidden as=\"legend\">\n\t\t\t\t{ __( 'Currently selected link settings' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t{ theSettings }\n\t\t</fieldset>\n\t);\n};\n\nexport default LinkControlSettings;\n"]}
@@ -196,7 +196,9 @@ function ListViewBlock(_ref) {
196
196
  isSelected,
197
197
  rowItemRef: rowRef,
198
198
  selectedClientIds
199
- });
199
+ }); // Detect if there is a block in the canvas currently being edited and multi-selection is not happening.
200
+
201
+ const currentlyEditingBlockInCanvas = isSelected && selectedClientIds.length === 1;
200
202
  return (0, _element.createElement)(_leaf.default, {
201
203
  className: classes,
202
204
  onMouseEnter: onMouseEnter,
@@ -237,7 +239,7 @@ function ListViewBlock(_ref) {
237
239
  siblingBlockCount: siblingBlockCount,
238
240
  level: level,
239
241
  ref: ref,
240
- tabIndex: tabIndex,
242
+ tabIndex: currentlyEditingBlockInCanvas ? 0 : tabIndex,
241
243
  onFocus: onFocus,
242
244
  isExpanded: isExpanded,
243
245
  selectedClientIds: selectedClientIds,