@wordpress/block-editor 10.5.0 → 11.0.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 (488) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/build/autocompleters/block.js +2 -6
  3. package/build/autocompleters/block.js.map +1 -1
  4. package/build/autocompleters/link.js +2 -0
  5. package/build/autocompleters/link.js.map +1 -1
  6. package/build/components/block-card/index.js +51 -3
  7. package/build/components/block-card/index.js.map +1 -1
  8. package/build/components/block-draggable/index.native.js +46 -39
  9. package/build/components/block-draggable/index.native.js.map +1 -1
  10. package/build/components/block-edit/edit.js +4 -3
  11. package/build/components/block-edit/edit.js.map +1 -1
  12. package/build/components/block-edit/edit.native.js +4 -7
  13. package/build/components/block-edit/edit.native.js.map +1 -1
  14. package/build/components/block-inspector/index.js +35 -33
  15. package/build/components/block-inspector/index.js.map +1 -1
  16. package/build/components/block-list/block-list-context.native.js +5 -8
  17. package/build/components/block-list/block-list-context.native.js.map +1 -1
  18. package/build/components/block-list/block.js +55 -24
  19. package/build/components/block-list/block.js.map +1 -1
  20. package/build/components/block-list/block.native.js +61 -28
  21. package/build/components/block-list/block.native.js.map +1 -1
  22. package/build/components/block-mobile-toolbar/block-actions-menu.native.js +12 -4
  23. package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  24. package/build/components/block-pattern-setup/index.js +3 -2
  25. package/build/components/block-pattern-setup/index.js.map +1 -1
  26. package/build/components/block-patterns-list/index.js +33 -11
  27. package/build/components/block-patterns-list/index.js.map +1 -1
  28. package/build/components/block-preview/auto.js +9 -3
  29. package/build/components/block-preview/auto.js.map +1 -1
  30. package/build/components/block-preview/index.js +5 -9
  31. package/build/components/block-preview/index.js.map +1 -1
  32. package/build/components/block-settings-menu/block-settings-dropdown.js +5 -2
  33. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  34. package/build/components/block-toolbar/index.js +5 -1
  35. package/build/components/block-toolbar/index.js.map +1 -1
  36. package/build/components/block-tools/insertion-point.js +8 -49
  37. package/build/components/block-tools/insertion-point.js.map +1 -1
  38. package/build/components/block-variation-picker/index.js +1 -2
  39. package/build/components/block-variation-picker/index.js.map +1 -1
  40. package/build/components/height-control/index.js +115 -0
  41. package/build/components/height-control/index.js.map +1 -0
  42. package/build/components/iframe/index.js +11 -8
  43. package/build/components/iframe/index.js.map +1 -1
  44. package/build/components/image-editor/use-save-image.js +2 -0
  45. package/build/components/image-editor/use-save-image.js.map +1 -1
  46. package/build/components/image-editor/zoom-dropdown.js +1 -0
  47. package/build/components/image-editor/zoom-dropdown.js.map +1 -1
  48. package/build/components/index.js +9 -0
  49. package/build/components/index.js.map +1 -1
  50. package/build/components/inner-blocks/index.js +20 -6
  51. package/build/components/inner-blocks/index.js.map +1 -1
  52. package/build/components/inner-blocks/use-inner-block-template-sync.js +25 -10
  53. package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  54. package/build/components/inserter/block-patterns-explorer/sidebar.js +1 -0
  55. package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
  56. package/build/components/inserter/block-patterns-tab.js +25 -46
  57. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  58. package/build/components/inserter/block-types-tab.js +3 -1
  59. package/build/components/inserter/block-types-tab.js.map +1 -1
  60. package/build/components/inserter/hooks/use-debounced-input.js +27 -0
  61. package/build/components/inserter/hooks/use-debounced-input.js.map +1 -0
  62. package/build/components/inserter/index.js +8 -3
  63. package/build/components/inserter/index.js.map +1 -1
  64. package/build/components/inserter/index.native.js +3 -4
  65. package/build/components/inserter/index.native.js.map +1 -1
  66. package/build/components/inserter/media-tab/hooks.js +103 -0
  67. package/build/components/inserter/media-tab/hooks.js.map +1 -0
  68. package/build/components/inserter/media-tab/index.js +32 -0
  69. package/build/components/inserter/media-tab/index.js.map +1 -0
  70. package/build/components/inserter/media-tab/media-list.js +100 -0
  71. package/build/components/inserter/media-tab/media-list.js.map +1 -0
  72. package/build/components/inserter/media-tab/media-panel.js +96 -0
  73. package/build/components/inserter/media-tab/media-panel.js.map +1 -0
  74. package/build/components/inserter/media-tab/media-tab.js +120 -0
  75. package/build/components/inserter/media-tab/media-tab.js.map +1 -0
  76. package/build/components/inserter/media-tab/utils.js +54 -0
  77. package/build/components/inserter/media-tab/utils.js.map +1 -0
  78. package/build/components/inserter/menu.js +35 -12
  79. package/build/components/inserter/menu.js.map +1 -1
  80. package/build/components/inserter/mobile-tab-navigation.js +70 -0
  81. package/build/components/inserter/mobile-tab-navigation.js.map +1 -0
  82. package/build/components/inserter/quick-inserter.js +1 -0
  83. package/build/components/inserter/quick-inserter.js.map +1 -1
  84. package/build/components/inserter/search-results.js +3 -1
  85. package/build/components/inserter/search-results.js.map +1 -1
  86. package/build/components/inserter/tabs.js +16 -2
  87. package/build/components/inserter/tabs.js.map +1 -1
  88. package/build/components/inserter-list-item/index.js +4 -1
  89. package/build/components/inserter-list-item/index.js.map +1 -1
  90. package/build/components/inspector-controls/groups.js +2 -0
  91. package/build/components/inspector-controls/groups.js.map +1 -1
  92. package/build/components/inspector-controls-tabs/advanced-controls-panel.js +46 -0
  93. package/build/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
  94. package/build/components/inspector-controls-tabs/index.js +71 -0
  95. package/build/components/inspector-controls-tabs/index.js.map +1 -0
  96. package/build/components/inspector-controls-tabs/settings-tab.js +28 -0
  97. package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -0
  98. package/build/components/inspector-controls-tabs/styles-tab.js +61 -0
  99. package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -0
  100. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +97 -0
  101. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
  102. package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +18 -0
  103. package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
  104. package/build/components/inspector-controls-tabs/utils.js +37 -0
  105. package/build/components/inspector-controls-tabs/utils.js.map +1 -0
  106. package/build/components/link-control/index.js +1 -0
  107. package/build/components/link-control/index.js.map +1 -1
  108. package/build/components/link-control/search-input.js +0 -1
  109. package/build/components/link-control/search-input.js.map +1 -1
  110. package/build/components/link-control/use-internal-input-value.js +3 -3
  111. package/build/components/link-control/use-internal-input-value.js.map +1 -1
  112. package/build/components/list-view/block.js +5 -2
  113. package/build/components/list-view/block.js.map +1 -1
  114. package/build/components/list-view/branch.js +13 -12
  115. package/build/components/list-view/branch.js.map +1 -1
  116. package/build/components/media-upload/index.native.js +2 -3
  117. package/build/components/media-upload/index.native.js.map +1 -1
  118. package/build/components/off-canvas-editor/appender.js +104 -0
  119. package/build/components/off-canvas-editor/appender.js.map +1 -0
  120. package/build/components/off-canvas-editor/block-edit-button.js +50 -0
  121. package/build/components/off-canvas-editor/block-edit-button.js.map +1 -0
  122. package/build/components/off-canvas-editor/block.js +36 -4
  123. package/build/components/off-canvas-editor/block.js.map +1 -1
  124. package/build/components/off-canvas-editor/branch.js +3 -5
  125. package/build/components/off-canvas-editor/branch.js.map +1 -1
  126. package/build/components/off-canvas-editor/index.js +20 -11
  127. package/build/components/off-canvas-editor/index.js.map +1 -1
  128. package/build/components/off-canvas-editor/leaf.js +1 -1
  129. package/build/components/off-canvas-editor/leaf.js.map +1 -1
  130. package/build/components/off-canvas-editor/link-ui.js +185 -0
  131. package/build/components/off-canvas-editor/link-ui.js.map +1 -0
  132. package/build/components/off-canvas-editor/update-attributes.js +108 -0
  133. package/build/components/off-canvas-editor/update-attributes.js.map +1 -0
  134. package/build/components/rich-text/format-toolbar/index.js +8 -4
  135. package/build/components/rich-text/format-toolbar/index.js.map +1 -1
  136. package/build/components/rich-text/index.js +3 -3
  137. package/build/components/rich-text/index.js.map +1 -1
  138. package/build/components/rich-text/index.native.js +0 -2
  139. package/build/components/rich-text/index.native.js.map +1 -1
  140. package/build/components/rich-text/use-insert-replacement-text.js +43 -0
  141. package/build/components/rich-text/use-insert-replacement-text.js.map +1 -0
  142. package/build/components/rich-text/use-undo-automatic-change.js +9 -1
  143. package/build/components/rich-text/use-undo-automatic-change.js.map +1 -1
  144. package/build/components/rich-text/utils.js +1 -19
  145. package/build/components/rich-text/utils.js.map +1 -1
  146. package/build/components/spacing-sizes-control/spacing-input-control.js +12 -3
  147. package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  148. package/build/components/ungroup-button/index.native.js +4 -2
  149. package/build/components/ungroup-button/index.native.js.map +1 -1
  150. package/build/components/url-input/index.js +46 -43
  151. package/build/components/url-input/index.js.map +1 -1
  152. package/build/components/use-block-display-information/index.js +8 -4
  153. package/build/components/use-block-display-information/index.js.map +1 -1
  154. package/build/components/use-setting/index.js +9 -1
  155. package/build/components/use-setting/index.js.map +1 -1
  156. package/build/hooks/child-layout.js +209 -0
  157. package/build/hooks/child-layout.js.map +1 -0
  158. package/build/hooks/content-lock-ui.js +1 -1
  159. package/build/hooks/content-lock-ui.js.map +1 -1
  160. package/build/hooks/dimensions.js +25 -7
  161. package/build/hooks/dimensions.js.map +1 -1
  162. package/build/hooks/layout.js +57 -1
  163. package/build/hooks/layout.js.map +1 -1
  164. package/build/hooks/min-height.js +4 -10
  165. package/build/hooks/min-height.js.map +1 -1
  166. package/build/store/reducer.js +393 -270
  167. package/build/store/reducer.js.map +1 -1
  168. package/build/store/selectors.js +57 -47
  169. package/build/store/selectors.js.map +1 -1
  170. package/build/utils/sorting.js +63 -0
  171. package/build/utils/sorting.js.map +1 -0
  172. package/build-module/autocompleters/block.js +2 -6
  173. package/build-module/autocompleters/block.js.map +1 -1
  174. package/build-module/autocompleters/link.js +2 -0
  175. package/build-module/autocompleters/link.js.map +1 -1
  176. package/build-module/components/block-card/index.js +45 -3
  177. package/build-module/components/block-card/index.js.map +1 -1
  178. package/build-module/components/block-draggable/index.native.js +40 -31
  179. package/build-module/components/block-draggable/index.native.js.map +1 -1
  180. package/build-module/components/block-edit/edit.js +4 -2
  181. package/build-module/components/block-edit/edit.js.map +1 -1
  182. package/build-module/components/block-edit/edit.native.js +4 -6
  183. package/build-module/components/block-edit/edit.native.js.map +1 -1
  184. package/build-module/components/block-inspector/index.js +32 -30
  185. package/build-module/components/block-inspector/index.js.map +1 -1
  186. package/build-module/components/block-list/block-list-context.native.js +5 -8
  187. package/build-module/components/block-list/block-list-context.native.js.map +1 -1
  188. package/build-module/components/block-list/block.js +55 -25
  189. package/build-module/components/block-list/block.js.map +1 -1
  190. package/build-module/components/block-list/block.native.js +61 -28
  191. package/build-module/components/block-list/block.native.js.map +1 -1
  192. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +13 -6
  193. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  194. package/build-module/components/block-pattern-setup/index.js +3 -2
  195. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  196. package/build-module/components/block-patterns-list/index.js +35 -13
  197. package/build-module/components/block-patterns-list/index.js.map +1 -1
  198. package/build-module/components/block-preview/auto.js +9 -3
  199. package/build-module/components/block-preview/auto.js.map +1 -1
  200. package/build-module/components/block-preview/index.js +5 -8
  201. package/build-module/components/block-preview/index.js.map +1 -1
  202. package/build-module/components/block-settings-menu/block-settings-dropdown.js +5 -2
  203. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  204. package/build-module/components/block-toolbar/index.js +6 -2
  205. package/build-module/components/block-toolbar/index.js.map +1 -1
  206. package/build-module/components/block-tools/insertion-point.js +8 -49
  207. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  208. package/build-module/components/block-variation-picker/index.js +1 -2
  209. package/build-module/components/block-variation-picker/index.js.map +1 -1
  210. package/build-module/components/height-control/index.js +103 -0
  211. package/build-module/components/height-control/index.js.map +1 -0
  212. package/build-module/components/iframe/index.js +11 -8
  213. package/build-module/components/iframe/index.js.map +1 -1
  214. package/build-module/components/image-editor/use-save-image.js +2 -0
  215. package/build-module/components/image-editor/use-save-image.js.map +1 -1
  216. package/build-module/components/image-editor/zoom-dropdown.js +1 -0
  217. package/build-module/components/image-editor/zoom-dropdown.js.map +1 -1
  218. package/build-module/components/index.js +1 -0
  219. package/build-module/components/index.js.map +1 -1
  220. package/build-module/components/inner-blocks/index.js +22 -8
  221. package/build-module/components/inner-blocks/index.js.map +1 -1
  222. package/build-module/components/inner-blocks/use-inner-block-template-sync.js +23 -10
  223. package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  224. package/build-module/components/inserter/block-patterns-explorer/sidebar.js +1 -0
  225. package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
  226. package/build-module/components/inserter/block-patterns-tab.js +27 -49
  227. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  228. package/build-module/components/inserter/block-types-tab.js +3 -2
  229. package/build-module/components/inserter/block-types-tab.js.map +1 -1
  230. package/build-module/components/inserter/hooks/use-debounced-input.js +18 -0
  231. package/build-module/components/inserter/hooks/use-debounced-input.js.map +1 -0
  232. package/build-module/components/inserter/index.js +8 -3
  233. package/build-module/components/inserter/index.js.map +1 -1
  234. package/build-module/components/inserter/index.native.js +3 -5
  235. package/build-module/components/inserter/index.native.js.map +1 -1
  236. package/build-module/components/inserter/media-tab/hooks.js +89 -0
  237. package/build-module/components/inserter/media-tab/hooks.js.map +1 -0
  238. package/build-module/components/inserter/media-tab/index.js +4 -0
  239. package/build-module/components/inserter/media-tab/index.js.map +1 -0
  240. package/build-module/components/inserter/media-tab/media-list.js +86 -0
  241. package/build-module/components/inserter/media-tab/media-list.js.map +1 -0
  242. package/build-module/components/inserter/media-tab/media-panel.js +77 -0
  243. package/build-module/components/inserter/media-tab/media-panel.js.map +1 -0
  244. package/build-module/components/inserter/media-tab/media-tab.js +100 -0
  245. package/build-module/components/inserter/media-tab/media-tab.js.map +1 -0
  246. package/build-module/components/inserter/media-tab/utils.js +45 -0
  247. package/build-module/components/inserter/media-tab/utils.js.map +1 -0
  248. package/build-module/components/inserter/menu.js +33 -12
  249. package/build-module/components/inserter/menu.js.map +1 -1
  250. package/build-module/components/inserter/mobile-tab-navigation.js +61 -0
  251. package/build-module/components/inserter/mobile-tab-navigation.js.map +1 -0
  252. package/build-module/components/inserter/quick-inserter.js +1 -0
  253. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  254. package/build-module/components/inserter/search-results.js +3 -2
  255. package/build-module/components/inserter/search-results.js.map +1 -1
  256. package/build-module/components/inserter/tabs.js +15 -2
  257. package/build-module/components/inserter/tabs.js.map +1 -1
  258. package/build-module/components/inserter-list-item/index.js +5 -2
  259. package/build-module/components/inserter-list-item/index.js.map +1 -1
  260. package/build-module/components/inspector-controls/groups.js +2 -0
  261. package/build-module/components/inspector-controls/groups.js.map +1 -1
  262. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js +32 -0
  263. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
  264. package/build-module/components/inspector-controls-tabs/index.js +56 -0
  265. package/build-module/components/inspector-controls-tabs/index.js.map +1 -0
  266. package/build-module/components/inspector-controls-tabs/settings-tab.js +17 -0
  267. package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -0
  268. package/build-module/components/inspector-controls-tabs/styles-tab.js +46 -0
  269. package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -0
  270. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +81 -0
  271. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
  272. package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +8 -0
  273. package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
  274. package/build-module/components/inspector-controls-tabs/utils.js +26 -0
  275. package/build-module/components/inspector-controls-tabs/utils.js.map +1 -0
  276. package/build-module/components/link-control/index.js +1 -0
  277. package/build-module/components/link-control/index.js.map +1 -1
  278. package/build-module/components/link-control/search-input.js +0 -1
  279. package/build-module/components/link-control/search-input.js.map +1 -1
  280. package/build-module/components/link-control/use-internal-input-value.js +3 -3
  281. package/build-module/components/link-control/use-internal-input-value.js.map +1 -1
  282. package/build-module/components/list-view/block.js +5 -2
  283. package/build-module/components/list-view/block.js.map +1 -1
  284. package/build-module/components/list-view/branch.js +12 -11
  285. package/build-module/components/list-view/branch.js.map +1 -1
  286. package/build-module/components/media-upload/index.native.js +2 -4
  287. package/build-module/components/media-upload/index.native.js.map +1 -1
  288. package/build-module/components/off-canvas-editor/appender.js +89 -0
  289. package/build-module/components/off-canvas-editor/appender.js.map +1 -0
  290. package/build-module/components/off-canvas-editor/block-edit-button.js +35 -0
  291. package/build-module/components/off-canvas-editor/block-edit-button.js.map +1 -0
  292. package/build-module/components/off-canvas-editor/block.js +36 -6
  293. package/build-module/components/off-canvas-editor/block.js.map +1 -1
  294. package/build-module/components/off-canvas-editor/branch.js +3 -4
  295. package/build-module/components/off-canvas-editor/branch.js.map +1 -1
  296. package/build-module/components/off-canvas-editor/index.js +20 -12
  297. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  298. package/build-module/components/off-canvas-editor/leaf.js +1 -1
  299. package/build-module/components/off-canvas-editor/leaf.js.map +1 -1
  300. package/build-module/components/off-canvas-editor/link-ui.js +165 -0
  301. package/build-module/components/off-canvas-editor/link-ui.js.map +1 -0
  302. package/build-module/components/off-canvas-editor/update-attributes.js +97 -0
  303. package/build-module/components/off-canvas-editor/update-attributes.js.map +1 -0
  304. package/build-module/components/rich-text/format-toolbar/index.js +6 -2
  305. package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
  306. package/build-module/components/rich-text/index.js +2 -3
  307. package/build-module/components/rich-text/index.js.map +1 -1
  308. package/build-module/components/rich-text/index.native.js +0 -2
  309. package/build-module/components/rich-text/index.native.js.map +1 -1
  310. package/build-module/components/rich-text/use-insert-replacement-text.js +33 -0
  311. package/build-module/components/rich-text/use-insert-replacement-text.js.map +1 -0
  312. package/build-module/components/rich-text/use-undo-automatic-change.js +9 -1
  313. package/build-module/components/rich-text/use-undo-automatic-change.js.map +1 -1
  314. package/build-module/components/rich-text/utils.js +1 -16
  315. package/build-module/components/rich-text/utils.js.map +1 -1
  316. package/build-module/components/spacing-sizes-control/spacing-input-control.js +12 -3
  317. package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  318. package/build-module/components/ungroup-button/index.native.js +3 -2
  319. package/build-module/components/ungroup-button/index.native.js.map +1 -1
  320. package/build-module/components/url-input/index.js +46 -43
  321. package/build-module/components/url-input/index.js.map +1 -1
  322. package/build-module/components/use-block-display-information/index.js +9 -5
  323. package/build-module/components/use-block-display-information/index.js.map +1 -1
  324. package/build-module/components/use-setting/index.js +8 -1
  325. package/build-module/components/use-setting/index.js.map +1 -1
  326. package/build-module/hooks/child-layout.js +189 -0
  327. package/build-module/hooks/child-layout.js.map +1 -0
  328. package/build-module/hooks/content-lock-ui.js +1 -1
  329. package/build-module/hooks/content-lock-ui.js.map +1 -1
  330. package/build-module/hooks/dimensions.js +25 -8
  331. package/build-module/hooks/dimensions.js.map +1 -1
  332. package/build-module/hooks/layout.js +55 -0
  333. package/build-module/hooks/layout.js.map +1 -1
  334. package/build-module/hooks/min-height.js +3 -9
  335. package/build-module/hooks/min-height.js.map +1 -1
  336. package/build-module/store/reducer.js +391 -271
  337. package/build-module/store/reducer.js.map +1 -1
  338. package/build-module/store/selectors.js +54 -47
  339. package/build-module/store/selectors.js.map +1 -1
  340. package/build-module/utils/sorting.js +56 -0
  341. package/build-module/utils/sorting.js.map +1 -0
  342. package/build-style/content-rtl.css +701 -0
  343. package/build-style/content.css +701 -0
  344. package/build-style/default-editor-styles-rtl.css +14 -0
  345. package/build-style/default-editor-styles.css +14 -0
  346. package/build-style/style-rtl.css +286 -662
  347. package/build-style/style.css +286 -662
  348. package/package.json +32 -30
  349. package/src/autocompleters/block.js +2 -6
  350. package/src/autocompleters/link.js +2 -0
  351. package/src/components/alignment-control/test/index.js +4 -1
  352. package/src/components/block-alignment-control/test/index.js +4 -1
  353. package/src/components/block-card/index.js +46 -2
  354. package/src/components/block-card/style.scss +4 -0
  355. package/src/components/block-content-overlay/{style.scss → content.scss} +7 -1
  356. package/src/components/block-draggable/content.scss +20 -0
  357. package/src/components/block-draggable/index.native.js +54 -40
  358. package/src/components/block-draggable/style.scss +0 -21
  359. package/src/components/block-draggable/test/helpers.native.js +7 -9
  360. package/src/components/block-draggable/test/index.native.js +35 -45
  361. package/src/components/block-edit/edit.js +5 -2
  362. package/src/components/block-edit/edit.native.js +5 -6
  363. package/src/components/block-inspector/index.js +96 -81
  364. package/src/components/block-inspector/style.scss +9 -1
  365. package/src/components/block-list/block-list-context.native.js +5 -8
  366. package/src/components/block-list/block.js +74 -23
  367. package/src/components/block-list/block.native.js +78 -23
  368. package/src/components/block-list/{style.scss → content.scss} +1 -15
  369. package/src/components/block-list-appender/{style.scss → content.scss} +0 -0
  370. package/src/components/block-mobile-toolbar/block-actions-menu.native.js +24 -6
  371. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +0 -2
  372. package/src/components/block-pattern-setup/index.js +2 -1
  373. package/src/components/block-patterns-list/index.js +47 -24
  374. package/src/components/block-preview/README.md +15 -10
  375. package/src/components/block-preview/auto.js +7 -1
  376. package/src/components/block-preview/content.scss +4 -0
  377. package/src/components/block-preview/index.js +7 -12
  378. package/src/components/block-preview/style.scss +0 -7
  379. package/src/components/block-preview/test/index.js +18 -35
  380. package/src/components/block-selection-clearer/test/index.js +12 -12
  381. package/src/components/block-settings-menu/block-settings-dropdown.js +32 -20
  382. package/src/components/block-switcher/test/index.js +4 -0
  383. package/src/components/block-toolbar/index.js +12 -5
  384. package/src/components/block-toolbar/style.scss +10 -0
  385. package/src/components/block-tools/insertion-point.js +3 -47
  386. package/src/components/block-tools/style.scss +12 -5
  387. package/src/components/block-variation-picker/index.js +1 -4
  388. package/src/components/block-vertical-alignment-control/test/index.js +4 -1
  389. package/src/components/default-block-appender/{style.scss → content.scss} +0 -0
  390. package/src/components/height-control/index.js +123 -0
  391. package/src/components/height-control/stories/index.js +21 -0
  392. package/src/components/height-control/style.scss +5 -0
  393. package/src/components/iframe/index.js +25 -18
  394. package/src/components/image-editor/use-save-image.js +2 -0
  395. package/src/components/image-editor/zoom-dropdown.js +1 -0
  396. package/src/components/index.js +1 -0
  397. package/src/components/inner-blocks/{style.scss → content.scss} +0 -0
  398. package/src/components/inner-blocks/index.js +23 -6
  399. package/src/components/inner-blocks/use-inner-block-template-sync.js +28 -10
  400. package/src/components/inserter/block-patterns-explorer/sidebar.js +1 -0
  401. package/src/components/inserter/block-patterns-tab.js +28 -71
  402. package/src/components/inserter/block-types-tab.js +3 -2
  403. package/src/components/inserter/hooks/use-debounced-input.js +17 -0
  404. package/src/components/inserter/index.js +10 -2
  405. package/src/components/inserter/index.native.js +1 -1
  406. package/src/components/inserter/media-tab/hooks.js +88 -0
  407. package/src/components/inserter/media-tab/index.js +3 -0
  408. package/src/components/inserter/media-tab/media-list.js +93 -0
  409. package/src/components/inserter/media-tab/media-panel.js +83 -0
  410. package/src/components/inserter/media-tab/media-tab.js +135 -0
  411. package/src/components/inserter/media-tab/utils.js +37 -0
  412. package/src/components/inserter/menu.js +55 -13
  413. package/src/components/inserter/mobile-tab-navigation.js +85 -0
  414. package/src/components/inserter/quick-inserter.js +1 -0
  415. package/src/components/inserter/search-results.js +3 -2
  416. package/src/components/inserter/stories/index.js +1 -1
  417. package/src/components/inserter/stories/{fixtures.js → utils/fixtures.js} +0 -0
  418. package/src/components/inserter/style.scss +176 -11
  419. package/src/components/inserter/tabs.js +12 -1
  420. package/src/components/inserter-list-item/index.js +11 -1
  421. package/src/components/inserter-list-item/style.scss +26 -0
  422. package/src/components/inspector-controls/groups.js +2 -0
  423. package/src/components/inspector-controls-tabs/advanced-controls-panel.js +37 -0
  424. package/src/components/inspector-controls-tabs/index.js +62 -0
  425. package/src/components/inspector-controls-tabs/settings-tab.js +18 -0
  426. package/src/components/inspector-controls-tabs/styles-tab.js +51 -0
  427. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +89 -0
  428. package/src/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +9 -0
  429. package/src/components/inspector-controls-tabs/utils.js +28 -0
  430. package/src/components/line-height-control/test/index.js +5 -5
  431. package/src/components/link-control/README.md +1 -1
  432. package/src/components/link-control/index.js +1 -0
  433. package/src/components/link-control/search-input.js +0 -1
  434. package/src/components/link-control/test/index.js +188 -401
  435. package/src/components/link-control/use-internal-input-value.js +3 -3
  436. package/src/components/list-view/block.js +3 -0
  437. package/src/components/list-view/branch.js +10 -8
  438. package/src/components/list-view/style.scss +20 -9
  439. package/src/components/media-placeholder/{style.scss → content.scss} +0 -0
  440. package/src/components/media-replace-flow/test/index.js +37 -9
  441. package/src/components/media-upload/test/index.native.js +2 -0
  442. package/src/components/off-canvas-editor/appender.js +93 -0
  443. package/src/components/off-canvas-editor/block-edit-button.js +27 -0
  444. package/src/components/off-canvas-editor/block.js +88 -22
  445. package/src/components/off-canvas-editor/branch.js +3 -5
  446. package/src/components/off-canvas-editor/index.js +59 -33
  447. package/src/components/off-canvas-editor/leaf.js +5 -1
  448. package/src/components/off-canvas-editor/link-ui.js +166 -0
  449. package/src/components/off-canvas-editor/style.scss +17 -388
  450. package/src/components/off-canvas-editor/update-attributes.js +99 -0
  451. package/src/components/plain-text/{style.scss → content.scss} +0 -0
  452. package/src/components/recursion-provider/test/index.js +27 -29
  453. package/src/components/rich-text/content.scss +42 -0
  454. package/src/components/rich-text/format-toolbar/index.js +6 -4
  455. package/src/components/rich-text/index.js +2 -2
  456. package/src/components/rich-text/index.native.js +0 -2
  457. package/src/components/rich-text/style.scss +0 -43
  458. package/src/components/rich-text/use-insert-replacement-text.js +31 -0
  459. package/src/components/rich-text/use-undo-automatic-change.js +7 -1
  460. package/src/components/rich-text/utils.js +2 -21
  461. package/src/components/spacing-sizes-control/spacing-input-control.js +9 -0
  462. package/src/components/ungroup-button/index.native.js +6 -2
  463. package/src/components/url-input/index.js +57 -73
  464. package/src/components/url-popover/test/__snapshots__/index.js.snap +8 -6
  465. package/src/components/url-popover/test/index.js +21 -9
  466. package/src/components/use-block-display-information/index.js +14 -5
  467. package/src/components/use-setting/index.js +13 -1
  468. package/src/components/use-setting/test/index.js +99 -0
  469. package/src/content.scss +10 -0
  470. package/src/hooks/child-layout.js +190 -0
  471. package/src/hooks/content-lock-ui.js +1 -1
  472. package/src/hooks/dimensions.js +45 -7
  473. package/src/hooks/layout.js +60 -0
  474. package/src/hooks/min-height.js +2 -19
  475. package/src/store/reducer.js +459 -423
  476. package/src/store/selectors.js +56 -57
  477. package/src/store/test/performance.js +71 -0
  478. package/src/store/test/reducer.js +623 -491
  479. package/src/store/test/selectors.js +1820 -1306
  480. package/src/style.scss +4 -7
  481. package/src/utils/sorting.js +54 -0
  482. package/src/utils/test/sorting.js +49 -0
  483. package/tsconfig.tsbuildinfo +1 -1
  484. package/build/components/block-preview/live.js +0 -30
  485. package/build/components/block-preview/live.js.map +0 -1
  486. package/build-module/components/block-preview/live.js +0 -20
  487. package/build-module/components/block-preview/live.js.map +0 -1
  488. package/src/components/block-preview/live.js +0 -19
@@ -46,10 +46,12 @@ class URLInput extends Component {
46
46
  this.inputRef = createRef();
47
47
  this.updateSuggestions = debounce(this.updateSuggestions.bind(this), 200);
48
48
  this.suggestionNodes = [];
49
- this.isUpdatingSuggestions = false;
49
+ this.suggestionsRequest = null;
50
50
  this.state = {
51
51
  suggestions: [],
52
52
  showSuggestions: false,
53
+ isUpdatingSuggestions: false,
54
+ suggestionsValue: null,
53
55
  selectedSuggestion: null,
54
56
  suggestionsListboxId: '',
55
57
  suggestionOptionIdPrefix: ''
@@ -78,7 +80,7 @@ class URLInput extends Component {
78
80
  } // Update suggestions when the value changes.
79
81
 
80
82
 
81
- if (prevProps.value !== value && !this.props.disableSuggestions && !this.isUpdatingSuggestions) {
83
+ if (prevProps.value !== value && !this.props.disableSuggestions && !this.state.isUpdatingSuggestions) {
82
84
  if (value !== null && value !== void 0 && value.length) {
83
85
  // If the new value is not empty we need to update with suggestions for it.
84
86
  this.updateSuggestions(value);
@@ -99,7 +101,7 @@ class URLInput extends Component {
99
101
  var _this$suggestionsRequ, _this$suggestionsRequ2;
100
102
 
101
103
  (_this$suggestionsRequ = this.suggestionsRequest) === null || _this$suggestionsRequ === void 0 ? void 0 : (_this$suggestionsRequ2 = _this$suggestionsRequ.cancel) === null || _this$suggestionsRequ2 === void 0 ? void 0 : _this$suggestionsRequ2.call(_this$suggestionsRequ);
102
- delete this.suggestionsRequest;
104
+ this.suggestionsRequest = null;
103
105
  }
104
106
 
105
107
  bindSuggestionNode(index) {
@@ -109,14 +111,11 @@ class URLInput extends Component {
109
111
  }
110
112
 
111
113
  shouldShowInitialSuggestions() {
112
- const {
113
- suggestions
114
- } = this.state;
115
114
  const {
116
115
  __experimentalShowInitialSuggestions = false,
117
116
  value
118
117
  } = this.props;
119
- return !this.isUpdatingSuggestions && __experimentalShowInitialSuggestions && !(value && value.length) && !(suggestions && suggestions.length);
118
+ return __experimentalShowInitialSuggestions && !(value && value.length);
120
119
  }
121
120
 
122
121
  updateSuggestions() {
@@ -143,16 +142,22 @@ class URLInput extends Component {
143
142
  // - this is a direct entry (eg: a URL)
144
143
 
145
144
  if (!isInitialSuggestions && (value.length < 2 || !handleURLSuggestions && isURL(value))) {
145
+ var _this$suggestionsRequ3, _this$suggestionsRequ4;
146
+
147
+ (_this$suggestionsRequ3 = this.suggestionsRequest) === null || _this$suggestionsRequ3 === void 0 ? void 0 : (_this$suggestionsRequ4 = _this$suggestionsRequ3.cancel) === null || _this$suggestionsRequ4 === void 0 ? void 0 : _this$suggestionsRequ4.call(_this$suggestionsRequ3);
148
+ this.suggestionsRequest = null;
146
149
  this.setState({
150
+ suggestions: [],
147
151
  showSuggestions: false,
152
+ suggestionsValue: value,
148
153
  selectedSuggestion: null,
149
154
  loading: false
150
155
  });
151
156
  return;
152
157
  }
153
158
 
154
- this.isUpdatingSuggestions = true;
155
159
  this.setState({
160
+ isUpdatingSuggestions: true,
156
161
  selectedSuggestion: null,
157
162
  loading: true
158
163
  });
@@ -169,6 +174,8 @@ class URLInput extends Component {
169
174
 
170
175
  this.setState({
171
176
  suggestions,
177
+ isUpdatingSuggestions: false,
178
+ suggestionsValue: value,
172
179
  loading: false,
173
180
  showSuggestions: !!suggestions.length
174
181
  });
@@ -180,15 +187,15 @@ class URLInput extends Component {
180
187
  } else {
181
188
  this.props.debouncedSpeak(__('No results.'), 'assertive');
182
189
  }
183
-
184
- this.isUpdatingSuggestions = false;
185
190
  }).catch(() => {
186
- if (this.suggestionsRequest === request) {
187
- this.setState({
188
- loading: false
189
- });
190
- this.isUpdatingSuggestions = false;
191
+ if (this.suggestionsRequest !== request) {
192
+ return;
191
193
  }
194
+
195
+ this.setState({
196
+ isUpdatingSuggestions: false,
197
+ loading: false
198
+ });
192
199
  }); // Note that this assignment is handled *before* the async search request
193
200
  // as a Promise always resolves on the next tick of the event loop.
194
201
 
@@ -196,12 +203,7 @@ class URLInput extends Component {
196
203
  }
197
204
 
198
205
  onChange(event) {
199
- const inputValue = event.target.value;
200
- this.props.onChange(inputValue);
201
-
202
- if (!this.props.disableSuggestions) {
203
- this.updateSuggestions(inputValue);
204
- }
206
+ this.props.onChange(event.target.value);
205
207
  }
206
208
 
207
209
  onFocus() {
@@ -214,7 +216,7 @@ class URLInput extends Component {
214
216
  } = this.props; // When opening the link editor, if there's a value present, we want to load the suggestions pane with the results for this input search value
215
217
  // Don't re-run the suggestions on focus if there are already suggestions present (prevents searching again when tabbing between the input and buttons)
216
218
 
217
- if (value && !disableSuggestions && !this.isUpdatingSuggestions && !(suggestions && suggestions.length)) {
219
+ if (value && !disableSuggestions && !this.state.isUpdatingSuggestions && !(suggestions && suggestions.length)) {
218
220
  // Ensure the suggestions are updated with the current input value.
219
221
  this.updateSuggestions(value);
220
222
  }
@@ -433,18 +435,22 @@ class URLInput extends Component {
433
435
  renderSuggestions() {
434
436
  const {
435
437
  className,
436
- __experimentalRenderSuggestions: renderSuggestions,
437
- value = '',
438
- __experimentalShowInitialSuggestions = false
438
+ __experimentalRenderSuggestions: renderSuggestions
439
439
  } = this.props;
440
440
  const {
441
441
  showSuggestions,
442
442
  suggestions,
443
+ suggestionsValue,
443
444
  selectedSuggestion,
444
445
  suggestionsListboxId,
445
446
  suggestionOptionIdPrefix,
446
447
  loading
447
448
  } = this.state;
449
+
450
+ if (!showSuggestions || suggestions.length === 0) {
451
+ return null;
452
+ }
453
+
448
454
  const suggestionsListProps = {
449
455
  id: suggestionsListboxId,
450
456
  ref: this.autocompleteRef,
@@ -461,7 +467,7 @@ class URLInput extends Component {
461
467
  };
462
468
  };
463
469
 
464
- if (isFunction(renderSuggestions) && showSuggestions && !!suggestions.length) {
470
+ if (isFunction(renderSuggestions)) {
465
471
  return renderSuggestions({
466
472
  suggestions,
467
473
  selectedSuggestion,
@@ -469,26 +475,23 @@ class URLInput extends Component {
469
475
  buildSuggestionItemProps,
470
476
  isLoading: loading,
471
477
  handleSuggestionClick: this.handleOnClick,
472
- isInitialSuggestions: __experimentalShowInitialSuggestions && !(value && value.length)
478
+ isInitialSuggestions: !(suggestionsValue !== null && suggestionsValue !== void 0 && suggestionsValue.length),
479
+ currentInputValue: suggestionsValue
473
480
  });
474
481
  }
475
482
 
476
- if (!isFunction(renderSuggestions) && showSuggestions && !!suggestions.length) {
477
- return createElement(Popover, {
478
- placement: "bottom",
479
- focusOnMount: false
480
- }, createElement("div", _extends({}, suggestionsListProps, {
481
- className: classnames('block-editor-url-input__suggestions', `${className}__suggestions`)
482
- }), suggestions.map((suggestion, index) => createElement(Button, _extends({}, buildSuggestionItemProps(suggestion, index), {
483
- key: suggestion.id,
484
- className: classnames('block-editor-url-input__suggestion', {
485
- 'is-selected': index === selectedSuggestion
486
- }),
487
- onClick: () => this.handleOnClick(suggestion)
488
- }), suggestion.title))));
489
- }
490
-
491
- return null;
483
+ return createElement(Popover, {
484
+ placement: "bottom",
485
+ focusOnMount: false
486
+ }, createElement("div", _extends({}, suggestionsListProps, {
487
+ className: classnames('block-editor-url-input__suggestions', `${className}__suggestions`)
488
+ }), suggestions.map((suggestion, index) => createElement(Button, _extends({}, buildSuggestionItemProps(suggestion, index), {
489
+ key: suggestion.id,
490
+ className: classnames('block-editor-url-input__suggestion', {
491
+ 'is-selected': index === selectedSuggestion
492
+ }),
493
+ onClick: () => this.handleOnClick(suggestion)
494
+ }), suggestion.title))));
492
495
  }
493
496
 
494
497
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/url-input/index.js"],"names":["classnames","scrollIntoView","__","sprintf","_n","Component","createRef","UP","DOWN","ENTER","TAB","BaseControl","Button","Spinner","withSpokenMessages","Popover","compose","debounce","withInstanceId","withSafeTimeout","withSelect","isURL","store","blockEditorStore","isFunction","maybeFunc","URLInput","constructor","props","onChange","bind","onFocus","onKeyDown","selectLink","handleOnClick","bindSuggestionNode","autocompleteRef","inputRef","updateSuggestions","suggestionNodes","isUpdatingSuggestions","state","suggestions","showSuggestions","selectedSuggestion","suggestionsListboxId","suggestionOptionIdPrefix","componentDidUpdate","prevProps","value","__experimentalShowInitialSuggestions","scrollingIntoView","current","onlyScrollIfNeeded","setTimeout","disableSuggestions","length","componentDidMount","shouldShowInitialSuggestions","componentWillUnmount","suggestionsRequest","cancel","index","ref","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","__experimentalHandleURLSuggestions","handleURLSuggestions","isInitialSuggestions","trim","setState","loading","request","then","debouncedSpeak","catch","event","inputValue","target","keyCode","selectionStart","preventDefault","setSelectionRange","onSubmit","suggestion","previousIndex","nextIndex","speak","url","focus","getDerivedStateFromProps","instanceId","shouldShowSuggestions","hasValue","render","renderControl","renderSuggestions","label","className","isFullWidth","placeholder","__experimentalRenderControl","inputId","controlProps","id","inputProps","required","type","role","undefined","__experimentalRenderSuggestions","suggestionsListProps","buildSuggestionItemProps","tabIndex","isLoading","handleSuggestionClick","map","title","select","getSettings"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,OAAOC,cAAP,MAA2B,sBAA3B;AAEA;AAC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F,EAActB,KAAd,KAClB,cAAC,MAAD,eACMkD,wBAAwB,CAC5B5B,UAD4B,EAE5BtB,KAF4B,CAD9B;AAKC,QAAA,GAAG,EAAGsB,UAAU,CAACoB,EALlB;AAMC,QAAA,SAAS,EAAGxG,UAAU,CACrB,oCADqB,EAErB;AACC,yBACC8D,KAAK,KAAKlB;AAFZ,SAFqB,CANvB;AAaC,QAAA,OAAO,EAAG,MACT,KAAKV,aAAL,CAAoBkD,UAApB;AAdF,UAiBGA,UAAU,CAACiC,KAjBd,CADC,CAPH,CADD,CADD;AAiCA;;AACD,WAAO,IAAP;AACA;;AAxhB+B;AA2hBjC;AACA;AACA;;;AACA,eAAerG,OAAO,CACrBG,eADqB,EAErBL,kBAFqB,EAGrBI,cAHqB,EAIrBE,UAAU,CAAE,CAAEkG,MAAF,EAAU1F,KAAV,KAAqB;AAChC;AACA;AACA,MAAKJ,UAAU,CAAEI,KAAK,CAACoC,kCAAR,CAAf,EAA8D;AAC7D;AACA;;AACD,QAAM;AAAEuD,IAAAA;AAAF,MAAkBD,MAAM,CAAE/F,gBAAF,CAA9B;AACA,SAAO;AACNyC,IAAAA,kCAAkC,EACjCuD,WAAW,GAAGvD;AAFT,GAAP;AAIA,CAXS,CAJW,CAAP,CAgBZtC,QAhBY,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport scrollIntoView from 'dom-scroll-into-view';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf, _n } from '@wordpress/i18n';\nimport { Component, createRef } from '@wordpress/element';\nimport { UP, DOWN, ENTER, TAB } from '@wordpress/keycodes';\nimport {\n\tBaseControl,\n\tButton,\n\tSpinner,\n\twithSpokenMessages,\n\tPopover,\n} from '@wordpress/components';\nimport {\n\tcompose,\n\tdebounce,\n\twithInstanceId,\n\twithSafeTimeout,\n} from '@wordpress/compose';\nimport { withSelect } from '@wordpress/data';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Whether the argument is a function.\n *\n * @param {*} maybeFunc The argument to check.\n * @return {boolean} True if the argument is a function, false otherwise.\n */\nfunction isFunction( maybeFunc ) {\n\treturn typeof maybeFunc === 'function';\n}\n\nclass URLInput extends Component {\n\tconstructor( props ) {\n\t\tsuper( props );\n\n\t\tthis.onChange = this.onChange.bind( this );\n\t\tthis.onFocus = this.onFocus.bind( this );\n\t\tthis.onKeyDown = this.onKeyDown.bind( this );\n\t\tthis.selectLink = this.selectLink.bind( this );\n\t\tthis.handleOnClick = this.handleOnClick.bind( this );\n\t\tthis.bindSuggestionNode = this.bindSuggestionNode.bind( this );\n\t\tthis.autocompleteRef = props.autocompleteRef || createRef();\n\t\tthis.inputRef = createRef();\n\t\tthis.updateSuggestions = debounce(\n\t\t\tthis.updateSuggestions.bind( this ),\n\t\t\t200\n\t\t);\n\n\t\tthis.suggestionNodes = [];\n\n\t\tthis.isUpdatingSuggestions = false;\n\n\t\tthis.state = {\n\t\t\tsuggestions: [],\n\t\t\tshowSuggestions: false,\n\t\t\tselectedSuggestion: null,\n\n\t\t\tsuggestionsListboxId: '',\n\t\t\tsuggestionOptionIdPrefix: '',\n\t\t};\n\t}\n\n\tcomponentDidUpdate( prevProps ) {\n\t\tconst { showSuggestions, selectedSuggestion } = this.state;\n\t\tconst { value, __experimentalShowInitialSuggestions = false } =\n\t\t\tthis.props;\n\n\t\t// Only have to worry about scrolling selected suggestion into view\n\t\t// when already expanded.\n\t\tif (\n\t\t\tshowSuggestions &&\n\t\t\tselectedSuggestion !== null &&\n\t\t\tthis.suggestionNodes[ selectedSuggestion ] &&\n\t\t\t! this.scrollingIntoView\n\t\t) {\n\t\t\tthis.scrollingIntoView = true;\n\t\t\tscrollIntoView(\n\t\t\t\tthis.suggestionNodes[ selectedSuggestion ],\n\t\t\t\tthis.autocompleteRef.current,\n\t\t\t\t{\n\t\t\t\t\tonlyScrollIfNeeded: true,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tthis.props.setTimeout( () => {\n\t\t\t\tthis.scrollingIntoView = false;\n\t\t\t}, 100 );\n\t\t}\n\n\t\t// Update suggestions when the value changes.\n\t\tif (\n\t\t\tprevProps.value !== value &&\n\t\t\t! this.props.disableSuggestions &&\n\t\t\t! this.isUpdatingSuggestions\n\t\t) {\n\t\t\tif ( value?.length ) {\n\t\t\t\t// If the new value is not empty we need to update with suggestions for it.\n\t\t\t\tthis.updateSuggestions( value );\n\t\t\t} else if ( __experimentalShowInitialSuggestions ) {\n\t\t\t\t// If the new value is empty and we can show initial suggestions, then show initial suggestions.\n\t\t\t\tthis.updateSuggestions();\n\t\t\t}\n\t\t}\n\t}\n\n\tcomponentDidMount() {\n\t\tif ( this.shouldShowInitialSuggestions() ) {\n\t\t\tthis.updateSuggestions();\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\tthis.suggestionsRequest?.cancel?.();\n\t\tdelete this.suggestionsRequest;\n\t}\n\n\tbindSuggestionNode( index ) {\n\t\treturn ( ref ) => {\n\t\t\tthis.suggestionNodes[ index ] = ref;\n\t\t};\n\t}\n\n\tshouldShowInitialSuggestions() {\n\t\tconst { suggestions } = this.state;\n\t\tconst { __experimentalShowInitialSuggestions = false, value } =\n\t\t\tthis.props;\n\t\treturn (\n\t\t\t! this.isUpdatingSuggestions &&\n\t\t\t__experimentalShowInitialSuggestions &&\n\t\t\t! ( value && value.length ) &&\n\t\t\t! ( suggestions && suggestions.length )\n\t\t);\n\t}\n\n\tupdateSuggestions( value = '' ) {\n\t\tconst {\n\t\t\t__experimentalFetchLinkSuggestions: fetchLinkSuggestions,\n\t\t\t__experimentalHandleURLSuggestions: handleURLSuggestions,\n\t\t} = this.props;\n\n\t\tif ( ! fetchLinkSuggestions ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Initial suggestions may only show if there is no value\n\t\t// (note: this includes whitespace).\n\t\tconst isInitialSuggestions = ! value?.length;\n\n\t\t// Trim only now we've determined whether or not it originally had a \"length\"\n\t\t// (even if that value was all whitespace).\n\t\tvalue = value.trim();\n\n\t\t// Allow a suggestions request if:\n\t\t// - there are at least 2 characters in the search input (except manual searches where\n\t\t// search input length is not required to trigger a fetch)\n\t\t// - this is a direct entry (eg: a URL)\n\t\tif (\n\t\t\t! isInitialSuggestions &&\n\t\t\t( value.length < 2 || ( ! handleURLSuggestions && isURL( value ) ) )\n\t\t) {\n\t\t\tthis.setState( {\n\t\t\t\tshowSuggestions: false,\n\t\t\t\tselectedSuggestion: null,\n\t\t\t\tloading: false,\n\t\t\t} );\n\n\t\t\treturn;\n\t\t}\n\n\t\tthis.isUpdatingSuggestions = true;\n\n\t\tthis.setState( {\n\t\t\tselectedSuggestion: null,\n\t\t\tloading: true,\n\t\t} );\n\n\t\tconst request = fetchLinkSuggestions( value, {\n\t\t\tisInitialSuggestions,\n\t\t} );\n\n\t\trequest\n\t\t\t.then( ( suggestions ) => {\n\t\t\t\t// A fetch Promise doesn't have an abort option. It's mimicked by\n\t\t\t\t// comparing the request reference in on the instance, which is\n\t\t\t\t// reset or deleted on subsequent requests or unmounting.\n\t\t\t\tif ( this.suggestionsRequest !== request ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.setState( {\n\t\t\t\t\tsuggestions,\n\t\t\t\t\tloading: false,\n\t\t\t\t\tshowSuggestions: !! suggestions.length,\n\t\t\t\t} );\n\n\t\t\t\tif ( !! suggestions.length ) {\n\t\t\t\t\tthis.props.debouncedSpeak(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %s: number of results. */\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'%d result found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\t'%d results found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\tsuggestions.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tsuggestions.length\n\t\t\t\t\t\t),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthis.props.debouncedSpeak(\n\t\t\t\t\t\t__( 'No results.' ),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthis.isUpdatingSuggestions = false;\n\t\t\t} )\n\t\t\t.catch( () => {\n\t\t\t\tif ( this.suggestionsRequest === request ) {\n\t\t\t\t\tthis.setState( {\n\t\t\t\t\t\tloading: false,\n\t\t\t\t\t} );\n\t\t\t\t\tthis.isUpdatingSuggestions = false;\n\t\t\t\t}\n\t\t\t} );\n\n\t\t// Note that this assignment is handled *before* the async search request\n\t\t// as a Promise always resolves on the next tick of the event loop.\n\t\tthis.suggestionsRequest = request;\n\t}\n\n\tonChange( event ) {\n\t\tconst inputValue = event.target.value;\n\n\t\tthis.props.onChange( inputValue );\n\t\tif ( ! this.props.disableSuggestions ) {\n\t\t\tthis.updateSuggestions( inputValue );\n\t\t}\n\t}\n\n\tonFocus() {\n\t\tconst { suggestions } = this.state;\n\t\tconst { disableSuggestions, value } = this.props;\n\n\t\t// When opening the link editor, if there's a value present, we want to load the suggestions pane with the results for this input search value\n\t\t// Don't re-run the suggestions on focus if there are already suggestions present (prevents searching again when tabbing between the input and buttons)\n\t\tif (\n\t\t\tvalue &&\n\t\t\t! disableSuggestions &&\n\t\t\t! this.isUpdatingSuggestions &&\n\t\t\t! ( suggestions && suggestions.length )\n\t\t) {\n\t\t\t// Ensure the suggestions are updated with the current input value.\n\t\t\tthis.updateSuggestions( value );\n\t\t}\n\t}\n\n\tonKeyDown( event ) {\n\t\tconst { showSuggestions, selectedSuggestion, suggestions, loading } =\n\t\t\tthis.state;\n\n\t\t// If the suggestions are not shown or loading, we shouldn't handle the arrow keys\n\t\t// We shouldn't preventDefault to allow block arrow keys navigation.\n\t\tif ( ! showSuggestions || ! suggestions.length || loading ) {\n\t\t\t// In the Windows version of Firefox the up and down arrows don't move the caret\n\t\t\t// within an input field like they do for Mac Firefox/Chrome/Safari. This causes\n\t\t\t// a form of focus trapping that is disruptive to the user experience. This disruption\n\t\t\t// only happens if the caret is not in the first or last position in the text input.\n\t\t\t// See: https://github.com/WordPress/gutenberg/issues/5693#issuecomment-436684747\n\t\t\tswitch ( event.keyCode ) {\n\t\t\t\t// When UP is pressed, if the caret is at the start of the text, move it to the 0\n\t\t\t\t// position.\n\t\t\t\tcase UP: {\n\t\t\t\t\tif ( 0 !== event.target.selectionStart ) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\t// Set the input caret to position 0.\n\t\t\t\t\t\tevent.target.setSelectionRange( 0, 0 );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t// When DOWN is pressed, if the caret is not at the end of the text, move it to the\n\t\t\t\t// last position.\n\t\t\t\tcase DOWN: {\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.props.value.length !== event.target.selectionStart\n\t\t\t\t\t) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\t// Set the input caret to the last position.\n\t\t\t\t\t\tevent.target.setSelectionRange(\n\t\t\t\t\t\t\tthis.props.value.length,\n\t\t\t\t\t\t\tthis.props.value.length\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t// Submitting while loading should trigger onSubmit.\n\t\t\t\tcase ENTER: {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tif ( this.props.onSubmit ) {\n\t\t\t\t\t\tthis.props.onSubmit( null, event );\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst suggestion =\n\t\t\tthis.state.suggestions[ this.state.selectedSuggestion ];\n\n\t\tswitch ( event.keyCode ) {\n\t\t\tcase UP: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst previousIndex = ! selectedSuggestion\n\t\t\t\t\t? suggestions.length - 1\n\t\t\t\t\t: selectedSuggestion - 1;\n\t\t\t\tthis.setState( {\n\t\t\t\t\tselectedSuggestion: previousIndex,\n\t\t\t\t} );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase DOWN: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst nextIndex =\n\t\t\t\t\tselectedSuggestion === null ||\n\t\t\t\t\tselectedSuggestion === suggestions.length - 1\n\t\t\t\t\t\t? 0\n\t\t\t\t\t\t: selectedSuggestion + 1;\n\t\t\t\tthis.setState( {\n\t\t\t\t\tselectedSuggestion: nextIndex,\n\t\t\t\t} );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase TAB: {\n\t\t\t\tif ( this.state.selectedSuggestion !== null ) {\n\t\t\t\t\tthis.selectLink( suggestion );\n\t\t\t\t\t// Announce a link has been selected when tabbing away from the input field.\n\t\t\t\t\tthis.props.speak( __( 'Link selected.' ) );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ENTER: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( this.state.selectedSuggestion !== null ) {\n\t\t\t\t\tthis.selectLink( suggestion );\n\n\t\t\t\t\tif ( this.props.onSubmit ) {\n\t\t\t\t\t\tthis.props.onSubmit( suggestion, event );\n\t\t\t\t\t}\n\t\t\t\t} else if ( this.props.onSubmit ) {\n\t\t\t\t\tthis.props.onSubmit( null, event );\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tselectLink( suggestion ) {\n\t\tthis.props.onChange( suggestion.url, suggestion );\n\t\tthis.setState( {\n\t\t\tselectedSuggestion: null,\n\t\t\tshowSuggestions: false,\n\t\t} );\n\t}\n\n\thandleOnClick( suggestion ) {\n\t\tthis.selectLink( suggestion );\n\t\t// Move focus to the input field when a link suggestion is clicked.\n\t\tthis.inputRef.current.focus();\n\t}\n\n\tstatic getDerivedStateFromProps(\n\t\t{\n\t\t\tvalue,\n\t\t\tinstanceId,\n\t\t\tdisableSuggestions,\n\t\t\t__experimentalShowInitialSuggestions = false,\n\t\t},\n\t\t{ showSuggestions }\n\t) {\n\t\tlet shouldShowSuggestions = showSuggestions;\n\n\t\tconst hasValue = value && value.length;\n\n\t\tif ( ! __experimentalShowInitialSuggestions && ! hasValue ) {\n\t\t\tshouldShowSuggestions = false;\n\t\t}\n\n\t\tif ( disableSuggestions === true ) {\n\t\t\tshouldShowSuggestions = false;\n\t\t}\n\n\t\treturn {\n\t\t\tshowSuggestions: shouldShowSuggestions,\n\t\t\tsuggestionsListboxId: `block-editor-url-input-suggestions-${ instanceId }`,\n\t\t\tsuggestionOptionIdPrefix: `block-editor-url-input-suggestion-${ instanceId }`,\n\t\t};\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ this.renderControl() }\n\t\t\t\t{ this.renderSuggestions() }\n\t\t\t</>\n\t\t);\n\t}\n\n\trenderControl() {\n\t\tconst {\n\t\t\tlabel = null,\n\t\t\tclassName,\n\t\t\tisFullWidth,\n\t\t\tinstanceId,\n\t\t\tplaceholder = __( 'Paste URL or type to search' ),\n\t\t\t__experimentalRenderControl: renderControl,\n\t\t\tvalue = '',\n\t\t} = this.props;\n\n\t\tconst {\n\t\t\tloading,\n\t\t\tshowSuggestions,\n\t\t\tselectedSuggestion,\n\t\t\tsuggestionsListboxId,\n\t\t\tsuggestionOptionIdPrefix,\n\t\t} = this.state;\n\n\t\tconst inputId = `url-input-control-${ instanceId }`;\n\n\t\tconst controlProps = {\n\t\t\tid: inputId, // Passes attribute to label for the for attribute\n\t\t\tlabel,\n\t\t\tclassName: classnames( 'block-editor-url-input', className, {\n\t\t\t\t'is-full-width': isFullWidth,\n\t\t\t} ),\n\t\t};\n\n\t\tconst inputProps = {\n\t\t\tid: inputId,\n\t\t\tvalue,\n\t\t\trequired: true,\n\t\t\tclassName: 'block-editor-url-input__input',\n\t\t\ttype: 'text',\n\t\t\tonChange: this.onChange,\n\t\t\tonFocus: this.onFocus,\n\t\t\tplaceholder,\n\t\t\tonKeyDown: this.onKeyDown,\n\t\t\trole: 'combobox',\n\t\t\t'aria-label': label ? undefined : __( 'URL' ), // Ensure input always has an accessible label\n\t\t\t'aria-expanded': showSuggestions,\n\t\t\t'aria-autocomplete': 'list',\n\t\t\t'aria-controls': suggestionsListboxId,\n\t\t\t'aria-activedescendant':\n\t\t\t\tselectedSuggestion !== null\n\t\t\t\t\t? `${ suggestionOptionIdPrefix }-${ selectedSuggestion }`\n\t\t\t\t\t: undefined,\n\t\t\tref: this.inputRef,\n\t\t};\n\n\t\tif ( renderControl ) {\n\t\t\treturn renderControl( controlProps, inputProps, loading );\n\t\t}\n\n\t\treturn (\n\t\t\t<BaseControl { ...controlProps }>\n\t\t\t\t<input { ...inputProps } />\n\t\t\t\t{ loading && <Spinner /> }\n\t\t\t</BaseControl>\n\t\t);\n\t}\n\n\trenderSuggestions() {\n\t\tconst {\n\t\t\tclassName,\n\t\t\t__experimentalRenderSuggestions: renderSuggestions,\n\t\t\tvalue = '',\n\t\t\t__experimentalShowInitialSuggestions = false,\n\t\t} = this.props;\n\n\t\tconst {\n\t\t\tshowSuggestions,\n\t\t\tsuggestions,\n\t\t\tselectedSuggestion,\n\t\t\tsuggestionsListboxId,\n\t\t\tsuggestionOptionIdPrefix,\n\t\t\tloading,\n\t\t} = this.state;\n\n\t\tconst suggestionsListProps = {\n\t\t\tid: suggestionsListboxId,\n\t\t\tref: this.autocompleteRef,\n\t\t\trole: 'listbox',\n\t\t};\n\n\t\tconst buildSuggestionItemProps = ( suggestion, index ) => {\n\t\t\treturn {\n\t\t\t\trole: 'option',\n\t\t\t\ttabIndex: '-1',\n\t\t\t\tid: `${ suggestionOptionIdPrefix }-${ index }`,\n\t\t\t\tref: this.bindSuggestionNode( index ),\n\t\t\t\t'aria-selected': index === selectedSuggestion,\n\t\t\t};\n\t\t};\n\n\t\tif (\n\t\t\tisFunction( renderSuggestions ) &&\n\t\t\tshowSuggestions &&\n\t\t\t!! suggestions.length\n\t\t) {\n\t\t\treturn renderSuggestions( {\n\t\t\t\tsuggestions,\n\t\t\t\tselectedSuggestion,\n\t\t\t\tsuggestionsListProps,\n\t\t\t\tbuildSuggestionItemProps,\n\t\t\t\tisLoading: loading,\n\t\t\t\thandleSuggestionClick: this.handleOnClick,\n\t\t\t\tisInitialSuggestions:\n\t\t\t\t\t__experimentalShowInitialSuggestions &&\n\t\t\t\t\t! ( value && value.length ),\n\t\t\t} );\n\t\t}\n\n\t\tif (\n\t\t\t! isFunction( renderSuggestions ) &&\n\t\t\tshowSuggestions &&\n\t\t\t!! suggestions.length\n\t\t) {\n\t\t\treturn (\n\t\t\t\t<Popover placement=\"bottom\" focusOnMount={ false }>\n\t\t\t\t\t<div\n\t\t\t\t\t\t{ ...suggestionsListProps }\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-url-input__suggestions',\n\t\t\t\t\t\t\t`${ className }__suggestions`\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ suggestions.map( ( suggestion, index ) => (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t{ ...buildSuggestionItemProps(\n\t\t\t\t\t\t\t\t\tsuggestion,\n\t\t\t\t\t\t\t\t\tindex\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tkey={ suggestion.id }\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t'block-editor-url-input__suggestion',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t'is-selected':\n\t\t\t\t\t\t\t\t\t\t\tindex === selectedSuggestion,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\tthis.handleOnClick( suggestion )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ suggestion.title }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</div>\n\t\t\t\t</Popover>\n\t\t\t);\n\t\t}\n\t\treturn null;\n\t}\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-input/README.md\n */\nexport default compose(\n\twithSafeTimeout,\n\twithSpokenMessages,\n\twithInstanceId,\n\twithSelect( ( select, props ) => {\n\t\t// If a link suggestions handler is already provided then\n\t\t// bail.\n\t\tif ( isFunction( props.__experimentalFetchLinkSuggestions ) ) {\n\t\t\treturn;\n\t\t}\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\t__experimentalFetchLinkSuggestions:\n\t\t\t\tgetSettings().__experimentalFetchLinkSuggestions,\n\t\t};\n\t} )\n)( URLInput );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/url-input/index.js"],"names":["classnames","scrollIntoView","__","sprintf","_n","Component","createRef","UP","DOWN","ENTER","TAB","BaseControl","Button","Spinner","withSpokenMessages","Popover","compose","debounce","withInstanceId","withSafeTimeout","withSelect","isURL","store","blockEditorStore","isFunction","maybeFunc","URLInput","constructor","props","onChange","bind","onFocus","onKeyDown","selectLink","handleOnClick","bindSuggestionNode","autocompleteRef","inputRef","updateSuggestions","suggestionNodes","suggestionsRequest","state","suggestions","showSuggestions","isUpdatingSuggestions","suggestionsValue","selectedSuggestion","suggestionsListboxId","suggestionOptionIdPrefix","componentDidUpdate","prevProps","value","__experimentalShowInitialSuggestions","scrollingIntoView","current","onlyScrollIfNeeded","setTimeout","disableSuggestions","length","componentDidMount","shouldShowInitialSuggestions","componentWillUnmount","cancel","index","ref","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","__experimentalHandleURLSuggestions","handleURLSuggestions","isInitialSuggestions","trim","setState","loading","request","then","debouncedSpeak","catch","event","target","keyCode","selectionStart","preventDefault","setSelectionRange","onSubmit","suggestion","previousIndex","nextIndex","speak","url","focus","getDerivedStateFromProps","instanceId","shouldShowSuggestions","hasValue","render","renderControl","renderSuggestions","label","className","isFullWidth","placeholder","__experimentalRenderControl","inputId","controlProps","id","inputProps","required","type","role","undefined","__experimentalRenderSuggestions","suggestionsListProps","buildSuggestionItemProps","tabIndex","isLoading","handleSuggestionClick","currentInputValue","map","title","select","getSettings"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,OAAOC,cAAP,MAA2B,sBAA3B;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,OAAb,EAAsBC,EAAtB,QAAgC,iBAAhC;AACA,SAASC,SAAT,EAAoBC,SAApB,QAAqC,oBAArC;AACA,SAASC,EAAT,EAAaC,IAAb,EAAmBC,KAAnB,EAA0BC,GAA1B,QAAqC,qBAArC;AACA,SACCC,WADD,EAECC,MAFD,EAGCC,OAHD,EAICC,kBAJD,EAKCC,OALD,QAMO,uBANP;AAOA,SACCC,OADD,EAECC,QAFD,EAGCC,cAHD,EAICC,eAJD,QAKO,oBALP;AAMA,SAASC,UAAT,QAA2B,iBAA3B;AACA,SAASC,KAAT,QAAsB,gBAAtB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,UAAT,CAAqBC,SAArB,EAAiC;AAChC,SAAO,OAAOA,SAAP,KAAqB,UAA5B;AACA;;AAED,MAAMC,QAAN,SAAuBrB,SAAvB,CAAiC;AAChCsB,EAAAA,WAAW,CAAEC,KAAF,EAAU;AACpB,UAAOA,KAAP;AAEA,SAAKC,QAAL,GAAgB,KAAKA,QAAL,CAAcC,IAAd,CAAoB,IAApB,CAAhB;AACA,SAAKC,OAAL,GAAe,KAAKA,OAAL,CAAaD,IAAb,CAAmB,IAAnB,CAAf;AACA,SAAKE,SAAL,GAAiB,KAAKA,SAAL,CAAeF,IAAf,CAAqB,IAArB,CAAjB;AACA,SAAKG,UAAL,GAAkB,KAAKA,UAAL,CAAgBH,IAAhB,CAAsB,IAAtB,CAAlB;AACA,SA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AxB;AAUA;;AAED,WACC,cAAC,OAAD;AAAS,MAAA,SAAS,EAAC,QAAnB;AAA4B,MAAA,YAAY,EAAG;AAA3C,OACC,kCACMkE,oBADN;AAEC,MAAA,SAAS,EAAG/G,UAAU,CACrB,qCADqB,EAEpB,GAAGkG,SAAW,eAFM;AAFvB,QAOGxD,WAAW,CAAC2E,GAAZ,CAAiB,CAAEjC,UAAF,EAAcrB,KAAd,KAClB,cAAC,MAAD,eACMiD,wBAAwB,CAAE5B,UAAF,EAAcrB,KAAd,CAD9B;AAEC,MAAA,GAAG,EAAGqB,UAAU,CAACoB,EAFlB;AAGC,MAAA,SAAS,EAAGxG,UAAU,CACrB,oCADqB,EAErB;AACC,uBAAe+D,KAAK,KAAKjB;AAD1B,OAFqB,CAHvB;AASC,MAAA,OAAO,EAAG,MAAM,KAAKZ,aAAL,CAAoBkD,UAApB;AATjB,QAWGA,UAAU,CAACkC,KAXd,CADC,CAPH,CADD,CADD;AA2BA;;AAxgB+B;AA2gBjC;AACA;AACA;;;AACA,eAAetG,OAAO,CACrBG,eADqB,EAErBL,kBAFqB,EAGrBI,cAHqB,EAIrBE,UAAU,CAAE,CAAEmG,MAAF,EAAU3F,KAAV,KAAqB;AAChC;AACA;AACA,MAAKJ,UAAU,CAAEI,KAAK,CAACqC,kCAAR,CAAf,EAA8D;AAC7D;AACA;;AACD,QAAM;AAAEuD,IAAAA;AAAF,MAAkBD,MAAM,CAAEhG,gBAAF,CAA9B;AACA,SAAO;AACN0C,IAAAA,kCAAkC,EACjCuD,WAAW,GAAGvD;AAFT,GAAP;AAIA,CAXS,CAJW,CAAP,CAgBZvC,QAhBY,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport scrollIntoView from 'dom-scroll-into-view';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf, _n } from '@wordpress/i18n';\nimport { Component, createRef } from '@wordpress/element';\nimport { UP, DOWN, ENTER, TAB } from '@wordpress/keycodes';\nimport {\n\tBaseControl,\n\tButton,\n\tSpinner,\n\twithSpokenMessages,\n\tPopover,\n} from '@wordpress/components';\nimport {\n\tcompose,\n\tdebounce,\n\twithInstanceId,\n\twithSafeTimeout,\n} from '@wordpress/compose';\nimport { withSelect } from '@wordpress/data';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Whether the argument is a function.\n *\n * @param {*} maybeFunc The argument to check.\n * @return {boolean} True if the argument is a function, false otherwise.\n */\nfunction isFunction( maybeFunc ) {\n\treturn typeof maybeFunc === 'function';\n}\n\nclass URLInput extends Component {\n\tconstructor( props ) {\n\t\tsuper( props );\n\n\t\tthis.onChange = this.onChange.bind( this );\n\t\tthis.onFocus = this.onFocus.bind( this );\n\t\tthis.onKeyDown = this.onKeyDown.bind( this );\n\t\tthis.selectLink = this.selectLink.bind( this );\n\t\tthis.handleOnClick = this.handleOnClick.bind( this );\n\t\tthis.bindSuggestionNode = this.bindSuggestionNode.bind( this );\n\t\tthis.autocompleteRef = props.autocompleteRef || createRef();\n\t\tthis.inputRef = createRef();\n\t\tthis.updateSuggestions = debounce(\n\t\t\tthis.updateSuggestions.bind( this ),\n\t\t\t200\n\t\t);\n\n\t\tthis.suggestionNodes = [];\n\n\t\tthis.suggestionsRequest = null;\n\n\t\tthis.state = {\n\t\t\tsuggestions: [],\n\t\t\tshowSuggestions: false,\n\t\t\tisUpdatingSuggestions: false,\n\t\t\tsuggestionsValue: null,\n\t\t\tselectedSuggestion: null,\n\t\t\tsuggestionsListboxId: '',\n\t\t\tsuggestionOptionIdPrefix: '',\n\t\t};\n\t}\n\n\tcomponentDidUpdate( prevProps ) {\n\t\tconst { showSuggestions, selectedSuggestion } = this.state;\n\t\tconst { value, __experimentalShowInitialSuggestions = false } =\n\t\t\tthis.props;\n\n\t\t// Only have to worry about scrolling selected suggestion into view\n\t\t// when already expanded.\n\t\tif (\n\t\t\tshowSuggestions &&\n\t\t\tselectedSuggestion !== null &&\n\t\t\tthis.suggestionNodes[ selectedSuggestion ] &&\n\t\t\t! this.scrollingIntoView\n\t\t) {\n\t\t\tthis.scrollingIntoView = true;\n\t\t\tscrollIntoView(\n\t\t\t\tthis.suggestionNodes[ selectedSuggestion ],\n\t\t\t\tthis.autocompleteRef.current,\n\t\t\t\t{\n\t\t\t\t\tonlyScrollIfNeeded: true,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tthis.props.setTimeout( () => {\n\t\t\t\tthis.scrollingIntoView = false;\n\t\t\t}, 100 );\n\t\t}\n\n\t\t// Update suggestions when the value changes.\n\t\tif (\n\t\t\tprevProps.value !== value &&\n\t\t\t! this.props.disableSuggestions &&\n\t\t\t! this.state.isUpdatingSuggestions\n\t\t) {\n\t\t\tif ( value?.length ) {\n\t\t\t\t// If the new value is not empty we need to update with suggestions for it.\n\t\t\t\tthis.updateSuggestions( value );\n\t\t\t} else if ( __experimentalShowInitialSuggestions ) {\n\t\t\t\t// If the new value is empty and we can show initial suggestions, then show initial suggestions.\n\t\t\t\tthis.updateSuggestions();\n\t\t\t}\n\t\t}\n\t}\n\n\tcomponentDidMount() {\n\t\tif ( this.shouldShowInitialSuggestions() ) {\n\t\t\tthis.updateSuggestions();\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\tthis.suggestionsRequest?.cancel?.();\n\t\tthis.suggestionsRequest = null;\n\t}\n\n\tbindSuggestionNode( index ) {\n\t\treturn ( ref ) => {\n\t\t\tthis.suggestionNodes[ index ] = ref;\n\t\t};\n\t}\n\n\tshouldShowInitialSuggestions() {\n\t\tconst { __experimentalShowInitialSuggestions = false, value } =\n\t\t\tthis.props;\n\t\treturn (\n\t\t\t__experimentalShowInitialSuggestions && ! ( value && value.length )\n\t\t);\n\t}\n\n\tupdateSuggestions( value = '' ) {\n\t\tconst {\n\t\t\t__experimentalFetchLinkSuggestions: fetchLinkSuggestions,\n\t\t\t__experimentalHandleURLSuggestions: handleURLSuggestions,\n\t\t} = this.props;\n\n\t\tif ( ! fetchLinkSuggestions ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Initial suggestions may only show if there is no value\n\t\t// (note: this includes whitespace).\n\t\tconst isInitialSuggestions = ! value?.length;\n\n\t\t// Trim only now we've determined whether or not it originally had a \"length\"\n\t\t// (even if that value was all whitespace).\n\t\tvalue = value.trim();\n\n\t\t// Allow a suggestions request if:\n\t\t// - there are at least 2 characters in the search input (except manual searches where\n\t\t// search input length is not required to trigger a fetch)\n\t\t// - this is a direct entry (eg: a URL)\n\t\tif (\n\t\t\t! isInitialSuggestions &&\n\t\t\t( value.length < 2 || ( ! handleURLSuggestions && isURL( value ) ) )\n\t\t) {\n\t\t\tthis.suggestionsRequest?.cancel?.();\n\t\t\tthis.suggestionsRequest = null;\n\n\t\t\tthis.setState( {\n\t\t\t\tsuggestions: [],\n\t\t\t\tshowSuggestions: false,\n\t\t\t\tsuggestionsValue: value,\n\t\t\t\tselectedSuggestion: null,\n\t\t\t\tloading: false,\n\t\t\t} );\n\n\t\t\treturn;\n\t\t}\n\n\t\tthis.setState( {\n\t\t\tisUpdatingSuggestions: true,\n\t\t\tselectedSuggestion: null,\n\t\t\tloading: true,\n\t\t} );\n\n\t\tconst request = fetchLinkSuggestions( value, {\n\t\t\tisInitialSuggestions,\n\t\t} );\n\n\t\trequest\n\t\t\t.then( ( suggestions ) => {\n\t\t\t\t// A fetch Promise doesn't have an abort option. It's mimicked by\n\t\t\t\t// comparing the request reference in on the instance, which is\n\t\t\t\t// reset or deleted on subsequent requests or unmounting.\n\t\t\t\tif ( this.suggestionsRequest !== request ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.setState( {\n\t\t\t\t\tsuggestions,\n\t\t\t\t\tisUpdatingSuggestions: false,\n\t\t\t\t\tsuggestionsValue: value,\n\t\t\t\t\tloading: false,\n\t\t\t\t\tshowSuggestions: !! suggestions.length,\n\t\t\t\t} );\n\n\t\t\t\tif ( !! suggestions.length ) {\n\t\t\t\t\tthis.props.debouncedSpeak(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %s: number of results. */\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'%d result found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\t'%d results found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\tsuggestions.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tsuggestions.length\n\t\t\t\t\t\t),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthis.props.debouncedSpeak(\n\t\t\t\t\t\t__( 'No results.' ),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.catch( () => {\n\t\t\t\tif ( this.suggestionsRequest !== request ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.setState( {\n\t\t\t\t\tisUpdatingSuggestions: false,\n\t\t\t\t\tloading: false,\n\t\t\t\t} );\n\t\t\t} );\n\n\t\t// Note that this assignment is handled *before* the async search request\n\t\t// as a Promise always resolves on the next tick of the event loop.\n\t\tthis.suggestionsRequest = request;\n\t}\n\n\tonChange( event ) {\n\t\tthis.props.onChange( event.target.value );\n\t}\n\n\tonFocus() {\n\t\tconst { suggestions } = this.state;\n\t\tconst { disableSuggestions, value } = this.props;\n\n\t\t// When opening the link editor, if there's a value present, we want to load the suggestions pane with the results for this input search value\n\t\t// Don't re-run the suggestions on focus if there are already suggestions present (prevents searching again when tabbing between the input and buttons)\n\t\tif (\n\t\t\tvalue &&\n\t\t\t! disableSuggestions &&\n\t\t\t! this.state.isUpdatingSuggestions &&\n\t\t\t! ( suggestions && suggestions.length )\n\t\t) {\n\t\t\t// Ensure the suggestions are updated with the current input value.\n\t\t\tthis.updateSuggestions( value );\n\t\t}\n\t}\n\n\tonKeyDown( event ) {\n\t\tconst { showSuggestions, selectedSuggestion, suggestions, loading } =\n\t\t\tthis.state;\n\n\t\t// If the suggestions are not shown or loading, we shouldn't handle the arrow keys\n\t\t// We shouldn't preventDefault to allow block arrow keys navigation.\n\t\tif ( ! showSuggestions || ! suggestions.length || loading ) {\n\t\t\t// In the Windows version of Firefox the up and down arrows don't move the caret\n\t\t\t// within an input field like they do for Mac Firefox/Chrome/Safari. This causes\n\t\t\t// a form of focus trapping that is disruptive to the user experience. This disruption\n\t\t\t// only happens if the caret is not in the first or last position in the text input.\n\t\t\t// See: https://github.com/WordPress/gutenberg/issues/5693#issuecomment-436684747\n\t\t\tswitch ( event.keyCode ) {\n\t\t\t\t// When UP is pressed, if the caret is at the start of the text, move it to the 0\n\t\t\t\t// position.\n\t\t\t\tcase UP: {\n\t\t\t\t\tif ( 0 !== event.target.selectionStart ) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\t// Set the input caret to position 0.\n\t\t\t\t\t\tevent.target.setSelectionRange( 0, 0 );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t// When DOWN is pressed, if the caret is not at the end of the text, move it to the\n\t\t\t\t// last position.\n\t\t\t\tcase DOWN: {\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.props.value.length !== event.target.selectionStart\n\t\t\t\t\t) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\t// Set the input caret to the last position.\n\t\t\t\t\t\tevent.target.setSelectionRange(\n\t\t\t\t\t\t\tthis.props.value.length,\n\t\t\t\t\t\t\tthis.props.value.length\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t// Submitting while loading should trigger onSubmit.\n\t\t\t\tcase ENTER: {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tif ( this.props.onSubmit ) {\n\t\t\t\t\t\tthis.props.onSubmit( null, event );\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst suggestion =\n\t\t\tthis.state.suggestions[ this.state.selectedSuggestion ];\n\n\t\tswitch ( event.keyCode ) {\n\t\t\tcase UP: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst previousIndex = ! selectedSuggestion\n\t\t\t\t\t? suggestions.length - 1\n\t\t\t\t\t: selectedSuggestion - 1;\n\t\t\t\tthis.setState( {\n\t\t\t\t\tselectedSuggestion: previousIndex,\n\t\t\t\t} );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase DOWN: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst nextIndex =\n\t\t\t\t\tselectedSuggestion === null ||\n\t\t\t\t\tselectedSuggestion === suggestions.length - 1\n\t\t\t\t\t\t? 0\n\t\t\t\t\t\t: selectedSuggestion + 1;\n\t\t\t\tthis.setState( {\n\t\t\t\t\tselectedSuggestion: nextIndex,\n\t\t\t\t} );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase TAB: {\n\t\t\t\tif ( this.state.selectedSuggestion !== null ) {\n\t\t\t\t\tthis.selectLink( suggestion );\n\t\t\t\t\t// Announce a link has been selected when tabbing away from the input field.\n\t\t\t\t\tthis.props.speak( __( 'Link selected.' ) );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ENTER: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( this.state.selectedSuggestion !== null ) {\n\t\t\t\t\tthis.selectLink( suggestion );\n\n\t\t\t\t\tif ( this.props.onSubmit ) {\n\t\t\t\t\t\tthis.props.onSubmit( suggestion, event );\n\t\t\t\t\t}\n\t\t\t\t} else if ( this.props.onSubmit ) {\n\t\t\t\t\tthis.props.onSubmit( null, event );\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tselectLink( suggestion ) {\n\t\tthis.props.onChange( suggestion.url, suggestion );\n\t\tthis.setState( {\n\t\t\tselectedSuggestion: null,\n\t\t\tshowSuggestions: false,\n\t\t} );\n\t}\n\n\thandleOnClick( suggestion ) {\n\t\tthis.selectLink( suggestion );\n\t\t// Move focus to the input field when a link suggestion is clicked.\n\t\tthis.inputRef.current.focus();\n\t}\n\n\tstatic getDerivedStateFromProps(\n\t\t{\n\t\t\tvalue,\n\t\t\tinstanceId,\n\t\t\tdisableSuggestions,\n\t\t\t__experimentalShowInitialSuggestions = false,\n\t\t},\n\t\t{ showSuggestions }\n\t) {\n\t\tlet shouldShowSuggestions = showSuggestions;\n\n\t\tconst hasValue = value && value.length;\n\n\t\tif ( ! __experimentalShowInitialSuggestions && ! hasValue ) {\n\t\t\tshouldShowSuggestions = false;\n\t\t}\n\n\t\tif ( disableSuggestions === true ) {\n\t\t\tshouldShowSuggestions = false;\n\t\t}\n\n\t\treturn {\n\t\t\tshowSuggestions: shouldShowSuggestions,\n\t\t\tsuggestionsListboxId: `block-editor-url-input-suggestions-${ instanceId }`,\n\t\t\tsuggestionOptionIdPrefix: `block-editor-url-input-suggestion-${ instanceId }`,\n\t\t};\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ this.renderControl() }\n\t\t\t\t{ this.renderSuggestions() }\n\t\t\t</>\n\t\t);\n\t}\n\n\trenderControl() {\n\t\tconst {\n\t\t\tlabel = null,\n\t\t\tclassName,\n\t\t\tisFullWidth,\n\t\t\tinstanceId,\n\t\t\tplaceholder = __( 'Paste URL or type to search' ),\n\t\t\t__experimentalRenderControl: renderControl,\n\t\t\tvalue = '',\n\t\t} = this.props;\n\n\t\tconst {\n\t\t\tloading,\n\t\t\tshowSuggestions,\n\t\t\tselectedSuggestion,\n\t\t\tsuggestionsListboxId,\n\t\t\tsuggestionOptionIdPrefix,\n\t\t} = this.state;\n\n\t\tconst inputId = `url-input-control-${ instanceId }`;\n\n\t\tconst controlProps = {\n\t\t\tid: inputId, // Passes attribute to label for the for attribute\n\t\t\tlabel,\n\t\t\tclassName: classnames( 'block-editor-url-input', className, {\n\t\t\t\t'is-full-width': isFullWidth,\n\t\t\t} ),\n\t\t};\n\n\t\tconst inputProps = {\n\t\t\tid: inputId,\n\t\t\tvalue,\n\t\t\trequired: true,\n\t\t\tclassName: 'block-editor-url-input__input',\n\t\t\ttype: 'text',\n\t\t\tonChange: this.onChange,\n\t\t\tonFocus: this.onFocus,\n\t\t\tplaceholder,\n\t\t\tonKeyDown: this.onKeyDown,\n\t\t\trole: 'combobox',\n\t\t\t'aria-label': label ? undefined : __( 'URL' ), // Ensure input always has an accessible label\n\t\t\t'aria-expanded': showSuggestions,\n\t\t\t'aria-autocomplete': 'list',\n\t\t\t'aria-controls': suggestionsListboxId,\n\t\t\t'aria-activedescendant':\n\t\t\t\tselectedSuggestion !== null\n\t\t\t\t\t? `${ suggestionOptionIdPrefix }-${ selectedSuggestion }`\n\t\t\t\t\t: undefined,\n\t\t\tref: this.inputRef,\n\t\t};\n\n\t\tif ( renderControl ) {\n\t\t\treturn renderControl( controlProps, inputProps, loading );\n\t\t}\n\n\t\treturn (\n\t\t\t<BaseControl { ...controlProps }>\n\t\t\t\t<input { ...inputProps } />\n\t\t\t\t{ loading && <Spinner /> }\n\t\t\t</BaseControl>\n\t\t);\n\t}\n\n\trenderSuggestions() {\n\t\tconst {\n\t\t\tclassName,\n\t\t\t__experimentalRenderSuggestions: renderSuggestions,\n\t\t} = this.props;\n\n\t\tconst {\n\t\t\tshowSuggestions,\n\t\t\tsuggestions,\n\t\t\tsuggestionsValue,\n\t\t\tselectedSuggestion,\n\t\t\tsuggestionsListboxId,\n\t\t\tsuggestionOptionIdPrefix,\n\t\t\tloading,\n\t\t} = this.state;\n\n\t\tif ( ! showSuggestions || suggestions.length === 0 ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst suggestionsListProps = {\n\t\t\tid: suggestionsListboxId,\n\t\t\tref: this.autocompleteRef,\n\t\t\trole: 'listbox',\n\t\t};\n\n\t\tconst buildSuggestionItemProps = ( suggestion, index ) => {\n\t\t\treturn {\n\t\t\t\trole: 'option',\n\t\t\t\ttabIndex: '-1',\n\t\t\t\tid: `${ suggestionOptionIdPrefix }-${ index }`,\n\t\t\t\tref: this.bindSuggestionNode( index ),\n\t\t\t\t'aria-selected': index === selectedSuggestion,\n\t\t\t};\n\t\t};\n\n\t\tif ( isFunction( renderSuggestions ) ) {\n\t\t\treturn renderSuggestions( {\n\t\t\t\tsuggestions,\n\t\t\t\tselectedSuggestion,\n\t\t\t\tsuggestionsListProps,\n\t\t\t\tbuildSuggestionItemProps,\n\t\t\t\tisLoading: loading,\n\t\t\t\thandleSuggestionClick: this.handleOnClick,\n\t\t\t\tisInitialSuggestions: ! suggestionsValue?.length,\n\t\t\t\tcurrentInputValue: suggestionsValue,\n\t\t\t} );\n\t\t}\n\n\t\treturn (\n\t\t\t<Popover placement=\"bottom\" focusOnMount={ false }>\n\t\t\t\t<div\n\t\t\t\t\t{ ...suggestionsListProps }\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'block-editor-url-input__suggestions',\n\t\t\t\t\t\t`${ className }__suggestions`\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t{ suggestions.map( ( suggestion, index ) => (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t{ ...buildSuggestionItemProps( suggestion, index ) }\n\t\t\t\t\t\t\tkey={ suggestion.id }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-url-input__suggestion',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-selected': index === selectedSuggestion,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tonClick={ () => this.handleOnClick( suggestion ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ suggestion.title }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) ) }\n\t\t\t\t</div>\n\t\t\t</Popover>\n\t\t);\n\t}\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-input/README.md\n */\nexport default compose(\n\twithSafeTimeout,\n\twithSpokenMessages,\n\twithInstanceId,\n\twithSelect( ( select, props ) => {\n\t\t// If a link suggestions handler is already provided then\n\t\t// bail.\n\t\tif ( isFunction( props.__experimentalFetchLinkSuggestions ) ) {\n\t\t\treturn;\n\t\t}\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\t__experimentalFetchLinkSuggestions:\n\t\t\t\tgetSettings().__experimentalFetchLinkSuggestions,\n\t\t};\n\t} )\n)( URLInput );\n"]}
@@ -2,7 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useSelect } from '@wordpress/data';
5
- import { store as blocksStore } from '@wordpress/blocks';
5
+ import { store as blocksStore, isReusableBlock, isTemplatePart } from '@wordpress/blocks';
6
6
  /**
7
7
  * Internal dependencies
8
8
  */
@@ -15,10 +15,11 @@ import { store as blockEditorStore } from '../../store';
15
15
  *
16
16
  * @typedef {Object} WPBlockDisplayInformation
17
17
  *
18
- * @property {string} title Human-readable block type label.
19
- * @property {WPIcon} icon Block type icon.
20
- * @property {string} description A detailed block type description.
21
- * @property {string} anchor HTML anchor.
18
+ * @property {boolean} isSynced True if is a reusable block or template part
19
+ * @property {string} title Human-readable block type label.
20
+ * @property {WPIcon} icon Block type icon.
21
+ * @property {string} description A detailed block type description.
22
+ * @property {string} anchor HTML anchor.
22
23
  */
23
24
 
24
25
  /**
@@ -52,7 +53,9 @@ export default function useBlockDisplayInformation(clientId) {
52
53
  if (!blockType) return null;
53
54
  const attributes = getBlockAttributes(clientId);
54
55
  const match = getActiveBlockVariation(blockName, attributes);
56
+ const isSynced = isReusableBlock(blockType) || isTemplatePart(blockType);
55
57
  const blockTypeInfo = {
58
+ isSynced,
56
59
  title: blockType.title,
57
60
  icon: blockType.icon,
58
61
  description: blockType.description,
@@ -60,6 +63,7 @@ export default function useBlockDisplayInformation(clientId) {
60
63
  };
61
64
  if (!match) return blockTypeInfo;
62
65
  return {
66
+ isSynced,
63
67
  title: match.title || blockType.title,
64
68
  icon: match.icon || blockType.icon,
65
69
  description: match.description || blockType.description,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/use-block-display-information/index.js"],"names":["useSelect","store","blocksStore","blockEditorStore","useBlockDisplayInformation","clientId","select","getBlockName","getBlockAttributes","getBlockType","getActiveBlockVariation","blockName","blockType","attributes","match","blockTypeInfo","title","icon","description","anchor"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AAEA;AACA;AACA;;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,aAA1C;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,eAAe,SAASC,0BAAT,CAAqCC,QAArC,EAAgD;AAC9D,SAAOL,SAAS,CACbM,MAAF,IAAc;AACb,QAAK,CAAED,QAAP,EAAkB,OAAO,IAAP;AAClB,UAAM;AAAEE,MAAAA,YAAF;AAAgBC,MAAAA;AAAhB,QACLF,MAAM,CAAEH,gBAAF,CADP;AAEA,UAAM;AAAEM,MAAAA,YAAF;AAAgBC,MAAAA;AAAhB,QACLJ,MAAM,CAAEJ,WAAF,CADP;AAEA,UAAMS,SAAS,GAAGJ,YAAY,CAAEF,QAAF,CAA9B;AACA,UAAMO,SAAS,GAAGH,YAAY,CAAEE,SAAF,CAA9B;AACA,QAAK,CAAEC,SAAP,EAAmB,OAAO,IAAP;AACnB,UAAMC,UAAU,GAAGL,kBAAkB,CAAEH,QAAF,CAArC;AACA,UAAMS,KAAK,GAAGJ,uBAAuB,CAAEC,SAAF,EAAaE,UAAb,CAArC;AACA,UAAME,aAAa,GAAG;AACrBC,MAAAA,KAAK,EAAEJ,SAAS,CAACI,KADI;AAErBC,MAAAA,IAAI,EAAEL,SAAS,CAACK,IAFK;AAGrBC,MAAAA,WAAW,EAAEN,SAAS,CAACM,WAHF;AAIrBC,MAAAA,MAAM,EAAEN,UAAF,aAAEA,UAAF,uBAAEA,UAAU,CAAEM;AAJC,KAAtB;AAMA,QAAK,CAAEL,KAAP,EAAe,OAAOC,aAAP;AAEf,WAAO;AACNC,MAAAA,KAAK,EAAEF,KAAK,CAACE,KAAN,IAAeJ,SAAS,CAACI,KAD1B;AAENC,MAAAA,IAAI,EAAEH,KAAK,CAACG,IAAN,IAAcL,SAAS,CAACK,IAFxB;AAGNC,MAAAA,WAAW,EAAEJ,KAAK,CAACI,WAAN,IAAqBN,SAAS,CAACM,WAHtC;AAINC,MAAAA,MAAM,EAAEN,UAAF,aAAEA,UAAF,uBAAEA,UAAU,CAAEM;AAJd,KAAP;AAMA,GA1Bc,EA2Bf,CAAEd,QAAF,CA3Be,CAAhB;AA6BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('@wordpress/blocks').WPIcon} WPIcon */\n\n/**\n * Contains basic block's information for display reasons.\n *\n * @typedef {Object} WPBlockDisplayInformation\n *\n * @property {string} title Human-readable block type label.\n * @property {WPIcon} icon Block type icon.\n * @property {string} description A detailed block type description.\n * @property {string} anchor HTML anchor.\n */\n\n/**\n * Hook used to try to find a matching block variation and return\n * the appropriate information for display reasons. In order to\n * to try to find a match we need to things:\n * 1. Block's client id to extract it's current attributes.\n * 2. A block variation should have set `isActive` prop to a proper function.\n *\n * If for any reason a block variaton match cannot be found,\n * the returned information come from the Block Type.\n * If no blockType is found with the provided clientId, returns null.\n *\n * @param {string} clientId Block's client id.\n * @return {?WPBlockDisplayInformation} Block's display information, or `null` when the block or its type not found.\n */\n\nexport default function useBlockDisplayInformation( clientId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) return null;\n\t\t\tconst { getBlockName, getBlockAttributes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { getBlockType, getActiveBlockVariation } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( blockName );\n\t\t\tif ( ! blockType ) return null;\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\t\t\tconst match = getActiveBlockVariation( blockName, attributes );\n\t\t\tconst blockTypeInfo = {\n\t\t\t\ttitle: blockType.title,\n\t\t\t\ticon: blockType.icon,\n\t\t\t\tdescription: blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t};\n\t\t\tif ( ! match ) return blockTypeInfo;\n\n\t\t\treturn {\n\t\t\t\ttitle: match.title || blockType.title,\n\t\t\t\ticon: match.icon || blockType.icon,\n\t\t\t\tdescription: match.description || blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/use-block-display-information/index.js"],"names":["useSelect","store","blocksStore","isReusableBlock","isTemplatePart","blockEditorStore","useBlockDisplayInformation","clientId","select","getBlockName","getBlockAttributes","getBlockType","getActiveBlockVariation","blockName","blockType","attributes","match","isSynced","blockTypeInfo","title","icon","description","anchor"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SACCC,KAAK,IAAIC,WADV,EAECC,eAFD,EAGCC,cAHD,QAIO,mBAJP;AAMA;AACA;AACA;;AACA,SAASH,KAAK,IAAII,gBAAlB,QAA0C,aAA1C;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,eAAe,SAASC,0BAAT,CAAqCC,QAArC,EAAgD;AAC9D,SAAOP,SAAS,CACbQ,MAAF,IA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,CAAEf,QAAF,CA/Be,CAAhB;AAiCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tstore as blocksStore,\n\tisReusableBlock,\n\tisTemplatePart,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('@wordpress/blocks').WPIcon} WPIcon */\n\n/**\n * Contains basic block's information for display reasons.\n *\n * @typedef {Object} WPBlockDisplayInformation\n *\n * @property {boolean} isSynced True if is a reusable block or template part\n * @property {string} title Human-readable block type label.\n * @property {WPIcon} icon Block type icon.\n * @property {string} description A detailed block type description.\n * @property {string} anchor HTML anchor.\n */\n\n/**\n * Hook used to try to find a matching block variation and return\n * the appropriate information for display reasons. In order to\n * to try to find a match we need to things:\n * 1. Block's client id to extract it's current attributes.\n * 2. A block variation should have set `isActive` prop to a proper function.\n *\n * If for any reason a block variaton match cannot be found,\n * the returned information come from the Block Type.\n * If no blockType is found with the provided clientId, returns null.\n *\n * @param {string} clientId Block's client id.\n * @return {?WPBlockDisplayInformation} Block's display information, or `null` when the block or its type not found.\n */\n\nexport default function useBlockDisplayInformation( clientId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) return null;\n\t\t\tconst { getBlockName, getBlockAttributes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { getBlockType, getActiveBlockVariation } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( blockName );\n\t\t\tif ( ! blockType ) return null;\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\t\t\tconst match = getActiveBlockVariation( blockName, attributes );\n\t\t\tconst isSynced =\n\t\t\t\tisReusableBlock( blockType ) || isTemplatePart( blockType );\n\t\t\tconst blockTypeInfo = {\n\t\t\t\tisSynced,\n\t\t\t\ttitle: blockType.title,\n\t\t\t\ticon: blockType.icon,\n\t\t\t\tdescription: blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t};\n\t\t\tif ( ! match ) return blockTypeInfo;\n\n\t\t\treturn {\n\t\t\t\tisSynced,\n\t\t\t\ttitle: match.title || blockType.title,\n\t\t\t\ticon: match.icon || blockType.icon,\n\t\t\t\tdescription: match.description || blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n"]}
@@ -8,6 +8,7 @@ import { get } from 'lodash';
8
8
 
9
9
  import { useSelect } from '@wordpress/data';
10
10
  import { __EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE, hasBlockSupport } from '@wordpress/blocks';
11
+ import { applyFilters } from '@wordpress/hooks';
11
12
  /**
12
13
  * Internal dependencies
13
14
  */
@@ -100,9 +101,15 @@ export default function useSetting(path) {
100
101
  // eslint-disable-next-line no-console
101
102
  console.warn('Top level useSetting paths are disabled. Please use a subpath to query the information needed.');
102
103
  return undefined;
104
+ } // 0. Allow third parties to filter the block's settings at runtime.
105
+
106
+
107
+ let result = applyFilters('blockEditor.useSetting.before', undefined, path, clientId, blockName);
108
+
109
+ if (undefined !== result) {
110
+ return result;
103
111
  }
104
112
 
105
- let result;
106
113
  const normalizedPath = removeCustomPrefixes(path); // 1. Take settings from the block instance or its ancestors.
107
114
  // Start from the current block and work our way up the ancestors.
108
115
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/use-setting/index.js"],"names":["get","useSelect","__EXPERIMENTAL_PATHS_WITH_MERGE","PATHS_WITH_MERGE","hasBlockSupport","useBlockEditContext","store","blockEditorStore","blockedPaths","deprecatedFlags","settings","colors","gradients","disableCustomColors","undefined","disableCustomGradients","fontSizes","disableCustomFontSizes","enableCustomLineHeight","enableCustomUnits","enableCustomSpacing","prefixedFlags","removeCustomPrefixes","path","useSetting","name","blockName","clientId","select","includes","console","warn","result","normalizedPath","candidates","getBlockParents","candidateClientId","candidateBlockName","getBlockName","candidateAtts","getBlockAttributes","getSettings","defaultsPath","blockPath","custom","theme","default","deprecatedSettingsValue"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,+BAA+B,IAAIC,gBADpC,EAECC,eAFD,QAGO,mBAHP;AAKA;AACA;AACA;;AACA,SAASC,mBAAT,QAAoC,eAApC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA,MAAMC,YAAY,GAAG,CACpB,OADoB,EAEpB,QAFoB,EAGpB,YAHoB,EAIpB,YAJoB,EAKpB,SALoB,CAArB;AAQA,MAAMC,eAAe,GAAG;AACvB,mBAAmBC,QAAF,IAAgBA,QAAQ,CAACC,MADnB;AAEvB,qBAAqBD,QAAF,IAAgBA,QAAQ,CAACE,SAFrB;AAGvB,kBAAkBF,QAAF,IACfA,QAAQ,CAACG,mBAAT,KAAiCC,SAAjC,GACGA,SADH,GAEG,CAAEJ,QAAQ,CAACG,mBANQ;AAOvB,0BAA0BH,QAAF,IACvBA,QAAQ,CAACK,sBAAT,KAAoCD,SAApC,GACGA,SADH,GAEG,CAAEJ,QAAQ,CAACK,sBAVQ;AAWvB,0BAA0BL,QAAF,IAAgBA,QAAQ,CAACM,SAX1B;AAYvB,+BAA+BN,QAAF,IAC5BA,QAAQ,CAACO,sBAAT,KAAoCH,SAApC,GACGA,SADH,GAEG,CAAEJ,QAAQ,CAACO,sBAfQ;AAgBvB,2BAA2BP,QAAF,IAAgBA,QAAQ,CAACQ,sBAhB3B;AAiBvB,mBAAmBR,QAAF,IAAgB;AAChC,QAAKA,QAAQ,CAACS,iBAAT,KAA+BL,SAApC,EAAgD;AAC/C;AACA;;AAED,QAAKJ,QAAQ,CAACS,iBAAT,KAA+B,IAApC,EAA2C;AAC1C,aAAO,CAAE,IAAF,EAAQ,IAAR,EAAc,KAAd,EAAqB,IAArB,EAA2B,IAA3B,EAAiC,GAAjC,CA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C7BxB,eAAe,CAAEwB,cAAF,CAAf,CAAmCvB,QAAnC,CAD6B,GAE7BI,SAFH;;AAGA,QAAKiC,uBAAuB,KAAKjC,SAAjC,EAA6C;AAC5C,aAAOiC,uBAAP;AACA,KA3EY,CA6Eb;AACA;AACA;AACA;;;AACA,WAAOd,cAAc,KAAK,oBAAnB,GAA0C,IAA1C,GAAiDnB,SAAxD;AACA,GAnFc,EAoFf,CAAEY,SAAF,EAAaC,QAAb,EAAuBJ,IAAvB,CApFe,CAAhB;AAsFA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\t__EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE,\n\thasBlockSupport,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit';\nimport { store as blockEditorStore } from '../../store';\n\nconst blockedPaths = [\n\t'color',\n\t'border',\n\t'dimensions',\n\t'typography',\n\t'spacing',\n];\n\nconst deprecatedFlags = {\n\t'color.palette': ( settings ) => settings.colors,\n\t'color.gradients': ( settings ) => settings.gradients,\n\t'color.custom': ( settings ) =>\n\t\tsettings.disableCustomColors === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomColors,\n\t'color.customGradient': ( settings ) =>\n\t\tsettings.disableCustomGradients === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomGradients,\n\t'typography.fontSizes': ( settings ) => settings.fontSizes,\n\t'typography.customFontSize': ( settings ) =>\n\t\tsettings.disableCustomFontSizes === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomFontSizes,\n\t'typography.lineHeight': ( settings ) => settings.enableCustomLineHeight,\n\t'spacing.units': ( settings ) => {\n\t\tif ( settings.enableCustomUnits === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( settings.enableCustomUnits === true ) {\n\t\t\treturn [ 'px', 'em', 'rem', 'vh', 'vw', '%' ];\n\t\t}\n\n\t\treturn settings.enableCustomUnits;\n\t},\n\t'spacing.padding': ( settings ) => settings.enableCustomSpacing,\n};\n\nconst prefixedFlags = {\n\t/*\n\t * These were only available in the plugin\n\t * and can be removed when the minimum WordPress version\n\t * for the plugin is 5.9.\n\t */\n\t'border.customColor': 'border.color',\n\t'border.customStyle': 'border.style',\n\t'border.customWidth': 'border.width',\n\t'typography.customFontStyle': 'typography.fontStyle',\n\t'typography.customFontWeight': 'typography.fontWeight',\n\t'typography.customLetterSpacing': 'typography.letterSpacing',\n\t'typography.customTextDecorations': 'typography.textDecoration',\n\t'typography.customTextTransforms': 'typography.textTransform',\n\t/*\n\t * These were part of WordPress 5.8 and we need to keep them.\n\t */\n\t'border.customRadius': 'border.radius',\n\t'spacing.customMargin': 'spacing.margin',\n\t'spacing.customPadding': 'spacing.padding',\n\t'typography.customLineHeight': 'typography.lineHeight',\n};\n\n/**\n * Remove `custom` prefixes for flags that did not land in 5.8.\n *\n * This provides continued support for `custom` prefixed properties. It will\n * be removed once third party devs have had sufficient time to update themes,\n * plugins, etc.\n *\n * @see https://github.com/WordPress/gutenberg/pull/34485\n *\n * @param {string} path Path to desired value in settings.\n * @return {string} The value for defined setting.\n */\nconst removeCustomPrefixes = ( path ) => {\n\treturn prefixedFlags[ path ] || path;\n};\n\n/**\n * Hook that retrieves the given setting for the block instance in use.\n *\n * It looks up the settings first in the block instance hierarchy.\n * If none is found, it'll look it up in the block editor store.\n *\n * @param {string} path The path to the setting.\n * @return {any} Returns the value defined for the setting.\n * @example\n * ```js\n * const isEnabled = useSetting( 'typography.dropCap' );\n * ```\n */\nexport default function useSetting( path ) {\n\tconst { name: blockName, clientId } = useBlockEditContext();\n\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tif ( blockedPaths.includes( path ) ) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.warn(\n\t\t\t\t\t'Top level useSetting paths are disabled. Please use a subpath to query the information needed.'\n\t\t\t\t);\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tlet result;\n\n\t\t\tconst normalizedPath = removeCustomPrefixes( path );\n\n\t\t\t// 1. Take settings from the block instance or its ancestors.\n\t\t\t// Start from the current block and work our way up the ancestors.\n\t\t\tconst candidates = [\n\t\t\t\tclientId,\n\t\t\t\t...select( blockEditorStore ).getBlockParents(\n\t\t\t\t\tclientId,\n\t\t\t\t\t/* ascending */ true\n\t\t\t\t),\n\t\t\t];\n\n\t\t\tfor ( const candidateClientId of candidates ) {\n\t\t\t\tconst candidateBlockName =\n\t\t\t\t\tselect( blockEditorStore ).getBlockName(\n\t\t\t\t\t\tcandidateClientId\n\t\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\thasBlockSupport(\n\t\t\t\t\t\tcandidateBlockName,\n\t\t\t\t\t\t'__experimentalSettings',\n\t\t\t\t\t\tfalse\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tconst candidateAtts =\n\t\t\t\t\t\tselect( blockEditorStore ).getBlockAttributes(\n\t\t\t\t\t\t\tcandidateClientId\n\t\t\t\t\t\t);\n\t\t\t\t\tresult =\n\t\t\t\t\t\tget(\n\t\t\t\t\t\t\tcandidateAtts,\n\t\t\t\t\t\t\t`settings.blocks.${ blockName }.${ normalizedPath }`\n\t\t\t\t\t\t) ??\n\t\t\t\t\t\tget( candidateAtts, `settings.${ normalizedPath }` );\n\t\t\t\t\tif ( result !== undefined ) {\n\t\t\t\t\t\t// Stop the search for more distant ancestors and move on.\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// 2. Fall back to the settings from the block editor store (__experimentalFeatures).\n\t\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\t\tif ( result === undefined ) {\n\t\t\t\tconst defaultsPath = `__experimentalFeatures.${ normalizedPath }`;\n\t\t\t\tconst blockPath = `__experimentalFeatures.blocks.${ blockName }.${ normalizedPath }`;\n\t\t\t\tresult =\n\t\t\t\t\tget( settings, blockPath ) ?? get( settings, defaultsPath );\n\t\t\t}\n\n\t\t\t// Return if the setting was found in either the block instance or the store.\n\t\t\tif ( result !== undefined ) {\n\t\t\t\tif ( PATHS_WITH_MERGE[ normalizedPath ] ) {\n\t\t\t\t\treturn result.custom ?? result.theme ?? result.default;\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\t// 3. Otherwise, use deprecated settings.\n\t\t\tconst deprecatedSettingsValue = deprecatedFlags[ normalizedPath ]\n\t\t\t\t? deprecatedFlags[ normalizedPath ]( settings )\n\t\t\t\t: undefined;\n\t\t\tif ( deprecatedSettingsValue !== undefined ) {\n\t\t\t\treturn deprecatedSettingsValue;\n\t\t\t}\n\n\t\t\t// 4. Fallback for typography.dropCap:\n\t\t\t// This is only necessary to support typography.dropCap.\n\t\t\t// when __experimentalFeatures are not present (core without plugin).\n\t\t\t// To remove when __experimentalFeatures are ported to core.\n\t\t\treturn normalizedPath === 'typography.dropCap' ? true : undefined;\n\t\t},\n\t\t[ blockName, clientId, path ]\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/use-setting/index.js"],"names":["get","useSelect","__EXPERIMENTAL_PATHS_WITH_MERGE","PATHS_WITH_MERGE","hasBlockSupport","applyFilters","useBlockEditContext","store","blockEditorStore","blockedPaths","deprecatedFlags","settings","colors","gradients","disableCustomColors","undefined","disableCustomGradients","fontSizes","disableCustomFontSizes","enableCustomLineHeight","enableCustomUnits","enableCustomSpacing","prefixedFlags","removeCustomPrefixes","path","useSetting","name","blockName","clientId","select","includes","console","warn","result","normalizedPath","candidates","getBlockParents","candidateClientId","candidateBlockName","getBlockName","candidateAtts","getBlockAttributes","getSettings","defaultsPath","blockPath","custom","theme","default","deprecatedSettingsValue"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,+BAA+B,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AAGtC,eAAe,CAAEwB,cAAF,CAAf,GAC7BxB,eAAe,CAAEwB,cAAF,CAAf,CAAmCvB,QAAnC,CAD6B,GAE7BI,SAFH;;AAGA,QAAKiC,uBAAuB,KAAKjC,SAAjC,EAA6C;AAC5C,aAAOiC,uBAAP;AACA,KAtFY,CAwFb;AACA;AACA;AACA;;;AACA,WAAOd,cAAc,KAAK,oBAAnB,GAA0C,IAA1C,GAAiDnB,SAAxD;AACA,GA9Fc,EA+Ff,CAAEY,SAAF,EAAaC,QAAb,EAAuBJ,IAAvB,CA/Fe,CAAhB;AAiGA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\t__EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE,\n\thasBlockSupport,\n} from '@wordpress/blocks';\nimport { applyFilters } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit';\nimport { store as blockEditorStore } from '../../store';\n\nconst blockedPaths = [\n\t'color',\n\t'border',\n\t'dimensions',\n\t'typography',\n\t'spacing',\n];\n\nconst deprecatedFlags = {\n\t'color.palette': ( settings ) => settings.colors,\n\t'color.gradients': ( settings ) => settings.gradients,\n\t'color.custom': ( settings ) =>\n\t\tsettings.disableCustomColors === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomColors,\n\t'color.customGradient': ( settings ) =>\n\t\tsettings.disableCustomGradients === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomGradients,\n\t'typography.fontSizes': ( settings ) => settings.fontSizes,\n\t'typography.customFontSize': ( settings ) =>\n\t\tsettings.disableCustomFontSizes === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomFontSizes,\n\t'typography.lineHeight': ( settings ) => settings.enableCustomLineHeight,\n\t'spacing.units': ( settings ) => {\n\t\tif ( settings.enableCustomUnits === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( settings.enableCustomUnits === true ) {\n\t\t\treturn [ 'px', 'em', 'rem', 'vh', 'vw', '%' ];\n\t\t}\n\n\t\treturn settings.enableCustomUnits;\n\t},\n\t'spacing.padding': ( settings ) => settings.enableCustomSpacing,\n};\n\nconst prefixedFlags = {\n\t/*\n\t * These were only available in the plugin\n\t * and can be removed when the minimum WordPress version\n\t * for the plugin is 5.9.\n\t */\n\t'border.customColor': 'border.color',\n\t'border.customStyle': 'border.style',\n\t'border.customWidth': 'border.width',\n\t'typography.customFontStyle': 'typography.fontStyle',\n\t'typography.customFontWeight': 'typography.fontWeight',\n\t'typography.customLetterSpacing': 'typography.letterSpacing',\n\t'typography.customTextDecorations': 'typography.textDecoration',\n\t'typography.customTextTransforms': 'typography.textTransform',\n\t/*\n\t * These were part of WordPress 5.8 and we need to keep them.\n\t */\n\t'border.customRadius': 'border.radius',\n\t'spacing.customMargin': 'spacing.margin',\n\t'spacing.customPadding': 'spacing.padding',\n\t'typography.customLineHeight': 'typography.lineHeight',\n};\n\n/**\n * Remove `custom` prefixes for flags that did not land in 5.8.\n *\n * This provides continued support for `custom` prefixed properties. It will\n * be removed once third party devs have had sufficient time to update themes,\n * plugins, etc.\n *\n * @see https://github.com/WordPress/gutenberg/pull/34485\n *\n * @param {string} path Path to desired value in settings.\n * @return {string} The value for defined setting.\n */\nconst removeCustomPrefixes = ( path ) => {\n\treturn prefixedFlags[ path ] || path;\n};\n\n/**\n * Hook that retrieves the given setting for the block instance in use.\n *\n * It looks up the settings first in the block instance hierarchy.\n * If none is found, it'll look it up in the block editor store.\n *\n * @param {string} path The path to the setting.\n * @return {any} Returns the value defined for the setting.\n * @example\n * ```js\n * const isEnabled = useSetting( 'typography.dropCap' );\n * ```\n */\nexport default function useSetting( path ) {\n\tconst { name: blockName, clientId } = useBlockEditContext();\n\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tif ( blockedPaths.includes( path ) ) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.warn(\n\t\t\t\t\t'Top level useSetting paths are disabled. Please use a subpath to query the information needed.'\n\t\t\t\t);\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\t// 0. Allow third parties to filter the block's settings at runtime.\n\t\t\tlet result = applyFilters(\n\t\t\t\t'blockEditor.useSetting.before',\n\t\t\t\tundefined,\n\t\t\t\tpath,\n\t\t\t\tclientId,\n\t\t\t\tblockName\n\t\t\t);\n\n\t\t\tif ( undefined !== result ) {\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tconst normalizedPath = removeCustomPrefixes( path );\n\n\t\t\t// 1. Take settings from the block instance or its ancestors.\n\t\t\t// Start from the current block and work our way up the ancestors.\n\t\t\tconst candidates = [\n\t\t\t\tclientId,\n\t\t\t\t...select( blockEditorStore ).getBlockParents(\n\t\t\t\t\tclientId,\n\t\t\t\t\t/* ascending */ true\n\t\t\t\t),\n\t\t\t];\n\n\t\t\tfor ( const candidateClientId of candidates ) {\n\t\t\t\tconst candidateBlockName =\n\t\t\t\t\tselect( blockEditorStore ).getBlockName(\n\t\t\t\t\t\tcandidateClientId\n\t\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\thasBlockSupport(\n\t\t\t\t\t\tcandidateBlockName,\n\t\t\t\t\t\t'__experimentalSettings',\n\t\t\t\t\t\tfalse\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tconst candidateAtts =\n\t\t\t\t\t\tselect( blockEditorStore ).getBlockAttributes(\n\t\t\t\t\t\t\tcandidateClientId\n\t\t\t\t\t\t);\n\t\t\t\t\tresult =\n\t\t\t\t\t\tget(\n\t\t\t\t\t\t\tcandidateAtts,\n\t\t\t\t\t\t\t`settings.blocks.${ blockName }.${ normalizedPath }`\n\t\t\t\t\t\t) ??\n\t\t\t\t\t\tget( candidateAtts, `settings.${ normalizedPath }` );\n\t\t\t\t\tif ( result !== undefined ) {\n\t\t\t\t\t\t// Stop the search for more distant ancestors and move on.\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// 2. Fall back to the settings from the block editor store (__experimentalFeatures).\n\t\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\t\tif ( result === undefined ) {\n\t\t\t\tconst defaultsPath = `__experimentalFeatures.${ normalizedPath }`;\n\t\t\t\tconst blockPath = `__experimentalFeatures.blocks.${ blockName }.${ normalizedPath }`;\n\t\t\t\tresult =\n\t\t\t\t\tget( settings, blockPath ) ?? get( settings, defaultsPath );\n\t\t\t}\n\n\t\t\t// Return if the setting was found in either the block instance or the store.\n\t\t\tif ( result !== undefined ) {\n\t\t\t\tif ( PATHS_WITH_MERGE[ normalizedPath ] ) {\n\t\t\t\t\treturn result.custom ?? result.theme ?? result.default;\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\t// 3. Otherwise, use deprecated settings.\n\t\t\tconst deprecatedSettingsValue = deprecatedFlags[ normalizedPath ]\n\t\t\t\t? deprecatedFlags[ normalizedPath ]( settings )\n\t\t\t\t: undefined;\n\t\t\tif ( deprecatedSettingsValue !== undefined ) {\n\t\t\t\treturn deprecatedSettingsValue;\n\t\t\t}\n\n\t\t\t// 4. Fallback for typography.dropCap:\n\t\t\t// This is only necessary to support typography.dropCap.\n\t\t\t// when __experimentalFeatures are not present (core without plugin).\n\t\t\t// To remove when __experimentalFeatures are ported to core.\n\t\t\treturn normalizedPath === 'typography.dropCap' ? true : undefined;\n\t\t},\n\t\t[ blockName, clientId, path ]\n\t);\n}\n"]}