@atlaskit/editor-plugin-type-ahead 2.5.4 → 2.6.1

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/editor-plugin-type-ahead
2
2
 
3
+ ## 2.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 2.6.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#149207](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/149207)
14
+ [`41c4599b89f3c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/41c4599b89f3c) -
15
+ ED-27854 Add invocationMethod to typeahead closed event
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies
20
+
3
21
  ## 2.5.4
4
22
 
5
23
  ### Patch Changes
@@ -1,21 +1,30 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.fireTypeAheadClosedAnalyticsEvent = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
7
9
  var _analytics = require("@atlaskit/editor-common/analytics");
10
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
+ 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; }
12
+ 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; }
8
13
  var fireTypeAheadClosedAnalyticsEvent = exports.fireTypeAheadClosedAnalyticsEvent = function fireTypeAheadClosedAnalyticsEvent(api, closeAction, hasQuery, inputMethod) {
9
14
  var _api$analytics;
15
+ var invocationMethod = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
16
+ var additionalAttributes = (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_analytics') ? {
17
+ invocationMethod: invocationMethod
18
+ } : {};
10
19
  api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent({
11
20
  action: _analytics.ACTION.CLOSED,
12
21
  actionSubject: _analytics.ACTION_SUBJECT.TYPEAHEAD,
13
22
  actionSubjectId: _analytics.ACTION_SUBJECT_ID.TYPEAHEAD_QUICK_INSERT,
14
- attributes: {
23
+ attributes: _objectSpread({
15
24
  inputMethod: inputMethod,
16
25
  closeAction: closeAction,
17
26
  hasQuery: hasQuery
18
- },
27
+ }, additionalAttributes),
19
28
  eventType: _analytics.EVENT_TYPE.TRACK
20
29
  });
21
30
  };
@@ -65,6 +65,7 @@ var Highlight = function Highlight(_ref) {
65
65
  };
66
66
  var OFFSET = [0, 8];
67
67
  var TypeAheadPopup = exports.TypeAheadPopup = /*#__PURE__*/_react.default.memo(function (props) {
68
+ var _getPluginState;
68
69
  var editorView = props.editorView,
69
70
  triggerHandler = props.triggerHandler,
70
71
  anchorElement = props.anchorElement,
@@ -89,7 +90,8 @@ var TypeAheadPopup = exports.TypeAheadPopup = /*#__PURE__*/_react.default.memo(f
89
90
  }, [moreElementsInQuickInsertViewEnabled]);
90
91
  var activityStateRef = (0, _react.useRef)({
91
92
  inputMethod: null,
92
- closeAction: null
93
+ closeAction: null,
94
+ invocationMethod: (_getPluginState = (0, _utils.getPluginState)(editorView.state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.inputMethod
93
95
  });
94
96
  var startTime = (0, _react.useMemo)(function () {
95
97
  return performance.now();
@@ -286,6 +288,7 @@ var TypeAheadPopup = exports.TypeAheadPopup = /*#__PURE__*/_react.default.memo(f
286
288
  removePrefixTriggerOnCancel = _ref3.removePrefixTriggerOnCancel;
287
289
  var escape = function escape(event) {
288
290
  if (event.key === 'Escape') {
291
+ activityStateRef.current.inputMethod = _analytics.INPUT_METHOD.KEYBOARD;
289
292
  cancel({
290
293
  addPrefixTrigger: isEditorControlsPatch2Enabled ? !removePrefixTriggerOnCancel : true,
291
294
  setSelectionAt: _constants.CloseSelectionOptions.AFTER_TEXT_INSERTED,
@@ -316,7 +319,8 @@ var TypeAheadPopup = exports.TypeAheadPopup = /*#__PURE__*/_react.default.memo(f
316
319
  if (openElementBrowserModal && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_4')) {
317
320
  activityStateRef.current = {
318
321
  inputMethod: _analytics.INPUT_METHOD.MOUSE,
319
- closeAction: _analytics.ACTION.VIEW_MORE
322
+ closeAction: _analytics.ACTION.VIEW_MORE,
323
+ invocationMethod: activityStateRef.current.invocationMethod
320
324
  };
321
325
  }
322
326
 
@@ -339,12 +343,13 @@ var TypeAheadPopup = exports.TypeAheadPopup = /*#__PURE__*/_react.default.memo(f
339
343
  if (selectedIndex > -1 && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_4')) {
340
344
  // if selectedIndex is -1, it means that the user has not selected any item
341
345
  // will be handled by WrapperTypeAhead
342
- (0, _analytics2.fireTypeAheadClosedAnalyticsEvent)(api, activityStateRef.current.closeAction, !isEmptyQuery, activityStateRef.current.inputMethod);
346
+ (0, _analytics2.fireTypeAheadClosedAnalyticsEvent)(api, activityStateRef.current.closeAction || _analytics.ACTION.CANCELLED, !isEmptyQuery, activityStateRef.current.inputMethod || _analytics.INPUT_METHOD.MOUSE, activityStateRef.current.invocationMethod);
343
347
 
344
348
  // reset activity state
345
349
  activityStateRef.current = {
346
350
  inputMethod: null,
347
- closeAction: null
351
+ closeAction: null,
352
+ invocationMethod: null
348
353
  };
349
354
  }
350
355
  }
@@ -367,7 +372,8 @@ var TypeAheadPopup = exports.TypeAheadPopup = /*#__PURE__*/_react.default.memo(f
367
372
  if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_4')) {
368
373
  activityStateRef.current = {
369
374
  inputMethod: inputMethod || null,
370
- closeAction: _analytics.ACTION.INSERTED
375
+ closeAction: _analytics.ACTION.INSERTED,
376
+ invocationMethod: activityStateRef.current.invocationMethod
371
377
  };
372
378
  }
373
379
  onItemInsert(mode, index);
@@ -85,7 +85,8 @@ var WrapperTypeAhead = exports.WrapperTypeAhead = /*#__PURE__*/_react.default.me
85
85
  text = _ref2.text,
86
86
  forceFocusOnEditor = _ref2.forceFocusOnEditor;
87
87
  if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_4')) {
88
- (0, _analytics2.fireTypeAheadClosedAnalyticsEvent)(api, _analytics.ACTION.CANCELLED, !!queryRef.current, _analytics.INPUT_METHOD.KEYBOARD);
88
+ var _getPluginState;
89
+ (0, _analytics2.fireTypeAheadClosedAnalyticsEvent)(api, _analytics.ACTION.CANCELLED, !!queryRef.current, _analytics.INPUT_METHOD.KEYBOARD, (_getPluginState = (0, _utils.getPluginState)(editorView.state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.inputMethod);
89
90
  }
90
91
  setClosed(true);
91
92
  var fullquery = addPrefixTrigger ? "".concat(triggerHandler.trigger).concat(text) : text;
@@ -94,7 +95,7 @@ var WrapperTypeAhead = exports.WrapperTypeAhead = /*#__PURE__*/_react.default.me
94
95
  setSelectionAt: setSelectionAt,
95
96
  text: fullquery
96
97
  });
97
- }, [api, triggerHandler.trigger, onTextInsert]);
98
+ }, [triggerHandler.trigger, onTextInsert, api, editorView.state]);
98
99
  var insertSelectedItem = (0, _react.useCallback)(function () {
99
100
  var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _typeAhead.SelectItemMode.SELECTED;
100
101
  var view = editorViewRef.current;
@@ -116,7 +117,8 @@ var WrapperTypeAhead = exports.WrapperTypeAhead = /*#__PURE__*/_react.default.me
116
117
  return;
117
118
  }
118
119
  if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_4')) {
119
- (0, _analytics2.fireTypeAheadClosedAnalyticsEvent)(api, _analytics.ACTION.INSERTED, !!queryRef.current, _analytics.INPUT_METHOD.KEYBOARD);
120
+ var _getPluginState2;
121
+ (0, _analytics2.fireTypeAheadClosedAnalyticsEvent)(api, _analytics.ACTION.INSERTED, !!queryRef.current, _analytics.INPUT_METHOD.KEYBOARD, (_getPluginState2 = (0, _utils.getPluginState)(editorView.state)) === null || _getPluginState2 === void 0 ? void 0 : _getPluginState2.inputMethod);
120
122
  }
121
123
  setClosed(true);
122
124
  queueMicrotask(function () {
@@ -126,7 +128,7 @@ var WrapperTypeAhead = exports.WrapperTypeAhead = /*#__PURE__*/_react.default.me
126
128
  query: queryRef.current
127
129
  });
128
130
  });
129
- }, [onItemInsert, api, items]);
131
+ }, [items, api, editorView.state, onItemInsert]);
130
132
  var showTypeAheadPopupList = (0, _react.useCallback)(function () {}, []);
131
133
  var closePopup = (0, _react.useCallback)(function () {
132
134
  setClosed(true);
@@ -1,6 +1,10 @@
1
1
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
2
- export const fireTypeAheadClosedAnalyticsEvent = (api, closeAction, hasQuery, inputMethod) => {
2
+ import { fg } from '@atlaskit/platform-feature-flags';
3
+ export const fireTypeAheadClosedAnalyticsEvent = (api, closeAction, hasQuery, inputMethod, invocationMethod = null) => {
3
4
  var _api$analytics;
5
+ const additionalAttributes = fg('platform_editor_controls_patch_analytics') ? {
6
+ invocationMethod
7
+ } : {};
4
8
  api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.fireAnalyticsEvent({
5
9
  action: ACTION.CLOSED,
6
10
  actionSubject: ACTION_SUBJECT.TYPEAHEAD,
@@ -8,7 +12,8 @@ export const fireTypeAheadClosedAnalyticsEvent = (api, closeAction, hasQuery, in
8
12
  attributes: {
9
13
  inputMethod,
10
14
  closeAction,
11
- hasQuery
15
+ hasQuery,
16
+ ...additionalAttributes
12
17
  },
13
18
  eventType: EVENT_TYPE.TRACK
14
19
  });
@@ -54,6 +54,7 @@ const Highlight = ({
54
54
  };
55
55
  const OFFSET = [0, 8];
56
56
  export const TypeAheadPopup = /*#__PURE__*/React.memo(props => {
57
+ var _getPluginState;
57
58
  const {
58
59
  editorView,
59
60
  triggerHandler,
@@ -79,7 +80,8 @@ export const TypeAheadPopup = /*#__PURE__*/React.memo(props => {
79
80
  const defaultMenuHeight = useMemo(() => moreElementsInQuickInsertViewEnabled ? DEFAULT_TYPEAHEAD_MENU_HEIGHT_NEW : DEFAULT_TYPEAHEAD_MENU_HEIGHT, [moreElementsInQuickInsertViewEnabled]);
80
81
  const activityStateRef = useRef({
81
82
  inputMethod: null,
82
- closeAction: null
83
+ closeAction: null,
84
+ invocationMethod: (_getPluginState = getPluginState(editorView.state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.inputMethod
83
85
  });
84
86
  const startTime = useMemo(() => performance.now(),
85
87
  // In case those props changes
@@ -279,6 +281,7 @@ export const TypeAheadPopup = /*#__PURE__*/React.memo(props => {
279
281
  } = getPluginState(editorView.state) || {};
280
282
  const escape = event => {
281
283
  if (event.key === 'Escape') {
284
+ activityStateRef.current.inputMethod = INPUT_METHOD.KEYBOARD;
282
285
  cancel({
283
286
  addPrefixTrigger: isEditorControlsPatch2Enabled ? !removePrefixTriggerOnCancel : true,
284
287
  setSelectionAt: CloseSelectionOptions.AFTER_TEXT_INSERTED,
@@ -315,7 +318,8 @@ export const TypeAheadPopup = /*#__PURE__*/React.memo(props => {
315
318
  if (openElementBrowserModal && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_4')) {
316
319
  activityStateRef.current = {
317
320
  inputMethod: INPUT_METHOD.MOUSE,
318
- closeAction: ACTION.VIEW_MORE
321
+ closeAction: ACTION.VIEW_MORE,
322
+ invocationMethod: activityStateRef.current.invocationMethod
319
323
  };
320
324
  }
321
325
 
@@ -338,12 +342,13 @@ export const TypeAheadPopup = /*#__PURE__*/React.memo(props => {
338
342
  if (selectedIndex > -1 && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_4')) {
339
343
  // if selectedIndex is -1, it means that the user has not selected any item
340
344
  // will be handled by WrapperTypeAhead
341
- fireTypeAheadClosedAnalyticsEvent(api, activityStateRef.current.closeAction, !isEmptyQuery, activityStateRef.current.inputMethod);
345
+ fireTypeAheadClosedAnalyticsEvent(api, activityStateRef.current.closeAction || ACTION.CANCELLED, !isEmptyQuery, activityStateRef.current.inputMethod || INPUT_METHOD.MOUSE, activityStateRef.current.invocationMethod);
342
346
 
343
347
  // reset activity state
344
348
  activityStateRef.current = {
345
349
  inputMethod: null,
346
- closeAction: null
350
+ closeAction: null,
351
+ invocationMethod: null
347
352
  };
348
353
  }
349
354
  }
@@ -366,7 +371,8 @@ export const TypeAheadPopup = /*#__PURE__*/React.memo(props => {
366
371
  if (editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_4')) {
367
372
  activityStateRef.current = {
368
373
  inputMethod: inputMethod || null,
369
- closeAction: ACTION.INSERTED
374
+ closeAction: ACTION.INSERTED,
375
+ invocationMethod: activityStateRef.current.invocationMethod
370
376
  };
371
377
  }
372
378
  onItemInsert(mode, index);
@@ -63,7 +63,8 @@ export const WrapperTypeAhead = /*#__PURE__*/React.memo(({
63
63
  forceFocusOnEditor
64
64
  }) => {
65
65
  if (editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_4')) {
66
- fireTypeAheadClosedAnalyticsEvent(api, ACTION.CANCELLED, !!queryRef.current, INPUT_METHOD.KEYBOARD);
66
+ var _getPluginState;
67
+ fireTypeAheadClosedAnalyticsEvent(api, ACTION.CANCELLED, !!queryRef.current, INPUT_METHOD.KEYBOARD, (_getPluginState = getPluginState(editorView.state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.inputMethod);
67
68
  }
68
69
  setClosed(true);
69
70
  const fullquery = addPrefixTrigger ? `${triggerHandler.trigger}${text}` : text;
@@ -72,7 +73,7 @@ export const WrapperTypeAhead = /*#__PURE__*/React.memo(({
72
73
  setSelectionAt,
73
74
  text: fullquery
74
75
  });
75
- }, [api, triggerHandler.trigger, onTextInsert]);
76
+ }, [triggerHandler.trigger, onTextInsert, api, editorView.state]);
76
77
  const insertSelectedItem = useCallback((mode = SelectItemMode.SELECTED) => {
77
78
  const {
78
79
  current: view
@@ -94,7 +95,8 @@ export const WrapperTypeAhead = /*#__PURE__*/React.memo(({
94
95
  return;
95
96
  }
96
97
  if (editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_4')) {
97
- fireTypeAheadClosedAnalyticsEvent(api, ACTION.INSERTED, !!queryRef.current, INPUT_METHOD.KEYBOARD);
98
+ var _getPluginState2;
99
+ fireTypeAheadClosedAnalyticsEvent(api, ACTION.INSERTED, !!queryRef.current, INPUT_METHOD.KEYBOARD, (_getPluginState2 = getPluginState(editorView.state)) === null || _getPluginState2 === void 0 ? void 0 : _getPluginState2.inputMethod);
98
100
  }
99
101
  setClosed(true);
100
102
  queueMicrotask(() => {
@@ -104,7 +106,7 @@ export const WrapperTypeAhead = /*#__PURE__*/React.memo(({
104
106
  query: queryRef.current
105
107
  });
106
108
  });
107
- }, [onItemInsert, api, items]);
109
+ }, [items, api, editorView.state, onItemInsert]);
108
110
  const showTypeAheadPopupList = useCallback(() => {}, []);
109
111
  const closePopup = useCallback(() => {
110
112
  setClosed(true);
@@ -1,15 +1,23 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ 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; }
3
+ 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) { _defineProperty(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; }
1
4
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
2
6
  export var fireTypeAheadClosedAnalyticsEvent = function fireTypeAheadClosedAnalyticsEvent(api, closeAction, hasQuery, inputMethod) {
3
7
  var _api$analytics;
8
+ var invocationMethod = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
9
+ var additionalAttributes = fg('platform_editor_controls_patch_analytics') ? {
10
+ invocationMethod: invocationMethod
11
+ } : {};
4
12
  api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent({
5
13
  action: ACTION.CLOSED,
6
14
  actionSubject: ACTION_SUBJECT.TYPEAHEAD,
7
15
  actionSubjectId: ACTION_SUBJECT_ID.TYPEAHEAD_QUICK_INSERT,
8
- attributes: {
16
+ attributes: _objectSpread({
9
17
  inputMethod: inputMethod,
10
18
  closeAction: closeAction,
11
19
  hasQuery: hasQuery
12
- },
20
+ }, additionalAttributes),
13
21
  eventType: EVENT_TYPE.TRACK
14
22
  });
15
23
  };
@@ -54,6 +54,7 @@ var Highlight = function Highlight(_ref) {
54
54
  };
55
55
  var OFFSET = [0, 8];
56
56
  export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
57
+ var _getPluginState;
57
58
  var editorView = props.editorView,
58
59
  triggerHandler = props.triggerHandler,
59
60
  anchorElement = props.anchorElement,
@@ -78,7 +79,8 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
78
79
  }, [moreElementsInQuickInsertViewEnabled]);
79
80
  var activityStateRef = useRef({
80
81
  inputMethod: null,
81
- closeAction: null
82
+ closeAction: null,
83
+ invocationMethod: (_getPluginState = getPluginState(editorView.state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.inputMethod
82
84
  });
83
85
  var startTime = useMemo(function () {
84
86
  return performance.now();
@@ -275,6 +277,7 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
275
277
  removePrefixTriggerOnCancel = _ref3.removePrefixTriggerOnCancel;
276
278
  var escape = function escape(event) {
277
279
  if (event.key === 'Escape') {
280
+ activityStateRef.current.inputMethod = INPUT_METHOD.KEYBOARD;
278
281
  cancel({
279
282
  addPrefixTrigger: isEditorControlsPatch2Enabled ? !removePrefixTriggerOnCancel : true,
280
283
  setSelectionAt: CloseSelectionOptions.AFTER_TEXT_INSERTED,
@@ -305,7 +308,8 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
305
308
  if (openElementBrowserModal && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_4')) {
306
309
  activityStateRef.current = {
307
310
  inputMethod: INPUT_METHOD.MOUSE,
308
- closeAction: ACTION.VIEW_MORE
311
+ closeAction: ACTION.VIEW_MORE,
312
+ invocationMethod: activityStateRef.current.invocationMethod
309
313
  };
310
314
  }
311
315
 
@@ -328,12 +332,13 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
328
332
  if (selectedIndex > -1 && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_4')) {
329
333
  // if selectedIndex is -1, it means that the user has not selected any item
330
334
  // will be handled by WrapperTypeAhead
331
- fireTypeAheadClosedAnalyticsEvent(api, activityStateRef.current.closeAction, !isEmptyQuery, activityStateRef.current.inputMethod);
335
+ fireTypeAheadClosedAnalyticsEvent(api, activityStateRef.current.closeAction || ACTION.CANCELLED, !isEmptyQuery, activityStateRef.current.inputMethod || INPUT_METHOD.MOUSE, activityStateRef.current.invocationMethod);
332
336
 
333
337
  // reset activity state
334
338
  activityStateRef.current = {
335
339
  inputMethod: null,
336
- closeAction: null
340
+ closeAction: null,
341
+ invocationMethod: null
337
342
  };
338
343
  }
339
344
  }
@@ -356,7 +361,8 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
356
361
  if (editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_4')) {
357
362
  activityStateRef.current = {
358
363
  inputMethod: inputMethod || null,
359
- closeAction: ACTION.INSERTED
364
+ closeAction: ACTION.INSERTED,
365
+ invocationMethod: activityStateRef.current.invocationMethod
360
366
  };
361
367
  }
362
368
  onItemInsert(mode, index);
@@ -75,7 +75,8 @@ export var WrapperTypeAhead = /*#__PURE__*/React.memo(function (_ref) {
75
75
  text = _ref2.text,
76
76
  forceFocusOnEditor = _ref2.forceFocusOnEditor;
77
77
  if (editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_4')) {
78
- fireTypeAheadClosedAnalyticsEvent(api, ACTION.CANCELLED, !!queryRef.current, INPUT_METHOD.KEYBOARD);
78
+ var _getPluginState;
79
+ fireTypeAheadClosedAnalyticsEvent(api, ACTION.CANCELLED, !!queryRef.current, INPUT_METHOD.KEYBOARD, (_getPluginState = getPluginState(editorView.state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.inputMethod);
79
80
  }
80
81
  setClosed(true);
81
82
  var fullquery = addPrefixTrigger ? "".concat(triggerHandler.trigger).concat(text) : text;
@@ -84,7 +85,7 @@ export var WrapperTypeAhead = /*#__PURE__*/React.memo(function (_ref) {
84
85
  setSelectionAt: setSelectionAt,
85
86
  text: fullquery
86
87
  });
87
- }, [api, triggerHandler.trigger, onTextInsert]);
88
+ }, [triggerHandler.trigger, onTextInsert, api, editorView.state]);
88
89
  var insertSelectedItem = useCallback(function () {
89
90
  var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SelectItemMode.SELECTED;
90
91
  var view = editorViewRef.current;
@@ -106,7 +107,8 @@ export var WrapperTypeAhead = /*#__PURE__*/React.memo(function (_ref) {
106
107
  return;
107
108
  }
108
109
  if (editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_4')) {
109
- fireTypeAheadClosedAnalyticsEvent(api, ACTION.INSERTED, !!queryRef.current, INPUT_METHOD.KEYBOARD);
110
+ var _getPluginState2;
111
+ fireTypeAheadClosedAnalyticsEvent(api, ACTION.INSERTED, !!queryRef.current, INPUT_METHOD.KEYBOARD, (_getPluginState2 = getPluginState(editorView.state)) === null || _getPluginState2 === void 0 ? void 0 : _getPluginState2.inputMethod);
110
112
  }
111
113
  setClosed(true);
112
114
  queueMicrotask(function () {
@@ -116,7 +118,7 @@ export var WrapperTypeAhead = /*#__PURE__*/React.memo(function (_ref) {
116
118
  query: queryRef.current
117
119
  });
118
120
  });
119
- }, [onItemInsert, api, items]);
121
+ }, [items, api, editorView.state, onItemInsert]);
120
122
  var showTypeAheadPopupList = useCallback(function () {}, []);
121
123
  var closePopup = useCallback(function () {
122
124
  setClosed(true);
@@ -1,6 +1,7 @@
1
1
  import { ACTION, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import { TypeAheadPlugin } from '../typeAheadPluginType';
4
+ import { TypeAheadInputMethod } from '../types';
4
5
  export type CloseActionType = ACTION.INSERTED | ACTION.CANCELLED | ACTION.VIEW_MORE;
5
6
  export type InputMethodType = INPUT_METHOD.KEYBOARD | INPUT_METHOD.MOUSE;
6
- export declare const fireTypeAheadClosedAnalyticsEvent: (api: ExtractInjectionAPI<TypeAheadPlugin> | undefined, closeAction: CloseActionType | null, hasQuery: boolean, inputMethod: InputMethodType | null) => void;
7
+ export declare const fireTypeAheadClosedAnalyticsEvent: (api: ExtractInjectionAPI<TypeAheadPlugin> | undefined, closeAction: CloseActionType | null, hasQuery: boolean, inputMethod: InputMethodType | null, invocationMethod?: TypeAheadInputMethod | null) => void;
@@ -1,6 +1,7 @@
1
1
  import { ACTION, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import { TypeAheadPlugin } from '../typeAheadPluginType';
4
+ import { TypeAheadInputMethod } from '../types';
4
5
  export type CloseActionType = ACTION.INSERTED | ACTION.CANCELLED | ACTION.VIEW_MORE;
5
6
  export type InputMethodType = INPUT_METHOD.KEYBOARD | INPUT_METHOD.MOUSE;
6
- export declare const fireTypeAheadClosedAnalyticsEvent: (api: ExtractInjectionAPI<TypeAheadPlugin> | undefined, closeAction: CloseActionType | null, hasQuery: boolean, inputMethod: InputMethodType | null) => void;
7
+ export declare const fireTypeAheadClosedAnalyticsEvent: (api: ExtractInjectionAPI<TypeAheadPlugin> | undefined, closeAction: CloseActionType | null, hasQuery: boolean, inputMethod: InputMethodType | null, invocationMethod?: TypeAheadInputMethod | null) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-type-ahead",
3
- "version": "2.5.4",
3
+ "version": "2.6.1",
4
4
  "description": "Type-ahead plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,11 +34,11 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@atlaskit/adf-schema": "^47.6.0",
37
- "@atlaskit/editor-common": "^103.21.0",
37
+ "@atlaskit/editor-common": "^104.0.0",
38
38
  "@atlaskit/editor-element-browser": "^0.1.0",
39
39
  "@atlaskit/editor-plugin-analytics": "^2.2.0",
40
40
  "@atlaskit/editor-plugin-connectivity": "^2.0.0",
41
- "@atlaskit/editor-plugin-context-panel": "^4.0.0",
41
+ "@atlaskit/editor-plugin-context-panel": "^4.1.0",
42
42
  "@atlaskit/editor-plugin-metrics": "^3.4.0",
43
43
  "@atlaskit/editor-prosemirror": "7.0.0",
44
44
  "@atlaskit/editor-shared-styles": "^3.4.0",
@@ -46,10 +46,10 @@
46
46
  "@atlaskit/icon": "^25.6.0",
47
47
  "@atlaskit/menu": "^5.0.0",
48
48
  "@atlaskit/platform-feature-flags": "^1.1.0",
49
- "@atlaskit/primitives": "^14.4.0",
49
+ "@atlaskit/primitives": "^14.7.0",
50
50
  "@atlaskit/prosemirror-input-rules": "^3.3.0",
51
51
  "@atlaskit/theme": "^18.0.0",
52
- "@atlaskit/tmp-editor-statsig": "^4.15.0",
52
+ "@atlaskit/tmp-editor-statsig": "^4.16.0",
53
53
  "@atlaskit/tokens": "^4.8.0",
54
54
  "@babel/runtime": "^7.0.0",
55
55
  "@emotion/react": "^11.7.1",
@@ -114,6 +114,9 @@
114
114
  "platform_editor_controls_patch_4": {
115
115
  "type": "boolean"
116
116
  },
117
+ "platform_editor_controls_patch_analytics": {
118
+ "type": "boolean"
119
+ },
117
120
  "platform_editor_ease_of_use_metrics": {
118
121
  "type": "boolean"
119
122
  },