@atlaskit/editor-core 188.8.0 → 188.9.2

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 (290) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/composable-editor/editor-internal.js +2 -2
  3. package/dist/cjs/create-editor/ReactEditorView.js +796 -8
  4. package/dist/cjs/labs/next/presets/default.js +2 -2
  5. package/dist/cjs/labs/next/presets/universal.js +7 -4
  6. package/dist/cjs/plugins/index.js +0 -28
  7. package/dist/cjs/plugins/insert-block/index.js +4 -6
  8. package/dist/cjs/plugins/tasks-and-decisions/index.js +4 -3
  9. package/dist/cjs/plugins/tasks-and-decisions/nodeviews/decisionItem.js +26 -6
  10. package/dist/cjs/plugins/tasks-and-decisions/nodeviews/taskItem.js +45 -13
  11. package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/main.js +15 -7
  12. package/dist/cjs/version-wrapper.js +1 -1
  13. package/dist/es2019/composable-editor/editor-internal.js +1 -1
  14. package/dist/es2019/create-editor/ReactEditorView.js +753 -2
  15. package/dist/es2019/labs/next/presets/default.js +1 -1
  16. package/dist/es2019/labs/next/presets/universal.js +4 -1
  17. package/dist/es2019/plugins/index.js +0 -4
  18. package/dist/es2019/plugins/insert-block/index.js +4 -6
  19. package/dist/es2019/plugins/tasks-and-decisions/index.js +4 -3
  20. package/dist/es2019/plugins/tasks-and-decisions/nodeviews/decisionItem.js +26 -6
  21. package/dist/es2019/plugins/tasks-and-decisions/nodeviews/taskItem.js +43 -10
  22. package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/main.js +13 -6
  23. package/dist/es2019/version-wrapper.js +1 -1
  24. package/dist/esm/composable-editor/editor-internal.js +1 -1
  25. package/dist/esm/create-editor/ReactEditorView.js +797 -8
  26. package/dist/esm/labs/next/presets/default.js +1 -1
  27. package/dist/esm/labs/next/presets/universal.js +4 -1
  28. package/dist/esm/plugins/index.js +0 -4
  29. package/dist/esm/plugins/insert-block/index.js +4 -6
  30. package/dist/esm/plugins/tasks-and-decisions/index.js +4 -3
  31. package/dist/esm/plugins/tasks-and-decisions/nodeviews/decisionItem.js +26 -6
  32. package/dist/esm/plugins/tasks-and-decisions/nodeviews/taskItem.js +45 -12
  33. package/dist/esm/plugins/tasks-and-decisions/pm-plugins/main.js +14 -7
  34. package/dist/esm/version-wrapper.js +1 -1
  35. package/dist/types/create-editor/ReactEditorView.d.ts +119 -5
  36. package/dist/types/labs/next/presets/default.d.ts +43 -43
  37. package/dist/types/plugins/index.d.ts +0 -4
  38. package/dist/types/plugins/insert-block/types.d.ts +3 -1
  39. package/dist/types/plugins/tasks-and-decisions/index.d.ts +2 -5
  40. package/dist/types/plugins/tasks-and-decisions/nodeviews/decisionItem.d.ts +9 -4
  41. package/dist/types/plugins/tasks-and-decisions/nodeviews/taskItem.d.ts +9 -4
  42. package/dist/types/plugins/tasks-and-decisions/pm-plugins/main.d.ts +4 -2
  43. package/dist/types/plugins/tasks-and-decisions/types.d.ts +6 -1
  44. package/dist/types/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.d.ts +1 -1
  45. package/dist/types-ts4.5/create-editor/ReactEditorView.d.ts +119 -5
  46. package/dist/types-ts4.5/labs/next/presets/default.d.ts +43 -43
  47. package/dist/types-ts4.5/plugins/index.d.ts +0 -4
  48. package/dist/types-ts4.5/plugins/insert-block/types.d.ts +3 -1
  49. package/dist/types-ts4.5/plugins/tasks-and-decisions/index.d.ts +2 -5
  50. package/dist/types-ts4.5/plugins/tasks-and-decisions/nodeviews/decisionItem.d.ts +9 -4
  51. package/dist/types-ts4.5/plugins/tasks-and-decisions/nodeviews/taskItem.d.ts +9 -4
  52. package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/main.d.ts +4 -2
  53. package/dist/types-ts4.5/plugins/tasks-and-decisions/types.d.ts +8 -1
  54. package/dist/types-ts4.5/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.d.ts +1 -1
  55. package/package.json +7 -7
  56. package/dist/cjs/create-editor/ReactEditorViewInternal.js +0 -812
  57. package/dist/cjs/create-editor/ReactEditorViewNext.js +0 -15
  58. package/dist/cjs/plugins/save-on-enter/index.js +0 -70
  59. package/dist/cjs/plugins/scroll-into-view/index.js +0 -55
  60. package/dist/cjs/plugins/status/actions.js +0 -158
  61. package/dist/cjs/plugins/status/analytics.js +0 -31
  62. package/dist/cjs/plugins/status/index.js +0 -143
  63. package/dist/cjs/plugins/status/keymap.js +0 -22
  64. package/dist/cjs/plugins/status/nodeviews/status.js +0 -58
  65. package/dist/cjs/plugins/status/plugin-key.js +0 -9
  66. package/dist/cjs/plugins/status/plugin.js +0 -133
  67. package/dist/cjs/plugins/status/types.js +0 -5
  68. package/dist/cjs/plugins/status/ui/statusPicker.js +0 -314
  69. package/dist/cjs/plugins/status/utils.js +0 -22
  70. package/dist/cjs/plugins/type-ahead/api.js +0 -215
  71. package/dist/cjs/plugins/type-ahead/commands/insert-type-ahead-item.js +0 -205
  72. package/dist/cjs/plugins/type-ahead/commands/update-list-items.js +0 -23
  73. package/dist/cjs/plugins/type-ahead/commands/update-query.js +0 -27
  74. package/dist/cjs/plugins/type-ahead/commands/update-selected-index.js +0 -27
  75. package/dist/cjs/plugins/type-ahead/constants.js +0 -15
  76. package/dist/cjs/plugins/type-ahead/index.js +0 -14
  77. package/dist/cjs/plugins/type-ahead/insert-utils.js +0 -107
  78. package/dist/cjs/plugins/type-ahead/messages.js +0 -79
  79. package/dist/cjs/plugins/type-ahead/plugin.js +0 -382
  80. package/dist/cjs/plugins/type-ahead/pm-plugins/actions.js +0 -16
  81. package/dist/cjs/plugins/type-ahead/pm-plugins/decorations.js +0 -148
  82. package/dist/cjs/plugins/type-ahead/pm-plugins/input-rules.js +0 -36
  83. package/dist/cjs/plugins/type-ahead/pm-plugins/insert-item-plugin.js +0 -22
  84. package/dist/cjs/plugins/type-ahead/pm-plugins/key.js +0 -8
  85. package/dist/cjs/plugins/type-ahead/pm-plugins/main.js +0 -110
  86. package/dist/cjs/plugins/type-ahead/pm-plugins/reducer.js +0 -158
  87. package/dist/cjs/plugins/type-ahead/pm-plugins/utils.js +0 -18
  88. package/dist/cjs/plugins/type-ahead/stats-modifier.js +0 -42
  89. package/dist/cjs/plugins/type-ahead/transforms/close-type-ahead.js +0 -13
  90. package/dist/cjs/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +0 -75
  91. package/dist/cjs/plugins/type-ahead/transforms/set-selection-before-query.js +0 -18
  92. package/dist/cjs/plugins/type-ahead/types.js +0 -5
  93. package/dist/cjs/plugins/type-ahead/ui/AssistiveText.js +0 -120
  94. package/dist/cjs/plugins/type-ahead/ui/InputQuery.js +0 -400
  95. package/dist/cjs/plugins/type-ahead/ui/TypeAheadList.js +0 -285
  96. package/dist/cjs/plugins/type-ahead/ui/TypeAheadListItem.js +0 -179
  97. package/dist/cjs/plugins/type-ahead/ui/TypeAheadPopup.js +0 -230
  98. package/dist/cjs/plugins/type-ahead/ui/WrapperTypeAhead.js +0 -127
  99. package/dist/cjs/plugins/type-ahead/ui/hooks/use-item-insert.js +0 -109
  100. package/dist/cjs/plugins/type-ahead/ui/hooks/use-load-items.js +0 -50
  101. package/dist/cjs/plugins/type-ahead/ui/hooks/use-on-force-select.js +0 -41
  102. package/dist/cjs/plugins/type-ahead/utils.js +0 -130
  103. package/dist/es2019/create-editor/ReactEditorViewInternal.js +0 -753
  104. package/dist/es2019/create-editor/ReactEditorViewNext.js +0 -7
  105. package/dist/es2019/plugins/save-on-enter/index.js +0 -63
  106. package/dist/es2019/plugins/scroll-into-view/index.js +0 -44
  107. package/dist/es2019/plugins/status/actions.js +0 -144
  108. package/dist/es2019/plugins/status/analytics.js +0 -18
  109. package/dist/es2019/plugins/status/index.js +0 -135
  110. package/dist/es2019/plugins/status/keymap.js +0 -13
  111. package/dist/es2019/plugins/status/nodeviews/status.js +0 -60
  112. package/dist/es2019/plugins/status/plugin-key.js +0 -3
  113. package/dist/es2019/plugins/status/plugin.js +0 -113
  114. package/dist/es2019/plugins/status/types.js +0 -1
  115. package/dist/es2019/plugins/status/ui/statusPicker.js +0 -293
  116. package/dist/es2019/plugins/status/utils.js +0 -12
  117. package/dist/es2019/plugins/type-ahead/api.js +0 -205
  118. package/dist/es2019/plugins/type-ahead/commands/insert-type-ahead-item.js +0 -204
  119. package/dist/es2019/plugins/type-ahead/commands/update-list-items.js +0 -17
  120. package/dist/es2019/plugins/type-ahead/commands/update-query.js +0 -21
  121. package/dist/es2019/plugins/type-ahead/commands/update-selected-index.js +0 -21
  122. package/dist/es2019/plugins/type-ahead/constants.js +0 -9
  123. package/dist/es2019/plugins/type-ahead/index.js +0 -3
  124. package/dist/es2019/plugins/type-ahead/insert-utils.js +0 -106
  125. package/dist/es2019/plugins/type-ahead/messages.js +0 -73
  126. package/dist/es2019/plugins/type-ahead/plugin.js +0 -381
  127. package/dist/es2019/plugins/type-ahead/pm-plugins/actions.js +0 -10
  128. package/dist/es2019/plugins/type-ahead/pm-plugins/decorations.js +0 -148
  129. package/dist/es2019/plugins/type-ahead/pm-plugins/input-rules.js +0 -29
  130. package/dist/es2019/plugins/type-ahead/pm-plugins/insert-item-plugin.js +0 -16
  131. package/dist/es2019/plugins/type-ahead/pm-plugins/key.js +0 -2
  132. package/dist/es2019/plugins/type-ahead/pm-plugins/main.js +0 -106
  133. package/dist/es2019/plugins/type-ahead/pm-plugins/reducer.js +0 -160
  134. package/dist/es2019/plugins/type-ahead/pm-plugins/utils.js +0 -12
  135. package/dist/es2019/plugins/type-ahead/stats-modifier.js +0 -33
  136. package/dist/es2019/plugins/type-ahead/transforms/close-type-ahead.js +0 -7
  137. package/dist/es2019/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +0 -71
  138. package/dist/es2019/plugins/type-ahead/transforms/set-selection-before-query.js +0 -10
  139. package/dist/es2019/plugins/type-ahead/types.js +0 -1
  140. package/dist/es2019/plugins/type-ahead/ui/AssistiveText.js +0 -88
  141. package/dist/es2019/plugins/type-ahead/ui/InputQuery.js +0 -393
  142. package/dist/es2019/plugins/type-ahead/ui/TypeAheadList.js +0 -273
  143. package/dist/es2019/plugins/type-ahead/ui/TypeAheadListItem.js +0 -214
  144. package/dist/es2019/plugins/type-ahead/ui/TypeAheadPopup.js +0 -233
  145. package/dist/es2019/plugins/type-ahead/ui/WrapperTypeAhead.js +0 -109
  146. package/dist/es2019/plugins/type-ahead/ui/hooks/use-item-insert.js +0 -112
  147. package/dist/es2019/plugins/type-ahead/ui/hooks/use-load-items.js +0 -41
  148. package/dist/es2019/plugins/type-ahead/ui/hooks/use-on-force-select.js +0 -38
  149. package/dist/es2019/plugins/type-ahead/utils.js +0 -126
  150. package/dist/esm/create-editor/ReactEditorViewInternal.js +0 -806
  151. package/dist/esm/create-editor/ReactEditorViewNext.js +0 -7
  152. package/dist/esm/plugins/save-on-enter/index.js +0 -63
  153. package/dist/esm/plugins/scroll-into-view/index.js +0 -50
  154. package/dist/esm/plugins/status/actions.js +0 -151
  155. package/dist/esm/plugins/status/analytics.js +0 -24
  156. package/dist/esm/plugins/status/index.js +0 -136
  157. package/dist/esm/plugins/status/keymap.js +0 -15
  158. package/dist/esm/plugins/status/nodeviews/status.js +0 -51
  159. package/dist/esm/plugins/status/plugin-key.js +0 -3
  160. package/dist/esm/plugins/status/plugin.js +0 -115
  161. package/dist/esm/plugins/status/types.js +0 -1
  162. package/dist/esm/plugins/status/ui/statusPicker.js +0 -308
  163. package/dist/esm/plugins/status/utils.js +0 -16
  164. package/dist/esm/plugins/type-ahead/api.js +0 -209
  165. package/dist/esm/plugins/type-ahead/commands/insert-type-ahead-item.js +0 -198
  166. package/dist/esm/plugins/type-ahead/commands/update-list-items.js +0 -17
  167. package/dist/esm/plugins/type-ahead/commands/update-query.js +0 -21
  168. package/dist/esm/plugins/type-ahead/commands/update-selected-index.js +0 -21
  169. package/dist/esm/plugins/type-ahead/constants.js +0 -9
  170. package/dist/esm/plugins/type-ahead/index.js +0 -3
  171. package/dist/esm/plugins/type-ahead/insert-utils.js +0 -101
  172. package/dist/esm/plugins/type-ahead/messages.js +0 -73
  173. package/dist/esm/plugins/type-ahead/plugin.js +0 -374
  174. package/dist/esm/plugins/type-ahead/pm-plugins/actions.js +0 -10
  175. package/dist/esm/plugins/type-ahead/pm-plugins/decorations.js +0 -141
  176. package/dist/esm/plugins/type-ahead/pm-plugins/input-rules.js +0 -29
  177. package/dist/esm/plugins/type-ahead/pm-plugins/insert-item-plugin.js +0 -16
  178. package/dist/esm/plugins/type-ahead/pm-plugins/key.js +0 -2
  179. package/dist/esm/plugins/type-ahead/pm-plugins/main.js +0 -104
  180. package/dist/esm/plugins/type-ahead/pm-plugins/reducer.js +0 -151
  181. package/dist/esm/plugins/type-ahead/pm-plugins/utils.js +0 -12
  182. package/dist/esm/plugins/type-ahead/stats-modifier.js +0 -35
  183. package/dist/esm/plugins/type-ahead/transforms/close-type-ahead.js +0 -7
  184. package/dist/esm/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +0 -69
  185. package/dist/esm/plugins/type-ahead/transforms/set-selection-before-query.js +0 -12
  186. package/dist/esm/plugins/type-ahead/types.js +0 -1
  187. package/dist/esm/plugins/type-ahead/ui/AssistiveText.js +0 -115
  188. package/dist/esm/plugins/type-ahead/ui/InputQuery.js +0 -390
  189. package/dist/esm/plugins/type-ahead/ui/TypeAheadList.js +0 -276
  190. package/dist/esm/plugins/type-ahead/ui/TypeAheadListItem.js +0 -169
  191. package/dist/esm/plugins/type-ahead/ui/TypeAheadPopup.js +0 -220
  192. package/dist/esm/plugins/type-ahead/ui/WrapperTypeAhead.js +0 -117
  193. package/dist/esm/plugins/type-ahead/ui/hooks/use-item-insert.js +0 -103
  194. package/dist/esm/plugins/type-ahead/ui/hooks/use-load-items.js +0 -43
  195. package/dist/esm/plugins/type-ahead/ui/hooks/use-on-force-select.js +0 -35
  196. package/dist/esm/plugins/type-ahead/utils.js +0 -124
  197. package/dist/types/create-editor/ReactEditorViewInternal.d.ts +0 -119
  198. package/dist/types/create-editor/ReactEditorViewNext.d.ts +0 -8
  199. package/dist/types/plugins/save-on-enter/index.d.ts +0 -10
  200. package/dist/types/plugins/scroll-into-view/index.d.ts +0 -14
  201. package/dist/types/plugins/status/actions.d.ts +0 -16
  202. package/dist/types/plugins/status/analytics.d.ts +0 -4
  203. package/dist/types/plugins/status/index.d.ts +0 -15
  204. package/dist/types/plugins/status/keymap.d.ts +0 -3
  205. package/dist/types/plugins/status/nodeviews/status.d.ts +0 -25
  206. package/dist/types/plugins/status/plugin-key.d.ts +0 -4
  207. package/dist/types/plugins/status/plugin.d.ts +0 -7
  208. package/dist/types/plugins/status/types.d.ts +0 -18
  209. package/dist/types/plugins/status/ui/statusPicker.d.ts +0 -63
  210. package/dist/types/plugins/status/utils.d.ts +0 -5
  211. package/dist/types/plugins/type-ahead/api.d.ts +0 -61
  212. package/dist/types/plugins/type-ahead/commands/insert-type-ahead-item.d.ts +0 -12
  213. package/dist/types/plugins/type-ahead/commands/update-list-items.d.ts +0 -3
  214. package/dist/types/plugins/type-ahead/commands/update-query.d.ts +0 -2
  215. package/dist/types/plugins/type-ahead/commands/update-selected-index.d.ts +0 -2
  216. package/dist/types/plugins/type-ahead/constants.d.ts +0 -8
  217. package/dist/types/plugins/type-ahead/index.d.ts +0 -4
  218. package/dist/types/plugins/type-ahead/insert-utils.d.ts +0 -18
  219. package/dist/types/plugins/type-ahead/messages.d.ts +0 -72
  220. package/dist/types/plugins/type-ahead/plugin.d.ts +0 -10
  221. package/dist/types/plugins/type-ahead/pm-plugins/actions.d.ts +0 -9
  222. package/dist/types/plugins/type-ahead/pm-plugins/decorations.d.ts +0 -14
  223. package/dist/types/plugins/type-ahead/pm-plugins/input-rules.d.ts +0 -6
  224. package/dist/types/plugins/type-ahead/pm-plugins/insert-item-plugin.d.ts +0 -2
  225. package/dist/types/plugins/type-ahead/pm-plugins/key.d.ts +0 -3
  226. package/dist/types/plugins/type-ahead/pm-plugins/main.d.ts +0 -14
  227. package/dist/types/plugins/type-ahead/pm-plugins/reducer.d.ts +0 -10
  228. package/dist/types/plugins/type-ahead/pm-plugins/utils.d.ts +0 -4
  229. package/dist/types/plugins/type-ahead/stats-modifier.d.ts +0 -20
  230. package/dist/types/plugins/type-ahead/transforms/close-type-ahead.d.ts +0 -2
  231. package/dist/types/plugins/type-ahead/transforms/open-typeahead-at-cursor.d.ts +0 -11
  232. package/dist/types/plugins/type-ahead/transforms/set-selection-before-query.d.ts +0 -2
  233. package/dist/types/plugins/type-ahead/types.d.ts +0 -109
  234. package/dist/types/plugins/type-ahead/ui/AssistiveText.d.ts +0 -33
  235. package/dist/types/plugins/type-ahead/ui/InputQuery.d.ts +0 -26
  236. package/dist/types/plugins/type-ahead/ui/TypeAheadList.d.ts +0 -25
  237. package/dist/types/plugins/type-ahead/ui/TypeAheadListItem.d.ts +0 -18
  238. package/dist/types/plugins/type-ahead/ui/TypeAheadPopup.d.ts +0 -29
  239. package/dist/types/plugins/type-ahead/ui/WrapperTypeAhead.d.ts +0 -20
  240. package/dist/types/plugins/type-ahead/ui/hooks/use-item-insert.d.ts +0 -3
  241. package/dist/types/plugins/type-ahead/ui/hooks/use-load-items.d.ts +0 -3
  242. package/dist/types/plugins/type-ahead/ui/hooks/use-on-force-select.d.ts +0 -11
  243. package/dist/types/plugins/type-ahead/utils.d.ts +0 -27
  244. package/dist/types-ts4.5/create-editor/ReactEditorViewInternal.d.ts +0 -119
  245. package/dist/types-ts4.5/create-editor/ReactEditorViewNext.d.ts +0 -8
  246. package/dist/types-ts4.5/plugins/save-on-enter/index.d.ts +0 -10
  247. package/dist/types-ts4.5/plugins/scroll-into-view/index.d.ts +0 -14
  248. package/dist/types-ts4.5/plugins/status/actions.d.ts +0 -16
  249. package/dist/types-ts4.5/plugins/status/analytics.d.ts +0 -4
  250. package/dist/types-ts4.5/plugins/status/index.d.ts +0 -17
  251. package/dist/types-ts4.5/plugins/status/keymap.d.ts +0 -3
  252. package/dist/types-ts4.5/plugins/status/nodeviews/status.d.ts +0 -25
  253. package/dist/types-ts4.5/plugins/status/plugin-key.d.ts +0 -4
  254. package/dist/types-ts4.5/plugins/status/plugin.d.ts +0 -7
  255. package/dist/types-ts4.5/plugins/status/types.d.ts +0 -18
  256. package/dist/types-ts4.5/plugins/status/ui/statusPicker.d.ts +0 -63
  257. package/dist/types-ts4.5/plugins/status/utils.d.ts +0 -5
  258. package/dist/types-ts4.5/plugins/type-ahead/api.d.ts +0 -61
  259. package/dist/types-ts4.5/plugins/type-ahead/commands/insert-type-ahead-item.d.ts +0 -12
  260. package/dist/types-ts4.5/plugins/type-ahead/commands/update-list-items.d.ts +0 -3
  261. package/dist/types-ts4.5/plugins/type-ahead/commands/update-query.d.ts +0 -2
  262. package/dist/types-ts4.5/plugins/type-ahead/commands/update-selected-index.d.ts +0 -2
  263. package/dist/types-ts4.5/plugins/type-ahead/constants.d.ts +0 -8
  264. package/dist/types-ts4.5/plugins/type-ahead/index.d.ts +0 -4
  265. package/dist/types-ts4.5/plugins/type-ahead/insert-utils.d.ts +0 -18
  266. package/dist/types-ts4.5/plugins/type-ahead/messages.d.ts +0 -72
  267. package/dist/types-ts4.5/plugins/type-ahead/plugin.d.ts +0 -10
  268. package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/actions.d.ts +0 -9
  269. package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/decorations.d.ts +0 -14
  270. package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/input-rules.d.ts +0 -6
  271. package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/insert-item-plugin.d.ts +0 -2
  272. package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/key.d.ts +0 -3
  273. package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/main.d.ts +0 -14
  274. package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/reducer.d.ts +0 -10
  275. package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/utils.d.ts +0 -4
  276. package/dist/types-ts4.5/plugins/type-ahead/stats-modifier.d.ts +0 -20
  277. package/dist/types-ts4.5/plugins/type-ahead/transforms/close-type-ahead.d.ts +0 -2
  278. package/dist/types-ts4.5/plugins/type-ahead/transforms/open-typeahead-at-cursor.d.ts +0 -11
  279. package/dist/types-ts4.5/plugins/type-ahead/transforms/set-selection-before-query.d.ts +0 -2
  280. package/dist/types-ts4.5/plugins/type-ahead/types.d.ts +0 -111
  281. package/dist/types-ts4.5/plugins/type-ahead/ui/AssistiveText.d.ts +0 -33
  282. package/dist/types-ts4.5/plugins/type-ahead/ui/InputQuery.d.ts +0 -26
  283. package/dist/types-ts4.5/plugins/type-ahead/ui/TypeAheadList.d.ts +0 -25
  284. package/dist/types-ts4.5/plugins/type-ahead/ui/TypeAheadListItem.d.ts +0 -18
  285. package/dist/types-ts4.5/plugins/type-ahead/ui/TypeAheadPopup.d.ts +0 -29
  286. package/dist/types-ts4.5/plugins/type-ahead/ui/WrapperTypeAhead.d.ts +0 -20
  287. package/dist/types-ts4.5/plugins/type-ahead/ui/hooks/use-item-insert.d.ts +0 -7
  288. package/dist/types-ts4.5/plugins/type-ahead/ui/hooks/use-load-items.d.ts +0 -3
  289. package/dist/types-ts4.5/plugins/type-ahead/ui/hooks/use-on-force-select.d.ts +0 -11
  290. package/dist/types-ts4.5/plugins/type-ahead/utils.d.ts +0 -27
@@ -1,390 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- /** @jsx jsx */
3
- import React, { useRef, useCallback, Fragment, useLayoutEffect, useState } from 'react';
4
- import { css, jsx } from '@emotion/react';
5
- import { keyName as keyNameNormalized } from 'w3c-keyname';
6
- import { browser } from '@atlaskit/editor-common/utils';
7
- import { getPluginState } from '../utils';
8
- import { CloseSelectionOptions, TYPE_AHEAD_POPUP_CONTENT_CLASS } from '../constants';
9
- import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
10
- import { TYPE_AHEAD_DECORATION_ELEMENT_ID } from '../constants';
11
- import { AssistiveText } from './AssistiveText';
12
- import { typeAheadListMessages } from '../messages';
13
- import { useIntl } from 'react-intl-next';
14
- import { blockNodesVerticalMargin } from '@atlaskit/editor-shared-styles';
15
- var querySpan = css({
16
- outline: 'none',
17
- '& input': {
18
- width: '5px',
19
- border: 'none',
20
- background: 'transparent',
21
- padding: 0,
22
- margin: 0,
23
- // ED-17022 Fixes firefox caret position
24
- fontSize: '1em',
25
- height: blockNodesVerticalMargin,
26
- caretColor: "var(--ds-text-accent-blue, #0052CC)"
27
- }
28
- });
29
- var isNavigationKey = function isNavigationKey(event) {
30
- return ['Enter', 'Tab', 'ArrowDown', 'ArrowUp'].includes(event.key);
31
- };
32
- var isUndoRedoShortcut = function isUndoRedoShortcut(event) {
33
- var key = keyNameNormalized(event);
34
- if (event.ctrlKey && key === 'y') {
35
- return 'historyRedo';
36
- }
37
- if ((event.ctrlKey || event.metaKey) && event.shiftKey && key === 'Z') {
38
- return 'historyRedo';
39
- }
40
- if ((event.ctrlKey || event.metaKey) && key === 'z') {
41
- return 'historyUndo';
42
- }
43
- return false;
44
- };
45
- var getAriaLabel = function getAriaLabel(triggerPrefix, intl) {
46
- switch (triggerPrefix) {
47
- case '@':
48
- return typeAheadListMessages.mentionInputLabel;
49
- case '/':
50
- return typeAheadListMessages.quickInsertInputLabel;
51
- case ':':
52
- return typeAheadListMessages.emojiInputLabel;
53
- default:
54
- return typeAheadListMessages.quickInsertInputLabel;
55
- }
56
- };
57
- export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
58
- var triggerQueryPrefix = _ref.triggerQueryPrefix,
59
- cancel = _ref.cancel,
60
- onQueryChange = _ref.onQueryChange,
61
- onItemSelect = _ref.onItemSelect,
62
- selectNextItem = _ref.selectNextItem,
63
- selectPreviousItem = _ref.selectPreviousItem,
64
- forceFocus = _ref.forceFocus,
65
- reopenQuery = _ref.reopenQuery,
66
- onQueryFocus = _ref.onQueryFocus,
67
- onUndoRedo = _ref.onUndoRedo,
68
- editorView = _ref.editorView,
69
- items = _ref.items;
70
- var ref = useRef(document.createElement('span'));
71
- var inputRef = useRef(null);
72
- var _useState = useState(null),
73
- _useState2 = _slicedToArray(_useState, 2),
74
- query = _useState2[0],
75
- setQuery = _useState2[1];
76
- var cleanedInputContent = useCallback(function () {
77
- var _ref$current;
78
- var raw = ((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.textContent) || '';
79
- return raw;
80
- }, []);
81
- var onKeyUp = useCallback(function (event) {
82
- var text = cleanedInputContent();
83
- onQueryChange(text);
84
- }, [onQueryChange, cleanedInputContent]);
85
- var _useState3 = useState(false),
86
- _useState4 = _slicedToArray(_useState3, 2),
87
- isInFocus = _useState4[0],
88
- setInFocus = _useState4[1];
89
- var checkKeyEvent = useCallback(function (event) {
90
- var _ref$current2;
91
- var key = keyNameNormalized(event);
92
- var sel = document.getSelection();
93
- var raw = ((_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.textContent) || '';
94
- var text = cleanedInputContent();
95
- var stopDefault = false;
96
- var _ref2 = getPluginState(editorView.state) || {},
97
- selectedIndex = _ref2.selectedIndex;
98
- setInFocus(true);
99
- switch (key) {
100
- case ' ':
101
- // space key
102
- if (text.length === 0) {
103
- cancel({
104
- forceFocusOnEditor: true,
105
- text: ' ',
106
- addPrefixTrigger: true,
107
- setSelectionAt: CloseSelectionOptions.AFTER_TEXT_INSERTED
108
- });
109
- stopDefault = true;
110
- }
111
- break;
112
- case 'Escape':
113
- case 'PageUp':
114
- case 'PageDown':
115
- case 'Home':
116
- cancel({
117
- text: text,
118
- forceFocusOnEditor: true,
119
- addPrefixTrigger: true,
120
- setSelectionAt: CloseSelectionOptions.AFTER_TEXT_INSERTED
121
- });
122
- stopDefault = true;
123
- break;
124
- case 'Backspace':
125
- if (raw.length === 0 || (sel === null || sel === void 0 ? void 0 : sel.anchorOffset) === 0) {
126
- event.stopPropagation();
127
- event.preventDefault();
128
- cancel({
129
- forceFocusOnEditor: true,
130
- text: text,
131
- addPrefixTrigger: false,
132
- setSelectionAt: CloseSelectionOptions.BEFORE_TEXT_INSERTED
133
- });
134
- }
135
- break;
136
- case 'Enter':
137
- // ED-14758 - Under the W3C specification, any keycode sent under IME would return a keycode 229
138
- // event.isComposing can't be used alone as this also included a virtual keyboard under a keyboardless device, therefore, it seems the best practice would be intercepting the event as below.
139
- // Some suggested the other workaround maybe listen on`keypress` instead of `keydown`
140
- if (!event.isComposing && event.which !== 229 && event.keyCode !== 229) {
141
- if (selectedIndex === -1) {
142
- /**
143
- * TODO DTR-1401: (also see ED-17200) There are two options
144
- * here, either
145
- * - set the index directly to 1 in WrapperTypeAhead.tsx's
146
- * `insertSelectedItem` at the cost of breaking some of the a11y
147
- * focus changes,
148
- * - or do this jank at the cost of some small analytics noise.
149
- *
150
- * The focus behaviour still needs cleanup
151
- */
152
- selectPreviousItem();
153
- selectNextItem();
154
- }
155
- onItemSelect(event.shiftKey ? SelectItemMode.SHIFT_ENTER : SelectItemMode.ENTER);
156
- }
157
- break;
158
- case 'Tab':
159
- if (selectedIndex === -1) {
160
- /**
161
- * TODO DTR-1401: (also see ED-17200) There are two options
162
- * here, either
163
- * - set the index directly to 1 in WrapperTypeAhead.tsx's
164
- * `insertSelectedItem` at the cost of breaking some of the a11y
165
- * focus changes,
166
- * - or do this jank at the cost of some small analytics noise.
167
- *
168
- */
169
- selectPreviousItem();
170
- selectNextItem();
171
- }
172
- // TODO DTR-1401: why is this calling select item when hitting tab? fix this in DTR-1401
173
- onItemSelect(SelectItemMode.TAB);
174
- break;
175
- case 'ArrowDown':
176
- selectNextItem();
177
- break;
178
- case 'ArrowUp':
179
- selectPreviousItem();
180
- break;
181
- }
182
- var undoRedoType = isUndoRedoShortcut(event);
183
- if (onUndoRedo && undoRedoType && onUndoRedo(undoRedoType)) {
184
- stopDefault = true;
185
- }
186
- if (isNavigationKey(event) || stopDefault) {
187
- event.stopPropagation();
188
- event.preventDefault();
189
- return false;
190
- }
191
- }, [onUndoRedo, onItemSelect, selectNextItem, selectPreviousItem, cancel, cleanedInputContent, editorView.state]);
192
- var onClick = useCallback(function (event) {
193
- var _inputRef$current;
194
- event.stopPropagation();
195
- event.preventDefault();
196
- onQueryFocus();
197
- (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
198
- return false;
199
- }, [onQueryFocus]);
200
- useLayoutEffect(function () {
201
- if (!ref.current) {
202
- return;
203
- }
204
- var element = ref.current;
205
- var onFocusIn = function onFocusIn(event) {
206
- onQueryFocus();
207
- };
208
- var keyDown = function keyDown(event) {
209
- var key = keyNameNormalized(event);
210
- if (['ArrowLeft', 'ArrowRight'].includes(key) && document.getSelection && document.getSelection()) {
211
- var _ref$current3;
212
- var q = ((_ref$current3 = ref.current) === null || _ref$current3 === void 0 ? void 0 : _ref$current3.textContent) || '';
213
- var sel = document.getSelection();
214
- var isMovingRight = sel && 'ArrowRight' === key && sel.anchorOffset === q.length;
215
- var isMovingLeft = sel && 'ArrowLeft' === key && (sel.anchorOffset === 0 || event.metaKey);
216
- if (!isMovingRight && !isMovingLeft) {
217
- return;
218
- }
219
- cancel({
220
- forceFocusOnEditor: true,
221
- addPrefixTrigger: true,
222
- text: cleanedInputContent(),
223
- setSelectionAt: isMovingRight ? CloseSelectionOptions.AFTER_TEXT_INSERTED : CloseSelectionOptions.BEFORE_TEXT_INSERTED
224
- });
225
- event.preventDefault();
226
- event.stopPropagation();
227
- return;
228
- }
229
- checkKeyEvent(event);
230
- };
231
- var onFocusOut = function onFocusOut(event) {
232
- var _window$getSelection;
233
- var relatedTarget = event.relatedTarget;
234
-
235
- // Given the user is changing the focus
236
- // When the target is inside the TypeAhead Popup
237
- // Then the popup should stay open
238
- if (relatedTarget instanceof HTMLElement && relatedTarget.closest && relatedTarget.closest(".".concat(TYPE_AHEAD_POPUP_CONTENT_CLASS))) {
239
- return;
240
- }
241
-
242
- // See ED-14909: Chrome may emit focusout events where an input
243
- // device was not directly responsible. (This rears in react v17+ consumers
244
- // where react-managed node removal now appears to propagate focusout events to
245
- // our event listener). As this path is strictly for click or other typeahead
246
- // dismissals that don't involve typeahead item selection, we carve out an
247
- // exception for Chrome-specific events where an input device was not the initiator.
248
- if (browser.chrome && !(((_window$getSelection = window.getSelection()) === null || _window$getSelection === void 0 ? void 0 : _window$getSelection.type) === 'Range') && !('sourceCapabilities' in event && event.sourceCapabilities)) {
249
- return;
250
- }
251
- cancel({
252
- addPrefixTrigger: true,
253
- text: cleanedInputContent(),
254
- setSelectionAt: CloseSelectionOptions.BEFORE_TEXT_INSERTED,
255
- forceFocusOnEditor: false
256
- });
257
- };
258
- var close = function close() {
259
- cancel({
260
- addPrefixTrigger: false,
261
- text: '',
262
- forceFocusOnEditor: true,
263
- setSelectionAt: CloseSelectionOptions.BEFORE_TEXT_INSERTED
264
- });
265
- };
266
- var beforeinput = function beforeinput(e) {
267
- var _target$textContent;
268
- setInFocus(false);
269
- var target = e.target;
270
- if (e.isComposing || !(target instanceof HTMLElement)) {
271
- return;
272
- }
273
- if (e.inputType === 'historyUndo' && ((_target$textContent = target.textContent) === null || _target$textContent === void 0 ? void 0 : _target$textContent.length) === 0) {
274
- e.preventDefault();
275
- e.stopPropagation();
276
- close();
277
- return;
278
- }
279
- if (e.data != null && inputRef.current === null) {
280
- setQuery('');
281
-
282
- // We need to change the content on Safari
283
- // and set the cursor at the right place
284
- if (browser.safari) {
285
- e.preventDefault();
286
- var dataElement = document.createTextNode(e.data);
287
- element.appendChild(dataElement);
288
- var sel = window.getSelection();
289
- var range = document.createRange();
290
- range.setStart(dataElement, dataElement.length);
291
- range.collapse(true);
292
- sel === null || sel === void 0 || sel.removeAllRanges();
293
- sel === null || sel === void 0 || sel.addRange(range);
294
- }
295
- }
296
- };
297
- var onInput = null;
298
- if (browser.safari) {
299
- // On Safari, for reasons beyond my understanding,
300
- // The undo behavior is totally different from other browsers
301
- // That why we need to have an specific branch only for Safari.
302
- var _onInput = function _onInput(e) {
303
- var _target$textContent2;
304
- var target = e.target;
305
- if (e.isComposing || !(target instanceof HTMLElement)) {
306
- return;
307
- }
308
- if (e.inputType === 'historyUndo' && ((_target$textContent2 = target.textContent) === null || _target$textContent2 === void 0 ? void 0 : _target$textContent2.length) === 1) {
309
- e.preventDefault();
310
- e.stopPropagation();
311
- close();
312
- return;
313
- }
314
- };
315
- element.addEventListener('input', _onInput);
316
- }
317
- element.addEventListener('focusout', onFocusOut);
318
- element.addEventListener('focusin', onFocusIn);
319
- element.addEventListener('keydown', keyDown);
320
- element.addEventListener('beforeinput', beforeinput);
321
- return function () {
322
- element.removeEventListener('focusout', onFocusOut);
323
- element.removeEventListener('focusin', onFocusIn);
324
- element.removeEventListener('keydown', keyDown);
325
- element.removeEventListener('beforeinput', beforeinput);
326
- if (browser.safari) {
327
- element.removeEventListener('input', onInput);
328
- }
329
- };
330
- }, [triggerQueryPrefix, cleanedInputContent, onQueryFocus, cancel, checkKeyEvent, editorView.state]);
331
- useLayoutEffect(function () {
332
- var hasReopenQuery = typeof reopenQuery === 'string' && reopenQuery.trim().length > 0;
333
- if (ref.current && forceFocus) {
334
- setQuery(hasReopenQuery ? reopenQuery : null);
335
- requestAnimationFrame(function () {
336
- if (!(ref !== null && ref !== void 0 && ref.current)) {
337
- return;
338
- }
339
- var sel = window.getSelection();
340
- if (sel && hasReopenQuery && ref.current.lastChild instanceof Text) {
341
- var lastChild = ref.current.lastChild;
342
- var range = document.createRange();
343
- range.setStart(ref.current.lastChild, lastChild.length);
344
- range.collapse(true);
345
- sel.removeAllRanges();
346
- sel.addRange(range);
347
- }
348
- ref.current.focus();
349
- setInFocus(true);
350
- });
351
- }
352
- }, [forceFocus, reopenQuery]);
353
- var assistiveHintID = TYPE_AHEAD_DECORATION_ELEMENT_ID + '__assistiveHint';
354
- var intl = useIntl();
355
-
356
- /**
357
- When we migrated to emotion from styled component, we started getting this error.
358
- jsx-a11y/interactive-supports-focus
359
- Task added in https://product-fabric.atlassian.net/wiki/spaces/E/pages/3182068181/Potential+improvements#Moderate-changes.
360
- */
361
- return jsx(Fragment, null, triggerQueryPrefix, jsx("span", {
362
- css: querySpan,
363
- contentEditable: true,
364
- ref: ref,
365
- onKeyUp: onKeyUp,
366
- onClick: onClick,
367
- role: "combobox",
368
- "aria-controls": TYPE_AHEAD_DECORATION_ELEMENT_ID,
369
- "aria-autocomplete": "list",
370
- "aria-expanded": items.length !== 0,
371
- "aria-labelledby": assistiveHintID,
372
- suppressContentEditableWarning: true,
373
- "data-query-prefix": triggerQueryPrefix
374
- }, query === null ? jsx("input", {
375
- ref: inputRef,
376
- type: "text"
377
- }) : query), jsx("span", {
378
- id: assistiveHintID,
379
- style: {
380
- display: 'none'
381
- }
382
- }, intl.formatMessage(getAriaLabel(triggerQueryPrefix, intl)), ",", intl.formatMessage(typeAheadListMessages.inputQueryAssistiveLabel)), jsx(AssistiveText, {
383
- assistiveText: items.length === 0 ? intl.formatMessage(typeAheadListMessages.noSearchResultsLabel, {
384
- itemsLength: items.length
385
- }) : '',
386
- isInFocus: items.length === 0 || isInFocus,
387
- id: TYPE_AHEAD_DECORATION_ELEMENT_ID
388
- }));
389
- });
390
- InputQuery.displayName = 'InputQuery';
@@ -1,276 +0,0 @@
1
- import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
- var _templateObject;
4
- /** @jsx jsx */
5
-
6
- import React, { useMemo, useRef, useCallback, useLayoutEffect, useState } from 'react';
7
- import { jsx, css } from '@emotion/react';
8
- import { MenuGroup } from '@atlaskit/menu';
9
- import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
10
- import { CellMeasurer, CellMeasurerCache } from 'react-virtualized/dist/commonjs/CellMeasurer';
11
- import { List } from 'react-virtualized/dist/commonjs/List';
12
- import { ICON_HEIGHT, ITEM_PADDING, TypeAheadListItem } from './TypeAheadListItem';
13
- import { injectIntl, useIntl } from 'react-intl-next';
14
- import { typeAheadListMessages } from '../messages';
15
- import { getTypeAheadListAriaLabels, moveSelectedIndex } from '../utils';
16
- import { updateSelectedIndex } from '../commands/update-selected-index';
17
- import { AssistiveText } from './AssistiveText';
18
- import { TYPE_AHEAD_DECORATION_ELEMENT_ID } from '../constants';
19
- var LIST_ITEM_ESTIMATED_HEIGHT = ICON_HEIGHT + ITEM_PADDING * 2;
20
- var LIST_WIDTH = 320;
21
- var TypeaheadAssistiveTextPureComponent = /*#__PURE__*/React.memo(function (_ref) {
22
- var numberOfResults = _ref.numberOfResults;
23
- var intl = useIntl();
24
- return jsx(AssistiveText, {
25
- assistiveText: intl.formatMessage(typeAheadListMessages.searchResultsLabel, {
26
- itemsLength: numberOfResults
27
- })
28
- // when the popup is open its always in focus
29
- ,
30
- isInFocus: true,
31
- id: TYPE_AHEAD_DECORATION_ELEMENT_ID + '__popup'
32
- });
33
- });
34
- var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref2) {
35
- var _decorationElement$qu2;
36
- var items = _ref2.items,
37
- selectedIndex = _ref2.selectedIndex,
38
- editorView = _ref2.editorView,
39
- onItemClick = _ref2.onItemClick,
40
- intl = _ref2.intl,
41
- fitHeight = _ref2.fitHeight,
42
- decorationElement = _ref2.decorationElement,
43
- triggerHandler = _ref2.triggerHandler;
44
- var listRef = useRef();
45
- var listContainerRef = useRef(null);
46
- var lastVisibleIndexes = useRef({
47
- overscanStartIndex: 0,
48
- overscanStopIndex: 0,
49
- startIndex: 0,
50
- stopIndex: 0
51
- });
52
- var estimatedHeight = items.length * LIST_ITEM_ESTIMATED_HEIGHT;
53
- var _useState = useState(Math.min(estimatedHeight, fitHeight)),
54
- _useState2 = _slicedToArray(_useState, 2),
55
- height = _useState2[0],
56
- setHeight = _useState2[1];
57
- var _useState3 = useState(new CellMeasurerCache({
58
- fixedWidth: true,
59
- defaultHeight: LIST_ITEM_ESTIMATED_HEIGHT
60
- })),
61
- _useState4 = _slicedToArray(_useState3, 2),
62
- cache = _useState4[0],
63
- setCache = _useState4[1];
64
- var onItemsRendered = useCallback(function (props) {
65
- lastVisibleIndexes.current = props;
66
- }, []);
67
- var actions = useMemo(function () {
68
- return {
69
- onItemClick: onItemClick
70
- };
71
- }, [onItemClick]);
72
- var isNavigationKey = function isNavigationKey(event) {
73
- return ['ArrowDown', 'ArrowUp', 'Tab', 'Enter'].includes(event.key);
74
- };
75
- var focusTargetElement = useCallback(function () {
76
- var _decorationElement$qu;
77
- //To reset the selected index
78
- updateSelectedIndex(-1)(editorView.state, editorView.dispatch);
79
- listRef.current.scrollToRow(0);
80
- decorationElement === null || decorationElement === void 0 || (_decorationElement$qu = decorationElement.querySelector("[role='combobox']")) === null || _decorationElement$qu === void 0 || _decorationElement$qu.focus();
81
- }, [editorView, listRef, decorationElement]);
82
- var selectNextItem = useMemo(function () {
83
- return moveSelectedIndex({
84
- editorView: editorView,
85
- direction: 'next'
86
- });
87
- }, [editorView]);
88
- var selectPreviousItem = useMemo(function () {
89
- return moveSelectedIndex({
90
- editorView: editorView,
91
- direction: 'previous'
92
- });
93
- }, [editorView]);
94
- var lastVisibleStartIndex = lastVisibleIndexes.current.startIndex;
95
- var lastVisibleStopIndex = lastVisibleIndexes.current.stopIndex;
96
- var onScroll = useCallback(function (_ref3) {
97
- var scrollUpdateWasRequested = _ref3.scrollUpdateWasRequested;
98
- if (!scrollUpdateWasRequested) {
99
- return;
100
- }
101
-
102
- // In case the user scroll to a non-visible item like press ArrowUp from the first index
103
- // We will force the scroll calling the scrollToItem in the useEffect hook
104
- // When the scroll happens and we render the elements,
105
- // we still need calculate the items height and re-draw the List.
106
- // It is possible the item selected became invisible again (because the items height changed)
107
- // So, we need to wait for height to be calculated. Then we need to check
108
- // if the selected item is visible or not. If it isn't visible we call the scrollToItem again.
109
- //
110
- // We can't do this check in the first frame because that frame is being used by the resetScreenThrottled
111
- // to calculate each height. THen, we can schedule a new frame when this one finishs.
112
- requestAnimationFrame(function () {
113
- requestAnimationFrame(function () {
114
- var isSelectedItemVisible = selectedIndex >= lastVisibleStartIndex && selectedIndex <= lastVisibleStopIndex;
115
-
116
- //Should scroll to the list item only when the selectedIndex >= 0 and item is not visible
117
- if (!isSelectedItemVisible && selectedIndex !== -1) {
118
- listRef.current.scrollToRow(selectedIndex);
119
- } else if (selectedIndex === -1) {
120
- listRef.current.scrollToRow(0);
121
- }
122
- });
123
- });
124
- }, [selectedIndex, lastVisibleStartIndex, lastVisibleStopIndex]);
125
- var _onMouseMove = function onMouseMove(event, index) {
126
- event.preventDefault();
127
- event.stopPropagation();
128
- if (selectedIndex === index) {
129
- return;
130
- }
131
- updateSelectedIndex(index)(editorView.state, editorView.dispatch);
132
- };
133
- useLayoutEffect(function () {
134
- if (!listRef.current) {
135
- return;
136
- }
137
- var isSelectedItemVisible = selectedIndex >= lastVisibleStartIndex && selectedIndex <= lastVisibleStopIndex;
138
-
139
- //Should scroll to the list item only when the selectedIndex >= 0 and item is not visible
140
- if (!isSelectedItemVisible && selectedIndex !== -1) {
141
- listRef.current.scrollToRow(selectedIndex);
142
- } else if (selectedIndex === -1) {
143
- listRef.current.scrollToRow(0);
144
- }
145
- }, [selectedIndex, lastVisibleStartIndex, lastVisibleStopIndex]);
146
- useLayoutEffect(function () {
147
- setCache(new CellMeasurerCache({
148
- fixedWidth: true,
149
- defaultHeight: LIST_ITEM_ESTIMATED_HEIGHT
150
- }));
151
- // When query is updated, sometimes the scroll position of the menu is not at the top
152
- // Scrolling back to top for consistency
153
- requestAnimationFrame(function () {
154
- var _listContainerRef$cur;
155
- if ((_listContainerRef$cur = listContainerRef.current) !== null && _listContainerRef$cur !== void 0 && _listContainerRef$cur.firstChild) {
156
- listContainerRef.current.firstChild.scrollTo(0, 0);
157
- }
158
- });
159
- }, [items]);
160
- useLayoutEffect(function () {
161
- var height = Math.min(items.reduce(function (prevValue, currentValue, index) {
162
- return prevValue + cache.rowHeight({
163
- index: index
164
- });
165
- }, 0), fitHeight);
166
- setHeight(height);
167
- }, [items, cache, fitHeight]);
168
- useLayoutEffect(function () {
169
- if (!listContainerRef.current) {
170
- return;
171
- }
172
- var element = listContainerRef.current;
173
- /**
174
- * To handle the key events on the list
175
- * @param event
176
- */
177
- var handleKeyDown = function handleKeyDown(event) {
178
- if (isNavigationKey(event)) {
179
- switch (event.key) {
180
- case 'ArrowDown':
181
- selectNextItem();
182
- event.preventDefault();
183
- event.stopPropagation();
184
- break;
185
- case 'ArrowUp':
186
- selectPreviousItem();
187
- event.preventDefault();
188
- event.stopPropagation();
189
- break;
190
-
191
- // TODO DTR-1401: why is this calling item click when hitting tab? fix this in DTR-1401
192
- case 'Tab':
193
- //Tab key quick inserts the selected item.
194
- onItemClick(SelectItemMode.TAB, selectedIndex);
195
- event.preventDefault();
196
- break;
197
- case 'Enter':
198
- //Enter key quick inserts the selected item.
199
- if (!event.isComposing || event.which !== 229 && event.keyCode !== 229) {
200
- onItemClick(event.shiftKey ? SelectItemMode.SHIFT_ENTER : SelectItemMode.ENTER, selectedIndex);
201
- event.preventDefault();
202
- }
203
- break;
204
- default:
205
- event.preventDefault();
206
- }
207
- } else {
208
- //All the remaining keys sets focus on the typeahead query(inputQuery.tsx))
209
- focusTargetElement();
210
- }
211
- };
212
- element === null || element === void 0 || element.addEventListener('keydown', handleKeyDown);
213
- return function () {
214
- element === null || element === void 0 || element.removeEventListener('keydown', handleKeyDown);
215
- };
216
- }, [editorView.state, focusTargetElement, selectNextItem, selectPreviousItem, selectedIndex, onItemClick, items.length]);
217
- var renderRow = function renderRow(_ref4) {
218
- var index = _ref4.index,
219
- key = _ref4.key,
220
- style = _ref4.style,
221
- parent = _ref4.parent;
222
- var currentItem = items[index];
223
- return jsx(CellMeasurer, {
224
- key: key,
225
- cache: cache,
226
- parent: parent,
227
- columnIndex: 0,
228
- rowIndex: index
229
- }, jsx("div", {
230
- style: style,
231
- "data-index": index
232
- }, jsx("div", {
233
- "data-testid": "list-item-height-observed-".concat(index),
234
- onMouseMove: function onMouseMove(e) {
235
- return _onMouseMove(e, index);
236
- }
237
- }, jsx(TypeAheadListItem, {
238
- key: items[index].title,
239
- item: currentItem,
240
- itemsLength: items.length,
241
- itemIndex: index,
242
- selectedIndex: selectedIndex,
243
- onItemClick: actions.onItemClick,
244
- ariaLabel: getTypeAheadListAriaLabels(triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.trigger, intl, currentItem).listItemAriaLabel
245
- }))));
246
- };
247
- var popupAriaLabel = getTypeAheadListAriaLabels(triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.trigger, intl).popupAriaLabel;
248
- if (!Array.isArray(items)) {
249
- return null;
250
- }
251
- var menuGroupId = ((_decorationElement$qu2 = decorationElement.querySelector("[role='combobox']")) === null || _decorationElement$qu2 === void 0 ? void 0 : _decorationElement$qu2.getAttribute('aria-controls')) || TYPE_AHEAD_DECORATION_ELEMENT_ID;
252
- return jsx(MenuGroup, {
253
- "aria-label": popupAriaLabel,
254
- "aria-relevant": "additions removals"
255
- }, jsx("div", {
256
- id: menuGroupId,
257
- ref: listContainerRef
258
- }, jsx(List, {
259
- rowRenderer: renderRow,
260
- ref: listRef,
261
- rowCount: items.length,
262
- rowHeight: cache.rowHeight,
263
- onRowsRendered: onItemsRendered,
264
- width: LIST_WIDTH,
265
- onScroll: onScroll,
266
- height: height,
267
- overscanRowCount: 3,
268
- containerRole: "presentation",
269
- role: "listbox",
270
- css: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n button {\n padding: ", "\n ", " 11px;\n span:last-child span:last-child {\n white-space: normal;\n }\n }\n "])), "var(--ds-space-150, 12px)", "var(--ds-space-150, 12px)")
271
- }), jsx(TypeaheadAssistiveTextPureComponent, {
272
- numberOfResults: items.length.toString()
273
- })));
274
- });
275
- export var TypeAheadList = injectIntl(TypeAheadListComponent);
276
- TypeAheadList.displayName = 'TypeAheadList';