@atlaskit/editor-plugin-annotation 4.0.0 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/editor-plugin-annotation
2
2
 
3
+ ## 4.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 4.0.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`b344c1b873169`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b344c1b873169) -
14
+ ED-29098: clean up sharedPluginStateHookMigratorFactory in annotation plugin
15
+ - Updated dependencies
16
+
3
17
  ## 4.0.0
4
18
 
5
19
  ### Patch Changes
@@ -153,21 +153,13 @@ var selector = function selector(states) {
153
153
  annotations: (_states$annotationSta3 = states.annotationState) === null || _states$annotationSta3 === void 0 ? void 0 : _states$annotationSta3.annotations
154
154
  };
155
155
  };
156
- var useAnnotationContentComponentPluginState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (api) {
157
- var annotationState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['annotation'], selector);
158
- return annotationState;
159
- }, function (api) {
160
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['annotation']),
161
- annotationState = _useSharedPluginState.annotationState;
162
- return annotationState;
163
- });
164
156
  function AnnotationContentComponent(_ref4) {
165
157
  var _api$analytics5;
166
158
  var api = _ref4.api,
167
159
  editorView = _ref4.editorView,
168
160
  annotationProviders = _ref4.annotationProviders,
169
161
  dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent;
170
- var annotationState = useAnnotationContentComponentPluginState(api);
162
+ var annotationState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['annotation'], selector);
171
163
  if (annotationState && !annotationState.isVisible && (0, _expValEquals.expValEquals)('platform_editor_usesharedpluginstatewithselector', 'isEnabled', false)) {
172
164
  return null;
173
165
  }
@@ -239,13 +239,9 @@ var resolveDraftBookmark = exports.resolveDraftBookmark = function resolveDraftB
239
239
  };
240
240
  /**
241
241
  * get selection from position to apply new comment for
242
- * @return bookmarked positions if they exists, otherwise current selection positions
242
+ * @returns bookmarked positions if they exists, otherwise current selection positions
243
243
  */
244
- function getSelectionPositions(editorState,
245
- // when cleaning up platform_editor_usesharedpluginstatewithselector, can change this prop to bookmark
246
- inlineCommentState) {
247
- var _ref2 = inlineCommentState || {},
248
- bookmark = _ref2.bookmark;
244
+ function getSelectionPositions(editorState, bookmark) {
249
245
  // get positions via saved bookmark if it is available
250
246
  // this is to make comments box positioned relative to temporary highlight rather then current selection
251
247
  if (bookmark) {
@@ -285,8 +281,8 @@ var getDraftCommandAnalyticsPayload = exports.getDraftCommandAnalyticsPayload =
285
281
  };
286
282
  }
287
283
  if ((0, _platformFeatureFlags.fg)('editor_inline_comments_on_inline_nodes')) {
288
- var _ref3 = getPluginState(state) || {},
289
- bookmark = _ref3.bookmark;
284
+ var _ref2 = getPluginState(state) || {},
285
+ bookmark = _ref2.bookmark;
290
286
  attributes.inlineNodeNames = (0, _utils.getRangeInlineNodeNames)({
291
287
  doc: state.doc,
292
288
  pos: resolveDraftBookmark(state, bookmark)
@@ -306,8 +302,8 @@ var isSelectionValid = exports.isSelectionValid = function isSelectionValid(stat
306
302
  var _currentMediaNodeWith;
307
303
  var _supportedNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
308
304
  var selection = state.selection;
309
- var _ref4 = getPluginState(state) || {},
310
- disallowOnWhitespace = _ref4.disallowOnWhitespace;
305
+ var _ref3 = getPluginState(state) || {},
306
+ disallowOnWhitespace = _ref3.disallowOnWhitespace;
311
307
  var allowedInlineNodes = ['emoji', 'status', 'date', 'mention', 'inlineCard'];
312
308
  var isSelectionEmpty = selection.empty;
313
309
  var isTextOrAllSelection = selection instanceof _state.TextSelection || selection instanceof _state.AllSelection;
@@ -48,37 +48,12 @@ var selector = function selector(states) {
48
48
  isAnnotationManagerEnabled: (_states$annotationSta7 = states.annotationState) === null || _states$annotationSta7 === void 0 ? void 0 : _states$annotationSta7.isAnnotationManagerEnabled
49
49
  };
50
50
  };
51
- var useAnnotationContentComponentPluginState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (_ref) {
52
- var api = _ref.api;
53
- var annotationState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['annotation'], selector);
54
- return annotationState;
55
- }, function (_ref2) {
56
- var _getPluginState;
57
- var state = _ref2.state;
58
- var _ref3 = (_getPluginState = (0, _utils3.getPluginState)(state)) !== null && _getPluginState !== void 0 ? _getPluginState : {},
59
- annotations = _ref3.annotations,
60
- bookmark = _ref3.bookmark,
61
- isInlineCommentViewClosed = _ref3.isInlineCommentViewClosed,
62
- isOpeningMediaCommentFromToolbar = _ref3.isOpeningMediaCommentFromToolbar,
63
- selectAnnotationMethod = _ref3.selectAnnotationMethod,
64
- selectedAnnotations = _ref3.selectedAnnotations,
65
- isAnnotationManagerEnabled = _ref3.isAnnotationManagerEnabled;
66
- return {
67
- annotations: annotations,
68
- bookmark: bookmark,
69
- isInlineCommentViewClosed: isInlineCommentViewClosed,
70
- isOpeningMediaCommentFromToolbar: isOpeningMediaCommentFromToolbar,
71
- selectAnnotationMethod: selectAnnotationMethod,
72
- selectedAnnotations: selectedAnnotations,
73
- isAnnotationManagerEnabled: isAnnotationManagerEnabled
74
- };
75
- });
76
- function InlineCommentView(_ref4) {
77
- var providers = _ref4.providers,
78
- editorView = _ref4.editorView,
79
- editorAnalyticsAPI = _ref4.editorAnalyticsAPI,
80
- editorAPI = _ref4.editorAPI,
81
- dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent;
51
+ function InlineCommentView(_ref) {
52
+ var providers = _ref.providers,
53
+ editorView = _ref.editorView,
54
+ editorAnalyticsAPI = _ref.editorAnalyticsAPI,
55
+ editorAPI = _ref.editorAPI,
56
+ dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent;
82
57
  // As inlineComment is the only annotation present, this function is not generic
83
58
  var inlineCommentProvider = providers.inlineComment;
84
59
  var state = editorView.state,
@@ -86,21 +61,16 @@ function InlineCommentView(_ref4) {
86
61
  var lastSelectedAnnotationId = (0, _react.useRef)();
87
62
  var CreateComponent = inlineCommentProvider.createComponent,
88
63
  ViewComponent = inlineCommentProvider.viewComponent;
89
- var _useAnnotationContent = useAnnotationContentComponentPluginState({
90
- api: editorAPI,
91
- state: state
92
- }),
93
- annotations = _useAnnotationContent.annotations,
94
- bookmark = _useAnnotationContent.bookmark,
95
- isInlineCommentViewClosed = _useAnnotationContent.isInlineCommentViewClosed,
96
- isOpeningMediaCommentFromToolbar = _useAnnotationContent.isOpeningMediaCommentFromToolbar,
97
- selectAnnotationMethod = _useAnnotationContent.selectAnnotationMethod,
98
- selectedAnnotations = _useAnnotationContent.selectedAnnotations,
99
- isAnnotationManagerEnabled = _useAnnotationContent.isAnnotationManagerEnabled;
64
+ var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(editorAPI, ['annotation'], selector),
65
+ annotations = _useSharedPluginState.annotations,
66
+ bookmark = _useSharedPluginState.bookmark,
67
+ isInlineCommentViewClosed = _useSharedPluginState.isInlineCommentViewClosed,
68
+ isOpeningMediaCommentFromToolbar = _useSharedPluginState.isOpeningMediaCommentFromToolbar,
69
+ selectAnnotationMethod = _useSharedPluginState.selectAnnotationMethod,
70
+ selectedAnnotations = _useSharedPluginState.selectedAnnotations,
71
+ isAnnotationManagerEnabled = _useSharedPluginState.isAnnotationManagerEnabled;
100
72
  var annotationsList = (0, _utils3.getAllAnnotations)(editorView.state.doc);
101
- var selection = (0, _utils3.getSelectionPositions)(state, {
102
- bookmark: bookmark
103
- });
73
+ var selection = (0, _utils3.getSelectionPositions)(state, bookmark);
104
74
  var position = findPosForDOM(selection);
105
75
  var dom;
106
76
  try {
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { sharedPluginStateHookMigratorFactory, useSharedPluginState, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
2
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
3
3
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
4
4
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
5
  import { setInlineCommentDraftState, showInlineCommentForBlockNode } from './editor-commands';
@@ -146,15 +146,6 @@ const selector = states => {
146
146
  annotations: (_states$annotationSta3 = states.annotationState) === null || _states$annotationSta3 === void 0 ? void 0 : _states$annotationSta3.annotations
147
147
  };
148
148
  };
149
- const useAnnotationContentComponentPluginState = sharedPluginStateHookMigratorFactory(api => {
150
- const annotationState = useSharedPluginStateWithSelector(api, ['annotation'], selector);
151
- return annotationState;
152
- }, api => {
153
- const {
154
- annotationState
155
- } = useSharedPluginState(api, ['annotation']);
156
- return annotationState;
157
- });
158
149
  function AnnotationContentComponent({
159
150
  api,
160
151
  editorView,
@@ -162,7 +153,7 @@ function AnnotationContentComponent({
162
153
  dispatchAnalyticsEvent
163
154
  }) {
164
155
  var _api$analytics5;
165
- const annotationState = useAnnotationContentComponentPluginState(api);
156
+ const annotationState = useSharedPluginStateWithSelector(api, ['annotation'], selector);
166
157
  if (annotationState && !annotationState.isVisible && expValEquals('platform_editor_usesharedpluginstatewithselector', 'isEnabled', false)) {
167
158
  return null;
168
159
  }
@@ -201,14 +201,9 @@ export const resolveDraftBookmark = (editorState, bookmark, supportedBlockNodes
201
201
  };
202
202
  /**
203
203
  * get selection from position to apply new comment for
204
- * @return bookmarked positions if they exists, otherwise current selection positions
204
+ * @returns bookmarked positions if they exists, otherwise current selection positions
205
205
  */
206
- export function getSelectionPositions(editorState,
207
- // when cleaning up platform_editor_usesharedpluginstatewithselector, can change this prop to bookmark
208
- inlineCommentState) {
209
- const {
210
- bookmark
211
- } = inlineCommentState || {};
206
+ export function getSelectionPositions(editorState, bookmark) {
212
207
  // get positions via saved bookmark if it is available
213
208
  // this is to make comments box positioned relative to temporary highlight rather then current selection
214
209
  if (bookmark) {
@@ -1,13 +1,13 @@
1
1
  import React, { useRef } 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, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
5
5
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
6
6
  import { getAnnotationInlineNodeTypes, getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
7
7
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
8
8
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
9
9
  import { closeComponent, createAnnotation, removeInlineCommentNearSelection, setInlineCommentDraftState, updateInlineCommentResolvedState } from '../editor-commands';
10
- import { getAllAnnotations, getAnnotationViewKey, getPluginState, getSelectionPositions } from '../pm-plugins/utils';
10
+ import { getAllAnnotations, getAnnotationViewKey, getSelectionPositions } from '../pm-plugins/utils';
11
11
  import { AnnotationTestIds } from '../types';
12
12
  import { AnnotationViewWrapper } from './AnnotationViewWrapper';
13
13
  const findPosForDOM = sel => {
@@ -38,34 +38,6 @@ const selector = states => {
38
38
  isAnnotationManagerEnabled: (_states$annotationSta7 = states.annotationState) === null || _states$annotationSta7 === void 0 ? void 0 : _states$annotationSta7.isAnnotationManagerEnabled
39
39
  };
40
40
  };
41
- const useAnnotationContentComponentPluginState = sharedPluginStateHookMigratorFactory(({
42
- api
43
- }) => {
44
- const annotationState = useSharedPluginStateWithSelector(api, ['annotation'], selector);
45
- return annotationState;
46
- }, ({
47
- state
48
- }) => {
49
- var _getPluginState;
50
- const {
51
- annotations,
52
- bookmark,
53
- isInlineCommentViewClosed,
54
- isOpeningMediaCommentFromToolbar,
55
- selectAnnotationMethod,
56
- selectedAnnotations,
57
- isAnnotationManagerEnabled
58
- } = (_getPluginState = getPluginState(state)) !== null && _getPluginState !== void 0 ? _getPluginState : {};
59
- return {
60
- annotations,
61
- bookmark,
62
- isInlineCommentViewClosed,
63
- isOpeningMediaCommentFromToolbar,
64
- selectAnnotationMethod,
65
- selectedAnnotations,
66
- isAnnotationManagerEnabled
67
- };
68
- });
69
41
  export function InlineCommentView({
70
42
  providers,
71
43
  editorView,
@@ -94,14 +66,9 @@ export function InlineCommentView({
94
66
  selectAnnotationMethod,
95
67
  selectedAnnotations,
96
68
  isAnnotationManagerEnabled
97
- } = useAnnotationContentComponentPluginState({
98
- api: editorAPI,
99
- state
100
- });
69
+ } = useSharedPluginStateWithSelector(editorAPI, ['annotation'], selector);
101
70
  const annotationsList = getAllAnnotations(editorView.state.doc);
102
- const selection = getSelectionPositions(state, {
103
- bookmark
104
- });
71
+ const selection = getSelectionPositions(state, bookmark);
105
72
  const position = findPosForDOM(selection);
106
73
  let dom;
107
74
  try {
@@ -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 { sharedPluginStateHookMigratorFactory, useSharedPluginState, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
5
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
6
6
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
7
7
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
8
8
  import { setInlineCommentDraftState, showInlineCommentForBlockNode } from './editor-commands';
@@ -146,21 +146,13 @@ var selector = function selector(states) {
146
146
  annotations: (_states$annotationSta3 = states.annotationState) === null || _states$annotationSta3 === void 0 ? void 0 : _states$annotationSta3.annotations
147
147
  };
148
148
  };
149
- var useAnnotationContentComponentPluginState = sharedPluginStateHookMigratorFactory(function (api) {
150
- var annotationState = useSharedPluginStateWithSelector(api, ['annotation'], selector);
151
- return annotationState;
152
- }, function (api) {
153
- var _useSharedPluginState = useSharedPluginState(api, ['annotation']),
154
- annotationState = _useSharedPluginState.annotationState;
155
- return annotationState;
156
- });
157
149
  function AnnotationContentComponent(_ref4) {
158
150
  var _api$analytics5;
159
151
  var api = _ref4.api,
160
152
  editorView = _ref4.editorView,
161
153
  annotationProviders = _ref4.annotationProviders,
162
154
  dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent;
163
- var annotationState = useAnnotationContentComponentPluginState(api);
155
+ var annotationState = useSharedPluginStateWithSelector(api, ['annotation'], selector);
164
156
  if (annotationState && !annotationState.isVisible && expValEquals('platform_editor_usesharedpluginstatewithselector', 'isEnabled', false)) {
165
157
  return null;
166
158
  }
@@ -222,13 +222,9 @@ export var resolveDraftBookmark = function resolveDraftBookmark(editorState, boo
222
222
  };
223
223
  /**
224
224
  * get selection from position to apply new comment for
225
- * @return bookmarked positions if they exists, otherwise current selection positions
225
+ * @returns bookmarked positions if they exists, otherwise current selection positions
226
226
  */
227
- export function getSelectionPositions(editorState,
228
- // when cleaning up platform_editor_usesharedpluginstatewithselector, can change this prop to bookmark
229
- inlineCommentState) {
230
- var _ref2 = inlineCommentState || {},
231
- bookmark = _ref2.bookmark;
227
+ export function getSelectionPositions(editorState, bookmark) {
232
228
  // get positions via saved bookmark if it is available
233
229
  // this is to make comments box positioned relative to temporary highlight rather then current selection
234
230
  if (bookmark) {
@@ -268,8 +264,8 @@ export var getDraftCommandAnalyticsPayload = function getDraftCommandAnalyticsPa
268
264
  };
269
265
  }
270
266
  if (fg('editor_inline_comments_on_inline_nodes')) {
271
- var _ref3 = getPluginState(state) || {},
272
- bookmark = _ref3.bookmark;
267
+ var _ref2 = getPluginState(state) || {},
268
+ bookmark = _ref2.bookmark;
273
269
  attributes.inlineNodeNames = getRangeInlineNodeNames({
274
270
  doc: state.doc,
275
271
  pos: resolveDraftBookmark(state, bookmark)
@@ -289,8 +285,8 @@ export var isSelectionValid = function isSelectionValid(state) {
289
285
  var _currentMediaNodeWith;
290
286
  var _supportedNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
291
287
  var selection = state.selection;
292
- var _ref4 = getPluginState(state) || {},
293
- disallowOnWhitespace = _ref4.disallowOnWhitespace;
288
+ var _ref3 = getPluginState(state) || {},
289
+ disallowOnWhitespace = _ref3.disallowOnWhitespace;
294
290
  var allowedInlineNodes = ['emoji', 'status', 'date', 'mention', 'inlineCard'];
295
291
  var isSelectionEmpty = selection.empty;
296
292
  var isTextOrAllSelection = selection instanceof TextSelection || selection instanceof AllSelection;
@@ -2,13 +2,13 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React, { useRef } 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, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
5
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
6
6
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
7
7
  import { getAnnotationInlineNodeTypes, getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
8
8
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
9
9
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
10
10
  import { closeComponent, createAnnotation, removeInlineCommentNearSelection, setInlineCommentDraftState, updateInlineCommentResolvedState } from '../editor-commands';
11
- import { getAllAnnotations, getAnnotationViewKey, getPluginState, getSelectionPositions } from '../pm-plugins/utils';
11
+ import { getAllAnnotations, getAnnotationViewKey, getSelectionPositions } from '../pm-plugins/utils';
12
12
  import { AnnotationTestIds } from '../types';
13
13
  import { AnnotationViewWrapper } from './AnnotationViewWrapper';
14
14
  var findPosForDOM = function findPosForDOM(sel) {
@@ -39,37 +39,12 @@ var selector = function selector(states) {
39
39
  isAnnotationManagerEnabled: (_states$annotationSta7 = states.annotationState) === null || _states$annotationSta7 === void 0 ? void 0 : _states$annotationSta7.isAnnotationManagerEnabled
40
40
  };
41
41
  };
42
- var useAnnotationContentComponentPluginState = sharedPluginStateHookMigratorFactory(function (_ref) {
43
- var api = _ref.api;
44
- var annotationState = useSharedPluginStateWithSelector(api, ['annotation'], selector);
45
- return annotationState;
46
- }, function (_ref2) {
47
- var _getPluginState;
48
- var state = _ref2.state;
49
- var _ref3 = (_getPluginState = getPluginState(state)) !== null && _getPluginState !== void 0 ? _getPluginState : {},
50
- annotations = _ref3.annotations,
51
- bookmark = _ref3.bookmark,
52
- isInlineCommentViewClosed = _ref3.isInlineCommentViewClosed,
53
- isOpeningMediaCommentFromToolbar = _ref3.isOpeningMediaCommentFromToolbar,
54
- selectAnnotationMethod = _ref3.selectAnnotationMethod,
55
- selectedAnnotations = _ref3.selectedAnnotations,
56
- isAnnotationManagerEnabled = _ref3.isAnnotationManagerEnabled;
57
- return {
58
- annotations: annotations,
59
- bookmark: bookmark,
60
- isInlineCommentViewClosed: isInlineCommentViewClosed,
61
- isOpeningMediaCommentFromToolbar: isOpeningMediaCommentFromToolbar,
62
- selectAnnotationMethod: selectAnnotationMethod,
63
- selectedAnnotations: selectedAnnotations,
64
- isAnnotationManagerEnabled: isAnnotationManagerEnabled
65
- };
66
- });
67
- export function InlineCommentView(_ref4) {
68
- var providers = _ref4.providers,
69
- editorView = _ref4.editorView,
70
- editorAnalyticsAPI = _ref4.editorAnalyticsAPI,
71
- editorAPI = _ref4.editorAPI,
72
- dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent;
42
+ export function InlineCommentView(_ref) {
43
+ var providers = _ref.providers,
44
+ editorView = _ref.editorView,
45
+ editorAnalyticsAPI = _ref.editorAnalyticsAPI,
46
+ editorAPI = _ref.editorAPI,
47
+ dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent;
73
48
  // As inlineComment is the only annotation present, this function is not generic
74
49
  var inlineCommentProvider = providers.inlineComment;
75
50
  var state = editorView.state,
@@ -77,21 +52,16 @@ export function InlineCommentView(_ref4) {
77
52
  var lastSelectedAnnotationId = useRef();
78
53
  var CreateComponent = inlineCommentProvider.createComponent,
79
54
  ViewComponent = inlineCommentProvider.viewComponent;
80
- var _useAnnotationContent = useAnnotationContentComponentPluginState({
81
- api: editorAPI,
82
- state: state
83
- }),
84
- annotations = _useAnnotationContent.annotations,
85
- bookmark = _useAnnotationContent.bookmark,
86
- isInlineCommentViewClosed = _useAnnotationContent.isInlineCommentViewClosed,
87
- isOpeningMediaCommentFromToolbar = _useAnnotationContent.isOpeningMediaCommentFromToolbar,
88
- selectAnnotationMethod = _useAnnotationContent.selectAnnotationMethod,
89
- selectedAnnotations = _useAnnotationContent.selectedAnnotations,
90
- isAnnotationManagerEnabled = _useAnnotationContent.isAnnotationManagerEnabled;
55
+ var _useSharedPluginState = useSharedPluginStateWithSelector(editorAPI, ['annotation'], selector),
56
+ annotations = _useSharedPluginState.annotations,
57
+ bookmark = _useSharedPluginState.bookmark,
58
+ isInlineCommentViewClosed = _useSharedPluginState.isInlineCommentViewClosed,
59
+ isOpeningMediaCommentFromToolbar = _useSharedPluginState.isOpeningMediaCommentFromToolbar,
60
+ selectAnnotationMethod = _useSharedPluginState.selectAnnotationMethod,
61
+ selectedAnnotations = _useSharedPluginState.selectedAnnotations,
62
+ isAnnotationManagerEnabled = _useSharedPluginState.isAnnotationManagerEnabled;
91
63
  var annotationsList = getAllAnnotations(editorView.state.doc);
92
- var selection = getSelectionPositions(state, {
93
- bookmark: bookmark
94
- });
64
+ var selection = getSelectionPositions(state, bookmark);
95
65
  var position = findPosForDOM(selection);
96
66
  var dom;
97
67
  try {
@@ -22,9 +22,9 @@ export declare const findAnnotationsInSelection: (selection: Selection, doc: Nod
22
22
  export declare const resolveDraftBookmark: (editorState: EditorState, bookmark?: SelectionBookmark, supportedBlockNodes?: string[]) => DraftBookmark;
23
23
  /**
24
24
  * get selection from position to apply new comment for
25
- * @return bookmarked positions if they exists, otherwise current selection positions
25
+ * @returns bookmarked positions if they exists, otherwise current selection positions
26
26
  */
27
- export declare function getSelectionPositions(editorState: EditorState, inlineCommentState?: Partial<InlineCommentPluginState> | null | undefined): Selection;
27
+ export declare function getSelectionPositions(editorState: EditorState, bookmark: SelectionBookmark | undefined): Selection;
28
28
  export declare const inlineCommentPluginKey: PluginKey<InlineCommentPluginState>;
29
29
  export declare const getPluginState: (state: EditorState) => InlineCommentPluginState | undefined;
30
30
  /**
@@ -22,9 +22,9 @@ export declare const findAnnotationsInSelection: (selection: Selection, doc: Nod
22
22
  export declare const resolveDraftBookmark: (editorState: EditorState, bookmark?: SelectionBookmark, supportedBlockNodes?: string[]) => DraftBookmark;
23
23
  /**
24
24
  * get selection from position to apply new comment for
25
- * @return bookmarked positions if they exists, otherwise current selection positions
25
+ * @returns bookmarked positions if they exists, otherwise current selection positions
26
26
  */
27
- export declare function getSelectionPositions(editorState: EditorState, inlineCommentState?: Partial<InlineCommentPluginState> | null | undefined): Selection;
27
+ export declare function getSelectionPositions(editorState: EditorState, bookmark: SelectionBookmark | undefined): Selection;
28
28
  export declare const inlineCommentPluginKey: PluginKey<InlineCommentPluginState>;
29
29
  export declare const getPluginState: (state: EditorState) => InlineCommentPluginState | undefined;
30
30
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-annotation",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "Annotation plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,19 +33,19 @@
33
33
  "@atlaskit/editor-plugin-connectivity": "^4.0.0",
34
34
  "@atlaskit/editor-plugin-editor-viewmode-effects": "^4.0.0",
35
35
  "@atlaskit/editor-plugin-feature-flags": "^3.0.0",
36
- "@atlaskit/editor-plugin-toolbar": "^1.0.0",
36
+ "@atlaskit/editor-plugin-toolbar": "^1.1.0",
37
37
  "@atlaskit/editor-prosemirror": "7.0.0",
38
- "@atlaskit/editor-toolbar": "^0.6.0",
38
+ "@atlaskit/editor-toolbar": "^0.7.0",
39
39
  "@atlaskit/editor-toolbar-model": "^0.2.0",
40
40
  "@atlaskit/icon": "^28.1.0",
41
41
  "@atlaskit/onboarding": "^14.3.0",
42
42
  "@atlaskit/platform-feature-flags": "^1.1.0",
43
- "@atlaskit/tmp-editor-statsig": "^12.0.0",
43
+ "@atlaskit/tmp-editor-statsig": "^12.2.0",
44
44
  "@babel/runtime": "^7.0.0",
45
45
  "react-intl-next": "npm:react-intl@^5.18.1"
46
46
  },
47
47
  "peerDependencies": {
48
- "@atlaskit/editor-common": "^108.0.0",
48
+ "@atlaskit/editor-common": "^108.1.0",
49
49
  "react": "^18.2.0",
50
50
  "react-dom": "^18.2.0"
51
51
  },