@atlaskit/editor-core 188.9.0 → 188.9.5

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 (207) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/labs/next/presets/default.js +2 -2
  3. package/dist/cjs/plugins/index.js +0 -7
  4. package/dist/cjs/plugins/insert-block/index.js +4 -6
  5. package/dist/cjs/plugins/tasks-and-decisions/index.js +4 -3
  6. package/dist/cjs/plugins/tasks-and-decisions/nodeviews/decisionItem.js +26 -6
  7. package/dist/cjs/plugins/tasks-and-decisions/nodeviews/taskItem.js +45 -13
  8. package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/main.js +15 -7
  9. package/dist/cjs/version-wrapper.js +1 -1
  10. package/dist/es2019/labs/next/presets/default.js +1 -1
  11. package/dist/es2019/plugins/index.js +0 -1
  12. package/dist/es2019/plugins/insert-block/index.js +4 -6
  13. package/dist/es2019/plugins/tasks-and-decisions/index.js +4 -3
  14. package/dist/es2019/plugins/tasks-and-decisions/nodeviews/decisionItem.js +26 -6
  15. package/dist/es2019/plugins/tasks-and-decisions/nodeviews/taskItem.js +43 -10
  16. package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/main.js +13 -6
  17. package/dist/es2019/version-wrapper.js +1 -1
  18. package/dist/esm/labs/next/presets/default.js +1 -1
  19. package/dist/esm/plugins/index.js +0 -1
  20. package/dist/esm/plugins/insert-block/index.js +4 -6
  21. package/dist/esm/plugins/tasks-and-decisions/index.js +4 -3
  22. package/dist/esm/plugins/tasks-and-decisions/nodeviews/decisionItem.js +26 -6
  23. package/dist/esm/plugins/tasks-and-decisions/nodeviews/taskItem.js +45 -12
  24. package/dist/esm/plugins/tasks-and-decisions/pm-plugins/main.js +14 -7
  25. package/dist/esm/version-wrapper.js +1 -1
  26. package/dist/types/labs/next/presets/default.d.ts +43 -43
  27. package/dist/types/plugins/index.d.ts +0 -1
  28. package/dist/types/plugins/insert-block/types.d.ts +2 -0
  29. package/dist/types/plugins/tasks-and-decisions/index.d.ts +2 -5
  30. package/dist/types/plugins/tasks-and-decisions/nodeviews/decisionItem.d.ts +9 -4
  31. package/dist/types/plugins/tasks-and-decisions/nodeviews/taskItem.d.ts +9 -4
  32. package/dist/types/plugins/tasks-and-decisions/pm-plugins/main.d.ts +4 -2
  33. package/dist/types/plugins/tasks-and-decisions/types.d.ts +6 -1
  34. package/dist/types-ts4.5/labs/next/presets/default.d.ts +43 -43
  35. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  36. package/dist/types-ts4.5/plugins/insert-block/types.d.ts +2 -0
  37. package/dist/types-ts4.5/plugins/tasks-and-decisions/index.d.ts +2 -5
  38. package/dist/types-ts4.5/plugins/tasks-and-decisions/nodeviews/decisionItem.d.ts +9 -4
  39. package/dist/types-ts4.5/plugins/tasks-and-decisions/nodeviews/taskItem.d.ts +9 -4
  40. package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/main.d.ts +4 -2
  41. package/dist/types-ts4.5/plugins/tasks-and-decisions/types.d.ts +8 -1
  42. package/package.json +10 -8
  43. package/dist/cjs/plugins/type-ahead/api.js +0 -215
  44. package/dist/cjs/plugins/type-ahead/commands/insert-type-ahead-item.js +0 -205
  45. package/dist/cjs/plugins/type-ahead/commands/update-list-items.js +0 -23
  46. package/dist/cjs/plugins/type-ahead/commands/update-query.js +0 -27
  47. package/dist/cjs/plugins/type-ahead/commands/update-selected-index.js +0 -27
  48. package/dist/cjs/plugins/type-ahead/constants.js +0 -15
  49. package/dist/cjs/plugins/type-ahead/index.js +0 -14
  50. package/dist/cjs/plugins/type-ahead/insert-utils.js +0 -107
  51. package/dist/cjs/plugins/type-ahead/messages.js +0 -79
  52. package/dist/cjs/plugins/type-ahead/plugin.js +0 -382
  53. package/dist/cjs/plugins/type-ahead/pm-plugins/actions.js +0 -16
  54. package/dist/cjs/plugins/type-ahead/pm-plugins/decorations.js +0 -148
  55. package/dist/cjs/plugins/type-ahead/pm-plugins/input-rules.js +0 -36
  56. package/dist/cjs/plugins/type-ahead/pm-plugins/insert-item-plugin.js +0 -22
  57. package/dist/cjs/plugins/type-ahead/pm-plugins/key.js +0 -8
  58. package/dist/cjs/plugins/type-ahead/pm-plugins/main.js +0 -110
  59. package/dist/cjs/plugins/type-ahead/pm-plugins/reducer.js +0 -158
  60. package/dist/cjs/plugins/type-ahead/pm-plugins/utils.js +0 -18
  61. package/dist/cjs/plugins/type-ahead/stats-modifier.js +0 -42
  62. package/dist/cjs/plugins/type-ahead/transforms/close-type-ahead.js +0 -13
  63. package/dist/cjs/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +0 -75
  64. package/dist/cjs/plugins/type-ahead/transforms/set-selection-before-query.js +0 -18
  65. package/dist/cjs/plugins/type-ahead/types.js +0 -5
  66. package/dist/cjs/plugins/type-ahead/ui/AssistiveText.js +0 -120
  67. package/dist/cjs/plugins/type-ahead/ui/InputQuery.js +0 -400
  68. package/dist/cjs/plugins/type-ahead/ui/TypeAheadList.js +0 -285
  69. package/dist/cjs/plugins/type-ahead/ui/TypeAheadListItem.js +0 -179
  70. package/dist/cjs/plugins/type-ahead/ui/TypeAheadPopup.js +0 -230
  71. package/dist/cjs/plugins/type-ahead/ui/WrapperTypeAhead.js +0 -127
  72. package/dist/cjs/plugins/type-ahead/ui/hooks/use-item-insert.js +0 -109
  73. package/dist/cjs/plugins/type-ahead/ui/hooks/use-load-items.js +0 -50
  74. package/dist/cjs/plugins/type-ahead/ui/hooks/use-on-force-select.js +0 -41
  75. package/dist/cjs/plugins/type-ahead/utils.js +0 -130
  76. package/dist/es2019/plugins/type-ahead/api.js +0 -205
  77. package/dist/es2019/plugins/type-ahead/commands/insert-type-ahead-item.js +0 -204
  78. package/dist/es2019/plugins/type-ahead/commands/update-list-items.js +0 -17
  79. package/dist/es2019/plugins/type-ahead/commands/update-query.js +0 -21
  80. package/dist/es2019/plugins/type-ahead/commands/update-selected-index.js +0 -21
  81. package/dist/es2019/plugins/type-ahead/constants.js +0 -9
  82. package/dist/es2019/plugins/type-ahead/index.js +0 -3
  83. package/dist/es2019/plugins/type-ahead/insert-utils.js +0 -106
  84. package/dist/es2019/plugins/type-ahead/messages.js +0 -73
  85. package/dist/es2019/plugins/type-ahead/plugin.js +0 -381
  86. package/dist/es2019/plugins/type-ahead/pm-plugins/actions.js +0 -10
  87. package/dist/es2019/plugins/type-ahead/pm-plugins/decorations.js +0 -148
  88. package/dist/es2019/plugins/type-ahead/pm-plugins/input-rules.js +0 -29
  89. package/dist/es2019/plugins/type-ahead/pm-plugins/insert-item-plugin.js +0 -16
  90. package/dist/es2019/plugins/type-ahead/pm-plugins/key.js +0 -2
  91. package/dist/es2019/plugins/type-ahead/pm-plugins/main.js +0 -106
  92. package/dist/es2019/plugins/type-ahead/pm-plugins/reducer.js +0 -160
  93. package/dist/es2019/plugins/type-ahead/pm-plugins/utils.js +0 -12
  94. package/dist/es2019/plugins/type-ahead/stats-modifier.js +0 -33
  95. package/dist/es2019/plugins/type-ahead/transforms/close-type-ahead.js +0 -7
  96. package/dist/es2019/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +0 -71
  97. package/dist/es2019/plugins/type-ahead/transforms/set-selection-before-query.js +0 -10
  98. package/dist/es2019/plugins/type-ahead/types.js +0 -1
  99. package/dist/es2019/plugins/type-ahead/ui/AssistiveText.js +0 -88
  100. package/dist/es2019/plugins/type-ahead/ui/InputQuery.js +0 -393
  101. package/dist/es2019/plugins/type-ahead/ui/TypeAheadList.js +0 -273
  102. package/dist/es2019/plugins/type-ahead/ui/TypeAheadListItem.js +0 -214
  103. package/dist/es2019/plugins/type-ahead/ui/TypeAheadPopup.js +0 -233
  104. package/dist/es2019/plugins/type-ahead/ui/WrapperTypeAhead.js +0 -109
  105. package/dist/es2019/plugins/type-ahead/ui/hooks/use-item-insert.js +0 -112
  106. package/dist/es2019/plugins/type-ahead/ui/hooks/use-load-items.js +0 -41
  107. package/dist/es2019/plugins/type-ahead/ui/hooks/use-on-force-select.js +0 -38
  108. package/dist/es2019/plugins/type-ahead/utils.js +0 -126
  109. package/dist/esm/plugins/type-ahead/api.js +0 -209
  110. package/dist/esm/plugins/type-ahead/commands/insert-type-ahead-item.js +0 -198
  111. package/dist/esm/plugins/type-ahead/commands/update-list-items.js +0 -17
  112. package/dist/esm/plugins/type-ahead/commands/update-query.js +0 -21
  113. package/dist/esm/plugins/type-ahead/commands/update-selected-index.js +0 -21
  114. package/dist/esm/plugins/type-ahead/constants.js +0 -9
  115. package/dist/esm/plugins/type-ahead/index.js +0 -3
  116. package/dist/esm/plugins/type-ahead/insert-utils.js +0 -101
  117. package/dist/esm/plugins/type-ahead/messages.js +0 -73
  118. package/dist/esm/plugins/type-ahead/plugin.js +0 -374
  119. package/dist/esm/plugins/type-ahead/pm-plugins/actions.js +0 -10
  120. package/dist/esm/plugins/type-ahead/pm-plugins/decorations.js +0 -141
  121. package/dist/esm/plugins/type-ahead/pm-plugins/input-rules.js +0 -29
  122. package/dist/esm/plugins/type-ahead/pm-plugins/insert-item-plugin.js +0 -16
  123. package/dist/esm/plugins/type-ahead/pm-plugins/key.js +0 -2
  124. package/dist/esm/plugins/type-ahead/pm-plugins/main.js +0 -104
  125. package/dist/esm/plugins/type-ahead/pm-plugins/reducer.js +0 -151
  126. package/dist/esm/plugins/type-ahead/pm-plugins/utils.js +0 -12
  127. package/dist/esm/plugins/type-ahead/stats-modifier.js +0 -35
  128. package/dist/esm/plugins/type-ahead/transforms/close-type-ahead.js +0 -7
  129. package/dist/esm/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +0 -69
  130. package/dist/esm/plugins/type-ahead/transforms/set-selection-before-query.js +0 -12
  131. package/dist/esm/plugins/type-ahead/types.js +0 -1
  132. package/dist/esm/plugins/type-ahead/ui/AssistiveText.js +0 -115
  133. package/dist/esm/plugins/type-ahead/ui/InputQuery.js +0 -390
  134. package/dist/esm/plugins/type-ahead/ui/TypeAheadList.js +0 -276
  135. package/dist/esm/plugins/type-ahead/ui/TypeAheadListItem.js +0 -169
  136. package/dist/esm/plugins/type-ahead/ui/TypeAheadPopup.js +0 -220
  137. package/dist/esm/plugins/type-ahead/ui/WrapperTypeAhead.js +0 -117
  138. package/dist/esm/plugins/type-ahead/ui/hooks/use-item-insert.js +0 -103
  139. package/dist/esm/plugins/type-ahead/ui/hooks/use-load-items.js +0 -43
  140. package/dist/esm/plugins/type-ahead/ui/hooks/use-on-force-select.js +0 -35
  141. package/dist/esm/plugins/type-ahead/utils.js +0 -124
  142. package/dist/types/plugins/type-ahead/api.d.ts +0 -61
  143. package/dist/types/plugins/type-ahead/commands/insert-type-ahead-item.d.ts +0 -12
  144. package/dist/types/plugins/type-ahead/commands/update-list-items.d.ts +0 -3
  145. package/dist/types/plugins/type-ahead/commands/update-query.d.ts +0 -2
  146. package/dist/types/plugins/type-ahead/commands/update-selected-index.d.ts +0 -2
  147. package/dist/types/plugins/type-ahead/constants.d.ts +0 -8
  148. package/dist/types/plugins/type-ahead/index.d.ts +0 -4
  149. package/dist/types/plugins/type-ahead/insert-utils.d.ts +0 -18
  150. package/dist/types/plugins/type-ahead/messages.d.ts +0 -72
  151. package/dist/types/plugins/type-ahead/plugin.d.ts +0 -10
  152. package/dist/types/plugins/type-ahead/pm-plugins/actions.d.ts +0 -9
  153. package/dist/types/plugins/type-ahead/pm-plugins/decorations.d.ts +0 -14
  154. package/dist/types/plugins/type-ahead/pm-plugins/input-rules.d.ts +0 -6
  155. package/dist/types/plugins/type-ahead/pm-plugins/insert-item-plugin.d.ts +0 -2
  156. package/dist/types/plugins/type-ahead/pm-plugins/key.d.ts +0 -3
  157. package/dist/types/plugins/type-ahead/pm-plugins/main.d.ts +0 -14
  158. package/dist/types/plugins/type-ahead/pm-plugins/reducer.d.ts +0 -10
  159. package/dist/types/plugins/type-ahead/pm-plugins/utils.d.ts +0 -4
  160. package/dist/types/plugins/type-ahead/stats-modifier.d.ts +0 -20
  161. package/dist/types/plugins/type-ahead/transforms/close-type-ahead.d.ts +0 -2
  162. package/dist/types/plugins/type-ahead/transforms/open-typeahead-at-cursor.d.ts +0 -11
  163. package/dist/types/plugins/type-ahead/transforms/set-selection-before-query.d.ts +0 -2
  164. package/dist/types/plugins/type-ahead/types.d.ts +0 -109
  165. package/dist/types/plugins/type-ahead/ui/AssistiveText.d.ts +0 -33
  166. package/dist/types/plugins/type-ahead/ui/InputQuery.d.ts +0 -26
  167. package/dist/types/plugins/type-ahead/ui/TypeAheadList.d.ts +0 -25
  168. package/dist/types/plugins/type-ahead/ui/TypeAheadListItem.d.ts +0 -18
  169. package/dist/types/plugins/type-ahead/ui/TypeAheadPopup.d.ts +0 -29
  170. package/dist/types/plugins/type-ahead/ui/WrapperTypeAhead.d.ts +0 -20
  171. package/dist/types/plugins/type-ahead/ui/hooks/use-item-insert.d.ts +0 -3
  172. package/dist/types/plugins/type-ahead/ui/hooks/use-load-items.d.ts +0 -3
  173. package/dist/types/plugins/type-ahead/ui/hooks/use-on-force-select.d.ts +0 -11
  174. package/dist/types/plugins/type-ahead/utils.d.ts +0 -27
  175. package/dist/types-ts4.5/plugins/type-ahead/api.d.ts +0 -61
  176. package/dist/types-ts4.5/plugins/type-ahead/commands/insert-type-ahead-item.d.ts +0 -12
  177. package/dist/types-ts4.5/plugins/type-ahead/commands/update-list-items.d.ts +0 -3
  178. package/dist/types-ts4.5/plugins/type-ahead/commands/update-query.d.ts +0 -2
  179. package/dist/types-ts4.5/plugins/type-ahead/commands/update-selected-index.d.ts +0 -2
  180. package/dist/types-ts4.5/plugins/type-ahead/constants.d.ts +0 -8
  181. package/dist/types-ts4.5/plugins/type-ahead/index.d.ts +0 -4
  182. package/dist/types-ts4.5/plugins/type-ahead/insert-utils.d.ts +0 -18
  183. package/dist/types-ts4.5/plugins/type-ahead/messages.d.ts +0 -72
  184. package/dist/types-ts4.5/plugins/type-ahead/plugin.d.ts +0 -10
  185. package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/actions.d.ts +0 -9
  186. package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/decorations.d.ts +0 -14
  187. package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/input-rules.d.ts +0 -6
  188. package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/insert-item-plugin.d.ts +0 -2
  189. package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/key.d.ts +0 -3
  190. package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/main.d.ts +0 -14
  191. package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/reducer.d.ts +0 -10
  192. package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/utils.d.ts +0 -4
  193. package/dist/types-ts4.5/plugins/type-ahead/stats-modifier.d.ts +0 -20
  194. package/dist/types-ts4.5/plugins/type-ahead/transforms/close-type-ahead.d.ts +0 -2
  195. package/dist/types-ts4.5/plugins/type-ahead/transforms/open-typeahead-at-cursor.d.ts +0 -11
  196. package/dist/types-ts4.5/plugins/type-ahead/transforms/set-selection-before-query.d.ts +0 -2
  197. package/dist/types-ts4.5/plugins/type-ahead/types.d.ts +0 -111
  198. package/dist/types-ts4.5/plugins/type-ahead/ui/AssistiveText.d.ts +0 -33
  199. package/dist/types-ts4.5/plugins/type-ahead/ui/InputQuery.d.ts +0 -26
  200. package/dist/types-ts4.5/plugins/type-ahead/ui/TypeAheadList.d.ts +0 -25
  201. package/dist/types-ts4.5/plugins/type-ahead/ui/TypeAheadListItem.d.ts +0 -18
  202. package/dist/types-ts4.5/plugins/type-ahead/ui/TypeAheadPopup.d.ts +0 -29
  203. package/dist/types-ts4.5/plugins/type-ahead/ui/WrapperTypeAhead.d.ts +0 -20
  204. package/dist/types-ts4.5/plugins/type-ahead/ui/hooks/use-item-insert.d.ts +0 -7
  205. package/dist/types-ts4.5/plugins/type-ahead/ui/hooks/use-load-items.d.ts +0 -3
  206. package/dist/types-ts4.5/plugins/type-ahead/ui/hooks/use-on-force-select.d.ts +0 -11
  207. package/dist/types-ts4.5/plugins/type-ahead/utils.d.ts +0 -27
@@ -1,8 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.pluginKey = void 0;
7
- var _state = require("@atlaskit/editor-prosemirror/state");
8
- var pluginKey = exports.pluginKey = new _state.PluginKey('typeAheadPlugin');
@@ -1,110 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createPlugin = createPlugin;
7
- var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
8
- var _view = require("@atlaskit/editor-prosemirror/view");
9
- var _steps = require("@atlaskit/adf-schema/steps");
10
- var _constants = require("../constants");
11
- var _actions = require("./actions");
12
- var _key = require("./key");
13
- var _utils = require("@atlaskit/editor-common/utils");
14
- var _reducer = require("./reducer");
15
- var _decorations = require("./decorations");
16
- var _utils2 = require("./utils");
17
- var hasValidTypeAheadStep = function hasValidTypeAheadStep(tr) {
18
- var steps = tr.steps.filter(function (step) {
19
- return step instanceof _steps.InsertTypeAheadStep;
20
- });
21
-
22
- // There are some cases, like collab rebase, where the steps are re-applied
23
- // We should not re open the type-ahead for those cases
24
- if (steps.length === 1) {
25
- return steps[0];
26
- }
27
- return null;
28
- };
29
- function createPlugin(_ref) {
30
- var reactDispatch = _ref.reactDispatch,
31
- popupMountRef = _ref.popupMountRef,
32
- createAnalyticsEvent = _ref.createAnalyticsEvent,
33
- typeAheadHandlers = _ref.typeAheadHandlers,
34
- getIntl = _ref.getIntl;
35
- var intl = getIntl();
36
- var _factoryDecorations = (0, _decorations.factoryDecorations)({
37
- intl: intl,
38
- popupMountRef: popupMountRef,
39
- createAnalyticsEvent: createAnalyticsEvent
40
- }),
41
- createDecorations = _factoryDecorations.createDecorations,
42
- removeDecorations = _factoryDecorations.removeDecorations;
43
- var reducer = (0, _reducer.createReducer)({
44
- createDecorations: createDecorations,
45
- removeDecorations: removeDecorations,
46
- typeAheadHandlers: typeAheadHandlers,
47
- popupMountRef: popupMountRef
48
- });
49
- return new _safePlugin.SafePlugin({
50
- key: _key.pluginKey,
51
- state: {
52
- init: function init() {
53
- return {
54
- typeAheadHandlers: typeAheadHandlers,
55
- query: '',
56
- decorationSet: _view.DecorationSet.empty,
57
- decorationElement: null,
58
- items: [],
59
- selectedIndex: -1,
60
- stats: null,
61
- inputMethod: null
62
- };
63
- },
64
- apply: function apply(tr, currentPluginState, oldEditorState, state) {
65
- var customStep = hasValidTypeAheadStep(tr);
66
- var nextPluginState = reducer(tr, currentPluginState, customStep);
67
- if (currentPluginState !== nextPluginState) {
68
- reactDispatch(_key.pluginKey, nextPluginState);
69
- }
70
- return nextPluginState;
71
- }
72
- },
73
- appendTransaction: function appendTransaction(transactions, _oldState, newState) {
74
- var insertItemCallback = (0, _utils2.isInsertionTransaction)(transactions, _actions.ACTIONS.INSERT_RAW_QUERY);
75
- if (insertItemCallback) {
76
- var tr = insertItemCallback(newState);
77
- if (tr) {
78
- return tr;
79
- }
80
- }
81
- },
82
- view: function view() {
83
- return {
84
- update: function update(editorView) {}
85
- };
86
- },
87
- props: {
88
- decorations: function decorations(state) {
89
- var _pluginKey$getState;
90
- return (_pluginKey$getState = _key.pluginKey.getState(state)) === null || _pluginKey$getState === void 0 ? void 0 : _pluginKey$getState.decorationSet;
91
- },
92
- handleDOMEvents: {
93
- compositionend: function compositionend(view, event) {
94
- return false;
95
- },
96
- click: function click(view, event) {
97
- var target = event.target;
98
- // ProseMirror view listen to any click event inside of it
99
- // When this event is coming from the typeahead
100
- // we should tell to ProseMirror to sit down and relax
101
- // cuz we know what we are doing (I hope)
102
- if (target instanceof HTMLElement && (0, _utils.closest)(target, "[data-type-ahead=".concat(_constants.TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE, "]"))) {
103
- return true;
104
- }
105
- return false;
106
- }
107
- }
108
- }
109
- });
110
- }
@@ -1,158 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createReducer = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _view = require("@atlaskit/editor-prosemirror/view");
10
- var _steps = require("@atlaskit/adf-schema/steps");
11
- var _actions = require("./actions");
12
- var _key = require("./key");
13
- var _analytics = require("@atlaskit/editor-common/analytics");
14
- var _utils = require("../utils");
15
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
- var shouldForceOpen = function shouldForceOpen(step) {
18
- if (!(step instanceof _steps.InsertTypeAheadStep)) {
19
- return false;
20
- }
21
- var isDeletionRawQueryOperation = step.isInsertionStep() && step.stage === _steps.InsertTypeAheadStages.DELETING_RAW_QUERY;
22
- var isUndoingInsertionItem = step.isUndoingStep() && step.stage === _steps.InsertTypeAheadStages.INSERTING_ITEM;
23
- return isDeletionRawQueryOperation || isUndoingInsertionItem;
24
- };
25
- var shouldForceClose = function shouldForceClose(step) {
26
- if (!(step instanceof _steps.InsertTypeAheadStep)) {
27
- return false;
28
- }
29
- var isInsertingItem = step.isInsertionStep() && step.stage === _steps.InsertTypeAheadStages.INSERTING_ITEM;
30
- var isUndoingDeletionRawQuery = step.isUndoingStep() && step.stage === _steps.InsertTypeAheadStages.DELETING_RAW_QUERY;
31
- return isInsertingItem || isUndoingDeletionRawQuery;
32
- };
33
- var createFindHandler = function createFindHandler(typeAheadHandlers) {
34
- return function (step) {
35
- if (!(step instanceof _steps.InsertTypeAheadStep)) {
36
- return null;
37
- }
38
- var handler = typeAheadHandlers.find(function (h) {
39
- return h.trigger === step.trigger;
40
- });
41
- return handler || null;
42
- };
43
- };
44
- var createReducer = exports.createReducer = function createReducer(_ref) {
45
- var typeAheadHandlers = _ref.typeAheadHandlers,
46
- removeDecorations = _ref.removeDecorations,
47
- createDecorations = _ref.createDecorations;
48
- var findHandler = createFindHandler(typeAheadHandlers);
49
- var openMenu = function openMenu(currentPluginState, _ref2) {
50
- var tr = _ref2.tr,
51
- triggerHandler = _ref2.triggerHandler,
52
- inputMethod = _ref2.inputMethod,
53
- reopenQuery = _ref2.reopenQuery,
54
- selectedIndex = _ref2.selectedIndex;
55
- removeDecorations(currentPluginState.decorationSet);
56
- var _createDecorations = createDecorations(tr, {
57
- triggerHandler: triggerHandler,
58
- inputMethod: inputMethod,
59
- reopenQuery: reopenQuery
60
- }),
61
- decorationSet = _createDecorations.decorationSet,
62
- decorationElement = _createDecorations.decorationElement,
63
- stats = _createDecorations.stats;
64
- return _objectSpread(_objectSpread({}, currentPluginState), {}, {
65
- stats: stats,
66
- decorationSet: decorationSet,
67
- triggerHandler: triggerHandler,
68
- decorationElement: decorationElement,
69
- inputMethod: inputMethod,
70
- selectedIndex: typeof selectedIndex === 'number' ? selectedIndex : -1,
71
- items: [],
72
- query: reopenQuery || ''
73
- });
74
- };
75
- var closeMenu = function closeMenu(currentPluginState) {
76
- removeDecorations(currentPluginState.decorationSet);
77
- return _objectSpread(_objectSpread({}, currentPluginState), {}, {
78
- inputMethod: null,
79
- query: '',
80
- decorationElement: null,
81
- decorationSet: _view.DecorationSet.empty,
82
- stats: null,
83
- triggerHandler: undefined,
84
- items: []
85
- });
86
- };
87
- return function (tr, currentPluginState, typeAheadStepOverride) {
88
- var meta = tr.getMeta(_key.pluginKey) || {};
89
-
90
- // This code below controls when we should force
91
- // the menu to open or close during undo/redo operations
92
- var overrideHandler = findHandler(typeAheadStepOverride);
93
- if (typeAheadStepOverride && overrideHandler && shouldForceOpen(typeAheadStepOverride)) {
94
- return openMenu(currentPluginState, {
95
- tr: tr,
96
- triggerHandler: overrideHandler,
97
- inputMethod: _analytics.INPUT_METHOD.KEYBOARD,
98
- reopenQuery: typeAheadStepOverride.query,
99
- selectedIndex: typeAheadStepOverride.selectedIndex
100
- });
101
- } else if (shouldForceClose(typeAheadStepOverride)) {
102
- return closeMenu(currentPluginState);
103
- }
104
- var _ref3 = meta || {},
105
- action = _ref3.action,
106
- params = _ref3.params;
107
- var shouldOpenMenu = action === _actions.ACTIONS.OPEN_TYPEAHEAD_AT_CURSOR && (0, _utils.isTypeAheadHandler)(params === null || params === void 0 ? void 0 : params.triggerHandler);
108
- var selectionChanged = tr.selectionSet && (tr.isGeneric || Boolean(tr.getMeta('pointer')));
109
- var shouldCloseMenu = [_actions.ACTIONS.CLOSE_TYPE_AHEAD, _actions.ACTIONS.INSERT_ITEM].includes(action) || selectionChanged;
110
- var shouldUpdateQuery = action === _actions.ACTIONS.CHANGE_QUERY;
111
- var shouldUpdateListItems = action === _actions.ACTIONS.UPDATE_LIST_ITEMS;
112
- var shouldUpdateSelectedIndex = action === _actions.ACTIONS.UPDATE_SELECTED_INDEX;
113
- if (shouldOpenMenu) {
114
- return openMenu(currentPluginState, {
115
- tr: tr,
116
- triggerHandler: params.triggerHandler,
117
- inputMethod: params.inputMethod
118
- });
119
- } else if (shouldCloseMenu) {
120
- return closeMenu(currentPluginState);
121
- } else if (shouldUpdateQuery) {
122
- return _objectSpread(_objectSpread({}, currentPluginState), {}, {
123
- query: params.query
124
- });
125
- } else if (shouldUpdateListItems) {
126
- var items = params.items;
127
- var selectedIndex = currentPluginState.selectedIndex;
128
- return _objectSpread(_objectSpread({}, currentPluginState), {}, {
129
- items: items,
130
- selectedIndex: Math.max(selectedIndex >= items.length ? items.length - 1 : selectedIndex, -1)
131
- });
132
- } else if (shouldUpdateSelectedIndex) {
133
- return _objectSpread(_objectSpread({}, currentPluginState), {}, {
134
- selectedIndex: params.selectedIndex
135
- });
136
- }
137
- if (tr.docChanged) {
138
- var decorationSet = currentPluginState.decorationSet;
139
- var onRemove = function onRemove() {
140
- // Make sure we are unmounting the component
141
- // from the react tree when this decoration is removed
142
- removeDecorations(currentPluginState.decorationSet);
143
- };
144
- var mappedDecorationSet = decorationSet.map(tr.mapping, tr.doc, {
145
- onRemove: onRemove
146
- });
147
-
148
- // return same pluginState if decorationSet did not change
149
- if (mappedDecorationSet === currentPluginState.decorationSet) {
150
- return currentPluginState;
151
- }
152
- return _objectSpread(_objectSpread({}, currentPluginState), {}, {
153
- decorationSet: mappedDecorationSet
154
- });
155
- }
156
- return currentPluginState;
157
- };
158
- };
@@ -1,18 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isInsertionTransaction = void 0;
7
- var _key = require("./key");
8
- var isInsertionTransaction = exports.isInsertionTransaction = function isInsertionTransaction(transactions, action) {
9
- var _tr$getMeta2;
10
- var tr = transactions.find(function (tr) {
11
- var _tr$getMeta;
12
- return ((_tr$getMeta = tr.getMeta(_key.pluginKey)) === null || _tr$getMeta === void 0 ? void 0 : _tr$getMeta.action) === action;
13
- });
14
- if (!tr) {
15
- return null;
16
- }
17
- return (_tr$getMeta2 = tr.getMeta(_key.pluginKey)) === null || _tr$getMeta2 === void 0 ? void 0 : _tr$getMeta2.params;
18
- };
@@ -1,42 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.StatsModifier = void 0;
8
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
9
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
- var StatsModifier = exports.StatsModifier = /*#__PURE__*/(0, _createClass2.default)(function StatsModifier() {
12
- var _this = this;
13
- (0, _classCallCheck2.default)(this, StatsModifier);
14
- (0, _defineProperty2.default)(this, "startedAt", 0);
15
- (0, _defineProperty2.default)(this, "endedAt", 0);
16
- (0, _defineProperty2.default)(this, "keyCount", {
17
- arrowUp: 0,
18
- arrowDown: 0
19
- });
20
- (0, _defineProperty2.default)(this, "increaseArrowUp", function () {
21
- _this.keyCount.arrowUp += 1;
22
- });
23
- (0, _defineProperty2.default)(this, "increaseArrowDown", function () {
24
- _this.keyCount.arrowDown += 1;
25
- });
26
- (0, _defineProperty2.default)(this, "serialize", function () {
27
- var _this$keyCount, _this$keyCount2;
28
- return {
29
- startedAt: _this.startedAt,
30
- endedAt: performance.now(),
31
- keyCount: {
32
- arrowUp: ((_this$keyCount = _this.keyCount) === null || _this$keyCount === void 0 ? void 0 : _this$keyCount.arrowUp) || 0,
33
- arrowDown: ((_this$keyCount2 = _this.keyCount) === null || _this$keyCount2 === void 0 ? void 0 : _this$keyCount2.arrowDown) || 0
34
- }
35
- };
36
- });
37
- this.startedAt = performance.now();
38
- this.keyCount = {
39
- arrowUp: 0,
40
- arrowDown: 0
41
- };
42
- });
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.closeTypeAhead = void 0;
7
- var _key = require("../pm-plugins/key");
8
- var _actions = require("../pm-plugins/actions");
9
- var closeTypeAhead = exports.closeTypeAhead = function closeTypeAhead(tr) {
10
- return tr.setMeta(_key.pluginKey, {
11
- action: _actions.ACTIONS.CLOSE_TYPE_AHEAD
12
- });
13
- };
@@ -1,75 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.openTypeAheadAtCursor = exports.openTypeAhead = void 0;
7
- var _state = require("@atlaskit/editor-prosemirror/state");
8
- var _selection = require("@atlaskit/editor-common/selection");
9
- var _key = require("../pm-plugins/key");
10
- var _actions = require("../pm-plugins/actions");
11
- var openTypeAhead = exports.openTypeAhead = function openTypeAhead(props) {
12
- return function (tr) {
13
- var triggerHandler = props.triggerHandler,
14
- inputMethod = props.inputMethod,
15
- query = props.query;
16
- tr.setMeta(_key.pluginKey, {
17
- action: _actions.ACTIONS.OPEN_TYPEAHEAD_AT_CURSOR,
18
- params: {
19
- triggerHandler: triggerHandler,
20
- inputMethod: inputMethod,
21
- query: query
22
- }
23
- });
24
- };
25
- };
26
- var openTypeAheadAtCursor = exports.openTypeAheadAtCursor = function openTypeAheadAtCursor(_ref) {
27
- var triggerHandler = _ref.triggerHandler,
28
- inputMethod = _ref.inputMethod,
29
- query = _ref.query;
30
- return function (_ref2) {
31
- var tr = _ref2.tr;
32
- openTypeAhead({
33
- triggerHandler: triggerHandler,
34
- inputMethod: inputMethod,
35
- query: query
36
- })(tr);
37
- var selection = tr.selection;
38
- if (!(selection instanceof _state.TextSelection || selection instanceof _selection.GapCursorSelection)) {
39
- return tr;
40
- }
41
- if (selection instanceof _selection.GapCursorSelection) {
42
- // Create space for the typeahead menu in gap cursor
43
- tr.insertText(' ');
44
- // delete 1 pos before wherever selection is now - that will delete the empty space
45
- tr.delete(tr.selection.from - 1, tr.selection.from);
46
- } else {
47
- var _selection$$head, _selection$$head$pare, _selection$$head$pare2;
48
- if (!selection.$cursor) {
49
- tr.deleteSelection();
50
- return tr;
51
- }
52
-
53
- // Search & Destroy placeholder
54
- var cursorPos = selection.$cursor.pos;
55
- var nodeAtCursor = tr.doc.nodeAt(cursorPos);
56
- var isPlaceholderAtCursorPosition = nodeAtCursor && nodeAtCursor.type.name === 'placeholder';
57
- if (nodeAtCursor && isPlaceholderAtCursorPosition) {
58
- tr.delete(cursorPos, cursorPos + nodeAtCursor.nodeSize);
59
- }
60
-
61
- // ME-2375 remove the superfluous '@' inserted before decoration
62
- // by composition (https://github.com/ProseMirror/prosemirror/issues/903)
63
- //
64
- // Update:
65
- // Now also handles any use case with superfluous typeahead triggers (ie. '@', ':', '/')
66
- // being inserted due to composition by checking if we have the trigger
67
- // directly before the typeahead. This should not happen unless it has
68
- // been eroneously added because we require whitespace/newline for typeahead.
69
- if (cursorPos >= 2 && !!(selection !== null && selection !== void 0 && (_selection$$head = selection.$head) !== null && _selection$$head !== void 0 && (_selection$$head = _selection$$head.parent) !== null && _selection$$head !== void 0 && _selection$$head.textContent) && (_selection$$head$pare = (_selection$$head$pare2 = selection.$head.parent.textContent).endsWith) !== null && _selection$$head$pare !== void 0 && _selection$$head$pare.call(_selection$$head$pare2, triggerHandler.trigger)) {
70
- tr.delete(cursorPos - 1, cursorPos);
71
- }
72
- }
73
- return tr;
74
- };
75
- };
@@ -1,18 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.setSelectionBeforeQuery = void 0;
7
- var _state = require("@atlaskit/editor-prosemirror/state");
8
- var setSelectionBeforeQuery = exports.setSelectionBeforeQuery = function setSelectionBeforeQuery(rawText) {
9
- return function (tr) {
10
- var currentPosition = tr.selection.$from.pos;
11
- var positionBeforeRawText = Math.max(currentPosition - rawText.length, 0);
12
- var resolvedPositionBeforeText = tr.doc.resolve(positionBeforeRawText);
13
- var nextSelection = _state.TextSelection.findFrom(resolvedPositionBeforeText, -1, true);
14
- if (nextSelection) {
15
- tr.setSelection(nextSelection);
16
- }
17
- };
18
- };
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
@@ -1,120 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.AssistiveText = void 0;
8
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
11
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
12
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
14
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
- var _debounce = _interopRequireDefault(require("lodash/debounce"));
16
- var _react = _interopRequireDefault(require("react"));
17
- var _react2 = require("@emotion/react");
18
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
19
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** @jsx jsx */
20
- var statusDebounceMillis = 1400;
21
- var assitiveTextStyles = (0, _react2.css)({
22
- border: 0,
23
- clip: 'rect(0 0 0 0)',
24
- height: '1px',
25
- marginbottom: '-1px',
26
- marginright: '-1px',
27
- overflow: 'hidden',
28
- padding: 0,
29
- position: 'absolute',
30
- whitespace: 'nowrap',
31
- width: '1px'
32
- });
33
- var AssistveTextComponent = /*#__PURE__*/function (_React$Component) {
34
- (0, _inherits2.default)(AssistveTextComponent, _React$Component);
35
- var _super = _createSuper(AssistveTextComponent);
36
- function AssistveTextComponent() {
37
- var _this;
38
- (0, _classCallCheck2.default)(this, AssistveTextComponent);
39
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
40
- args[_key] = arguments[_key];
41
- }
42
- _this = _super.call.apply(_super, [this].concat(args));
43
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
44
- bump: false,
45
- //when the same text needs to be read again, Hence it needs to be toggled between __status--A and __status--B
46
- debounced: false,
47
- silenced: false
48
- });
49
- return _this;
50
- }
51
- (0, _createClass2.default)(AssistveTextComponent, [{
52
- key: "componentWillMount",
53
- value: function componentWillMount() {
54
- var _this2 = this;
55
- this.debounceStatusUpdate = (0, _debounce.default)(function () {
56
- if (!_this2.state.debounced) {
57
- var shouldSilence = !_this2.props.isInFocus;
58
- _this2.setState(function (_ref) {
59
- var bump = _ref.bump;
60
- return {
61
- bump: !bump,
62
- debounced: true,
63
- silenced: shouldSilence
64
- };
65
- });
66
- }
67
- }, statusDebounceMillis);
68
- }
69
- }, {
70
- key: "componentWillUnmount",
71
- value: function componentWillUnmount() {
72
- this.debounceStatusUpdate.cancel();
73
- }
74
- }, {
75
- key: "componentWillReceiveProps",
76
- value: function componentWillReceiveProps() {
77
- this.setState(function (_ref2) {
78
- var bump = _ref2.bump;
79
- return {
80
- bump: !bump,
81
- debounced: false
82
- };
83
- });
84
- }
85
- }, {
86
- key: "render",
87
- value: function render() {
88
- var _this$props = this.props,
89
- assistiveText = _this$props.assistiveText,
90
- id = _this$props.id;
91
- var _this$state = this.state,
92
- bump = _this$state.bump,
93
- debounced = _this$state.debounced,
94
- silenced = _this$state.silenced;
95
- this.debounceStatusUpdate();
96
- return (0, _react2.jsx)("div", {
97
- css: assitiveTextStyles
98
- }, (0, _react2.jsx)("div", {
99
- id: id + '__status--A',
100
- role: "status",
101
- "aria-atomic": "true",
102
- "aria-live": "polite"
103
- }, "".concat(!silenced && debounced && bump ? assistiveText : '')), (0, _react2.jsx)("div", {
104
- id: id + '__status--B',
105
- role: "status",
106
- "aria-atomic": "true",
107
- "aria-live": "polite"
108
- }, "".concat(!silenced && debounced && !bump ? assistiveText : '')));
109
- }
110
- }]);
111
- return AssistveTextComponent;
112
- }(_react.default.Component);
113
- (0, _defineProperty2.default)(AssistveTextComponent, "defaultProps", {
114
- statusDebounceMillis: 1400,
115
- debounce: true,
116
- assistiveText: '',
117
- isInFocus: false,
118
- id: ''
119
- });
120
- var AssistiveText = exports.AssistiveText = AssistveTextComponent;