@atlaskit/editor-plugin-type-ahead 2.4.2 → 2.5.0

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,18 @@
1
1
  # @atlaskit/editor-plugin-type-ahead
2
2
 
3
+ ## 2.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#139089](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/139089)
8
+ [`69dcdc0c4a543`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/69dcdc0c4a543) -
9
+ ED-26588 Start activity session and persist active session when type ahead and element broswer is
10
+ open
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies
15
+
3
16
  ## 2.4.2
4
17
 
5
18
  ### Patch Changes
@@ -150,6 +150,10 @@ var factoryDecorations = exports.factoryDecorations = function factoryDecoration
150
150
  }
151
151
  nodeViewPortalProviderAPI.remove(spec.key);
152
152
  });
153
+ if ((0, _platformFeatureFlags.fg)('platform_editor_ease_of_use_metrics')) {
154
+ var _api$metrics;
155
+ api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$metrics = api.metrics) === null || _api$metrics === void 0 ? void 0 : _api$metrics.commands.startActiveSessionTimer());
156
+ }
153
157
  return true;
154
158
  };
155
159
  return {
@@ -8,6 +8,7 @@ var _steps = require("@atlaskit/adf-schema/steps");
8
8
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
9
9
  var _utils = require("@atlaskit/editor-common/utils");
10
10
  var _view = require("@atlaskit/editor-prosemirror/view");
11
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
12
  var _actions = require("./actions");
12
13
  var _constants = require("./constants");
13
14
  var _decorations = require("./decorations");
@@ -79,6 +80,12 @@ function createPlugin(_ref) {
79
80
  if (insertItemCallback) {
80
81
  var tr = insertItemCallback(newState);
81
82
  if (tr) {
83
+ if ((0, _platformFeatureFlags.fg)('platform_editor_ease_of_use_metrics')) {
84
+ var _api$metrics;
85
+ api === null || api === void 0 || (_api$metrics = api.metrics) === null || _api$metrics === void 0 || _api$metrics.commands.startActiveSessionTimer()({
86
+ tr: tr
87
+ });
88
+ }
82
89
  return tr;
83
90
  }
84
91
  }
@@ -11,6 +11,7 @@ var _analytics = require("@atlaskit/editor-common/analytics");
11
11
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
12
12
  var _typeAhead = require("@atlaskit/editor-common/type-ahead");
13
13
  var _view2 = require("@atlaskit/editor-prosemirror/view");
14
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
14
15
  var _closeTypeAhead = require("./pm-plugins/commands/close-type-ahead");
15
16
  var _insertTypeAheadItem = require("./pm-plugins/commands/insert-type-ahead-item");
16
17
  var _openTypeaheadAtCursor = require("./pm-plugins/commands/open-typeahead-at-cursor");
@@ -283,8 +284,17 @@ var typeAheadPlugin = exports.typeAheadPlugin = function typeAheadPlugin(_ref) {
283
284
  });
284
285
  }
285
286
  if (newTriggerHandler !== null && newTriggerHandler !== void 0 && newTriggerHandler.onOpen && isANewHandler) {
287
+ if ((0, _platformFeatureFlags.fg)('platform_editor_ease_of_use_metrics')) {
288
+ var _api$metrics;
289
+ api === null || api === void 0 || (_api$metrics = api.metrics) === null || _api$metrics === void 0 || _api$metrics.commands.handleIntentToStartEdit({
290
+ shouldStartTimer: false,
291
+ shouldPersistActiveSession: true
292
+ });
293
+ }
286
294
  newTriggerHandler.onOpen(newEditorState);
287
295
  }
296
+ var oldIsOpen = (0, _utils.isTypeAheadOpen)(oldEditorState);
297
+ var newIsOpen = (0, _utils.isTypeAheadOpen)(newEditorState);
288
298
  if (newTriggerHandler && isANewHandler) {
289
299
  // if the typeahead opens another typeahead via the quickInsert we do NOT want to fire this analytic event (mentions and emojis) as it is already being fired from editor-plugin-analytics
290
300
  var isDuplicateInvokedEvent = newPluginState.inputMethod === _analytics.INPUT_METHOD.QUICK_INSERT && Object.values(_typeAhead.TypeAheadAvailableNodes).includes(newTriggerHandler.id);
@@ -300,6 +310,9 @@ var typeAheadPlugin = exports.typeAheadPlugin = function typeAheadPlugin(_ref) {
300
310
  eventType: _analytics.EVENT_TYPE.UI
301
311
  });
302
312
  }
313
+ } else if (oldIsOpen && !newIsOpen && (0, _platformFeatureFlags.fg)('platform_editor_ease_of_use_metrics')) {
314
+ var _api$metrics2;
315
+ api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$metrics2 = api.metrics) === null || _api$metrics2 === void 0 ? void 0 : _api$metrics2.commands.startActiveSessionTimer());
303
316
  }
304
317
  }
305
318
  };
@@ -49,6 +49,15 @@ var WrapperTypeAhead = exports.WrapperTypeAhead = /*#__PURE__*/_react.default.me
49
49
  var queryRef = (0, _react.useRef)(query);
50
50
  var editorViewRef = (0, _react.useRef)(editorView);
51
51
  var items = (0, _useLoadItems.useLoadItems)(triggerHandler, editorView, query, showViewMore);
52
+ (0, _react.useEffect)(function () {
53
+ if (!closed && (0, _platformFeatureFlags.fg)('platform_editor_ease_of_use_metrics')) {
54
+ var _api$metrics;
55
+ api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$metrics = api.metrics) === null || _api$metrics === void 0 ? void 0 : _api$metrics.commands.handleIntentToStartEdit({
56
+ shouldStartTimer: false,
57
+ shouldPersistActiveSession: true
58
+ }));
59
+ }
60
+ }, [closed, api]);
52
61
  (0, _react.useLayoutEffect)(function () {
53
62
  queryRef.current = query;
54
63
  }, [query]);
@@ -150,6 +150,10 @@ export const factoryDecorations = ({
150
150
  }
151
151
  nodeViewPortalProviderAPI.remove(spec.key);
152
152
  });
153
+ if (fg('platform_editor_ease_of_use_metrics')) {
154
+ var _api$metrics;
155
+ api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$metrics = api.metrics) === null || _api$metrics === void 0 ? void 0 : _api$metrics.commands.startActiveSessionTimer());
156
+ }
153
157
  return true;
154
158
  };
155
159
  return {
@@ -2,6 +2,7 @@ import { InsertTypeAheadStep } from '@atlaskit/adf-schema/steps';
2
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
3
  import { closest } from '@atlaskit/editor-common/utils';
4
4
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
5
6
  import { ACTIONS } from './actions';
6
7
  import { TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE } from './constants';
7
8
  import { factoryDecorations } from './decorations';
@@ -73,6 +74,12 @@ export function createPlugin({
73
74
  if (insertItemCallback) {
74
75
  const tr = insertItemCallback(newState);
75
76
  if (tr) {
77
+ if (fg('platform_editor_ease_of_use_metrics')) {
78
+ var _api$metrics;
79
+ api === null || api === void 0 ? void 0 : (_api$metrics = api.metrics) === null || _api$metrics === void 0 ? void 0 : _api$metrics.commands.startActiveSessionTimer()({
80
+ tr
81
+ });
82
+ }
76
83
  return tr;
77
84
  }
78
85
  }
@@ -12,6 +12,7 @@ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/edit
12
12
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
13
13
  import { SelectItemMode, TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
14
14
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
15
+ import { fg } from '@atlaskit/platform-feature-flags';
15
16
  import { closeTypeAhead } from './pm-plugins/commands/close-type-ahead';
16
17
  import { insertTypeAheadItem } from './pm-plugins/commands/insert-type-ahead-item';
17
18
  import { openTypeAheadAtCursor } from './pm-plugins/commands/open-typeahead-at-cursor';
@@ -283,8 +284,17 @@ export const typeAheadPlugin = ({
283
284
  });
284
285
  }
285
286
  if (newTriggerHandler !== null && newTriggerHandler !== void 0 && newTriggerHandler.onOpen && isANewHandler) {
287
+ if (fg('platform_editor_ease_of_use_metrics')) {
288
+ var _api$metrics;
289
+ api === null || api === void 0 ? void 0 : (_api$metrics = api.metrics) === null || _api$metrics === void 0 ? void 0 : _api$metrics.commands.handleIntentToStartEdit({
290
+ shouldStartTimer: false,
291
+ shouldPersistActiveSession: true
292
+ });
293
+ }
286
294
  newTriggerHandler.onOpen(newEditorState);
287
295
  }
296
+ const oldIsOpen = isTypeAheadOpen(oldEditorState);
297
+ const newIsOpen = isTypeAheadOpen(newEditorState);
288
298
  if (newTriggerHandler && isANewHandler) {
289
299
  // if the typeahead opens another typeahead via the quickInsert we do NOT want to fire this analytic event (mentions and emojis) as it is already being fired from editor-plugin-analytics
290
300
  const isDuplicateInvokedEvent = newPluginState.inputMethod === INPUT_METHOD.QUICK_INSERT && Object.values(TypeAheadAvailableNodes).includes(newTriggerHandler.id);
@@ -300,6 +310,9 @@ export const typeAheadPlugin = ({
300
310
  eventType: EVENT_TYPE.UI
301
311
  });
302
312
  }
313
+ } else if (oldIsOpen && !newIsOpen && fg('platform_editor_ease_of_use_metrics')) {
314
+ var _api$metrics2;
315
+ api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$metrics2 = api.metrics) === null || _api$metrics2 === void 0 ? void 0 : _api$metrics2.commands.startActiveSessionTimer());
303
316
  }
304
317
  }
305
318
  };
@@ -33,6 +33,15 @@ export const WrapperTypeAhead = /*#__PURE__*/React.memo(({
33
33
  const queryRef = useRef(query);
34
34
  const editorViewRef = useRef(editorView);
35
35
  const items = useLoadItems(triggerHandler, editorView, query, showViewMore);
36
+ useEffect(() => {
37
+ if (!closed && fg('platform_editor_ease_of_use_metrics')) {
38
+ var _api$metrics;
39
+ api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$metrics = api.metrics) === null || _api$metrics === void 0 ? void 0 : _api$metrics.commands.handleIntentToStartEdit({
40
+ shouldStartTimer: false,
41
+ shouldPersistActiveSession: true
42
+ }));
43
+ }
44
+ }, [closed, api]);
36
45
  useLayoutEffect(() => {
37
46
  queryRef.current = query;
38
47
  }, [query]);
@@ -143,6 +143,10 @@ export var factoryDecorations = function factoryDecorations(_ref) {
143
143
  }
144
144
  nodeViewPortalProviderAPI.remove(spec.key);
145
145
  });
146
+ if (fg('platform_editor_ease_of_use_metrics')) {
147
+ var _api$metrics;
148
+ api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$metrics = api.metrics) === null || _api$metrics === void 0 ? void 0 : _api$metrics.commands.startActiveSessionTimer());
149
+ }
146
150
  return true;
147
151
  };
148
152
  return {
@@ -2,6 +2,7 @@ import { InsertTypeAheadStep } from '@atlaskit/adf-schema/steps';
2
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
3
  import { closest } from '@atlaskit/editor-common/utils';
4
4
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
5
6
  import { ACTIONS } from './actions';
6
7
  import { TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE } from './constants';
7
8
  import { factoryDecorations } from './decorations';
@@ -73,6 +74,12 @@ export function createPlugin(_ref) {
73
74
  if (insertItemCallback) {
74
75
  var tr = insertItemCallback(newState);
75
76
  if (tr) {
77
+ if (fg('platform_editor_ease_of_use_metrics')) {
78
+ var _api$metrics;
79
+ api === null || api === void 0 || (_api$metrics = api.metrics) === null || _api$metrics === void 0 || _api$metrics.commands.startActiveSessionTimer()({
80
+ tr: tr
81
+ });
82
+ }
76
83
  return tr;
77
84
  }
78
85
  }
@@ -12,6 +12,7 @@ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/edit
12
12
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
13
13
  import { SelectItemMode, TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
14
14
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
15
+ import { fg } from '@atlaskit/platform-feature-flags';
15
16
  import { closeTypeAhead } from './pm-plugins/commands/close-type-ahead';
16
17
  import { insertTypeAheadItem } from './pm-plugins/commands/insert-type-ahead-item';
17
18
  import { openTypeAheadAtCursor } from './pm-plugins/commands/open-typeahead-at-cursor';
@@ -275,8 +276,17 @@ export var typeAheadPlugin = function typeAheadPlugin(_ref) {
275
276
  });
276
277
  }
277
278
  if (newTriggerHandler !== null && newTriggerHandler !== void 0 && newTriggerHandler.onOpen && isANewHandler) {
279
+ if (fg('platform_editor_ease_of_use_metrics')) {
280
+ var _api$metrics;
281
+ api === null || api === void 0 || (_api$metrics = api.metrics) === null || _api$metrics === void 0 || _api$metrics.commands.handleIntentToStartEdit({
282
+ shouldStartTimer: false,
283
+ shouldPersistActiveSession: true
284
+ });
285
+ }
278
286
  newTriggerHandler.onOpen(newEditorState);
279
287
  }
288
+ var oldIsOpen = isTypeAheadOpen(oldEditorState);
289
+ var newIsOpen = isTypeAheadOpen(newEditorState);
280
290
  if (newTriggerHandler && isANewHandler) {
281
291
  // if the typeahead opens another typeahead via the quickInsert we do NOT want to fire this analytic event (mentions and emojis) as it is already being fired from editor-plugin-analytics
282
292
  var isDuplicateInvokedEvent = newPluginState.inputMethod === INPUT_METHOD.QUICK_INSERT && Object.values(TypeAheadAvailableNodes).includes(newTriggerHandler.id);
@@ -292,6 +302,9 @@ export var typeAheadPlugin = function typeAheadPlugin(_ref) {
292
302
  eventType: EVENT_TYPE.UI
293
303
  });
294
304
  }
305
+ } else if (oldIsOpen && !newIsOpen && fg('platform_editor_ease_of_use_metrics')) {
306
+ var _api$metrics2;
307
+ api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$metrics2 = api.metrics) === null || _api$metrics2 === void 0 ? void 0 : _api$metrics2.commands.startActiveSessionTimer());
295
308
  }
296
309
  }
297
310
  };
@@ -39,6 +39,15 @@ export var WrapperTypeAhead = /*#__PURE__*/React.memo(function (_ref) {
39
39
  var queryRef = useRef(query);
40
40
  var editorViewRef = useRef(editorView);
41
41
  var items = useLoadItems(triggerHandler, editorView, query, showViewMore);
42
+ useEffect(function () {
43
+ if (!closed && fg('platform_editor_ease_of_use_metrics')) {
44
+ var _api$metrics;
45
+ api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$metrics = api.metrics) === null || _api$metrics === void 0 ? void 0 : _api$metrics.commands.handleIntentToStartEdit({
46
+ shouldStartTimer: false,
47
+ shouldPersistActiveSession: true
48
+ }));
49
+ }
50
+ }, [closed, api]);
42
51
  useLayoutEffect(function () {
43
52
  queryRef.current = query;
44
53
  }, [query]);
@@ -4,6 +4,7 @@ import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
4
  import type { ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
5
5
  import type { ContextPanelPlugin } from '@atlaskit/editor-plugin-context-panel';
6
6
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
7
+ import type { MetricsPlugin } from '@atlaskit/editor-plugin-metrics';
7
8
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
8
9
  import { type TypeAheadPluginOptions, type TypeAheadPluginSharedState, type OpenTypeAheadProps } from './types';
9
10
  type InsertTypeAheadItemProps = {
@@ -27,7 +28,8 @@ export type TypeAheadPlugin = NextEditorPlugin<'typeAhead', {
27
28
  OptionalPlugin<AnalyticsPlugin>,
28
29
  OptionalPlugin<FeatureFlagsPlugin>,
29
30
  OptionalPlugin<ConnectivityPlugin>,
30
- OptionalPlugin<ContextPanelPlugin>
31
+ OptionalPlugin<ContextPanelPlugin>,
32
+ OptionalPlugin<MetricsPlugin>
31
33
  ];
32
34
  sharedState: TypeAheadPluginSharedState;
33
35
  actions: {
@@ -4,6 +4,7 @@ import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
4
  import type { ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
5
5
  import type { ContextPanelPlugin } from '@atlaskit/editor-plugin-context-panel';
6
6
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
7
+ import type { MetricsPlugin } from '@atlaskit/editor-plugin-metrics';
7
8
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
8
9
  import { type TypeAheadPluginOptions, type TypeAheadPluginSharedState, type OpenTypeAheadProps } from './types';
9
10
  type InsertTypeAheadItemProps = {
@@ -27,7 +28,8 @@ export type TypeAheadPlugin = NextEditorPlugin<'typeAhead', {
27
28
  OptionalPlugin<AnalyticsPlugin>,
28
29
  OptionalPlugin<FeatureFlagsPlugin>,
29
30
  OptionalPlugin<ConnectivityPlugin>,
30
- OptionalPlugin<ContextPanelPlugin>
31
+ OptionalPlugin<ContextPanelPlugin>,
32
+ OptionalPlugin<MetricsPlugin>
31
33
  ];
32
34
  sharedState: TypeAheadPluginSharedState;
33
35
  actions: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-type-ahead",
3
- "version": "2.4.2",
3
+ "version": "2.5.0",
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,12 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@atlaskit/adf-schema": "^47.6.0",
37
- "@atlaskit/editor-common": "^103.8.0",
37
+ "@atlaskit/editor-common": "^103.9.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
41
  "@atlaskit/editor-plugin-context-panel": "^4.0.0",
42
+ "@atlaskit/editor-plugin-metrics": "^3.4.0",
42
43
  "@atlaskit/editor-prosemirror": "7.0.0",
43
44
  "@atlaskit/editor-shared-styles": "^3.4.0",
44
45
  "@atlaskit/heading": "^5.2.0",
@@ -48,7 +49,7 @@
48
49
  "@atlaskit/primitives": "^14.4.0",
49
50
  "@atlaskit/prosemirror-input-rules": "^3.3.0",
50
51
  "@atlaskit/theme": "^18.0.0",
51
- "@atlaskit/tmp-editor-statsig": "^4.10.0",
52
+ "@atlaskit/tmp-editor-statsig": "^4.11.0",
52
53
  "@atlaskit/tokens": "^4.8.0",
53
54
  "@babel/runtime": "^7.0.0",
54
55
  "@emotion/react": "^11.7.1",
@@ -112,6 +113,9 @@
112
113
  },
113
114
  "platform_editor_controls_patch_4": {
114
115
  "type": "boolean"
116
+ },
117
+ "platform_editor_ease_of_use_metrics": {
118
+ "type": "boolean"
115
119
  }
116
120
  }
117
121
  }