@atlaskit/editor-plugin-annotation 2.9.2 → 2.9.4

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,25 @@
1
1
  # @atlaskit/editor-plugin-annotation
2
2
 
3
+ ## 2.9.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#144021](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/144021)
8
+ [`8357b7ad2daa6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8357b7ad2daa6) -
9
+ Added config option for starting viewInlineCommentTraceUFOPress for inline-comments
10
+ annotationPlugin
11
+ - Updated dependencies
12
+
13
+ ## 2.9.3
14
+
15
+ ### Patch Changes
16
+
17
+ - [#163361](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/163361)
18
+ [`76c3619bccda1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/76c3619bccda1) -
19
+ Changed the annotation manager feature gate to instead use the existance of the manager rather
20
+ then a gate
21
+ - Updated dependencies
22
+
3
23
  ## 2.9.2
4
24
 
5
25
  ### Patch Changes
@@ -61,6 +61,7 @@ var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref
61
61
  editorAnalyticsAPI: api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions,
62
62
  featureFlagsPluginState: featureFlags,
63
63
  selectCommentExperience: annotationProviders.selectCommentExperience,
64
+ viewInlineCommentTraceUFOPress: annotationProviders.viewInlineCommentTraceUFOPress,
64
65
  annotationManager: annotationProviders.annotationManager,
65
66
  api: api
66
67
  });
@@ -7,7 +7,6 @@ exports.startDraft = exports.setIsAnnotationSelected = exports.setIsAnnotationHo
7
7
  var _adfSchema = require("@atlaskit/adf-schema");
8
8
  var _utils = require("@atlaskit/editor-common/utils");
9
9
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
10
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
10
  var _editorCommands = require("../editor-commands");
12
11
  var _types = require("../types");
13
12
  var _utils3 = require("./utils");
@@ -58,7 +57,7 @@ var startDraft = exports.startDraft = function startDraft(editorView, options) {
58
57
  reason: ERROR_REASON_DRAFT_IN_PROGRESS
59
58
  };
60
59
  }
61
- if (!!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.length) && (0, _platformFeatureFlags.fg)('platform_editor_comments_api_manager_select')) {
60
+ if (!!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.length)) {
62
61
  // if there are selected annotations when starting a draft, we need to clear the selected annotations
63
62
  // before we start the draft.
64
63
  (0, _editorCommands.closeComponent)()(editorView.state, editorView.dispatch);
@@ -93,6 +93,7 @@ var fetchState = /*#__PURE__*/function () {
93
93
  var initialState = function initialState() {
94
94
  var disallowOnWhitespace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
95
95
  var featureFlagsPluginState = arguments.length > 1 ? arguments[1] : undefined;
96
+ var isAnnotationManagerEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
96
97
  return {
97
98
  annotations: {},
98
99
  selectedAnnotations: [],
@@ -107,7 +108,8 @@ var initialState = function initialState() {
107
108
  featureFlagsPluginState: featureFlagsPluginState,
108
109
  isDrafting: false,
109
110
  pendingSelectedAnnotations: [],
110
- pendingSelectedAnnotationsUpdateCount: 0
111
+ pendingSelectedAnnotationsUpdateCount: 0,
112
+ isAnnotationManagerEnabled: isAnnotationManagerEnabled
111
113
  };
112
114
  };
113
115
  var hideToolbar = function hideToolbar(state, dispatch) {
@@ -164,7 +166,7 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
164
166
  annotationManager = options.annotationManager;
165
167
  return new _safePlugin.SafePlugin({
166
168
  key: _utils2.inlineCommentPluginKey,
167
- state: (0, _pluginFactory.createPluginState)(options.dispatch, initialState(provider.disallowOnWhitespace, featureFlagsPluginState)),
169
+ state: (0, _pluginFactory.createPluginState)(options.dispatch, initialState(provider.disallowOnWhitespace, featureFlagsPluginState, !!annotationManager)),
168
170
  view: function view(editorView) {
169
171
  var allowAnnotationFn;
170
172
  var startDraftFn;
@@ -174,25 +176,23 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
174
176
  var setIsAnnotationSelectedFn;
175
177
  var setIsAnnotationHoveredFn;
176
178
  var clearAnnotationFn;
177
- if (annotationManager && (0, _platformFeatureFlags.fg)('platform_editor_comments_api_manager')) {
179
+ if (annotationManager) {
178
180
  allowAnnotationFn = (0, _annotationManagerHooks.allowAnnotation)(editorView, options);
179
181
  startDraftFn = (0, _annotationManagerHooks.startDraft)(editorView, options);
180
182
  clearDraftFn = (0, _annotationManagerHooks.clearDraft)(editorView, options);
181
183
  applyDraftFn = (0, _annotationManagerHooks.applyDraft)(editorView, options);
182
184
  getDraftFn = (0, _annotationManagerHooks.getDraft)(editorView, options);
185
+ setIsAnnotationSelectedFn = (0, _annotationManagerHooks.setIsAnnotationSelected)(editorView, options);
186
+ setIsAnnotationHoveredFn = (0, _annotationManagerHooks.setIsAnnotationHovered)(editorView, options);
187
+ clearAnnotationFn = (0, _annotationManagerHooks.clearAnnotation)(editorView, options);
183
188
  annotationManager.hook('allowAnnotation', allowAnnotationFn);
184
189
  annotationManager.hook('startDraft', startDraftFn);
185
190
  annotationManager.hook('clearDraft', clearDraftFn);
186
191
  annotationManager.hook('applyDraft', applyDraftFn);
187
192
  annotationManager.hook('getDraft', getDraftFn);
188
- if ((0, _platformFeatureFlags.fg)('platform_editor_comments_api_manager_select')) {
189
- setIsAnnotationSelectedFn = (0, _annotationManagerHooks.setIsAnnotationSelected)(editorView, options);
190
- setIsAnnotationHoveredFn = (0, _annotationManagerHooks.setIsAnnotationHovered)(editorView, options);
191
- clearAnnotationFn = (0, _annotationManagerHooks.clearAnnotation)(editorView, options);
192
- annotationManager.hook('setIsAnnotationSelected', setIsAnnotationSelectedFn);
193
- annotationManager.hook('setIsAnnotationHovered', setIsAnnotationHoveredFn);
194
- annotationManager.hook('clearAnnotation', clearAnnotationFn);
195
- }
193
+ annotationManager.hook('setIsAnnotationSelected', setIsAnnotationSelectedFn);
194
+ annotationManager.hook('setIsAnnotationHovered', setIsAnnotationHoveredFn);
195
+ annotationManager.hook('clearAnnotation', clearAnnotationFn);
196
196
  }
197
197
  // Get initial state
198
198
  // Need to pass `editorView` to mitigate editor state going stale
@@ -266,18 +266,25 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
266
266
  var _ref5 = (0, _utils2.getPluginState)(_prevState) || {},
267
267
  prevSelectedAnnotations = _ref5.selectedAnnotations;
268
268
  var selectedAnnotationId = selectedAnnotations && selectedAnnotations.length !== 0 && selectedAnnotations[0].id ? selectedAnnotations[0].id : undefined;
269
+
269
270
  // If the new state has an unresolved selected annotation, and it's different from
270
- // the previous one then we mark the select annotation experience as complete.
271
+ // the previous one then...
271
272
  if (
272
273
  //This checks the selected annotation is different from the previous one
273
274
  selectedAnnotationId && selectedAnnotationId !== (prevSelectedAnnotations === null || prevSelectedAnnotations === void 0 || (_prevSelectedAnnotati = prevSelectedAnnotations[0]) === null || _prevSelectedAnnotati === void 0 ? void 0 : _prevSelectedAnnotati.id) &&
274
275
  // This ensures that the selected annotation is unresolved
275
276
  annotations && annotations[selectedAnnotationId] === false) {
276
277
  var _options$selectCommen;
278
+ // ...we mark the select annotation experience as complete.
277
279
  // The selectComponentExperience is using a simplified object, which is why it's type asserted.
278
280
  (_options$selectCommen = options.selectCommentExperience) === null || _options$selectCommen === void 0 || _options$selectCommen.selectAnnotation.complete(selectedAnnotationId);
281
+ if ((0, _platformFeatureFlags.fg)('cc_comments_track_view_inline_comment_action')) {
282
+ var _options$viewInlineCo;
283
+ // ...and start a new UFO press trace since the selected comment is changing
284
+ (_options$viewInlineCo = options.viewInlineCommentTraceUFOPress) === null || _options$viewInlineCo === void 0 || _options$viewInlineCo.call(options);
285
+ }
279
286
  }
280
- if ((0, _platformFeatureFlags.fg)('platform_editor_comments_api_manager_select')) {
287
+ if (annotationManager) {
281
288
  // In the Editor, Annotations can be selected in three ways:
282
289
  // 1. By clicking on the annotation in the editor
283
290
  // 2. By using the annotation manager to select the annotation
@@ -295,7 +302,7 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
295
302
  // Need to set a lock to avoid calling gate multiple times. The lock will be released
296
303
  // when the preemptive gate is complete.
297
304
  isPreemptiveGateActive = true;
298
- annotationManager === null || annotationManager === void 0 || annotationManager.checkPreemptiveGate().then(function (canSelectAnnotation) {
305
+ annotationManager.checkPreemptiveGate().then(function (canSelectAnnotation) {
299
306
  var _ref8 = (0, _utils2.getPluginState)(view.state) || {},
300
307
  isDrafting = _ref8.isDrafting,
301
308
  latestPendingSelectedAnnotations = _ref8.pendingSelectedAnnotations,
@@ -314,8 +321,8 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
314
321
  return pendingAnnotation.id === annotation.id;
315
322
  })) === -1;
316
323
  }).forEach(function (annotation) {
317
- var _options$annotationMa, _getAnnotationInlineN;
318
- (_options$annotationMa = options.annotationManager) === null || _options$annotationMa === void 0 || _options$annotationMa.emit({
324
+ var _getAnnotationInlineN;
325
+ annotationManager.emit({
319
326
  name: 'annotationSelectionChanged',
320
327
  data: {
321
328
  annotationId: annotation.id,
@@ -327,9 +334,9 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
327
334
 
328
335
  // Notify the annotation manager that the pending selection has changed.
329
336
  latestPendingSelectedAnnotations === null || latestPendingSelectedAnnotations === void 0 || latestPendingSelectedAnnotations.forEach(function (_ref9) {
330
- var _options$annotationMa2, _getAnnotationInlineN2;
337
+ var _getAnnotationInlineN2;
331
338
  var id = _ref9.id;
332
- (_options$annotationMa2 = options.annotationManager) === null || _options$annotationMa2 === void 0 || _options$annotationMa2.emit({
339
+ annotationManager.emit({
333
340
  name: 'annotationSelectionChanged',
334
341
  data: {
335
342
  annotationId: id,
@@ -352,8 +359,8 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
352
359
  });
353
360
  }
354
361
  }
355
- var _ref10 = (0, _utils2.getPluginState)(view.state) || {},
356
- dirtyAnnotations = _ref10.dirtyAnnotations;
362
+ var _ref0 = (0, _utils2.getPluginState)(view.state) || {},
363
+ dirtyAnnotations = _ref0.dirtyAnnotations;
357
364
  if (!dirtyAnnotations) {
358
365
  return;
359
366
  }
@@ -366,7 +373,7 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
366
373
  if (updateSubscriber) {
367
374
  updateSubscriber.off('resolve', resolve).off('delete', resolve).off('unresolve', unResolve).off('create', unResolve).off('setvisibility', setVisibility).off('setselectedannotation', setSelectedAnnotationFn).off('sethoveredannotation', setHoveredAnnotationFn).off('removehoveredannotation', removeHoveredannotationFn).off('closeinlinecomment', closeInlineCommentFn);
368
375
  }
369
- if (annotationManager && (0, _platformFeatureFlags.fg)('platform_editor_comments_api_manager')) {
376
+ if (annotationManager) {
370
377
  annotationManager.unhook('allowAnnotation', allowAnnotationFn);
371
378
  annotationManager.unhook('startDraft', startDraftFn);
372
379
  annotationManager.unhook('clearDraft', clearDraftFn);
@@ -416,13 +423,13 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
416
423
  if (isSelected && !(pluginState !== null && pluginState !== void 0 && pluginState.isInlineCommentViewClosed)) {
417
424
  return false;
418
425
  }
419
- var _ref11 = pluginState || {},
420
- annotations = _ref11.annotations;
426
+ var _ref1 = pluginState || {},
427
+ annotations = _ref1.annotations;
421
428
  var isUnresolved = annotations && annotations[annotationId] === false;
422
429
  if (!isUnresolved) {
423
430
  return false;
424
431
  }
425
- if ((0, _platformFeatureFlags.fg)('platform_editor_comments_api_manager_select')) {
432
+ if (annotationManager) {
426
433
  var _pluginState$pendingS;
427
434
  // The manager disable setting the selected annotation on click because in the editor this is already
428
435
  // handled by the selection update handler. When the manager is enabled, and a selection changes it's pushed into
@@ -445,13 +452,13 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
445
452
  },
446
453
  decorations: function decorations(state) {
447
454
  // highlight comments, depending on state
448
- var _ref12 = (0, _utils2.getPluginState)(state) || {},
449
- draftDecorationSet = _ref12.draftDecorationSet,
450
- annotations = _ref12.annotations,
451
- selectedAnnotations = _ref12.selectedAnnotations,
452
- isVisible = _ref12.isVisible,
453
- isInlineCommentViewClosed = _ref12.isInlineCommentViewClosed,
454
- hoveredAnnotations = _ref12.hoveredAnnotations;
455
+ var _ref10 = (0, _utils2.getPluginState)(state) || {},
456
+ draftDecorationSet = _ref10.draftDecorationSet,
457
+ annotations = _ref10.annotations,
458
+ selectedAnnotations = _ref10.selectedAnnotations,
459
+ isVisible = _ref10.isVisible,
460
+ isInlineCommentViewClosed = _ref10.isInlineCommentViewClosed,
461
+ hoveredAnnotations = _ref10.hoveredAnnotations;
455
462
  var decorations = draftDecorationSet !== null && draftDecorationSet !== void 0 ? draftDecorationSet : _view.DecorationSet.empty;
456
463
  var focusDecorations = [];
457
464
 
@@ -9,7 +9,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
9
9
  var _utils = require("@atlaskit/editor-common/utils");
10
10
  var _state = require("@atlaskit/editor-prosemirror/state");
11
11
  var _view = require("@atlaskit/editor-prosemirror/view");
12
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
12
  var _reducer = _interopRequireDefault(require("./reducer"));
14
13
  var _utils2 = require("./utils");
15
14
  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; }
@@ -111,7 +110,6 @@ var getSelectionChangeHandlerNew = function getSelectionChangeHandlerNew(reopenC
111
110
 
112
111
  // NOTE: I've left this commented code here as a reference that the previous old code would reset the selected annotations
113
112
  // if the selection is empty. If this is no longer needed, we can remove this code.
114
- // clean up with platform_editor_comments_api_manager_select
115
113
  // if (selectedAnnotations.length === 0) {
116
114
  // return {
117
115
  // ...pluginState,
@@ -140,7 +138,11 @@ var getSelectionChangeHandlerNew = function getSelectionChangeHandlerNew(reopenC
140
138
  };
141
139
  var getSelectionChangedHandler = function getSelectionChangedHandler(reopenCommentView) {
142
140
  return function (tr, pluginState) {
143
- return (0, _platformFeatureFlags.fg)('platform_editor_comments_api_manager_select') ? getSelectionChangeHandlerNew(reopenCommentView)(tr, pluginState) : getSelectionChangeHandlerOld(reopenCommentView)(tr, pluginState);
141
+ return pluginState.isAnnotationManagerEnabled ?
142
+ // if platform_editor_comments_api_manager == true
143
+ getSelectionChangeHandlerNew(reopenCommentView)(tr, pluginState) :
144
+ // else if platform_editor_comments_api_manager == false
145
+ getSelectionChangeHandlerOld(reopenCommentView)(tr, pluginState);
144
146
  };
145
147
  };
146
148
  var _pluginFactory = (0, _utils.pluginFactory)(_utils2.inlineCommentPluginKey, _reducer.default, {
@@ -38,7 +38,7 @@ var _default = exports.default = function _default(pluginState, action) {
38
38
  isOpeningMediaCommentFromToolbar: false
39
39
  }, (0, _platformFeatureFlags.fg)('platform_editor_annotation_selected_annotation') && {
40
40
  selectedAnnotations: []
41
- }), (0, _platformFeatureFlags.fg)('platform_editor_comments_api_manager_select') && {
41
+ }), pluginState.isAnnotationManagerEnabled && {
42
42
  selectedAnnotations: []
43
43
  });
44
44
  case _types.ACTIONS.ADD_INLINE_COMMENT:
@@ -48,7 +48,7 @@ var _default = exports.default = function _default(pluginState, action) {
48
48
  annotations: _objectSpread(_objectSpread({}, pluginState.annotations), action.data.inlineComments),
49
49
  isInlineCommentViewClosed: false,
50
50
  selectAnnotationMethod: undefined
51
- }, (0, _platformFeatureFlags.fg)('platform_editor_comments_api_manager_select') && {
51
+ }, pluginState.isAnnotationManagerEnabled && {
52
52
  skipSelectionHandling: true
53
53
  });
54
54
  case _types.ACTIONS.INLINE_COMMENT_SET_VISIBLE:
@@ -133,7 +133,7 @@ var buildToolbar = exports.buildToolbar = function buildToolbar(editorAnalyticsA
133
133
  pageMode: 'edit'
134
134
  }
135
135
  });
136
- if (annotationManager && (0, _platformFeatureFlags.fg)('platform_editor_comments_api_manager')) {
136
+ if (annotationManager) {
137
137
  annotationManager.checkPreemptiveGate().then(function (canStartDraft) {
138
138
  if (canStartDraft) {
139
139
  createCommentExperience === null || createCommentExperience === void 0 || createCommentExperience.start({
@@ -26,9 +26,4 @@ var AnnotationTestIds = exports.AnnotationTestIds = {
26
26
  floatingToolbarCreateButton: "".concat(prefix, "-toolbar-create-button"),
27
27
  componentSave: "".concat(prefix, "-dummy-save-button"),
28
28
  componentClose: "".concat(prefix, "-dummy-close-button")
29
- };
30
-
31
- /**
32
- * Alternative to SelectInlineCommentCompoundExperience, used for the annotation plugin options
33
- * in the confluence editor presets. See createFullPageEditorPreset.ts or annotationPluginOptions.ts for usage.
34
- */
29
+ };
@@ -20,8 +20,7 @@ var _editorCommands = require("../editor-commands");
20
20
  var _utils3 = require("../pm-plugins/utils");
21
21
  var _types = require("../types");
22
22
  var _AnnotationViewWrapper = require("./AnnotationViewWrapper");
23
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
24
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
23
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
25
24
  var findPosForDOM = function findPosForDOM(sel) {
26
25
  var $from = sel.$from,
27
26
  from = sel.from;
@@ -52,6 +52,7 @@ export const annotationPlugin = ({
52
52
  editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions,
53
53
  featureFlagsPluginState: featureFlags,
54
54
  selectCommentExperience: annotationProviders.selectCommentExperience,
55
+ viewInlineCommentTraceUFOPress: annotationProviders.viewInlineCommentTraceUFOPress,
55
56
  annotationManager: annotationProviders.annotationManager,
56
57
  api
57
58
  });
@@ -1,7 +1,6 @@
1
1
  import { AnnotationTypes } from '@atlaskit/adf-schema';
2
2
  import { getAnnotationInlineNodeTypes, getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
3
3
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
4
- import { fg } from '@atlaskit/platform-feature-flags';
5
4
  import { setInlineCommentDraftState, createAnnotation, setSelectedAnnotation, closeComponent, setHoveredAnnotation, removeInlineCommentFromDoc } from '../editor-commands';
6
5
  import { AnnotationSelectionType } from '../types';
7
6
  import { inlineCommentPluginKey, isSelectionValid } from './utils';
@@ -51,7 +50,7 @@ export const startDraft = (editorView, options) => () => {
51
50
  reason: ERROR_REASON_DRAFT_IN_PROGRESS
52
51
  };
53
52
  }
54
- if (!!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.length) && fg('platform_editor_comments_api_manager_select')) {
53
+ if (!!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.length)) {
55
54
  // if there are selected annotations when starting a draft, we need to clear the selected annotations
56
55
  // before we start the draft.
57
56
  closeComponent()(editorView.state, editorView.dispatch);
@@ -37,7 +37,7 @@ const fetchState = async (provider, annotationIds, editorView, editorAnalyticsAP
37
37
  updateInlineCommentResolvedState(editorAnalyticsAPI)(inlineCommentStates)(editorView.state, editorView.dispatch);
38
38
  }
39
39
  };
40
- const initialState = (disallowOnWhitespace = false, featureFlagsPluginState) => {
40
+ const initialState = (disallowOnWhitespace = false, featureFlagsPluginState, isAnnotationManagerEnabled = false) => {
41
41
  return {
42
42
  annotations: {},
43
43
  selectedAnnotations: [],
@@ -52,7 +52,8 @@ const initialState = (disallowOnWhitespace = false, featureFlagsPluginState) =>
52
52
  featureFlagsPluginState,
53
53
  isDrafting: false,
54
54
  pendingSelectedAnnotations: [],
55
- pendingSelectedAnnotationsUpdateCount: 0
55
+ pendingSelectedAnnotationsUpdateCount: 0,
56
+ isAnnotationManagerEnabled
56
57
  };
57
58
  };
58
59
  const hideToolbar = (state, dispatch) => () => {
@@ -104,7 +105,7 @@ export const inlineCommentPlugin = options => {
104
105
  } = options;
105
106
  return new SafePlugin({
106
107
  key: inlineCommentPluginKey,
107
- state: createPluginState(options.dispatch, initialState(provider.disallowOnWhitespace, featureFlagsPluginState)),
108
+ state: createPluginState(options.dispatch, initialState(provider.disallowOnWhitespace, featureFlagsPluginState, !!annotationManager)),
108
109
  view(editorView) {
109
110
  let allowAnnotationFn;
110
111
  let startDraftFn;
@@ -114,25 +115,23 @@ export const inlineCommentPlugin = options => {
114
115
  let setIsAnnotationSelectedFn;
115
116
  let setIsAnnotationHoveredFn;
116
117
  let clearAnnotationFn;
117
- if (annotationManager && fg('platform_editor_comments_api_manager')) {
118
+ if (annotationManager) {
118
119
  allowAnnotationFn = allowAnnotation(editorView, options);
119
120
  startDraftFn = startDraft(editorView, options);
120
121
  clearDraftFn = clearDraft(editorView, options);
121
122
  applyDraftFn = applyDraft(editorView, options);
122
123
  getDraftFn = getDraft(editorView, options);
124
+ setIsAnnotationSelectedFn = setIsAnnotationSelected(editorView, options);
125
+ setIsAnnotationHoveredFn = setIsAnnotationHovered(editorView, options);
126
+ clearAnnotationFn = clearAnnotation(editorView, options);
123
127
  annotationManager.hook('allowAnnotation', allowAnnotationFn);
124
128
  annotationManager.hook('startDraft', startDraftFn);
125
129
  annotationManager.hook('clearDraft', clearDraftFn);
126
130
  annotationManager.hook('applyDraft', applyDraftFn);
127
131
  annotationManager.hook('getDraft', getDraftFn);
128
- if (fg('platform_editor_comments_api_manager_select')) {
129
- setIsAnnotationSelectedFn = setIsAnnotationSelected(editorView, options);
130
- setIsAnnotationHoveredFn = setIsAnnotationHovered(editorView, options);
131
- clearAnnotationFn = clearAnnotation(editorView, options);
132
- annotationManager.hook('setIsAnnotationSelected', setIsAnnotationSelectedFn);
133
- annotationManager.hook('setIsAnnotationHovered', setIsAnnotationHoveredFn);
134
- annotationManager.hook('clearAnnotation', clearAnnotationFn);
135
- }
132
+ annotationManager.hook('setIsAnnotationSelected', setIsAnnotationSelectedFn);
133
+ annotationManager.hook('setIsAnnotationHovered', setIsAnnotationHoveredFn);
134
+ annotationManager.hook('clearAnnotation', clearAnnotationFn);
136
135
  }
137
136
  // Get initial state
138
137
  // Need to pass `editorView` to mitigate editor state going stale
@@ -202,18 +201,25 @@ export const inlineCommentPlugin = options => {
202
201
  selectedAnnotations: prevSelectedAnnotations
203
202
  } = getPluginState(_prevState) || {};
204
203
  const selectedAnnotationId = selectedAnnotations && selectedAnnotations.length !== 0 && selectedAnnotations[0].id ? selectedAnnotations[0].id : undefined;
204
+
205
205
  // If the new state has an unresolved selected annotation, and it's different from
206
- // the previous one then we mark the select annotation experience as complete.
206
+ // the previous one then...
207
207
  if (
208
208
  //This checks the selected annotation is different from the previous one
209
209
  selectedAnnotationId && selectedAnnotationId !== (prevSelectedAnnotations === null || prevSelectedAnnotations === void 0 ? void 0 : (_prevSelectedAnnotati = prevSelectedAnnotations[0]) === null || _prevSelectedAnnotati === void 0 ? void 0 : _prevSelectedAnnotati.id) &&
210
210
  // This ensures that the selected annotation is unresolved
211
211
  annotations && annotations[selectedAnnotationId] === false) {
212
212
  var _options$selectCommen;
213
+ // ...we mark the select annotation experience as complete.
213
214
  // The selectComponentExperience is using a simplified object, which is why it's type asserted.
214
215
  (_options$selectCommen = options.selectCommentExperience) === null || _options$selectCommen === void 0 ? void 0 : _options$selectCommen.selectAnnotation.complete(selectedAnnotationId);
216
+ if (fg('cc_comments_track_view_inline_comment_action')) {
217
+ var _options$viewInlineCo;
218
+ // ...and start a new UFO press trace since the selected comment is changing
219
+ (_options$viewInlineCo = options.viewInlineCommentTraceUFOPress) === null || _options$viewInlineCo === void 0 ? void 0 : _options$viewInlineCo.call(options);
220
+ }
215
221
  }
216
- if (fg('platform_editor_comments_api_manager_select')) {
222
+ if (annotationManager) {
217
223
  // In the Editor, Annotations can be selected in three ways:
218
224
  // 1. By clicking on the annotation in the editor
219
225
  // 2. By using the annotation manager to select the annotation
@@ -233,7 +239,7 @@ export const inlineCommentPlugin = options => {
233
239
  // Need to set a lock to avoid calling gate multiple times. The lock will be released
234
240
  // when the preemptive gate is complete.
235
241
  isPreemptiveGateActive = true;
236
- annotationManager === null || annotationManager === void 0 ? void 0 : annotationManager.checkPreemptiveGate().then(canSelectAnnotation => {
242
+ annotationManager.checkPreemptiveGate().then(canSelectAnnotation => {
237
243
  const {
238
244
  isDrafting,
239
245
  pendingSelectedAnnotations: latestPendingSelectedAnnotations,
@@ -249,8 +255,8 @@ export const inlineCommentPlugin = options => {
249
255
  // Flush the pending selections into the selected annotations list.
250
256
  flushPendingSelections(options.editorAnalyticsAPI)(true)(view.state, view.dispatch);
251
257
  latestSelectedAnnotations === null || latestSelectedAnnotations === void 0 ? void 0 : latestSelectedAnnotations.filter(annotation => (latestPendingSelectedAnnotations === null || latestPendingSelectedAnnotations === void 0 ? void 0 : latestPendingSelectedAnnotations.findIndex(pendingAnnotation => pendingAnnotation.id === annotation.id)) === -1).forEach(annotation => {
252
- var _options$annotationMa, _getAnnotationInlineN;
253
- (_options$annotationMa = options.annotationManager) === null || _options$annotationMa === void 0 ? void 0 : _options$annotationMa.emit({
258
+ var _getAnnotationInlineN;
259
+ annotationManager.emit({
254
260
  name: 'annotationSelectionChanged',
255
261
  data: {
256
262
  annotationId: annotation.id,
@@ -264,8 +270,8 @@ export const inlineCommentPlugin = options => {
264
270
  latestPendingSelectedAnnotations === null || latestPendingSelectedAnnotations === void 0 ? void 0 : latestPendingSelectedAnnotations.forEach(({
265
271
  id
266
272
  }) => {
267
- var _options$annotationMa2, _getAnnotationInlineN2;
268
- (_options$annotationMa2 = options.annotationManager) === null || _options$annotationMa2 === void 0 ? void 0 : _options$annotationMa2.emit({
273
+ var _getAnnotationInlineN2;
274
+ annotationManager.emit({
269
275
  name: 'annotationSelectionChanged',
270
276
  data: {
271
277
  annotationId: id,
@@ -303,7 +309,7 @@ export const inlineCommentPlugin = options => {
303
309
  if (updateSubscriber) {
304
310
  updateSubscriber.off('resolve', resolve).off('delete', resolve).off('unresolve', unResolve).off('create', unResolve).off('setvisibility', setVisibility).off('setselectedannotation', setSelectedAnnotationFn).off('sethoveredannotation', setHoveredAnnotationFn).off('removehoveredannotation', removeHoveredannotationFn).off('closeinlinecomment', closeInlineCommentFn);
305
311
  }
306
- if (annotationManager && fg('platform_editor_comments_api_manager')) {
312
+ if (annotationManager) {
307
313
  annotationManager.unhook('allowAnnotation', allowAnnotationFn);
308
314
  annotationManager.unhook('startDraft', startDraftFn);
309
315
  annotationManager.unhook('clearDraft', clearDraftFn);
@@ -358,7 +364,7 @@ export const inlineCommentPlugin = options => {
358
364
  if (!isUnresolved) {
359
365
  return false;
360
366
  }
361
- if (fg('platform_editor_comments_api_manager_select')) {
367
+ if (annotationManager) {
362
368
  var _pluginState$pendingS;
363
369
  // The manager disable setting the selected annotation on click because in the editor this is already
364
370
  // handled by the selection update handler. When the manager is enabled, and a selection changes it's pushed into
@@ -1,7 +1,6 @@
1
1
  import { pluginFactory } from '@atlaskit/editor-common/utils';
2
2
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
3
3
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
- import { fg } from '@atlaskit/platform-feature-flags';
5
4
  import reducer from './reducer';
6
5
  import { decorationKey, findAnnotationsInSelection, inlineCommentPluginKey, isBlockNodeAnnotationsSelected, isSelectedAnnotationsChanged } from './utils';
7
6
  const handleDocChanged = (tr, prevPluginState) => {
@@ -111,7 +110,6 @@ const getSelectionChangeHandlerNew = reopenCommentView => (tr, pluginState) => {
111
110
 
112
111
  // NOTE: I've left this commented code here as a reference that the previous old code would reset the selected annotations
113
112
  // if the selection is empty. If this is no longer needed, we can remove this code.
114
- // clean up with platform_editor_comments_api_manager_select
115
113
  // if (selectedAnnotations.length === 0) {
116
114
  // return {
117
115
  // ...pluginState,
@@ -141,7 +139,11 @@ const getSelectionChangeHandlerNew = reopenCommentView => (tr, pluginState) => {
141
139
  selectAnnotationMethod: undefined
142
140
  };
143
141
  };
144
- const getSelectionChangedHandler = reopenCommentView => (tr, pluginState) => fg('platform_editor_comments_api_manager_select') ? getSelectionChangeHandlerNew(reopenCommentView)(tr, pluginState) : getSelectionChangeHandlerOld(reopenCommentView)(tr, pluginState);
142
+ const getSelectionChangedHandler = reopenCommentView => (tr, pluginState) => pluginState.isAnnotationManagerEnabled ?
143
+ // if platform_editor_comments_api_manager == true
144
+ getSelectionChangeHandlerNew(reopenCommentView)(tr, pluginState) :
145
+ // else if platform_editor_comments_api_manager == false
146
+ getSelectionChangeHandlerOld(reopenCommentView)(tr, pluginState);
145
147
  export const {
146
148
  createPluginState,
147
149
  createCommand
@@ -35,7 +35,7 @@ export default ((pluginState, action) => {
35
35
  ...(fg('platform_editor_annotation_selected_annotation') && {
36
36
  selectedAnnotations: []
37
37
  }),
38
- ...(fg('platform_editor_comments_api_manager_select') && {
38
+ ...(pluginState.isAnnotationManagerEnabled && {
39
39
  selectedAnnotations: []
40
40
  })
41
41
  };
@@ -50,7 +50,7 @@ export default ((pluginState, action) => {
50
50
  },
51
51
  isInlineCommentViewClosed: false,
52
52
  selectAnnotationMethod: undefined,
53
- ...(fg('platform_editor_comments_api_manager_select') && {
53
+ ...(pluginState.isAnnotationManagerEnabled && {
54
54
  skipSelectionHandling: true
55
55
  })
56
56
  };
@@ -131,7 +131,7 @@ export const buildToolbar = editorAnalyticsAPI => ({
131
131
  pageMode: 'edit'
132
132
  }
133
133
  });
134
- if (annotationManager && fg('platform_editor_comments_api_manager')) {
134
+ if (annotationManager) {
135
135
  annotationManager.checkPreemptiveGate().then(canStartDraft => {
136
136
  if (canStartDraft) {
137
137
  createCommentExperience === null || createCommentExperience === void 0 ? void 0 : createCommentExperience.start({
@@ -22,9 +22,4 @@ export const AnnotationTestIds = {
22
22
  floatingToolbarCreateButton: `${prefix}-toolbar-create-button`,
23
23
  componentSave: `${prefix}-dummy-save-button`,
24
24
  componentClose: `${prefix}-dummy-close-button`
25
- };
26
-
27
- /**
28
- * Alternative to SelectInlineCommentCompoundExperience, used for the annotation plugin options
29
- * in the confluence editor presets. See createFullPageEditorPreset.ts or annotationPluginOptions.ts for usage.
30
- */
25
+ };
@@ -54,6 +54,7 @@ export var annotationPlugin = function annotationPlugin(_ref) {
54
54
  editorAnalyticsAPI: api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions,
55
55
  featureFlagsPluginState: featureFlags,
56
56
  selectCommentExperience: annotationProviders.selectCommentExperience,
57
+ viewInlineCommentTraceUFOPress: annotationProviders.viewInlineCommentTraceUFOPress,
57
58
  annotationManager: annotationProviders.annotationManager,
58
59
  api: api
59
60
  });
@@ -1,7 +1,6 @@
1
1
  import { AnnotationTypes } from '@atlaskit/adf-schema';
2
2
  import { getAnnotationInlineNodeTypes, getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
3
3
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
4
- import { fg } from '@atlaskit/platform-feature-flags';
5
4
  import { setInlineCommentDraftState, createAnnotation, setSelectedAnnotation, closeComponent, setHoveredAnnotation, removeInlineCommentFromDoc } from '../editor-commands';
6
5
  import { AnnotationSelectionType } from '../types';
7
6
  import { inlineCommentPluginKey, isSelectionValid } from './utils';
@@ -52,7 +51,7 @@ export var startDraft = function startDraft(editorView, options) {
52
51
  reason: ERROR_REASON_DRAFT_IN_PROGRESS
53
52
  };
54
53
  }
55
- if (!!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.length) && fg('platform_editor_comments_api_manager_select')) {
54
+ if (!!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.length)) {
56
55
  // if there are selected annotations when starting a draft, we need to clear the selected annotations
57
56
  // before we start the draft.
58
57
  closeComponent()(editorView.state, editorView.dispatch);