@atlaskit/editor-plugin-annotation 2.7.1 → 2.7.3

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.7.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#146979](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/146979)
8
+ [`5cea1d6e69c56`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5cea1d6e69c56) -
9
+ ED-27655: Moving annotation plugin options from confluence's full page editor preset to the
10
+ confluence-presets.
11
+ - Updated dependencies
12
+
13
+ ## 2.7.2
14
+
15
+ ### Patch Changes
16
+
17
+ - [#145138](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/145138)
18
+ [`0ba0ff24c0e33`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0ba0ff24c0e33) -
19
+ Enable useSharedPluginStateSelector in accessibility, alignment, annotation and avatar-group
20
+ plugins
21
+ - Updated dependencies
22
+
3
23
  ## 2.7.1
4
24
 
5
25
  ### Patch Changes
@@ -8,6 +8,7 @@ exports.annotationPlugin = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _react = _interopRequireDefault(require("react"));
10
10
  var _hooks = require("@atlaskit/editor-common/hooks");
11
+ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
11
12
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
13
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
13
14
  var _editorCommands = require("./editor-commands");
@@ -138,9 +139,20 @@ function AnnotationContentComponent(_ref4) {
138
139
  editorView = _ref4.editorView,
139
140
  annotationProviders = _ref4.annotationProviders,
140
141
  dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent;
141
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['annotation']),
142
- inlineCommentState = _useSharedPluginState.annotationState;
143
- if (inlineCommentState && !inlineCommentState.isVisible) {
142
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['annotation'], {
143
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
144
+ }),
145
+ annotationState = _useSharedPluginState.annotationState;
146
+ var isVisibleSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'annotation.isVisible', {
147
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
148
+ });
149
+ var isVisible = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? isVisibleSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.isVisible;
150
+ if (annotationState && !isVisible && (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)) {
151
+ return null;
152
+ }
153
+
154
+ // need to expclicitly check for false as undefined is also a valid value to continue
155
+ if (isVisible === false && (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)) {
144
156
  return null;
145
157
  }
146
158
  return /*#__PURE__*/_react.default.createElement("div", {
@@ -231,15 +231,21 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
231
231
  if ((0, _platformFeatureFlags.fg)('confluence_comments_select_comment_experience')) {
232
232
  var _prevSelectedAnnotati;
233
233
  var _ref4 = (0, _utils.getPluginState)(view.state) || {},
234
- selectedAnnotations = _ref4.selectedAnnotations;
234
+ selectedAnnotations = _ref4.selectedAnnotations,
235
+ annotations = _ref4.annotations;
235
236
  var _ref5 = (0, _utils.getPluginState)(_prevState) || {},
236
237
  prevSelectedAnnotations = _ref5.selectedAnnotations;
237
-
238
- // If the new state has a selected annotation, and it's different from the previous one
239
- // then we mark the select annotation experience as complete
240
- if (selectedAnnotations && selectedAnnotations.length !== 0 && selectedAnnotations[0].id !== (prevSelectedAnnotations === null || prevSelectedAnnotations === void 0 || (_prevSelectedAnnotati = prevSelectedAnnotations[0]) === null || _prevSelectedAnnotati === void 0 ? void 0 : _prevSelectedAnnotati.id)) {
238
+ var selectedAnnotationId = selectedAnnotations && selectedAnnotations.length !== 0 && selectedAnnotations[0].id ? selectedAnnotations[0].id : undefined;
239
+ // If the new state has an unresolved selected annotation, and it's different from
240
+ // the previous one then we mark the select annotation experience as complete.
241
+ if (
242
+ //This checks the selected annotation is different from the previous one
243
+ selectedAnnotationId && selectedAnnotationId !== (prevSelectedAnnotations === null || prevSelectedAnnotations === void 0 || (_prevSelectedAnnotati = prevSelectedAnnotations[0]) === null || _prevSelectedAnnotati === void 0 ? void 0 : _prevSelectedAnnotati.id) &&
244
+ // This ensures that the selected annotation is unresolved
245
+ annotations && annotations[selectedAnnotationId] === false) {
241
246
  var _options$selectCommen;
242
- (_options$selectCommen = options.selectCommentExperience) === null || _options$selectCommen === void 0 || _options$selectCommen.selectAnnotation.complete(selectedAnnotations[0].id);
247
+ // Under the confluence_comments_select_comment_experience feature flag, the selectComponentExperience is using a simplified object, which is why it's type asserted.
248
+ (_options$selectCommen = options.selectCommentExperience) === null || _options$selectCommen === void 0 || _options$selectCommen.selectAnnotation.complete(selectedAnnotationId);
243
249
  }
244
250
  }
245
251
  var _ref6 = (0, _utils.getPluginState)(view.state) || {},
@@ -253,7 +253,9 @@ var resolveDraftBookmark = exports.resolveDraftBookmark = function resolveDraftB
253
253
  * get selection from position to apply new comment for
254
254
  * @return bookmarked positions if they exists, otherwise current selection positions
255
255
  */
256
- function getSelectionPositions(editorState, inlineCommentState) {
256
+ function getSelectionPositions(editorState,
257
+ // when cleaning up platform_editor_usesharedpluginstateselector, can change this prop to bookmark
258
+ inlineCommentState) {
257
259
  var _ref2 = inlineCommentState || {},
258
260
  bookmark = _ref2.bookmark;
259
261
  // get positions via saved bookmark if it is available
@@ -26,4 +26,9 @@ 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
- };
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
+ */
@@ -9,9 +9,11 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
9
9
  var _react = _interopRequireDefault(require("react"));
10
10
  var _adfSchema = require("@atlaskit/adf-schema");
11
11
  var _analytics = require("@atlaskit/editor-common/analytics");
12
+ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
12
13
  var _utils = require("@atlaskit/editor-common/utils");
13
14
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
14
15
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
15
17
  var _editorCommands = require("../editor-commands");
16
18
  var _utils3 = require("../pm-plugins/utils");
17
19
  var _types = require("../types");
@@ -45,14 +47,40 @@ function InlineCommentView(_ref) {
45
47
  var CreateComponent = inlineCommentProvider.createComponent,
46
48
  ViewComponent = inlineCommentProvider.viewComponent;
47
49
  var inlineCommentState = (0, _utils3.getPluginState)(state);
48
- var _ref2 = inlineCommentState || {},
49
- bookmark = _ref2.bookmark,
50
- selectedAnnotations = _ref2.selectedAnnotations,
51
- annotations = _ref2.annotations,
52
- isInlineCommentViewClosed = _ref2.isInlineCommentViewClosed,
53
- isOpeningMediaCommentFromToolbar = _ref2.isOpeningMediaCommentFromToolbar;
50
+
51
+ // bookmark
52
+ var bookmarkSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(editorAPI, 'annotation.bookmark', {
53
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
54
+ });
55
+ var bookmark = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? bookmarkSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.bookmark;
56
+
57
+ // selectedAnnotations
58
+ var selectedAnnotationsSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(editorAPI, 'annotation.selectedAnnotations', {
59
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
60
+ });
61
+ var selectedAnnotations = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? selectedAnnotationsSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectedAnnotations;
62
+
63
+ // annotations
64
+ var annotationsSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(editorAPI, 'annotation.annotations', {
65
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
66
+ });
67
+ var annotations = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? annotationsSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.annotations;
68
+
69
+ // isInlineCommentViewClosed
70
+ var isInlineCommentViewClosedSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(editorAPI, 'annotation.isInlineCommentViewClosed', {
71
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
72
+ });
73
+ var isInlineCommentViewClosed = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? isInlineCommentViewClosedSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isInlineCommentViewClosed;
74
+
75
+ // isOpeningMediaCommentFromToolbar
76
+ var isOpeningMediaCommentFromToolbarSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(editorAPI, 'annotation.isOpeningMediaCommentFromToolbar', {
77
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
78
+ });
79
+ var isOpeningMediaCommentFromToolbar = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? isOpeningMediaCommentFromToolbarSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isOpeningMediaCommentFromToolbar;
54
80
  var annotationsList = (0, _utils3.getAllAnnotations)(editorView.state.doc);
55
- var selection = (0, _utils3.getSelectionPositions)(state, inlineCommentState);
81
+ var selection = (0, _utils3.getSelectionPositions)(state, (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? {
82
+ bookmark: bookmark
83
+ } : inlineCommentState);
56
84
  var position = findPosForDOM(selection);
57
85
  var dom;
58
86
  try {
@@ -78,6 +106,11 @@ function InlineCommentView(_ref) {
78
106
  dispatchAnalyticsEvent(payload);
79
107
  }
80
108
  }
109
+
110
+ // selectAnnotationMethod
111
+ var selectAnnotationMethodSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(editorAPI, 'annotation.selectAnnotationMethod', {
112
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
113
+ });
81
114
  if (!dom) {
82
115
  return null;
83
116
  }
@@ -132,8 +165,6 @@ function InlineCommentView(_ref) {
132
165
  if (!dispatchAnalyticsEvent) {
133
166
  return;
134
167
  }
135
- var _ref3 = inlineCommentState || {},
136
- selectAnnotationMethod = _ref3.selectAnnotationMethod;
137
168
 
138
169
  // fire analytics
139
170
  var payload = {
@@ -144,7 +175,7 @@ function InlineCommentView(_ref) {
144
175
  attributes: {
145
176
  overlap: activeAnnotations.length ? activeAnnotations.length - 1 : 0,
146
177
  targetNodeType: (_editorView$state$doc = editorView.state.doc.nodeAt(position)) === null || _editorView$state$doc === void 0 ? void 0 : _editorView$state$doc.type.name,
147
- method: selectAnnotationMethod
178
+ method: (0, _experiments.editorExperiment)('platform_editor_tables_table_selector', true) ? selectAnnotationMethodSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectAnnotationMethod
148
179
  }
149
180
  };
150
181
  dispatchAnalyticsEvent(payload);
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
3
4
  import { fg } from '@atlaskit/platform-feature-flags';
4
5
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
6
  import { setInlineCommentDraftState, showInlineCommentForBlockNode } from './editor-commands';
@@ -134,9 +135,20 @@ function AnnotationContentComponent({
134
135
  }) {
135
136
  var _api$analytics5;
136
137
  const {
137
- annotationState: inlineCommentState
138
- } = useSharedPluginState(api, ['annotation']);
139
- if (inlineCommentState && !inlineCommentState.isVisible) {
138
+ annotationState
139
+ } = useSharedPluginState(api, ['annotation'], {
140
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
141
+ });
142
+ const isVisibleSelector = useSharedPluginStateSelector(api, 'annotation.isVisible', {
143
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
144
+ });
145
+ const isVisible = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isVisibleSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.isVisible;
146
+ if (annotationState && !isVisible && editorExperiment('platform_editor_usesharedpluginstateselector', false)) {
147
+ return null;
148
+ }
149
+
150
+ // need to expclicitly check for false as undefined is also a valid value to continue
151
+ if (isVisible === false && editorExperiment('platform_editor_usesharedpluginstateselector', true)) {
140
152
  return null;
141
153
  }
142
154
  return /*#__PURE__*/React.createElement("div", {
@@ -165,17 +165,23 @@ export const inlineCommentPlugin = options => {
165
165
  if (fg('confluence_comments_select_comment_experience')) {
166
166
  var _prevSelectedAnnotati;
167
167
  const {
168
- selectedAnnotations
168
+ selectedAnnotations,
169
+ annotations
169
170
  } = getPluginState(view.state) || {};
170
171
  const {
171
172
  selectedAnnotations: prevSelectedAnnotations
172
173
  } = getPluginState(_prevState) || {};
173
-
174
- // If the new state has a selected annotation, and it's different from the previous one
175
- // then we mark the select annotation experience as complete
176
- if (selectedAnnotations && selectedAnnotations.length !== 0 && selectedAnnotations[0].id !== (prevSelectedAnnotations === null || prevSelectedAnnotations === void 0 ? void 0 : (_prevSelectedAnnotati = prevSelectedAnnotations[0]) === null || _prevSelectedAnnotati === void 0 ? void 0 : _prevSelectedAnnotati.id)) {
174
+ const selectedAnnotationId = selectedAnnotations && selectedAnnotations.length !== 0 && selectedAnnotations[0].id ? selectedAnnotations[0].id : undefined;
175
+ // If the new state has an unresolved selected annotation, and it's different from
176
+ // the previous one then we mark the select annotation experience as complete.
177
+ if (
178
+ //This checks the selected annotation is different from the previous one
179
+ selectedAnnotationId && selectedAnnotationId !== (prevSelectedAnnotations === null || prevSelectedAnnotations === void 0 ? void 0 : (_prevSelectedAnnotati = prevSelectedAnnotations[0]) === null || _prevSelectedAnnotati === void 0 ? void 0 : _prevSelectedAnnotati.id) &&
180
+ // This ensures that the selected annotation is unresolved
181
+ annotations && annotations[selectedAnnotationId] === false) {
177
182
  var _options$selectCommen;
178
- (_options$selectCommen = options.selectCommentExperience) === null || _options$selectCommen === void 0 ? void 0 : _options$selectCommen.selectAnnotation.complete(selectedAnnotations[0].id);
183
+ // Under the confluence_comments_select_comment_experience feature flag, the selectComponentExperience is using a simplified object, which is why it's type asserted.
184
+ (_options$selectCommen = options.selectCommentExperience) === null || _options$selectCommen === void 0 ? void 0 : _options$selectCommen.selectAnnotation.complete(selectedAnnotationId);
179
185
  }
180
186
  }
181
187
  const {
@@ -217,7 +217,9 @@ export const resolveDraftBookmark = (editorState, bookmark, supportedBlockNodes
217
217
  * get selection from position to apply new comment for
218
218
  * @return bookmarked positions if they exists, otherwise current selection positions
219
219
  */
220
- export function getSelectionPositions(editorState, inlineCommentState) {
220
+ export function getSelectionPositions(editorState,
221
+ // when cleaning up platform_editor_usesharedpluginstateselector, can change this prop to bookmark
222
+ inlineCommentState) {
221
223
  const {
222
224
  bookmark
223
225
  } = inlineCommentState || {};
@@ -22,4 +22,9 @@ 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
- };
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
+ */
@@ -1,9 +1,11 @@
1
1
  import React from 'react';
2
2
  import { AnnotationTypes } from '@atlaskit/adf-schema';
3
3
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, CONTENT_COMPONENT, EVENT_TYPE, RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
4
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
4
5
  import { getAnnotationInlineNodeTypes, getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
5
6
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
6
7
  import { fg } from '@atlaskit/platform-feature-flags';
8
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
9
  import { closeComponent, createAnnotation, removeInlineCommentNearSelection, setInlineCommentDraftState, updateInlineCommentResolvedState } from '../editor-commands';
8
10
  import { getAllAnnotations, getAnnotationViewKey, getPluginState, getSelectionPositions } from '../pm-plugins/utils';
9
11
  import { AnnotationTestIds } from '../types';
@@ -44,15 +46,40 @@ export function InlineCommentView({
44
46
  viewComponent: ViewComponent
45
47
  } = inlineCommentProvider;
46
48
  const inlineCommentState = getPluginState(state);
47
- const {
48
- bookmark,
49
- selectedAnnotations,
50
- annotations,
51
- isInlineCommentViewClosed,
52
- isOpeningMediaCommentFromToolbar
53
- } = inlineCommentState || {};
49
+
50
+ // bookmark
51
+ const bookmarkSelector = useSharedPluginStateSelector(editorAPI, 'annotation.bookmark', {
52
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
53
+ });
54
+ const bookmark = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? bookmarkSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.bookmark;
55
+
56
+ // selectedAnnotations
57
+ const selectedAnnotationsSelector = useSharedPluginStateSelector(editorAPI, 'annotation.selectedAnnotations', {
58
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
59
+ });
60
+ const selectedAnnotations = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectedAnnotationsSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectedAnnotations;
61
+
62
+ // annotations
63
+ const annotationsSelector = useSharedPluginStateSelector(editorAPI, 'annotation.annotations', {
64
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
65
+ });
66
+ const annotations = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? annotationsSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.annotations;
67
+
68
+ // isInlineCommentViewClosed
69
+ const isInlineCommentViewClosedSelector = useSharedPluginStateSelector(editorAPI, 'annotation.isInlineCommentViewClosed', {
70
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
71
+ });
72
+ const isInlineCommentViewClosed = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isInlineCommentViewClosedSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isInlineCommentViewClosed;
73
+
74
+ // isOpeningMediaCommentFromToolbar
75
+ const isOpeningMediaCommentFromToolbarSelector = useSharedPluginStateSelector(editorAPI, 'annotation.isOpeningMediaCommentFromToolbar', {
76
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
77
+ });
78
+ const isOpeningMediaCommentFromToolbar = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isOpeningMediaCommentFromToolbarSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isOpeningMediaCommentFromToolbar;
54
79
  const annotationsList = getAllAnnotations(editorView.state.doc);
55
- const selection = getSelectionPositions(state, inlineCommentState);
80
+ const selection = getSelectionPositions(state, editorExperiment('platform_editor_usesharedpluginstateselector', true) ? {
81
+ bookmark
82
+ } : inlineCommentState);
56
83
  const position = findPosForDOM(selection);
57
84
  let dom;
58
85
  try {
@@ -78,6 +105,11 @@ export function InlineCommentView({
78
105
  dispatchAnalyticsEvent(payload);
79
106
  }
80
107
  }
108
+
109
+ // selectAnnotationMethod
110
+ const selectAnnotationMethodSelector = useSharedPluginStateSelector(editorAPI, 'annotation.selectAnnotationMethod', {
111
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
112
+ });
81
113
  if (!dom) {
82
114
  return null;
83
115
  }
@@ -130,9 +162,6 @@ export function InlineCommentView({
130
162
  if (!dispatchAnalyticsEvent) {
131
163
  return;
132
164
  }
133
- const {
134
- selectAnnotationMethod
135
- } = inlineCommentState || {};
136
165
 
137
166
  // fire analytics
138
167
  const payload = {
@@ -143,7 +172,7 @@ export function InlineCommentView({
143
172
  attributes: {
144
173
  overlap: activeAnnotations.length ? activeAnnotations.length - 1 : 0,
145
174
  targetNodeType: (_editorView$state$doc = editorView.state.doc.nodeAt(position)) === null || _editorView$state$doc === void 0 ? void 0 : _editorView$state$doc.type.name,
146
- method: selectAnnotationMethod
175
+ method: editorExperiment('platform_editor_tables_table_selector', true) ? selectAnnotationMethodSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectAnnotationMethod
147
176
  }
148
177
  };
149
178
  dispatchAnalyticsEvent(payload);
@@ -3,6 +3,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
3
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; }
4
4
  import React from 'react';
5
5
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
6
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
6
7
  import { fg } from '@atlaskit/platform-feature-flags';
7
8
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
8
9
  import { setInlineCommentDraftState, showInlineCommentForBlockNode } from './editor-commands';
@@ -131,9 +132,20 @@ function AnnotationContentComponent(_ref4) {
131
132
  editorView = _ref4.editorView,
132
133
  annotationProviders = _ref4.annotationProviders,
133
134
  dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent;
134
- var _useSharedPluginState = useSharedPluginState(api, ['annotation']),
135
- inlineCommentState = _useSharedPluginState.annotationState;
136
- if (inlineCommentState && !inlineCommentState.isVisible) {
135
+ var _useSharedPluginState = useSharedPluginState(api, ['annotation'], {
136
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
137
+ }),
138
+ annotationState = _useSharedPluginState.annotationState;
139
+ var isVisibleSelector = useSharedPluginStateSelector(api, 'annotation.isVisible', {
140
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
141
+ });
142
+ var isVisible = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isVisibleSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.isVisible;
143
+ if (annotationState && !isVisible && editorExperiment('platform_editor_usesharedpluginstateselector', false)) {
144
+ return null;
145
+ }
146
+
147
+ // need to expclicitly check for false as undefined is also a valid value to continue
148
+ if (isVisible === false && editorExperiment('platform_editor_usesharedpluginstateselector', true)) {
137
149
  return null;
138
150
  }
139
151
  return /*#__PURE__*/React.createElement("div", {
@@ -224,15 +224,21 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
224
224
  if (fg('confluence_comments_select_comment_experience')) {
225
225
  var _prevSelectedAnnotati;
226
226
  var _ref4 = getPluginState(view.state) || {},
227
- selectedAnnotations = _ref4.selectedAnnotations;
227
+ selectedAnnotations = _ref4.selectedAnnotations,
228
+ annotations = _ref4.annotations;
228
229
  var _ref5 = getPluginState(_prevState) || {},
229
230
  prevSelectedAnnotations = _ref5.selectedAnnotations;
230
-
231
- // If the new state has a selected annotation, and it's different from the previous one
232
- // then we mark the select annotation experience as complete
233
- if (selectedAnnotations && selectedAnnotations.length !== 0 && selectedAnnotations[0].id !== (prevSelectedAnnotations === null || prevSelectedAnnotations === void 0 || (_prevSelectedAnnotati = prevSelectedAnnotations[0]) === null || _prevSelectedAnnotati === void 0 ? void 0 : _prevSelectedAnnotati.id)) {
231
+ var selectedAnnotationId = selectedAnnotations && selectedAnnotations.length !== 0 && selectedAnnotations[0].id ? selectedAnnotations[0].id : undefined;
232
+ // If the new state has an unresolved selected annotation, and it's different from
233
+ // the previous one then we mark the select annotation experience as complete.
234
+ if (
235
+ //This checks the selected annotation is different from the previous one
236
+ selectedAnnotationId && selectedAnnotationId !== (prevSelectedAnnotations === null || prevSelectedAnnotations === void 0 || (_prevSelectedAnnotati = prevSelectedAnnotations[0]) === null || _prevSelectedAnnotati === void 0 ? void 0 : _prevSelectedAnnotati.id) &&
237
+ // This ensures that the selected annotation is unresolved
238
+ annotations && annotations[selectedAnnotationId] === false) {
234
239
  var _options$selectCommen;
235
- (_options$selectCommen = options.selectCommentExperience) === null || _options$selectCommen === void 0 || _options$selectCommen.selectAnnotation.complete(selectedAnnotations[0].id);
240
+ // Under the confluence_comments_select_comment_experience feature flag, the selectComponentExperience is using a simplified object, which is why it's type asserted.
241
+ (_options$selectCommen = options.selectCommentExperience) === null || _options$selectCommen === void 0 || _options$selectCommen.selectAnnotation.complete(selectedAnnotationId);
236
242
  }
237
243
  }
238
244
  var _ref6 = getPluginState(view.state) || {},
@@ -236,7 +236,9 @@ export var resolveDraftBookmark = function resolveDraftBookmark(editorState, boo
236
236
  * get selection from position to apply new comment for
237
237
  * @return bookmarked positions if they exists, otherwise current selection positions
238
238
  */
239
- export function getSelectionPositions(editorState, inlineCommentState) {
239
+ export function getSelectionPositions(editorState,
240
+ // when cleaning up platform_editor_usesharedpluginstateselector, can change this prop to bookmark
241
+ inlineCommentState) {
240
242
  var _ref2 = inlineCommentState || {},
241
243
  bookmark = _ref2.bookmark;
242
244
  // get positions via saved bookmark if it is available
@@ -22,4 +22,9 @@ export var AnnotationTestIds = {
22
22
  floatingToolbarCreateButton: "".concat(prefix, "-toolbar-create-button"),
23
23
  componentSave: "".concat(prefix, "-dummy-save-button"),
24
24
  componentClose: "".concat(prefix, "-dummy-close-button")
25
- };
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
+ */
@@ -2,9 +2,11 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React from 'react';
3
3
  import { AnnotationTypes } from '@atlaskit/adf-schema';
4
4
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, CONTENT_COMPONENT, EVENT_TYPE, RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
5
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
5
6
  import { getAnnotationInlineNodeTypes, getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
6
7
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
7
8
  import { fg } from '@atlaskit/platform-feature-flags';
9
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
8
10
  import { closeComponent, createAnnotation, removeInlineCommentNearSelection, setInlineCommentDraftState, updateInlineCommentResolvedState } from '../editor-commands';
9
11
  import { getAllAnnotations, getAnnotationViewKey, getPluginState, getSelectionPositions } from '../pm-plugins/utils';
10
12
  import { AnnotationTestIds } from '../types';
@@ -38,14 +40,40 @@ export function InlineCommentView(_ref) {
38
40
  var CreateComponent = inlineCommentProvider.createComponent,
39
41
  ViewComponent = inlineCommentProvider.viewComponent;
40
42
  var inlineCommentState = getPluginState(state);
41
- var _ref2 = inlineCommentState || {},
42
- bookmark = _ref2.bookmark,
43
- selectedAnnotations = _ref2.selectedAnnotations,
44
- annotations = _ref2.annotations,
45
- isInlineCommentViewClosed = _ref2.isInlineCommentViewClosed,
46
- isOpeningMediaCommentFromToolbar = _ref2.isOpeningMediaCommentFromToolbar;
43
+
44
+ // bookmark
45
+ var bookmarkSelector = useSharedPluginStateSelector(editorAPI, 'annotation.bookmark', {
46
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
47
+ });
48
+ var bookmark = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? bookmarkSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.bookmark;
49
+
50
+ // selectedAnnotations
51
+ var selectedAnnotationsSelector = useSharedPluginStateSelector(editorAPI, 'annotation.selectedAnnotations', {
52
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
53
+ });
54
+ var selectedAnnotations = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectedAnnotationsSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectedAnnotations;
55
+
56
+ // annotations
57
+ var annotationsSelector = useSharedPluginStateSelector(editorAPI, 'annotation.annotations', {
58
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
59
+ });
60
+ var annotations = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? annotationsSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.annotations;
61
+
62
+ // isInlineCommentViewClosed
63
+ var isInlineCommentViewClosedSelector = useSharedPluginStateSelector(editorAPI, 'annotation.isInlineCommentViewClosed', {
64
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
65
+ });
66
+ var isInlineCommentViewClosed = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isInlineCommentViewClosedSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isInlineCommentViewClosed;
67
+
68
+ // isOpeningMediaCommentFromToolbar
69
+ var isOpeningMediaCommentFromToolbarSelector = useSharedPluginStateSelector(editorAPI, 'annotation.isOpeningMediaCommentFromToolbar', {
70
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
71
+ });
72
+ var isOpeningMediaCommentFromToolbar = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isOpeningMediaCommentFromToolbarSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isOpeningMediaCommentFromToolbar;
47
73
  var annotationsList = getAllAnnotations(editorView.state.doc);
48
- var selection = getSelectionPositions(state, inlineCommentState);
74
+ var selection = getSelectionPositions(state, editorExperiment('platform_editor_usesharedpluginstateselector', true) ? {
75
+ bookmark: bookmark
76
+ } : inlineCommentState);
49
77
  var position = findPosForDOM(selection);
50
78
  var dom;
51
79
  try {
@@ -71,6 +99,11 @@ export function InlineCommentView(_ref) {
71
99
  dispatchAnalyticsEvent(payload);
72
100
  }
73
101
  }
102
+
103
+ // selectAnnotationMethod
104
+ var selectAnnotationMethodSelector = useSharedPluginStateSelector(editorAPI, 'annotation.selectAnnotationMethod', {
105
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
106
+ });
74
107
  if (!dom) {
75
108
  return null;
76
109
  }
@@ -125,8 +158,6 @@ export function InlineCommentView(_ref) {
125
158
  if (!dispatchAnalyticsEvent) {
126
159
  return;
127
160
  }
128
- var _ref3 = inlineCommentState || {},
129
- selectAnnotationMethod = _ref3.selectAnnotationMethod;
130
161
 
131
162
  // fire analytics
132
163
  var payload = {
@@ -137,7 +168,7 @@ export function InlineCommentView(_ref) {
137
168
  attributes: {
138
169
  overlap: activeAnnotations.length ? activeAnnotations.length - 1 : 0,
139
170
  targetNodeType: (_editorView$state$doc = editorView.state.doc.nodeAt(position)) === null || _editorView$state$doc === void 0 ? void 0 : _editorView$state$doc.type.name,
140
- method: selectAnnotationMethod
171
+ method: editorExperiment('platform_editor_tables_table_selector', true) ? selectAnnotationMethodSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectAnnotationMethod
141
172
  }
142
173
  };
143
174
  dispatchAnalyticsEvent(payload);
@@ -1,4 +1,4 @@
1
1
  export { annotationPlugin } from './annotationPlugin';
2
2
  export type { AnnotationPlugin, AnnotationPluginOptions } from './annotationPluginType';
3
- export type { AnnotationProviders, InlineCommentAnnotationProvider, AnnotationInfo, InlineCommentCreateComponentProps, InlineCommentViewComponentProps, AnnotationState, AnnotationTypeProvider, InlineCommentState, TargetType, InlineCommentInputMethod, } from './types';
3
+ export type { AnnotationInfo, AnnotationProviders, AnnotationState, AnnotationTypeProvider, InlineCommentAnnotationProvider, InlineCommentCompoundExperience, InlineCommentCreateComponentProps, InlineCommentInputMethod, InlineCommentState, InlineCommentViewComponentProps, SelectInlineCommentCompoundExperience, SelectInlineCommentCompoundExperienceEntryPoint, SimpleSelectInlineCommentCompoundExperience, StartAttributes, TargetType, } from './types';
4
4
  export type { InlineCommentMap, InlineCommentPluginState, InlineCommentPluginOptions, InlineCommentAction, } from './pm-plugins/types';
@@ -82,12 +82,50 @@ export type InlineCommentAction = {
82
82
  };
83
83
  };
84
84
  export type InlineCommentPluginState = {
85
+ /**
86
+ * The resolved state of the annotations.
87
+ *
88
+ * The keys are the annotation ids, and the values are booleans indicating whether the annotation is resolved or not.
89
+ *
90
+ * The annotation is only considered unresolved if the value is false. An undefined value is treated as resolved.
91
+ * This is because the editor does not know yet the resolved state of the annotation, and so it is treated as resolved until
92
+ * the editor receives the resolved state from the server. (see dirtyAnnotations for more details)
93
+ *
94
+ * Example value
95
+ * ```
96
+ * {
97
+ * // resolved comments
98
+ * 'annotation-id': true,
99
+ * 'annotation-id-3': undefined,
100
+ * // unresolved comment
101
+ * 'annotation-id-2': false,
102
+ * }
103
+ * ```
104
+ */
85
105
  annotations: InlineCommentMap;
106
+ /**
107
+ * A list of the annotations at the current selection.
108
+ *
109
+ * While this is a list, consumers only make use of the first element, and from the
110
+ * user perspective, there is only one annotation selected at a time.
111
+ */
86
112
  selectedAnnotations: AnnotationInfo[];
113
+ /**
114
+ * Indicates the document has annotations which it does not currently know the resolved state of.
115
+ * This can happen when the annotations are loaded via ncs, and the editor has not received the
116
+ * resolved state of the annotations yet (as the resolved state comes from a separate service).
117
+ */
87
118
  dirtyAnnotations?: boolean;
88
119
  mouseData: InlineCommentMouseData;
89
120
  draftDecorationSet?: DecorationSet;
90
121
  bookmark?: SelectionBookmark;
122
+ /**
123
+ * Warning: This is not the state of annotations which are currently being hovered over,
124
+ * but rather the annotations which have been given a selected like visual state from an
125
+ * editor api.
126
+ * The Comment consumer does this when browsing comments in the sidebar, where it sets
127
+ * a "hovered" state on the annotation, while the comment is hovered in the sidebar.
128
+ */
91
129
  hoveredAnnotations?: AnnotationInfo[];
92
130
  disallowOnWhitespace: boolean;
93
131
  isInlineCommentViewClosed: boolean;
@@ -25,7 +25,7 @@ export declare const resolveDraftBookmark: (editorState: EditorState, bookmark?:
25
25
  * get selection from position to apply new comment for
26
26
  * @return bookmarked positions if they exists, otherwise current selection positions
27
27
  */
28
- export declare function getSelectionPositions(editorState: EditorState, inlineCommentState?: InlineCommentPluginState | null | undefined): Selection;
28
+ export declare function getSelectionPositions(editorState: EditorState, inlineCommentState?: Partial<InlineCommentPluginState> | null | undefined): Selection;
29
29
  export declare const inlineCommentPluginKey: PluginKey<InlineCommentPluginState>;
30
30
  export declare const getPluginState: (state: EditorState) => InlineCommentPluginState | undefined;
31
31
  /**
@@ -1,5 +1,6 @@
1
1
  import type React from 'react';
2
2
  import type { AnnotationTypes } from '@atlaskit/adf-schema';
3
+ import { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next/types';
3
4
  import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
5
  import type { AnnotationUpdateEmitter, AnnotationManager } from '@atlaskit/editor-common/annotation';
5
6
  /**
@@ -104,28 +105,8 @@ export type InlineCommentAnnotationProvider = AnnotationTypeProvider<AnnotationT
104
105
  };
105
106
  export interface AnnotationProviders {
106
107
  inlineComment: InlineCommentAnnotationProvider;
107
- createCommentExperience?: {
108
- start: (_: {
109
- attributes: {
110
- pageClass: 'editor';
111
- commentType: 'inline';
112
- annotationId?: undefined;
113
- } | {
114
- pageClass: 'editor';
115
- commentType: 'block';
116
- blockType: 'media';
117
- annotationId?: undefined;
118
- };
119
- }) => void;
120
- initExperience: {
121
- start: () => void;
122
- };
123
- };
124
- selectCommentExperience?: {
125
- selectAnnotation: {
126
- complete: (annotationId: string) => void;
127
- };
128
- };
108
+ createCommentExperience?: InlineCommentCompoundExperience;
109
+ selectCommentExperience?: SimpleSelectInlineCommentCompoundExperience;
129
110
  annotationManager?: AnnotationManager;
130
111
  }
131
112
  export declare enum AnnotationSelectionType {
@@ -152,4 +133,135 @@ export type DraftBookmark = {
152
133
  head: number;
153
134
  isBlockNode?: boolean;
154
135
  };
136
+ type ExperienceAttributes = {
137
+ [key: string]: string | number | boolean | string[] | number[];
138
+ };
139
+ type InlineCommentAttributes = {
140
+ pageClass: 'editor';
141
+ commentType: 'inline';
142
+ annotationId?: undefined;
143
+ } | {
144
+ pageClass: 'editor';
145
+ commentType: 'block';
146
+ blockType: 'media';
147
+ annotationId?: undefined;
148
+ } | {
149
+ pageClass: 'renderer';
150
+ commentType: 'inline';
151
+ annotationId: string;
152
+ } | {
153
+ pageClass: 'renderer';
154
+ commentType: 'block';
155
+ blockType: 'media';
156
+ annotationId: string;
157
+ };
158
+ export type SelectInlineCommentCompoundExperienceEntryPoint = 'create-comment' | 'annotation-change' | 'comment-navigation' | 'keyboard-navigation' | 'sidebar' | 'unknown:RendererFocus' | 'unknown:InlineComment' | 'unknown:CommentsPanelList';
159
+ export type StartAttributes = {
160
+ pageClass: 'editor' | 'renderer';
161
+ /**
162
+ * This is optional as in some scenarios the entry point does not know
163
+ * what type of comment is being selected (e.g. comment navigation, sidebar).
164
+ **/
165
+ commentType?: 'block' | 'inline';
166
+ blockType?: 'media';
167
+ annotationId: string;
168
+ entryPoint: Exclude<SelectInlineCommentCompoundExperienceEntryPoint, 'keyboard-navigation' | 'comment-navigation'>;
169
+ linkedCompoundTaskId?: string;
170
+ } | {
171
+ pageClass: 'editor' | 'renderer';
172
+ /**
173
+ * This is optional as in some scenarios the entry point does not know
174
+ * what type of comment is being selected (e.g. comment navigation, sidebar).
175
+ **/
176
+ commentType?: 'block' | 'inline';
177
+ blockType?: 'media';
178
+ entryPoint: 'keyboard-navigation' | 'comment-navigation';
179
+ linkedCompoundTaskId?: string;
180
+ };
181
+ type ExperienceDebugFunction = (params: {
182
+ createAnalyticsEvent: CreateUIAnalyticsEvent;
183
+ error: Error;
184
+ extraAttributes?: ExperienceAttributes;
185
+ }) => void;
186
+ export type InlineCommentCompoundExperience = {
187
+ start: (params: {
188
+ attributes: InlineCommentAttributes;
189
+ }) => void;
190
+ debug: ExperienceDebugFunction;
191
+ addCommonAttributes: (commonAttributes: ExperienceAttributes) => void;
192
+ attachCommonAttributes: (experienceName: string) => void;
193
+ initExperience: {
194
+ start: () => void;
195
+ fail: (error: Error) => void;
196
+ softFail: (error: Error) => void;
197
+ abort: (params: {
198
+ abortReason: 'Draft annotation removed from document';
199
+ }) => void;
200
+ complete: () => void;
201
+ debug: ExperienceDebugFunction;
202
+ };
203
+ draftToPublishExperience: {
204
+ start: () => void;
205
+ publishFailed: (error: Error) => void;
206
+ publishSucceeded: () => void;
207
+ abort: (params: {
208
+ abortReason: 'Create Comment UI dismissed' | 'Unable to apply annotation to document';
209
+ }) => void;
210
+ fail: (error: Error, attributes?: ExperienceAttributes) => void;
211
+ dismissed: () => void;
212
+ softFail: (error: Error) => void;
213
+ complete: () => void;
214
+ debug: ExperienceDebugFunction;
215
+ debugPoint: (message: string, attributes?: ExperienceAttributes) => void;
216
+ };
217
+ attachCommentExperience: {
218
+ start: () => void;
219
+ fail: (error: Error, attributes?: ExperienceAttributes) => void;
220
+ complete: () => void;
221
+ debug: ExperienceDebugFunction;
222
+ debugPoint: (message: string, attributes?: ExperienceAttributes) => void;
223
+ };
224
+ };
225
+ export type SelectInlineCommentCompoundExperience = {
226
+ _start: (startAttributes: StartAttributes) => void;
227
+ addCommonAttributes: (additionalCommonAttributes: {
228
+ [key: string]: string | number | boolean;
229
+ }) => void;
230
+ abort: (params: {
231
+ abortReason: 'test abort';
232
+ }) => void;
233
+ selectAnnotation: {
234
+ debug: ExperienceDebugFunction;
235
+ start: (startAttributes: StartAttributes) => void;
236
+ abort: (params: {
237
+ abortReason: 'Comment navigation when only one comment';
238
+ }) => void;
239
+ complete: (startAttributes: StartAttributes) => void;
240
+ };
241
+ showComment: {
242
+ debug: ExperienceDebugFunction;
243
+ debugPoint: (message: string, attributes?: {
244
+ [key: string]: string | number | boolean;
245
+ }) => void;
246
+ start: (startAttributes: StartAttributes & {
247
+ annotationId: string;
248
+ }) => void;
249
+ abort: (params: {
250
+ abortReason: 'Non inline comment being shown' | 'Comment sidebar dismissed';
251
+ }) => void;
252
+ fail: (error: Error, extraAttributes?: {
253
+ misalignedBy: number;
254
+ }) => void;
255
+ complete: () => void;
256
+ };
257
+ };
258
+ /**
259
+ * Alternative to SelectInlineCommentCompoundExperience, used for the annotation plugin options
260
+ * in the confluence editor presets. See createFullPageEditorPreset.ts or annotationPluginOptions.ts for usage.
261
+ */
262
+ export type SimpleSelectInlineCommentCompoundExperience = {
263
+ selectAnnotation: {
264
+ complete: (annotationId: string) => void;
265
+ };
266
+ };
155
267
  export {};
@@ -1,4 +1,4 @@
1
1
  export { annotationPlugin } from './annotationPlugin';
2
2
  export type { AnnotationPlugin, AnnotationPluginOptions } from './annotationPluginType';
3
- export type { AnnotationProviders, InlineCommentAnnotationProvider, AnnotationInfo, InlineCommentCreateComponentProps, InlineCommentViewComponentProps, AnnotationState, AnnotationTypeProvider, InlineCommentState, TargetType, InlineCommentInputMethod, } from './types';
3
+ export type { AnnotationInfo, AnnotationProviders, AnnotationState, AnnotationTypeProvider, InlineCommentAnnotationProvider, InlineCommentCompoundExperience, InlineCommentCreateComponentProps, InlineCommentInputMethod, InlineCommentState, InlineCommentViewComponentProps, SelectInlineCommentCompoundExperience, SelectInlineCommentCompoundExperienceEntryPoint, SimpleSelectInlineCommentCompoundExperience, StartAttributes, TargetType, } from './types';
4
4
  export type { InlineCommentMap, InlineCommentPluginState, InlineCommentPluginOptions, InlineCommentAction, } from './pm-plugins/types';
@@ -82,12 +82,50 @@ export type InlineCommentAction = {
82
82
  };
83
83
  };
84
84
  export type InlineCommentPluginState = {
85
+ /**
86
+ * The resolved state of the annotations.
87
+ *
88
+ * The keys are the annotation ids, and the values are booleans indicating whether the annotation is resolved or not.
89
+ *
90
+ * The annotation is only considered unresolved if the value is false. An undefined value is treated as resolved.
91
+ * This is because the editor does not know yet the resolved state of the annotation, and so it is treated as resolved until
92
+ * the editor receives the resolved state from the server. (see dirtyAnnotations for more details)
93
+ *
94
+ * Example value
95
+ * ```
96
+ * {
97
+ * // resolved comments
98
+ * 'annotation-id': true,
99
+ * 'annotation-id-3': undefined,
100
+ * // unresolved comment
101
+ * 'annotation-id-2': false,
102
+ * }
103
+ * ```
104
+ */
85
105
  annotations: InlineCommentMap;
106
+ /**
107
+ * A list of the annotations at the current selection.
108
+ *
109
+ * While this is a list, consumers only make use of the first element, and from the
110
+ * user perspective, there is only one annotation selected at a time.
111
+ */
86
112
  selectedAnnotations: AnnotationInfo[];
113
+ /**
114
+ * Indicates the document has annotations which it does not currently know the resolved state of.
115
+ * This can happen when the annotations are loaded via ncs, and the editor has not received the
116
+ * resolved state of the annotations yet (as the resolved state comes from a separate service).
117
+ */
87
118
  dirtyAnnotations?: boolean;
88
119
  mouseData: InlineCommentMouseData;
89
120
  draftDecorationSet?: DecorationSet;
90
121
  bookmark?: SelectionBookmark;
122
+ /**
123
+ * Warning: This is not the state of annotations which are currently being hovered over,
124
+ * but rather the annotations which have been given a selected like visual state from an
125
+ * editor api.
126
+ * The Comment consumer does this when browsing comments in the sidebar, where it sets
127
+ * a "hovered" state on the annotation, while the comment is hovered in the sidebar.
128
+ */
91
129
  hoveredAnnotations?: AnnotationInfo[];
92
130
  disallowOnWhitespace: boolean;
93
131
  isInlineCommentViewClosed: boolean;
@@ -25,7 +25,7 @@ export declare const resolveDraftBookmark: (editorState: EditorState, bookmark?:
25
25
  * get selection from position to apply new comment for
26
26
  * @return bookmarked positions if they exists, otherwise current selection positions
27
27
  */
28
- export declare function getSelectionPositions(editorState: EditorState, inlineCommentState?: InlineCommentPluginState | null | undefined): Selection;
28
+ export declare function getSelectionPositions(editorState: EditorState, inlineCommentState?: Partial<InlineCommentPluginState> | null | undefined): Selection;
29
29
  export declare const inlineCommentPluginKey: PluginKey<InlineCommentPluginState>;
30
30
  export declare const getPluginState: (state: EditorState) => InlineCommentPluginState | undefined;
31
31
  /**
@@ -1,5 +1,6 @@
1
1
  import type React from 'react';
2
2
  import type { AnnotationTypes } from '@atlaskit/adf-schema';
3
+ import { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next/types';
3
4
  import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
5
  import type { AnnotationUpdateEmitter, AnnotationManager } from '@atlaskit/editor-common/annotation';
5
6
  /**
@@ -104,28 +105,8 @@ export type InlineCommentAnnotationProvider = AnnotationTypeProvider<AnnotationT
104
105
  };
105
106
  export interface AnnotationProviders {
106
107
  inlineComment: InlineCommentAnnotationProvider;
107
- createCommentExperience?: {
108
- start: (_: {
109
- attributes: {
110
- pageClass: 'editor';
111
- commentType: 'inline';
112
- annotationId?: undefined;
113
- } | {
114
- pageClass: 'editor';
115
- commentType: 'block';
116
- blockType: 'media';
117
- annotationId?: undefined;
118
- };
119
- }) => void;
120
- initExperience: {
121
- start: () => void;
122
- };
123
- };
124
- selectCommentExperience?: {
125
- selectAnnotation: {
126
- complete: (annotationId: string) => void;
127
- };
128
- };
108
+ createCommentExperience?: InlineCommentCompoundExperience;
109
+ selectCommentExperience?: SimpleSelectInlineCommentCompoundExperience;
129
110
  annotationManager?: AnnotationManager;
130
111
  }
131
112
  export declare enum AnnotationSelectionType {
@@ -152,4 +133,135 @@ export type DraftBookmark = {
152
133
  head: number;
153
134
  isBlockNode?: boolean;
154
135
  };
136
+ type ExperienceAttributes = {
137
+ [key: string]: string | number | boolean | string[] | number[];
138
+ };
139
+ type InlineCommentAttributes = {
140
+ pageClass: 'editor';
141
+ commentType: 'inline';
142
+ annotationId?: undefined;
143
+ } | {
144
+ pageClass: 'editor';
145
+ commentType: 'block';
146
+ blockType: 'media';
147
+ annotationId?: undefined;
148
+ } | {
149
+ pageClass: 'renderer';
150
+ commentType: 'inline';
151
+ annotationId: string;
152
+ } | {
153
+ pageClass: 'renderer';
154
+ commentType: 'block';
155
+ blockType: 'media';
156
+ annotationId: string;
157
+ };
158
+ export type SelectInlineCommentCompoundExperienceEntryPoint = 'create-comment' | 'annotation-change' | 'comment-navigation' | 'keyboard-navigation' | 'sidebar' | 'unknown:RendererFocus' | 'unknown:InlineComment' | 'unknown:CommentsPanelList';
159
+ export type StartAttributes = {
160
+ pageClass: 'editor' | 'renderer';
161
+ /**
162
+ * This is optional as in some scenarios the entry point does not know
163
+ * what type of comment is being selected (e.g. comment navigation, sidebar).
164
+ **/
165
+ commentType?: 'block' | 'inline';
166
+ blockType?: 'media';
167
+ annotationId: string;
168
+ entryPoint: Exclude<SelectInlineCommentCompoundExperienceEntryPoint, 'keyboard-navigation' | 'comment-navigation'>;
169
+ linkedCompoundTaskId?: string;
170
+ } | {
171
+ pageClass: 'editor' | 'renderer';
172
+ /**
173
+ * This is optional as in some scenarios the entry point does not know
174
+ * what type of comment is being selected (e.g. comment navigation, sidebar).
175
+ **/
176
+ commentType?: 'block' | 'inline';
177
+ blockType?: 'media';
178
+ entryPoint: 'keyboard-navigation' | 'comment-navigation';
179
+ linkedCompoundTaskId?: string;
180
+ };
181
+ type ExperienceDebugFunction = (params: {
182
+ createAnalyticsEvent: CreateUIAnalyticsEvent;
183
+ error: Error;
184
+ extraAttributes?: ExperienceAttributes;
185
+ }) => void;
186
+ export type InlineCommentCompoundExperience = {
187
+ start: (params: {
188
+ attributes: InlineCommentAttributes;
189
+ }) => void;
190
+ debug: ExperienceDebugFunction;
191
+ addCommonAttributes: (commonAttributes: ExperienceAttributes) => void;
192
+ attachCommonAttributes: (experienceName: string) => void;
193
+ initExperience: {
194
+ start: () => void;
195
+ fail: (error: Error) => void;
196
+ softFail: (error: Error) => void;
197
+ abort: (params: {
198
+ abortReason: 'Draft annotation removed from document';
199
+ }) => void;
200
+ complete: () => void;
201
+ debug: ExperienceDebugFunction;
202
+ };
203
+ draftToPublishExperience: {
204
+ start: () => void;
205
+ publishFailed: (error: Error) => void;
206
+ publishSucceeded: () => void;
207
+ abort: (params: {
208
+ abortReason: 'Create Comment UI dismissed' | 'Unable to apply annotation to document';
209
+ }) => void;
210
+ fail: (error: Error, attributes?: ExperienceAttributes) => void;
211
+ dismissed: () => void;
212
+ softFail: (error: Error) => void;
213
+ complete: () => void;
214
+ debug: ExperienceDebugFunction;
215
+ debugPoint: (message: string, attributes?: ExperienceAttributes) => void;
216
+ };
217
+ attachCommentExperience: {
218
+ start: () => void;
219
+ fail: (error: Error, attributes?: ExperienceAttributes) => void;
220
+ complete: () => void;
221
+ debug: ExperienceDebugFunction;
222
+ debugPoint: (message: string, attributes?: ExperienceAttributes) => void;
223
+ };
224
+ };
225
+ export type SelectInlineCommentCompoundExperience = {
226
+ _start: (startAttributes: StartAttributes) => void;
227
+ addCommonAttributes: (additionalCommonAttributes: {
228
+ [key: string]: string | number | boolean;
229
+ }) => void;
230
+ abort: (params: {
231
+ abortReason: 'test abort';
232
+ }) => void;
233
+ selectAnnotation: {
234
+ debug: ExperienceDebugFunction;
235
+ start: (startAttributes: StartAttributes) => void;
236
+ abort: (params: {
237
+ abortReason: 'Comment navigation when only one comment';
238
+ }) => void;
239
+ complete: (startAttributes: StartAttributes) => void;
240
+ };
241
+ showComment: {
242
+ debug: ExperienceDebugFunction;
243
+ debugPoint: (message: string, attributes?: {
244
+ [key: string]: string | number | boolean;
245
+ }) => void;
246
+ start: (startAttributes: StartAttributes & {
247
+ annotationId: string;
248
+ }) => void;
249
+ abort: (params: {
250
+ abortReason: 'Non inline comment being shown' | 'Comment sidebar dismissed';
251
+ }) => void;
252
+ fail: (error: Error, extraAttributes?: {
253
+ misalignedBy: number;
254
+ }) => void;
255
+ complete: () => void;
256
+ };
257
+ };
258
+ /**
259
+ * Alternative to SelectInlineCommentCompoundExperience, used for the annotation plugin options
260
+ * in the confluence editor presets. See createFullPageEditorPreset.ts or annotationPluginOptions.ts for usage.
261
+ */
262
+ export type SimpleSelectInlineCommentCompoundExperience = {
263
+ selectAnnotation: {
264
+ complete: (annotationId: string) => void;
265
+ };
266
+ };
155
267
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-annotation",
3
- "version": "2.7.1",
3
+ "version": "2.7.3",
4
4
  "description": "Annotation plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,7 +32,8 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@atlaskit/adf-schema": "^47.6.0",
35
- "@atlaskit/editor-common": "^103.11.0",
35
+ "@atlaskit/analytics-next": "^11.0.0",
36
+ "@atlaskit/editor-common": "^103.21.0",
36
37
  "@atlaskit/editor-plugin-analytics": "^2.2.0",
37
38
  "@atlaskit/editor-plugin-connectivity": "^2.0.0",
38
39
  "@atlaskit/editor-plugin-editor-viewmode-effects": "^2.0.0",
@@ -41,7 +42,7 @@
41
42
  "@atlaskit/icon": "^25.6.0",
42
43
  "@atlaskit/onboarding": "^14.0.0",
43
44
  "@atlaskit/platform-feature-flags": "^1.1.0",
44
- "@atlaskit/tmp-editor-statsig": "^4.12.0",
45
+ "@atlaskit/tmp-editor-statsig": "^4.15.0",
45
46
  "@babel/runtime": "^7.0.0"
46
47
  },
47
48
  "peerDependencies": {
@@ -49,10 +50,10 @@
49
50
  "react-dom": "^18.2.0"
50
51
  },
51
52
  "devDependencies": {
52
- "@af/integration-testing": "^0.5.0",
53
- "@af/visual-regression": "^1.3.0",
54
- "@atlaskit/ssr": "^0.4.0",
55
- "@atlaskit/visual-regression": "^0.10.0",
53
+ "@af/integration-testing": "workspace:^",
54
+ "@af/visual-regression": "workspace:^",
55
+ "@atlaskit/ssr": "workspace:^",
56
+ "@atlaskit/visual-regression": "workspace:^",
56
57
  "@testing-library/react": "^13.4.0",
57
58
  "typescript": "~5.4.2",
58
59
  "wait-for-expect": "^1.2.0"