@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,374 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- /**
3
- *
4
- * Revamped typeahead using decorations instead of the `typeAheadQuery` mark
5
- *
6
- * https://product-fabric.atlassian.net/wiki/spaces/E/pages/2992177582/Technical+TypeAhead+Data+Flow
7
- *
8
- *
9
- */
10
- import React from 'react';
11
- import { typeAheadQuery } from '@atlaskit/adf-schema';
12
- import { ACTION, ACTION_SUBJECT, EVENT_TYPE, fireAnalyticsEvent, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
13
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
14
- import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
15
- import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
16
- import { insertTypeAheadItem } from './commands/insert-type-ahead-item';
17
- import { updateSelectedIndex } from './commands/update-selected-index';
18
- import { inputRulePlugin } from './pm-plugins/input-rules';
19
- import { createPlugin as createInsertItemPlugin } from './pm-plugins/insert-item-plugin';
20
- import { pluginKey as typeAheadPluginKey } from './pm-plugins/key';
21
- import { createPlugin } from './pm-plugins/main';
22
- import { StatsModifier } from './stats-modifier';
23
- import { closeTypeAhead } from './transforms/close-type-ahead';
24
- import { openTypeAheadAtCursor } from './transforms/open-typeahead-at-cursor';
25
- import { useItemInsert } from './ui/hooks/use-item-insert';
26
- import { TypeAheadPopup } from './ui/TypeAheadPopup';
27
- import { findHandler, getPluginState, getTypeAheadHandler, getTypeAheadQuery, isTypeAheadAllowed, isTypeAheadOpen } from './utils';
28
- var TypeAheadMenu = /*#__PURE__*/React.memo(function (_ref) {
29
- var _popupMountRef$curren, _popupMountRef$curren2, _popupMountRef$curren3;
30
- var editorView = _ref.editorView,
31
- popupMountRef = _ref.popupMountRef,
32
- typeAheadState = _ref.typeAheadState,
33
- fireAnalyticsCallback = _ref.fireAnalyticsCallback;
34
- var isOpen = typeAheadState.decorationSet.find().length > 0;
35
- var triggerHandler = typeAheadState.triggerHandler,
36
- items = typeAheadState.items,
37
- selectedIndex = typeAheadState.selectedIndex,
38
- decorationElement = typeAheadState.decorationElement,
39
- decorationSet = typeAheadState.decorationSet,
40
- query = typeAheadState.query;
41
- var _useItemInsert = useItemInsert(triggerHandler, editorView, items),
42
- _useItemInsert2 = _slicedToArray(_useItemInsert, 3),
43
- onItemInsert = _useItemInsert2[0],
44
- onTextInsert = _useItemInsert2[1],
45
- onItemMatch = _useItemInsert2[2];
46
- var setSelectedItem = React.useCallback(function (_ref2) {
47
- var nextIndex = _ref2.index;
48
- queueMicrotask(function () {
49
- updateSelectedIndex(nextIndex)(editorView.state, editorView.dispatch);
50
- });
51
- }, [editorView]);
52
- var insertItem = React.useCallback(function () {
53
- var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SelectItemMode.SELECTED;
54
- var index = arguments.length > 1 ? arguments[1] : undefined;
55
- queueMicrotask(function () {
56
- onItemInsert({
57
- mode: mode,
58
- index: index,
59
- query: query
60
- });
61
- });
62
- }, [onItemInsert, query]);
63
- var cancel = React.useCallback(function (_ref3) {
64
- var setSelectionAt = _ref3.setSelectionAt,
65
- addPrefixTrigger = _ref3.addPrefixTrigger,
66
- forceFocusOnEditor = _ref3.forceFocusOnEditor;
67
- var fullQuery = addPrefixTrigger ? "".concat(triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.trigger).concat(query) : query;
68
- onTextInsert({
69
- forceFocusOnEditor: forceFocusOnEditor,
70
- setSelectionAt: setSelectionAt,
71
- text: fullQuery
72
- });
73
- }, [triggerHandler, onTextInsert, query]);
74
- React.useEffect(function () {
75
- if (!isOpen || !query) {
76
- return;
77
- }
78
- var isLastCharSpace = query[query.length - 1] === ' ';
79
- if (!isLastCharSpace) {
80
- return;
81
- }
82
- var result = onItemMatch({
83
- mode: SelectItemMode.SPACE,
84
- query: query.trim()
85
- });
86
- if (!result) {
87
- return;
88
- }
89
- }, [isOpen, query, onItemMatch]);
90
- if (!isOpen || !triggerHandler || !(decorationElement instanceof HTMLElement) || items.length === 0) {
91
- return null;
92
- }
93
- return /*#__PURE__*/React.createElement(TypeAheadPopup, {
94
- editorView: editorView,
95
- popupsMountPoint: (_popupMountRef$curren = popupMountRef.current) === null || _popupMountRef$curren === void 0 ? void 0 : _popupMountRef$curren.popupsMountPoint,
96
- popupsBoundariesElement: (_popupMountRef$curren2 = popupMountRef.current) === null || _popupMountRef$curren2 === void 0 ? void 0 : _popupMountRef$curren2.popupsBoundariesElement,
97
- popupsScrollableElement: (_popupMountRef$curren3 = popupMountRef.current) === null || _popupMountRef$curren3 === void 0 ? void 0 : _popupMountRef$curren3.popupsScrollableElement,
98
- anchorElement: decorationElement,
99
- triggerHandler: triggerHandler,
100
- fireAnalyticsCallback: fireAnalyticsCallback,
101
- items: items,
102
- selectedIndex: selectedIndex,
103
- setSelectedItem: setSelectedItem,
104
- onItemInsert: insertItem,
105
- decorationSet: decorationSet,
106
- isEmptyQuery: !query,
107
- cancel: cancel
108
- });
109
- });
110
- var createOpenAtTransaction = function createOpenAtTransaction(editorAnalyticsAPI) {
111
- return function (props) {
112
- return function (tr) {
113
- var triggerHandler = props.triggerHandler,
114
- inputMethod = props.inputMethod;
115
- openTypeAheadAtCursor({
116
- triggerHandler: triggerHandler,
117
- inputMethod: inputMethod
118
- })({
119
- tr: tr
120
- });
121
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
122
- action: ACTION.INVOKED,
123
- actionSubject: ACTION_SUBJECT.TYPEAHEAD,
124
- actionSubjectId: triggerHandler.id,
125
- attributes: {
126
- inputMethod: inputMethod
127
- },
128
- eventType: EVENT_TYPE.UI
129
- })(tr);
130
- return true;
131
- };
132
- };
133
- };
134
- var createOpenTypeAhead = function createOpenTypeAhead(editorViewRef, editorAnalyticsAPI) {
135
- return function (props) {
136
- if (!editorViewRef.current) {
137
- return false;
138
- }
139
- var view = editorViewRef.current;
140
- var tr = view.state.tr;
141
- createOpenAtTransaction(editorAnalyticsAPI)(props)(tr);
142
- view.dispatch(tr);
143
- return true;
144
- };
145
- };
146
- var createInsertTypeAheadItem = function createInsertTypeAheadItem(editorViewRef) {
147
- return function (props) {
148
- if (!editorViewRef.current) {
149
- return false;
150
- }
151
- var view = editorViewRef.current;
152
- var triggerHandler = props.triggerHandler,
153
- contentItem = props.contentItem,
154
- query = props.query,
155
- sourceListItem = props.sourceListItem,
156
- mode = props.mode;
157
- insertTypeAheadItem(view)({
158
- handler: triggerHandler,
159
- item: contentItem,
160
- mode: mode || SelectItemMode.SELECTED,
161
- query: query,
162
- sourceListItem: sourceListItem
163
- });
164
- return true;
165
- };
166
- };
167
- var createFindHandlerByTrigger = function createFindHandlerByTrigger(editorViewRef) {
168
- return function (trigger) {
169
- if (!editorViewRef.current) {
170
- return null;
171
- }
172
- var view = editorViewRef.current;
173
- return findHandler(trigger, view.state);
174
- };
175
- };
176
- var createCloseTypeAhead = function createCloseTypeAhead(editorViewRef) {
177
- return function (options) {
178
- if (!editorViewRef.current) {
179
- return false;
180
- }
181
- var view = editorViewRef.current;
182
- var currentQuery = getTypeAheadQuery(view.state) || '';
183
- var state = view.state;
184
- var tr = state.tr;
185
- if (options.attachCommand) {
186
- var fakeDispatch = function fakeDispatch(customTr) {
187
- tr = customTr;
188
- };
189
- options.attachCommand(state, fakeDispatch);
190
- }
191
- closeTypeAhead(tr);
192
- if (options.insertCurrentQueryAsRawText && currentQuery && currentQuery.length > 0) {
193
- var handler = getTypeAheadHandler(state);
194
- if (!handler) {
195
- return false;
196
- }
197
- var text = handler.trigger.concat(currentQuery);
198
- tr.replaceSelectionWith(state.schema.text(text));
199
- }
200
- view.dispatch(tr);
201
- if (!view.hasFocus()) {
202
- view.focus();
203
- }
204
- return true;
205
- };
206
- };
207
-
208
- /**
209
- *
210
- * Revamped typeahead using decorations instead of the `typeAheadQuery` mark
211
- *
212
- * https://product-fabric.atlassian.net/wiki/spaces/E/pages/2992177582/Technical+TypeAhead+Data+Flow
213
- *
214
- *
215
- */
216
- export var typeAheadPlugin = function typeAheadPlugin(_ref4) {
217
- var _api$analytics, _api$analytics2;
218
- var options = _ref4.config,
219
- api = _ref4.api;
220
- var fireAnalyticsCallback = fireAnalyticsEvent(options === null || options === void 0 ? void 0 : options.createAnalyticsEvent);
221
- var popupMountRef = {
222
- current: null
223
- };
224
- var editorViewRef = {
225
- current: null
226
- };
227
- return {
228
- name: 'typeAhead',
229
- marks: function marks() {
230
- // We need to keep this to make sure
231
- // All documents with typeahead marks will be loaded normally
232
- return [{
233
- name: 'typeAheadQuery',
234
- mark: typeAheadQuery
235
- }];
236
- },
237
- pmPlugins: function pmPlugins() {
238
- var typeAhead = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
239
- return [{
240
- name: 'typeAhead',
241
- plugin: function plugin(_ref5) {
242
- var dispatch = _ref5.dispatch,
243
- getIntl = _ref5.getIntl;
244
- return createPlugin({
245
- getIntl: getIntl,
246
- popupMountRef: popupMountRef,
247
- reactDispatch: dispatch,
248
- typeAheadHandlers: typeAhead,
249
- createAnalyticsEvent: options === null || options === void 0 ? void 0 : options.createAnalyticsEvent
250
- });
251
- }
252
- }, {
253
- name: 'typeAheadEditorViewRef',
254
- plugin: function plugin() {
255
- return new SafePlugin({
256
- view: function view(_view) {
257
- editorViewRef.current = _view;
258
- return {
259
- destroy: function destroy() {
260
- editorViewRef.current = null;
261
- }
262
- };
263
- }
264
- });
265
- }
266
- }, {
267
- name: 'typeAheadInsertItem',
268
- plugin: createInsertItemPlugin
269
- }, {
270
- name: 'typeAheadInputRule',
271
- plugin: function plugin(_ref6) {
272
- var schema = _ref6.schema,
273
- featureFlags = _ref6.featureFlags;
274
- return inputRulePlugin(schema, typeAhead, featureFlags);
275
- }
276
- }];
277
- },
278
- getSharedState: function getSharedState(editorState) {
279
- if (!editorState) {
280
- return {
281
- query: '',
282
- isOpen: false,
283
- isAllowed: false,
284
- currentHandler: undefined
285
- };
286
- }
287
- var isOpen = isTypeAheadOpen(editorState);
288
- return {
289
- query: getTypeAheadQuery(editorState) || '',
290
- currentHandler: getTypeAheadHandler(editorState),
291
- isOpen: isOpen,
292
- isAllowed: !isOpen
293
- };
294
- },
295
- actions: {
296
- isOpen: isTypeAheadOpen,
297
- isAllowed: isTypeAheadAllowed,
298
- open: createOpenTypeAhead(editorViewRef, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions),
299
- openAtTransaction: createOpenAtTransaction(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions),
300
- findHandlerByTrigger: createFindHandlerByTrigger(editorViewRef),
301
- insert: createInsertTypeAheadItem(editorViewRef),
302
- close: createCloseTypeAhead(editorViewRef)
303
- },
304
- contentComponent: function contentComponent(_ref7) {
305
- var editorView = _ref7.editorView,
306
- containerElement = _ref7.containerElement,
307
- popupsMountPoint = _ref7.popupsMountPoint,
308
- popupsBoundariesElement = _ref7.popupsBoundariesElement,
309
- popupsScrollableElement = _ref7.popupsScrollableElement,
310
- wrapperElement = _ref7.wrapperElement;
311
- popupMountRef.current = {
312
- popupsMountPoint: popupsMountPoint || wrapperElement || undefined,
313
- popupsBoundariesElement: popupsBoundariesElement,
314
- popupsScrollableElement: popupsScrollableElement || containerElement || undefined
315
- };
316
- return /*#__PURE__*/React.createElement(WithPluginState, {
317
- plugins: {
318
- typeAheadState: typeAheadPluginKey
319
- },
320
- render: function render(_ref8) {
321
- var typeAheadState = _ref8.typeAheadState;
322
- if (!typeAheadState) {
323
- return null;
324
- }
325
- return /*#__PURE__*/React.createElement(TypeAheadMenu, {
326
- editorView: editorView,
327
- popupMountRef: popupMountRef,
328
- typeAheadState: typeAheadState,
329
- fireAnalyticsCallback: fireAnalyticsCallback
330
- });
331
- }
332
- });
333
- },
334
- onEditorViewStateUpdated: function onEditorViewStateUpdated(_ref9) {
335
- var originalTransaction = _ref9.originalTransaction,
336
- oldEditorState = _ref9.oldEditorState,
337
- newEditorState = _ref9.newEditorState;
338
- var oldPluginState = getPluginState(oldEditorState);
339
- var newPluginState = getPluginState(newEditorState);
340
- if (!oldPluginState || !newPluginState) {
341
- return;
342
- }
343
- var oldTriggerHandler = oldPluginState.triggerHandler;
344
- var newTriggerHandler = newPluginState.triggerHandler;
345
- var isANewHandler = oldTriggerHandler !== newTriggerHandler;
346
- if (oldTriggerHandler !== null && oldTriggerHandler !== void 0 && oldTriggerHandler.dismiss && isANewHandler) {
347
- var typeAheadMessage = originalTransaction.getMeta(typeAheadPluginKey);
348
- var wasItemInserted = typeAheadMessage && typeAheadMessage.action === 'INSERT_RAW_QUERY';
349
- oldTriggerHandler.dismiss({
350
- editorState: newEditorState,
351
- query: oldPluginState.query,
352
- stats: (oldPluginState.stats || new StatsModifier()).serialize(),
353
- wasItemInserted: wasItemInserted
354
- });
355
- }
356
- if (newTriggerHandler !== null && newTriggerHandler !== void 0 && newTriggerHandler.onOpen && isANewHandler) {
357
- newTriggerHandler.onOpen(newEditorState);
358
- }
359
- if (newTriggerHandler && isANewHandler && options !== null && options !== void 0 && options.createAnalyticsEvent) {
360
- fireAnalyticsCallback({
361
- payload: {
362
- action: ACTION.INVOKED,
363
- actionSubject: ACTION_SUBJECT.TYPEAHEAD,
364
- actionSubjectId: newTriggerHandler.id || 'not_set',
365
- attributes: {
366
- inputMethod: newPluginState.inputMethod || INPUT_METHOD.KEYBOARD
367
- },
368
- eventType: EVENT_TYPE.UI
369
- }
370
- });
371
- }
372
- }
373
- };
374
- };
@@ -1,10 +0,0 @@
1
- export var ACTIONS = /*#__PURE__*/function (ACTIONS) {
2
- ACTIONS["OPEN_TYPEAHEAD_AT_CURSOR"] = "OPEN_TYPEAHEAD_AT_CURSOR";
3
- ACTIONS["CLOSE_TYPE_AHEAD"] = "CLOSE_TYPE_AHEAD";
4
- ACTIONS["CHANGE_QUERY"] = "CHANGE_QUERY";
5
- ACTIONS["INSERT_ITEM"] = "INSERT_ITEM";
6
- ACTIONS["INSERT_RAW_QUERY"] = "INSERT_RAW_QUERY";
7
- ACTIONS["UPDATE_LIST_ITEMS"] = "UPDATE_LIST_ITEMS";
8
- ACTIONS["UPDATE_SELECTED_INDEX"] = "UPDATE_SELECTED_INDEX";
9
- return ACTIONS;
10
- }({});
@@ -1,141 +0,0 @@
1
- import React from 'react';
2
- import ReactDOM from 'react-dom';
3
- import uuid from 'uuid';
4
- import { TextSelection } from '@atlaskit/editor-prosemirror/state';
5
- import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
6
- import { B400 } from '@atlaskit/theme/colors';
7
- import { keyName as keyNameNormalized } from 'w3c-keyname';
8
- import { IntlProvider } from 'react-intl-next';
9
- import { redo, undo } from '@atlaskit/editor-prosemirror/history';
10
- import { TYPE_AHEAD_DECORATION_KEY, TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE } from '../constants';
11
- import { WrapperTypeAhead } from '../ui/WrapperTypeAhead';
12
- import { StatsModifier } from '../stats-modifier';
13
- import { getTypeAheadQuery } from '../utils';
14
- import { closeTypeAhead } from '../transforms/close-type-ahead';
15
- export var factoryDecorations = function factoryDecorations(_ref) {
16
- var intl = _ref.intl,
17
- popupMountRef = _ref.popupMountRef,
18
- createAnalyticsEvent = _ref.createAnalyticsEvent;
19
- var createDecorations = function createDecorations(tr, _ref2) {
20
- var triggerHandler = _ref2.triggerHandler,
21
- inputMethod = _ref2.inputMethod,
22
- reopenQuery = _ref2.reopenQuery;
23
- var selection = tr.selection;
24
- if (!(selection instanceof TextSelection) || !selection.$cursor) {
25
- return {
26
- decorationSet: DecorationSet.empty,
27
- stats: null,
28
- decorationElement: null
29
- };
30
- }
31
- var decorationId = "decoration_id_".concat(TYPE_AHEAD_DECORATION_KEY, "_").concat(uuid());
32
- var $cursor = selection.$cursor;
33
- var typeaheadComponent = document.createElement('mark');
34
- var stats = new StatsModifier();
35
- var shouldFocusCursorInsideQuery = true;
36
- var deco = Decoration.widget($cursor.pos, function (editorView, getDecorationPosition) {
37
- var _popupMountRef$curren, _popupMountRef$curren2, _popupMountRef$curren3;
38
- typeaheadComponent.setAttribute('id', decorationId);
39
- typeaheadComponent.setAttribute('role', 'search');
40
- typeaheadComponent.dataset.typeAheadQuery = 'true';
41
- typeaheadComponent.dataset.trigger = triggerHandler.trigger;
42
-
43
- // This line below seems weird,
44
- // we need that cuz the clickAreaHelper
45
- // will try to hijack any click event coming
46
- // from the inside of the Editor
47
- // packages/editor/editor-core/src/ui/Addon/click-area-helper.ts
48
- typeaheadComponent.dataset.editorPopup = 'true';
49
- typeaheadComponent.dataset.typeAhead = TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE;
50
- typeaheadComponent.style.color = "var(--ds-text-accent-blue, ".concat(B400, ")");
51
- typeaheadComponent.style.backgroundColor = 'transparent';
52
- var onUndoRedo = function onUndoRedo(inputType) {
53
- if (!['historyUndo', 'historyRedo'].includes(inputType)) {
54
- return false;
55
- }
56
- var hasReopenQuery = typeof reopenQuery === 'string' && reopenQuery.trim().length > 0;
57
- var currentQuery = getTypeAheadQuery(editorView.state);
58
- if (hasReopenQuery || (currentQuery === null || currentQuery === void 0 ? void 0 : currentQuery.length) === 0) {
59
- var command = inputType === 'historyUndo' ? undo : redo;
60
- var _tr = editorView.state.tr;
61
- var fakeDispatch = function fakeDispatch(customTr) {
62
- _tr = customTr;
63
- };
64
- var result = command(editorView.state, fakeDispatch);
65
- if (result) {
66
- closeTypeAhead(_tr);
67
- editorView.dispatch(_tr);
68
- editorView.focus();
69
- }
70
- return result;
71
- }
72
- return false;
73
- };
74
- ReactDOM.render( /*#__PURE__*/React.createElement(IntlProvider, {
75
- locale: intl.locale || 'en',
76
- messages: intl.messages,
77
- formats: intl.formats
78
- }, /*#__PURE__*/React.createElement(WrapperTypeAhead, {
79
- triggerHandler: triggerHandler,
80
- editorView: editorView,
81
- anchorElement: typeaheadComponent,
82
- createAnalyticsEvent: createAnalyticsEvent,
83
- inputMethod: inputMethod,
84
- getDecorationPosition: getDecorationPosition,
85
- shouldFocusCursorInsideQuery: shouldFocusCursorInsideQuery,
86
- popupsMountPoint: (_popupMountRef$curren = popupMountRef.current) === null || _popupMountRef$curren === void 0 ? void 0 : _popupMountRef$curren.popupsMountPoint,
87
- popupsBoundariesElement: (_popupMountRef$curren2 = popupMountRef.current) === null || _popupMountRef$curren2 === void 0 ? void 0 : _popupMountRef$curren2.popupsBoundariesElement,
88
- popupsScrollableElement: (_popupMountRef$curren3 = popupMountRef.current) === null || _popupMountRef$curren3 === void 0 ? void 0 : _popupMountRef$curren3.popupsScrollableElement,
89
- onUndoRedo: onUndoRedo,
90
- reopenQuery: reopenQuery
91
- })), typeaheadComponent);
92
- shouldFocusCursorInsideQuery = false;
93
- return typeaheadComponent;
94
- }, {
95
- isTypeAheadDecoration: true,
96
- key: decorationId,
97
- side: 0,
98
- stopEvent: function stopEvent(e) {
99
- var key = keyNameNormalized(e);
100
- var sel = document.getSelection();
101
- if ('ArrowLeft' === key && (sel === null || sel === void 0 ? void 0 : sel.anchorOffset) === 0) {
102
- return false;
103
- }
104
- return true;
105
- },
106
- ignoreSelection: false
107
- });
108
- return {
109
- decorationSet: DecorationSet.create(tr.doc, [deco]),
110
- decorationElement: typeaheadComponent,
111
- stats: stats
112
- };
113
- };
114
- var removeDecorations = function removeDecorations(decorationSet) {
115
- if (!decorationSet || decorationSet === DecorationSet.empty) {
116
- return false;
117
- }
118
- var typeAheadDecorations = decorationSet.find(undefined, undefined, function (spec) {
119
- return spec.isTypeAheadDecoration;
120
- });
121
- if (!typeAheadDecorations || typeAheadDecorations.length === 0) {
122
- return false;
123
- }
124
- typeAheadDecorations.forEach(function (_ref3) {
125
- var spec = _ref3.spec;
126
- if (!spec.key) {
127
- return;
128
- }
129
- var decoElement = document.querySelector("#".concat(spec.key));
130
- if (!decoElement) {
131
- return;
132
- }
133
- ReactDOM.unmountComponentAtNode(decoElement);
134
- });
135
- return true;
136
- };
137
- return {
138
- createDecorations: createDecorations,
139
- removeDecorations: removeDecorations
140
- };
141
- };
@@ -1,29 +0,0 @@
1
- import { createRule, createPlugin, leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
2
- import { openTypeAheadAtCursor } from '../transforms/open-typeahead-at-cursor';
3
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
- export function inputRulePlugin(schema, typeAheads, featureFlags) {
5
- if (!typeAheads || typeAheads.length === 0) {
6
- return;
7
- }
8
- var rules = typeAheads.reduce(function (acc, typeAhead) {
9
- var trigger = typeAhead.customRegex || typeAhead.trigger;
10
- if (!trigger) {
11
- return acc;
12
- }
13
- var regex = new RegExp("(^|[.!?\\s".concat(leafNodeReplacementCharacter, "])(").concat(trigger, ")$"));
14
- acc.push(createRule(regex, function (state, match) {
15
- return openTypeAheadAtCursor({
16
- triggerHandler: typeAhead,
17
- inputMethod: INPUT_METHOD.KEYBOARD
18
- })({
19
- tr: state.tr
20
- });
21
- }));
22
- return acc;
23
- }, []);
24
- var plugin = createPlugin('type-ahead', rules, {
25
- allowInsertTextOnDocument: false
26
- });
27
- return plugin;
28
- }
29
- export default inputRulePlugin;
@@ -1,16 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { ACTIONS } from './actions';
3
- import { isInsertionTransaction } from './utils';
4
- export function createPlugin() {
5
- return new SafePlugin({
6
- appendTransaction: function appendTransaction(transactions, _oldState, newState) {
7
- var insertItemCallback = isInsertionTransaction(transactions, ACTIONS.INSERT_ITEM);
8
- if (insertItemCallback) {
9
- var tr = insertItemCallback(newState);
10
- if (tr) {
11
- return tr;
12
- }
13
- }
14
- }
15
- });
16
- }
@@ -1,2 +0,0 @@
1
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
- export var pluginKey = new PluginKey('typeAheadPlugin');
@@ -1,104 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
- import { InsertTypeAheadStep } from '@atlaskit/adf-schema/steps';
4
- import { TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE } from '../constants';
5
- import { ACTIONS } from './actions';
6
- import { pluginKey } from './key';
7
- import { closest } from '@atlaskit/editor-common/utils';
8
- import { createReducer } from './reducer';
9
- import { factoryDecorations } from './decorations';
10
- import { isInsertionTransaction } from './utils';
11
- var hasValidTypeAheadStep = function hasValidTypeAheadStep(tr) {
12
- var steps = tr.steps.filter(function (step) {
13
- return step instanceof InsertTypeAheadStep;
14
- });
15
-
16
- // There are some cases, like collab rebase, where the steps are re-applied
17
- // We should not re open the type-ahead for those cases
18
- if (steps.length === 1) {
19
- return steps[0];
20
- }
21
- return null;
22
- };
23
- export function createPlugin(_ref) {
24
- var reactDispatch = _ref.reactDispatch,
25
- popupMountRef = _ref.popupMountRef,
26
- createAnalyticsEvent = _ref.createAnalyticsEvent,
27
- typeAheadHandlers = _ref.typeAheadHandlers,
28
- getIntl = _ref.getIntl;
29
- var intl = getIntl();
30
- var _factoryDecorations = factoryDecorations({
31
- intl: intl,
32
- popupMountRef: popupMountRef,
33
- createAnalyticsEvent: createAnalyticsEvent
34
- }),
35
- createDecorations = _factoryDecorations.createDecorations,
36
- removeDecorations = _factoryDecorations.removeDecorations;
37
- var reducer = createReducer({
38
- createDecorations: createDecorations,
39
- removeDecorations: removeDecorations,
40
- typeAheadHandlers: typeAheadHandlers,
41
- popupMountRef: popupMountRef
42
- });
43
- return new SafePlugin({
44
- key: pluginKey,
45
- state: {
46
- init: function init() {
47
- return {
48
- typeAheadHandlers: typeAheadHandlers,
49
- query: '',
50
- decorationSet: DecorationSet.empty,
51
- decorationElement: null,
52
- items: [],
53
- selectedIndex: -1,
54
- stats: null,
55
- inputMethod: null
56
- };
57
- },
58
- apply: function apply(tr, currentPluginState, oldEditorState, state) {
59
- var customStep = hasValidTypeAheadStep(tr);
60
- var nextPluginState = reducer(tr, currentPluginState, customStep);
61
- if (currentPluginState !== nextPluginState) {
62
- reactDispatch(pluginKey, nextPluginState);
63
- }
64
- return nextPluginState;
65
- }
66
- },
67
- appendTransaction: function appendTransaction(transactions, _oldState, newState) {
68
- var insertItemCallback = isInsertionTransaction(transactions, ACTIONS.INSERT_RAW_QUERY);
69
- if (insertItemCallback) {
70
- var tr = insertItemCallback(newState);
71
- if (tr) {
72
- return tr;
73
- }
74
- }
75
- },
76
- view: function view() {
77
- return {
78
- update: function update(editorView) {}
79
- };
80
- },
81
- props: {
82
- decorations: function decorations(state) {
83
- var _pluginKey$getState;
84
- return (_pluginKey$getState = pluginKey.getState(state)) === null || _pluginKey$getState === void 0 ? void 0 : _pluginKey$getState.decorationSet;
85
- },
86
- handleDOMEvents: {
87
- compositionend: function compositionend(view, event) {
88
- return false;
89
- },
90
- click: function click(view, event) {
91
- var target = event.target;
92
- // ProseMirror view listen to any click event inside of it
93
- // When this event is coming from the typeahead
94
- // we should tell to ProseMirror to sit down and relax
95
- // cuz we know what we are doing (I hope)
96
- if (target instanceof HTMLElement && closest(target, "[data-type-ahead=".concat(TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE, "]"))) {
97
- return true;
98
- }
99
- return false;
100
- }
101
- }
102
- }
103
- });
104
- }