@wordpress/block-editor 10.5.0 → 11.1.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 (716) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +2 -1
  3. package/build/autocompleters/block.js +2 -6
  4. package/build/autocompleters/block.js.map +1 -1
  5. package/build/autocompleters/link.js +2 -0
  6. package/build/autocompleters/link.js.map +1 -1
  7. package/build/components/alignment-control/ui.js +1 -7
  8. package/build/components/alignment-control/ui.js.map +1 -1
  9. package/build/components/block-alignment-control/use-available-alignments.js +4 -3
  10. package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
  11. package/build/components/block-card/index.js +51 -3
  12. package/build/components/block-card/index.js.map +1 -1
  13. package/build/components/block-draggable/index.native.js +46 -39
  14. package/build/components/block-draggable/index.native.js.map +1 -1
  15. package/build/components/block-edit/edit.js +4 -3
  16. package/build/components/block-edit/edit.js.map +1 -1
  17. package/build/components/block-edit/edit.native.js +4 -7
  18. package/build/components/block-edit/edit.native.js.map +1 -1
  19. package/build/components/block-icon/index.js +4 -2
  20. package/build/components/block-icon/index.js.map +1 -1
  21. package/build/components/block-inspector/index.js +90 -37
  22. package/build/components/block-inspector/index.js.map +1 -1
  23. package/build/components/block-list/block-list-context.native.js +5 -8
  24. package/build/components/block-list/block-list-context.native.js.map +1 -1
  25. package/build/components/block-list/block.js +55 -24
  26. package/build/components/block-list/block.js.map +1 -1
  27. package/build/components/block-list/block.native.js +61 -28
  28. package/build/components/block-list/block.native.js.map +1 -1
  29. package/build/components/block-list-appender/index.js +46 -34
  30. package/build/components/block-list-appender/index.js.map +1 -1
  31. package/build/components/block-list-appender/index.native.js +39 -34
  32. package/build/components/block-list-appender/index.native.js.map +1 -1
  33. package/build/components/block-mobile-toolbar/block-actions-menu.native.js +30 -22
  34. package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  35. package/build/components/block-mobile-toolbar/index.native.js +1 -1
  36. package/build/components/block-mobile-toolbar/index.native.js.map +1 -1
  37. package/build/components/block-pattern-setup/index.js +16 -8
  38. package/build/components/block-pattern-setup/index.js.map +1 -1
  39. package/build/components/block-patterns-list/index.js +33 -11
  40. package/build/components/block-patterns-list/index.js.map +1 -1
  41. package/build/components/block-preview/auto.js +9 -3
  42. package/build/components/block-preview/auto.js.map +1 -1
  43. package/build/components/block-preview/index.js +5 -9
  44. package/build/components/block-preview/index.js.map +1 -1
  45. package/build/components/block-settings-menu/block-settings-dropdown.js +5 -2
  46. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  47. package/build/components/block-styles/index.native.js +1 -3
  48. package/build/components/block-styles/index.native.js.map +1 -1
  49. package/build/components/block-styles/utils.js +7 -10
  50. package/build/components/block-styles/utils.js.map +1 -1
  51. package/build/components/block-toolbar/index.js +5 -1
  52. package/build/components/block-toolbar/index.js.map +1 -1
  53. package/build/components/block-toolbar/index.native.js +6 -8
  54. package/build/components/block-toolbar/index.native.js.map +1 -1
  55. package/build/components/block-tools/insertion-point.js +8 -49
  56. package/build/components/block-tools/insertion-point.js.map +1 -1
  57. package/build/components/block-tools/selected-block-popover.js +1 -3
  58. package/build/components/block-tools/selected-block-popover.js.map +1 -1
  59. package/build/components/block-variation-picker/index.js +2 -3
  60. package/build/components/block-variation-picker/index.js.map +1 -1
  61. package/build/components/colors/utils.js +2 -6
  62. package/build/components/colors/utils.js.map +1 -1
  63. package/build/components/colors-gradients/control.js +0 -3
  64. package/build/components/colors-gradients/control.js.map +1 -1
  65. package/build/components/colors-gradients/dropdown.js +0 -2
  66. package/build/components/colors-gradients/dropdown.js.map +1 -1
  67. package/build/components/colors-gradients/panel-color-gradient-settings.js +2 -19
  68. package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  69. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -3
  70. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
  71. package/build/components/copy-handler/index.js +37 -9
  72. package/build/components/copy-handler/index.js.map +1 -1
  73. package/build/components/font-sizes/fluid-utils.js +5 -2
  74. package/build/components/font-sizes/fluid-utils.js.map +1 -1
  75. package/build/components/font-sizes/utils.js +10 -4
  76. package/build/components/font-sizes/utils.js.map +1 -1
  77. package/build/components/font-sizes/with-font-sizes.js +11 -6
  78. package/build/components/font-sizes/with-font-sizes.js.map +1 -1
  79. package/build/components/gradients/use-gradient.js +2 -8
  80. package/build/components/gradients/use-gradient.js.map +1 -1
  81. package/build/components/height-control/index.js +115 -0
  82. package/build/components/height-control/index.js.map +1 -0
  83. package/build/components/iframe/index.js +22 -101
  84. package/build/components/iframe/index.js.map +1 -1
  85. package/build/components/iframe/use-compatibility-styles.js +93 -0
  86. package/build/components/iframe/use-compatibility-styles.js.map +1 -0
  87. package/build/components/image-editor/use-save-image.js +2 -0
  88. package/build/components/image-editor/use-save-image.js.map +1 -1
  89. package/build/components/image-editor/zoom-dropdown.js +1 -0
  90. package/build/components/image-editor/zoom-dropdown.js.map +1 -1
  91. package/build/components/index.js +9 -0
  92. package/build/components/index.js.map +1 -1
  93. package/build/components/inner-blocks/index.js +25 -7
  94. package/build/components/inner-blocks/index.js.map +1 -1
  95. package/build/components/inner-blocks/use-inner-block-template-sync.js +25 -10
  96. package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  97. package/build/components/inserter/block-patterns-explorer/sidebar.js +1 -0
  98. package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
  99. package/build/components/inserter/block-patterns-tab.js +25 -46
  100. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  101. package/build/components/inserter/block-types-tab.js +3 -1
  102. package/build/components/inserter/block-types-tab.js.map +1 -1
  103. package/build/components/inserter/hooks/use-debounced-input.js +27 -0
  104. package/build/components/inserter/hooks/use-debounced-input.js.map +1 -0
  105. package/build/components/inserter/hooks/use-insertion-point.js +4 -3
  106. package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
  107. package/build/components/inserter/index.js +20 -6
  108. package/build/components/inserter/index.js.map +1 -1
  109. package/build/components/inserter/index.native.js +3 -4
  110. package/build/components/inserter/index.native.js.map +1 -1
  111. package/build/components/inserter/media-tab/hooks.js +106 -0
  112. package/build/components/inserter/media-tab/hooks.js.map +1 -0
  113. package/build/components/inserter/media-tab/index.js +32 -0
  114. package/build/components/inserter/media-tab/index.js.map +1 -0
  115. package/build/components/inserter/media-tab/media-list.js +100 -0
  116. package/build/components/inserter/media-tab/media-list.js.map +1 -0
  117. package/build/components/inserter/media-tab/media-panel.js +96 -0
  118. package/build/components/inserter/media-tab/media-panel.js.map +1 -0
  119. package/build/components/inserter/media-tab/media-tab.js +120 -0
  120. package/build/components/inserter/media-tab/media-tab.js.map +1 -0
  121. package/build/components/inserter/media-tab/utils.js +54 -0
  122. package/build/components/inserter/media-tab/utils.js.map +1 -0
  123. package/build/components/inserter/menu.js +35 -12
  124. package/build/components/inserter/menu.js.map +1 -1
  125. package/build/components/inserter/mobile-tab-navigation.js +70 -0
  126. package/build/components/inserter/mobile-tab-navigation.js.map +1 -0
  127. package/build/components/inserter/quick-inserter.js +7 -3
  128. package/build/components/inserter/quick-inserter.js.map +1 -1
  129. package/build/components/inserter/search-items.js +15 -14
  130. package/build/components/inserter/search-items.js.map +1 -1
  131. package/build/components/inserter/search-results.js +7 -3
  132. package/build/components/inserter/search-results.js.map +1 -1
  133. package/build/components/inserter/tabs.js +16 -2
  134. package/build/components/inserter/tabs.js.map +1 -1
  135. package/build/components/inserter-list-item/index.js +4 -1
  136. package/build/components/inserter-list-item/index.js.map +1 -1
  137. package/build/components/inspector-controls/groups.js +2 -0
  138. package/build/components/inspector-controls/groups.js.map +1 -1
  139. package/build/components/inspector-controls-tabs/advanced-controls-panel.js +46 -0
  140. package/build/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
  141. package/build/components/inspector-controls-tabs/index.js +71 -0
  142. package/build/components/inspector-controls-tabs/index.js.map +1 -0
  143. package/build/components/inspector-controls-tabs/settings-tab.js +28 -0
  144. package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -0
  145. package/build/components/inspector-controls-tabs/styles-tab.js +61 -0
  146. package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -0
  147. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +97 -0
  148. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
  149. package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +18 -0
  150. package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
  151. package/build/components/inspector-controls-tabs/utils.js +37 -0
  152. package/build/components/inspector-controls-tabs/utils.js.map +1 -0
  153. package/build/components/link-control/index.js +1 -0
  154. package/build/components/link-control/index.js.map +1 -1
  155. package/build/components/link-control/search-input.js +0 -1
  156. package/build/components/link-control/search-input.js.map +1 -1
  157. package/build/components/link-control/use-internal-input-value.js +3 -3
  158. package/build/components/link-control/use-internal-input-value.js.map +1 -1
  159. package/build/components/list-view/block-select-button.js +1 -1
  160. package/build/components/list-view/block-select-button.js.map +1 -1
  161. package/build/components/list-view/block.js +5 -2
  162. package/build/components/list-view/block.js.map +1 -1
  163. package/build/components/list-view/branch.js +13 -12
  164. package/build/components/list-view/branch.js.map +1 -1
  165. package/build/components/media-upload/index.native.js +2 -3
  166. package/build/components/media-upload/index.native.js.map +1 -1
  167. package/build/components/off-canvas-editor/appender.js +99 -0
  168. package/build/components/off-canvas-editor/appender.js.map +1 -0
  169. package/build/components/off-canvas-editor/block-edit-button.js +50 -0
  170. package/build/components/off-canvas-editor/block-edit-button.js.map +1 -0
  171. package/build/components/off-canvas-editor/block-select-button.js +3 -2
  172. package/build/components/off-canvas-editor/block-select-button.js.map +1 -1
  173. package/build/components/off-canvas-editor/block.js +82 -38
  174. package/build/components/off-canvas-editor/block.js.map +1 -1
  175. package/build/components/off-canvas-editor/branch.js +3 -5
  176. package/build/components/off-canvas-editor/branch.js.map +1 -1
  177. package/build/components/off-canvas-editor/index.js +24 -11
  178. package/build/components/off-canvas-editor/index.js.map +1 -1
  179. package/build/components/off-canvas-editor/leaf.js +1 -1
  180. package/build/components/off-canvas-editor/leaf.js.map +1 -1
  181. package/build/components/off-canvas-editor/link-ui.js +185 -0
  182. package/build/components/off-canvas-editor/link-ui.js.map +1 -0
  183. package/build/components/off-canvas-editor/update-attributes.js +108 -0
  184. package/build/components/off-canvas-editor/update-attributes.js.map +1 -0
  185. package/build/components/off-canvas-editor/use-inserted-block.js +58 -0
  186. package/build/components/off-canvas-editor/use-inserted-block.js.map +1 -0
  187. package/build/components/responsive-block-control/label.js.map +1 -1
  188. package/build/components/rich-text/format-edit.js +12 -10
  189. package/build/components/rich-text/format-edit.js.map +1 -1
  190. package/build/components/rich-text/format-toolbar/index.js +8 -4
  191. package/build/components/rich-text/format-toolbar/index.js.map +1 -1
  192. package/build/components/rich-text/index.js +3 -3
  193. package/build/components/rich-text/index.js.map +1 -1
  194. package/build/components/rich-text/index.native.js +0 -2
  195. package/build/components/rich-text/index.native.js.map +1 -1
  196. package/build/components/rich-text/use-insert-replacement-text.js +43 -0
  197. package/build/components/rich-text/use-insert-replacement-text.js.map +1 -0
  198. package/build/components/rich-text/use-paste-handler.js +21 -12
  199. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  200. package/build/components/rich-text/use-undo-automatic-change.js +9 -1
  201. package/build/components/rich-text/use-undo-automatic-change.js.map +1 -1
  202. package/build/components/rich-text/utils.js +1 -19
  203. package/build/components/rich-text/utils.js.map +1 -1
  204. package/build/components/spacing-sizes-control/index.js +0 -1
  205. package/build/components/spacing-sizes-control/index.js.map +1 -1
  206. package/build/components/spacing-sizes-control/spacing-input-control.js +12 -3
  207. package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  208. package/build/components/spacing-sizes-control/utils.js +1 -1
  209. package/build/components/spacing-sizes-control/utils.js.map +1 -1
  210. package/build/components/typewriter/index.js +1 -1
  211. package/build/components/typewriter/index.js.map +1 -1
  212. package/build/components/ungroup-button/index.native.js +4 -2
  213. package/build/components/ungroup-button/index.native.js.map +1 -1
  214. package/build/components/url-input/index.js +46 -43
  215. package/build/components/url-input/index.js.map +1 -1
  216. package/build/components/url-popover/image-url-input-ui.js +2 -2
  217. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  218. package/build/components/use-block-display-information/index.js +8 -4
  219. package/build/components/use-block-display-information/index.js.map +1 -1
  220. package/build/components/use-setting/index.js +9 -1
  221. package/build/components/use-setting/index.js.map +1 -1
  222. package/build/components/writing-flow/index.js +1 -1
  223. package/build/components/writing-flow/index.js.map +1 -1
  224. package/build/hooks/border.js +0 -1
  225. package/build/hooks/border.js.map +1 -1
  226. package/build/hooks/child-layout.js +209 -0
  227. package/build/hooks/child-layout.js.map +1 -0
  228. package/build/hooks/color-panel.js +0 -1
  229. package/build/hooks/color-panel.js.map +1 -1
  230. package/build/hooks/color.js +1 -2
  231. package/build/hooks/color.js.map +1 -1
  232. package/build/hooks/content-lock-ui.js +1 -1
  233. package/build/hooks/content-lock-ui.js.map +1 -1
  234. package/build/hooks/dimensions.js +25 -7
  235. package/build/hooks/dimensions.js.map +1 -1
  236. package/build/hooks/font-family.js +4 -4
  237. package/build/hooks/font-family.js.map +1 -1
  238. package/build/hooks/font-size.js +5 -3
  239. package/build/hooks/font-size.js.map +1 -1
  240. package/build/hooks/layout.js +57 -1
  241. package/build/hooks/layout.js.map +1 -1
  242. package/build/hooks/min-height.js +4 -10
  243. package/build/hooks/min-height.js.map +1 -1
  244. package/build/hooks/use-typography-props.js +11 -8
  245. package/build/hooks/use-typography-props.js.map +1 -1
  246. package/build/store/reducer.js +411 -274
  247. package/build/store/reducer.js.map +1 -1
  248. package/build/store/selectors.js +58 -48
  249. package/build/store/selectors.js.map +1 -1
  250. package/build/utils/pasting.js +6 -11
  251. package/build/utils/pasting.js.map +1 -1
  252. package/build/utils/sorting.js +63 -0
  253. package/build/utils/sorting.js.map +1 -0
  254. package/build-module/autocompleters/block.js +2 -6
  255. package/build-module/autocompleters/block.js.map +1 -1
  256. package/build-module/autocompleters/link.js +2 -0
  257. package/build-module/autocompleters/link.js.map +1 -1
  258. package/build-module/components/alignment-control/ui.js +1 -6
  259. package/build-module/components/alignment-control/ui.js.map +1 -1
  260. package/build-module/components/block-alignment-control/use-available-alignments.js +4 -3
  261. package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
  262. package/build-module/components/block-card/index.js +45 -3
  263. package/build-module/components/block-card/index.js.map +1 -1
  264. package/build-module/components/block-draggable/index.native.js +40 -31
  265. package/build-module/components/block-draggable/index.native.js.map +1 -1
  266. package/build-module/components/block-edit/edit.js +4 -2
  267. package/build-module/components/block-edit/edit.js.map +1 -1
  268. package/build-module/components/block-edit/edit.native.js +4 -6
  269. package/build-module/components/block-edit/edit.native.js.map +1 -1
  270. package/build-module/components/block-icon/index.js +4 -2
  271. package/build-module/components/block-icon/index.js.map +1 -1
  272. package/build-module/components/block-inspector/index.js +87 -34
  273. package/build-module/components/block-inspector/index.js.map +1 -1
  274. package/build-module/components/block-list/block-list-context.native.js +5 -8
  275. package/build-module/components/block-list/block-list-context.native.js.map +1 -1
  276. package/build-module/components/block-list/block.js +55 -25
  277. package/build-module/components/block-list/block.js.map +1 -1
  278. package/build-module/components/block-list/block.native.js +61 -28
  279. package/build-module/components/block-list/block.native.js.map +1 -1
  280. package/build-module/components/block-list-appender/index.js +46 -34
  281. package/build-module/components/block-list-appender/index.js.map +1 -1
  282. package/build-module/components/block-list-appender/index.native.js +39 -32
  283. package/build-module/components/block-list-appender/index.native.js.map +1 -1
  284. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +31 -24
  285. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  286. package/build-module/components/block-mobile-toolbar/index.native.js +1 -1
  287. package/build-module/components/block-mobile-toolbar/index.native.js.map +1 -1
  288. package/build-module/components/block-pattern-setup/index.js +16 -8
  289. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  290. package/build-module/components/block-patterns-list/index.js +35 -13
  291. package/build-module/components/block-patterns-list/index.js.map +1 -1
  292. package/build-module/components/block-preview/auto.js +9 -3
  293. package/build-module/components/block-preview/auto.js.map +1 -1
  294. package/build-module/components/block-preview/index.js +5 -8
  295. package/build-module/components/block-preview/index.js.map +1 -1
  296. package/build-module/components/block-settings-menu/block-settings-dropdown.js +5 -2
  297. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  298. package/build-module/components/block-styles/index.native.js +1 -2
  299. package/build-module/components/block-styles/index.native.js.map +1 -1
  300. package/build-module/components/block-styles/utils.js +7 -9
  301. package/build-module/components/block-styles/utils.js.map +1 -1
  302. package/build-module/components/block-toolbar/index.js +6 -2
  303. package/build-module/components/block-toolbar/index.js.map +1 -1
  304. package/build-module/components/block-toolbar/index.native.js +6 -8
  305. package/build-module/components/block-toolbar/index.native.js.map +1 -1
  306. package/build-module/components/block-tools/insertion-point.js +8 -49
  307. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  308. package/build-module/components/block-tools/selected-block-popover.js +1 -2
  309. package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
  310. package/build-module/components/block-variation-picker/index.js +2 -3
  311. package/build-module/components/block-variation-picker/index.js.map +1 -1
  312. package/build-module/components/colors/utils.js +3 -7
  313. package/build-module/components/colors/utils.js.map +1 -1
  314. package/build-module/components/colors-gradients/control.js +0 -3
  315. package/build-module/components/colors-gradients/control.js.map +1 -1
  316. package/build-module/components/colors-gradients/dropdown.js +0 -2
  317. package/build-module/components/colors-gradients/dropdown.js.map +1 -1
  318. package/build-module/components/colors-gradients/panel-color-gradient-settings.js +4 -19
  319. package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  320. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -2
  321. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
  322. package/build-module/components/copy-handler/index.js +38 -10
  323. package/build-module/components/copy-handler/index.js.map +1 -1
  324. package/build-module/components/font-sizes/fluid-utils.js +5 -2
  325. package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
  326. package/build-module/components/font-sizes/utils.js +11 -5
  327. package/build-module/components/font-sizes/utils.js.map +1 -1
  328. package/build-module/components/font-sizes/with-font-sizes.js +12 -7
  329. package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
  330. package/build-module/components/gradients/use-gradient.js +2 -7
  331. package/build-module/components/gradients/use-gradient.js.map +1 -1
  332. package/build-module/components/height-control/index.js +103 -0
  333. package/build-module/components/height-control/index.js.map +1 -0
  334. package/build-module/components/iframe/index.js +21 -101
  335. package/build-module/components/iframe/index.js.map +1 -1
  336. package/build-module/components/iframe/use-compatibility-styles.js +85 -0
  337. package/build-module/components/iframe/use-compatibility-styles.js.map +1 -0
  338. package/build-module/components/image-editor/use-save-image.js +2 -0
  339. package/build-module/components/image-editor/use-save-image.js.map +1 -1
  340. package/build-module/components/image-editor/zoom-dropdown.js +1 -0
  341. package/build-module/components/image-editor/zoom-dropdown.js.map +1 -1
  342. package/build-module/components/index.js +1 -0
  343. package/build-module/components/index.js.map +1 -1
  344. package/build-module/components/inner-blocks/index.js +27 -9
  345. package/build-module/components/inner-blocks/index.js.map +1 -1
  346. package/build-module/components/inner-blocks/use-inner-block-template-sync.js +23 -10
  347. package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  348. package/build-module/components/inserter/block-patterns-explorer/sidebar.js +1 -0
  349. package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
  350. package/build-module/components/inserter/block-patterns-tab.js +27 -49
  351. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  352. package/build-module/components/inserter/block-types-tab.js +3 -2
  353. package/build-module/components/inserter/block-types-tab.js.map +1 -1
  354. package/build-module/components/inserter/hooks/use-debounced-input.js +18 -0
  355. package/build-module/components/inserter/hooks/use-debounced-input.js.map +1 -0
  356. package/build-module/components/inserter/hooks/use-insertion-point.js +4 -3
  357. package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
  358. package/build-module/components/inserter/index.js +20 -6
  359. package/build-module/components/inserter/index.js.map +1 -1
  360. package/build-module/components/inserter/index.native.js +3 -5
  361. package/build-module/components/inserter/index.native.js.map +1 -1
  362. package/build-module/components/inserter/media-tab/hooks.js +92 -0
  363. package/build-module/components/inserter/media-tab/hooks.js.map +1 -0
  364. package/build-module/components/inserter/media-tab/index.js +4 -0
  365. package/build-module/components/inserter/media-tab/index.js.map +1 -0
  366. package/build-module/components/inserter/media-tab/media-list.js +86 -0
  367. package/build-module/components/inserter/media-tab/media-list.js.map +1 -0
  368. package/build-module/components/inserter/media-tab/media-panel.js +77 -0
  369. package/build-module/components/inserter/media-tab/media-panel.js.map +1 -0
  370. package/build-module/components/inserter/media-tab/media-tab.js +100 -0
  371. package/build-module/components/inserter/media-tab/media-tab.js.map +1 -0
  372. package/build-module/components/inserter/media-tab/utils.js +45 -0
  373. package/build-module/components/inserter/media-tab/utils.js.map +1 -0
  374. package/build-module/components/inserter/menu.js +33 -12
  375. package/build-module/components/inserter/menu.js.map +1 -1
  376. package/build-module/components/inserter/mobile-tab-navigation.js +61 -0
  377. package/build-module/components/inserter/mobile-tab-navigation.js.map +1 -0
  378. package/build-module/components/inserter/quick-inserter.js +7 -3
  379. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  380. package/build-module/components/inserter/search-items.js +15 -13
  381. package/build-module/components/inserter/search-items.js.map +1 -1
  382. package/build-module/components/inserter/search-results.js +7 -4
  383. package/build-module/components/inserter/search-results.js.map +1 -1
  384. package/build-module/components/inserter/tabs.js +15 -2
  385. package/build-module/components/inserter/tabs.js.map +1 -1
  386. package/build-module/components/inserter-list-item/index.js +5 -2
  387. package/build-module/components/inserter-list-item/index.js.map +1 -1
  388. package/build-module/components/inspector-controls/groups.js +2 -0
  389. package/build-module/components/inspector-controls/groups.js.map +1 -1
  390. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js +32 -0
  391. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
  392. package/build-module/components/inspector-controls-tabs/index.js +56 -0
  393. package/build-module/components/inspector-controls-tabs/index.js.map +1 -0
  394. package/build-module/components/inspector-controls-tabs/settings-tab.js +17 -0
  395. package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -0
  396. package/build-module/components/inspector-controls-tabs/styles-tab.js +46 -0
  397. package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -0
  398. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +81 -0
  399. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
  400. package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +8 -0
  401. package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
  402. package/build-module/components/inspector-controls-tabs/utils.js +26 -0
  403. package/build-module/components/inspector-controls-tabs/utils.js.map +1 -0
  404. package/build-module/components/link-control/index.js +1 -0
  405. package/build-module/components/link-control/index.js.map +1 -1
  406. package/build-module/components/link-control/search-input.js +0 -1
  407. package/build-module/components/link-control/search-input.js.map +1 -1
  408. package/build-module/components/link-control/use-internal-input-value.js +3 -3
  409. package/build-module/components/link-control/use-internal-input-value.js.map +1 -1
  410. package/build-module/components/list-view/block-select-button.js +1 -1
  411. package/build-module/components/list-view/block-select-button.js.map +1 -1
  412. package/build-module/components/list-view/block.js +5 -2
  413. package/build-module/components/list-view/block.js.map +1 -1
  414. package/build-module/components/list-view/branch.js +12 -11
  415. package/build-module/components/list-view/branch.js.map +1 -1
  416. package/build-module/components/media-upload/index.native.js +2 -4
  417. package/build-module/components/media-upload/index.native.js.map +1 -1
  418. package/build-module/components/off-canvas-editor/appender.js +83 -0
  419. package/build-module/components/off-canvas-editor/appender.js.map +1 -0
  420. package/build-module/components/off-canvas-editor/block-edit-button.js +35 -0
  421. package/build-module/components/off-canvas-editor/block-edit-button.js.map +1 -0
  422. package/build-module/components/off-canvas-editor/block-select-button.js +3 -2
  423. package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -1
  424. package/build-module/components/off-canvas-editor/block.js +83 -41
  425. package/build-module/components/off-canvas-editor/block.js.map +1 -1
  426. package/build-module/components/off-canvas-editor/branch.js +3 -4
  427. package/build-module/components/off-canvas-editor/branch.js.map +1 -1
  428. package/build-module/components/off-canvas-editor/index.js +24 -12
  429. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  430. package/build-module/components/off-canvas-editor/leaf.js +1 -1
  431. package/build-module/components/off-canvas-editor/leaf.js.map +1 -1
  432. package/build-module/components/off-canvas-editor/link-ui.js +165 -0
  433. package/build-module/components/off-canvas-editor/link-ui.js.map +1 -0
  434. package/build-module/components/off-canvas-editor/update-attributes.js +97 -0
  435. package/build-module/components/off-canvas-editor/update-attributes.js.map +1 -0
  436. package/build-module/components/off-canvas-editor/use-inserted-block.js +47 -0
  437. package/build-module/components/off-canvas-editor/use-inserted-block.js.map +1 -0
  438. package/build-module/components/responsive-block-control/label.js +1 -2
  439. package/build-module/components/responsive-block-control/label.js.map +1 -1
  440. package/build-module/components/rich-text/format-edit.js +12 -9
  441. package/build-module/components/rich-text/format-edit.js.map +1 -1
  442. package/build-module/components/rich-text/format-toolbar/index.js +6 -2
  443. package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
  444. package/build-module/components/rich-text/index.js +2 -3
  445. package/build-module/components/rich-text/index.js.map +1 -1
  446. package/build-module/components/rich-text/index.native.js +0 -2
  447. package/build-module/components/rich-text/index.native.js.map +1 -1
  448. package/build-module/components/rich-text/use-insert-replacement-text.js +33 -0
  449. package/build-module/components/rich-text/use-insert-replacement-text.js.map +1 -0
  450. package/build-module/components/rich-text/use-paste-handler.js +22 -12
  451. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  452. package/build-module/components/rich-text/use-undo-automatic-change.js +9 -1
  453. package/build-module/components/rich-text/use-undo-automatic-change.js.map +1 -1
  454. package/build-module/components/rich-text/utils.js +1 -16
  455. package/build-module/components/rich-text/utils.js.map +1 -1
  456. package/build-module/components/spacing-sizes-control/index.js +0 -1
  457. package/build-module/components/spacing-sizes-control/index.js.map +1 -1
  458. package/build-module/components/spacing-sizes-control/spacing-input-control.js +12 -3
  459. package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  460. package/build-module/components/spacing-sizes-control/utils.js +1 -1
  461. package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
  462. package/build-module/components/typewriter/index.js +1 -1
  463. package/build-module/components/typewriter/index.js.map +1 -1
  464. package/build-module/components/ungroup-button/index.native.js +3 -2
  465. package/build-module/components/ungroup-button/index.native.js.map +1 -1
  466. package/build-module/components/url-input/index.js +46 -43
  467. package/build-module/components/url-input/index.js.map +1 -1
  468. package/build-module/components/url-popover/image-url-input-ui.js +3 -3
  469. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  470. package/build-module/components/use-block-display-information/index.js +9 -5
  471. package/build-module/components/use-block-display-information/index.js.map +1 -1
  472. package/build-module/components/use-setting/index.js +8 -1
  473. package/build-module/components/use-setting/index.js.map +1 -1
  474. package/build-module/components/writing-flow/index.js +1 -1
  475. package/build-module/components/writing-flow/index.js.map +1 -1
  476. package/build-module/hooks/border.js +0 -1
  477. package/build-module/hooks/border.js.map +1 -1
  478. package/build-module/hooks/child-layout.js +189 -0
  479. package/build-module/hooks/child-layout.js.map +1 -0
  480. package/build-module/hooks/color-panel.js +0 -1
  481. package/build-module/hooks/color-panel.js.map +1 -1
  482. package/build-module/hooks/color.js +1 -2
  483. package/build-module/hooks/color.js.map +1 -1
  484. package/build-module/hooks/content-lock-ui.js +1 -1
  485. package/build-module/hooks/content-lock-ui.js.map +1 -1
  486. package/build-module/hooks/dimensions.js +25 -8
  487. package/build-module/hooks/dimensions.js.map +1 -1
  488. package/build-module/hooks/font-family.js +5 -5
  489. package/build-module/hooks/font-family.js.map +1 -1
  490. package/build-module/hooks/font-size.js +5 -3
  491. package/build-module/hooks/font-size.js.map +1 -1
  492. package/build-module/hooks/layout.js +55 -0
  493. package/build-module/hooks/layout.js.map +1 -1
  494. package/build-module/hooks/min-height.js +3 -9
  495. package/build-module/hooks/min-height.js.map +1 -1
  496. package/build-module/hooks/use-typography-props.js +11 -8
  497. package/build-module/hooks/use-typography-props.js.map +1 -1
  498. package/build-module/store/reducer.js +409 -274
  499. package/build-module/store/reducer.js.map +1 -1
  500. package/build-module/store/selectors.js +55 -48
  501. package/build-module/store/selectors.js.map +1 -1
  502. package/build-module/utils/pasting.js +6 -10
  503. package/build-module/utils/pasting.js.map +1 -1
  504. package/build-module/utils/sorting.js +56 -0
  505. package/build-module/utils/sorting.js.map +1 -0
  506. package/build-style/content-rtl.css +701 -0
  507. package/build-style/content.css +701 -0
  508. package/build-style/default-editor-styles-rtl.css +17 -3
  509. package/build-style/default-editor-styles.css +17 -3
  510. package/build-style/style-rtl.css +313 -665
  511. package/build-style/style.css +313 -665
  512. package/package.json +32 -30
  513. package/src/autocompleters/block.js +2 -6
  514. package/src/autocompleters/link.js +2 -0
  515. package/src/components/alignment-control/test/index.js +6 -1
  516. package/src/components/alignment-control/ui.js +1 -7
  517. package/src/components/block-alignment-control/test/index.js +6 -1
  518. package/src/components/block-alignment-control/use-available-alignments.js +4 -3
  519. package/src/components/block-card/index.js +46 -2
  520. package/src/components/block-card/style.scss +4 -0
  521. package/src/components/block-content-overlay/{style.scss → content.scss} +7 -1
  522. package/src/components/block-draggable/content.scss +20 -0
  523. package/src/components/block-draggable/index.native.js +54 -40
  524. package/src/components/block-draggable/style.scss +0 -21
  525. package/src/components/block-draggable/test/helpers.native.js +7 -9
  526. package/src/components/block-draggable/test/index.native.js +35 -45
  527. package/src/components/block-edit/edit.js +5 -2
  528. package/src/components/block-edit/edit.native.js +5 -6
  529. package/src/components/block-icon/index.js +4 -2
  530. package/src/components/block-icon/test/index.js +9 -5
  531. package/src/components/block-inspector/index.js +173 -85
  532. package/src/components/block-inspector/style.scss +16 -1
  533. package/src/components/block-list/block-list-context.native.js +5 -8
  534. package/src/components/block-list/block.js +74 -23
  535. package/src/components/block-list/block.native.js +78 -23
  536. package/src/components/block-list/{style.scss → content.scss} +1 -15
  537. package/src/components/block-list-appender/{style.scss → content.scss} +0 -0
  538. package/src/components/block-list-appender/index.js +65 -54
  539. package/src/components/block-list-appender/index.native.js +45 -34
  540. package/src/components/block-mobile-toolbar/block-actions-menu.native.js +42 -28
  541. package/src/components/block-mobile-toolbar/index.native.js +1 -1
  542. package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +125 -0
  543. package/src/components/block-mobile-toolbar/test/block-actions-menu.native.js +439 -0
  544. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +42 -2
  545. package/src/components/block-mover/test/index.native.js +157 -1
  546. package/src/components/block-pattern-setup/index.js +17 -7
  547. package/src/components/block-pattern-setup/style.scss +29 -1
  548. package/src/components/block-patterns-list/index.js +47 -24
  549. package/src/components/block-preview/README.md +15 -10
  550. package/src/components/block-preview/auto.js +7 -1
  551. package/src/components/block-preview/content.scss +4 -0
  552. package/src/components/block-preview/index.js +7 -12
  553. package/src/components/block-preview/style.scss +0 -7
  554. package/src/components/block-preview/test/index.js +18 -35
  555. package/src/components/block-selection-clearer/test/index.js +12 -12
  556. package/src/components/block-settings-menu/block-settings-dropdown.js +32 -20
  557. package/src/components/block-styles/index.native.js +1 -2
  558. package/src/components/block-styles/utils.js +5 -7
  559. package/src/components/block-switcher/test/index.js +6 -1
  560. package/src/components/block-toolbar/index.js +12 -5
  561. package/src/components/block-toolbar/index.native.js +8 -11
  562. package/src/components/block-toolbar/style.scss +10 -0
  563. package/src/components/block-tools/insertion-point.js +3 -47
  564. package/src/components/block-tools/selected-block-popover.js +1 -3
  565. package/src/components/block-tools/style.scss +12 -5
  566. package/src/components/block-variation-picker/index.js +6 -5
  567. package/src/components/block-vertical-alignment-control/test/index.js +6 -1
  568. package/src/components/colors/test/with-colors.js +2 -0
  569. package/src/components/colors/utils.js +5 -3
  570. package/src/components/colors-gradients/control.js +0 -7
  571. package/src/components/colors-gradients/dropdown.js +0 -2
  572. package/src/components/colors-gradients/panel-color-gradient-settings.js +4 -22
  573. package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -2
  574. package/src/components/copy-handler/index.js +53 -7
  575. package/src/components/default-block-appender/{style.scss → content.scss} +0 -0
  576. package/src/components/default-block-appender/test/index.js +2 -0
  577. package/src/components/font-sizes/fluid-utils.js +7 -1
  578. package/src/components/font-sizes/utils.js +5 -3
  579. package/src/components/font-sizes/with-font-sizes.js +4 -4
  580. package/src/components/gradients/use-gradient.js +2 -7
  581. package/src/components/height-control/index.js +123 -0
  582. package/src/components/height-control/stories/index.js +21 -0
  583. package/src/components/height-control/style.scss +5 -0
  584. package/src/components/iframe/index.js +33 -121
  585. package/src/components/iframe/use-compatibility-styles.js +95 -0
  586. package/src/components/image-editor/use-save-image.js +2 -0
  587. package/src/components/image-editor/zoom-dropdown.js +1 -0
  588. package/src/components/image-size-control/test/index.js +147 -79
  589. package/src/components/index.js +1 -0
  590. package/src/components/inner-blocks/{style.scss → content.scss} +0 -0
  591. package/src/components/inner-blocks/index.js +26 -7
  592. package/src/components/inner-blocks/use-inner-block-template-sync.js +28 -10
  593. package/src/components/inserter/block-patterns-explorer/sidebar.js +1 -0
  594. package/src/components/inserter/block-patterns-tab.js +28 -71
  595. package/src/components/inserter/block-types-tab.js +3 -2
  596. package/src/components/inserter/hooks/use-debounced-input.js +17 -0
  597. package/src/components/inserter/hooks/use-insertion-point.js +3 -2
  598. package/src/components/inserter/index.js +24 -3
  599. package/src/components/inserter/index.native.js +1 -1
  600. package/src/components/inserter/media-tab/hooks.js +89 -0
  601. package/src/components/inserter/media-tab/index.js +3 -0
  602. package/src/components/inserter/media-tab/media-list.js +93 -0
  603. package/src/components/inserter/media-tab/media-panel.js +83 -0
  604. package/src/components/inserter/media-tab/media-tab.js +135 -0
  605. package/src/components/inserter/media-tab/utils.js +37 -0
  606. package/src/components/inserter/menu.js +55 -13
  607. package/src/components/inserter/mobile-tab-navigation.js +85 -0
  608. package/src/components/inserter/quick-inserter.js +4 -0
  609. package/src/components/inserter/search-items.js +1 -2
  610. package/src/components/inserter/search-results.js +5 -2
  611. package/src/components/inserter/stories/index.js +1 -1
  612. package/src/components/inserter/stories/{fixtures.js → utils/fixtures.js} +0 -0
  613. package/src/components/inserter/style.scss +176 -11
  614. package/src/components/inserter/tabs.js +12 -1
  615. package/src/components/inserter-list-item/index.js +11 -1
  616. package/src/components/inserter-list-item/style.scss +26 -0
  617. package/src/components/inspector-controls/groups.js +2 -0
  618. package/src/components/inspector-controls-tabs/advanced-controls-panel.js +37 -0
  619. package/src/components/inspector-controls-tabs/index.js +62 -0
  620. package/src/components/inspector-controls-tabs/settings-tab.js +18 -0
  621. package/src/components/inspector-controls-tabs/styles-tab.js +51 -0
  622. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +89 -0
  623. package/src/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +9 -0
  624. package/src/components/inspector-controls-tabs/utils.js +28 -0
  625. package/src/components/line-height-control/test/index.js +5 -5
  626. package/src/components/link-control/README.md +1 -1
  627. package/src/components/link-control/index.js +1 -0
  628. package/src/components/link-control/search-input.js +0 -1
  629. package/src/components/link-control/test/index.js +204 -403
  630. package/src/components/link-control/use-internal-input-value.js +3 -3
  631. package/src/components/list-view/block-select-button.js +1 -1
  632. package/src/components/list-view/block.js +3 -0
  633. package/src/components/list-view/branch.js +10 -8
  634. package/src/components/list-view/style.scss +21 -16
  635. package/src/components/media-placeholder/{style.scss → content.scss} +0 -0
  636. package/src/components/media-replace-flow/test/index.js +39 -9
  637. package/src/components/media-upload/test/index.native.js +2 -0
  638. package/src/components/off-canvas-editor/appender.js +98 -0
  639. package/src/components/off-canvas-editor/block-edit-button.js +27 -0
  640. package/src/components/off-canvas-editor/block-select-button.js +6 -2
  641. package/src/components/off-canvas-editor/block.js +160 -77
  642. package/src/components/off-canvas-editor/branch.js +3 -5
  643. package/src/components/off-canvas-editor/index.js +68 -33
  644. package/src/components/off-canvas-editor/leaf.js +5 -1
  645. package/src/components/off-canvas-editor/link-ui.js +166 -0
  646. package/src/components/off-canvas-editor/style.scss +19 -386
  647. package/src/components/off-canvas-editor/test/use-inserted-block.js +108 -0
  648. package/src/components/off-canvas-editor/update-attributes.js +99 -0
  649. package/src/components/off-canvas-editor/use-inserted-block.js +47 -0
  650. package/src/components/plain-text/{style.scss → content.scss} +0 -0
  651. package/src/components/recursion-provider/test/index.js +27 -29
  652. package/src/components/responsive-block-control/label.js +2 -3
  653. package/src/components/responsive-block-control/test/index.js +4 -2
  654. package/src/components/rich-text/content.scss +42 -0
  655. package/src/components/rich-text/format-edit.js +6 -10
  656. package/src/components/rich-text/format-toolbar/index.js +6 -4
  657. package/src/components/rich-text/index.js +3 -2
  658. package/src/components/rich-text/index.native.js +0 -2
  659. package/src/components/rich-text/style.scss +0 -43
  660. package/src/components/rich-text/use-insert-replacement-text.js +31 -0
  661. package/src/components/rich-text/use-paste-handler.js +33 -14
  662. package/src/components/rich-text/use-undo-automatic-change.js +7 -1
  663. package/src/components/rich-text/utils.js +2 -21
  664. package/src/components/spacing-sizes-control/index.js +0 -1
  665. package/src/components/spacing-sizes-control/spacing-input-control.js +9 -0
  666. package/src/components/spacing-sizes-control/utils.js +1 -1
  667. package/src/components/typewriter/index.js +3 -1
  668. package/src/components/ungroup-button/index.native.js +6 -2
  669. package/src/components/url-input/index.js +57 -73
  670. package/src/components/url-input/test/button.js +2 -0
  671. package/src/components/url-popover/image-url-input-ui.js +5 -4
  672. package/src/components/url-popover/test/__snapshots__/index.js.snap +8 -6
  673. package/src/components/url-popover/test/index.js +37 -9
  674. package/src/components/use-block-display-information/index.js +14 -5
  675. package/src/components/use-setting/index.js +13 -1
  676. package/src/components/use-setting/test/index.js +99 -0
  677. package/src/components/warning/test/index.js +2 -0
  678. package/src/components/writing-flow/index.js +1 -1
  679. package/src/content.scss +10 -0
  680. package/src/hooks/border.js +0 -1
  681. package/src/hooks/child-layout.js +190 -0
  682. package/src/hooks/color-panel.js +0 -1
  683. package/src/hooks/color.js +0 -2
  684. package/src/hooks/content-lock-ui.js +1 -1
  685. package/src/hooks/dimensions.js +45 -7
  686. package/src/hooks/font-family.js +3 -5
  687. package/src/hooks/font-size.js +13 -4
  688. package/src/hooks/layout.js +60 -0
  689. package/src/hooks/min-height.js +2 -19
  690. package/src/hooks/test/use-typography-props.js +26 -0
  691. package/src/hooks/use-typography-props.js +15 -7
  692. package/src/store/reducer.js +471 -428
  693. package/src/store/selectors.js +57 -59
  694. package/src/store/test/performance.js +71 -0
  695. package/src/store/test/reducer.js +623 -491
  696. package/src/store/test/selectors.js +1820 -1306
  697. package/src/style.scss +4 -7
  698. package/src/utils/pasting.js +3 -9
  699. package/src/utils/sorting.js +54 -0
  700. package/src/utils/test/sorting.js +49 -0
  701. package/tsconfig.tsbuildinfo +1 -1
  702. package/build/components/block-preview/live.js +0 -30
  703. package/build/components/block-preview/live.js.map +0 -1
  704. package/build/components/colors-gradients/use-common-single-multiple-selects.js +0 -21
  705. package/build/components/colors-gradients/use-common-single-multiple-selects.js.map +0 -1
  706. package/build/components/rich-text/file-paste-handler.js +0 -21
  707. package/build/components/rich-text/file-paste-handler.js.map +0 -1
  708. package/build-module/components/block-preview/live.js +0 -20
  709. package/build-module/components/block-preview/live.js.map +0 -1
  710. package/build-module/components/colors-gradients/use-common-single-multiple-selects.js +0 -11
  711. package/build-module/components/colors-gradients/use-common-single-multiple-selects.js.map +0 -1
  712. package/build-module/components/rich-text/file-paste-handler.js +0 -13
  713. package/build-module/components/rich-text/file-paste-handler.js.map +0 -1
  714. package/src/components/block-preview/live.js +0 -19
  715. package/src/components/colors-gradients/use-common-single-multiple-selects.js +0 -11
  716. package/src/components/rich-text/file-paste-handler.js +0 -13
@@ -1,18 +1,21 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { act, fireEvent, render, screen, within } from '@testing-library/react';
4
+ import {
5
+ fireEvent,
6
+ render,
7
+ screen,
8
+ waitFor,
9
+ within,
10
+ } from '@testing-library/react';
5
11
  import userEvent from '@testing-library/user-event';
6
12
 
7
13
  /**
8
14
  * WordPress dependencies
9
15
  */
10
16
  import { useState } from '@wordpress/element';
11
-
12
- /**
13
- * WordPress dependencies
14
- */
15
17
  import { useSelect } from '@wordpress/data';
18
+
16
19
  /**
17
20
  * Internal dependencies
18
21
  */
@@ -23,14 +26,6 @@ import {
23
26
  uniqueId,
24
27
  } from './fixtures';
25
28
 
26
- // Mock debounce() so that it runs instantly.
27
- jest.mock( '@wordpress/compose/src/utils/debounce', () => ( {
28
- debounce: ( fn ) => {
29
- fn.cancel = jest.fn();
30
- return fn;
31
- },
32
- } ) );
33
-
34
29
  const mockFetchSearchSuggestions = jest.fn();
35
30
 
36
31
  /**
@@ -58,18 +53,6 @@ jest.mock( '@wordpress/data/src/components/use-dispatch', () => ( {
58
53
 
59
54
  jest.useRealTimers();
60
55
 
61
- /**
62
- * Wait for next tick of event loop. This is required
63
- * because the `fetchSearchSuggestions` Promise will
64
- * resolve on the next tick of the event loop (this is
65
- * inline with the Promise spec). As a result we need to
66
- * wait on this loop to "tick" before we can expect the UI
67
- * to have updated.
68
- */
69
- function eventLoopTick() {
70
- return new Promise( ( resolve ) => setImmediate( resolve ) );
71
- }
72
-
73
56
  beforeEach( () => {
74
57
  // Setup a DOM element as a render target.
75
58
  mockFetchSearchSuggestions.mockImplementation( fetchFauxEntitySuggestions );
@@ -186,8 +169,7 @@ describe( 'Basic rendering', () => {
186
169
  const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
187
170
 
188
171
  // Simulate searching for a term.
189
- searchInput.focus();
190
- await user.keyboard( searchTerm );
172
+ await user.type( searchInput, searchTerm );
191
173
 
192
174
  expect( screen.queryByText( '://' ) ).not.toBeInTheDocument();
193
175
  } );
@@ -289,6 +271,7 @@ describe( 'Basic rendering', () => {
289
271
  it( 'should show "Unlink" button if a onRemove handler is provided', async () => {
290
272
  const user = userEvent.setup();
291
273
  const mockOnRemove = jest.fn();
274
+
292
275
  render(
293
276
  <LinkControl
294
277
  value={ { url: 'https://example.com' } }
@@ -314,13 +297,12 @@ describe( 'Searching for a link', () => {
314
297
  const searchTerm = 'Hello';
315
298
 
316
299
  let resolver;
317
-
318
- const fauxRequest = () =>
319
- new Promise( ( resolve ) => {
320
- resolver = resolve;
321
- } );
322
-
323
- mockFetchSearchSuggestions.mockImplementation( fauxRequest );
300
+ mockFetchSearchSuggestions.mockImplementation(
301
+ () =>
302
+ new Promise( ( resolve ) => {
303
+ resolver = resolve;
304
+ } )
305
+ );
324
306
 
325
307
  render( <LinkControl /> );
326
308
 
@@ -328,35 +310,22 @@ describe( 'Searching for a link', () => {
328
310
  const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
329
311
 
330
312
  // Simulate searching for a term.
331
- searchInput.focus();
332
- await user.keyboard( searchTerm );
313
+ await user.type( searchInput, searchTerm );
333
314
 
334
- // fetchFauxEntitySuggestions resolves on next "tick" of event loop.
335
- await eventLoopTick();
315
+ expect( await screen.findByRole( 'presentation' ) ).toBeVisible();
316
+ expect( screen.queryByRole( 'listbox' ) ).not.toBeInTheDocument();
336
317
 
337
- const searchResultsField = screen.queryByRole( 'listbox' );
338
-
339
- let loadingUI = screen.queryByRole( 'presentation' );
340
-
341
- expect( searchResultsField ).not.toBeInTheDocument();
342
-
343
- expect( loadingUI ).toBeVisible();
318
+ // make the search suggestions fetch return a response
319
+ resolver( fauxEntitySuggestions );
344
320
 
345
- act( () => {
346
- resolver( fauxEntitySuggestions );
347
- } );
348
-
349
- await eventLoopTick();
350
-
351
- loadingUI = screen.queryByRole( 'presentation' );
352
-
353
- expect( loadingUI ).not.toBeInTheDocument();
321
+ expect( await screen.findByRole( 'listbox' ) ).toBeVisible();
322
+ expect( screen.queryByRole( 'presentation' ) ).not.toBeInTheDocument();
354
323
  } );
355
324
 
356
325
  it( 'should display only search suggestions when current input value is not URL-like', async () => {
357
326
  const user = userEvent.setup();
358
327
  const searchTerm = 'Hello world';
359
- const firstFauxSuggestion = fauxEntitySuggestions[ 0 ];
328
+ const firstSuggestion = fauxEntitySuggestions[ 0 ];
360
329
 
361
330
  render( <LinkControl /> );
362
331
 
@@ -364,14 +333,10 @@ describe( 'Searching for a link', () => {
364
333
  const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
365
334
 
366
335
  // Simulate searching for a term.
367
- searchInput.focus();
368
- await user.keyboard( searchTerm );
369
-
370
- // fetchFauxEntitySuggestions resolves on next "tick" of event loop.
371
- await eventLoopTick();
336
+ await user.type( searchInput, searchTerm );
372
337
 
373
338
  const searchResultElements = within(
374
- screen.getByRole( 'listbox', {
339
+ await screen.findByRole( 'listbox', {
375
340
  name: /Search results for.*/,
376
341
  } )
377
342
  ).getAllByRole( 'option' );
@@ -382,12 +347,12 @@ describe( 'Searching for a link', () => {
382
347
 
383
348
  expect( searchInput ).toHaveAttribute( 'aria-expanded', 'true' );
384
349
 
385
- // Sanity check that a search suggestion shows up corresponding to the data.
350
+ // Check that a search suggestion shows up corresponding to the data.
386
351
  expect( searchResultElements[ 0 ] ).toHaveTextContent(
387
- firstFauxSuggestion.title
352
+ firstSuggestion.title
388
353
  );
389
354
  expect( searchResultElements[ 0 ] ).toHaveTextContent(
390
- firstFauxSuggestion.type
355
+ firstSuggestion.type
391
356
  );
392
357
 
393
358
  // The fallback URL suggestion should not be shown when input is not URL-like.
@@ -400,34 +365,37 @@ describe( 'Searching for a link', () => {
400
365
  const user = userEvent.setup();
401
366
  const searchTerm = ' Hello ';
402
367
 
403
- const { container } = render( <LinkControl /> );
368
+ render( <LinkControl /> );
404
369
 
405
370
  // Search Input UI.
406
371
  const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
407
372
 
408
373
  // Simulate searching for a term.
409
- searchInput.focus();
410
- await user.keyboard( searchTerm );
411
-
412
- // fetchFauxEntitySuggestions resolves on next "tick" of event loop.
413
- await eventLoopTick();
374
+ await user.type( searchInput, searchTerm );
414
375
 
415
- const searchResultTextHighlightElements = Array.from(
416
- container.querySelectorAll(
417
- '[role="listbox"] button[role="option"] mark'
418
- )
419
- );
376
+ const searchResults = await screen.findByRole( 'listbox', {
377
+ name: /Search results for.*/,
378
+ } );
420
379
 
421
- const invalidResults = searchResultTextHighlightElements.find(
422
- ( mark ) => mark.innerHTML !== 'Hello'
423
- );
380
+ const searchResultTextHighlightElements = within( searchResults )
381
+ .getAllByRole( 'option' )
382
+ // TODO: Change to `getByRole( 'mark' )` when officially supported by
383
+ // WAI-ARIA 1.3 - see https://w3c.github.io/aria/#mark
384
+ // eslint-disable-next-line testing-library/no-node-access
385
+ .map( ( searchResult ) => searchResult.querySelector( 'mark' ) )
386
+ .flat()
387
+ .filter( Boolean );
424
388
 
425
389
  // Given we're mocking out the results we should always have 4 mark elements.
426
390
  expect( searchResultTextHighlightElements ).toHaveLength( 4 );
427
391
 
428
392
  // Make sure there are no `mark` elements which contain anything other
429
393
  // than the trimmed search term (ie: no whitespace).
430
- expect( invalidResults ).toBeFalsy();
394
+ expect(
395
+ searchResultTextHighlightElements.every(
396
+ ( mark ) => mark.innerHTML === 'Hello'
397
+ )
398
+ ).toBe( true );
431
399
 
432
400
  // Implementation detail test to ensure that the fetch handler is called
433
401
  // with the trimmed search value. We do this because we are mocking out
@@ -447,14 +415,10 @@ describe( 'Searching for a link', () => {
447
415
  const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
448
416
 
449
417
  // Simulate searching for a term.
450
- searchInput.focus();
451
- await user.keyboard( 'anything' );
418
+ await user.type( searchInput, 'anything' );
452
419
 
453
420
  const searchResultsField = screen.queryByRole( 'listbox' );
454
421
 
455
- // fetchFauxEntitySuggestions resolves on next "tick" of event loop.
456
- await eventLoopTick();
457
-
458
422
  expect( searchResultsField ).not.toBeInTheDocument();
459
423
  expect( mockFetchSearchSuggestions ).not.toHaveBeenCalled();
460
424
  } );
@@ -472,14 +436,10 @@ describe( 'Searching for a link', () => {
472
436
  const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
473
437
 
474
438
  // Simulate searching for a term.
475
- searchInput.focus();
476
- await user.keyboard( searchTerm );
477
-
478
- // fetchFauxEntitySuggestions resolves on next "tick" of event loop.
479
- await eventLoopTick();
439
+ await user.type( searchInput, searchTerm );
480
440
 
481
441
  const searchResultElements = within(
482
- screen.getByRole( 'listbox', {
442
+ await screen.findByRole( 'listbox', {
483
443
  name: /Search results for.*/,
484
444
  } )
485
445
  ).getAllByRole( 'option' );
@@ -510,14 +470,10 @@ describe( 'Searching for a link', () => {
510
470
  const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
511
471
 
512
472
  // Simulate searching for a term.
513
- searchInput.focus();
514
- await user.keyboard( 'couldbeurlorentitysearchterm' );
515
-
516
- // fetchFauxEntitySuggestions resolves on next "tick" of event loop.
517
- await eventLoopTick();
473
+ await user.type( searchInput, 'couldbeurlorentitysearchterm' );
518
474
 
519
475
  const searchResultElements = within(
520
- screen.getByRole( 'listbox', {
476
+ await screen.findByRole( 'listbox', {
521
477
  name: /Search results for.*/,
522
478
  } )
523
479
  ).getAllByRole( 'option' );
@@ -544,14 +500,10 @@ describe( 'Manual link entry', () => {
544
500
  const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
545
501
 
546
502
  // Simulate searching for a term.
547
- searchInput.focus();
548
- await user.keyboard( searchTerm );
549
-
550
- // fetchFauxEntitySuggestions resolves on next "tick" of event loop.
551
- await eventLoopTick();
503
+ await user.type( searchInput, searchTerm );
552
504
 
553
505
  const searchResultElements = within(
554
- screen.getByRole( 'listbox', {
506
+ await screen.findByRole( 'listbox', {
555
507
  name: /Search results for.*/,
556
508
  } )
557
509
  ).getByRole( 'option' );
@@ -584,29 +536,25 @@ describe( 'Manual link entry', () => {
584
536
  name: 'URL',
585
537
  } );
586
538
 
587
- let submitButton = screen.queryByRole( 'button', {
539
+ let submitButton = screen.getByRole( 'button', {
588
540
  name: 'Submit',
589
541
  } );
590
542
 
591
543
  expect( submitButton ).toBeDisabled();
592
544
  expect( submitButton ).toBeVisible();
593
545
 
594
- searchInput.focus();
595
546
  if ( searchString.length ) {
596
547
  // Simulate searching for a term.
597
- await user.keyboard( searchString );
548
+ await user.type( searchInput, searchString );
598
549
  } else {
599
550
  // Simulate clearing the search term.
600
- await userEvent.clear( searchInput );
551
+ await user.clear( searchInput );
601
552
  }
602
553
 
603
- // fetchFauxEntitySuggestions resolves on next "tick" of event loop.
604
- await eventLoopTick();
605
-
606
554
  // Attempt to submit the empty search value in the input.
607
555
  await user.keyboard( '[Enter]' );
608
556
 
609
- submitButton = screen.queryByRole( 'button', {
557
+ submitButton = screen.getByRole( 'button', {
610
558
  name: 'Submit',
611
559
  } );
612
560
 
@@ -637,18 +585,14 @@ describe( 'Manual link entry', () => {
637
585
  expect( submitButton ).toBeVisible();
638
586
 
639
587
  // Simulate searching for a term.
640
- searchInput.focus();
641
588
  if ( searchString.length ) {
642
589
  // Simulate searching for a term.
643
- await user.keyboard( searchString );
590
+ await user.type( searchInput, searchString );
644
591
  } else {
645
592
  // Simulate clearing the search term.
646
- await userEvent.clear( searchInput );
593
+ await user.clear( searchInput );
647
594
  }
648
595
 
649
- // fetchFauxEntitySuggestions resolves on next "tick" of event loop.
650
- await eventLoopTick();
651
-
652
596
  // Attempt to submit the empty search value in the input.
653
597
  await user.click( submitButton );
654
598
 
@@ -681,14 +625,10 @@ describe( 'Manual link entry', () => {
681
625
  } );
682
626
 
683
627
  // Simulate searching for a term.
684
- searchInput.focus();
685
- await user.keyboard( searchTerm );
686
-
687
- // fetchFauxEntitySuggestions resolves on next "tick" of event loop.
688
- await eventLoopTick();
628
+ await user.type( searchInput, searchTerm );
689
629
 
690
630
  const searchResultElements = within(
691
- screen.getByRole( 'listbox', {
631
+ await screen.findByRole( 'listbox', {
692
632
  name: /Search results for.*/,
693
633
  } )
694
634
  ).getByRole( 'option' );
@@ -706,14 +646,10 @@ describe( 'Manual link entry', () => {
706
646
 
707
647
  describe( 'Default search suggestions', () => {
708
648
  it( 'should display a list of initial search suggestions when there is no search value or suggestions', async () => {
709
- const expectedResultsLength = 3; // Set within `LinkControl`.
710
-
711
649
  render( <LinkControl showInitialSuggestions /> );
712
650
 
713
- await eventLoopTick();
714
-
715
651
  expect(
716
- screen.queryByRole( 'listbox', {
652
+ await screen.findByRole( 'listbox', {
717
653
  name: 'Recently updated',
718
654
  } )
719
655
  ).toBeVisible();
@@ -731,24 +667,16 @@ describe( 'Default search suggestions', () => {
731
667
  expect( mockFetchSearchSuggestions ).toHaveBeenCalledTimes( 1 );
732
668
 
733
669
  // Verify the search results already display the initial suggestions.
734
- expect( screen.queryAllByRole( 'option' ) ).toHaveLength(
735
- expectedResultsLength
736
- );
670
+ // `LinkControl` internally always limits the number of initial suggestions to 3.
671
+ expect( screen.queryAllByRole( 'option' ) ).toHaveLength( 3 );
737
672
  } );
738
673
 
739
674
  it( 'should not display initial suggestions when input value is present', async () => {
740
675
  const user = userEvent.setup();
741
676
 
742
- // Render with an initial value an ensure that no initial suggestions
743
- // are shown.
744
- render(
745
- <LinkControl
746
- showInitialSuggestions
747
- value={ fauxEntitySuggestions[ 0 ] }
748
- />
749
- );
750
-
751
- await eventLoopTick();
677
+ // Render with an initial value an ensure that no initial suggestions are shown.
678
+ const initialValue = fauxEntitySuggestions[ 0 ];
679
+ render( <LinkControl showInitialSuggestions value={ initialValue } /> );
752
680
 
753
681
  expect( mockFetchSearchSuggestions ).not.toHaveBeenCalled();
754
682
 
@@ -758,23 +686,21 @@ describe( 'Default search suggestions', () => {
758
686
  const currentLinkBtn = within( currentLinkUI ).getByRole( 'button', {
759
687
  name: 'Edit',
760
688
  } );
761
-
762
689
  await user.click( currentLinkBtn );
763
690
 
764
691
  const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
765
- searchInput.focus();
692
+ // Search input is set to the URL value.
693
+ expect( searchInput ).toHaveValue( initialValue.url );
766
694
 
767
- await eventLoopTick();
695
+ // Focus the search input to display suggestions
696
+ await user.click( searchInput );
768
697
 
769
698
  const searchResultElements = within(
770
- screen.getByRole( 'listbox', {
699
+ await screen.findByRole( 'listbox', {
771
700
  name: /Search results for.*/,
772
701
  } )
773
702
  ).getAllByRole( 'option' );
774
703
 
775
- // Search input is set to the URL value.
776
- expect( searchInput ).toHaveValue( fauxEntitySuggestions[ 0 ].url );
777
-
778
704
  // It should match any url that's like ?p= and also include a URL option.
779
705
  expect( searchResultElements ).toHaveLength( 5 );
780
706
 
@@ -789,63 +715,45 @@ describe( 'Default search suggestions', () => {
789
715
 
790
716
  render( <LinkControl showInitialSuggestions /> );
791
717
 
792
- let searchResultElements;
793
- let searchInput;
794
-
795
718
  // Search Input UI.
796
- searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
719
+ const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
797
720
 
798
721
  // Simulate searching for a term.
799
- searchInput.focus();
800
- await user.keyboard( searchTerm );
801
-
802
- // fetchFauxEntitySuggestions resolves on next "tick" of event loop.
803
- await eventLoopTick();
722
+ await user.type( searchInput, searchTerm );
804
723
 
805
724
  expect( searchInput ).toHaveValue( searchTerm );
806
725
 
807
- searchResultElements = within(
808
- screen.getByRole( 'listbox', {
809
- name: /Search results for.*/,
810
- } )
811
- ).getAllByRole( 'option' );
812
-
813
- // Delete the text.
814
- await userEvent.clear( searchInput );
726
+ const searchResultsList = await screen.findByRole( 'listbox', {
727
+ name: /Search results for.*/,
728
+ } );
815
729
 
816
- await eventLoopTick();
730
+ expect( searchResultsList ).toBeVisible();
817
731
 
818
- searchResultElements = within(
819
- screen.getByRole( 'listbox', {
820
- name: 'Recently updated',
821
- } )
822
- ).getAllByRole( 'option' );
732
+ expect(
733
+ within( searchResultsList ).getAllByRole( 'option' )
734
+ ).toHaveLength( 4 );
823
735
 
824
- searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
736
+ // Delete the text.
737
+ await userEvent.clear( searchInput );
825
738
 
826
739
  // Check the input is empty now.
827
740
  expect( searchInput ).toHaveValue( '' );
828
741
 
829
- expect(
830
- screen.queryByRole( 'listbox', {
831
- name: 'Recently updated',
832
- } )
833
- ).toBeVisible();
742
+ const initialResultsList = await screen.findByRole( 'listbox', {
743
+ name: 'Recently updated',
744
+ } );
834
745
 
835
- expect( searchResultElements ).toHaveLength( 3 );
746
+ expect(
747
+ within( initialResultsList ).getAllByRole( 'option' )
748
+ ).toHaveLength( 3 );
836
749
  } );
837
750
 
838
751
  it( 'should not display initial suggestions when there are no recently updated pages/posts', async () => {
839
- const noResults = [];
840
752
  // Force API returning empty results for recently updated Pages.
841
- mockFetchSearchSuggestions.mockImplementation( () =>
842
- Promise.resolve( noResults )
843
- );
753
+ mockFetchSearchSuggestions.mockImplementation( async () => [] );
844
754
 
845
755
  render( <LinkControl showInitialSuggestions /> );
846
756
 
847
- await eventLoopTick();
848
-
849
757
  const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
850
758
 
851
759
  const searchResultsField = screen.queryByRole( 'listbox', {
@@ -876,19 +784,15 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
876
784
  async ( entityNameText ) => {
877
785
  const user = userEvent.setup();
878
786
  let resolver;
879
- let resolvedEntity;
880
-
881
787
  const createSuggestion = ( title ) =>
882
788
  new Promise( ( resolve ) => {
883
- resolver = ( arg ) => {
884
- resolve( arg );
885
- };
886
- resolvedEntity = {
887
- title,
888
- id: 123,
889
- url: '/?p=123',
890
- type: 'page',
891
- };
789
+ resolver = () =>
790
+ resolve( {
791
+ title,
792
+ id: 123,
793
+ url: '/?p=123',
794
+ type: 'page',
795
+ } );
892
796
  } );
893
797
 
894
798
  const LinkControlConsumer = () => {
@@ -911,16 +815,15 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
911
815
  const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
912
816
 
913
817
  // Simulate searching for a term.
914
- searchInput.focus();
915
- await user.keyboard( entityNameText );
916
-
917
- await eventLoopTick();
818
+ await user.type( searchInput, entityNameText );
918
819
 
919
- const searchResultElements = screen.queryAllByRole( 'option' );
820
+ const searchResults = await screen.findByRole( 'listbox', {
821
+ name: /Search results for.*/,
822
+ } );
920
823
 
921
- const createButton = Array.from( searchResultElements ).filter(
922
- ( result ) => result.innerHTML.includes( 'Create:' )
923
- )[ 0 ];
824
+ const createButton = within( searchResults ).getByRole( 'option', {
825
+ name: /^Create:/,
826
+ } );
924
827
 
925
828
  expect( createButton ).toBeVisible();
926
829
  expect( createButton ).toHaveTextContent( entityNameText );
@@ -929,8 +832,6 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
929
832
  // resolution manually via the `resolver` reference.
930
833
  await user.click( createButton );
931
834
 
932
- await eventLoopTick();
933
-
934
835
  // Check for loading indicator.
935
836
  const loadingIndicator = screen.getByText( 'Creating…' );
936
837
  const currentLinkLabel =
@@ -943,13 +844,11 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
943
844
  );
944
845
 
945
846
  // Resolve the `createSuggestion` promise.
946
- await act( async () => {
947
- resolver( resolvedEntity );
948
- } );
949
-
950
- await eventLoopTick();
847
+ resolver();
951
848
 
952
- const currentLink = screen.getByLabelText( 'Currently selected' );
849
+ const currentLink = await screen.findByLabelText(
850
+ 'Currently selected'
851
+ );
953
852
 
954
853
  expect( currentLink ).toHaveTextContent( entityNameText );
955
854
  expect( currentLink ).toHaveTextContent( '/?p=123' );
@@ -983,25 +882,18 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
983
882
  const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
984
883
 
985
884
  // Simulate searching for a term.
986
- searchInput.focus();
987
- await user.keyboard( 'Some new page to create' );
988
-
989
- await eventLoopTick();
885
+ await user.type( searchInput, 'Some new page to create' );
990
886
 
991
- const searchResultElements = within(
992
- screen.getByRole( 'listbox', {
993
- name: /Search results for.*/,
994
- } )
995
- ).getAllByRole( 'option' );
887
+ const searchResults = await screen.findByRole( 'listbox', {
888
+ name: /Search results for.*/,
889
+ } );
996
890
 
997
- const createButton = Array.from( searchResultElements ).filter(
998
- ( result ) => result.innerHTML.includes( 'Create:' )
999
- )[ 0 ];
891
+ const createButton = within( searchResults ).getByRole( 'option', {
892
+ name: /^Create:/,
893
+ } );
1000
894
 
1001
895
  await user.click( createButton );
1002
896
 
1003
- await eventLoopTick();
1004
-
1005
897
  const currentLink = screen.getByLabelText( 'Currently selected' );
1006
898
 
1007
899
  expect( currentLink ).toHaveTextContent( 'Some new page to create' );
@@ -1039,33 +931,27 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
1039
931
  const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
1040
932
 
1041
933
  // Simulate searching for a term.
1042
- searchInput.focus();
1043
- await user.keyboard( entityNameText );
934
+ await user.type( searchInput, entityNameText );
1044
935
 
1045
- await eventLoopTick();
1046
-
1047
- const searchResultElements = within(
1048
- screen.getByRole( 'listbox', {
1049
- name: /Search results for.*/,
1050
- } )
1051
- ).getAllByRole( 'option' );
1052
- const createButton = Array.from( searchResultElements ).filter(
1053
- ( result ) => result.innerHTML.includes( 'Create:' )
1054
- )[ 0 ];
936
+ const searchResults = await screen.findByRole( 'listbox', {
937
+ name: /Search results for.*/,
938
+ } );
1055
939
 
1056
- // Step down into the search results, highlighting the first result item.
940
+ // Step down into the search results, selecting the first result item.
1057
941
  triggerArrowDown( searchInput );
1058
942
 
1059
- createButton.focus();
1060
- await user.keyboard( '[Enter]' );
1061
-
1062
- searchInput.focus();
1063
- await user.keyboard( '[Enter]' );
943
+ // Check that the create button is in the results and that it's selected
944
+ const createButton = within( searchResults ).getByRole( 'option', {
945
+ name: /^Create:/,
946
+ selected: true,
947
+ } );
948
+ expect( createButton ).toBeVisible();
1064
949
 
1065
- await eventLoopTick();
950
+ expect( searchInput ).toHaveFocus();
951
+ triggerEnter( searchInput );
1066
952
 
1067
953
  expect(
1068
- screen.getByLabelText( 'Currently selected' )
954
+ await screen.findByLabelText( 'Currently selected' )
1069
955
  ).toHaveTextContent( entityNameText );
1070
956
  } );
1071
957
 
@@ -1088,20 +974,15 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
1088
974
  const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
1089
975
 
1090
976
  // Simulate searching for a term.
1091
- searchInput.focus();
1092
- await user.keyboard( entityNameText );
977
+ await user.type( searchInput, entityNameText );
1093
978
 
1094
- await eventLoopTick();
1095
-
1096
- const searchResultElements = within(
1097
- screen.getByRole( 'listbox', {
1098
- name: /Search results for.*/,
1099
- } )
1100
- ).getAllByRole( 'option' );
979
+ const searchResults = await screen.findByRole( 'listbox', {
980
+ name: /Search results for.*/,
981
+ } );
1101
982
 
1102
- const createButton = Array.from( searchResultElements ).filter(
1103
- ( result ) => result.innerHTML.includes( 'Custom suggestion text' )
1104
- )[ 0 ];
983
+ const createButton = within( searchResults ).getByRole( 'option', {
984
+ name: /Custom suggestion text/,
985
+ } );
1105
986
 
1106
987
  expect( createButton ).toBeVisible();
1107
988
  } );
@@ -1112,9 +993,6 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
1112
993
  async ( handler ) => {
1113
994
  render( <LinkControl createSuggestion={ handler } /> );
1114
995
 
1115
- // Await the initial suggestions to be fetched.
1116
- await eventLoopTick();
1117
-
1118
996
  // Search Input UI.
1119
997
  const searchInput = screen.getByRole( 'combobox', {
1120
998
  name: 'URL',
@@ -1128,17 +1006,14 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
1128
1006
  }
1129
1007
  );
1130
1008
 
1131
- it( 'should not show not show an option to create an entity when input is empty', async () => {
1009
+ it( 'should not show an option to create an entity when input is empty', async () => {
1132
1010
  render(
1133
1011
  <LinkControl
1134
- showInitialSuggestions={ true } // Should show even if we're not showing initial suggestions.
1012
+ showInitialSuggestions // Should show even if we're not showing initial suggestions.
1135
1013
  createSuggestion={ jest.fn() }
1136
1014
  />
1137
1015
  );
1138
1016
 
1139
- // Await the initial suggestions to be fetched.
1140
- await eventLoopTick();
1141
-
1142
1017
  // Search Input UI.
1143
1018
  const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
1144
1019
 
@@ -1167,22 +1042,17 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
1167
1042
  } );
1168
1043
 
1169
1044
  // Simulate searching for a term.
1170
- searchInput.focus();
1171
- await user.keyboard( inputText );
1172
-
1173
- await eventLoopTick();
1174
-
1175
- const searchResultElements = within(
1176
- screen.getByRole( 'listbox', {
1177
- name: /Search results for.*/,
1178
- } )
1179
- ).getAllByRole( 'option' );
1045
+ await user.type( searchInput, inputText );
1180
1046
 
1181
- const createButton = Array.from( searchResultElements ).filter(
1182
- ( result ) => result.innerHTML.includes( 'New page' )
1183
- )[ 0 ];
1047
+ const searchResults = await screen.findByRole( 'listbox', {
1048
+ name: /Search results for.*/,
1049
+ } );
1184
1050
 
1185
- expect( createButton ).toBeFalsy(); // Shouldn't exist!
1051
+ const createButton = within( searchResults ).queryByRole(
1052
+ 'option',
1053
+ { name: /New page/ }
1054
+ );
1055
+ expect( createButton ).not.toBeInTheDocument(); // Shouldn't exist!
1186
1056
  }
1187
1057
  );
1188
1058
  } );
@@ -1205,24 +1075,18 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
1205
1075
  searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
1206
1076
 
1207
1077
  // Simulate searching for a term.
1208
- searchInput.focus();
1209
- await user.keyboard( searchText );
1078
+ await user.type( searchInput, searchText );
1210
1079
 
1211
- await eventLoopTick();
1080
+ const searchResults = await screen.findByRole( 'listbox', {
1081
+ name: /Search results for.*/,
1082
+ } );
1212
1083
 
1213
- const searchResultElements = within(
1214
- screen.getByRole( 'listbox', {
1215
- name: /Search results for.*/,
1216
- } )
1217
- ).getAllByRole( 'option' );
1218
- const createButton = Array.from( searchResultElements ).filter(
1219
- ( result ) => result.innerHTML.includes( 'Create:' )
1220
- )[ 0 ];
1084
+ const createButton = within( searchResults ).getByRole( 'option', {
1085
+ name: /^Create:/,
1086
+ } );
1221
1087
 
1222
1088
  await user.click( createButton );
1223
1089
 
1224
- await eventLoopTick();
1225
-
1226
1090
  searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
1227
1091
 
1228
1092
  const errorNotice = screen.getAllByText(
@@ -1234,6 +1098,7 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
1234
1098
 
1235
1099
  // Check human readable error notice is perceivable.
1236
1100
  expect( errorNotice ).toBeVisible();
1101
+ // eslint-disable-next-line testing-library/no-node-access
1237
1102
  expect( errorNotice.parentElement ).toHaveClass(
1238
1103
  'block-editor-link-control__search-error'
1239
1104
  );
@@ -1340,14 +1205,10 @@ describe( 'Selecting links', () => {
1340
1205
  } );
1341
1206
 
1342
1207
  // Simulate searching for a term.
1343
- searchInput.focus();
1344
- await user.keyboard( searchTerm );
1345
-
1346
- // fetchFauxEntitySuggestions resolves on next "tick" of event loop.
1347
- await eventLoopTick();
1208
+ await user.type( searchInput, searchTerm );
1348
1209
 
1349
1210
  const searchResultElements = within(
1350
- screen.getByRole( 'listbox', {
1211
+ await screen.findByRole( 'listbox', {
1351
1212
  name: /Search results for.*/,
1352
1213
  } )
1353
1214
  ).getAllByRole( 'option' );
@@ -1406,20 +1267,17 @@ describe( 'Selecting links', () => {
1406
1267
  } );
1407
1268
 
1408
1269
  // Simulate searching for a term.
1409
- searchInput.focus();
1410
- await user.keyboard( searchTerm );
1270
+ await user.type( searchInput, searchTerm );
1411
1271
 
1412
- // fetchFauxEntitySuggestions resolves on next "tick" of event loop.
1413
- await eventLoopTick();
1272
+ const searchResults = await screen.findByRole( 'listbox', {
1273
+ name: /Search results for.*/,
1274
+ } );
1414
1275
 
1415
1276
  // Step down into the search results, highlighting the first result item.
1416
1277
  triggerArrowDown( searchInput );
1417
1278
 
1418
- const searchResultElements = within(
1419
- screen.getByRole( 'listbox', {
1420
- name: /Search results for.*/,
1421
- } )
1422
- ).getAllByRole( 'option' );
1279
+ const searchResultElements =
1280
+ within( searchResults ).getAllByRole( 'option' );
1423
1281
 
1424
1282
  const firstSearchSuggestion = searchResultElements[ 0 ];
1425
1283
  const secondSearchSuggestion = searchResultElements[ 1 ];
@@ -1429,7 +1287,7 @@ describe( 'Selecting links', () => {
1429
1287
  } );
1430
1288
 
1431
1289
  // We should have highlighted the first item using the keyboard.
1432
- expect( selectedSearchResultElement ).toEqual(
1290
+ expect( selectedSearchResultElement ).toBe(
1433
1291
  firstSearchSuggestion
1434
1292
  );
1435
1293
 
@@ -1444,7 +1302,7 @@ describe( 'Selecting links', () => {
1444
1302
 
1445
1303
  // We should have highlighted the first item using the keyboard
1446
1304
  // eslint-disable-next-line jest/no-conditional-expect
1447
- expect( selectedSearchResultElement ).toEqual(
1305
+ expect( selectedSearchResultElement ).toBe(
1448
1306
  secondSearchSuggestion
1449
1307
  );
1450
1308
 
@@ -1457,7 +1315,7 @@ describe( 'Selecting links', () => {
1457
1315
 
1458
1316
  // We should be back to highlighting the first search result again
1459
1317
  // eslint-disable-next-line jest/no-conditional-expect
1460
- expect( selectedSearchResultElement ).toEqual(
1318
+ expect( selectedSearchResultElement ).toBe(
1461
1319
  firstSearchSuggestion
1462
1320
  );
1463
1321
  }
@@ -1473,7 +1331,8 @@ describe( 'Selecting links', () => {
1473
1331
  } );
1474
1332
 
1475
1333
  // Make sure focus is retained after submission.
1476
- expect( container ).toContainElement( document.activeElement );
1334
+ // eslint-disable-next-line testing-library/no-node-access
1335
+ expect( container.firstChild ).toHaveFocus();
1477
1336
 
1478
1337
  expect( currentLink ).toBeVisible();
1479
1338
  expect(
@@ -1486,10 +1345,8 @@ describe( 'Selecting links', () => {
1486
1345
  it( 'should allow selection of initial search results via the keyboard', async () => {
1487
1346
  render( <LinkControl showInitialSuggestions /> );
1488
1347
 
1489
- await eventLoopTick();
1490
-
1491
1348
  expect(
1492
- screen.queryByRole( 'listbox', {
1349
+ await screen.findByRole( 'listbox', {
1493
1350
  name: 'Recently updated',
1494
1351
  } )
1495
1352
  ).toBeVisible();
@@ -1500,8 +1357,6 @@ describe( 'Selecting links', () => {
1500
1357
  // Step down into the search results, highlighting the first result item.
1501
1358
  triggerArrowDown( searchInput );
1502
1359
 
1503
- await eventLoopTick();
1504
-
1505
1360
  const searchResultElements = within(
1506
1361
  screen.getByRole( 'listbox', {
1507
1362
  name: 'Recently updated',
@@ -1626,14 +1481,10 @@ describe( 'Post types', () => {
1626
1481
  const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
1627
1482
 
1628
1483
  // Simulate searching for a term.
1629
- searchInput.focus();
1630
- await user.keyboard( searchTerm );
1631
-
1632
- // fetchFauxEntitySuggestions resolves on next "tick" of event loop.
1633
- await eventLoopTick();
1484
+ await user.type( searchInput, searchTerm );
1634
1485
 
1635
1486
  const searchResultElements = within(
1636
- screen.getByRole( 'listbox', {
1487
+ await screen.findByRole( 'listbox', {
1637
1488
  name: /Search results for.*/,
1638
1489
  } )
1639
1490
  ).getAllByRole( 'option' );
@@ -1657,14 +1508,10 @@ describe( 'Post types', () => {
1657
1508
  const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
1658
1509
 
1659
1510
  // Simulate searching for a term.
1660
- searchInput.focus();
1661
- await user.keyboard( searchTerm );
1662
-
1663
- // fetchFauxEntitySuggestions resolves on next "tick" of event loop.
1664
- await eventLoopTick();
1511
+ await user.type( searchInput, searchTerm );
1665
1512
 
1666
1513
  const searchResultElements = within(
1667
- screen.getByRole( 'listbox', {
1514
+ await screen.findByRole( 'listbox', {
1668
1515
  name: /Search results for.*/,
1669
1516
  } )
1670
1517
  ).getAllByRole( 'option' );
@@ -1712,11 +1559,6 @@ describe( 'Rich link previews', () => {
1712
1559
 
1713
1560
  render( <LinkControl value={ selectedLink } /> );
1714
1561
 
1715
- // mockFetchRichUrlData resolves on next "tick" of event loop.
1716
- await act( async () => {
1717
- await eventLoopTick();
1718
- } );
1719
-
1720
1562
  const linkPreview = screen.getByLabelText( 'Currently selected' );
1721
1563
 
1722
1564
  const isRichLinkPreview = linkPreview.classList.contains( 'is-rich' );
@@ -1738,16 +1580,9 @@ describe( 'Rich link previews', () => {
1738
1580
 
1739
1581
  render( <LinkControl value={ selectedLink } hasRichPreviews /> );
1740
1582
 
1741
- // mockFetchRichUrlData resolves on next "tick" of event loop.
1742
- await act( async () => {
1743
- await eventLoopTick();
1744
- } );
1745
-
1746
1583
  const linkPreview = screen.getByLabelText( 'Currently selected' );
1747
1584
 
1748
- const isRichLinkPreview = linkPreview.classList.contains( 'is-rich' );
1749
-
1750
- expect( isRichLinkPreview ).toBe( true );
1585
+ await waitFor( () => expect( linkPreview ).toHaveClass( 'is-rich' ) );
1751
1586
  } );
1752
1587
 
1753
1588
  it( 'should not display placeholders for the image and description if neither is available in the data', async () => {
@@ -1762,19 +1597,18 @@ describe( 'Rich link previews', () => {
1762
1597
 
1763
1598
  render( <LinkControl value={ selectedLink } hasRichPreviews /> );
1764
1599
 
1765
- // mockFetchRichUrlData resolves on next "tick" of event loop.
1766
- await act( async () => {
1767
- await eventLoopTick();
1768
- } );
1769
-
1770
1600
  const linkPreview = screen.getByLabelText( 'Currently selected' );
1771
1601
 
1602
+ await waitFor( () => expect( linkPreview ).toHaveClass( 'is-rich' ) );
1603
+
1772
1604
  // Todo: refactor to use user-facing queries.
1605
+ // eslint-disable-next-line testing-library/no-node-access
1773
1606
  const hasRichImagePreview = linkPreview.querySelector(
1774
1607
  '.block-editor-link-control__search-item-image'
1775
1608
  );
1776
1609
 
1777
1610
  // Todo: refactor to use user-facing queries.
1611
+ // eslint-disable-next-line testing-library/no-node-access
1778
1612
  const hasRichDescriptionPreview = linkPreview.querySelector(
1779
1613
  '.block-editor-link-control__search-item-description'
1780
1614
  );
@@ -1795,15 +1629,9 @@ describe( 'Rich link previews', () => {
1795
1629
 
1796
1630
  render( <LinkControl value={ selectedLink } hasRichPreviews /> );
1797
1631
 
1798
- // mockFetchRichUrlData resolves on next "tick" of event loop.
1799
- await act( async () => {
1800
- await eventLoopTick();
1801
- } );
1802
-
1803
1632
  const linkPreview = screen.getByLabelText( 'Currently selected' );
1804
1633
 
1805
- const isRichLinkPreview = linkPreview.classList.contains( 'is-rich' );
1806
- expect( isRichLinkPreview ).toBe( true );
1634
+ await waitFor( () => expect( linkPreview ).toHaveClass( 'is-rich' ) );
1807
1635
 
1808
1636
  const titlePreview = screen.getByText( selectedLink.title );
1809
1637
 
@@ -1824,21 +1652,18 @@ describe( 'Rich link previews', () => {
1824
1652
 
1825
1653
  render( <LinkControl value={ selectedLink } hasRichPreviews /> );
1826
1654
 
1827
- // mockFetchRichUrlData resolves on next "tick" of event loop.
1828
- await act( async () => {
1829
- await eventLoopTick();
1830
- } );
1831
-
1832
1655
  const linkPreview = screen.getByLabelText( 'Currently selected' );
1833
1656
 
1834
- const isRichLinkPreview = linkPreview.classList.contains( 'is-rich' );
1835
- expect( isRichLinkPreview ).toBe( true );
1657
+ await waitFor( () => expect( linkPreview ).toHaveClass( 'is-rich' ) );
1836
1658
 
1659
+ // eslint-disable-next-line testing-library/no-node-access
1837
1660
  const iconPreview = linkPreview.querySelector(
1838
1661
  `.block-editor-link-control__search-item-icon`
1839
1662
  );
1840
1663
 
1664
+ // eslint-disable-next-line testing-library/no-node-access
1841
1665
  const fallBackIcon = iconPreview.querySelector( 'svg' );
1666
+ // eslint-disable-next-line testing-library/no-node-access
1842
1667
  const richIcon = iconPreview.querySelector( 'img' );
1843
1668
 
1844
1669
  expect( fallBackIcon ).toBeVisible();
@@ -1862,17 +1687,13 @@ describe( 'Rich link previews', () => {
1862
1687
 
1863
1688
  render( <LinkControl value={ selectedLink } hasRichPreviews /> );
1864
1689
 
1865
- // mockFetchRichUrlData resolves on next "tick" of event loop.
1866
- await act( async () => {
1867
- await eventLoopTick();
1868
- } );
1869
-
1870
1690
  const linkPreview = screen.getByLabelText( 'Currently selected' );
1871
1691
 
1872
- const isRichLinkPreview =
1873
- linkPreview.classList.contains( 'is-rich' );
1874
- expect( isRichLinkPreview ).toBe( true );
1692
+ await waitFor( () =>
1693
+ expect( linkPreview ).toHaveClass( 'is-rich' )
1694
+ );
1875
1695
 
1696
+ // eslint-disable-next-line testing-library/no-node-access
1876
1697
  const missingDataItem = linkPreview.querySelector(
1877
1698
  `.block-editor-link-control__search-item-${ dataItem }`
1878
1699
  );
@@ -1887,23 +1708,19 @@ describe( 'Rich link previews', () => {
1887
1708
  ] )(
1888
1709
  'should not display a rich preview when data is %s',
1889
1710
  async ( _descriptor, data ) => {
1890
- mockFetchRichUrlData.mockImplementation( () =>
1891
- Promise.resolve( data )
1892
- );
1711
+ mockFetchRichUrlData.mockImplementation( async () => data );
1893
1712
 
1894
1713
  render( <LinkControl value={ selectedLink } hasRichPreviews /> );
1895
1714
 
1896
- // mockFetchRichUrlData resolves on next "tick" of event loop.
1897
- await act( async () => {
1898
- await eventLoopTick();
1899
- } );
1900
-
1901
1715
  const linkPreview = screen.getByLabelText( 'Currently selected' );
1902
1716
 
1903
- const isRichLinkPreview =
1904
- linkPreview.classList.contains( 'is-rich' );
1717
+ expect( linkPreview ).toHaveClass( 'is-fetching' );
1905
1718
 
1906
- expect( isRichLinkPreview ).toBe( false );
1719
+ await waitFor( () =>
1720
+ expect( linkPreview ).not.toHaveClass( 'is-fetching' )
1721
+ );
1722
+
1723
+ expect( linkPreview ).not.toHaveClass( 'is-rich' );
1907
1724
  }
1908
1725
  );
1909
1726
 
@@ -1914,19 +1731,10 @@ describe( 'Rich link previews', () => {
1914
1731
 
1915
1732
  render( <LinkControl value={ selectedLink } hasRichPreviews /> );
1916
1733
 
1917
- // mockFetchRichUrlData resolves on next "tick" of event loop.
1918
- await act( async () => {
1919
- await eventLoopTick();
1920
- } );
1921
-
1922
1734
  const linkPreview = screen.getByLabelText( 'Currently selected' );
1923
1735
 
1924
- const isFetchingRichPreview =
1925
- linkPreview.classList.contains( 'is-fetching' );
1926
- const isRichLinkPreview = linkPreview.classList.contains( 'is-rich' );
1927
-
1928
- expect( isFetchingRichPreview ).toBe( true );
1929
- expect( isRichLinkPreview ).toBe( false );
1736
+ expect( linkPreview ).toHaveClass( 'is-fetching' );
1737
+ expect( linkPreview ).not.toHaveClass( 'is-rich' );
1930
1738
  } );
1931
1739
 
1932
1740
  it( 'should remove fetching UI indicators and fallback to standard preview if request for rich preview results in an error', async () => {
@@ -1936,20 +1744,15 @@ describe( 'Rich link previews', () => {
1936
1744
 
1937
1745
  render( <LinkControl value={ selectedLink } hasRichPreviews /> );
1938
1746
 
1939
- // mockFetchRichUrlData resolves on next "tick" of event loop.
1940
- await act( async () => {
1941
- await eventLoopTick();
1942
- } );
1943
-
1944
1747
  const linkPreview = screen.getByLabelText( 'Currently selected' );
1945
1748
 
1946
- const isFetchingRichPreview =
1947
- linkPreview.classList.contains( 'is-fetching' );
1749
+ expect( linkPreview ).toHaveClass( 'is-fetching' );
1948
1750
 
1949
- const isRichLinkPreview = linkPreview.classList.contains( 'is-rich' );
1751
+ await waitFor( () =>
1752
+ expect( linkPreview ).not.toHaveClass( 'is-fetching' )
1753
+ );
1950
1754
 
1951
- expect( isFetchingRichPreview ).toBe( false );
1952
- expect( isRichLinkPreview ).toBe( false );
1755
+ expect( linkPreview ).not.toHaveClass( 'is-rich' );
1953
1756
  } );
1954
1757
 
1955
1758
  afterAll( () => {
@@ -2050,8 +1853,7 @@ describe( 'Controlling link title text', () => {
2050
1853
 
2051
1854
  const textInput = screen.queryByRole( 'textbox', { name: 'Text' } );
2052
1855
 
2053
- textInput.focus();
2054
- await userEvent.clear( textInput );
1856
+ await user.clear( textInput );
2055
1857
  await user.keyboard( textValue );
2056
1858
 
2057
1859
  expect( textInput ).toHaveValue( textValue );
@@ -2087,8 +1889,7 @@ describe( 'Controlling link title text', () => {
2087
1889
 
2088
1890
  expect( textInput ).toBeVisible();
2089
1891
 
2090
- textInput.focus();
2091
- await userEvent.clear( textInput );
1892
+ await user.clear( textInput );
2092
1893
  await user.keyboard( textValue );
2093
1894
 
2094
1895
  // Attempt to submit the empty search value in the input.