@wordpress/block-editor 12.5.0 → 12.7.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 (442) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +2 -6
  3. package/build/autocompleters/block.js +6 -2
  4. package/build/autocompleters/block.js.map +1 -1
  5. package/build/components/block-draggable/index.js +6 -3
  6. package/build/components/block-draggable/index.js.map +1 -1
  7. package/build/components/block-draggable/index.native.js +2 -2
  8. package/build/components/block-draggable/index.native.js.map +1 -1
  9. package/build/components/block-edit/edit.js +25 -13
  10. package/build/components/block-edit/edit.js.map +1 -1
  11. package/build/components/block-editing-mode/index.js +1 -1
  12. package/build/components/block-editing-mode/index.js.map +1 -1
  13. package/build/components/block-list/block-outline.native.js +14 -18
  14. package/build/components/block-list/block-outline.native.js.map +1 -1
  15. package/build/components/block-list/block.js +4 -2
  16. package/build/components/block-list/block.js.map +1 -1
  17. package/build/components/block-list/block.native.js +21 -42
  18. package/build/components/block-list/block.native.js.map +1 -1
  19. package/build/components/block-list/index.js +2 -4
  20. package/build/components/block-list/index.js.map +1 -1
  21. package/build/components/block-mover/index.native.js +1 -1
  22. package/build/components/block-mover/index.native.js.map +1 -1
  23. package/build/components/block-parent-selector/index.js +6 -21
  24. package/build/components/block-parent-selector/index.js.map +1 -1
  25. package/build/components/block-preview/auto.js +6 -1
  26. package/build/components/block-preview/auto.js.map +1 -1
  27. package/build/components/block-removal-warning-modal/index.js +1 -4
  28. package/build/components/block-removal-warning-modal/index.js.map +1 -1
  29. package/build/components/block-settings/button.native.js +2 -2
  30. package/build/components/block-settings/button.native.js.map +1 -1
  31. package/build/components/block-settings-menu/block-settings-dropdown.js +3 -17
  32. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  33. package/build/components/{block-mobile-toolbar/block-actions-menu.native.js → block-toolbar/block-toolbar-menu.native.js} +7 -5
  34. package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -0
  35. package/build/components/block-toolbar/index.js +4 -33
  36. package/build/components/block-toolbar/index.js.map +1 -1
  37. package/build/components/block-toolbar/index.native.js +62 -3
  38. package/build/components/block-toolbar/index.native.js.map +1 -1
  39. package/build/components/block-toolbar/utils.js +56 -51
  40. package/build/components/block-toolbar/utils.js.map +1 -1
  41. package/build/components/block-tools/block-contextual-toolbar.js +4 -2
  42. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  43. package/build/components/block-variation-picker/index.native.js +10 -20
  44. package/build/components/block-variation-picker/index.native.js.map +1 -1
  45. package/build/components/colors-gradients/control.js +4 -2
  46. package/build/components/colors-gradients/control.js.map +1 -1
  47. package/build/components/editor-styles/index.js +2 -2
  48. package/build/components/editor-styles/index.js.map +1 -1
  49. package/build/components/font-sizes/fluid-utils.js +11 -11
  50. package/build/components/font-sizes/fluid-utils.js.map +1 -1
  51. package/build/components/global-styles/behaviors-panel.js +66 -0
  52. package/build/components/global-styles/behaviors-panel.js.map +1 -0
  53. package/build/components/global-styles/color-panel.js +21 -15
  54. package/build/components/global-styles/color-panel.js.map +1 -1
  55. package/build/components/global-styles/dimensions-panel.js +13 -2
  56. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  57. package/build/components/global-styles/get-block-css-selector.js +4 -8
  58. package/build/components/global-styles/get-block-css-selector.js.map +1 -1
  59. package/build/components/global-styles/hooks.js +131 -27
  60. package/build/components/global-styles/hooks.js.map +1 -1
  61. package/build/components/global-styles/index.js +20 -0
  62. package/build/components/global-styles/index.js.map +1 -1
  63. package/build/components/global-styles/typography-panel.js +18 -3
  64. package/build/components/global-styles/typography-panel.js.map +1 -1
  65. package/build/components/global-styles/typography-utils.js +4 -4
  66. package/build/components/global-styles/typography-utils.js.map +1 -1
  67. package/build/components/global-styles/use-global-styles-output.js +12 -18
  68. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  69. package/build/components/global-styles/utils.js +7 -7
  70. package/build/components/global-styles/utils.js.map +1 -1
  71. package/build/components/iframe/index.js +36 -48
  72. package/build/components/iframe/index.js.map +1 -1
  73. package/build/components/iframe/use-compatibility-styles.js +5 -0
  74. package/build/components/iframe/use-compatibility-styles.js.map +1 -1
  75. package/build/components/index.js +1 -10
  76. package/build/components/index.js.map +1 -1
  77. package/build/components/inner-blocks/index.js +3 -1
  78. package/build/components/inner-blocks/index.js.map +1 -1
  79. package/build/components/inner-blocks/index.native.js +3 -1
  80. package/build/components/inner-blocks/index.native.js.map +1 -1
  81. package/build/components/inner-blocks/use-nested-settings-update.js +33 -7
  82. package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  83. package/build/components/inserter/hooks/use-block-types-state.js +6 -2
  84. package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
  85. package/build/components/inserter/hooks/use-debounced-input.js +5 -7
  86. package/build/components/inserter/hooks/use-debounced-input.js.map +1 -1
  87. package/build/components/inserter/hooks/use-patterns-state.js +3 -2
  88. package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
  89. package/build/components/inserter/index.js +2 -4
  90. package/build/components/inserter/index.js.map +1 -1
  91. package/build/components/inserter/index.native.js +21 -32
  92. package/build/components/inserter/index.native.js.map +1 -1
  93. package/build/components/inserter/reusable-block-rename-hint.js +23 -3
  94. package/build/components/inserter/reusable-block-rename-hint.js.map +1 -1
  95. package/build/components/inserter/reusable-blocks-tab.js +3 -2
  96. package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
  97. package/build/components/inserter-list-item/index.js +1 -1
  98. package/build/components/inserter-list-item/index.js.map +1 -1
  99. package/build/components/link-control/index.js +51 -7
  100. package/build/components/link-control/index.js.map +1 -1
  101. package/build/components/link-control/link-preview.js +3 -3
  102. package/build/components/link-control/link-preview.js.map +1 -1
  103. package/build/components/link-control/search-item.js +1 -1
  104. package/build/components/link-control/search-item.js.map +1 -1
  105. package/build/components/list-view/use-list-view-client-ids.js +2 -2
  106. package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
  107. package/build/components/list-view/use-list-view-drop-zone.js +6 -1
  108. package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
  109. package/build/components/media-placeholder/index.native.js +65 -31
  110. package/build/components/media-placeholder/index.native.js.map +1 -1
  111. package/build/components/media-replace-flow/index.native.js +15 -3
  112. package/build/components/media-replace-flow/index.native.js.map +1 -1
  113. package/build/components/preview-options/index.js +2 -2
  114. package/build/components/preview-options/index.js.map +1 -1
  115. package/build/components/rich-text/content.js +0 -36
  116. package/build/components/rich-text/content.js.map +1 -1
  117. package/build/components/rich-text/format-edit.js +57 -28
  118. package/build/components/rich-text/format-edit.js.map +1 -1
  119. package/build/components/rich-text/get-rich-text-values.js +111 -0
  120. package/build/components/rich-text/get-rich-text-values.js.map +1 -0
  121. package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
  122. package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
  123. package/build/components/spacing-sizes-control/input-controls/axial.js +6 -2
  124. package/build/components/spacing-sizes-control/input-controls/axial.js.map +1 -1
  125. package/build/components/spacing-sizes-control/input-controls/separated.js +5 -1
  126. package/build/components/spacing-sizes-control/input-controls/separated.js.map +1 -1
  127. package/build/components/spacing-sizes-control/input-controls/single.js +5 -1
  128. package/build/components/spacing-sizes-control/input-controls/single.js.map +1 -1
  129. package/build/components/spacing-sizes-control/utils.js +2 -2
  130. package/build/components/spacing-sizes-control/utils.js.map +1 -1
  131. package/build/components/use-block-display-information/index.js +7 -3
  132. package/build/components/use-block-display-information/index.js.map +1 -1
  133. package/build/components/use-block-drop-zone/index.native.js +49 -8
  134. package/build/components/use-block-drop-zone/index.native.js.map +1 -1
  135. package/build/components/use-setting/index.js +5 -9
  136. package/build/components/use-setting/index.js.map +1 -1
  137. package/build/hooks/behaviors.js +5 -12
  138. package/build/hooks/behaviors.js.map +1 -1
  139. package/build/hooks/border.js +2 -1
  140. package/build/hooks/border.js.map +1 -1
  141. package/build/hooks/margin.js +1 -1
  142. package/build/hooks/margin.js.map +1 -1
  143. package/build/hooks/padding.js +1 -1
  144. package/build/hooks/padding.js.map +1 -1
  145. package/build/hooks/style.js +11 -2
  146. package/build/hooks/style.js.map +1 -1
  147. package/build/hooks/utils.js +1 -7
  148. package/build/hooks/utils.js.map +1 -1
  149. package/build/private-apis.js +10 -3
  150. package/build/private-apis.js.map +1 -1
  151. package/build/store/actions.js +3 -4
  152. package/build/store/actions.js.map +1 -1
  153. package/build/store/private-selectors.js +5 -6
  154. package/build/store/private-selectors.js.map +1 -1
  155. package/build/store/reducer.js +0 -1
  156. package/build/store/reducer.js.map +1 -1
  157. package/build/store/selectors.js +23 -79
  158. package/build/store/selectors.js.map +1 -1
  159. package/build/utils/object.js +38 -2
  160. package/build/utils/object.js.map +1 -1
  161. package/build-module/autocompleters/block.js +7 -3
  162. package/build-module/autocompleters/block.js.map +1 -1
  163. package/build-module/components/block-draggable/index.js +6 -3
  164. package/build-module/components/block-draggable/index.js.map +1 -1
  165. package/build-module/components/block-draggable/index.native.js +2 -2
  166. package/build-module/components/block-draggable/index.native.js.map +1 -1
  167. package/build-module/components/block-edit/edit.js +27 -10
  168. package/build-module/components/block-edit/edit.js.map +1 -1
  169. package/build-module/components/block-editing-mode/index.js +1 -1
  170. package/build-module/components/block-editing-mode/index.js.map +1 -1
  171. package/build-module/components/block-list/block-outline.native.js +14 -18
  172. package/build-module/components/block-list/block-outline.native.js.map +1 -1
  173. package/build-module/components/block-list/block.js +4 -2
  174. package/build-module/components/block-list/block.js.map +1 -1
  175. package/build-module/components/block-list/block.native.js +24 -43
  176. package/build-module/components/block-list/block.native.js.map +1 -1
  177. package/build-module/components/block-list/index.js +2 -3
  178. package/build-module/components/block-list/index.js.map +1 -1
  179. package/build-module/components/block-mover/index.native.js +3 -3
  180. package/build-module/components/block-mover/index.native.js.map +1 -1
  181. package/build-module/components/block-parent-selector/index.js +7 -22
  182. package/build-module/components/block-parent-selector/index.js.map +1 -1
  183. package/build-module/components/block-preview/auto.js +6 -1
  184. package/build-module/components/block-preview/auto.js.map +1 -1
  185. package/build-module/components/block-removal-warning-modal/index.js +1 -4
  186. package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
  187. package/build-module/components/block-settings/button.native.js +3 -3
  188. package/build-module/components/block-settings/button.native.js.map +1 -1
  189. package/build-module/components/block-settings-menu/block-settings-dropdown.js +4 -18
  190. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  191. package/build-module/components/{block-mobile-toolbar/block-actions-menu.native.js → block-toolbar/block-toolbar-menu.native.js} +9 -7
  192. package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -0
  193. package/build-module/components/block-toolbar/index.js +6 -35
  194. package/build-module/components/block-toolbar/index.js.map +1 -1
  195. package/build-module/components/block-toolbar/index.native.js +60 -4
  196. package/build-module/components/block-toolbar/index.native.js.map +1 -1
  197. package/build-module/components/block-toolbar/utils.js +54 -49
  198. package/build-module/components/block-toolbar/utils.js.map +1 -1
  199. package/build-module/components/block-tools/block-contextual-toolbar.js +4 -2
  200. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  201. package/build-module/components/block-variation-picker/index.native.js +13 -23
  202. package/build-module/components/block-variation-picker/index.native.js.map +1 -1
  203. package/build-module/components/colors-gradients/control.js +3 -2
  204. package/build-module/components/colors-gradients/control.js.map +1 -1
  205. package/build-module/components/editor-styles/index.js +2 -2
  206. package/build-module/components/editor-styles/index.js.map +1 -1
  207. package/build-module/components/font-sizes/fluid-utils.js +11 -11
  208. package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
  209. package/build-module/components/global-styles/behaviors-panel.js +57 -0
  210. package/build-module/components/global-styles/behaviors-panel.js.map +1 -0
  211. package/build-module/components/global-styles/color-panel.js +21 -15
  212. package/build-module/components/global-styles/color-panel.js.map +1 -1
  213. package/build-module/components/global-styles/dimensions-panel.js +13 -2
  214. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  215. package/build-module/components/global-styles/get-block-css-selector.js +4 -8
  216. package/build-module/components/global-styles/get-block-css-selector.js.map +1 -1
  217. package/build-module/components/global-styles/hooks.js +127 -27
  218. package/build-module/components/global-styles/hooks.js.map +1 -1
  219. package/build-module/components/global-styles/index.js +2 -1
  220. package/build-module/components/global-styles/index.js.map +1 -1
  221. package/build-module/components/global-styles/typography-panel.js +18 -3
  222. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  223. package/build-module/components/global-styles/typography-utils.js +4 -4
  224. package/build-module/components/global-styles/typography-utils.js.map +1 -1
  225. package/build-module/components/global-styles/use-global-styles-output.js +13 -18
  226. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  227. package/build-module/components/global-styles/utils.js +6 -6
  228. package/build-module/components/global-styles/utils.js.map +1 -1
  229. package/build-module/components/iframe/index.js +37 -49
  230. package/build-module/components/iframe/index.js.map +1 -1
  231. package/build-module/components/iframe/use-compatibility-styles.js +5 -0
  232. package/build-module/components/iframe/use-compatibility-styles.js.map +1 -1
  233. package/build-module/components/index.js +0 -5
  234. package/build-module/components/index.js.map +1 -1
  235. package/build-module/components/inner-blocks/index.js +3 -1
  236. package/build-module/components/inner-blocks/index.js.map +1 -1
  237. package/build-module/components/inner-blocks/index.native.js +3 -1
  238. package/build-module/components/inner-blocks/index.native.js.map +1 -1
  239. package/build-module/components/inner-blocks/use-nested-settings-update.js +30 -7
  240. package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  241. package/build-module/components/inserter/hooks/use-block-types-state.js +7 -3
  242. package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
  243. package/build-module/components/inserter/hooks/use-debounced-input.js +5 -7
  244. package/build-module/components/inserter/hooks/use-debounced-input.js.map +1 -1
  245. package/build-module/components/inserter/hooks/use-patterns-state.js +3 -2
  246. package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
  247. package/build-module/components/inserter/index.js +2 -4
  248. package/build-module/components/inserter/index.js.map +1 -1
  249. package/build-module/components/inserter/index.native.js +22 -33
  250. package/build-module/components/inserter/index.native.js.map +1 -1
  251. package/build-module/components/inserter/reusable-block-rename-hint.js +22 -3
  252. package/build-module/components/inserter/reusable-block-rename-hint.js.map +1 -1
  253. package/build-module/components/inserter/reusable-blocks-tab.js +3 -2
  254. package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
  255. package/build-module/components/inserter-list-item/index.js +1 -1
  256. package/build-module/components/inserter-list-item/index.js.map +1 -1
  257. package/build-module/components/link-control/index.js +49 -7
  258. package/build-module/components/link-control/index.js.map +1 -1
  259. package/build-module/components/link-control/link-preview.js +3 -3
  260. package/build-module/components/link-control/link-preview.js.map +1 -1
  261. package/build-module/components/link-control/search-item.js +1 -1
  262. package/build-module/components/link-control/search-item.js.map +1 -1
  263. package/build-module/components/list-view/use-list-view-client-ids.js +2 -2
  264. package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
  265. package/build-module/components/list-view/use-list-view-drop-zone.js +6 -1
  266. package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
  267. package/build-module/components/media-placeholder/index.native.js +66 -33
  268. package/build-module/components/media-placeholder/index.native.js.map +1 -1
  269. package/build-module/components/media-replace-flow/index.native.js +15 -3
  270. package/build-module/components/media-replace-flow/index.native.js.map +1 -1
  271. package/build-module/components/preview-options/index.js +2 -2
  272. package/build-module/components/preview-options/index.js.map +1 -1
  273. package/build-module/components/rich-text/content.js +1 -36
  274. package/build-module/components/rich-text/content.js.map +1 -1
  275. package/build-module/components/rich-text/format-edit.js +51 -26
  276. package/build-module/components/rich-text/format-edit.js.map +1 -1
  277. package/build-module/components/rich-text/get-rich-text-values.js +100 -0
  278. package/build-module/components/rich-text/get-rich-text-values.js.map +1 -0
  279. package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
  280. package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
  281. package/build-module/components/spacing-sizes-control/input-controls/axial.js +7 -3
  282. package/build-module/components/spacing-sizes-control/input-controls/axial.js.map +1 -1
  283. package/build-module/components/spacing-sizes-control/input-controls/separated.js +6 -2
  284. package/build-module/components/spacing-sizes-control/input-controls/separated.js.map +1 -1
  285. package/build-module/components/spacing-sizes-control/input-controls/single.js +6 -2
  286. package/build-module/components/spacing-sizes-control/input-controls/single.js.map +1 -1
  287. package/build-module/components/spacing-sizes-control/utils.js +2 -2
  288. package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
  289. package/build-module/components/use-block-display-information/index.js +7 -3
  290. package/build-module/components/use-block-display-information/index.js.map +1 -1
  291. package/build-module/components/use-block-drop-zone/index.native.js +50 -8
  292. package/build-module/components/use-block-drop-zone/index.native.js.map +1 -1
  293. package/build-module/components/use-setting/index.js +5 -9
  294. package/build-module/components/use-setting/index.js.map +1 -1
  295. package/build-module/hooks/behaviors.js +5 -12
  296. package/build-module/hooks/behaviors.js.map +1 -1
  297. package/build-module/hooks/border.js +2 -1
  298. package/build-module/hooks/border.js.map +1 -1
  299. package/build-module/hooks/margin.js +1 -1
  300. package/build-module/hooks/margin.js.map +1 -1
  301. package/build-module/hooks/padding.js +1 -1
  302. package/build-module/hooks/padding.js.map +1 -1
  303. package/build-module/hooks/style.js +11 -2
  304. package/build-module/hooks/style.js.map +1 -1
  305. package/build-module/hooks/utils.js +2 -7
  306. package/build-module/hooks/utils.js.map +1 -1
  307. package/build-module/private-apis.js +7 -2
  308. package/build-module/private-apis.js.map +1 -1
  309. package/build-module/store/actions.js +4 -5
  310. package/build-module/store/actions.js.map +1 -1
  311. package/build-module/store/private-selectors.js +3 -3
  312. package/build-module/store/private-selectors.js.map +1 -1
  313. package/build-module/store/reducer.js +0 -1
  314. package/build-module/store/reducer.js.map +1 -1
  315. package/build-module/store/selectors.js +20 -75
  316. package/build-module/store/selectors.js.map +1 -1
  317. package/build-module/utils/object.js +34 -2
  318. package/build-module/utils/object.js.map +1 -1
  319. package/build-style/content-rtl.css +2 -1
  320. package/build-style/content.css +2 -1
  321. package/build-style/style-rtl.css +25 -6
  322. package/build-style/style.css +25 -6
  323. package/package.json +32 -32
  324. package/src/autocompleters/block.js +21 -6
  325. package/src/components/block-controls/README.md +89 -0
  326. package/src/components/block-draggable/index.js +13 -4
  327. package/src/components/block-draggable/index.native.js +7 -3
  328. package/src/components/block-draggable/test/index.native.js +2 -57
  329. package/src/components/block-edit/edit.js +26 -9
  330. package/src/components/block-edit/test/edit.js +1 -1
  331. package/src/components/block-editing-mode/index.js +1 -1
  332. package/src/components/block-list/block-outline.native.js +26 -25
  333. package/src/components/block-list/block.js +6 -1
  334. package/src/components/block-list/block.native.js +24 -38
  335. package/src/components/block-list/block.native.scss +18 -40
  336. package/src/components/block-list/index.js +3 -6
  337. package/src/components/block-list/style.native.scss +3 -3
  338. package/src/components/block-list/test/block-invalid-warning.native.js +8 -1
  339. package/src/components/block-mover/index.native.js +3 -3
  340. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +40 -6
  341. package/src/components/block-parent-selector/index.js +30 -42
  342. package/src/components/block-preview/auto.js +8 -1
  343. package/src/components/block-preview/style.scss +2 -1
  344. package/src/components/block-removal-warning-modal/index.js +0 -3
  345. package/src/components/block-settings/button.native.js +12 -6
  346. package/src/components/block-settings-menu/block-settings-dropdown.js +4 -13
  347. package/src/components/{block-mobile-toolbar/block-actions-menu.native.js → block-toolbar/block-toolbar-menu.native.js} +15 -10
  348. package/src/components/block-toolbar/index.js +36 -64
  349. package/src/components/block-toolbar/index.native.js +86 -6
  350. package/src/components/{block-mobile-toolbar/test/block-actions-menu.native.js → block-toolbar/test/block-toolbar-menu.native.js} +20 -54
  351. package/src/components/block-toolbar/test/index.native.js +42 -0
  352. package/src/components/block-toolbar/utils.js +57 -45
  353. package/src/components/block-tools/block-contextual-toolbar.js +43 -35
  354. package/src/components/block-tools/style.scss +17 -5
  355. package/src/components/block-variation-picker/index.native.js +52 -72
  356. package/src/components/button-block-appender/styles.native.scss +2 -2
  357. package/src/components/caption/README.md +49 -0
  358. package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
  359. package/src/components/colors-gradients/control.js +3 -2
  360. package/src/components/editor-styles/index.js +2 -2
  361. package/src/components/font-sizes/fluid-utils.js +17 -17
  362. package/src/components/font-sizes/test/fluid-utils.js +6 -6
  363. package/src/components/global-styles/behaviors-panel.js +71 -0
  364. package/src/components/global-styles/color-panel.js +23 -16
  365. package/src/components/global-styles/dimensions-panel.js +8 -2
  366. package/src/components/global-styles/get-block-css-selector.js +5 -9
  367. package/src/components/global-styles/hooks.js +134 -31
  368. package/src/components/global-styles/index.js +3 -0
  369. package/src/components/global-styles/test/typography-utils.js +6 -6
  370. package/src/components/global-styles/typography-panel.js +17 -5
  371. package/src/components/global-styles/typography-utils.js +4 -4
  372. package/src/components/global-styles/use-global-styles-output.js +36 -18
  373. package/src/components/global-styles/utils.js +17 -7
  374. package/src/components/iframe/index.js +30 -56
  375. package/src/components/iframe/use-compatibility-styles.js +5 -0
  376. package/src/components/index.js +0 -5
  377. package/src/components/inner-blocks/README.md +10 -0
  378. package/src/components/inner-blocks/index.js +4 -0
  379. package/src/components/inner-blocks/index.native.js +4 -0
  380. package/src/components/inner-blocks/use-nested-settings-update.js +32 -5
  381. package/src/components/inserter/hooks/use-block-types-state.js +15 -6
  382. package/src/components/inserter/hooks/use-debounced-input.js +8 -7
  383. package/src/components/inserter/hooks/use-patterns-state.js +2 -1
  384. package/src/components/inserter/index.js +2 -3
  385. package/src/components/inserter/index.native.js +17 -36
  386. package/src/components/inserter/reusable-block-rename-hint.js +18 -1
  387. package/src/components/inserter/reusable-blocks-tab.js +4 -1
  388. package/src/components/inserter/style.native.scss +10 -15
  389. package/src/components/inserter-list-item/index.js +3 -1
  390. package/src/components/link-control/README.md +12 -3
  391. package/src/components/link-control/index.js +47 -7
  392. package/src/components/link-control/link-preview.js +6 -4
  393. package/src/components/link-control/search-item.js +1 -1
  394. package/src/components/link-control/style.scss +11 -3
  395. package/src/components/link-control/test/index.js +28 -1
  396. package/src/components/list-view/use-list-view-client-ids.js +2 -2
  397. package/src/components/list-view/use-list-view-drop-zone.js +5 -1
  398. package/src/components/media-placeholder/index.native.js +108 -59
  399. package/src/components/media-placeholder/styles.native.scss +59 -24
  400. package/src/components/media-replace-flow/index.native.js +12 -3
  401. package/src/components/media-upload/test/index.native.js +1 -0
  402. package/src/components/preview-options/README.md +18 -17
  403. package/src/components/preview-options/index.js +2 -2
  404. package/src/components/rich-text/content.js +1 -46
  405. package/src/components/rich-text/format-edit.js +62 -38
  406. package/src/components/rich-text/get-rich-text-values.js +99 -0
  407. package/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
  408. package/src/components/spacing-sizes-control/input-controls/axial.js +17 -2
  409. package/src/components/spacing-sizes-control/input-controls/separated.js +17 -2
  410. package/src/components/spacing-sizes-control/input-controls/single.js +12 -2
  411. package/src/components/spacing-sizes-control/test/utils.js +9 -1
  412. package/src/components/spacing-sizes-control/utils.js +2 -2
  413. package/src/components/text-transform-control/README.md +44 -0
  414. package/src/components/use-block-display-information/index.js +12 -5
  415. package/src/components/use-block-drop-zone/index.native.js +65 -28
  416. package/src/components/use-setting/index.js +8 -8
  417. package/src/hooks/behaviors.js +10 -16
  418. package/src/hooks/border.js +2 -1
  419. package/src/hooks/margin.js +4 -1
  420. package/src/hooks/padding.js +4 -1
  421. package/src/hooks/style.js +7 -3
  422. package/src/hooks/utils.js +5 -7
  423. package/src/private-apis.js +9 -1
  424. package/src/store/actions.js +23 -30
  425. package/src/store/private-selectors.js +3 -6
  426. package/src/store/reducer.js +0 -1
  427. package/src/store/selectors.js +36 -85
  428. package/src/store/test/actions.js +3 -0
  429. package/src/store/test/private-selectors.js +5 -5
  430. package/src/store/test/reducer.js +14 -7
  431. package/src/store/test/selectors.js +8 -7
  432. package/src/utils/object.js +32 -2
  433. package/src/utils/test/object.js +36 -0
  434. package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +0 -1
  435. package/build/components/block-mobile-toolbar/index.native.js +0 -135
  436. package/build/components/block-mobile-toolbar/index.native.js.map +0 -1
  437. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +0 -1
  438. package/build-module/components/block-mobile-toolbar/index.native.js +0 -116
  439. package/build-module/components/block-mobile-toolbar/index.native.js.map +0 -1
  440. package/src/components/block-mobile-toolbar/index.native.js +0 -127
  441. package/src/components/block-mobile-toolbar/style.native.scss +0 -16
  442. /package/src/components/{block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap → block-toolbar/test/__snapshots__/block-toolbar-menu.native.js.snap} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/inserter/index.native.js"],"names":["AccessibilityInfo","Platform","Text","__","_x","Dropdown","ToolbarButton","Picker","Component","withDispatch","withSelect","compose","withPreferredColorScheme","isUnmodifiedDefaultBlock","Icon","plus","plusCircle","plusCircleFilled","insertAfter","insertBefore","setBlockTypeImpressions","styles","InserterMenu","BlockInsertionPoint","store","blockEditorStore","VOICE_OVER_ANNOUNCEMENT_DELAY","defaultRenderToggle","onToggle","disabled","style","containerStyle","onLongPress","useExpandedMode","expandedModeViewProps","icon","customContainerStyles","fixedRatio","expandedModeViewText","hint","testID","Inserter","announcementTimeout","constructor","arguments","bind","renderInserterToggle","renderContent","componentWillUnmount","clearTimeout","getInsertionOptions","addBeforeOption","value","label","replaceCurrentOption","addAfterOption","addToBeginningOption","addToEndOption","isAnyBlockSelected","isSelectedBlockReplaceable","props","getInsertionIndex","insertionType","insertionIndexDefault","insertionIndexStart","insertionIndexBefore","insertionIndexAfter","insertionIndexEnd","shouldReplaceBlock","isOpen","blockTypeImpressions","updateSettings","impressionsRemain","Object","values","some","count","decrementedImpressions","entries","reduce","acc","blockName","Math","max","impressions","onInserterToggledAnnouncement","isScreenReaderEnabled","then","isEnabled","isIOS","OS","announcement","setTimeout","announceForAccessibility","renderToggle","getStylesFromColorScheme","showSeparator","onPress","setState","destinationRootClientId","insertionIndex","picker","presentPicker","onPickerSelect","instance","onClose","clientId","isAppender","state","render","dispatch","select","rootClientId","getBlockRootClientId","getBlockSelectionEnd","getBlockOrder","getBlockIndex","getBlock","getSettings","getBlockEditorSettings","end","selectedBlockIndex","endOfRootIndex","length","isSelectedUnmodifiedDefaultBlock","undefined","getDefaultInsertionIndex","__experimentalShouldInsertAtTheTop","shouldInsertAtTheTop"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,iBAAT,EAA4BC,QAA5B,EAAsCC,IAAtC,QAAkD,cAAlD;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,QAAT,EAAmBC,aAAnB,EAAkCC,MAAlC,QAAgD,uBAAhD;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,YAAT,EAAuBC,UAAvB,QAAyC,iBAAzC;AACA,SAASC,OAAT,EAAkBC,wBAAlB,QAAkD,oBAAlD;AACA,SAASC,wBAAT,QAAyC,mBAAzC;AACA,SACCC,IADD,EAECC,IAFD,EAGCC,UAHD,EAICC,gBAJD,EAKCC,WALD,EAMCC,YAND,QAOO,kBAPP;AAQA,SAASC,uBAAT,QAAwC,gCAAxC;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,cAAnB;AACA,OAAOC,YAAP,MAAyB,QAAzB;AACA,OAAOC,mBAAP,MAAgC,+BAAhC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA,MAAMC,6BAA6B,GAAG,IAAtC;;AAEA,MAAMC,mBAAmB,GAAG,CAAE;AAC7BC,EAAAA,QAD6B;AAE7BC,EAAAA,QAF6B;AAG7BC,EAAAA,KAH6B;AAI7BC,EAAAA,cAJ6B;AAK7BC,EAAAA,WAL6B;AAM7BC,EAAAA;AAN6B,CAAF,KAOrB;AACN;AACA;AACA;AACA;AACA,QAAMC,qBAAqB,GAAGD,eAAe,IAAI;AAChDE,IAAAA,IAAI,EAAE,cAAC,IAAD;AAAM,MAAA,IAAI,EAAGpB,IAAb;AAAoB,MAAA,KAAK,EAAGe;AAA5B,MAD0C;AAEhDM,IAAAA,qBAAqB,EAAEL,cAFyB;A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O;AACNpD,IAAAA,oBAAoB,EAAEiD,sBAAsB,GAAGnC,WADzC;AAENe,IAAAA,uBAFM;AAGNpC,IAAAA,qBAAqB,EAAE+D,wBAAwB,EAHzC;AAIN7D,IAAAA,oBAJM;AAKNC,IAAAA,mBALM;AAMNF,IAAAA,mBANM;AAONG,IAAAA,iBAPM;AAQNT,IAAAA,kBAAkB,EAAE,CAAC,CAAEA,kBARjB;AASNC,IAAAA,0BAA0B,EAAEiE;AATtB,GAAP;AAWA,CA5ES,CALa,EAmFvBhH,wBAnFuB,CAAF,CAAP,CAoFV6B,QApFU,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { AccessibilityInfo, Platform, Text } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport { Dropdown, ToolbarButton, Picker } from '@wordpress/components';\nimport { Component } from '@wordpress/element';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose, withPreferredColorScheme } from '@wordpress/compose';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\nimport {\n\tIcon,\n\tplus,\n\tplusCircle,\n\tplusCircleFilled,\n\tinsertAfter,\n\tinsertBefore,\n} from '@wordpress/icons';\nimport { setBlockTypeImpressions } from '@wordpress/react-native-bridge';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\nimport InserterMenu from './menu';\nimport BlockInsertionPoint from '../block-list/insertion-point';\nimport { store as blockEditorStore } from '../../store';\n\nconst VOICE_OVER_ANNOUNCEMENT_DELAY = 1000;\n\nconst defaultRenderToggle = ( {\n\tonToggle,\n\tdisabled,\n\tstyle,\n\tcontainerStyle,\n\tonLongPress,\n\tuseExpandedMode,\n} ) => {\n\t// The \"expanded mode\" refers to the editor's appearance when no blocks\n\t// are currently selected. The \"add block\" button has a separate style\n\t// for the \"expanded mode\", which are added via the below \"expandedModeViewProps\"\n\t// and \"expandedModeViewText\" variables.\n\tconst expandedModeViewProps = useExpandedMode && {\n\t\ticon: <Icon icon={ plus } style={ style } />,\n\t\tcustomContainerStyles: containerStyle,\n\t\tfixedRatio: false,\n\t};\n\tconst expandedModeViewText = (\n\t\t<Text style={ styles[ 'inserter-menu__add-block-button-text' ] }>\n\t\t\t{ __( 'Add blocks' ) }\n\t\t</Text>\n\t);\n\n\treturn (\n\t\t<ToolbarButton\n\t\t\ttitle={ _x(\n\t\t\t\t'Add block',\n\t\t\t\t'Generic label for block inserter button'\n\t\t\t) }\n\t\t\ticon={ <Icon icon={ plusCircleFilled } style={ style } /> }\n\t\t\tonClick={ onToggle }\n\t\t\textraProps={ {\n\t\t\t\thint: __( 'Double tap to add a block' ),\n\t\t\t\t// testID is present to disambiguate this element for native UI tests. It's not\n\t\t\t\t// usually required for components. See: https://github.com/WordPress/gutenberg/pull/18832#issuecomment-561411389.\n\t\t\t\ttestID: 'add-block-button',\n\t\t\t\tonLongPress,\n\t\t\t} }\n\t\t\tisDisabled={ disabled }\n\t\t\t{ ...expandedModeViewProps }\n\t\t>\n\t\t\t{ useExpandedMode && expandedModeViewText }\n\t\t</ToolbarButton>\n\t);\n};\n\nexport class Inserter extends Component {\n\tannouncementTimeout;\n\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.onToggle = this.onToggle.bind( this );\n\t\tthis.renderInserterToggle = this.renderInserterToggle.bind( this );\n\t\tthis.renderContent = this.renderContent.bind( this );\n\t}\n\n\tcomponentWillUnmount() {\n\t\tclearTimeout( this.announcementTimeout );\n\t}\n\n\tgetInsertionOptions() {\n\t\tconst addBeforeOption = {\n\t\t\tvalue: 'before',\n\t\t\tlabel: __( 'Add Block Before' ),\n\t\t\ticon: plusCircle,\n\t\t};\n\n\t\tconst replaceCurrentOption = {\n\t\t\tvalue: 'replace',\n\t\t\tlabel: __( 'Replace Current Block' ),\n\t\t\ticon: plusCircleFilled,\n\t\t};\n\n\t\tconst addAfterOption = {\n\t\t\tvalue: 'after',\n\t\t\tlabel: __( 'Add Block After' ),\n\t\t\ticon: plusCircle,\n\t\t};\n\n\t\tconst addToBeginningOption = {\n\t\t\tvalue: 'start',\n\t\t\tlabel: __( 'Add To Beginning' ),\n\t\t\ticon: insertBefore,\n\t\t};\n\n\t\tconst addToEndOption = {\n\t\t\tvalue: 'end',\n\t\t\tlabel: __( 'Add To End' ),\n\t\t\ticon: insertAfter,\n\t\t};\n\n\t\tconst { isAnyBlockSelected, isSelectedBlockReplaceable } = this.props;\n\t\tif ( isAnyBlockSelected ) {\n\t\t\tif ( isSelectedBlockReplaceable ) {\n\t\t\t\treturn [\n\t\t\t\t\taddToBeginningOption,\n\t\t\t\t\taddBeforeOption,\n\t\t\t\t\treplaceCurrentOption,\n\t\t\t\t\taddAfterOption,\n\t\t\t\t\taddToEndOption,\n\t\t\t\t];\n\t\t\t}\n\t\t\treturn [\n\t\t\t\taddToBeginningOption,\n\t\t\t\taddBeforeOption,\n\t\t\t\taddAfterOption,\n\t\t\t\taddToEndOption,\n\t\t\t];\n\t\t}\n\t\treturn [ addToBeginningOption, addToEndOption ];\n\t}\n\n\tgetInsertionIndex( insertionType ) {\n\t\tconst {\n\t\t\tinsertionIndexDefault,\n\t\t\tinsertionIndexStart,\n\t\t\tinsertionIndexBefore,\n\t\t\tinsertionIndexAfter,\n\t\t\tinsertionIndexEnd,\n\t\t} = this.props;\n\t\tif ( insertionType === 'start' ) {\n\t\t\treturn insertionIndexStart;\n\t\t}\n\t\tif ( insertionType === 'before' || insertionType === 'replace' ) {\n\t\t\treturn insertionIndexBefore;\n\t\t}\n\t\tif ( insertionType === 'after' ) {\n\t\t\treturn insertionIndexAfter;\n\t\t}\n\t\tif ( insertionType === 'end' ) {\n\t\t\treturn insertionIndexEnd;\n\t\t}\n\t\treturn insertionIndexDefault;\n\t}\n\n\tshouldReplaceBlock( insertionType ) {\n\t\tconst { isSelectedBlockReplaceable } = this.props;\n\t\tif ( insertionType === 'replace' ) {\n\t\t\treturn true;\n\t\t}\n\t\tif ( insertionType === 'default' && isSelectedBlockReplaceable ) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tonToggle( isOpen ) {\n\t\tconst { blockTypeImpressions, onToggle, updateSettings } = this.props;\n\n\t\tif ( ! isOpen ) {\n\t\t\tconst impressionsRemain = Object.values(\n\t\t\t\tblockTypeImpressions\n\t\t\t).some( ( count ) => count > 0 );\n\n\t\t\tif ( impressionsRemain ) {\n\t\t\t\tconst decrementedImpressions = Object.entries(\n\t\t\t\t\tblockTypeImpressions\n\t\t\t\t).reduce(\n\t\t\t\t\t( acc, [ blockName, count ] ) => ( {\n\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t[ blockName ]: Math.max( count - 1, 0 ),\n\t\t\t\t\t} ),\n\t\t\t\t\t{}\n\t\t\t\t);\n\n\t\t\t\t// Persist block type impression to JavaScript store.\n\t\t\t\tupdateSettings( {\n\t\t\t\t\timpressions: decrementedImpressions,\n\t\t\t\t} );\n\n\t\t\t\t// Persist block type impression count to native app store.\n\t\t\t\tsetBlockTypeImpressions( decrementedImpressions );\n\t\t\t}\n\t\t}\n\n\t\t// Surface toggle callback to parent component.\n\t\tif ( onToggle ) {\n\t\t\tonToggle( isOpen );\n\t\t}\n\t\tthis.onInserterToggledAnnouncement( isOpen );\n\t}\n\n\tonInserterToggledAnnouncement( isOpen ) {\n\t\tAccessibilityInfo.isScreenReaderEnabled().then( ( isEnabled ) => {\n\t\t\tif ( isEnabled ) {\n\t\t\t\tconst isIOS = Platform.OS === 'ios';\n\t\t\t\tconst announcement = isOpen\n\t\t\t\t\t? __( 'Scrollable block menu opened. Select a block.' )\n\t\t\t\t\t: __( 'Scrollable block menu closed.' );\n\t\t\t\tthis.announcementTimeout = setTimeout(\n\t\t\t\t\t() =>\n\t\t\t\t\t\tAccessibilityInfo.announceForAccessibility(\n\t\t\t\t\t\t\tannouncement\n\t\t\t\t\t\t),\n\t\t\t\t\tisIOS ? VOICE_OVER_ANNOUNCEMENT_DELAY : 0\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\t}\n\n\t/**\n\t * Render callback to display Dropdown toggle element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onToggle Callback to invoke when toggle is\n\t * pressed.\n\t * @param {boolean} options.isOpen Whether dropdown is currently open.\n\t *\n\t * @return {WPElement} Dropdown toggle element.\n\t */\n\trenderInserterToggle( { onToggle, isOpen } ) {\n\t\tconst {\n\t\t\tdisabled,\n\t\t\trenderToggle = defaultRenderToggle,\n\t\t\tgetStylesFromColorScheme,\n\t\t\tshowSeparator,\n\t\t\tuseExpandedMode,\n\t\t} = this.props;\n\t\tif ( showSeparator && isOpen ) {\n\t\t\treturn <BlockInsertionPoint />;\n\t\t}\n\t\tconst style = useExpandedMode\n\t\t\t? styles[ 'inserter-menu__add-block-button-icon--expanded' ]\n\t\t\t: getStylesFromColorScheme(\n\t\t\t\t\tstyles[ 'inserter-menu__add-block-button-icon' ],\n\t\t\t\t\tstyles[ 'inserter-menu__add-block-button-icon--dark' ]\n\t\t\t );\n\n\t\tconst containerStyle = getStylesFromColorScheme(\n\t\t\tstyles[ 'inserter-menu__add-block-button' ],\n\t\t\tstyles[ 'inserter-menu__add-block-button--dark' ]\n\t\t);\n\n\t\tconst onPress = () => {\n\t\t\tthis.setState(\n\t\t\t\t{\n\t\t\t\t\tdestinationRootClientId: this.props.destinationRootClientId,\n\t\t\t\t\tshouldReplaceBlock: this.shouldReplaceBlock( 'default' ),\n\t\t\t\t\tinsertionIndex: this.getInsertionIndex( 'default' ),\n\t\t\t\t},\n\t\t\t\tonToggle\n\t\t\t);\n\t\t};\n\n\t\tconst onLongPress = () => {\n\t\t\tif ( this.picker ) {\n\t\t\t\tthis.picker.presentPicker();\n\t\t\t}\n\t\t};\n\n\t\tconst onPickerSelect = ( insertionType ) => {\n\t\t\tthis.setState(\n\t\t\t\t{\n\t\t\t\t\tdestinationRootClientId: this.props.destinationRootClientId,\n\t\t\t\t\tshouldReplaceBlock:\n\t\t\t\t\t\tthis.shouldReplaceBlock( insertionType ),\n\t\t\t\t\tinsertionIndex: this.getInsertionIndex( insertionType ),\n\t\t\t\t},\n\t\t\t\tonToggle\n\t\t\t);\n\t\t};\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ renderToggle( {\n\t\t\t\t\tonToggle: onPress,\n\t\t\t\t\tisOpen,\n\t\t\t\t\tdisabled,\n\t\t\t\t\tstyle,\n\t\t\t\t\tcontainerStyle,\n\t\t\t\t\tonLongPress,\n\t\t\t\t\tuseExpandedMode,\n\t\t\t\t} ) }\n\t\t\t\t<Picker\n\t\t\t\t\tref={ ( instance ) => ( this.picker = instance ) }\n\t\t\t\t\toptions={ this.getInsertionOptions() }\n\t\t\t\t\tonChange={ onPickerSelect }\n\t\t\t\t\thideCancelButton\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t}\n\n\t/**\n\t * Render callback to display Dropdown content element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onClose Callback to invoke when dropdown is\n\t * closed.\n\t * @param {boolean} options.isOpen Whether dropdown is currently open.\n\t *\n\t * @return {WPElement} Dropdown content element.\n\t */\n\trenderContent( { onClose, isOpen } ) {\n\t\tconst { clientId, isAppender } = this.props;\n\t\tconst { destinationRootClientId, shouldReplaceBlock, insertionIndex } =\n\t\t\tthis.state;\n\t\treturn (\n\t\t\t<InserterMenu\n\t\t\t\tisOpen={ isOpen }\n\t\t\t\tonSelect={ onClose }\n\t\t\t\tonDismiss={ onClose }\n\t\t\t\trootClientId={ destinationRootClientId }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tisAppender={ isAppender }\n\t\t\t\tshouldReplaceBlock={ shouldReplaceBlock }\n\t\t\t\tinsertionIndex={ insertionIndex }\n\t\t\t/>\n\t\t);\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Dropdown\n\t\t\t\tonToggle={ this.onToggle }\n\t\t\t\theaderTitle={ __( 'Add a block' ) }\n\t\t\t\trenderToggle={ this.renderInserterToggle }\n\t\t\t\trenderContent={ this.renderContent }\n\t\t\t/>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithDispatch( ( dispatch ) => {\n\t\tconst { updateSettings } = dispatch( blockEditorStore );\n\t\treturn { updateSettings };\n\t} ),\n\twithSelect( ( select, { clientId, isAppender, rootClientId } ) => {\n\t\tconst {\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlockSelectionEnd,\n\t\t\tgetBlockOrder,\n\t\t\tgetBlockIndex,\n\t\t\tgetBlock,\n\t\t\tgetSettings: getBlockEditorSettings,\n\t\t} = select( blockEditorStore );\n\n\t\tconst end = getBlockSelectionEnd();\n\t\t// `end` argument (id) can refer to the component which is removed\n\t\t// due to pressing `undo` button, that's why we need to check\n\t\t// if `getBlock( end) is valid, otherwise `null` is passed\n\t\tconst isAnyBlockSelected = ! isAppender && end && getBlock( end );\n\t\tconst destinationRootClientId = isAnyBlockSelected\n\t\t\t? getBlockRootClientId( end )\n\t\t\t: rootClientId;\n\t\tconst selectedBlockIndex = getBlockIndex( end );\n\t\tconst endOfRootIndex = getBlockOrder( rootClientId ).length;\n\t\tconst isSelectedUnmodifiedDefaultBlock = isAnyBlockSelected\n\t\t\t? isUnmodifiedDefaultBlock( getBlock( end ) )\n\t\t\t: undefined;\n\n\t\tfunction getDefaultInsertionIndex() {\n\t\t\tconst { __experimentalShouldInsertAtTheTop: shouldInsertAtTheTop } =\n\t\t\t\tgetBlockEditorSettings();\n\n\t\t\t// If post title is selected insert as first block.\n\t\t\tif ( shouldInsertAtTheTop ) {\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\t// If the clientId is defined, we insert at the position of the block.\n\t\t\tif ( clientId ) {\n\t\t\t\treturn getBlockIndex( clientId );\n\t\t\t}\n\n\t\t\t// If there is a selected block,\n\t\t\tif ( isAnyBlockSelected ) {\n\t\t\t\t// And the last selected block is unmodified (empty), it will be replaced.\n\t\t\t\tif ( isSelectedUnmodifiedDefaultBlock ) {\n\t\t\t\t\treturn selectedBlockIndex;\n\t\t\t\t}\n\n\t\t\t\t// We insert after the selected block.\n\t\t\t\treturn selectedBlockIndex + 1;\n\t\t\t}\n\n\t\t\t// Otherwise, we insert at the end of the current rootClientId.\n\t\t\treturn endOfRootIndex;\n\t\t}\n\n\t\tconst insertionIndexStart = 0;\n\n\t\tconst insertionIndexBefore = isAnyBlockSelected\n\t\t\t? selectedBlockIndex\n\t\t\t: insertionIndexStart;\n\n\t\tconst insertionIndexAfter = isAnyBlockSelected\n\t\t\t? selectedBlockIndex + 1\n\t\t\t: endOfRootIndex;\n\n\t\tconst insertionIndexEnd = endOfRootIndex;\n\n\t\treturn {\n\t\t\tblockTypeImpressions: getBlockEditorSettings().impressions,\n\t\t\tdestinationRootClientId,\n\t\t\tinsertionIndexDefault: getDefaultInsertionIndex(),\n\t\t\tinsertionIndexBefore,\n\t\t\tinsertionIndexAfter,\n\t\t\tinsertionIndexStart,\n\t\t\tinsertionIndexEnd,\n\t\t\tisAnyBlockSelected: !! isAnyBlockSelected,\n\t\t\tisSelectedBlockReplaceable: isSelectedUnmodifiedDefaultBlock,\n\t\t};\n\t} ),\n\n\twithPreferredColorScheme,\n] )( Inserter );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/inserter/index.native.js"],"names":["AccessibilityInfo","Platform","__","_x","Dropdown","ToolbarButton","Picker","Component","withDispatch","withSelect","compose","withPreferredColorScheme","isUnmodifiedDefaultBlock","Icon","plus","plusCircle","plusCircleFilled","insertAfter","insertBefore","setBlockTypeImpressions","styles","InserterMenu","BlockInsertionPoint","store","blockEditorStore","VOICE_OVER_ANNOUNCEMENT_DELAY","defaultRenderToggle","onToggle","disabled","iconStyle","buttonStyle","onLongPress","hint","testID","hitSlop","top","bottom","left","right","Inserter","announcementTimeout","constructor","arguments","bind","renderInserterToggle","renderContent","componentWillUnmount","clearTimeout","getInsertionOptions","addBeforeOption","value","label","icon","replaceCurrentOption","addAfterOption","addToBeginningOption","addToEndOption","isAnyBlockSelected","isSelectedBlockReplaceable","props","getInsertionIndex","insertionType","insertionIndexDefault","insertionIndexStart","insertionIndexBefore","insertionIndexAfter","insertionIndexEnd","shouldReplaceBlock","isOpen","blockTypeImpressions","updateSettings","impressionsRemain","Object","values","some","count","decrementedImpressions","entries","reduce","acc","blockName","Math","max","impressions","onInserterToggledAnnouncement","isScreenReaderEnabled","then","isEnabled","isIOS","OS","announcement","setTimeout","announceForAccessibility","renderToggle","getStylesFromColorScheme","showSeparator","onPress","setState","destinationRootClientId","insertionIndex","picker","presentPicker","onPickerSelect","instance","onClose","clientId","isAppender","state","render","dispatch","select","rootClientId","getBlockRootClientId","getBlockSelectionEnd","getBlockOrder","getBlockIndex","getBlock","getSettings","getBlockEditorSettings","end","selectedBlockIndex","endOfRootIndex","length","isSelectedUnmodifiedDefaultBlock","undefined","getDefaultInsertionIndex","__experimentalShouldInsertAtTheTop","shouldInsertAtTheTop"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,iBAAT,EAA4BC,QAA5B,QAA4C,cAA5C;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,QAAT,EAAmBC,aAAnB,EAAkCC,MAAlC,QAAgD,uBAAhD;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,YAAT,EAAuBC,UAAvB,QAAyC,iBAAzC;AACA,SAASC,OAAT,EAAkBC,wBAAlB,QAAkD,oBAAlD;AACA,SAASC,wBAAT,QAAyC,mBAAzC;AACA,SACCC,IADD,EAECC,IAFD,EAGCC,UAHD,EAICC,gBAJD,EAKCC,WALD,EAMCC,YAND,QAOO,kBAPP;AAQA,SAASC,uBAAT,QAAwC,gCAAxC;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,cAAnB;AACA,OAAOC,YAAP,MAAyB,QAAzB;AACA,OAAOC,mBAAP,MAAgC,+BAAhC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA,MAAMC,6BAA6B,GAAG,IAAtC;;AAEA,MAAMC,mBAAmB,GAAG,CAAE;AAC7BC,E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H;AAIA,QAAMvD,iBAAiB,GAAGuD,cAA1B;AAEA,SAAO;AACNpD,IAAAA,oBAAoB,EAAEiD,sBAAsB,GAAGnC,WADzC;AAENe,IAAAA,uBAFM;AAGNpC,IAAAA,qBAAqB,EAAE+D,wBAAwB,EAHzC;AAIN7D,IAAAA,oBAJM;AAKNC,IAAAA,mBALM;AAMNF,IAAAA,mBANM;AAONG,IAAAA,iBAPM;AAQNT,IAAAA,kBAAkB,EAAE,CAAC,CAAEA,kBARjB;AASNC,IAAAA,0BAA0B,EAAEiE;AATtB,GAAP;AAWA,CA5ES,CALa,EAmFvBhH,wBAnFuB,CAAF,CAAP,CAoFV4B,QApFU,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { AccessibilityInfo, Platform } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport { Dropdown, ToolbarButton, Picker } from '@wordpress/components';\nimport { Component } from '@wordpress/element';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose, withPreferredColorScheme } from '@wordpress/compose';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\nimport {\n\tIcon,\n\tplus,\n\tplusCircle,\n\tplusCircleFilled,\n\tinsertAfter,\n\tinsertBefore,\n} from '@wordpress/icons';\nimport { setBlockTypeImpressions } from '@wordpress/react-native-bridge';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\nimport InserterMenu from './menu';\nimport BlockInsertionPoint from '../block-list/insertion-point';\nimport { store as blockEditorStore } from '../../store';\n\nconst VOICE_OVER_ANNOUNCEMENT_DELAY = 1000;\n\nconst defaultRenderToggle = ( {\n\tonToggle,\n\tdisabled,\n\ticonStyle,\n\tbuttonStyle,\n\tonLongPress,\n} ) => {\n\treturn (\n\t\t<ToolbarButton\n\t\t\ttitle={ _x(\n\t\t\t\t'Add block',\n\t\t\t\t'Generic label for block inserter button'\n\t\t\t) }\n\t\t\ticon={ <Icon icon={ plus } style={ iconStyle } /> }\n\t\t\tonClick={ onToggle }\n\t\t\textraProps={ {\n\t\t\t\thint: __( 'Double tap to add a block' ),\n\t\t\t\t// testID is present to disambiguate this element for native UI tests. It's not\n\t\t\t\t// usually required for components. See: https://github.com/WordPress/gutenberg/pull/18832#issuecomment-561411389.\n\t\t\t\ttestID: 'add-block-button',\n\t\t\t\tonLongPress,\n\t\t\t\thitSlop: { top: 10, bottom: 10, left: 10, right: 10 },\n\t\t\t} }\n\t\t\tisDisabled={ disabled }\n\t\t\tcustomContainerStyles={ buttonStyle }\n\t\t\tfixedRatio={ false }\n\t\t/>\n\t);\n};\n\nexport class Inserter extends Component {\n\tannouncementTimeout;\n\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.onToggle = this.onToggle.bind( this );\n\t\tthis.renderInserterToggle = this.renderInserterToggle.bind( this );\n\t\tthis.renderContent = this.renderContent.bind( this );\n\t}\n\n\tcomponentWillUnmount() {\n\t\tclearTimeout( this.announcementTimeout );\n\t}\n\n\tgetInsertionOptions() {\n\t\tconst addBeforeOption = {\n\t\t\tvalue: 'before',\n\t\t\tlabel: __( 'Add Block Before' ),\n\t\t\ticon: plusCircle,\n\t\t};\n\n\t\tconst replaceCurrentOption = {\n\t\t\tvalue: 'replace',\n\t\t\tlabel: __( 'Replace Current Block' ),\n\t\t\ticon: plusCircleFilled,\n\t\t};\n\n\t\tconst addAfterOption = {\n\t\t\tvalue: 'after',\n\t\t\tlabel: __( 'Add Block After' ),\n\t\t\ticon: plusCircle,\n\t\t};\n\n\t\tconst addToBeginningOption = {\n\t\t\tvalue: 'start',\n\t\t\tlabel: __( 'Add To Beginning' ),\n\t\t\ticon: insertBefore,\n\t\t};\n\n\t\tconst addToEndOption = {\n\t\t\tvalue: 'end',\n\t\t\tlabel: __( 'Add To End' ),\n\t\t\ticon: insertAfter,\n\t\t};\n\n\t\tconst { isAnyBlockSelected, isSelectedBlockReplaceable } = this.props;\n\t\tif ( isAnyBlockSelected ) {\n\t\t\tif ( isSelectedBlockReplaceable ) {\n\t\t\t\treturn [\n\t\t\t\t\taddToBeginningOption,\n\t\t\t\t\taddBeforeOption,\n\t\t\t\t\treplaceCurrentOption,\n\t\t\t\t\taddAfterOption,\n\t\t\t\t\taddToEndOption,\n\t\t\t\t];\n\t\t\t}\n\t\t\treturn [\n\t\t\t\taddToBeginningOption,\n\t\t\t\taddBeforeOption,\n\t\t\t\taddAfterOption,\n\t\t\t\taddToEndOption,\n\t\t\t];\n\t\t}\n\t\treturn [ addToBeginningOption, addToEndOption ];\n\t}\n\n\tgetInsertionIndex( insertionType ) {\n\t\tconst {\n\t\t\tinsertionIndexDefault,\n\t\t\tinsertionIndexStart,\n\t\t\tinsertionIndexBefore,\n\t\t\tinsertionIndexAfter,\n\t\t\tinsertionIndexEnd,\n\t\t} = this.props;\n\t\tif ( insertionType === 'start' ) {\n\t\t\treturn insertionIndexStart;\n\t\t}\n\t\tif ( insertionType === 'before' || insertionType === 'replace' ) {\n\t\t\treturn insertionIndexBefore;\n\t\t}\n\t\tif ( insertionType === 'after' ) {\n\t\t\treturn insertionIndexAfter;\n\t\t}\n\t\tif ( insertionType === 'end' ) {\n\t\t\treturn insertionIndexEnd;\n\t\t}\n\t\treturn insertionIndexDefault;\n\t}\n\n\tshouldReplaceBlock( insertionType ) {\n\t\tconst { isSelectedBlockReplaceable } = this.props;\n\t\tif ( insertionType === 'replace' ) {\n\t\t\treturn true;\n\t\t}\n\t\tif ( insertionType === 'default' && isSelectedBlockReplaceable ) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tonToggle( isOpen ) {\n\t\tconst { blockTypeImpressions, onToggle, updateSettings } = this.props;\n\n\t\tif ( ! isOpen ) {\n\t\t\tconst impressionsRemain = Object.values(\n\t\t\t\tblockTypeImpressions\n\t\t\t).some( ( count ) => count > 0 );\n\n\t\t\tif ( impressionsRemain ) {\n\t\t\t\tconst decrementedImpressions = Object.entries(\n\t\t\t\t\tblockTypeImpressions\n\t\t\t\t).reduce(\n\t\t\t\t\t( acc, [ blockName, count ] ) => ( {\n\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t[ blockName ]: Math.max( count - 1, 0 ),\n\t\t\t\t\t} ),\n\t\t\t\t\t{}\n\t\t\t\t);\n\n\t\t\t\t// Persist block type impression to JavaScript store.\n\t\t\t\tupdateSettings( {\n\t\t\t\t\timpressions: decrementedImpressions,\n\t\t\t\t} );\n\n\t\t\t\t// Persist block type impression count to native app store.\n\t\t\t\tsetBlockTypeImpressions( decrementedImpressions );\n\t\t\t}\n\t\t}\n\n\t\t// Surface toggle callback to parent component.\n\t\tif ( onToggle ) {\n\t\t\tonToggle( isOpen );\n\t\t}\n\t\tthis.onInserterToggledAnnouncement( isOpen );\n\t}\n\n\tonInserterToggledAnnouncement( isOpen ) {\n\t\tAccessibilityInfo.isScreenReaderEnabled().then( ( isEnabled ) => {\n\t\t\tif ( isEnabled ) {\n\t\t\t\tconst isIOS = Platform.OS === 'ios';\n\t\t\t\tconst announcement = isOpen\n\t\t\t\t\t? __( 'Scrollable block menu opened. Select a block.' )\n\t\t\t\t\t: __( 'Scrollable block menu closed.' );\n\t\t\t\tthis.announcementTimeout = setTimeout(\n\t\t\t\t\t() =>\n\t\t\t\t\t\tAccessibilityInfo.announceForAccessibility(\n\t\t\t\t\t\t\tannouncement\n\t\t\t\t\t\t),\n\t\t\t\t\tisIOS ? VOICE_OVER_ANNOUNCEMENT_DELAY : 0\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\t}\n\n\t/**\n\t * Render callback to display Dropdown toggle element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onToggle Callback to invoke when toggle is\n\t * pressed.\n\t * @param {boolean} options.isOpen Whether dropdown is currently open.\n\t *\n\t * @return {WPElement} Dropdown toggle element.\n\t */\n\trenderInserterToggle( { onToggle, isOpen } ) {\n\t\tconst {\n\t\t\tdisabled,\n\t\t\trenderToggle = defaultRenderToggle,\n\t\t\tgetStylesFromColorScheme,\n\t\t\tshowSeparator,\n\t\t} = this.props;\n\t\tif ( showSeparator && isOpen ) {\n\t\t\treturn <BlockInsertionPoint />;\n\t\t}\n\n\t\tconst buttonStyle = getStylesFromColorScheme(\n\t\t\tstyles[ 'inserter-menu__add-block-button' ],\n\t\t\tstyles[ 'inserter-menu__add-block-button--dark' ]\n\t\t);\n\n\t\tconst iconStyle = getStylesFromColorScheme(\n\t\t\tstyles[ 'inserter-menu__add-block-button-icon' ],\n\t\t\tstyles[ 'inserter-menu__add-block-button-icon--dark' ]\n\t\t);\n\n\t\tconst onPress = () => {\n\t\t\tthis.setState(\n\t\t\t\t{\n\t\t\t\t\tdestinationRootClientId: this.props.destinationRootClientId,\n\t\t\t\t\tshouldReplaceBlock: this.shouldReplaceBlock( 'default' ),\n\t\t\t\t\tinsertionIndex: this.getInsertionIndex( 'default' ),\n\t\t\t\t},\n\t\t\t\tonToggle\n\t\t\t);\n\t\t};\n\n\t\tconst onLongPress = () => {\n\t\t\tif ( this.picker ) {\n\t\t\t\tthis.picker.presentPicker();\n\t\t\t}\n\t\t};\n\n\t\tconst onPickerSelect = ( insertionType ) => {\n\t\t\tthis.setState(\n\t\t\t\t{\n\t\t\t\t\tdestinationRootClientId: this.props.destinationRootClientId,\n\t\t\t\t\tshouldReplaceBlock:\n\t\t\t\t\t\tthis.shouldReplaceBlock( insertionType ),\n\t\t\t\t\tinsertionIndex: this.getInsertionIndex( insertionType ),\n\t\t\t\t},\n\t\t\t\tonToggle\n\t\t\t);\n\t\t};\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ renderToggle( {\n\t\t\t\t\tonToggle: onPress,\n\t\t\t\t\tisOpen,\n\t\t\t\t\tdisabled,\n\t\t\t\t\ticonStyle,\n\t\t\t\t\tbuttonStyle,\n\t\t\t\t\tonLongPress,\n\t\t\t\t} ) }\n\t\t\t\t<Picker\n\t\t\t\t\tref={ ( instance ) => ( this.picker = instance ) }\n\t\t\t\t\toptions={ this.getInsertionOptions() }\n\t\t\t\t\tonChange={ onPickerSelect }\n\t\t\t\t\thideCancelButton\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t}\n\n\t/**\n\t * Render callback to display Dropdown content element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onClose Callback to invoke when dropdown is\n\t * closed.\n\t * @param {boolean} options.isOpen Whether dropdown is currently open.\n\t *\n\t * @return {WPElement} Dropdown content element.\n\t */\n\trenderContent( { onClose, isOpen } ) {\n\t\tconst { clientId, isAppender } = this.props;\n\t\tconst { destinationRootClientId, shouldReplaceBlock, insertionIndex } =\n\t\t\tthis.state;\n\t\treturn (\n\t\t\t<InserterMenu\n\t\t\t\tisOpen={ isOpen }\n\t\t\t\tonSelect={ onClose }\n\t\t\t\tonDismiss={ onClose }\n\t\t\t\trootClientId={ destinationRootClientId }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tisAppender={ isAppender }\n\t\t\t\tshouldReplaceBlock={ shouldReplaceBlock }\n\t\t\t\tinsertionIndex={ insertionIndex }\n\t\t\t/>\n\t\t);\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Dropdown\n\t\t\t\tonToggle={ this.onToggle }\n\t\t\t\theaderTitle={ __( 'Add a block' ) }\n\t\t\t\trenderToggle={ this.renderInserterToggle }\n\t\t\t\trenderContent={ this.renderContent }\n\t\t\t/>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithDispatch( ( dispatch ) => {\n\t\tconst { updateSettings } = dispatch( blockEditorStore );\n\t\treturn { updateSettings };\n\t} ),\n\twithSelect( ( select, { clientId, isAppender, rootClientId } ) => {\n\t\tconst {\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlockSelectionEnd,\n\t\t\tgetBlockOrder,\n\t\t\tgetBlockIndex,\n\t\t\tgetBlock,\n\t\t\tgetSettings: getBlockEditorSettings,\n\t\t} = select( blockEditorStore );\n\n\t\tconst end = getBlockSelectionEnd();\n\t\t// `end` argument (id) can refer to the component which is removed\n\t\t// due to pressing `undo` button, that's why we need to check\n\t\t// if `getBlock( end) is valid, otherwise `null` is passed\n\t\tconst isAnyBlockSelected = ! isAppender && end && getBlock( end );\n\t\tconst destinationRootClientId = isAnyBlockSelected\n\t\t\t? getBlockRootClientId( end )\n\t\t\t: rootClientId;\n\t\tconst selectedBlockIndex = getBlockIndex( end );\n\t\tconst endOfRootIndex = getBlockOrder( rootClientId ).length;\n\t\tconst isSelectedUnmodifiedDefaultBlock = isAnyBlockSelected\n\t\t\t? isUnmodifiedDefaultBlock( getBlock( end ) )\n\t\t\t: undefined;\n\n\t\tfunction getDefaultInsertionIndex() {\n\t\t\tconst { __experimentalShouldInsertAtTheTop: shouldInsertAtTheTop } =\n\t\t\t\tgetBlockEditorSettings();\n\n\t\t\t// If post title is selected insert as first block.\n\t\t\tif ( shouldInsertAtTheTop ) {\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\t// If the clientId is defined, we insert at the position of the block.\n\t\t\tif ( clientId ) {\n\t\t\t\treturn getBlockIndex( clientId );\n\t\t\t}\n\n\t\t\t// If there is a selected block,\n\t\t\tif ( isAnyBlockSelected ) {\n\t\t\t\t// And the last selected block is unmodified (empty), it will be replaced.\n\t\t\t\tif ( isSelectedUnmodifiedDefaultBlock ) {\n\t\t\t\t\treturn selectedBlockIndex;\n\t\t\t\t}\n\n\t\t\t\t// We insert after the selected block.\n\t\t\t\treturn selectedBlockIndex + 1;\n\t\t\t}\n\n\t\t\t// Otherwise, we insert at the end of the current rootClientId.\n\t\t\treturn endOfRootIndex;\n\t\t}\n\n\t\tconst insertionIndexStart = 0;\n\n\t\tconst insertionIndexBefore = isAnyBlockSelected\n\t\t\t? selectedBlockIndex\n\t\t\t: insertionIndexStart;\n\n\t\tconst insertionIndexAfter = isAnyBlockSelected\n\t\t\t? selectedBlockIndex + 1\n\t\t\t: endOfRootIndex;\n\n\t\tconst insertionIndexEnd = endOfRootIndex;\n\n\t\treturn {\n\t\t\tblockTypeImpressions: getBlockEditorSettings().impressions,\n\t\t\tdestinationRootClientId,\n\t\t\tinsertionIndexDefault: getDefaultInsertionIndex(),\n\t\t\tinsertionIndexBefore,\n\t\t\tinsertionIndexAfter,\n\t\t\tinsertionIndexStart,\n\t\t\tinsertionIndexEnd,\n\t\t\tisAnyBlockSelected: !! isAnyBlockSelected,\n\t\t\tisSelectedBlockReplaceable: isSelectedUnmodifiedDefaultBlock,\n\t\t};\n\t} ),\n\n\twithPreferredColorScheme,\n] )( Inserter );\n"]}
@@ -11,12 +11,31 @@ import { __ } from '@wordpress/i18n';
11
11
  import { close } from '@wordpress/icons';
12
12
  import { store as preferencesStore } from '@wordpress/preferences';
13
13
  const PREFERENCE_NAME = 'isResuableBlocksrRenameHintVisible';
14
- export default function ReusableBlocksRenameHint() {
15
- const isReusableBlocksRenameHint = useSelect(select => {
14
+ /*
15
+ * This hook was added in 6.3 to help users with the transition from Reusable blocks to Patterns.
16
+ * It is only exported for use in the reusable-blocks package as well as block-editor.
17
+ * It will be removed in 6.4. and should not be used in any new code.
18
+ */
19
+
20
+ export function useReusableBlocksRenameHint() {
21
+ return useSelect(select => {
16
22
  var _select$get;
17
23
 
18
24
  return (_select$get = select(preferencesStore).get('core', PREFERENCE_NAME)) !== null && _select$get !== void 0 ? _select$get : true;
19
25
  }, []);
26
+ }
27
+ /*
28
+ * This component was added in 6.3 to help users with the transition from Reusable blocks to Patterns.
29
+ * It is only exported for use in the reusable-blocks package as well as block-editor.
30
+ * It will be removed in 6.4. and should not be used in any new code.
31
+ */
32
+
33
+ export default function ReusableBlocksRenameHint() {
34
+ const isReusableBlocksRenameHint = useSelect(select => {
35
+ var _select$get2;
36
+
37
+ return (_select$get2 = select(preferencesStore).get('core', PREFERENCE_NAME)) !== null && _select$get2 !== void 0 ? _select$get2 : true;
38
+ }, []);
20
39
  const ref = useRef();
21
40
  const {
22
41
  set: setPreference
@@ -31,7 +50,7 @@ export default function ReusableBlocksRenameHint() {
31
50
  className: "reusable-blocks-menu-items__rename-hint"
32
51
  }, createElement("div", {
33
52
  className: "reusable-blocks-menu-items__rename-hint-content"
34
- }, __('Reusable blocks are now called patterns. A synced pattern will behave in exactly the same way as a reusable block.')), createElement(Button, {
53
+ }, __('Reusable blocks are now synced patterns. A synced pattern will behave in exactly the same way as a reusable block.')), createElement(Button, {
35
54
  className: "reusable-blocks-menu-items__rename-hint-dismiss",
36
55
  icon: close,
37
56
  iconSize: "16",
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/inserter/reusable-block-rename-hint.js"],"names":["Button","useDispatch","useSelect","focus","useRef","__","close","store","preferencesStore","PREFERENCE_NAME","ReusableBlocksRenameHint","isReusableBlocksRenameHint","select","get","ref","set","setPreference","previousElement","tabbable","findPrevious","current"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,uBAAvB;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,KAAT,QAAsB,gBAAtB;AACA,SAASC,MAAT,QAAuB,oBAAvB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAT,QAAsB,kBAAtB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,wBAA1C;AAEA,MAAMC,eAAe,GAAG,oCAAxB;AAEA,eAAe,SAASC,wBAAT,GAAoC;AAClD,QAAMC,0BAA0B,GAAGT,SAAS,CACzCU,MAAF;AAAA;;AAAA,0BACCA,MAAM,CAAEJ,gBAAF,CAAN,CAA2BK,GAA3B,CAAgC,MAAhC,EAAwCJ,eAAxC,CADD,qDAC8D,IAD9D;AAAA,GAD2C,EAG3C,EAH2C,CAA5C;AAMA,QAAMK,GAAG,GAAGV,MAAM,EAAlB;AAEA,QAAM;AAAEW,IAAAA,GAAG,EAAEC;AAAP,MAAyBf,WAAW,CAAEO,gBAAF,CAA1C;;AACA,MAAK,CAAEG,0BAAP,EAAoC;AACnC,WAAO,IAAP;AACA;;AAED,SACC;AAAK,IAAA,GAAG,EAAGG,GAAX;AAAiB,IAAA,SAAS,EAAC;AAA3B,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGT,EAAE,CACH,oHADG,CADL,CADD,EAMC,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,iDADX;AAEC,IAAA,IAAI,EAAGC,KAFR;AAGC,IAAA,QAAQ,EAAC,IAHV;AAIC,IAAA,KAAK,EAAGD,EAAE,CAAE,cAAF,CAJX;AAKC,IAAA,OAAO,EAAG,MAAM;AACf;AACA,YAAMY,eAAe,GAAGd,KAAK,CAACe,QAAN,CAAeC,YAAf,CACvBL,GAAG,CAACM,OADmB,CAAxB;AAGAH,MAAAA,eAAe,EAAEd,KAAjB;AACAa,MAAAA,aAAa,CAAE,MAAF,EAAUP,eAAV,EAA2B,KAA3B,CAAb;AACA,KAZF;AAaC,IAAA,WAAW,EAAG;AAbf,IAND,CADD;AAwBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { focus } from '@wordpress/dom';\nimport { useRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { close } from '@wordpress/icons';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\nconst PREFERENCE_NAME = 'isResuableBlocksrRenameHintVisible';\n\nexport default function ReusableBlocksRenameHint() {\n\tconst isReusableBlocksRenameHint = useSelect(\n\t\t( select ) =>\n\t\t\tselect( preferencesStore ).get( 'core', PREFERENCE_NAME ) ?? true,\n\t\t[]\n\t);\n\n\tconst ref = useRef();\n\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\tif ( ! isReusableBlocksRenameHint ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div ref={ ref } className=\"reusable-blocks-menu-items__rename-hint\">\n\t\t\t<div className=\"reusable-blocks-menu-items__rename-hint-content\">\n\t\t\t\t{ __(\n\t\t\t\t\t'Reusable blocks are now called patterns. A synced pattern will behave in exactly the same way as a reusable block.'\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t<Button\n\t\t\t\tclassName=\"reusable-blocks-menu-items__rename-hint-dismiss\"\n\t\t\t\ticon={ close }\n\t\t\t\ticonSize=\"16\"\n\t\t\t\tlabel={ __( 'Dismiss hint' ) }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\t// Retain focus when dismissing the element.\n\t\t\t\t\tconst previousElement = focus.tabbable.findPrevious(\n\t\t\t\t\t\tref.current\n\t\t\t\t\t);\n\t\t\t\t\tpreviousElement?.focus();\n\t\t\t\t\tsetPreference( 'core', PREFERENCE_NAME, false );\n\t\t\t\t} }\n\t\t\t\tshowTooltip={ false }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/inserter/reusable-block-rename-hint.js"],"names":["Button","useDispatch","useSelect","focus","useRef","__","close","store","preferencesStore","PREFERENCE_NAME","useReusableBlocksRenameHint","select","get","ReusableBlocksRenameHint","isReusableBlocksRenameHint","ref","set","setPreference","previousElement","tabbable","findPrevious","current"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,uBAAvB;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,KAAT,QAAsB,gBAAtB;AACA,SAASC,MAAT,QAAuB,oBAAvB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAT,QAAsB,kBAAtB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,wBAA1C;AAEA,MAAMC,eAAe,GAAG,oCAAxB;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,2BAAT,GAAuC;AAC7C,SAAOR,SAAS,CACbS,MAAF;AAAA;;AAAA,0BACCA,MAAM,CAAEH,gBAAF,CAAN,CAA2BI,GAA3B,CAAgC,MAAhC,EAAwCH,eAAxC,CADD,qDAC8D,IAD9D;AAAA,GADe,EAGf,EAHe,CAAhB;AAKA;AAED;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASI,wBAAT,GAAoC;AAClD,QAAMC,0BAA0B,GAAGZ,SAAS,CACzCS,MAAF;AAAA;;AAAA,2BACCA,MAAM,CAAEH,gBAAF,CAAN,CAA2BI,GAA3B,CAAgC,MAAhC,EAAwCH,eAAxC,CADD,uDAC8D,IAD9D;AAAA,GAD2C,EAG3C,EAH2C,CAA5C;AAMA,QAAMM,GAAG,GAAGX,MAAM,EAAlB;AAEA,QAAM;AAAEY,IAAAA,GAAG,EAAEC;AAAP,MAAyBhB,WAAW,CAAEO,gBAAF,CAA1C;;AACA,MAAK,CAAEM,0BAAP,EAAoC;AACnC,WAAO,IAAP;AACA;;AAED,SACC;AAAK,IAAA,GAAG,EAAGC,GAAX;AAAiB,IAAA,SAAS,EAAC;AAA3B,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGV,EAAE,CACH,oHADG,CADL,CADD,EAMC,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,iDADX;AAEC,IAAA,IAAI,EAAGC,KAFR;AAGC,IAAA,QAAQ,EAAC,IAHV;AAIC,IAAA,KAAK,EAAGD,EAAE,CAAE,cAAF,CAJX;AAKC,IAAA,OAAO,EAAG,MAAM;AACf;AACA,YAAMa,eAAe,GAAGf,KAAK,CAACgB,QAAN,CAAeC,YAAf,CACvBL,GAAG,CAACM,OADmB,CAAxB;AAGAH,MAAAA,eAAe,EAAEf,KAAjB;AACAc,MAAAA,aAAa,CAAE,MAAF,EAAUR,eAAV,EAA2B,KAA3B,CAAb;AACA,KAZF;AAaC,IAAA,WAAW,EAAG;AAbf,IAND,CADD;AAwBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { focus } from '@wordpress/dom';\nimport { useRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { close } from '@wordpress/icons';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\nconst PREFERENCE_NAME = 'isResuableBlocksrRenameHintVisible';\n/*\n * This hook was added in 6.3 to help users with the transition from Reusable blocks to Patterns.\n * It is only exported for use in the reusable-blocks package as well as block-editor.\n * It will be removed in 6.4. and should not be used in any new code.\n */\nexport function useReusableBlocksRenameHint() {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( preferencesStore ).get( 'core', PREFERENCE_NAME ) ?? true,\n\t\t[]\n\t);\n}\n\n/*\n * This component was added in 6.3 to help users with the transition from Reusable blocks to Patterns.\n * It is only exported for use in the reusable-blocks package as well as block-editor.\n * It will be removed in 6.4. and should not be used in any new code.\n */\nexport default function ReusableBlocksRenameHint() {\n\tconst isReusableBlocksRenameHint = useSelect(\n\t\t( select ) =>\n\t\t\tselect( preferencesStore ).get( 'core', PREFERENCE_NAME ) ?? true,\n\t\t[]\n\t);\n\n\tconst ref = useRef();\n\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\tif ( ! isReusableBlocksRenameHint ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div ref={ ref } className=\"reusable-blocks-menu-items__rename-hint\">\n\t\t\t<div className=\"reusable-blocks-menu-items__rename-hint-content\">\n\t\t\t\t{ __(\n\t\t\t\t\t'Reusable blocks are now synced patterns. A synced pattern will behave in exactly the same way as a reusable block.'\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t<Button\n\t\t\t\tclassName=\"reusable-blocks-menu-items__rename-hint-dismiss\"\n\t\t\t\ticon={ close }\n\t\t\t\ticonSize=\"16\"\n\t\t\t\tlabel={ __( 'Dismiss hint' ) }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\t// Retain focus when dismissing the element.\n\t\t\t\t\tconst previousElement = focus.tabbable.findPrevious(\n\t\t\t\t\t\tref.current\n\t\t\t\t\t);\n\t\t\t\t\tpreviousElement?.focus();\n\t\t\t\t\tsetPreference( 'core', PREFERENCE_NAME, false );\n\t\t\t\t} }\n\t\t\t\tshowTooltip={ false }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
@@ -25,8 +25,9 @@ function ReusableBlocksList({
25
25
  const [items,,, onSelectItem] = useBlockTypesState(rootClientId, onInsert);
26
26
  const filteredItems = useMemo(() => {
27
27
  return items.filter(({
28
- category
29
- }) => category === 'reusable');
28
+ category,
29
+ syncStatus
30
+ }) => category === 'reusable' && syncStatus !== 'unsynced');
30
31
  }, [items]);
31
32
 
32
33
  if (filteredItems.length === 0) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/inserter/reusable-blocks-tab.js"],"names":["useMemo","__","addQueryArgs","Button","BlockTypesList","InserterPanel","InserterNoResults","useBlockTypesState","ReusableBlocksRenameHint","ReusableBlocksList","onHover","onInsert","rootClientId","items","onSelectItem","filteredItems","filter","category","length","ReusableBlocksTab","post_type"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SAASC,MAAT,QAAuB,uBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,qBAA3B;AACA,OAAOC,aAAP,MAA0B,SAA1B;AACA,OAAOC,iBAAP,MAA8B,cAA9B;AACA,OAAOC,kBAAP,MAA+B,+BAA/B;AACA,OAAOC,wBAAP,MAAqC,8BAArC;;AAEA,SAASC,kBAAT,CAA6B;AAAEC,EAAAA,OAAF;AAAWC,EAAAA,QAAX;AAAqBC,EAAAA;AAArB,CAA7B,EAAmE;AAClE,QAAM,CAAEC,KAAF,IAAaC,YAAb,IAA8BP,kBAAkB,CACrDK,YADqD,EAErDD,QAFqD,CAAtD;AAKA,QAAMI,aAAa,GAAGf,OAAO,CAAE,MAAM;AACpC,WAAOa,KAAK,CAACG,MAAN,CAAc,CAAE;AAAEC,MAAAA;AAAF,KAAF,KAAoBA,QAAQ,KAAK,UAA/C,CAAP;AACA,GAF4B,EAE1B,CAAEJ,KAAF,CAF0B,CAA7B;;AAIA,MAAKE,aAAa,CAACG,MAAd,KAAyB,CAA9B,EAAkC;AACjC,WAAO,cAAC,iBAAD,OAAP;AACA;;AAED,SACC,cAAC,aAAD;AAAe,IAAA,KAAK,EAAGjB,EAAE,CAAE,iBAAF;AAAzB,KACC,cAAC,cAAD;AACC,IAAA,KAAK,EAAGc,aADT;AAEC,IAAA,QAAQ,EAAGD,YAFZ;AAGC,IAAA,OAAO,EAAGJ,OAHX;AAIC,IAAA,KAAK,EAAGT,EAAE,CAAE,iBAAF;AAJX,IADD,CADD;AAUA,C,CAED;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASkB,iBAAT,CAA4B;AAAEP,EAAAA,YAAF;AAAgBD,EAAAA,QAAhB;AAA0BD,EAAAA;AAA1B,CAA5B,EAAkE;AACxE,SACC,8BACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,wBAAD,OADD,CADD,EAIC,cAAC,kBAAD;AACC,IAAA,OAAO,EAAGA,OADX;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,YAAY,EAAGC;AAHhB,IAJD,EASC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,+CADX;AAEC,IAAA,OAAO,EAAC,WAFT;AAGC,IAAA,IAAI,EAAGV,YAAY,CAAE,UAAF,EAAc;AAChCkB,MAAAA,SAAS,EAAE;AADqB,KAAd;AAHpB,KAOGnB,EAAE,CAAE,oBAAF,CAPL,CADD,CATD,CADD;AAuBA;AAED,eAAekB,iBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { addQueryArgs } from '@wordpress/url';\nimport { Button } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockTypesList from '../block-types-list';\nimport InserterPanel from './panel';\nimport InserterNoResults from './no-results';\nimport useBlockTypesState from './hooks/use-block-types-state';\nimport ReusableBlocksRenameHint from './reusable-block-rename-hint';\n\nfunction ReusableBlocksList( { onHover, onInsert, rootClientId } ) {\n\tconst [ items, , , onSelectItem ] = useBlockTypesState(\n\t\trootClientId,\n\t\tonInsert\n\t);\n\n\tconst filteredItems = useMemo( () => {\n\t\treturn items.filter( ( { category } ) => category === 'reusable' );\n\t}, [ items ] );\n\n\tif ( filteredItems.length === 0 ) {\n\t\treturn <InserterNoResults />;\n\t}\n\n\treturn (\n\t\t<InserterPanel title={ __( 'Synced patterns' ) }>\n\t\t\t<BlockTypesList\n\t\t\t\titems={ filteredItems }\n\t\t\t\tonSelect={ onSelectItem }\n\t\t\t\tonHover={ onHover }\n\t\t\t\tlabel={ __( 'Synced patterns' ) }\n\t\t\t/>\n\t\t</InserterPanel>\n\t);\n}\n\n// The unwrapped component is only exported for use by unit tests.\n/**\n * List of reusable blocks shown in the \"Reusable\" tab of the inserter.\n *\n * @param {Object} props Component props.\n * @param {?string} props.rootClientId Client id of block to insert into.\n * @param {Function} props.onInsert Callback to run when item is inserted.\n * @param {Function} props.onHover Callback to run when item is hovered.\n *\n * @return {WPComponent} The component.\n */\nexport function ReusableBlocksTab( { rootClientId, onInsert, onHover } ) {\n\treturn (\n\t\t<>\n\t\t\t<div className=\"block-editor-inserter__hint\">\n\t\t\t\t<ReusableBlocksRenameHint />\n\t\t\t</div>\n\t\t\t<ReusableBlocksList\n\t\t\t\tonHover={ onHover }\n\t\t\t\tonInsert={ onInsert }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t/>\n\t\t\t<div className=\"block-editor-inserter__manage-reusable-blocks-container\">\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"block-editor-inserter__manage-reusable-blocks\"\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\thref={ addQueryArgs( 'edit.php', {\n\t\t\t\t\t\tpost_type: 'wp_block',\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Manage my patterns' ) }\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default ReusableBlocksTab;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/inserter/reusable-blocks-tab.js"],"names":["useMemo","__","addQueryArgs","Button","BlockTypesList","InserterPanel","InserterNoResults","useBlockTypesState","ReusableBlocksRenameHint","ReusableBlocksList","onHover","onInsert","rootClientId","items","onSelectItem","filteredItems","filter","category","syncStatus","length","ReusableBlocksTab","post_type"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SAASC,MAAT,QAAuB,uBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,qBAA3B;AACA,OAAOC,aAAP,MAA0B,SAA1B;AACA,OAAOC,iBAAP,MAA8B,cAA9B;AACA,OAAOC,kBAAP,MAA+B,+BAA/B;AACA,OAAOC,wBAAP,MAAqC,8BAArC;;AAEA,SAASC,kBAAT,CAA6B;AAAEC,EAAAA,OAAF;AAAWC,EAAAA,QAAX;AAAqBC,EAAAA;AAArB,CAA7B,EAAmE;AAClE,QAAM,CAAEC,KAAF,IAAaC,YAAb,IAA8BP,kBAAkB,CACrDK,YADqD,EAErDD,QAFqD,CAAtD;AAKA,QAAMI,aAAa,GAAGf,OAAO,CAAE,MAAM;AACpC,WAAOa,KAAK,CAACG,MAAN,CACN,CAAE;AAAEC,MAAAA,QAAF;AAAYC,MAAAA;AAAZ,KAAF,KACCD,QAAQ,KAAK,UAAb,IAA2BC,UAAU,KAAK,UAFrC,CAAP;AAIA,GAL4B,EAK1B,CAAEL,KAAF,CAL0B,CAA7B;;AAOA,MAAKE,aAAa,CAACI,MAAd,KAAyB,CAA9B,EAAkC;AACjC,WAAO,cAAC,iBAAD,OAAP;AACA;;AAED,SACC,cAAC,aAAD;AAAe,IAAA,KAAK,EAAGlB,EAAE,CAAE,iBAAF;AAAzB,KACC,cAAC,cAAD;AACC,IAAA,KAAK,EAAGc,aADT;AAEC,IAAA,QAAQ,EAAGD,YAFZ;AAGC,IAAA,OAAO,EAAGJ,OAHX;AAIC,IAAA,KAAK,EAAGT,EAAE,CAAE,iBAAF;AAJX,IADD,CADD;AAUA,C,CAED;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASmB,iBAAT,CAA4B;AAAER,EAAAA,YAAF;AAAgBD,EAAAA,QAAhB;AAA0BD,EAAAA;AAA1B,CAA5B,EAAkE;AACxE,SACC,8BACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,wBAAD,OADD,CADD,EAIC,cAAC,kBAAD;AACC,IAAA,OAAO,EAAGA,OADX;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,YAAY,EAAGC;AAHhB,IAJD,EASC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,+CADX;AAEC,IAAA,OAAO,EAAC,WAFT;AAGC,IAAA,IAAI,EAAGV,YAAY,CAAE,UAAF,EAAc;AAChCmB,MAAAA,SAAS,EAAE;AADqB,KAAd;AAHpB,KAOGpB,EAAE,CAAE,oBAAF,CAPL,CADD,CATD,CADD;AAuBA;AAED,eAAemB,iBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { addQueryArgs } from '@wordpress/url';\nimport { Button } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockTypesList from '../block-types-list';\nimport InserterPanel from './panel';\nimport InserterNoResults from './no-results';\nimport useBlockTypesState from './hooks/use-block-types-state';\nimport ReusableBlocksRenameHint from './reusable-block-rename-hint';\n\nfunction ReusableBlocksList( { onHover, onInsert, rootClientId } ) {\n\tconst [ items, , , onSelectItem ] = useBlockTypesState(\n\t\trootClientId,\n\t\tonInsert\n\t);\n\n\tconst filteredItems = useMemo( () => {\n\t\treturn items.filter(\n\t\t\t( { category, syncStatus } ) =>\n\t\t\t\tcategory === 'reusable' && syncStatus !== 'unsynced'\n\t\t);\n\t}, [ items ] );\n\n\tif ( filteredItems.length === 0 ) {\n\t\treturn <InserterNoResults />;\n\t}\n\n\treturn (\n\t\t<InserterPanel title={ __( 'Synced patterns' ) }>\n\t\t\t<BlockTypesList\n\t\t\t\titems={ filteredItems }\n\t\t\t\tonSelect={ onSelectItem }\n\t\t\t\tonHover={ onHover }\n\t\t\t\tlabel={ __( 'Synced patterns' ) }\n\t\t\t/>\n\t\t</InserterPanel>\n\t);\n}\n\n// The unwrapped component is only exported for use by unit tests.\n/**\n * List of reusable blocks shown in the \"Reusable\" tab of the inserter.\n *\n * @param {Object} props Component props.\n * @param {?string} props.rootClientId Client id of block to insert into.\n * @param {Function} props.onInsert Callback to run when item is inserted.\n * @param {Function} props.onHover Callback to run when item is hovered.\n *\n * @return {WPComponent} The component.\n */\nexport function ReusableBlocksTab( { rootClientId, onInsert, onHover } ) {\n\treturn (\n\t\t<>\n\t\t\t<div className=\"block-editor-inserter__hint\">\n\t\t\t\t<ReusableBlocksRenameHint />\n\t\t\t</div>\n\t\t\t<ReusableBlocksList\n\t\t\t\tonHover={ onHover }\n\t\t\t\tonInsert={ onInsert }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t/>\n\t\t\t<div className=\"block-editor-inserter__manage-reusable-blocks-container\">\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"block-editor-inserter__manage-reusable-blocks\"\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\thref={ addQueryArgs( 'edit.php', {\n\t\t\t\t\t\tpost_type: 'wp_block',\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Manage my patterns' ) }\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default ReusableBlocksTab;\n"]}
@@ -37,7 +37,7 @@ function InserterListItem({
37
37
  const blocks = useMemo(() => {
38
38
  return [createBlock(item.name, item.initialAttributes, createBlocksFromInnerBlocksTemplate(item.innerBlocks))];
39
39
  }, [item.name, item.initialAttributes, item.initialAttributes]);
40
- const isSynced = isReusableBlock(item) || isTemplatePart(item);
40
+ const isSynced = isReusableBlock(item) && item.syncStatus !== 'unsynced' || isTemplatePart(item);
41
41
  return createElement(InserterDraggableBlocks, {
42
42
  isEnabled: isDraggable && !item.disabled,
43
43
  blocks: blocks,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/inserter-list-item/index.js"],"names":["classnames","useMemo","useRef","memo","createBlock","createBlocksFromInnerBlocksTemplate","isReusableBlock","isTemplatePart","__experimentalTruncate","Truncate","ENTER","isAppleOS","BlockIcon","InserterListboxItem","InserterDraggableBlocks","InserterListItem","className","isFirst","item","onSelect","onHover","isDraggable","props","isDragging","itemIconStyle","icon","backgroundColor","background","color","foreground","blocks","name","initialAttributes","innerBlocks","isSynced","disabled","draggable","onDragStart","onDragEnd","event","current","isDisabled","preventDefault","metaKey","ctrlKey","keyCode","title"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,OAAT,EAAkBC,MAAlB,EAA0BC,IAA1B,QAAsC,oBAAtC;AACA,SACCC,WADD,EAECC,mCAFD,EAGCC,eAHD,EAICC,cAJD,QAKO,mBALP;AAMA,SAASC,sBAAsB,IAAIC,QAAnC,QAAmD,uBAAnD;AACA,SAASC,KAAT,EAAgBC,SAAhB,QAAiC,qBAAjC;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,eAAtB;AACA,SAASC,mBAAT,QAAoC,qBAApC;AACA,OAAOC,uBAAP,MAAoC,8BAApC;;AAEA,SAASC,gBAAT,CAA2B;AAC1BC,EAAAA,SAD0B;AAE1BC,EAAAA,OAF0B;AAG1BC,EAAAA,IAH0B;AAI1BC,EAAAA,QAJ0B;AAK1BC,EAAAA,OAL0B;AAM1BC,EAAAA,WAN0B;AAO1B,KAAGC;AAPuB,CAA3B,EAQI;AACH,QAAMC,UAAU,GAAGrB,MA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B,KACC,cAAC,QAAD;AAAU,IAAA,aAAa,EAAG;AAA1B,KACGP,IAAI,CAAC4B,KADR,CADD,CAzCD,CAvBD,CANF,CADD;AAiFA;;AAED,eAAe3C,IAAI,CAAEY,gBAAF,CAAnB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useRef, memo } from '@wordpress/element';\nimport {\n\tcreateBlock,\n\tcreateBlocksFromInnerBlocksTemplate,\n\tisReusableBlock,\n\tisTemplatePart,\n} from '@wordpress/blocks';\nimport { __experimentalTruncate as Truncate } from '@wordpress/components';\nimport { ENTER, isAppleOS } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\nimport { InserterListboxItem } from '../inserter-listbox';\nimport InserterDraggableBlocks from '../inserter-draggable-blocks';\n\nfunction InserterListItem( {\n\tclassName,\n\tisFirst,\n\titem,\n\tonSelect,\n\tonHover,\n\tisDraggable,\n\t...props\n} ) {\n\tconst isDragging = useRef( false );\n\tconst itemIconStyle = item.icon\n\t\t? {\n\t\t\t\tbackgroundColor: item.icon.background,\n\t\t\t\tcolor: item.icon.foreground,\n\t\t }\n\t\t: {};\n\tconst blocks = useMemo( () => {\n\t\treturn [\n\t\t\tcreateBlock(\n\t\t\t\titem.name,\n\t\t\t\titem.initialAttributes,\n\t\t\t\tcreateBlocksFromInnerBlocksTemplate( item.innerBlocks )\n\t\t\t),\n\t\t];\n\t}, [ item.name, item.initialAttributes, item.initialAttributes ] );\n\n\tconst isSynced = isReusableBlock( item ) || isTemplatePart( item );\n\n\treturn (\n\t\t<InserterDraggableBlocks\n\t\t\tisEnabled={ isDraggable && ! item.disabled }\n\t\t\tblocks={ blocks }\n\t\t\ticon={ item.icon }\n\t\t>\n\t\t\t{ ( { draggable, onDragStart, onDragEnd } ) => (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'block-editor-block-types-list__list-item',\n\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'is-synced': isSynced,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\tdraggable={ draggable }\n\t\t\t\t\tonDragStart={ ( event ) => {\n\t\t\t\t\t\tisDragging.current = true;\n\t\t\t\t\t\tif ( onDragStart ) {\n\t\t\t\t\t\t\tonHover( null );\n\t\t\t\t\t\t\tonDragStart( event );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tonDragEnd={ ( event ) => {\n\t\t\t\t\t\tisDragging.current = false;\n\t\t\t\t\t\tif ( onDragEnd ) {\n\t\t\t\t\t\t\tonDragEnd( event );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<InserterListboxItem\n\t\t\t\t\t\tisFirst={ isFirst }\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-block-types-list__item',\n\t\t\t\t\t\t\tclassName\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tdisabled={ item.isDisabled }\n\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tonSelect(\n\t\t\t\t\t\t\t\titem,\n\t\t\t\t\t\t\t\tisAppleOS() ? event.metaKey : event.ctrlKey\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tonHover( null );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\t\t\tconst { keyCode } = event;\n\t\t\t\t\t\t\tif ( keyCode === ENTER ) {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\tonSelect(\n\t\t\t\t\t\t\t\t\titem,\n\t\t\t\t\t\t\t\t\tisAppleOS() ? event.metaKey : event.ctrlKey\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tonHover( null );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonMouseEnter={ () => {\n\t\t\t\t\t\t\tif ( isDragging.current ) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonHover( item );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonMouseLeave={ () => onHover( null ) }\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName=\"block-editor-block-types-list__item-icon\"\n\t\t\t\t\t\t\tstyle={ itemIconStyle }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockIcon icon={ item.icon } showColors />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span className=\"block-editor-block-types-list__item-title\">\n\t\t\t\t\t\t\t<Truncate numberOfLines={ 3 }>\n\t\t\t\t\t\t\t\t{ item.title }\n\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</InserterListboxItem>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</InserterDraggableBlocks>\n\t);\n}\n\nexport default memo( InserterListItem );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/inserter-list-item/index.js"],"names":["classnames","useMemo","useRef","memo","createBlock","createBlocksFromInnerBlocksTemplate","isReusableBlock","isTemplatePart","__experimentalTruncate","Truncate","ENTER","isAppleOS","BlockIcon","InserterListboxItem","InserterDraggableBlocks","InserterListItem","className","isFirst","item","onSelect","onHover","isDraggable","props","isDragging","itemIconStyle","icon","backgroundColor","background","color","foreground","blocks","name","initialAttributes","innerBlocks","isSynced","syncStatus","disabled","draggable","onDragStart","onDragEnd","event","current","isDisabled","preventDefault","metaKey","ctrlKey","keyCode","title"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,OAAT,EAAkBC,MAAlB,EAA0BC,IAA1B,QAAsC,oBAAtC;AACA,SACCC,WADD,EAECC,mCAFD,EAGCC,eAHD,EAICC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KAAK,CAACK,OAF7B,CAAR;AAIAzB,QAAAA,OAAO,CAAE,IAAF,CAAP;AACA;AACD,KAzBF;AA0BC,IAAA,YAAY,EAAG,MAAM;AACpB,UAAKG,UAAU,CAACkB,OAAhB,EAA0B;AACzB;AACA;;AACDrB,MAAAA,OAAO,CAAEF,IAAF,CAAP;AACA,KA/BF;AAgCC,IAAA,YAAY,EAAG,MAAME,OAAO,CAAE,IAAF,CAhC7B;AAAA,OAiCME;AAjCN,KAmCC;AACC,IAAA,SAAS,EAAC,0CADX;AAEC,IAAA,KAAK,EAAGE;AAFT,KAIC,cAAC,SAAD;AAAW,IAAA,IAAI,EAAGN,IAAI,CAACO,IAAvB;AAA8B,IAAA,UAAU;AAAxC,IAJD,CAnCD,EAyCC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACC,cAAC,QAAD;AAAU,IAAA,aAAa,EAAG;AAA1B,KACGP,IAAI,CAAC6B,KADR,CADD,CAzCD,CAvBD,CANF,CADD;AAiFA;;AAED,eAAe5C,IAAI,CAAEY,gBAAF,CAAnB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useRef, memo } from '@wordpress/element';\nimport {\n\tcreateBlock,\n\tcreateBlocksFromInnerBlocksTemplate,\n\tisReusableBlock,\n\tisTemplatePart,\n} from '@wordpress/blocks';\nimport { __experimentalTruncate as Truncate } from '@wordpress/components';\nimport { ENTER, isAppleOS } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\nimport { InserterListboxItem } from '../inserter-listbox';\nimport InserterDraggableBlocks from '../inserter-draggable-blocks';\n\nfunction InserterListItem( {\n\tclassName,\n\tisFirst,\n\titem,\n\tonSelect,\n\tonHover,\n\tisDraggable,\n\t...props\n} ) {\n\tconst isDragging = useRef( false );\n\tconst itemIconStyle = item.icon\n\t\t? {\n\t\t\t\tbackgroundColor: item.icon.background,\n\t\t\t\tcolor: item.icon.foreground,\n\t\t }\n\t\t: {};\n\tconst blocks = useMemo( () => {\n\t\treturn [\n\t\t\tcreateBlock(\n\t\t\t\titem.name,\n\t\t\t\titem.initialAttributes,\n\t\t\t\tcreateBlocksFromInnerBlocksTemplate( item.innerBlocks )\n\t\t\t),\n\t\t];\n\t}, [ item.name, item.initialAttributes, item.initialAttributes ] );\n\n\tconst isSynced =\n\t\t( isReusableBlock( item ) && item.syncStatus !== 'unsynced' ) ||\n\t\tisTemplatePart( item );\n\n\treturn (\n\t\t<InserterDraggableBlocks\n\t\t\tisEnabled={ isDraggable && ! item.disabled }\n\t\t\tblocks={ blocks }\n\t\t\ticon={ item.icon }\n\t\t>\n\t\t\t{ ( { draggable, onDragStart, onDragEnd } ) => (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'block-editor-block-types-list__list-item',\n\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'is-synced': isSynced,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\tdraggable={ draggable }\n\t\t\t\t\tonDragStart={ ( event ) => {\n\t\t\t\t\t\tisDragging.current = true;\n\t\t\t\t\t\tif ( onDragStart ) {\n\t\t\t\t\t\t\tonHover( null );\n\t\t\t\t\t\t\tonDragStart( event );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tonDragEnd={ ( event ) => {\n\t\t\t\t\t\tisDragging.current = false;\n\t\t\t\t\t\tif ( onDragEnd ) {\n\t\t\t\t\t\t\tonDragEnd( event );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<InserterListboxItem\n\t\t\t\t\t\tisFirst={ isFirst }\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-block-types-list__item',\n\t\t\t\t\t\t\tclassName\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tdisabled={ item.isDisabled }\n\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tonSelect(\n\t\t\t\t\t\t\t\titem,\n\t\t\t\t\t\t\t\tisAppleOS() ? event.metaKey : event.ctrlKey\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tonHover( null );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\t\t\tconst { keyCode } = event;\n\t\t\t\t\t\t\tif ( keyCode === ENTER ) {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\tonSelect(\n\t\t\t\t\t\t\t\t\titem,\n\t\t\t\t\t\t\t\t\tisAppleOS() ? event.metaKey : event.ctrlKey\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tonHover( null );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonMouseEnter={ () => {\n\t\t\t\t\t\t\tif ( isDragging.current ) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonHover( item );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonMouseLeave={ () => onHover( null ) }\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName=\"block-editor-block-types-list__item-icon\"\n\t\t\t\t\t\t\tstyle={ itemIconStyle }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockIcon icon={ item.icon } showColors />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span className=\"block-editor-block-types-list__item-title\">\n\t\t\t\t\t\t\t<Truncate numberOfLines={ 3 }>\n\t\t\t\t\t\t\t\t{ item.title }\n\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</InserterListboxItem>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</InserterDraggableBlocks>\n\t);\n}\n\nexport default memo( InserterListItem );\n"]}
@@ -14,6 +14,8 @@ import { useRef, useState, useEffect } from '@wordpress/element';
14
14
  import { focus } from '@wordpress/dom';
15
15
  import { ENTER } from '@wordpress/keycodes';
16
16
  import { isShallowEqualObjects } from '@wordpress/is-shallow-equal';
17
+ import { useSelect, useDispatch } from '@wordpress/data';
18
+ import { store as preferencesStore } from '@wordpress/preferences';
17
19
  /**
18
20
  * Internal dependencies
19
21
  */
@@ -103,6 +105,9 @@ import { DEFAULT_LINK_SETTINGS } from './constants';
103
105
  */
104
106
 
105
107
  const noop = () => {};
108
+
109
+ const PREFERENCE_SCOPE = 'core/block-editor';
110
+ const PREFERENCE_KEY = 'linkControlSettingsDrawer';
106
111
  /**
107
112
  * Renders a link control. A link control is a controlled input which maintains
108
113
  * a value associated with a link (HTML anchor element) and relevant settings
@@ -111,7 +116,6 @@ const noop = () => {};
111
116
  * @param {WPLinkControlProps} props Component props.
112
117
  */
113
118
 
114
-
115
119
  function LinkControl({
116
120
  searchInputPlaceholder,
117
121
  value,
@@ -137,6 +141,43 @@ function LinkControl({
137
141
  withCreateSuggestion = true;
138
142
  }
139
143
 
144
+ const [settingsOpen, setSettingsOpen] = useState(false);
145
+ const {
146
+ advancedSettingsPreference
147
+ } = useSelect(select => {
148
+ var _prefsStore$get;
149
+
150
+ const prefsStore = select(preferencesStore);
151
+ return {
152
+ advancedSettingsPreference: (_prefsStore$get = prefsStore.get(PREFERENCE_SCOPE, PREFERENCE_KEY)) !== null && _prefsStore$get !== void 0 ? _prefsStore$get : false
153
+ };
154
+ }, []);
155
+ const {
156
+ set: setPreference
157
+ } = useDispatch(preferencesStore);
158
+ /**
159
+ * Sets the open/closed state of the Advanced Settings Drawer,
160
+ * optionlly persisting the state to the user's preferences.
161
+ *
162
+ * Note that Block Editor components can be consumed by non-WordPress
163
+ * environments which may not have preferences setup.
164
+ * Therefore a local state is also used as a fallback.
165
+ *
166
+ * @param {boolean} prefVal the open/closed state of the Advanced Settings Drawer.
167
+ */
168
+
169
+ const setSettingsOpenWithPreference = prefVal => {
170
+ if (setPreference) {
171
+ setPreference(PREFERENCE_SCOPE, PREFERENCE_KEY, prefVal);
172
+ }
173
+
174
+ setSettingsOpen(prefVal);
175
+ }; // Block Editor components can be consumed by non-WordPress environments
176
+ // which may not have these preferences setup.
177
+ // Therefore a local state is used as a fallback.
178
+
179
+
180
+ const isSettingsOpen = advancedSettingsPreference || settingsOpen;
140
181
  const isMounting = useRef(true);
141
182
  const wrapperNode = useRef();
142
183
  const textInputRef = useRef();
@@ -144,7 +185,6 @@ function LinkControl({
144
185
  const settingsKeys = settings.map(({
145
186
  id
146
187
  }) => id);
147
- const [settingsOpen, setSettingsOpen] = useState(false);
148
188
  const [internalControlValue, setInternalControlValue, setInternalURLInputValue, setInternalTextInputValue, createSetInternalSettingValueHandler] = useInternalValue(value);
149
189
  const valueHasChanges = value && !isShallowEqualObjects(internalControlValue, value);
150
190
  const [isEditingLink, setIsEditingLink] = useState(forceIsEditingLink !== undefined ? forceIsEditingLink : !value || !value.url);
@@ -186,7 +226,6 @@ function LinkControl({
186
226
 
187
227
  const stopEditing = () => {
188
228
  isEndingEditWithFocus.current = !!wrapperNode.current?.contains(wrapperNode.current.ownerDocument.activeElement);
189
- setSettingsOpen(false);
190
229
  setIsEditingLink(false);
191
230
  };
192
231
 
@@ -260,7 +299,6 @@ function LinkControl({
260
299
  const currentUrlInputValue = propInputValue || internalControlValue?.url || '';
261
300
  const currentInputIsEmpty = !currentUrlInputValue?.trim()?.length;
262
301
  const shownUnlinkControl = onRemove && value && !isEditingLink && !isCreatingPage;
263
- const showSettings = !!settings?.length && isEditingLink && hasLinkValue;
264
302
  const showActions = isEditingLink && hasLinkValue; // Only show text control once a URL value has been committed
265
303
  // and it isn't just empty whitespace.
266
304
  // See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.
@@ -268,6 +306,7 @@ function LinkControl({
268
306
  const showTextControl = hasLinkValue && hasTextControl;
269
307
  const isEditing = (isEditingLink || !value) && !isCreatingPage;
270
308
  const isDisabled = !valueHasChanges || currentInputIsEmpty;
309
+ const showSettings = !!settings?.length && isEditingLink && hasLinkValue;
271
310
  return createElement("div", {
272
311
  tabIndex: -1,
273
312
  ref: wrapperNode,
@@ -315,12 +354,15 @@ function LinkControl({
315
354
  onEditClick: () => setIsEditingLink(true),
316
355
  hasRichPreviews: hasRichPreviews,
317
356
  hasUnlinkControl: shownUnlinkControl,
318
- onRemove: onRemove
357
+ onRemove: () => {
358
+ onRemove();
359
+ setIsEditingLink(true);
360
+ }
319
361
  }), showSettings && createElement("div", {
320
362
  className: "block-editor-link-control__tools"
321
363
  }, !currentInputIsEmpty && createElement(LinkControlSettingsDrawer, {
322
- settingsOpen: settingsOpen,
323
- setSettingsOpen: setSettingsOpen
364
+ settingsOpen: isSettingsOpen,
365
+ setSettingsOpen: setSettingsOpenWithPreference
324
366
  }, createElement(LinkSettings, {
325
367
  value: internalControlValue,
326
368
  settings: settings,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/index.js"],"names":["classnames","Button","Spinner","Notice","TextControl","__","useRef","useState","useEffect","focus","ENTER","isShallowEqualObjects","LinkControlSettingsDrawer","LinkControlSearchInput","LinkPreview","LinkSettings","useCreatePage","useInternalValue","ViewerFill","DEFAULT_LINK_SETTINGS","noop","LinkControl","searchInputPlaceholder","value","settings","onChange","onRemove","onCancel","noDirectEntry","showSuggestions","showInitialSuggestions","forceIsEditingLink","createSuggestion","withCreateSuggestion","inputValue","propInputValue","suggestionsQuery","noURLSuggestion","createSuggestionButtonText","hasRichPreviews","hasTextControl","renderControlBottom","undefined","isMounting","wrapperNode","textInputRef","isEndingEditWithFocus","settingsKeys","map","id","settingsOpen","setSettingsOpen","internalControlValue","setInternalControlValue","setInternalURLInputValue","setInternalTextInputValue","createSetInternalSettingValueHandler","valueHasChanges","isEditingLink","setIsEditingLink","url","createPage","isCreatingPage","errorMessage","current","nextFocusTarget","focusable","find","hasLinkValue","trim","length","stopEditing","contains","ownerDocument","activeElement","handleSelectSuggestion","updatedValue","nonSettingsChanges","Object","keys","reduce","acc","key","includes","title","handleSubmit","currentUrlInputValue","handleSubmitWithEnter","event","keyCode","currentInputIsEmpty","preventDefault","resetInternalValues","handleCancel","stopPropagation","shownUnlinkControl","showSettings","showActions","showTextControl","isEditing","isDisabled"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,EAAiBC,OAAjB,EAA0BC,MAA1B,EAAkCC,WAAlC,QAAqD,uBAArD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,EAAiBC,QAAjB,EAA2BC,SAA3B,QAA4C,oBAA5C;AACA,SAASC,KAAT,QAAsB,gBAAtB;AACA,SAASC,KAAT,QAAsB,qBAAtB;AACA,SAASC,qBAAT,QAAsC,6BAAtC;AAEA;AACA;AACA;;AACA,OAAOC,yBAAP,MAAsC,mBAAtC;AACA,OAAOC,sBAAP,MAAmC,gBAAnC;AACA,OAAOC,WAAP,MAAwB,gBAAxB;AACA,OAAOC,YAAP,MAAyB,YAAzB;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,OAAOC,gBAAP,MAA6B,sBAA7B;AACA,SAASC,UAAT,QAA2B,eAA3B;AACA,SAASC,qBAAT,QAAsC,aAAtC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AACA;AACA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;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CACoB;AADpB;AAEC,IAAA,KAAK,EAAGrC,KAFT;AAGC,IAAA,WAAW,EAAG,MAAMoC,gBAAgB,CAAE,IAAF,CAHrC;AAIC,IAAA,eAAe,EAAGpB,eAJnB;AAKC,IAAA,gBAAgB,EAAGwD,kBALpB;AAMC,IAAA,QAAQ,EAAGrE;AANZ,IAhEF,EA0EGsE,YAAY,IACb;AAAK,IAAA,SAAS,EAAC;AAAf,KACG,CAAEN,mBAAF,IACD,cAAC,yBAAD;AACC,IAAA,YAAY,EAAGxC,YADhB;AAEC,IAAA,eAAe,EAAGC;AAFnB,KAIC,cAAC,YAAD;AACC,IAAA,KAAK,EAAGC,oBADT;AAEC,IAAA,QAAQ,EAAG5B,QAFZ;AAGC,IAAA,QAAQ,EAAGgC,oCAAoC,CAC9CT,YAD8C;AAHhD,IAJD,CAFF,CA3EF,EA6FGkD,WAAW,IACZ;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,OAAO,EAAGG,UAAU,GAAGhF,IAAH,GAAUiE,YAF/B;AAGC,IAAA,SAAS,EAAC,0CAHX;AAIC,qBAAgBe;AAJjB,KAMG/F,EAAE,CAAE,MAAF,CANL,CADD,EASC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,UAAhB;AAA2B,IAAA,OAAO,EAAGwF;AAArC,KACGxF,EAAE,CAAE,QAAF,CADL,CATD,CA9FF,EA6GGoC,mBAAmB,IAAIA,mBAAmB,EA7G7C,CADD;AAiHA;;AAEDpB,WAAW,CAACH,UAAZ,GAAyBA,UAAzB;AAEA,eAAeG,WAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button, Spinner, Notice, TextControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useState, useEffect } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport { ENTER } from '@wordpress/keycodes';\nimport { isShallowEqualObjects } from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport LinkControlSettingsDrawer from './settings-drawer';\nimport LinkControlSearchInput from './search-input';\nimport LinkPreview from './link-preview';\nimport LinkSettings from './settings';\nimport useCreatePage from './use-create-page';\nimport useInternalValue from './use-internal-value';\nimport { ViewerFill } from './viewer-slot';\nimport { DEFAULT_LINK_SETTINGS } from './constants';\n\n/**\n * Default properties associated with a link control value.\n *\n * @typedef WPLinkControlDefaultValue\n *\n * @property {string} url Link URL.\n * @property {string=} title Link title.\n * @property {boolean=} opensInNewTab Whether link should open in a new browser\n * tab. This value is only assigned if not\n * providing a custom `settings` prop.\n */\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Custom settings values associated with a link.\n *\n * @typedef {{[setting:string]:any}} WPLinkControlSettingsValue\n */\n/* eslint-enable */\n\n/**\n * Custom settings values associated with a link.\n *\n * @typedef WPLinkControlSetting\n *\n * @property {string} id Identifier to use as property for setting value.\n * @property {string} title Human-readable label to show in user interface.\n */\n\n/**\n * Properties associated with a link control value, composed as a union of the\n * default properties and any custom settings values.\n *\n * @typedef {WPLinkControlDefaultValue&WPLinkControlSettingsValue} WPLinkControlValue\n */\n\n/** @typedef {(nextValue:WPLinkControlValue)=>void} WPLinkControlOnChangeProp */\n\n/**\n * Properties associated with a search suggestion used within the LinkControl.\n *\n * @typedef WPLinkControlSuggestion\n *\n * @property {string} id Identifier to use to uniquely identify the suggestion.\n * @property {string} type Identifies the type of the suggestion (eg: `post`,\n * `page`, `url`...etc)\n * @property {string} title Human-readable label to show in user interface.\n * @property {string} url A URL for the suggestion.\n */\n\n/** @typedef {(title:string)=>WPLinkControlSuggestion} WPLinkControlCreateSuggestionProp */\n\n/**\n * @typedef WPLinkControlProps\n *\n * @property {(WPLinkControlSetting[])=} settings An array of settings objects. Each object will used to\n * render a `ToggleControl` for that setting.\n * @property {boolean=} forceIsEditingLink If passed as either `true` or `false`, controls the\n * internal editing state of the component to respective\n * show or not show the URL input field.\n * @property {WPLinkControlValue=} value Current link value.\n * @property {WPLinkControlOnChangeProp=} onChange Value change handler, called with the updated value if\n * the user selects a new link or updates settings.\n * @property {boolean=} noDirectEntry Whether to allow turning a URL-like search query directly into a link.\n * @property {boolean=} showSuggestions Whether to present suggestions when typing the URL.\n * @property {boolean=} showInitialSuggestions Whether to present initial suggestions immediately.\n * @property {boolean=} withCreateSuggestion Whether to allow creation of link value from suggestion.\n * @property {Object=} suggestionsQuery Query parameters to pass along to wp.blockEditor.__experimentalFetchLinkSuggestions.\n * @property {boolean=} noURLSuggestion Whether to add a fallback suggestion which treats the search query as a URL.\n * @property {boolean=} hasTextControl Whether to add a text field to the UI to update the value.title.\n * @property {string|Function|undefined} createSuggestionButtonText The text to use in the button that calls createSuggestion.\n * @property {Function} renderControlBottom Optional controls to be rendered at the bottom of the component.\n */\n\nconst noop = () => {};\n\n/**\n * Renders a link control. A link control is a controlled input which maintains\n * a value associated with a link (HTML anchor element) and relevant settings\n * for how that link is expected to behave.\n *\n * @param {WPLinkControlProps} props Component props.\n */\nfunction LinkControl( {\n\tsearchInputPlaceholder,\n\tvalue,\n\tsettings = DEFAULT_LINK_SETTINGS,\n\tonChange = noop,\n\tonRemove,\n\tonCancel,\n\tnoDirectEntry = false,\n\tshowSuggestions = true,\n\tshowInitialSuggestions,\n\tforceIsEditingLink,\n\tcreateSuggestion,\n\twithCreateSuggestion,\n\tinputValue: propInputValue = '',\n\tsuggestionsQuery = {},\n\tnoURLSuggestion = false,\n\tcreateSuggestionButtonText,\n\thasRichPreviews = false,\n\thasTextControl = false,\n\trenderControlBottom = null,\n} ) {\n\tif ( withCreateSuggestion === undefined && createSuggestion ) {\n\t\twithCreateSuggestion = true;\n\t}\n\n\tconst isMounting = useRef( true );\n\tconst wrapperNode = useRef();\n\tconst textInputRef = useRef();\n\tconst isEndingEditWithFocus = useRef( false );\n\n\tconst settingsKeys = settings.map( ( { id } ) => id );\n\n\tconst [ settingsOpen, setSettingsOpen ] = useState( false );\n\n\tconst [\n\t\tinternalControlValue,\n\t\tsetInternalControlValue,\n\t\tsetInternalURLInputValue,\n\t\tsetInternalTextInputValue,\n\t\tcreateSetInternalSettingValueHandler,\n\t] = useInternalValue( value );\n\n\tconst valueHasChanges =\n\t\tvalue && ! isShallowEqualObjects( internalControlValue, value );\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState(\n\t\tforceIsEditingLink !== undefined\n\t\t\t? forceIsEditingLink\n\t\t\t: ! value || ! value.url\n\t);\n\n\tconst { createPage, isCreatingPage, errorMessage } =\n\t\tuseCreatePage( createSuggestion );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tforceIsEditingLink !== undefined &&\n\t\t\tforceIsEditingLink !== isEditingLink\n\t\t) {\n\t\t\tsetIsEditingLink( forceIsEditingLink );\n\t\t}\n\t\t// Todo: bug if the missing dep is introduced. Will need a fix.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ forceIsEditingLink ] );\n\n\tuseEffect( () => {\n\t\t// We don't auto focus into the Link UI on mount\n\t\t// because otherwise using the keyboard to select text\n\t\t// *within* the link format is not possible.\n\t\tif ( isMounting.current ) {\n\t\t\tisMounting.current = false;\n\t\t\treturn;\n\t\t}\n\n\t\t// Scenario - when:\n\t\t// - switching between editable and non editable LinkControl\n\t\t// - clicking on a link\n\t\t// ...then move focus to the *first* element to avoid focus loss\n\t\t// and to ensure focus is *within* the Link UI.\n\t\tconst nextFocusTarget =\n\t\t\tfocus.focusable.find( wrapperNode.current )[ 0 ] ||\n\t\t\twrapperNode.current;\n\n\t\tnextFocusTarget.focus();\n\n\t\tisEndingEditWithFocus.current = false;\n\t}, [ isEditingLink, isCreatingPage ] );\n\n\tconst hasLinkValue = value?.url?.trim()?.length > 0;\n\n\t/**\n\t * Cancels editing state and marks that focus may need to be restored after\n\t * the next render, if focus was within the wrapper when editing finished.\n\t */\n\tconst stopEditing = () => {\n\t\tisEndingEditWithFocus.current = !! wrapperNode.current?.contains(\n\t\t\twrapperNode.current.ownerDocument.activeElement\n\t\t);\n\n\t\tsetSettingsOpen( false );\n\t\tsetIsEditingLink( false );\n\t};\n\n\tconst handleSelectSuggestion = ( updatedValue ) => {\n\t\t// Suggestions may contains \"settings\" values (e.g. `opensInNewTab`)\n\t\t// which should not overide any existing settings values set by the\n\t\t// user. This filters out any settings values from the suggestion.\n\t\tconst nonSettingsChanges = Object.keys( updatedValue ).reduce(\n\t\t\t( acc, key ) => {\n\t\t\t\tif ( ! settingsKeys.includes( key ) ) {\n\t\t\t\t\tacc[ key ] = updatedValue[ key ];\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\tonChange( {\n\t\t\t...internalControlValue,\n\t\t\t...nonSettingsChanges,\n\t\t\t// As title is not a setting, it must be manually applied\n\t\t\t// in such a way as to preserve the users changes over\n\t\t\t// any \"title\" value provided by the \"suggestion\".\n\t\t\ttitle: internalControlValue?.title || updatedValue?.title,\n\t\t} );\n\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmit = () => {\n\t\tif ( valueHasChanges ) {\n\t\t\t// Submit the original value with new stored values applied\n\t\t\t// on top. URL is a special case as it may also be a prop.\n\t\t\tonChange( {\n\t\t\t\t...value,\n\t\t\t\t...internalControlValue,\n\t\t\t\turl: currentUrlInputValue,\n\t\t\t} );\n\t\t}\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmitWithEnter = ( event ) => {\n\t\tconst { keyCode } = event;\n\n\t\tif (\n\t\t\tkeyCode === ENTER &&\n\t\t\t! currentInputIsEmpty // Disallow submitting empty values.\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t\thandleSubmit();\n\t\t}\n\t};\n\n\tconst resetInternalValues = () => {\n\t\tsetInternalControlValue( value );\n\t};\n\n\tconst handleCancel = ( event ) => {\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\n\t\t// Ensure that any unsubmitted input changes are reset.\n\t\tresetInternalValues();\n\n\t\tif ( hasLinkValue ) {\n\t\t\t// If there is a link then exist editing mode and show preview.\n\t\t\tstopEditing();\n\t\t} else {\n\t\t\t// If there is no link value, then remove the link entirely.\n\t\t\tonRemove?.();\n\t\t}\n\n\t\tonCancel?.();\n\t};\n\n\tconst currentUrlInputValue =\n\t\tpropInputValue || internalControlValue?.url || '';\n\n\tconst currentInputIsEmpty = ! currentUrlInputValue?.trim()?.length;\n\n\tconst shownUnlinkControl =\n\t\tonRemove && value && ! isEditingLink && ! isCreatingPage;\n\n\tconst showSettings = !! settings?.length && isEditingLink && hasLinkValue;\n\tconst showActions = isEditingLink && hasLinkValue;\n\n\t// Only show text control once a URL value has been committed\n\t// and it isn't just empty whitespace.\n\t// See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.\n\tconst showTextControl = hasLinkValue && hasTextControl;\n\n\tconst isEditing = ( isEditingLink || ! value ) && ! isCreatingPage;\n\tconst isDisabled = ! valueHasChanges || currentInputIsEmpty;\n\n\treturn (\n\t\t<div\n\t\t\ttabIndex={ -1 }\n\t\t\tref={ wrapperNode }\n\t\t\tclassName=\"block-editor-link-control\"\n\t\t>\n\t\t\t{ isCreatingPage && (\n\t\t\t\t<div className=\"block-editor-link-control__loading\">\n\t\t\t\t\t<Spinner /> { __( 'Creating' ) }…\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ isEditing && (\n\t\t\t\t<>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames( {\n\t\t\t\t\t\t\t'block-editor-link-control__search-input-wrapper': true,\n\t\t\t\t\t\t\t'has-text-control': showTextControl,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ showTextControl && (\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tref={ textInputRef }\n\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__text-content\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\t\t\t\t\tvalue={ internalControlValue?.title }\n\t\t\t\t\t\t\t\tonChange={ setInternalTextInputValue }\n\t\t\t\t\t\t\t\tonKeyDown={ handleSubmitWithEnter }\n\t\t\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<LinkControlSearchInput\n\t\t\t\t\t\t\tcurrentLink={ value }\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__search-input\"\n\t\t\t\t\t\t\tplaceholder={ searchInputPlaceholder }\n\t\t\t\t\t\t\tvalue={ currentUrlInputValue }\n\t\t\t\t\t\t\twithCreateSuggestion={ withCreateSuggestion }\n\t\t\t\t\t\t\tonCreateSuggestion={ createPage }\n\t\t\t\t\t\t\tonChange={ setInternalURLInputValue }\n\t\t\t\t\t\t\tonSelect={ handleSelectSuggestion }\n\t\t\t\t\t\t\tshowInitialSuggestions={ showInitialSuggestions }\n\t\t\t\t\t\t\tallowDirectEntry={ ! noDirectEntry }\n\t\t\t\t\t\t\tshowSuggestions={ showSuggestions }\n\t\t\t\t\t\t\tsuggestionsQuery={ suggestionsQuery }\n\t\t\t\t\t\t\twithURLSuggestion={ ! noURLSuggestion }\n\t\t\t\t\t\t\tcreateSuggestionButtonText={\n\t\t\t\t\t\t\t\tcreateSuggestionButtonText\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\thideLabelFromVision={ ! showTextControl }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t{ errorMessage && (\n\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-error\"\n\t\t\t\t\t\t\tstatus=\"error\"\n\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ errorMessage }\n\t\t\t\t\t\t</Notice>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ value && ! isEditingLink && ! isCreatingPage && (\n\t\t\t\t<LinkPreview\n\t\t\t\t\tkey={ value?.url } // force remount when URL changes to avoid race conditions for rich previews\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonEditClick={ () => setIsEditingLink( true ) }\n\t\t\t\t\thasRichPreviews={ hasRichPreviews }\n\t\t\t\t\thasUnlinkControl={ shownUnlinkControl }\n\t\t\t\t\tonRemove={ onRemove }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ showSettings && (\n\t\t\t\t<div className=\"block-editor-link-control__tools\">\n\t\t\t\t\t{ ! currentInputIsEmpty && (\n\t\t\t\t\t\t<LinkControlSettingsDrawer\n\t\t\t\t\t\t\tsettingsOpen={ settingsOpen }\n\t\t\t\t\t\t\tsetSettingsOpen={ setSettingsOpen }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<LinkSettings\n\t\t\t\t\t\t\t\tvalue={ internalControlValue }\n\t\t\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\t\t\tonChange={ createSetInternalSettingValueHandler(\n\t\t\t\t\t\t\t\t\tsettingsKeys\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</LinkControlSettingsDrawer>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ showActions && (\n\t\t\t\t<div className=\"block-editor-link-control__search-actions\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ isDisabled ? noop : handleSubmit }\n\t\t\t\t\t\tclassName=\"block-editor-link-control__search-submit\"\n\t\t\t\t\t\taria-disabled={ isDisabled }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button variant=\"tertiary\" onClick={ handleCancel }>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ renderControlBottom && renderControlBottom() }\n\t\t</div>\n\t);\n}\n\nLinkControl.ViewerFill = ViewerFill;\n\nexport default LinkControl;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/index.js"],"names":["classnames","Button","Spinner","Notice","TextControl","__","useRef","useState","useEffect","focus","ENTER","isShallowEqualObjects","useSelect","useDispatch","store","preferencesStore","LinkControlSettingsDrawer","LinkControlSearchInput","LinkPreview","LinkSettings","useCreatePage","useInternalValue","ViewerFill","DEFAULT_LINK_SETTINGS","noop","PREFERENCE_SCOPE","PREFERENCE_KEY","LinkControl","searchInputPlaceholder","value","settings","onChange","onRemove","onCancel","noDirectEntry","showSuggestions","showInitialSuggestions","forceIsEditingLink","createSuggestion","withCreateSuggestion","inputValue","propInputValue","suggestionsQuery","noURLSuggestion","createSuggestionButtonText","hasRichPreviews","hasTextControl","renderControlBottom","undefined","settingsOpen","setSettingsOpen","advancedSettingsPreference","select","prefsStore","get","set","setPreference","setSettingsOpenWithPreference","prefVal","isSettingsOpen","isMounting","wrapperNode","textInputRef","isEndingEditWithFocus","settingsKeys","map","id","internalControlValue","setInternalControlValue","setInternalURLInputValue","setInternalTextInputValue","createSetInternalSettingValueHandler","valueHasChanges","isEditingLink","setIsEditingLink","url","createPage","isCreatingPage","errorMessage","current","nextFocusTarget","focusable","find","hasLinkValue","trim","length","stopEditing","contains","ownerDocument","activeElement","handleSelectSuggestion","updatedValue","nonSettingsChanges","Object","keys","reduce","acc","key","includes","title","handleSubmit","currentUrlInputValue","handleSubmitWithEnter","event","keyCode","currentInputIsEmpty","preventDefault","resetInternalValues","handleCancel","stopPropagation","shownUnlinkControl","showActions","showTextControl","isEditing","isDisabled","showSettings"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,EAAiBC,OAAjB,EAA0BC,MAA1B,EAAkCC,WAAlC,QAAqD,uBAArD;AACA,SAASC,EAAT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A,SAAS,EAAC,0CAHX;AAIC,qBAAgBc;AAJjB,KAMG7G,EAAE,CAAE,MAAF,CANL,CADD,EASC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,UAAhB;AAA2B,IAAA,OAAO,EAAGuG;AAArC,KACGvG,EAAE,CAAE,QAAF,CADL,CATD,CAjGF,EAgHG0C,mBAAmB,IAAIA,mBAAmB,EAhH7C,CADD;AAoHA;;AAEDpB,WAAW,CAACL,UAAZ,GAAyBA,UAAzB;AAEA,eAAeK,WAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button, Spinner, Notice, TextControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useState, useEffect } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport { ENTER } from '@wordpress/keycodes';\nimport { isShallowEqualObjects } from '@wordpress/is-shallow-equal';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport LinkControlSettingsDrawer from './settings-drawer';\nimport LinkControlSearchInput from './search-input';\nimport LinkPreview from './link-preview';\nimport LinkSettings from './settings';\nimport useCreatePage from './use-create-page';\nimport useInternalValue from './use-internal-value';\nimport { ViewerFill } from './viewer-slot';\nimport { DEFAULT_LINK_SETTINGS } from './constants';\n\n/**\n * Default properties associated with a link control value.\n *\n * @typedef WPLinkControlDefaultValue\n *\n * @property {string} url Link URL.\n * @property {string=} title Link title.\n * @property {boolean=} opensInNewTab Whether link should open in a new browser\n * tab. This value is only assigned if not\n * providing a custom `settings` prop.\n */\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Custom settings values associated with a link.\n *\n * @typedef {{[setting:string]:any}} WPLinkControlSettingsValue\n */\n/* eslint-enable */\n\n/**\n * Custom settings values associated with a link.\n *\n * @typedef WPLinkControlSetting\n *\n * @property {string} id Identifier to use as property for setting value.\n * @property {string} title Human-readable label to show in user interface.\n */\n\n/**\n * Properties associated with a link control value, composed as a union of the\n * default properties and any custom settings values.\n *\n * @typedef {WPLinkControlDefaultValue&WPLinkControlSettingsValue} WPLinkControlValue\n */\n\n/** @typedef {(nextValue:WPLinkControlValue)=>void} WPLinkControlOnChangeProp */\n\n/**\n * Properties associated with a search suggestion used within the LinkControl.\n *\n * @typedef WPLinkControlSuggestion\n *\n * @property {string} id Identifier to use to uniquely identify the suggestion.\n * @property {string} type Identifies the type of the suggestion (eg: `post`,\n * `page`, `url`...etc)\n * @property {string} title Human-readable label to show in user interface.\n * @property {string} url A URL for the suggestion.\n */\n\n/** @typedef {(title:string)=>WPLinkControlSuggestion} WPLinkControlCreateSuggestionProp */\n\n/**\n * @typedef WPLinkControlProps\n *\n * @property {(WPLinkControlSetting[])=} settings An array of settings objects. Each object will used to\n * render a `ToggleControl` for that setting.\n * @property {boolean=} forceIsEditingLink If passed as either `true` or `false`, controls the\n * internal editing state of the component to respective\n * show or not show the URL input field.\n * @property {WPLinkControlValue=} value Current link value.\n * @property {WPLinkControlOnChangeProp=} onChange Value change handler, called with the updated value if\n * the user selects a new link or updates settings.\n * @property {boolean=} noDirectEntry Whether to allow turning a URL-like search query directly into a link.\n * @property {boolean=} showSuggestions Whether to present suggestions when typing the URL.\n * @property {boolean=} showInitialSuggestions Whether to present initial suggestions immediately.\n * @property {boolean=} withCreateSuggestion Whether to allow creation of link value from suggestion.\n * @property {Object=} suggestionsQuery Query parameters to pass along to wp.blockEditor.__experimentalFetchLinkSuggestions.\n * @property {boolean=} noURLSuggestion Whether to add a fallback suggestion which treats the search query as a URL.\n * @property {boolean=} hasTextControl Whether to add a text field to the UI to update the value.title.\n * @property {string|Function|undefined} createSuggestionButtonText The text to use in the button that calls createSuggestion.\n * @property {Function} renderControlBottom Optional controls to be rendered at the bottom of the component.\n */\n\nconst noop = () => {};\n\nconst PREFERENCE_SCOPE = 'core/block-editor';\nconst PREFERENCE_KEY = 'linkControlSettingsDrawer';\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 [ settingsOpen, setSettingsOpen ] = useState( false );\n\n\tconst { advancedSettingsPreference } = useSelect( ( select ) => {\n\t\tconst prefsStore = select( preferencesStore );\n\n\t\treturn {\n\t\t\tadvancedSettingsPreference:\n\t\t\t\tprefsStore.get( PREFERENCE_SCOPE, PREFERENCE_KEY ) ?? false,\n\t\t};\n\t}, [] );\n\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\n\t/**\n\t * Sets the open/closed state of the Advanced Settings Drawer,\n\t * optionlly persisting the state to the user's preferences.\n\t *\n\t * Note that Block Editor components can be consumed by non-WordPress\n\t * environments which may not have preferences setup.\n\t * Therefore a local state is also used as a fallback.\n\t *\n\t * @param {boolean} prefVal the open/closed state of the Advanced Settings Drawer.\n\t */\n\tconst setSettingsOpenWithPreference = ( prefVal ) => {\n\t\tif ( setPreference ) {\n\t\t\tsetPreference( PREFERENCE_SCOPE, PREFERENCE_KEY, prefVal );\n\t\t}\n\t\tsetSettingsOpen( prefVal );\n\t};\n\n\t// Block Editor components can be consumed by non-WordPress environments\n\t// which may not have these preferences setup.\n\t// Therefore a local state is used as a fallback.\n\tconst isSettingsOpen = advancedSettingsPreference || settingsOpen;\n\n\tconst isMounting = useRef( true );\n\tconst wrapperNode = useRef();\n\tconst textInputRef = useRef();\n\tconst isEndingEditWithFocus = useRef( false );\n\n\tconst settingsKeys = settings.map( ( { id } ) => id );\n\n\tconst [\n\t\tinternalControlValue,\n\t\tsetInternalControlValue,\n\t\tsetInternalURLInputValue,\n\t\tsetInternalTextInputValue,\n\t\tcreateSetInternalSettingValueHandler,\n\t] = useInternalValue( value );\n\n\tconst valueHasChanges =\n\t\tvalue && ! isShallowEqualObjects( internalControlValue, value );\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState(\n\t\tforceIsEditingLink !== undefined\n\t\t\t? forceIsEditingLink\n\t\t\t: ! value || ! value.url\n\t);\n\n\tconst { createPage, isCreatingPage, errorMessage } =\n\t\tuseCreatePage( createSuggestion );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tforceIsEditingLink !== undefined &&\n\t\t\tforceIsEditingLink !== isEditingLink\n\t\t) {\n\t\t\tsetIsEditingLink( forceIsEditingLink );\n\t\t}\n\t\t// Todo: bug if the missing dep is introduced. Will need a fix.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ forceIsEditingLink ] );\n\n\tuseEffect( () => {\n\t\t// We don't auto focus into the Link UI on mount\n\t\t// because otherwise using the keyboard to select text\n\t\t// *within* the link format is not possible.\n\t\tif ( isMounting.current ) {\n\t\t\tisMounting.current = false;\n\t\t\treturn;\n\t\t}\n\n\t\t// Scenario - when:\n\t\t// - switching between editable and non editable LinkControl\n\t\t// - clicking on a link\n\t\t// ...then move focus to the *first* element to avoid focus loss\n\t\t// and to ensure focus is *within* the Link UI.\n\t\tconst nextFocusTarget =\n\t\t\tfocus.focusable.find( wrapperNode.current )[ 0 ] ||\n\t\t\twrapperNode.current;\n\n\t\tnextFocusTarget.focus();\n\n\t\tisEndingEditWithFocus.current = false;\n\t}, [ isEditingLink, isCreatingPage ] );\n\n\tconst hasLinkValue = value?.url?.trim()?.length > 0;\n\n\t/**\n\t * Cancels editing state and marks that focus may need to be restored after\n\t * the next render, if focus was within the wrapper when editing finished.\n\t */\n\tconst stopEditing = () => {\n\t\tisEndingEditWithFocus.current = !! wrapperNode.current?.contains(\n\t\t\twrapperNode.current.ownerDocument.activeElement\n\t\t);\n\n\t\tsetIsEditingLink( false );\n\t};\n\n\tconst handleSelectSuggestion = ( updatedValue ) => {\n\t\t// Suggestions may contains \"settings\" values (e.g. `opensInNewTab`)\n\t\t// which should not overide any existing settings values set by the\n\t\t// user. This filters out any settings values from the suggestion.\n\t\tconst nonSettingsChanges = Object.keys( updatedValue ).reduce(\n\t\t\t( acc, key ) => {\n\t\t\t\tif ( ! settingsKeys.includes( key ) ) {\n\t\t\t\t\tacc[ key ] = updatedValue[ key ];\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\tonChange( {\n\t\t\t...internalControlValue,\n\t\t\t...nonSettingsChanges,\n\t\t\t// As title is not a setting, it must be manually applied\n\t\t\t// in such a way as to preserve the users changes over\n\t\t\t// any \"title\" value provided by the \"suggestion\".\n\t\t\ttitle: internalControlValue?.title || updatedValue?.title,\n\t\t} );\n\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmit = () => {\n\t\tif ( valueHasChanges ) {\n\t\t\t// Submit the original value with new stored values applied\n\t\t\t// on top. URL is a special case as it may also be a prop.\n\t\t\tonChange( {\n\t\t\t\t...value,\n\t\t\t\t...internalControlValue,\n\t\t\t\turl: currentUrlInputValue,\n\t\t\t} );\n\t\t}\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmitWithEnter = ( event ) => {\n\t\tconst { keyCode } = event;\n\n\t\tif (\n\t\t\tkeyCode === ENTER &&\n\t\t\t! currentInputIsEmpty // Disallow submitting empty values.\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t\thandleSubmit();\n\t\t}\n\t};\n\n\tconst resetInternalValues = () => {\n\t\tsetInternalControlValue( value );\n\t};\n\n\tconst handleCancel = ( event ) => {\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\n\t\t// Ensure that any unsubmitted input changes are reset.\n\t\tresetInternalValues();\n\n\t\tif ( hasLinkValue ) {\n\t\t\t// If there is a link then exist editing mode and show preview.\n\t\t\tstopEditing();\n\t\t} else {\n\t\t\t// If there is no link value, then remove the link entirely.\n\t\t\tonRemove?.();\n\t\t}\n\n\t\tonCancel?.();\n\t};\n\n\tconst currentUrlInputValue =\n\t\tpropInputValue || internalControlValue?.url || '';\n\n\tconst currentInputIsEmpty = ! currentUrlInputValue?.trim()?.length;\n\n\tconst shownUnlinkControl =\n\t\tonRemove && value && ! isEditingLink && ! isCreatingPage;\n\n\tconst showActions = isEditingLink && hasLinkValue;\n\n\t// Only show text control once a URL value has been committed\n\t// and it isn't just empty whitespace.\n\t// See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.\n\tconst showTextControl = hasLinkValue && hasTextControl;\n\n\tconst isEditing = ( isEditingLink || ! value ) && ! isCreatingPage;\n\tconst isDisabled = ! valueHasChanges || currentInputIsEmpty;\n\tconst showSettings = !! settings?.length && isEditingLink && hasLinkValue;\n\n\treturn (\n\t\t<div\n\t\t\ttabIndex={ -1 }\n\t\t\tref={ wrapperNode }\n\t\t\tclassName=\"block-editor-link-control\"\n\t\t>\n\t\t\t{ isCreatingPage && (\n\t\t\t\t<div className=\"block-editor-link-control__loading\">\n\t\t\t\t\t<Spinner /> { __( 'Creating' ) }…\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ isEditing && (\n\t\t\t\t<>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames( {\n\t\t\t\t\t\t\t'block-editor-link-control__search-input-wrapper': true,\n\t\t\t\t\t\t\t'has-text-control': showTextControl,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ showTextControl && (\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tref={ textInputRef }\n\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__text-content\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\t\t\t\t\tvalue={ internalControlValue?.title }\n\t\t\t\t\t\t\t\tonChange={ setInternalTextInputValue }\n\t\t\t\t\t\t\t\tonKeyDown={ handleSubmitWithEnter }\n\t\t\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<LinkControlSearchInput\n\t\t\t\t\t\t\tcurrentLink={ value }\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__search-input\"\n\t\t\t\t\t\t\tplaceholder={ searchInputPlaceholder }\n\t\t\t\t\t\t\tvalue={ currentUrlInputValue }\n\t\t\t\t\t\t\twithCreateSuggestion={ withCreateSuggestion }\n\t\t\t\t\t\t\tonCreateSuggestion={ createPage }\n\t\t\t\t\t\t\tonChange={ setInternalURLInputValue }\n\t\t\t\t\t\t\tonSelect={ handleSelectSuggestion }\n\t\t\t\t\t\t\tshowInitialSuggestions={ showInitialSuggestions }\n\t\t\t\t\t\t\tallowDirectEntry={ ! noDirectEntry }\n\t\t\t\t\t\t\tshowSuggestions={ showSuggestions }\n\t\t\t\t\t\t\tsuggestionsQuery={ suggestionsQuery }\n\t\t\t\t\t\t\twithURLSuggestion={ ! noURLSuggestion }\n\t\t\t\t\t\t\tcreateSuggestionButtonText={\n\t\t\t\t\t\t\t\tcreateSuggestionButtonText\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\thideLabelFromVision={ ! showTextControl }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t{ errorMessage && (\n\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-error\"\n\t\t\t\t\t\t\tstatus=\"error\"\n\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ errorMessage }\n\t\t\t\t\t\t</Notice>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ value && ! isEditingLink && ! isCreatingPage && (\n\t\t\t\t<LinkPreview\n\t\t\t\t\tkey={ value?.url } // force remount when URL changes to avoid race conditions for rich previews\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonEditClick={ () => setIsEditingLink( true ) }\n\t\t\t\t\thasRichPreviews={ hasRichPreviews }\n\t\t\t\t\thasUnlinkControl={ shownUnlinkControl }\n\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\tonRemove();\n\t\t\t\t\t\tsetIsEditingLink( true );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ showSettings && (\n\t\t\t\t<div className=\"block-editor-link-control__tools\">\n\t\t\t\t\t{ ! currentInputIsEmpty && (\n\t\t\t\t\t\t<LinkControlSettingsDrawer\n\t\t\t\t\t\t\tsettingsOpen={ isSettingsOpen }\n\t\t\t\t\t\t\tsetSettingsOpen={ setSettingsOpenWithPreference }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<LinkSettings\n\t\t\t\t\t\t\t\tvalue={ internalControlValue }\n\t\t\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\t\t\tonChange={ createSetInternalSettingValueHandler(\n\t\t\t\t\t\t\t\t\tsettingsKeys\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</LinkControlSettingsDrawer>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ showActions && (\n\t\t\t\t<div className=\"block-editor-link-control__search-actions\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ isDisabled ? noop : handleSubmit }\n\t\t\t\t\t\tclassName=\"block-editor-link-control__search-submit\"\n\t\t\t\t\t\taria-disabled={ isDisabled }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button variant=\"tertiary\" onClick={ handleCancel }>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ renderControlBottom && renderControlBottom() }\n\t\t</div>\n\t);\n}\n\nLinkControl.ViewerFill = ViewerFill;\n\nexport default LinkControl;\n"]}
@@ -34,10 +34,10 @@ export default function LinkPreview({
34
34
  } = useRichUrlData(showRichPreviews); // Rich data may be an empty object so test for that.
35
35
 
36
36
  const hasRichData = richData && Object.keys(richData).length;
37
- const displayURL = value && filterURLForDisplay(safeDecodeURI(value.url), 16) || '';
38
- const displayTitle = richData?.title || value?.title || displayURL; // url can be undefined if the href attribute is unset
37
+ const displayURL = value && filterURLForDisplay(safeDecodeURI(value.url), 16) || ''; // url can be undefined if the href attribute is unset
39
38
 
40
39
  const isEmptyURL = !value?.url?.length;
40
+ const displayTitle = !isEmptyURL && stripHTML(richData?.title || value?.title || displayURL);
41
41
  let icon;
42
42
 
43
43
  if (richData?.icon) {
@@ -78,7 +78,7 @@ export default function LinkPreview({
78
78
  }, !isEmptyURL ? createElement(Fragment, null, createElement(ExternalLink, {
79
79
  className: "block-editor-link-control__search-item-title",
80
80
  href: value.url
81
- }, stripHTML(displayTitle)), value?.url && createElement("span", {
81
+ }, displayTitle), value?.url && displayTitle !== displayURL && createElement("span", {
82
82
  className: "block-editor-link-control__search-item-info"
83
83
  }, displayURL)) : createElement("span", {
84
84
  className: "block-editor-link-control__search-item-error-notice"
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/link-preview.js"],"names":["classnames","__","Button","ExternalLink","__experimentalText","Text","filterURLForDisplay","safeDecodeURI","Icon","globe","info","linkOff","edit","__unstableStripHTML","stripHTML","ViewerSlot","useRichUrlData","LinkPreview","value","onEditClick","hasRichPreviews","hasUnlinkControl","onRemove","showRichPreviews","url","richData","isFetching","hasRichData","Object","keys","length","displayURL","displayTitle","title","isEmptyURL","icon","image","description"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,MADD,EAECC,YAFD,EAGCC,kBAAkB,IAAIC,IAHvB,QAIO,uBAJP;AAKA,SAASC,mBAAT,EAA8BC,aAA9B,QAAmD,gBAAnD;AACA,SAASC,IAAT,EAAeC,KAAf,EAAsBC,IAAtB,EAA4BC,OAA5B,EAAqCC,IAArC,QAAiD,kBAAjD;AACA,SAASC,mBAAmB,IAAIC,SAAhC,QAAiD,gBAAjD;AAEA;AACA;AACA;;AACA,SAASC,UAAT,QAA2B,eAA3B;AAEA,OAAOC,cAAP,MAA2B,qBAA3B;AAEA,eAAe,SAASC,WAAT,CAAsB;AACpCC,EAAAA,KADoC;AAEpCC,EAAAA,WAFoC;AAGpCC,EAAAA,eAAe,GAAG,KAHkB;AAIpCC,EAAAA,gBAAgB,GAAG,KAJiB;AAKpCC,EAAAA;AALoC,CAAtB,EAMX;AACH;AACA,QAAMC,gBAAgB,GAAGH,eAAe,GAAGF,KAAK,EAAEM,GAAV,GAAgB,IAAxD;AAEA,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAA2BV,cAAc,CAAEO,gBAAF,CAA/C,CAJG,CAMH;;AACA,QAAMI,WAAW,GAAGF,QAAQ,IAAIG,MAAM,CAACC,IAAP,CAAaJ,QAAb,EAAwBK,MAAxD;AAEA,QAAMC,UAAU,GACbb,KAAK,IAAIZ,mBAAmB,CAAEC,aAAa,CAAEW,KAAK,CAACM,GAAR,CAAf,EAA8B,EAA9B,CAA9B,IACA,EAFD;AAIA,QAAMQ,YAAY,GAAGP,QAAQ,EAAEQ,KAAV,IAAmBf,KAAK,EAAEe,KAA1B,IAAmCF,UAAxD,CAbG,CAeH;;AACA,QAAMG,UAAU,GAAG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Ad;AAAe,IAAA,aAAa,EAAC;AAA7B,KACGZ,QAAQ,CAACY,WADZ,CAVF,CAlBF,CAtEF,CADD;AA6GA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tButton,\n\tExternalLink,\n\t__experimentalText as Text,\n} from '@wordpress/components';\nimport { filterURLForDisplay, safeDecodeURI } from '@wordpress/url';\nimport { Icon, globe, info, linkOff, edit } from '@wordpress/icons';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { ViewerSlot } from './viewer-slot';\n\nimport useRichUrlData from './use-rich-url-data';\n\nexport default function LinkPreview( {\n\tvalue,\n\tonEditClick,\n\thasRichPreviews = false,\n\thasUnlinkControl = false,\n\tonRemove,\n} ) {\n\t// Avoid fetching if rich previews are not desired.\n\tconst showRichPreviews = hasRichPreviews ? value?.url : null;\n\n\tconst { richData, isFetching } = useRichUrlData( showRichPreviews );\n\n\t// Rich data may be an empty object so test for that.\n\tconst hasRichData = richData && Object.keys( richData ).length;\n\n\tconst displayURL =\n\t\t( value && filterURLForDisplay( safeDecodeURI( value.url ), 16 ) ) ||\n\t\t'';\n\n\tconst displayTitle = richData?.title || value?.title || displayURL;\n\n\t// url can be undefined if the href attribute is unset\n\tconst isEmptyURL = ! value?.url?.length;\n\n\tlet icon;\n\n\tif ( richData?.icon ) {\n\t\ticon = <img src={ richData?.icon } alt=\"\" />;\n\t} else if ( isEmptyURL ) {\n\t\ticon = <Icon icon={ info } size={ 32 } />;\n\t} else {\n\t\ticon = <Icon icon={ globe } />;\n\t}\n\n\treturn (\n\t\t<div\n\t\t\taria-label={ __( 'Currently selected' ) }\n\t\t\tclassName={ classnames( 'block-editor-link-control__search-item', {\n\t\t\t\t'is-current': true,\n\t\t\t\t'is-rich': hasRichData,\n\t\t\t\t'is-fetching': !! isFetching,\n\t\t\t\t'is-preview': true,\n\t\t\t\t'is-error': isEmptyURL,\n\t\t\t} ) }\n\t\t>\n\t\t\t<div className=\"block-editor-link-control__search-item-top\">\n\t\t\t\t<span className=\"block-editor-link-control__search-item-header\">\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-link-control__search-item-icon',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-image': richData?.icon,\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\t\t{ icon }\n\t\t\t\t\t</span>\n\t\t\t\t\t<span className=\"block-editor-link-control__search-item-details\">\n\t\t\t\t\t\t{ ! isEmptyURL ? (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-item-title\"\n\t\t\t\t\t\t\t\t\thref={ value.url }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ stripHTML( displayTitle ) }\n\t\t\t\t\t\t\t\t</ExternalLink>\n\n\t\t\t\t\t\t\t\t{ value?.url && (\n\t\t\t\t\t\t\t\t\t<span className=\"block-editor-link-control__search-item-info\">\n\t\t\t\t\t\t\t\t\t\t{ displayURL }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<span className=\"block-editor-link-control__search-item-error-notice\">\n\t\t\t\t\t\t\t\t{ __( 'Link is empty' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t</span>\n\n\t\t\t\t<Button\n\t\t\t\t\ticon={ edit }\n\t\t\t\t\tlabel={ __( 'Edit' ) }\n\t\t\t\t\tclassName=\"block-editor-link-control__search-item-action\"\n\t\t\t\t\tonClick={ onEditClick }\n\t\t\t\t\ticonSize={ 24 }\n\t\t\t\t/>\n\t\t\t\t{ hasUnlinkControl && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\tlabel={ __( 'Unlink' ) }\n\t\t\t\t\t\tclassName=\"block-editor-link-control__search-item-action block-editor-link-control__unlink\"\n\t\t\t\t\t\tonClick={ onRemove }\n\t\t\t\t\t\ticonSize={ 24 }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<ViewerSlot fillProps={ value } />\n\t\t\t</div>\n\n\t\t\t{ !! (\n\t\t\t\t( hasRichData &&\n\t\t\t\t\t( richData?.image || richData?.description ) ) ||\n\t\t\t\tisFetching\n\t\t\t) && (\n\t\t\t\t<div className=\"block-editor-link-control__search-item-bottom\">\n\t\t\t\t\t{ ( richData?.image || isFetching ) && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\taria-hidden={ ! richData?.image }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-link-control__search-item-image',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-placeholder': ! richData?.image,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ richData?.image && (\n\t\t\t\t\t\t\t\t<img src={ richData?.image } alt=\"\" />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ ( richData?.description || isFetching ) && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\taria-hidden={ ! richData?.description }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-link-control__search-item-description',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-placeholder': ! richData?.description,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ richData?.description && (\n\t\t\t\t\t\t\t\t<Text truncate numberOfLines=\"2\">\n\t\t\t\t\t\t\t\t\t{ richData.description }\n\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/link-preview.js"],"names":["classnames","__","Button","ExternalLink","__experimentalText","Text","filterURLForDisplay","safeDecodeURI","Icon","globe","info","linkOff","edit","__unstableStripHTML","stripHTML","ViewerSlot","useRichUrlData","LinkPreview","value","onEditClick","hasRichPreviews","hasUnlinkControl","onRemove","showRichPreviews","url","richData","isFetching","hasRichData","Object","keys","length","displayURL","isEmptyURL","displayTitle","title","icon","image","description"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,MADD,EAECC,YAFD,EAGCC,kBAAkB,IAAIC,IAHvB,QAIO,uBAJP;AAKA,SAASC,mBAAT,EAA8BC,aAA9B,QAAmD,gBAAnD;AACA,SAASC,IAAT,EAAeC,KAAf,EAAsBC,IAAtB,EAA4BC,OAA5B,EAAqCC,IAArC,QAAiD,kBAAjD;AACA,SAASC,mBAAmB,IAAIC,SAAhC,QAAiD,gBAAjD;AAEA;AACA;AACA;;AACA,SAASC,UAAT,QAA2B,eAA3B;AAEA,OAAOC,cAAP,MAA2B,qBAA3B;AAEA,eAAe,SAASC,WAAT,CAAsB;AACpCC,EAAAA,KADoC;AAEpCC,EAAAA,WAFoC;AAGpCC,EAAAA,eAAe,GAAG,KAHkB;AAIpCC,EAAAA,gBAAgB,GAAG,KAJiB;AAKpCC,EAAAA;AALoC,CAAtB,EAMX;AACH;AACA,QAAMC,gBAAgB,GAAGH,eAAe,GAAGF,KAAK,EAAEM,GAAV,GAAgB,IAAxD;AAEA,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MA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AAQ,EAAEW;AAD/B,KAFqB;AAFvB,KASGX,QAAQ,EAAEW,KAAV,IACD;AAAK,IAAA,GAAG,EAAGX,QAAQ,EAAEW,KAArB;AAA6B,IAAA,GAAG,EAAC;AAAjC,IAVF,CAFF,EAiBG,CAAEX,QAAQ,EAAEY,WAAV,IAAyBX,UAA3B,KACD;AACC,mBAAc,CAAED,QAAQ,EAAEY,WAD3B;AAEC,IAAA,SAAS,EAAGrC,UAAU,CACrB,oDADqB,EAErB;AACC,wBAAkB,CAAEyB,QAAQ,EAAEY;AAD/B,KAFqB;AAFvB,KASGZ,QAAQ,EAAEY,WAAV,IACD,cAAC,IAAD;AAAM,IAAA,QAAQ,MAAd;AAAe,IAAA,aAAa,EAAC;AAA7B,KACGZ,QAAQ,CAACY,WADZ,CAVF,CAlBF,CAtEF,CADD;AA6GA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tButton,\n\tExternalLink,\n\t__experimentalText as Text,\n} from '@wordpress/components';\nimport { filterURLForDisplay, safeDecodeURI } from '@wordpress/url';\nimport { Icon, globe, info, linkOff, edit } from '@wordpress/icons';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { ViewerSlot } from './viewer-slot';\n\nimport useRichUrlData from './use-rich-url-data';\n\nexport default function LinkPreview( {\n\tvalue,\n\tonEditClick,\n\thasRichPreviews = false,\n\thasUnlinkControl = false,\n\tonRemove,\n} ) {\n\t// Avoid fetching if rich previews are not desired.\n\tconst showRichPreviews = hasRichPreviews ? value?.url : null;\n\n\tconst { richData, isFetching } = useRichUrlData( showRichPreviews );\n\n\t// Rich data may be an empty object so test for that.\n\tconst hasRichData = richData && Object.keys( richData ).length;\n\n\tconst displayURL =\n\t\t( value && filterURLForDisplay( safeDecodeURI( value.url ), 16 ) ) ||\n\t\t'';\n\n\t// url can be undefined if the href attribute is unset\n\tconst isEmptyURL = ! value?.url?.length;\n\n\tconst displayTitle =\n\t\t! isEmptyURL &&\n\t\tstripHTML( richData?.title || value?.title || displayURL );\n\n\tlet icon;\n\n\tif ( richData?.icon ) {\n\t\ticon = <img src={ richData?.icon } alt=\"\" />;\n\t} else if ( isEmptyURL ) {\n\t\ticon = <Icon icon={ info } size={ 32 } />;\n\t} else {\n\t\ticon = <Icon icon={ globe } />;\n\t}\n\n\treturn (\n\t\t<div\n\t\t\taria-label={ __( 'Currently selected' ) }\n\t\t\tclassName={ classnames( 'block-editor-link-control__search-item', {\n\t\t\t\t'is-current': true,\n\t\t\t\t'is-rich': hasRichData,\n\t\t\t\t'is-fetching': !! isFetching,\n\t\t\t\t'is-preview': true,\n\t\t\t\t'is-error': isEmptyURL,\n\t\t\t} ) }\n\t\t>\n\t\t\t<div className=\"block-editor-link-control__search-item-top\">\n\t\t\t\t<span className=\"block-editor-link-control__search-item-header\">\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-link-control__search-item-icon',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-image': richData?.icon,\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\t\t{ icon }\n\t\t\t\t\t</span>\n\t\t\t\t\t<span className=\"block-editor-link-control__search-item-details\">\n\t\t\t\t\t\t{ ! isEmptyURL ? (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-item-title\"\n\t\t\t\t\t\t\t\t\thref={ value.url }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ displayTitle }\n\t\t\t\t\t\t\t\t</ExternalLink>\n\n\t\t\t\t\t\t\t\t{ value?.url && displayTitle !== displayURL && (\n\t\t\t\t\t\t\t\t\t<span className=\"block-editor-link-control__search-item-info\">\n\t\t\t\t\t\t\t\t\t\t{ displayURL }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<span className=\"block-editor-link-control__search-item-error-notice\">\n\t\t\t\t\t\t\t\t{ __( 'Link is empty' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t</span>\n\n\t\t\t\t<Button\n\t\t\t\t\ticon={ edit }\n\t\t\t\t\tlabel={ __( 'Edit' ) }\n\t\t\t\t\tclassName=\"block-editor-link-control__search-item-action\"\n\t\t\t\t\tonClick={ onEditClick }\n\t\t\t\t\ticonSize={ 24 }\n\t\t\t\t/>\n\t\t\t\t{ hasUnlinkControl && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\tlabel={ __( 'Unlink' ) }\n\t\t\t\t\t\tclassName=\"block-editor-link-control__search-item-action block-editor-link-control__unlink\"\n\t\t\t\t\t\tonClick={ onRemove }\n\t\t\t\t\t\ticonSize={ 24 }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<ViewerSlot fillProps={ value } />\n\t\t\t</div>\n\n\t\t\t{ !! (\n\t\t\t\t( hasRichData &&\n\t\t\t\t\t( richData?.image || richData?.description ) ) ||\n\t\t\t\tisFetching\n\t\t\t) && (\n\t\t\t\t<div className=\"block-editor-link-control__search-item-bottom\">\n\t\t\t\t\t{ ( richData?.image || isFetching ) && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\taria-hidden={ ! richData?.image }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-link-control__search-item-image',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-placeholder': ! richData?.image,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ richData?.image && (\n\t\t\t\t\t\t\t\t<img src={ richData?.image } alt=\"\" />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ ( richData?.description || isFetching ) && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\taria-hidden={ ! richData?.description }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-link-control__search-item-description',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-placeholder': ! richData?.description,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ richData?.description && (\n\t\t\t\t\t\t\t\t<Text truncate numberOfLines=\"2\">\n\t\t\t\t\t\t\t\t\t{ richData.description }\n\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"]}