@atlaskit/editor-plugin-annotation 6.0.0 → 6.1.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,19 @@
1
1
  # @atlaskit/editor-plugin-annotation
2
2
 
3
+ ## 6.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`daf58795e19b8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/daf58795e19b8) -
8
+ Add a new property (annotationsLoaded: boolean) to the Editor Plugin Annotation state. This
9
+ property is used to indicate whether inline comments have been fetched.
10
+
11
+ ## 6.0.1
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+
3
17
  ## 6.0.0
4
18
 
5
19
  ### Patch Changes
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.updateMouseState = exports.updateInlineCommentResolvedState = exports.showInlineCommentForBlockNode = exports.setSelectedAnnotation = exports.setPendingSelectedAnnotation = exports.setInlineCommentsVisibility = exports.setInlineCommentDraftState = exports.setHoveredAnnotation = exports.removeInlineCommentNearSelection = exports.removeInlineCommentFromDoc = exports.flushPendingSelections = exports.createAnnotation = exports.closeComponent = exports.clearDirtyMark = exports.addInlineComment = void 0;
7
+ exports.updateMouseState = exports.updateInlineCommentResolvedState = exports.showInlineCommentForBlockNode = exports.setSelectedAnnotation = exports.setPendingSelectedAnnotation = exports.setInlineCommentsVisibility = exports.setInlineCommentsFetched = exports.setInlineCommentDraftState = exports.setHoveredAnnotation = exports.removeInlineCommentNearSelection = exports.removeInlineCommentFromDoc = exports.flushPendingSelections = exports.createAnnotation = exports.closeComponent = exports.clearDirtyMark = exports.addInlineComment = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _adfSchema = require("@atlaskit/adf-schema");
10
10
  var _analytics = require("@atlaskit/editor-common/analytics");
@@ -54,6 +54,11 @@ var clearDirtyMark = exports.clearDirtyMark = function clearDirtyMark() {
54
54
  type: _types.ACTIONS.INLINE_COMMENT_CLEAR_DIRTY_MARK
55
55
  });
56
56
  };
57
+ var setInlineCommentsFetched = exports.setInlineCommentsFetched = function setInlineCommentsFetched() {
58
+ return (0, _pluginFactory.createCommand)({
59
+ type: _types.ACTIONS.SET_INLINE_COMMENTS_FETCHED
60
+ });
61
+ };
57
62
  var flushPendingSelections = exports.flushPendingSelections = function flushPendingSelections(editorAnalyticsAPI) {
58
63
  return function (canSetAsSelectedAnnotations, errorReason) {
59
64
  var command = {
@@ -61,7 +61,7 @@ var fetchProviderStates = /*#__PURE__*/function () {
61
61
  // Requires `editorView` instead of the decomposition as the async means state may end up stale
62
62
  var fetchState = /*#__PURE__*/function () {
63
63
  var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(provider, annotationIds, editorView, editorAnalyticsAPI) {
64
- var inlineCommentStates;
64
+ var inlineCommentStates, _ref3, annotationsLoaded;
65
65
  return _regenerator.default.wrap(function _callee2$(_context2) {
66
66
  while (1) switch (_context2.prev = _context2.next) {
67
67
  case 0:
@@ -70,15 +70,19 @@ var fetchState = /*#__PURE__*/function () {
70
70
  case 2:
71
71
  inlineCommentStates = _context2.sent;
72
72
  if (!(Object.keys(inlineCommentStates).length === 0)) {
73
- _context2.next = 5;
73
+ _context2.next = 7;
74
74
  break;
75
75
  }
76
+ _ref3 = (0, _utils3.getPluginState)(editorView.state) || {}, annotationsLoaded = _ref3.annotationsLoaded;
77
+ if (!annotationsLoaded && (0, _platformFeatureFlags.fg)('confluence_frontend_new_dangling_comments_ux')) {
78
+ (0, _editorCommands.setInlineCommentsFetched)()(editorView.state, editorView.dispatch);
79
+ }
76
80
  return _context2.abrupt("return");
77
- case 5:
81
+ case 7:
78
82
  if (editorView.dispatch) {
79
83
  (0, _editorCommands.updateInlineCommentResolvedState)(editorAnalyticsAPI)(inlineCommentStates)(editorView.state, editorView.dispatch);
80
84
  }
81
- case 6:
85
+ case 8:
82
86
  case "end":
83
87
  return _context2.stop();
84
88
  }
@@ -93,6 +97,7 @@ var initialState = function initialState() {
93
97
  var featureFlagsPluginState = arguments.length > 1 ? arguments[1] : undefined;
94
98
  var isAnnotationManagerEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
95
99
  return {
100
+ annotationsLoaded: false,
96
101
  annotations: {},
97
102
  selectedAnnotations: [],
98
103
  hoveredAnnotations: [],
@@ -135,8 +140,8 @@ var onUnResolve = function onUnResolve(editorAnalyticsAPI) {
135
140
  };
136
141
  var onMouseUp = function onMouseUp(state, dispatch) {
137
142
  return function (e) {
138
- var _ref3 = (0, _utils3.getPluginState)(state) || {},
139
- mouseData = _ref3.mouseData;
143
+ var _ref4 = (0, _utils3.getPluginState)(state) || {},
144
+ mouseData = _ref4.mouseData;
140
145
  if (mouseData !== null && mouseData !== void 0 && mouseData.isSelecting) {
141
146
  (0, _editorCommands.updateMouseState)({
142
147
  isSelecting: false
@@ -244,13 +249,13 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
244
249
  return {
245
250
  update: function update(view, _prevState) {
246
251
  var _prevSelectedAnnotati;
247
- var _ref4 = (0, _utils3.getPluginState)(view.state) || {},
248
- selectedAnnotations = _ref4.selectedAnnotations,
249
- annotations = _ref4.annotations,
250
- isDrafting = _ref4.isDrafting,
251
- bookmark = _ref4.bookmark;
252
- var _ref5 = (0, _utils3.getPluginState)(_prevState) || {},
253
- prevSelectedAnnotations = _ref5.selectedAnnotations;
252
+ var _ref5 = (0, _utils3.getPluginState)(view.state) || {},
253
+ selectedAnnotations = _ref5.selectedAnnotations,
254
+ annotations = _ref5.annotations,
255
+ isDrafting = _ref5.isDrafting,
256
+ bookmark = _ref5.bookmark;
257
+ var _ref6 = (0, _utils3.getPluginState)(_prevState) || {},
258
+ prevSelectedAnnotations = _ref6.selectedAnnotations;
254
259
  var selectedAnnotationId = selectedAnnotations && selectedAnnotations.length !== 0 && selectedAnnotations[0].id ? selectedAnnotations[0].id : undefined;
255
260
 
256
261
  // If the new state has an unresolved selected annotation, and it's different from
@@ -272,8 +277,8 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
272
277
  if (isDrafting && !view.state.selection.eq(_prevState.selection) && (0, _experiments.editorExperiment)('platform_editor_toolbar_aifc', true) && (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_patch_2', 'isEnabled', true)) {
273
278
  // It is possible that user update selection while having a active draft,
274
279
  // so we need to reset the user intent to allow inline text toolbar to be visible
275
- api === null || api === void 0 || api.core.actions.execute(function (_ref6) {
276
- var tr = _ref6.tr;
280
+ api === null || api === void 0 || api.core.actions.execute(function (_ref7) {
281
+ var tr = _ref7.tr;
277
282
  if ((0, _toolbar.shouldSuppressFloatingToolbar)({
278
283
  state: view.state,
279
284
  bookmark: bookmark
@@ -294,20 +299,20 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
294
299
  // at a time when changing the selection could cause data loss.
295
300
  // The following preemptive check is designed to cover these items.
296
301
 
297
- var _ref7 = (0, _utils3.getPluginState)(view.state) || {},
298
- pendingSelectedAnnotations = _ref7.pendingSelectedAnnotations,
299
- pendingSelectedAnnotationsUpdateCount = _ref7.pendingSelectedAnnotationsUpdateCount;
300
- var _ref8 = (0, _utils3.getPluginState)(_prevState) || {},
301
- prevPendingSelectedAnnotationsUpdateCount = _ref8.pendingSelectedAnnotationsUpdateCount;
302
+ var _ref8 = (0, _utils3.getPluginState)(view.state) || {},
303
+ pendingSelectedAnnotations = _ref8.pendingSelectedAnnotations,
304
+ pendingSelectedAnnotationsUpdateCount = _ref8.pendingSelectedAnnotationsUpdateCount;
305
+ var _ref9 = (0, _utils3.getPluginState)(_prevState) || {},
306
+ prevPendingSelectedAnnotationsUpdateCount = _ref9.pendingSelectedAnnotationsUpdateCount;
302
307
  if (!isPreemptiveGateActive && pendingSelectedAnnotationsUpdateCount !== prevPendingSelectedAnnotationsUpdateCount && !!(pendingSelectedAnnotations !== null && pendingSelectedAnnotations !== void 0 && pendingSelectedAnnotations.length)) {
303
308
  // Need to set a lock to avoid calling gate multiple times. The lock will be released
304
309
  // when the preemptive gate is complete.
305
310
  isPreemptiveGateActive = true;
306
311
  annotationManager.checkPreemptiveGate().then(function (canSelectAnnotation) {
307
- var _ref9 = (0, _utils3.getPluginState)(view.state) || {},
308
- isDrafting = _ref9.isDrafting,
309
- latestPendingSelectedAnnotations = _ref9.pendingSelectedAnnotations,
310
- latestSelectedAnnotations = _ref9.selectedAnnotations;
312
+ var _ref0 = (0, _utils3.getPluginState)(view.state) || {},
313
+ isDrafting = _ref0.isDrafting,
314
+ latestPendingSelectedAnnotations = _ref0.pendingSelectedAnnotations,
315
+ latestSelectedAnnotations = _ref0.selectedAnnotations;
311
316
  if (canSelectAnnotation) {
312
317
  if (isDrafting) {
313
318
  // The user must have chosen to discard there draft. So before we flush the pending selections
@@ -334,9 +339,9 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
334
339
  });
335
340
 
336
341
  // Notify the annotation manager that the pending selection has changed.
337
- latestPendingSelectedAnnotations === null || latestPendingSelectedAnnotations === void 0 || latestPendingSelectedAnnotations.forEach(function (_ref0) {
342
+ latestPendingSelectedAnnotations === null || latestPendingSelectedAnnotations === void 0 || latestPendingSelectedAnnotations.forEach(function (_ref1) {
338
343
  var _getAnnotationInlineN2;
339
- var id = _ref0.id;
344
+ var id = _ref1.id;
340
345
  annotationManager.emit({
341
346
  name: 'annotationSelectionChanged',
342
347
  data: {
@@ -360,8 +365,8 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
360
365
  });
361
366
  }
362
367
  }
363
- var _ref1 = (0, _utils3.getPluginState)(view.state) || {},
364
- dirtyAnnotations = _ref1.dirtyAnnotations;
368
+ var _ref10 = (0, _utils3.getPluginState)(view.state) || {},
369
+ dirtyAnnotations = _ref10.dirtyAnnotations;
365
370
  if (!dirtyAnnotations) {
366
371
  return;
367
372
  }
@@ -424,8 +429,8 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
424
429
  if (isSelected && !(pluginState !== null && pluginState !== void 0 && pluginState.isInlineCommentViewClosed)) {
425
430
  return false;
426
431
  }
427
- var _ref10 = pluginState || {},
428
- annotations = _ref10.annotations;
432
+ var _ref11 = pluginState || {},
433
+ annotations = _ref11.annotations;
429
434
  var isUnresolved = annotations && annotations[annotationId] === false;
430
435
  if (!isUnresolved) {
431
436
  return false;
@@ -453,13 +458,13 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
453
458
  },
454
459
  decorations: function decorations(state) {
455
460
  // highlight comments, depending on state
456
- var _ref11 = (0, _utils3.getPluginState)(state) || {},
457
- draftDecorationSet = _ref11.draftDecorationSet,
458
- annotations = _ref11.annotations,
459
- selectedAnnotations = _ref11.selectedAnnotations,
460
- isVisible = _ref11.isVisible,
461
- isInlineCommentViewClosed = _ref11.isInlineCommentViewClosed,
462
- hoveredAnnotations = _ref11.hoveredAnnotations;
461
+ var _ref12 = (0, _utils3.getPluginState)(state) || {},
462
+ draftDecorationSet = _ref12.draftDecorationSet,
463
+ annotations = _ref12.annotations,
464
+ selectedAnnotations = _ref12.selectedAnnotations,
465
+ isVisible = _ref12.isVisible,
466
+ isInlineCommentViewClosed = _ref12.isInlineCommentViewClosed,
467
+ hoveredAnnotations = _ref12.hoveredAnnotations;
463
468
  var decorations = draftDecorationSet !== null && draftDecorationSet !== void 0 ? draftDecorationSet : _view.DecorationSet.empty;
464
469
  var focusDecorations = [];
465
470
 
@@ -15,8 +15,13 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
15
15
  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; }
16
16
  var _default = exports.default = function _default(pluginState, action) {
17
17
  switch (action.type) {
18
+ case _types.ACTIONS.SET_INLINE_COMMENTS_FETCHED:
19
+ return _objectSpread(_objectSpread({}, pluginState), {}, {
20
+ annotationsLoaded: true
21
+ });
18
22
  case _types.ACTIONS.UPDATE_INLINE_COMMENT_STATE:
19
23
  return _objectSpread(_objectSpread({}, pluginState), {}, {
24
+ annotationsLoaded: true,
20
25
  annotations: _objectSpread(_objectSpread({}, pluginState.annotations), action.data)
21
26
  });
22
27
  case _types.ACTIONS.INLINE_COMMENT_UPDATE_MOUSE_STATE:
@@ -16,5 +16,6 @@ var ACTIONS = exports.ACTIONS = /*#__PURE__*/function (ACTIONS) {
16
16
  ACTIONS[ACTIONS["SET_HOVERED_ANNOTATION"] = 8] = "SET_HOVERED_ANNOTATION";
17
17
  ACTIONS[ACTIONS["FLUSH_PENDING_SELECTIONS"] = 9] = "FLUSH_PENDING_SELECTIONS";
18
18
  ACTIONS[ACTIONS["SET_PENDING_SELECTIONS"] = 10] = "SET_PENDING_SELECTIONS";
19
+ ACTIONS[ACTIONS["SET_INLINE_COMMENTS_FETCHED"] = 11] = "SET_INLINE_COMMENTS_FETCHED";
19
20
  return ACTIONS;
20
21
  }({});
@@ -34,6 +34,9 @@ export const closeComponent = () => createCommand({
34
34
  export const clearDirtyMark = () => createCommand({
35
35
  type: ACTIONS.INLINE_COMMENT_CLEAR_DIRTY_MARK
36
36
  });
37
+ export const setInlineCommentsFetched = () => createCommand({
38
+ type: ACTIONS.SET_INLINE_COMMENTS_FETCHED
39
+ });
37
40
  export const flushPendingSelections = editorAnalyticsAPI => (canSetAsSelectedAnnotations, errorReason) => {
38
41
  const command = {
39
42
  type: ACTIONS.FLUSH_PENDING_SELECTIONS,
@@ -6,7 +6,7 @@ import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
6
6
  import { fg } from '@atlaskit/platform-feature-flags';
7
7
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
8
8
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
9
- import { clearDirtyMark, closeComponent, setHoveredAnnotation, setInlineCommentsVisibility, setSelectedAnnotation, flushPendingSelections, updateInlineCommentResolvedState, updateMouseState, setPendingSelectedAnnotation, setInlineCommentDraftState } from '../editor-commands';
9
+ import { clearDirtyMark, closeComponent, setHoveredAnnotation, setInlineCommentsVisibility, setSelectedAnnotation, flushPendingSelections, updateInlineCommentResolvedState, updateMouseState, setPendingSelectedAnnotation, setInlineCommentDraftState, setInlineCommentsFetched } from '../editor-commands';
10
10
  import { resetUserIntent, setUserIntent } from '../editor-commands/utils';
11
11
  import { getAnnotationViewClassname, getBlockAnnotationViewClassname } from '../nodeviews';
12
12
  import { allowAnnotation, applyDraft, clearDraft, clearAnnotation, getDraft, setIsAnnotationHovered, setIsAnnotationSelected, startDraft } from './annotation-manager-hooks';
@@ -32,6 +32,12 @@ const fetchProviderStates = async (provider, annotationIds) => {
32
32
  const fetchState = async (provider, annotationIds, editorView, editorAnalyticsAPI) => {
33
33
  const inlineCommentStates = await fetchProviderStates(provider, annotationIds);
34
34
  if (Object.keys(inlineCommentStates).length === 0) {
35
+ const {
36
+ annotationsLoaded
37
+ } = getPluginState(editorView.state) || {};
38
+ if (!annotationsLoaded && fg('confluence_frontend_new_dangling_comments_ux')) {
39
+ setInlineCommentsFetched()(editorView.state, editorView.dispatch);
40
+ }
35
41
  return;
36
42
  }
37
43
  if (editorView.dispatch) {
@@ -40,6 +46,7 @@ const fetchState = async (provider, annotationIds, editorView, editorAnalyticsAP
40
46
  };
41
47
  const initialState = (disallowOnWhitespace = false, featureFlagsPluginState, isAnnotationManagerEnabled = false) => {
42
48
  return {
49
+ annotationsLoaded: false,
43
50
  annotations: {},
44
51
  selectedAnnotations: [],
45
52
  hoveredAnnotations: [],
@@ -4,9 +4,15 @@ import { ACTIONS } from './types';
4
4
  import { addDraftDecoration, resolveDraftBookmark } from './utils';
5
5
  export default ((pluginState, action) => {
6
6
  switch (action.type) {
7
+ case ACTIONS.SET_INLINE_COMMENTS_FETCHED:
8
+ return {
9
+ ...pluginState,
10
+ annotationsLoaded: true
11
+ };
7
12
  case ACTIONS.UPDATE_INLINE_COMMENT_STATE:
8
13
  return {
9
14
  ...pluginState,
15
+ annotationsLoaded: true,
10
16
  annotations: {
11
17
  ...pluginState.annotations,
12
18
  ...action.data
@@ -10,5 +10,6 @@ export let ACTIONS = /*#__PURE__*/function (ACTIONS) {
10
10
  ACTIONS[ACTIONS["SET_HOVERED_ANNOTATION"] = 8] = "SET_HOVERED_ANNOTATION";
11
11
  ACTIONS[ACTIONS["FLUSH_PENDING_SELECTIONS"] = 9] = "FLUSH_PENDING_SELECTIONS";
12
12
  ACTIONS[ACTIONS["SET_PENDING_SELECTIONS"] = 10] = "SET_PENDING_SELECTIONS";
13
+ ACTIONS[ACTIONS["SET_INLINE_COMMENTS_FETCHED"] = 11] = "SET_INLINE_COMMENTS_FETCHED";
13
14
  return ACTIONS;
14
15
  }({});
@@ -47,6 +47,11 @@ export var clearDirtyMark = function clearDirtyMark() {
47
47
  type: ACTIONS.INLINE_COMMENT_CLEAR_DIRTY_MARK
48
48
  });
49
49
  };
50
+ export var setInlineCommentsFetched = function setInlineCommentsFetched() {
51
+ return createCommand({
52
+ type: ACTIONS.SET_INLINE_COMMENTS_FETCHED
53
+ });
54
+ };
50
55
  export var flushPendingSelections = function flushPendingSelections(editorAnalyticsAPI) {
51
56
  return function (canSetAsSelectedAnnotations, errorReason) {
52
57
  var command = {
@@ -9,7 +9,7 @@ import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
9
9
  import { fg } from '@atlaskit/platform-feature-flags';
10
10
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
11
11
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
12
- import { clearDirtyMark, closeComponent, setHoveredAnnotation, setInlineCommentsVisibility, setSelectedAnnotation, flushPendingSelections, updateInlineCommentResolvedState, updateMouseState, setPendingSelectedAnnotation, setInlineCommentDraftState } from '../editor-commands';
12
+ import { clearDirtyMark, closeComponent, setHoveredAnnotation, setInlineCommentsVisibility, setSelectedAnnotation, flushPendingSelections, updateInlineCommentResolvedState, updateMouseState, setPendingSelectedAnnotation, setInlineCommentDraftState, setInlineCommentsFetched } from '../editor-commands';
13
13
  import { resetUserIntent, setUserIntent } from '../editor-commands/utils';
14
14
  import { getAnnotationViewClassname, getBlockAnnotationViewClassname } from '../nodeviews';
15
15
  import { allowAnnotation, applyDraft, clearDraft, clearAnnotation, getDraft, setIsAnnotationHovered, setIsAnnotationSelected, startDraft } from './annotation-manager-hooks';
@@ -54,7 +54,7 @@ var fetchProviderStates = /*#__PURE__*/function () {
54
54
  // Requires `editorView` instead of the decomposition as the async means state may end up stale
55
55
  var fetchState = /*#__PURE__*/function () {
56
56
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(provider, annotationIds, editorView, editorAnalyticsAPI) {
57
- var inlineCommentStates;
57
+ var inlineCommentStates, _ref3, annotationsLoaded;
58
58
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
59
59
  while (1) switch (_context2.prev = _context2.next) {
60
60
  case 0:
@@ -63,15 +63,19 @@ var fetchState = /*#__PURE__*/function () {
63
63
  case 2:
64
64
  inlineCommentStates = _context2.sent;
65
65
  if (!(Object.keys(inlineCommentStates).length === 0)) {
66
- _context2.next = 5;
66
+ _context2.next = 7;
67
67
  break;
68
68
  }
69
+ _ref3 = getPluginState(editorView.state) || {}, annotationsLoaded = _ref3.annotationsLoaded;
70
+ if (!annotationsLoaded && fg('confluence_frontend_new_dangling_comments_ux')) {
71
+ setInlineCommentsFetched()(editorView.state, editorView.dispatch);
72
+ }
69
73
  return _context2.abrupt("return");
70
- case 5:
74
+ case 7:
71
75
  if (editorView.dispatch) {
72
76
  updateInlineCommentResolvedState(editorAnalyticsAPI)(inlineCommentStates)(editorView.state, editorView.dispatch);
73
77
  }
74
- case 6:
78
+ case 8:
75
79
  case "end":
76
80
  return _context2.stop();
77
81
  }
@@ -86,6 +90,7 @@ var initialState = function initialState() {
86
90
  var featureFlagsPluginState = arguments.length > 1 ? arguments[1] : undefined;
87
91
  var isAnnotationManagerEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
88
92
  return {
93
+ annotationsLoaded: false,
89
94
  annotations: {},
90
95
  selectedAnnotations: [],
91
96
  hoveredAnnotations: [],
@@ -128,8 +133,8 @@ var onUnResolve = function onUnResolve(editorAnalyticsAPI) {
128
133
  };
129
134
  var onMouseUp = function onMouseUp(state, dispatch) {
130
135
  return function (e) {
131
- var _ref3 = getPluginState(state) || {},
132
- mouseData = _ref3.mouseData;
136
+ var _ref4 = getPluginState(state) || {},
137
+ mouseData = _ref4.mouseData;
133
138
  if (mouseData !== null && mouseData !== void 0 && mouseData.isSelecting) {
134
139
  updateMouseState({
135
140
  isSelecting: false
@@ -237,13 +242,13 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
237
242
  return {
238
243
  update: function update(view, _prevState) {
239
244
  var _prevSelectedAnnotati;
240
- var _ref4 = getPluginState(view.state) || {},
241
- selectedAnnotations = _ref4.selectedAnnotations,
242
- annotations = _ref4.annotations,
243
- isDrafting = _ref4.isDrafting,
244
- bookmark = _ref4.bookmark;
245
- var _ref5 = getPluginState(_prevState) || {},
246
- prevSelectedAnnotations = _ref5.selectedAnnotations;
245
+ var _ref5 = getPluginState(view.state) || {},
246
+ selectedAnnotations = _ref5.selectedAnnotations,
247
+ annotations = _ref5.annotations,
248
+ isDrafting = _ref5.isDrafting,
249
+ bookmark = _ref5.bookmark;
250
+ var _ref6 = getPluginState(_prevState) || {},
251
+ prevSelectedAnnotations = _ref6.selectedAnnotations;
247
252
  var selectedAnnotationId = selectedAnnotations && selectedAnnotations.length !== 0 && selectedAnnotations[0].id ? selectedAnnotations[0].id : undefined;
248
253
 
249
254
  // If the new state has an unresolved selected annotation, and it's different from
@@ -265,8 +270,8 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
265
270
  if (isDrafting && !view.state.selection.eq(_prevState.selection) && editorExperiment('platform_editor_toolbar_aifc', true) && expValEquals('platform_editor_toolbar_aifc_patch_2', 'isEnabled', true)) {
266
271
  // It is possible that user update selection while having a active draft,
267
272
  // so we need to reset the user intent to allow inline text toolbar to be visible
268
- api === null || api === void 0 || api.core.actions.execute(function (_ref6) {
269
- var tr = _ref6.tr;
273
+ api === null || api === void 0 || api.core.actions.execute(function (_ref7) {
274
+ var tr = _ref7.tr;
270
275
  if (shouldSuppressFloatingToolbar({
271
276
  state: view.state,
272
277
  bookmark: bookmark
@@ -287,20 +292,20 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
287
292
  // at a time when changing the selection could cause data loss.
288
293
  // The following preemptive check is designed to cover these items.
289
294
 
290
- var _ref7 = getPluginState(view.state) || {},
291
- pendingSelectedAnnotations = _ref7.pendingSelectedAnnotations,
292
- pendingSelectedAnnotationsUpdateCount = _ref7.pendingSelectedAnnotationsUpdateCount;
293
- var _ref8 = getPluginState(_prevState) || {},
294
- prevPendingSelectedAnnotationsUpdateCount = _ref8.pendingSelectedAnnotationsUpdateCount;
295
+ var _ref8 = getPluginState(view.state) || {},
296
+ pendingSelectedAnnotations = _ref8.pendingSelectedAnnotations,
297
+ pendingSelectedAnnotationsUpdateCount = _ref8.pendingSelectedAnnotationsUpdateCount;
298
+ var _ref9 = getPluginState(_prevState) || {},
299
+ prevPendingSelectedAnnotationsUpdateCount = _ref9.pendingSelectedAnnotationsUpdateCount;
295
300
  if (!isPreemptiveGateActive && pendingSelectedAnnotationsUpdateCount !== prevPendingSelectedAnnotationsUpdateCount && !!(pendingSelectedAnnotations !== null && pendingSelectedAnnotations !== void 0 && pendingSelectedAnnotations.length)) {
296
301
  // Need to set a lock to avoid calling gate multiple times. The lock will be released
297
302
  // when the preemptive gate is complete.
298
303
  isPreemptiveGateActive = true;
299
304
  annotationManager.checkPreemptiveGate().then(function (canSelectAnnotation) {
300
- var _ref9 = getPluginState(view.state) || {},
301
- isDrafting = _ref9.isDrafting,
302
- latestPendingSelectedAnnotations = _ref9.pendingSelectedAnnotations,
303
- latestSelectedAnnotations = _ref9.selectedAnnotations;
305
+ var _ref0 = getPluginState(view.state) || {},
306
+ isDrafting = _ref0.isDrafting,
307
+ latestPendingSelectedAnnotations = _ref0.pendingSelectedAnnotations,
308
+ latestSelectedAnnotations = _ref0.selectedAnnotations;
304
309
  if (canSelectAnnotation) {
305
310
  if (isDrafting) {
306
311
  // The user must have chosen to discard there draft. So before we flush the pending selections
@@ -327,9 +332,9 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
327
332
  });
328
333
 
329
334
  // Notify the annotation manager that the pending selection has changed.
330
- latestPendingSelectedAnnotations === null || latestPendingSelectedAnnotations === void 0 || latestPendingSelectedAnnotations.forEach(function (_ref0) {
335
+ latestPendingSelectedAnnotations === null || latestPendingSelectedAnnotations === void 0 || latestPendingSelectedAnnotations.forEach(function (_ref1) {
331
336
  var _getAnnotationInlineN2;
332
- var id = _ref0.id;
337
+ var id = _ref1.id;
333
338
  annotationManager.emit({
334
339
  name: 'annotationSelectionChanged',
335
340
  data: {
@@ -353,8 +358,8 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
353
358
  });
354
359
  }
355
360
  }
356
- var _ref1 = getPluginState(view.state) || {},
357
- dirtyAnnotations = _ref1.dirtyAnnotations;
361
+ var _ref10 = getPluginState(view.state) || {},
362
+ dirtyAnnotations = _ref10.dirtyAnnotations;
358
363
  if (!dirtyAnnotations) {
359
364
  return;
360
365
  }
@@ -417,8 +422,8 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
417
422
  if (isSelected && !(pluginState !== null && pluginState !== void 0 && pluginState.isInlineCommentViewClosed)) {
418
423
  return false;
419
424
  }
420
- var _ref10 = pluginState || {},
421
- annotations = _ref10.annotations;
425
+ var _ref11 = pluginState || {},
426
+ annotations = _ref11.annotations;
422
427
  var isUnresolved = annotations && annotations[annotationId] === false;
423
428
  if (!isUnresolved) {
424
429
  return false;
@@ -446,13 +451,13 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
446
451
  },
447
452
  decorations: function decorations(state) {
448
453
  // highlight comments, depending on state
449
- var _ref11 = getPluginState(state) || {},
450
- draftDecorationSet = _ref11.draftDecorationSet,
451
- annotations = _ref11.annotations,
452
- selectedAnnotations = _ref11.selectedAnnotations,
453
- isVisible = _ref11.isVisible,
454
- isInlineCommentViewClosed = _ref11.isInlineCommentViewClosed,
455
- hoveredAnnotations = _ref11.hoveredAnnotations;
454
+ var _ref12 = getPluginState(state) || {},
455
+ draftDecorationSet = _ref12.draftDecorationSet,
456
+ annotations = _ref12.annotations,
457
+ selectedAnnotations = _ref12.selectedAnnotations,
458
+ isVisible = _ref12.isVisible,
459
+ isInlineCommentViewClosed = _ref12.isInlineCommentViewClosed,
460
+ hoveredAnnotations = _ref12.hoveredAnnotations;
456
461
  var decorations = draftDecorationSet !== null && draftDecorationSet !== void 0 ? draftDecorationSet : DecorationSet.empty;
457
462
  var focusDecorations = [];
458
463
 
@@ -8,8 +8,13 @@ import { ACTIONS } from './types';
8
8
  import { addDraftDecoration, resolveDraftBookmark } from './utils';
9
9
  export default (function (pluginState, action) {
10
10
  switch (action.type) {
11
+ case ACTIONS.SET_INLINE_COMMENTS_FETCHED:
12
+ return _objectSpread(_objectSpread({}, pluginState), {}, {
13
+ annotationsLoaded: true
14
+ });
11
15
  case ACTIONS.UPDATE_INLINE_COMMENT_STATE:
12
16
  return _objectSpread(_objectSpread({}, pluginState), {}, {
17
+ annotationsLoaded: true,
13
18
  annotations: _objectSpread(_objectSpread({}, pluginState.annotations), action.data)
14
19
  });
15
20
  case ACTIONS.INLINE_COMMENT_UPDATE_MOUSE_STATE:
@@ -10,5 +10,6 @@ export var ACTIONS = /*#__PURE__*/function (ACTIONS) {
10
10
  ACTIONS[ACTIONS["SET_HOVERED_ANNOTATION"] = 8] = "SET_HOVERED_ANNOTATION";
11
11
  ACTIONS[ACTIONS["FLUSH_PENDING_SELECTIONS"] = 9] = "FLUSH_PENDING_SELECTIONS";
12
12
  ACTIONS[ACTIONS["SET_PENDING_SELECTIONS"] = 10] = "SET_PENDING_SELECTIONS";
13
+ ACTIONS[ACTIONS["SET_INLINE_COMMENTS_FETCHED"] = 11] = "SET_INLINE_COMMENTS_FETCHED";
13
14
  return ACTIONS;
14
15
  }({});
@@ -9,6 +9,7 @@ import type { InlineCommentInputMethod, TargetType } from '../types';
9
9
  export declare const updateInlineCommentResolvedState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (partialNewState: InlineCommentMap, resolveMethod?: RESOLVE_METHOD) => Command;
10
10
  export declare const closeComponent: () => Command;
11
11
  export declare const clearDirtyMark: () => Command;
12
+ export declare const setInlineCommentsFetched: () => Command;
12
13
  export declare const flushPendingSelections: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (canSetAsSelectedAnnotations: boolean, errorReason?: string) => Command;
13
14
  export declare const setPendingSelectedAnnotation: (id: string) => Command;
14
15
  export declare const removeInlineCommentNearSelection: (id: string, supportedNodes?: string[]) => Command;
@@ -17,7 +17,8 @@ export declare enum ACTIONS {
17
17
  SET_SELECTED_ANNOTATION = 7,
18
18
  SET_HOVERED_ANNOTATION = 8,
19
19
  FLUSH_PENDING_SELECTIONS = 9,
20
- SET_PENDING_SELECTIONS = 10
20
+ SET_PENDING_SELECTIONS = 10,
21
+ SET_INLINE_COMMENTS_FETCHED = 11
21
22
  }
22
23
  export interface InlineCommentPluginOptions {
23
24
  annotationManager?: AnnotationManager;
@@ -93,8 +94,11 @@ export type InlineCommentAction = {
93
94
  selectedAnnotations: AnnotationInfo[];
94
95
  };
95
96
  type: ACTIONS.SET_PENDING_SELECTIONS;
97
+ } | {
98
+ type: ACTIONS.SET_INLINE_COMMENTS_FETCHED;
96
99
  };
97
100
  export type InlineCommentPluginState = {
101
+ annotationsLoaded: boolean;
98
102
  /**
99
103
  * The resolved state of the annotations.
100
104
  *
@@ -9,6 +9,7 @@ import type { InlineCommentInputMethod, TargetType } from '../types';
9
9
  export declare const updateInlineCommentResolvedState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (partialNewState: InlineCommentMap, resolveMethod?: RESOLVE_METHOD) => Command;
10
10
  export declare const closeComponent: () => Command;
11
11
  export declare const clearDirtyMark: () => Command;
12
+ export declare const setInlineCommentsFetched: () => Command;
12
13
  export declare const flushPendingSelections: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (canSetAsSelectedAnnotations: boolean, errorReason?: string) => Command;
13
14
  export declare const setPendingSelectedAnnotation: (id: string) => Command;
14
15
  export declare const removeInlineCommentNearSelection: (id: string, supportedNodes?: string[]) => Command;
@@ -17,7 +17,8 @@ export declare enum ACTIONS {
17
17
  SET_SELECTED_ANNOTATION = 7,
18
18
  SET_HOVERED_ANNOTATION = 8,
19
19
  FLUSH_PENDING_SELECTIONS = 9,
20
- SET_PENDING_SELECTIONS = 10
20
+ SET_PENDING_SELECTIONS = 10,
21
+ SET_INLINE_COMMENTS_FETCHED = 11
21
22
  }
22
23
  export interface InlineCommentPluginOptions {
23
24
  annotationManager?: AnnotationManager;
@@ -93,8 +94,11 @@ export type InlineCommentAction = {
93
94
  selectedAnnotations: AnnotationInfo[];
94
95
  };
95
96
  type: ACTIONS.SET_PENDING_SELECTIONS;
97
+ } | {
98
+ type: ACTIONS.SET_INLINE_COMMENTS_FETCHED;
96
99
  };
97
100
  export type InlineCommentPluginState = {
101
+ annotationsLoaded: boolean;
98
102
  /**
99
103
  * The resolved state of the annotations.
100
104
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-annotation",
3
- "version": "6.0.0",
3
+ "version": "6.1.0",
4
4
  "description": "Annotation plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -29,24 +29,24 @@
29
29
  "dependencies": {
30
30
  "@atlaskit/adf-schema": "^51.2.0",
31
31
  "@atlaskit/analytics-next": "^11.1.0",
32
- "@atlaskit/editor-plugin-analytics": "^6.0.0",
32
+ "@atlaskit/editor-plugin-analytics": "^6.1.0",
33
33
  "@atlaskit/editor-plugin-connectivity": "^6.0.0",
34
34
  "@atlaskit/editor-plugin-editor-viewmode-effects": "^6.0.0",
35
35
  "@atlaskit/editor-plugin-feature-flags": "^5.0.0",
36
36
  "@atlaskit/editor-plugin-toolbar": "^3.0.0",
37
37
  "@atlaskit/editor-plugin-user-intent": "^4.0.0",
38
38
  "@atlaskit/editor-prosemirror": "7.0.0",
39
- "@atlaskit/editor-toolbar": "^0.9.0",
39
+ "@atlaskit/editor-toolbar": "^0.10.0",
40
40
  "@atlaskit/editor-toolbar-model": "^0.2.0",
41
41
  "@atlaskit/icon": "^28.3.0",
42
42
  "@atlaskit/onboarding": "^14.4.0",
43
43
  "@atlaskit/platform-feature-flags": "^1.1.0",
44
- "@atlaskit/tmp-editor-statsig": "^12.31.0",
44
+ "@atlaskit/tmp-editor-statsig": "^12.32.0",
45
45
  "@babel/runtime": "^7.0.0",
46
46
  "react-intl-next": "npm:react-intl@^5.18.1"
47
47
  },
48
48
  "peerDependencies": {
49
- "@atlaskit/editor-common": "^110.0.0",
49
+ "@atlaskit/editor-common": "^110.3.0",
50
50
  "react": "^18.2.0",
51
51
  "react-dom": "^18.2.0"
52
52
  },
@@ -108,6 +108,9 @@
108
108
  },
109
109
  "confluence_frontend_preload_inline_comment_editor": {
110
110
  "type": "boolean"
111
+ },
112
+ "confluence_frontend_new_dangling_comments_ux": {
113
+ "type": "boolean"
111
114
  }
112
115
  }
113
116
  }