@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,169 +0,0 @@
1
- import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
3
- /** @jsx jsx */
4
- import React, { useCallback, useMemo, useLayoutEffect } from 'react';
5
- import { css, jsx } from '@emotion/react';
6
- import { DN600, N200, N800, N30, B400 } from '@atlaskit/theme/colors';
7
- import { themed } from '@atlaskit/theme/components';
8
- import { borderRadius } from '@atlaskit/theme/constants';
9
- import { ButtonItem } from '@atlaskit/menu';
10
- import { relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
11
- import { IconFallback } from '@atlaskit/editor-common/quick-insert';
12
- import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
13
- import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
14
- import { useIntl } from 'react-intl-next';
15
- import { typeAheadListMessages } from '../messages';
16
- export var ICON_HEIGHT = 40;
17
- export var ICON_WIDTH = 40;
18
- export var ITEM_PADDING = 12;
19
- export var itemIcon = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: ", "px;\n height: ", "px;\n overflow: hidden;\n border: 1px solid ", "; /* N60 at 50% */\n border-radius: ", "px;\n box-sizing: border-box;\n\n display: flex;\n justify-content: center;\n align-items: center;\n\n div {\n width: ", "px;\n height: ", "px;\n }\n"])), ICON_WIDTH, ICON_HEIGHT, "var(--ds-border, rgba(223, 225, 229, 0.5))", borderRadius(), ICON_WIDTH, ICON_HEIGHT);
20
- var itemBody = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n"])));
21
- var itemText = function itemText(theme) {
22
- return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n white-space: initial;\n color: ", ";\n .item-title {\n line-height: 1.4;\n }\n .item-description {\n font-size: ", ";\n color: ", ";\n margin-top: 3px;\n }\n"])), themed({
23
- light: "var(--ds-text, ".concat(N800, ")"),
24
- dark: "var(--ds-text, ".concat(DN600, ")")
25
- })(theme), relativeFontSizeToBase16(12), "var(--ds-text-subtlest, ".concat(N200, ")"));
26
- };
27
- var itemAfter = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n flex: 0 0 auto;\n"])));
28
- var customRenderItemDivStyle = css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n overflow: hidden;\n &:focus {\n box-shadow: inset 2px 0px 0px ", ";\n background-color: ", ";\n outline: none;\n }\n"])), "var(--ds-border-focused, ".concat(B400, ")"), "var(--ds-background-neutral-subtle-hovered, ".concat(N30, ")"));
29
-
30
- /**
31
- * This CSS emulates the desired behaviour with :focus-visible for firefox.
32
- * Firefox unfortunately does not register keyboard focus if user mouseDown and drag a typeahead item
33
- * resulting in focus-visible style not drawn.
34
- */
35
- var selectionFrame = {
36
- '& > button:focus': {
37
- boxShadow: "inset 2px 0px 0px ".concat("var(--ds-border-focused, ".concat(B400, ")"), ";"),
38
- backgroundColor: "".concat("var(--ds-background-neutral-subtle-hovered, ".concat(N30, ")")),
39
- outline: 'none',
40
- '&:active': {
41
- boxShadow: 'none'
42
- }
43
- },
44
- '& > button:hover': {
45
- backgroundColor: 'inherit',
46
- outline: 'none'
47
- }
48
- };
49
- var selectedStyle = css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n background-color: ", ";\n box-shadow: inset 2px 0px 0px ", ";\n"])), "var(--ds-background-neutral-subtle-hovered, ".concat(N30, ")"), "var(--ds-border-focused, ".concat(B400, ")"));
50
- var FallbackIcon = /*#__PURE__*/React.memo(function (_ref) {
51
- var label = _ref.label;
52
- return jsx(IconFallback, null);
53
- });
54
- var noop = function noop() {};
55
- var AssistiveText = function AssistiveText(_ref2) {
56
- var title = _ref2.title,
57
- description = _ref2.description,
58
- shortcut = _ref2.shortcut;
59
- var intl = useIntl();
60
- var descriptionText = description ? " ".concat(intl.formatMessage(typeAheadListMessages.descriptionLabel), " ").concat(description, ".") : '';
61
- var shortcutText = shortcut ? " ".concat(intl.formatMessage(typeAheadListMessages.shortcutLabel), " ").concat(shortcut, ".") : '';
62
- return jsx("span", {
63
- className: "assistive"
64
- }, "".concat(title, ". ").concat(descriptionText, " ").concat(shortcutText));
65
- };
66
- export var TypeAheadListItem = function TypeAheadListItem(_ref3) {
67
- var item = _ref3.item,
68
- itemsLength = _ref3.itemsLength,
69
- selectedIndex = _ref3.selectedIndex,
70
- onItemClick = _ref3.onItemClick,
71
- itemIndex = _ref3.itemIndex,
72
- ariaLabel = _ref3.ariaLabel;
73
- /**
74
- * To select and highlight the first Item when no item is selected
75
- * However selectedIndex remains -1, So that user does not skip the first item when down arrow key is used from typeahead query(inputQuery.tsx)
76
- */
77
- var isSelected = itemIndex === selectedIndex || selectedIndex === -1 && itemIndex === 0;
78
- var icon = item.icon,
79
- title = item.title,
80
- customRenderItem = item.render;
81
- var elementIcon = useMemo(function () {
82
- return jsx("div", {
83
- css: itemIcon
84
- }, icon ? icon() : jsx(FallbackIcon, {
85
- label: title
86
- }));
87
- }, [icon, title]);
88
- var insertSelectedItem = useCallback(function () {
89
- onItemClick(SelectItemMode.SELECTED, itemIndex);
90
- }, [onItemClick, itemIndex]);
91
- var customItemRef = /*#__PURE__*/React.createRef();
92
- var buttonItemRef = /*#__PURE__*/React.createRef();
93
- var shouldUpdateFocus = selectedIndex === itemIndex;
94
- useLayoutEffect(function () {
95
- if (shouldUpdateFocus) {
96
- var _customItemRef$curren;
97
- customItemRef === null || customItemRef === void 0 || (_customItemRef$curren = customItemRef.current) === null || _customItemRef$curren === void 0 || _customItemRef$curren.focus();
98
- }
99
- }, [customItemRef, shouldUpdateFocus]);
100
- useLayoutEffect(function () {
101
- if (shouldUpdateFocus) {
102
- var _buttonItemRef$curren;
103
- buttonItemRef === null || buttonItemRef === void 0 || (_buttonItemRef$curren = buttonItemRef.current) === null || _buttonItemRef$curren === void 0 || _buttonItemRef$curren.focus();
104
- }
105
- }, [buttonItemRef, shouldUpdateFocus]);
106
- var customItem = useMemo(function () {
107
- if (!customRenderItem) {
108
- return null;
109
- }
110
- var Comp = customRenderItem;
111
- var listItemClasses = [customRenderItemDivStyle, isSelected && selectedStyle];
112
- return jsx("div", {
113
- "aria-selected": isSelected,
114
- role: "option",
115
- "aria-label": ariaLabel,
116
- "aria-setsize": itemsLength,
117
- "aria-posinset": itemIndex,
118
- tabIndex: 0,
119
- css: listItemClasses,
120
- className: "ak-typeahead-item ".concat(isSelected ? 'typeahead-selected-item' : '')
121
- //CSS classes added for test cases purpose
122
- ,
123
- ref: customItemRef
124
- }, jsx("div", {
125
- "aria-hidden": true
126
- }, jsx(Comp, {
127
- onClick: insertSelectedItem,
128
- isSelected: false //The selection styles are handled in the parent div instead. Hence isSelected is made false always.
129
- ,
130
- onHover: noop
131
- })));
132
- }, [customRenderItem, isSelected, ariaLabel, itemsLength, customItemRef, insertSelectedItem, itemIndex]);
133
- if (customItem) {
134
- return customItem;
135
- }
136
- var listItemClasses = [selectionFrame, isSelected && selectedStyle];
137
- return jsx("span", {
138
- css: listItemClasses
139
- }, jsx(ButtonItem, {
140
- onClick: insertSelectedItem,
141
- iconBefore: elementIcon,
142
- isSelected: isSelected,
143
- "aria-selected": isSelected,
144
- "aria-label": title,
145
- "aria-setsize": itemsLength,
146
- "aria-posinset": itemIndex,
147
- role: "option",
148
- ref: buttonItemRef,
149
- css: listItemClasses
150
- }, jsx("div", {
151
- "aria-hidden": true
152
- }, jsx("div", {
153
- css: itemText
154
- }, jsx("div", {
155
- css: itemBody
156
- }, jsx("div", {
157
- className: "item-title"
158
- }, item.title), jsx("div", {
159
- css: itemAfter
160
- }, item.keyshortcut && jsx("div", {
161
- css: shortcutStyle
162
- }, item.keyshortcut))), jsx("div", {
163
- className: "item-description"
164
- }, item.description))), jsx(AssistiveText, {
165
- title: item.title,
166
- description: item.description,
167
- shortcut: item.keyshortcut
168
- })));
169
- };
@@ -1,220 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
3
- var _templateObject;
4
- /** @jsx jsx */
5
- import React, { useCallback, useEffect, useMemo, useState, useLayoutEffect, useRef } from 'react';
6
- import { css, jsx } from '@emotion/react';
7
- import rafSchedule from 'raf-schd';
8
- import { akEditorFloatingDialogZIndex } from '@atlaskit/editor-shared-styles';
9
- import { findOverflowScrollParent, Popup } from '@atlaskit/editor-common/ui';
10
- import { borderRadius } from '@atlaskit/theme/constants';
11
- import { N0, N60A, N50A } from '@atlaskit/theme/colors';
12
- import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
13
- import { CloseSelectionOptions, TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE, TYPE_AHEAD_POPUP_CONTENT_CLASS } from '../constants';
14
- import { TypeAheadList } from './TypeAheadList';
15
- import { ITEM_PADDING } from './TypeAheadListItem';
16
- var DEFAULT_TYPEAHEAD_MENU_HEIGHT = 380;
17
- var typeAheadContent = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background: ", ";\n border-radius: ", "px;\n box-shadow: ", ";\n padding: ", " 0;\n width: 320px;\n max-height: 380px; /* ~5.5 visibile items */\n overflow-y: auto;\n -ms-overflow-style: -ms-autohiding-scrollbar;\n position: relative;\n"])), "var(--ds-surface-overlay, ".concat(N0, ")"), borderRadius(), "var(--ds-shadow-overlay, ".concat("0 0 1px ".concat(N60A, ", 0 4px 8px -2px ").concat(N50A), ")"), "var(--ds-space-050, 4px)");
18
- var Highlight = function Highlight(_ref) {
19
- var state = _ref.state,
20
- triggerHandler = _ref.triggerHandler;
21
- if (!(triggerHandler !== null && triggerHandler !== void 0 && triggerHandler.getHighlight)) {
22
- return null;
23
- }
24
- return triggerHandler.getHighlight(state);
25
- };
26
- var OFFSET = [0, 8];
27
- export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
28
- var editorView = props.editorView,
29
- triggerHandler = props.triggerHandler,
30
- anchorElement = props.anchorElement,
31
- popupsMountPoint = props.popupsMountPoint,
32
- popupsBoundariesElement = props.popupsBoundariesElement,
33
- popupsScrollableElement = props.popupsScrollableElement,
34
- items = props.items,
35
- selectedIndex = props.selectedIndex,
36
- onItemInsert = props.onItemInsert,
37
- fireAnalyticsCallback = props.fireAnalyticsCallback,
38
- isEmptyQuery = props.isEmptyQuery,
39
- cancel = props.cancel;
40
- var ref = useRef(null);
41
- var startTime = useMemo(function () {
42
- return performance.now();
43
- },
44
- // In case those props changes
45
- // we need to recreate the startTime
46
- [items, isEmptyQuery, fireAnalyticsCallback, triggerHandler] // eslint-disable-line react-hooks/exhaustive-deps
47
- );
48
-
49
- useEffect(function () {
50
- if (!fireAnalyticsCallback) {
51
- return;
52
- }
53
- var stopTime = performance.now();
54
- var time = stopTime - startTime;
55
- fireAnalyticsCallback({
56
- payload: {
57
- action: ACTION.RENDERED,
58
- actionSubject: ACTION_SUBJECT.TYPEAHEAD,
59
- eventType: EVENT_TYPE.OPERATIONAL,
60
- attributes: {
61
- time: time,
62
- items: items.length,
63
- initial: isEmptyQuery
64
- }
65
- }
66
- });
67
- }, [startTime, items, fireAnalyticsCallback, isEmptyQuery,
68
- // In case the current triggerHandler changes
69
- // e.g: Inserting a mention using the quick insert
70
- // we need to send the event again
71
- // eslint-disable-next-line react-hooks/exhaustive-deps
72
- triggerHandler]);
73
- useEffect(function () {
74
- if (!fireAnalyticsCallback) {
75
- return;
76
- }
77
- fireAnalyticsCallback({
78
- payload: {
79
- action: ACTION.VIEWED,
80
- actionSubject: ACTION_SUBJECT.TYPEAHEAD_ITEM,
81
- eventType: EVENT_TYPE.OPERATIONAL,
82
- attributes: {
83
- index: selectedIndex,
84
- items: items.length
85
- }
86
- }
87
- });
88
- }, [items, fireAnalyticsCallback, selectedIndex,
89
- // In case the current triggerHandler changes
90
- // e.g: Inserting a mention using the quick insert
91
- // we need to send the event again
92
- // eslint-disable-next-line react-hooks/exhaustive-deps
93
- triggerHandler]);
94
- var _useState = useState(DEFAULT_TYPEAHEAD_MENU_HEIGHT),
95
- _useState2 = _slicedToArray(_useState, 2),
96
- fitHeight = _useState2[0],
97
- setFitHeight = _useState2[1];
98
- var getFitHeight = useCallback(function () {
99
- if (!anchorElement || !popupsMountPoint) {
100
- return;
101
- }
102
- var target = anchorElement;
103
- var _target$getBoundingCl = target.getBoundingClientRect(),
104
- targetTop = _target$getBoundingCl.top,
105
- targetHeight = _target$getBoundingCl.height;
106
- var boundariesElement = document.body;
107
- var _boundariesElement$ge = boundariesElement.getBoundingClientRect(),
108
- boundariesHeight = _boundariesElement$ge.height,
109
- boundariesTop = _boundariesElement$ge.top;
110
-
111
- // Calculating the space above and space below our decoration
112
- var spaceAbove = targetTop - (boundariesTop - boundariesElement.scrollTop);
113
- var spaceBelow = boundariesTop + boundariesHeight - (targetTop + targetHeight);
114
-
115
- // Keep default height if more than enough space
116
- if (spaceBelow >= DEFAULT_TYPEAHEAD_MENU_HEIGHT) {
117
- return setFitHeight(DEFAULT_TYPEAHEAD_MENU_HEIGHT);
118
- }
119
-
120
- // Determines whether typeahead will fit above or below decoration
121
- // and return the space available.
122
- var newFitHeight = spaceBelow >= spaceAbove ? spaceBelow : spaceAbove;
123
-
124
- // Each typeahead item has some padding
125
- // We want to leave some space at the top so first item
126
- // is not partially cropped
127
- var fitHeightWithSpace = newFitHeight - ITEM_PADDING * 2;
128
-
129
- // Ensure typeahead height is max its default height
130
- var minFitHeight = Math.min(DEFAULT_TYPEAHEAD_MENU_HEIGHT, fitHeightWithSpace);
131
- return setFitHeight(minFitHeight);
132
- }, [anchorElement, popupsMountPoint]);
133
- var getFitHeightDebounced = rafSchedule(getFitHeight);
134
- useLayoutEffect(function () {
135
- var scrollableElement = popupsScrollableElement || findOverflowScrollParent(anchorElement);
136
- getFitHeight();
137
- window.addEventListener('resize', getFitHeightDebounced);
138
- if (scrollableElement) {
139
- scrollableElement.addEventListener('scroll', getFitHeightDebounced);
140
- }
141
- return function () {
142
- window.removeEventListener('resize', getFitHeightDebounced);
143
- if (scrollableElement) {
144
- scrollableElement.removeEventListener('scroll', getFitHeightDebounced);
145
- }
146
- };
147
- }, [anchorElement, popupsScrollableElement, getFitHeightDebounced, getFitHeight]);
148
- useLayoutEffect(function () {
149
- var focusOut = function focusOut(event) {
150
- var _window$getSelection;
151
- var relatedTarget = event.relatedTarget;
152
-
153
- // Given the user is changing the focus
154
- // When the target is inside the TypeAhead Popup
155
- // Then the popup should stay open
156
- if (relatedTarget instanceof HTMLElement && relatedTarget.closest && (relatedTarget.closest(".".concat(TYPE_AHEAD_POPUP_CONTENT_CLASS)) || relatedTarget.closest("[data-type-ahead=\"".concat(TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE, "\"]")))) {
157
- return;
158
- }
159
- if (!(((_window$getSelection = window.getSelection()) === null || _window$getSelection === void 0 ? void 0 : _window$getSelection.type) === 'Range')) {
160
- return;
161
- }
162
- cancel({
163
- addPrefixTrigger: true,
164
- setSelectionAt: CloseSelectionOptions.AFTER_TEXT_INSERTED,
165
- forceFocusOnEditor: false
166
- });
167
- };
168
- var element = ref.current;
169
- element === null || element === void 0 || element.addEventListener('focusout', focusOut);
170
- return function () {
171
- element === null || element === void 0 || element.removeEventListener('focusout', focusOut);
172
- };
173
- }, [ref, cancel]);
174
-
175
- // ED-17443 When you press escape on typeahead panel, it should remove focus and close the panel
176
- // This is the expected keyboard behaviour advised by the Accessibility team
177
- useLayoutEffect(function () {
178
- var escape = function escape(event) {
179
- if (event.key === 'Escape') {
180
- cancel({
181
- addPrefixTrigger: true,
182
- setSelectionAt: CloseSelectionOptions.AFTER_TEXT_INSERTED,
183
- forceFocusOnEditor: true
184
- });
185
- }
186
- };
187
- var element = ref.current;
188
- element === null || element === void 0 || element.addEventListener('keydown', escape);
189
- return function () {
190
- element === null || element === void 0 || element.removeEventListener('keydown', escape);
191
- };
192
- }, [ref, cancel]);
193
- return jsx(Popup, {
194
- zIndex: akEditorFloatingDialogZIndex,
195
- target: anchorElement,
196
- mountTo: popupsMountPoint,
197
- boundariesElement: popupsBoundariesElement,
198
- scrollableElement: popupsScrollableElement,
199
- fitHeight: fitHeight,
200
- fitWidth: 340,
201
- offset: OFFSET
202
- }, jsx("div", {
203
- css: typeAheadContent,
204
- tabIndex: 0,
205
- className: TYPE_AHEAD_POPUP_CONTENT_CLASS,
206
- ref: ref
207
- }, jsx(Highlight, {
208
- state: editorView.state,
209
- triggerHandler: triggerHandler
210
- }), jsx(TypeAheadList, {
211
- items: items,
212
- selectedIndex: selectedIndex,
213
- onItemClick: onItemInsert,
214
- fitHeight: fitHeight,
215
- editorView: editorView,
216
- decorationElement: anchorElement,
217
- triggerHandler: triggerHandler
218
- })));
219
- });
220
- TypeAheadPopup.displayName = 'TypeAheadPopup';
@@ -1,117 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import React, { useMemo, useEffect, useLayoutEffect, useCallback, useRef, useState } from 'react';
3
- import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
4
- import { moveSelectedIndex, getPluginState } from '../utils';
5
- import { updateQuery } from '../commands/update-query';
6
- import { InputQuery } from './InputQuery';
7
- import { useLoadItems } from './hooks/use-load-items';
8
- import { useItemInsert } from './hooks/use-item-insert';
9
- import { useOnForceSelect } from './hooks/use-on-force-select';
10
- export var WrapperTypeAhead = /*#__PURE__*/React.memo(function (_ref) {
11
- var triggerHandler = _ref.triggerHandler,
12
- editorView = _ref.editorView,
13
- anchorElement = _ref.anchorElement,
14
- shouldFocusCursorInsideQuery = _ref.shouldFocusCursorInsideQuery,
15
- popupsMountPoint = _ref.popupsMountPoint,
16
- popupsBoundariesElement = _ref.popupsBoundariesElement,
17
- popupsScrollableElement = _ref.popupsScrollableElement,
18
- createAnalyticsEvent = _ref.createAnalyticsEvent,
19
- inputMethod = _ref.inputMethod,
20
- getDecorationPosition = _ref.getDecorationPosition,
21
- reopenQuery = _ref.reopenQuery,
22
- onUndoRedo = _ref.onUndoRedo;
23
- var _useState = useState(false),
24
- _useState2 = _slicedToArray(_useState, 2),
25
- closed = _useState2[0],
26
- setClosed = _useState2[1];
27
- var _useState3 = useState(reopenQuery || ''),
28
- _useState4 = _slicedToArray(_useState3, 2),
29
- query = _useState4[0],
30
- setQuery = _useState4[1];
31
- var queryRef = useRef(query);
32
- var editorViewRef = useRef(editorView);
33
- var items = useLoadItems(triggerHandler, editorView, query);
34
- useLayoutEffect(function () {
35
- queryRef.current = query;
36
- }, [query]);
37
- var _useItemInsert = useItemInsert(triggerHandler, editorView, items),
38
- _useItemInsert2 = _slicedToArray(_useItemInsert, 2),
39
- onItemInsert = _useItemInsert2[0],
40
- onTextInsert = _useItemInsert2[1];
41
- var selectNextItem = useMemo(function () {
42
- return moveSelectedIndex({
43
- editorView: editorView,
44
- direction: 'next'
45
- });
46
- }, [editorView]);
47
- var selectPreviousItem = useMemo(function () {
48
- return moveSelectedIndex({
49
- editorView: editorView,
50
- direction: 'previous'
51
- });
52
- }, [editorView]);
53
- var cancel = useCallback(function (_ref2) {
54
- var setSelectionAt = _ref2.setSelectionAt,
55
- addPrefixTrigger = _ref2.addPrefixTrigger,
56
- text = _ref2.text,
57
- forceFocusOnEditor = _ref2.forceFocusOnEditor;
58
- setClosed(true);
59
- var fullquery = addPrefixTrigger ? "".concat(triggerHandler.trigger).concat(text) : text;
60
- onTextInsert({
61
- forceFocusOnEditor: forceFocusOnEditor,
62
- setSelectionAt: setSelectionAt,
63
- text: fullquery
64
- });
65
- }, [triggerHandler, onTextInsert]);
66
- var insertSelectedItem = useCallback(function () {
67
- var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SelectItemMode.SELECTED;
68
- var view = editorViewRef.current;
69
- var _ref3 = getPluginState(view.state),
70
- selectedIndex = _ref3.selectedIndex;
71
- setClosed(true);
72
- queueMicrotask(function () {
73
- onItemInsert({
74
- mode: mode,
75
- index: selectedIndex,
76
- query: queryRef.current
77
- });
78
- });
79
- }, [onItemInsert]);
80
- var showTypeAheadPopupList = useCallback(function () {}, []);
81
- var closePopup = useCallback(function () {
82
- setClosed(true);
83
- }, []);
84
- useEffect(function () {
85
- var view = editorViewRef.current;
86
- var pluginState = getPluginState(view.state);
87
- if (query.length === 0 || query === (pluginState === null || pluginState === void 0 ? void 0 : pluginState.query) || !(pluginState !== null && pluginState !== void 0 && pluginState.triggerHandler)) {
88
- return;
89
- }
90
- updateQuery(query)(view.state, view.dispatch);
91
- }, [query, reopenQuery]);
92
- useOnForceSelect({
93
- triggerHandler: triggerHandler,
94
- items: items,
95
- query: query,
96
- editorView: editorView,
97
- closePopup: closePopup
98
- });
99
- if (closed) {
100
- return null;
101
- }
102
- return /*#__PURE__*/React.createElement(InputQuery, {
103
- triggerQueryPrefix: triggerHandler.trigger,
104
- onQueryChange: setQuery,
105
- onItemSelect: insertSelectedItem,
106
- selectNextItem: selectNextItem,
107
- selectPreviousItem: selectPreviousItem,
108
- onQueryFocus: showTypeAheadPopupList,
109
- cancel: cancel,
110
- forceFocus: shouldFocusCursorInsideQuery,
111
- onUndoRedo: onUndoRedo,
112
- reopenQuery: reopenQuery,
113
- editorView: editorView,
114
- items: items
115
- });
116
- });
117
- WrapperTypeAhead.displayName = 'WrapperTypeAhead';
@@ -1,103 +0,0 @@
1
- import { useLayoutEffect, useCallback, useRef } from 'react';
2
- import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
3
- import { closeTypeAhead } from '../../transforms/close-type-ahead';
4
- import { setSelectionBeforeQuery } from '../../transforms/set-selection-before-query';
5
- import { insertTypeAheadItem } from '../../commands/insert-type-ahead-item';
6
- import { CloseSelectionOptions } from '../../constants';
7
- var insertRawQuery = function insertRawQuery(_ref) {
8
- var view = _ref.view,
9
- setSelectionAt = _ref.setSelectionAt,
10
- text = _ref.text,
11
- forceFocusOnEditor = _ref.forceFocusOnEditor;
12
- var _view$state = view.state,
13
- tr = _view$state.tr,
14
- schema = _view$state.schema;
15
- closeTypeAhead(tr);
16
- if (text.length > 0) {
17
- tr.replaceSelectionWith(schema.text(text));
18
- if (setSelectionAt === CloseSelectionOptions.BEFORE_TEXT_INSERTED) {
19
- setSelectionBeforeQuery(text)(tr);
20
- }
21
- }
22
- view.dispatch(tr);
23
- if (forceFocusOnEditor) {
24
- view.focus();
25
- }
26
- };
27
- export var useItemInsert = function useItemInsert(triggerHandler, editorView, items) {
28
- var editorViewRef = useRef(editorView);
29
- var itemsRef = useRef(items);
30
- var onTextInsert = useCallback(function (_ref2) {
31
- var setSelectionAt = _ref2.setSelectionAt,
32
- text = _ref2.text,
33
- forceFocusOnEditor = _ref2.forceFocusOnEditor;
34
- if (!triggerHandler) {
35
- return;
36
- }
37
- var view = editorViewRef.current;
38
- insertRawQuery({
39
- view: view,
40
- setSelectionAt: setSelectionAt,
41
- text: text,
42
- forceFocusOnEditor: forceFocusOnEditor
43
- });
44
- }, [triggerHandler]);
45
- var onItemInsert = useCallback(function (_ref3) {
46
- var mode = _ref3.mode,
47
- index = _ref3.index,
48
- query = _ref3.query;
49
- var sourceListItem = itemsRef.current;
50
- if (sourceListItem.length === 0 || !triggerHandler) {
51
- var text = "".concat(triggerHandler.trigger).concat(query);
52
- onTextInsert({
53
- forceFocusOnEditor: true,
54
- setSelectionAt: CloseSelectionOptions.AFTER_TEXT_INSERTED,
55
- text: text
56
- });
57
- return;
58
- }
59
- var itemToInsert = sourceListItem[index];
60
- if (!itemToInsert) {
61
- return;
62
- }
63
- var view = editorViewRef.current;
64
- insertTypeAheadItem(view)({
65
- item: itemToInsert,
66
- handler: triggerHandler,
67
- mode: mode,
68
- query: query,
69
- sourceListItem: sourceListItem
70
- });
71
- }, [triggerHandler, onTextInsert]);
72
- var onItemMatch = useCallback(function (_ref4) {
73
- var mode = _ref4.mode,
74
- query = _ref4.query;
75
- var _items = itemsRef.current;
76
- if (_items && _items.length > 1) {
77
- return false;
78
- }
79
- if (_items.length === 1) {
80
- queueMicrotask(function () {
81
- onItemInsert({
82
- mode: mode,
83
- query: query,
84
- index: 0
85
- });
86
- });
87
- } else {
88
- var text = "".concat(triggerHandler.trigger).concat(query);
89
- queueMicrotask(function () {
90
- onTextInsert({
91
- forceFocusOnEditor: true,
92
- setSelectionAt: CloseSelectionOptions.AFTER_TEXT_INSERTED,
93
- text: mode === SelectItemMode.SPACE ? text.concat(' ') : text
94
- });
95
- });
96
- }
97
- return true;
98
- }, [onItemInsert, triggerHandler, onTextInsert]);
99
- useLayoutEffect(function () {
100
- itemsRef.current = items;
101
- }, [items]);
102
- return [onItemInsert, onTextInsert, onItemMatch];
103
- };
@@ -1,43 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import { useRef, useState, useEffect } from 'react';
3
- import { updateListItem } from '../../commands/update-list-items';
4
- var EMPTY_LIST_ITEM = [];
5
- export var useLoadItems = function useLoadItems(triggerHandler, editorView, query) {
6
- var _useState = useState(EMPTY_LIST_ITEM),
7
- _useState2 = _slicedToArray(_useState, 2),
8
- items = _useState2[0],
9
- setItems = _useState2[1];
10
- var componentIsMounted = useRef(true);
11
- var editorViewRef = useRef(editorView);
12
- useEffect(function () {
13
- var getItems = triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.getItems;
14
- if (!getItems) {
15
- setItems(EMPTY_LIST_ITEM);
16
- return;
17
- }
18
- var options = {
19
- query: query || '',
20
- editorState: editorView.state
21
- };
22
- var view = editorViewRef.current;
23
- getItems(options).then(function (result) {
24
- var list = result.length > 0 ? result : EMPTY_LIST_ITEM;
25
- if (componentIsMounted.current) {
26
- setItems(list);
27
- }
28
- queueMicrotask(function () {
29
- updateListItem(list)(view.state, view.dispatch);
30
- });
31
- });
32
-
33
- // ignore because EditorView is mutable but we don't want to
34
- // call loadItems when it changes, only when the query changes
35
- // eslint-disable-next-line react-hooks/exhaustive-deps
36
- }, [triggerHandler, query]);
37
- useEffect(function () {
38
- return function () {
39
- componentIsMounted.current = false;
40
- };
41
- }, []);
42
- return items;
43
- };
@@ -1,35 +0,0 @@
1
- import { useLayoutEffect, useRef } from 'react';
2
- import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
3
- import { insertTypeAheadItem } from '../../commands/insert-type-ahead-item';
4
- export var useOnForceSelect = function useOnForceSelect(_ref) {
5
- var triggerHandler = _ref.triggerHandler,
6
- items = _ref.items,
7
- query = _ref.query,
8
- editorView = _ref.editorView,
9
- closePopup = _ref.closePopup;
10
- var editorViewRef = useRef(editorView);
11
- useLayoutEffect(function () {
12
- if (!query || typeof triggerHandler.forceSelect !== 'function') {
13
- return;
14
- }
15
- var item = triggerHandler.forceSelect({
16
- items: items,
17
- query: query,
18
- editorState: editorViewRef.current.state
19
- });
20
- if (!item) {
21
- return;
22
- }
23
- var view = editorViewRef.current;
24
- closePopup();
25
- queueMicrotask(function () {
26
- insertTypeAheadItem(view)({
27
- item: item,
28
- mode: SelectItemMode.SPACE,
29
- query: query,
30
- handler: triggerHandler,
31
- sourceListItem: items
32
- });
33
- });
34
- }, [triggerHandler, closePopup, query, items]);
35
- };