@atlaskit/editor-plugin-annotation 2.7.5 → 2.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @atlaskit/editor-plugin-annotation
2
2
 
3
+ ## 2.7.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#142925](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/142925)
8
+ [`e013698350bef`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e013698350bef) -
9
+ This updates the renderer to use the new annotation manager create comment APIs and disables the
10
+ use of the old create hooks. This should be backward compatible and can be controled by a FG
11
+ - [#151999](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/151999)
12
+ [`daf7c638efb95`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/daf7c638efb95) -
13
+ Refactor to use sharedPluginStateHookMigratorFactory
14
+ - Updated dependencies
15
+
3
16
  ## 2.7.5
4
17
 
5
18
  ### Patch Changes
@@ -136,20 +136,29 @@ var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref
136
136
  }
137
137
  };
138
138
  };
139
+ var useAnnotationContentComponentPluginState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (api) {
140
+ var isVisible = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'annotation.isVisible');
141
+ return {
142
+ isVisible: isVisible,
143
+ annotationState: undefined
144
+ };
145
+ }, function (api) {
146
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['annotation']),
147
+ annotationState = _useSharedPluginState.annotationState;
148
+ return {
149
+ isVisible: annotationState === null || annotationState === void 0 ? void 0 : annotationState.isVisible,
150
+ annotationState: annotationState
151
+ };
152
+ });
139
153
  function AnnotationContentComponent(_ref4) {
140
154
  var _api$analytics5;
141
155
  var api = _ref4.api,
142
156
  editorView = _ref4.editorView,
143
157
  annotationProviders = _ref4.annotationProviders,
144
158
  dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent;
145
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['annotation'], {
146
- disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
147
- }),
148
- annotationState = _useSharedPluginState.annotationState;
149
- var isVisibleSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'annotation.isVisible', {
150
- disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
151
- });
152
- var isVisible = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? isVisibleSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.isVisible;
159
+ var _useAnnotationContent = useAnnotationContentComponentPluginState(api),
160
+ isVisible = _useAnnotationContent.isVisible,
161
+ annotationState = _useAnnotationContent.annotationState;
153
162
  if (annotationState && !isVisible && (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)) {
154
163
  return null;
155
164
  }
@@ -147,7 +147,9 @@ var applyDraft = exports.applyDraft = function applyDraft(editorView, options) {
147
147
  return {
148
148
  success: true,
149
149
  // Get the dom element from the newly created annotation and return it here.
150
- targetElement: targetElement
150
+ targetElement: targetElement,
151
+ // In Editor this is undefined, because the editor will update the document.
152
+ actionResult: undefined
151
153
  };
152
154
  };
153
155
  };
@@ -9,11 +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 _hooks = require("@atlaskit/editor-common/hooks");
12
13
  var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
13
14
  var _utils = require("@atlaskit/editor-common/utils");
14
15
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
15
16
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
- var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
17
17
  var _editorCommands = require("../editor-commands");
18
18
  var _utils3 = require("../pm-plugins/utils");
19
19
  var _types = require("../types");
@@ -34,53 +34,66 @@ var findPosForDOM = function findPosForDOM(sel) {
34
34
  }
35
35
  return from;
36
36
  };
37
- function InlineCommentView(_ref) {
38
- var providers = _ref.providers,
39
- editorView = _ref.editorView,
40
- editorAnalyticsAPI = _ref.editorAnalyticsAPI,
41
- editorAPI = _ref.editorAPI,
42
- dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent;
37
+ var useInlineCommentViewPluginState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (_ref) {
38
+ var api = _ref.api;
39
+ // eslint-disable-next-line react-hooks/rules-of-hooks
40
+ var bookmark = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'annotation.bookmark');
41
+ // eslint-disable-next-line react-hooks/rules-of-hooks
42
+ var selectedAnnotations = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'annotation.selectedAnnotations');
43
+ // eslint-disable-next-line react-hooks/rules-of-hooks
44
+ var annotations = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'annotation.annotations');
45
+ // eslint-disable-next-line react-hooks/rules-of-hooks
46
+ var isInlineCommentViewClosed = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'annotation.isInlineCommentViewClosed');
47
+ // eslint-disable-next-line react-hooks/rules-of-hooks
48
+ var isOpeningMediaCommentFromToolbar = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'annotation.isOpeningMediaCommentFromToolbar');
49
+ // eslint-disable-next-line react-hooks/rules-of-hooks
50
+ var selectAnnotationMethod = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'annotation.selectAnnotationMethod');
51
+ return {
52
+ bookmark: bookmark,
53
+ selectedAnnotations: selectedAnnotations,
54
+ annotations: annotations,
55
+ isInlineCommentViewClosed: isInlineCommentViewClosed,
56
+ isOpeningMediaCommentFromToolbar: isOpeningMediaCommentFromToolbar,
57
+ selectAnnotationMethod: selectAnnotationMethod
58
+ };
59
+ }, function (_ref2) {
60
+ var state = _ref2.state;
61
+ var inlineCommentState = (0, _utils3.getPluginState)(state);
62
+ return {
63
+ bookmark: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.bookmark,
64
+ selectedAnnotations: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectedAnnotations,
65
+ annotations: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.annotations,
66
+ isInlineCommentViewClosed: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isInlineCommentViewClosed,
67
+ isOpeningMediaCommentFromToolbar: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isOpeningMediaCommentFromToolbar,
68
+ selectAnnotationMethod: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectAnnotationMethod
69
+ };
70
+ });
71
+ function InlineCommentView(_ref3) {
72
+ var providers = _ref3.providers,
73
+ editorView = _ref3.editorView,
74
+ editorAnalyticsAPI = _ref3.editorAnalyticsAPI,
75
+ editorAPI = _ref3.editorAPI,
76
+ dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent;
43
77
  // As inlineComment is the only annotation present, this function is not generic
44
78
  var inlineCommentProvider = providers.inlineComment;
45
79
  var state = editorView.state,
46
80
  dispatch = editorView.dispatch;
47
81
  var CreateComponent = inlineCommentProvider.createComponent,
48
82
  ViewComponent = inlineCommentProvider.viewComponent;
49
- var inlineCommentState = (0, _utils3.getPluginState)(state);
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;
83
+ var _useInlineCommentView = useInlineCommentViewPluginState({
84
+ api: editorAPI,
85
+ state: state
86
+ }),
87
+ annotations = _useInlineCommentView.annotations,
88
+ bookmark = _useInlineCommentView.bookmark,
89
+ isInlineCommentViewClosed = _useInlineCommentView.isInlineCommentViewClosed,
90
+ isOpeningMediaCommentFromToolbar = _useInlineCommentView.isOpeningMediaCommentFromToolbar,
91
+ selectAnnotationMethod = _useInlineCommentView.selectAnnotationMethod,
92
+ selectedAnnotations = _useInlineCommentView.selectedAnnotations;
80
93
  var annotationsList = (0, _utils3.getAllAnnotations)(editorView.state.doc);
81
- var selection = (0, _utils3.getSelectionPositions)(state, (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? {
94
+ var selection = (0, _utils3.getSelectionPositions)(state, {
82
95
  bookmark: bookmark
83
- } : inlineCommentState);
96
+ });
84
97
  var position = findPosForDOM(selection);
85
98
  var dom;
86
99
  try {
@@ -106,11 +119,6 @@ function InlineCommentView(_ref) {
106
119
  dispatchAnalyticsEvent(payload);
107
120
  }
108
121
  }
109
-
110
- // selectAnnotationMethod
111
- var selectAnnotationMethodSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(editorAPI, 'annotation.selectAnnotationMethod', {
112
- disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
113
- });
114
122
  if (!dom) {
115
123
  return null;
116
124
  }
@@ -175,7 +183,7 @@ function InlineCommentView(_ref) {
175
183
  attributes: {
176
184
  overlap: activeAnnotations.length ? activeAnnotations.length - 1 : 0,
177
185
  targetNodeType: (_editorView$state$doc = editorView.state.doc.nodeAt(position)) === null || _editorView$state$doc === void 0 ? void 0 : _editorView$state$doc.type.name,
178
- method: (0, _experiments.editorExperiment)('platform_editor_tables_table_selector', true) ? selectAnnotationMethodSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectAnnotationMethod
186
+ method: selectAnnotationMethod
179
187
  }
180
188
  };
181
189
  dispatchAnalyticsEvent(payload);
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
2
+ import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
3
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
4
4
  import { fg } from '@atlaskit/platform-feature-flags';
5
5
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
@@ -129,6 +129,21 @@ export const annotationPlugin = ({
129
129
  }
130
130
  };
131
131
  };
132
+ const useAnnotationContentComponentPluginState = sharedPluginStateHookMigratorFactory(api => {
133
+ const isVisible = useSharedPluginStateSelector(api, 'annotation.isVisible');
134
+ return {
135
+ isVisible,
136
+ annotationState: undefined
137
+ };
138
+ }, api => {
139
+ const {
140
+ annotationState
141
+ } = useSharedPluginState(api, ['annotation']);
142
+ return {
143
+ isVisible: annotationState === null || annotationState === void 0 ? void 0 : annotationState.isVisible,
144
+ annotationState
145
+ };
146
+ });
132
147
  function AnnotationContentComponent({
133
148
  api,
134
149
  editorView,
@@ -137,14 +152,9 @@ function AnnotationContentComponent({
137
152
  }) {
138
153
  var _api$analytics5;
139
154
  const {
155
+ isVisible,
140
156
  annotationState
141
- } = useSharedPluginState(api, ['annotation'], {
142
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
143
- });
144
- const isVisibleSelector = useSharedPluginStateSelector(api, 'annotation.isVisible', {
145
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
146
- });
147
- const isVisible = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isVisibleSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.isVisible;
157
+ } = useAnnotationContentComponentPluginState(api);
148
158
  if (annotationState && !isVisible && editorExperiment('platform_editor_usesharedpluginstateselector', false)) {
149
159
  return null;
150
160
  }
@@ -139,7 +139,9 @@ export const applyDraft = (editorView, options) => id => {
139
139
  return {
140
140
  success: true,
141
141
  // Get the dom element from the newly created annotation and return it here.
142
- targetElement
142
+ targetElement,
143
+ // In Editor this is undefined, because the editor will update the document.
144
+ actionResult: undefined
143
145
  };
144
146
  };
145
147
  export const getDraft = (editorView, options) => () => {
@@ -1,11 +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 { sharedPluginStateHookMigratorFactory } from '@atlaskit/editor-common/hooks';
4
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';
8
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
9
9
  import { closeComponent, createAnnotation, removeInlineCommentNearSelection, setInlineCommentDraftState, updateInlineCommentResolvedState } from '../editor-commands';
10
10
  import { getAllAnnotations, getAnnotationViewKey, getPluginState, getSelectionPositions } from '../pm-plugins/utils';
11
11
  import { AnnotationTestIds } from '../types';
@@ -26,6 +26,42 @@ const findPosForDOM = sel => {
26
26
  }
27
27
  return from;
28
28
  };
29
+ const useInlineCommentViewPluginState = sharedPluginStateHookMigratorFactory(({
30
+ api
31
+ }) => {
32
+ // eslint-disable-next-line react-hooks/rules-of-hooks
33
+ const bookmark = useSharedPluginStateSelector(api, 'annotation.bookmark');
34
+ // eslint-disable-next-line react-hooks/rules-of-hooks
35
+ const selectedAnnotations = useSharedPluginStateSelector(api, 'annotation.selectedAnnotations');
36
+ // eslint-disable-next-line react-hooks/rules-of-hooks
37
+ const annotations = useSharedPluginStateSelector(api, 'annotation.annotations');
38
+ // eslint-disable-next-line react-hooks/rules-of-hooks
39
+ const isInlineCommentViewClosed = useSharedPluginStateSelector(api, 'annotation.isInlineCommentViewClosed');
40
+ // eslint-disable-next-line react-hooks/rules-of-hooks
41
+ const isOpeningMediaCommentFromToolbar = useSharedPluginStateSelector(api, 'annotation.isOpeningMediaCommentFromToolbar');
42
+ // eslint-disable-next-line react-hooks/rules-of-hooks
43
+ const selectAnnotationMethod = useSharedPluginStateSelector(api, 'annotation.selectAnnotationMethod');
44
+ return {
45
+ bookmark,
46
+ selectedAnnotations,
47
+ annotations,
48
+ isInlineCommentViewClosed,
49
+ isOpeningMediaCommentFromToolbar,
50
+ selectAnnotationMethod
51
+ };
52
+ }, ({
53
+ state
54
+ }) => {
55
+ const inlineCommentState = getPluginState(state);
56
+ return {
57
+ bookmark: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.bookmark,
58
+ selectedAnnotations: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectedAnnotations,
59
+ annotations: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.annotations,
60
+ isInlineCommentViewClosed: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isInlineCommentViewClosed,
61
+ isOpeningMediaCommentFromToolbar: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isOpeningMediaCommentFromToolbar,
62
+ selectAnnotationMethod: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectAnnotationMethod
63
+ };
64
+ });
29
65
  export function InlineCommentView({
30
66
  providers,
31
67
  editorView,
@@ -45,41 +81,21 @@ export function InlineCommentView({
45
81
  createComponent: CreateComponent,
46
82
  viewComponent: ViewComponent
47
83
  } = inlineCommentProvider;
48
- const inlineCommentState = getPluginState(state);
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)
84
+ const {
85
+ annotations,
86
+ bookmark,
87
+ isInlineCommentViewClosed,
88
+ isOpeningMediaCommentFromToolbar,
89
+ selectAnnotationMethod,
90
+ selectedAnnotations
91
+ } = useInlineCommentViewPluginState({
92
+ api: editorAPI,
93
+ state
77
94
  });
78
- const isOpeningMediaCommentFromToolbar = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isOpeningMediaCommentFromToolbarSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isOpeningMediaCommentFromToolbar;
79
95
  const annotationsList = getAllAnnotations(editorView.state.doc);
80
- const selection = getSelectionPositions(state, editorExperiment('platform_editor_usesharedpluginstateselector', true) ? {
96
+ const selection = getSelectionPositions(state, {
81
97
  bookmark
82
- } : inlineCommentState);
98
+ });
83
99
  const position = findPosForDOM(selection);
84
100
  let dom;
85
101
  try {
@@ -105,11 +121,6 @@ export function InlineCommentView({
105
121
  dispatchAnalyticsEvent(payload);
106
122
  }
107
123
  }
108
-
109
- // selectAnnotationMethod
110
- const selectAnnotationMethodSelector = useSharedPluginStateSelector(editorAPI, 'annotation.selectAnnotationMethod', {
111
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
112
- });
113
124
  if (!dom) {
114
125
  return null;
115
126
  }
@@ -172,7 +183,7 @@ export function InlineCommentView({
172
183
  attributes: {
173
184
  overlap: activeAnnotations.length ? activeAnnotations.length - 1 : 0,
174
185
  targetNodeType: (_editorView$state$doc = editorView.state.doc.nodeAt(position)) === null || _editorView$state$doc === void 0 ? void 0 : _editorView$state$doc.type.name,
175
- method: editorExperiment('platform_editor_tables_table_selector', true) ? selectAnnotationMethodSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectAnnotationMethod
186
+ method: selectAnnotationMethod
176
187
  }
177
188
  };
178
189
  dispatchAnalyticsEvent(payload);
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
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
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
5
+ import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
6
6
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
7
7
  import { fg } from '@atlaskit/platform-feature-flags';
8
8
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
@@ -129,20 +129,29 @@ export var annotationPlugin = function annotationPlugin(_ref) {
129
129
  }
130
130
  };
131
131
  };
132
+ var useAnnotationContentComponentPluginState = sharedPluginStateHookMigratorFactory(function (api) {
133
+ var isVisible = useSharedPluginStateSelector(api, 'annotation.isVisible');
134
+ return {
135
+ isVisible: isVisible,
136
+ annotationState: undefined
137
+ };
138
+ }, function (api) {
139
+ var _useSharedPluginState = useSharedPluginState(api, ['annotation']),
140
+ annotationState = _useSharedPluginState.annotationState;
141
+ return {
142
+ isVisible: annotationState === null || annotationState === void 0 ? void 0 : annotationState.isVisible,
143
+ annotationState: annotationState
144
+ };
145
+ });
132
146
  function AnnotationContentComponent(_ref4) {
133
147
  var _api$analytics5;
134
148
  var api = _ref4.api,
135
149
  editorView = _ref4.editorView,
136
150
  annotationProviders = _ref4.annotationProviders,
137
151
  dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent;
138
- var _useSharedPluginState = useSharedPluginState(api, ['annotation'], {
139
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
140
- }),
141
- annotationState = _useSharedPluginState.annotationState;
142
- var isVisibleSelector = useSharedPluginStateSelector(api, 'annotation.isVisible', {
143
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
144
- });
145
- var isVisible = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isVisibleSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.isVisible;
152
+ var _useAnnotationContent = useAnnotationContentComponentPluginState(api),
153
+ isVisible = _useAnnotationContent.isVisible,
154
+ annotationState = _useAnnotationContent.annotationState;
146
155
  if (annotationState && !isVisible && editorExperiment('platform_editor_usesharedpluginstateselector', false)) {
147
156
  return null;
148
157
  }
@@ -141,7 +141,9 @@ export var applyDraft = function applyDraft(editorView, options) {
141
141
  return {
142
142
  success: true,
143
143
  // Get the dom element from the newly created annotation and return it here.
144
- targetElement: targetElement
144
+ targetElement: targetElement,
145
+ // In Editor this is undefined, because the editor will update the document.
146
+ actionResult: undefined
145
147
  };
146
148
  };
147
149
  };
@@ -2,11 +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 { sharedPluginStateHookMigratorFactory } from '@atlaskit/editor-common/hooks';
5
6
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
6
7
  import { getAnnotationInlineNodeTypes, getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
7
8
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
8
9
  import { fg } from '@atlaskit/platform-feature-flags';
9
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
10
10
  import { closeComponent, createAnnotation, removeInlineCommentNearSelection, setInlineCommentDraftState, updateInlineCommentResolvedState } from '../editor-commands';
11
11
  import { getAllAnnotations, getAnnotationViewKey, getPluginState, getSelectionPositions } from '../pm-plugins/utils';
12
12
  import { AnnotationTestIds } from '../types';
@@ -27,53 +27,66 @@ var findPosForDOM = function findPosForDOM(sel) {
27
27
  }
28
28
  return from;
29
29
  };
30
- export function InlineCommentView(_ref) {
31
- var providers = _ref.providers,
32
- editorView = _ref.editorView,
33
- editorAnalyticsAPI = _ref.editorAnalyticsAPI,
34
- editorAPI = _ref.editorAPI,
35
- dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent;
30
+ var useInlineCommentViewPluginState = sharedPluginStateHookMigratorFactory(function (_ref) {
31
+ var api = _ref.api;
32
+ // eslint-disable-next-line react-hooks/rules-of-hooks
33
+ var bookmark = useSharedPluginStateSelector(api, 'annotation.bookmark');
34
+ // eslint-disable-next-line react-hooks/rules-of-hooks
35
+ var selectedAnnotations = useSharedPluginStateSelector(api, 'annotation.selectedAnnotations');
36
+ // eslint-disable-next-line react-hooks/rules-of-hooks
37
+ var annotations = useSharedPluginStateSelector(api, 'annotation.annotations');
38
+ // eslint-disable-next-line react-hooks/rules-of-hooks
39
+ var isInlineCommentViewClosed = useSharedPluginStateSelector(api, 'annotation.isInlineCommentViewClosed');
40
+ // eslint-disable-next-line react-hooks/rules-of-hooks
41
+ var isOpeningMediaCommentFromToolbar = useSharedPluginStateSelector(api, 'annotation.isOpeningMediaCommentFromToolbar');
42
+ // eslint-disable-next-line react-hooks/rules-of-hooks
43
+ var selectAnnotationMethod = useSharedPluginStateSelector(api, 'annotation.selectAnnotationMethod');
44
+ return {
45
+ bookmark: bookmark,
46
+ selectedAnnotations: selectedAnnotations,
47
+ annotations: annotations,
48
+ isInlineCommentViewClosed: isInlineCommentViewClosed,
49
+ isOpeningMediaCommentFromToolbar: isOpeningMediaCommentFromToolbar,
50
+ selectAnnotationMethod: selectAnnotationMethod
51
+ };
52
+ }, function (_ref2) {
53
+ var state = _ref2.state;
54
+ var inlineCommentState = getPluginState(state);
55
+ return {
56
+ bookmark: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.bookmark,
57
+ selectedAnnotations: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectedAnnotations,
58
+ annotations: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.annotations,
59
+ isInlineCommentViewClosed: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isInlineCommentViewClosed,
60
+ isOpeningMediaCommentFromToolbar: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isOpeningMediaCommentFromToolbar,
61
+ selectAnnotationMethod: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectAnnotationMethod
62
+ };
63
+ });
64
+ export function InlineCommentView(_ref3) {
65
+ var providers = _ref3.providers,
66
+ editorView = _ref3.editorView,
67
+ editorAnalyticsAPI = _ref3.editorAnalyticsAPI,
68
+ editorAPI = _ref3.editorAPI,
69
+ dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent;
36
70
  // As inlineComment is the only annotation present, this function is not generic
37
71
  var inlineCommentProvider = providers.inlineComment;
38
72
  var state = editorView.state,
39
73
  dispatch = editorView.dispatch;
40
74
  var CreateComponent = inlineCommentProvider.createComponent,
41
75
  ViewComponent = inlineCommentProvider.viewComponent;
42
- var inlineCommentState = getPluginState(state);
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;
76
+ var _useInlineCommentView = useInlineCommentViewPluginState({
77
+ api: editorAPI,
78
+ state: state
79
+ }),
80
+ annotations = _useInlineCommentView.annotations,
81
+ bookmark = _useInlineCommentView.bookmark,
82
+ isInlineCommentViewClosed = _useInlineCommentView.isInlineCommentViewClosed,
83
+ isOpeningMediaCommentFromToolbar = _useInlineCommentView.isOpeningMediaCommentFromToolbar,
84
+ selectAnnotationMethod = _useInlineCommentView.selectAnnotationMethod,
85
+ selectedAnnotations = _useInlineCommentView.selectedAnnotations;
73
86
  var annotationsList = getAllAnnotations(editorView.state.doc);
74
- var selection = getSelectionPositions(state, editorExperiment('platform_editor_usesharedpluginstateselector', true) ? {
87
+ var selection = getSelectionPositions(state, {
75
88
  bookmark: bookmark
76
- } : inlineCommentState);
89
+ });
77
90
  var position = findPosForDOM(selection);
78
91
  var dom;
79
92
  try {
@@ -99,11 +112,6 @@ export function InlineCommentView(_ref) {
99
112
  dispatchAnalyticsEvent(payload);
100
113
  }
101
114
  }
102
-
103
- // selectAnnotationMethod
104
- var selectAnnotationMethodSelector = useSharedPluginStateSelector(editorAPI, 'annotation.selectAnnotationMethod', {
105
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
106
- });
107
115
  if (!dom) {
108
116
  return null;
109
117
  }
@@ -168,7 +176,7 @@ export function InlineCommentView(_ref) {
168
176
  attributes: {
169
177
  overlap: activeAnnotations.length ? activeAnnotations.length - 1 : 0,
170
178
  targetNodeType: (_editorView$state$doc = editorView.state.doc.nodeAt(position)) === null || _editorView$state$doc === void 0 ? void 0 : _editorView$state$doc.type.name,
171
- method: editorExperiment('platform_editor_tables_table_selector', true) ? selectAnnotationMethodSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectAnnotationMethod
179
+ method: selectAnnotationMethod
172
180
  }
173
181
  };
174
182
  dispatchAnalyticsEvent(payload);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-annotation",
3
- "version": "2.7.5",
3
+ "version": "2.7.6",
4
4
  "description": "Annotation plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",