@atlaskit/renderer 118.6.5 → 118.6.7

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,24 @@
1
1
  # @atlaskit/renderer
2
2
 
3
+ ## 118.6.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [#165439](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/165439)
8
+ [`1b15e228a1e86`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1b15e228a1e86) -
9
+ Fixed an issue which meant the new annotation manager still realied on a FG to be enabled when in
10
+ fact it should be enabled if an instance of the manager is supplied. Thie removed all dependencies
11
+ relying on the FG.
12
+
13
+ ## 118.6.6
14
+
15
+ ### Patch Changes
16
+
17
+ - [#163587](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/163587)
18
+ [`59a3ee21507aa`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/59a3ee21507aa) -
19
+ EDITOR-835 - Can not start another draft after starting a draft in renderer
20
+ - Updated dependencies
21
+
3
22
  ## 118.6.5
4
23
 
5
24
  ### Patch Changes
@@ -62,7 +62,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
62
62
  var NORMAL_SEVERITY_THRESHOLD = exports.NORMAL_SEVERITY_THRESHOLD = 2000;
63
63
  var DEGRADED_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = 3000;
64
64
  var packageName = "@atlaskit/renderer";
65
- var packageVersion = "118.6.5";
65
+ var packageVersion = "118.6.7";
66
66
  var setAsQueryContainerStyles = (0, _react2.css)({
67
67
  containerName: 'ak-renderer-wrapper',
68
68
  containerType: 'inline-size'
@@ -128,9 +128,11 @@ var MarkComponent = exports.MarkComponent = function MarkComponent(_ref) {
128
128
  return (0, _toConsumableArray2.default)(new Set([].concat((0, _toConsumableArray2.default)(annotationParentIds), [id])));
129
129
  }, [id, annotationParentIds]);
130
130
  var _useAnnotationManager = (0, _AnnotationManagerContext.useAnnotationManagerDispatch)(),
131
+ annotationManager = _useAnnotationManager.annotationManager,
131
132
  dispatch = _useAnnotationManager.dispatch;
132
133
  var _useAnnotationManager2 = (0, _AnnotationManagerContext.useAnnotationManagerState)(),
133
134
  currentSelectedAnnotationId = _useAnnotationManager2.currentSelectedAnnotationId;
135
+ var isAnnotationManagerEnabled = !!annotationManager;
134
136
 
135
137
  // after creating a new annotation, we need to set the markRef to the new mark
136
138
  var markRef = (0, _react.useCallback)(function (node) {
@@ -169,7 +171,7 @@ var MarkComponent = exports.MarkComponent = function MarkComponent(_ref) {
169
171
  // prevents from opening link URL inside webView in Safari
170
172
  event.preventDefault();
171
173
  }
172
- if ((0, _platformFeatureFlags.fg)('platform_editor_comments_api_manager')) {
174
+ if (isAnnotationManagerEnabled) {
173
175
  // currentTarget is the right element if there are multiple overlapping annotations
174
176
  // Ignored via go/ees005
175
177
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
@@ -185,7 +187,7 @@ var MarkComponent = exports.MarkComponent = function MarkComponent(_ref) {
185
187
  annotationIds: annotationIds
186
188
  });
187
189
  }
188
- }, [annotationIds, onClick, state]);
190
+ }, [annotationIds, onClick, state, isAnnotationManagerEnabled]);
189
191
  var onMarkEnter = function onMarkEnter(evt) {
190
192
  var _document$activeEleme;
191
193
  var focusedElementTag = (_document$activeEleme = document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.tagName;
@@ -12,7 +12,6 @@ var _types = require("@atlaskit/editor-common/types");
12
12
  var _adfSchema = require("@atlaskit/adf-schema");
13
13
  var _analytics = require("@atlaskit/editor-common/analytics");
14
14
  var _types2 = require("@atlaskit/analytics-listeners/types");
15
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
15
  var _AnnotationManagerContext = require("../contexts/AnnotationManagerContext");
17
16
  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; }
18
17
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -24,9 +23,11 @@ var useAnnotationStateByTypeEvent = exports.useAnnotationStateByTypeEvent = func
24
23
  states = _useState2[0],
25
24
  setStates = _useState2[1];
26
25
  var _useAnnotationManager = (0, _AnnotationManagerContext.useAnnotationManagerDispatch)(),
26
+ annotationManager = _useAnnotationManager.annotationManager,
27
27
  dispatch = _useAnnotationManager.dispatch;
28
28
  var _useAnnotationManager2 = (0, _AnnotationManagerContext.useAnnotationManagerState)(),
29
29
  annotations = _useAnnotationManager2.annotations;
30
+ var isAnnotationManagerEnabled = !!annotationManager;
30
31
  (0, _react.useLayoutEffect)(function () {
31
32
  if (!updateSubscriber) {
32
33
  return;
@@ -45,19 +46,19 @@ var useAnnotationStateByTypeEvent = exports.useAnnotationStateByTypeEvent = func
45
46
  }, {});
46
47
  setStates(_objectSpread(_objectSpread({}, states), nextStates));
47
48
  };
48
- if (!(0, _platformFeatureFlags.fg)('platform_editor_comments_api_manager')) {
49
+ if (!isAnnotationManagerEnabled) {
49
50
  updateSubscriber.on(_types.AnnotationUpdateEvent.SET_ANNOTATION_STATE, cb);
50
51
  return function () {
51
52
  updateSubscriber.off(_types.AnnotationUpdateEvent.SET_ANNOTATION_STATE, cb);
52
53
  };
53
54
  }
54
- }, [states, type, updateSubscriber, dispatch]);
55
+ }, [states, type, updateSubscriber, dispatch, isAnnotationManagerEnabled]);
55
56
  var annotationMarkStates = (0, _react.useMemo)(function () {
56
57
  return Object.values(annotations).reduce(function (acc, curr) {
57
58
  return _objectSpread(_objectSpread({}, acc), {}, (0, _defineProperty2.default)({}, curr.id, curr.markState));
58
59
  }, {});
59
60
  }, [annotations]);
60
- if ((0, _platformFeatureFlags.fg)('platform_editor_comments_api_manager')) {
61
+ if (isAnnotationManagerEnabled) {
61
62
  return annotationMarkStates;
62
63
  } else {
63
64
  return states;
@@ -77,6 +78,9 @@ var useHasFocusEvent = exports.useHasFocusEvent = function useHasFocusEvent(_ref
77
78
  var _useAnnotationManager3 = (0, _AnnotationManagerContext.useAnnotationManagerState)(),
78
79
  currentSelectedAnnotationId = _useAnnotationManager3.currentSelectedAnnotationId,
79
80
  currentHoveredAnnotationId = _useAnnotationManager3.currentHoveredAnnotationId;
81
+ var _useAnnotationManager4 = (0, _AnnotationManagerContext.useAnnotationManagerDispatch)(),
82
+ annotationManager = _useAnnotationManager4.annotationManager;
83
+ var isAnnotationManagerEnabled = !!annotationManager;
80
84
  (0, _react.useLayoutEffect)(function () {
81
85
  if (!updateSubscriber) {
82
86
  return;
@@ -99,7 +103,7 @@ var useHasFocusEvent = exports.useHasFocusEvent = function useHasFocusEvent(_ref
99
103
  document.activeElement.blur();
100
104
  }
101
105
  };
102
- if (!(0, _platformFeatureFlags.fg)('platform_editor_comments_api_manager')) {
106
+ if (!isAnnotationManagerEnabled) {
103
107
  updateSubscriber.on(_types.AnnotationUpdateEvent.SET_ANNOTATION_FOCUS, cb);
104
108
  updateSubscriber.on(_types.AnnotationUpdateEvent.SET_ANNOTATION_HOVERED, callbackForHoveredAnnotation);
105
109
  updateSubscriber.on(_types.AnnotationUpdateEvent.REMOVE_ANNOTATION_FOCUS, removeFocus);
@@ -111,8 +115,8 @@ var useHasFocusEvent = exports.useHasFocusEvent = function useHasFocusEvent(_ref
111
115
  updateSubscriber.off(_types.AnnotationUpdateEvent.SET_ANNOTATION_HOVERED, removeHoverEffect);
112
116
  };
113
117
  }
114
- }, [id, updateSubscriber]);
115
- if ((0, _platformFeatureFlags.fg)('platform_editor_comments_api_manager')) {
118
+ }, [id, updateSubscriber, isAnnotationManagerEnabled]);
119
+ if (isAnnotationManagerEnabled) {
116
120
  return {
117
121
  hasFocus: currentSelectedAnnotationId === id,
118
122
  isHovered: currentHoveredAnnotationId === id
@@ -136,9 +140,12 @@ var useAnnotationClickEvent = exports.useAnnotationClickEvent = function useAnno
136
140
  var updateSubscriber = props.updateSubscriber,
137
141
  createAnalyticsEvent = props.createAnalyticsEvent,
138
142
  isNestedRender = props.isNestedRender;
139
- var _useAnnotationManager4 = (0, _AnnotationManagerContext.useAnnotationManagerState)(),
140
- currentSelectedAnnotationId = _useAnnotationManager4.currentSelectedAnnotationId,
141
- currentSelectedMarkRef = _useAnnotationManager4.currentSelectedMarkRef;
143
+ var _useAnnotationManager5 = (0, _AnnotationManagerContext.useAnnotationManagerDispatch)(),
144
+ annotationManager = _useAnnotationManager5.annotationManager;
145
+ var isAnnotationManagerEnabled = !!annotationManager;
146
+ var _useAnnotationManager6 = (0, _AnnotationManagerContext.useAnnotationManagerState)(),
147
+ currentSelectedAnnotationId = _useAnnotationManager6.currentSelectedAnnotationId,
148
+ currentSelectedMarkRef = _useAnnotationManager6.currentSelectedMarkRef;
142
149
  var selectedAnnotation = (0, _react.useMemo)(function () {
143
150
  return currentSelectedAnnotationId && currentSelectedMarkRef && currentSelectedMarkRef.id === currentSelectedAnnotationId ? {
144
151
  annotations: [{
@@ -196,7 +203,7 @@ var useAnnotationClickEvent = exports.useAnnotationClickEvent = function useAnno
196
203
  document.activeElement.blur();
197
204
  }
198
205
  };
199
- if (!(0, _platformFeatureFlags.fg)('platform_editor_comments_api_manager')) {
206
+ if (!isAnnotationManagerEnabled) {
200
207
  updateSubscriber.on(_types.AnnotationUpdateEvent.ON_ANNOTATION_CLICK, clickCb);
201
208
  updateSubscriber.on(_types.AnnotationUpdateEvent.DESELECT_ANNOTATIONS, deselectCb);
202
209
  return function () {
@@ -204,8 +211,8 @@ var useAnnotationClickEvent = exports.useAnnotationClickEvent = function useAnno
204
211
  updateSubscriber.off(_types.AnnotationUpdateEvent.DESELECT_ANNOTATIONS, deselectCb);
205
212
  };
206
213
  }
207
- }, [updateSubscriber, createAnalyticsEvent, isNestedRender]);
208
- if ((0, _platformFeatureFlags.fg)('platform_editor_comments_api_manager')) {
214
+ }, [updateSubscriber, createAnalyticsEvent, isNestedRender, isAnnotationManagerEnabled]);
215
+ if (isAnnotationManagerEnabled) {
209
216
  return isNestedRender ? null : selectedAnnotation;
210
217
  } else {
211
218
  return annotationClickEvent;
@@ -21,7 +21,9 @@ var useLoadAnnotations = exports.useLoadAnnotations = function useLoadAnnotation
21
21
  var actions = (0, _react.useContext)(_RendererActionsContext.RendererContext);
22
22
  var providers = (0, _react.useContext)(_context.ProvidersContext);
23
23
  var _useAnnotationManager = (0, _AnnotationManagerContext.useAnnotationManagerDispatch)(),
24
+ annotationManager = _useAnnotationManager.annotationManager,
24
25
  dispatch = _useAnnotationManager.dispatch;
26
+ var isAnnotationManagerEnabled = !!annotationManager;
25
27
  (0, _react.useEffect)(function () {
26
28
  if (!providers) {
27
29
  return;
@@ -51,7 +53,7 @@ var useLoadAnnotations = exports.useLoadAnnotations = function useLoadAnnotation
51
53
  var payload = data.reduce(function (acc, value) {
52
54
  return _objectSpread(_objectSpread({}, acc), {}, (0, _defineProperty2.default)({}, value.id, value));
53
55
  }, {});
54
- if ((0, _platformFeatureFlags.fg)('platform_editor_comments_api_manager')) {
56
+ if (isAnnotationManagerEnabled) {
55
57
  dispatch({
56
58
  type: 'loadAnnotation',
57
59
  data: Object.keys(payload).map(function (id) {
@@ -72,5 +74,5 @@ var useLoadAnnotations = exports.useLoadAnnotations = function useLoadAnnotation
72
74
  });
73
75
  };
74
76
  inlineCommentGetState(ids, isNestedRender).then(cb);
75
- }, [actions, providers, adfDocument, isNestedRender, onLoadComplete, dispatch]);
77
+ }, [actions, providers, adfDocument, isNestedRender, onLoadComplete, dispatch, isAnnotationManagerEnabled]);
76
78
  };
@@ -9,6 +9,7 @@ var _AnnotationRangeContext = require("../contexts/AnnotationRangeContext");
9
9
  var _utils = require("./utils");
10
10
  var _steps = require("../../../steps");
11
11
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
+ var _AnnotationManagerContext = require("../contexts/AnnotationManagerContext");
12
13
  var useUserSelectionRange = exports.useUserSelectionRange = function useUserSelectionRange(props) {
13
14
  var rendererDOM = props.rendererRef.current;
14
15
  var selectionTimeoutRef = (0, _react.useRef)();
@@ -19,7 +20,10 @@ var useUserSelectionRange = exports.useUserSelectionRange = function useUserSele
19
20
  range = _useAnnotationRangeSt.range,
20
21
  type = _useAnnotationRangeSt.type,
21
22
  selectionDraftRange = _useAnnotationRangeSt.selectionDraftRange;
23
+ var _useAnnotationManager = (0, _AnnotationManagerContext.useAnnotationManagerDispatch)(),
24
+ annotationManager = _useAnnotationManager.annotationManager;
22
25
  var lastRangeRef = (0, _react.useRef)(null);
26
+ var isAnnotationManagerEnabled = !!annotationManager;
23
27
  var onSelectionChange = (0, _react.useCallback)(function (event) {
24
28
  if ((0, _platformFeatureFlags.fg)('platform_renderer_triple_click_selects_paragraph')) {
25
29
  if (selectionTimeoutRef.current) {
@@ -29,6 +33,9 @@ var useUserSelectionRange = exports.useUserSelectionRange = function useUserSele
29
33
  var sel = document.getSelection();
30
34
  if (!sel || sel.type !== 'Range' || sel.rangeCount !== 1) {
31
35
  lastRangeRef.current = null; // Clear last range if selection is invalid
36
+ if (isAnnotationManagerEnabled) {
37
+ clearSelectionRange();
38
+ }
32
39
  return;
33
40
  }
34
41
  var _range = sel.getRangeAt(0);
@@ -66,6 +73,9 @@ var useUserSelectionRange = exports.useUserSelectionRange = function useUserSele
66
73
  selectionTimeoutRef.current = setTimeout(function () {
67
74
  var sel = document.getSelection();
68
75
  if (!sel || sel.type !== 'Range' || sel.rangeCount !== 1) {
76
+ if (isAnnotationManagerEnabled) {
77
+ clearSelectionRange();
78
+ }
69
79
  return;
70
80
  }
71
81
  var _range = sel.getRangeAt(0);
@@ -100,7 +110,7 @@ var useUserSelectionRange = exports.useUserSelectionRange = function useUserSele
100
110
  }
101
111
  }, 250);
102
112
  }
103
- }, [rendererDOM, setSelectionRange]);
113
+ }, [rendererDOM, setSelectionRange, clearSelectionRange, isAnnotationManagerEnabled]);
104
114
  (0, _react.useEffect)(function () {
105
115
  if (!document || !rendererDOM) {
106
116
  return;
@@ -67,6 +67,7 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
67
67
  var onCreateCallback = (0, _react.useCallback)(function (annotationId) {
68
68
  // We want to support creation on a documentPosition if the user is only using ranges
69
69
  // but we want to prioritize draft positions if they are being used by consumers
70
+ // !!! at this point, the documentPosition can be the wrong position if the user select something else
70
71
  var positionToAnnotate = selectionDraftDocumentPosition || documentPosition;
71
72
  if (!positionToAnnotate || !applyAnnotation) {
72
73
  // TODO: EDITOR-595 - This analytic event is temporary and should be removed once the following issue
@@ -169,7 +170,12 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
169
170
  }
170
171
  }
171
172
  });
172
- var positionToAnnotate = selectionDraftDocumentPosition || documentPosition;
173
+
174
+ // at this point, the documentPosition is the position that the user has selected,
175
+ // not the selectionDraftDocumentPosition
176
+ // because the documentPosition is not promoted to selectionDraftDocumentPosition yet
177
+ // use platform_editor_comments_api_manager here so we can clear the code path when the flag is removed
178
+ var positionToAnnotate = (0, _platformFeatureFlags.fg)('platform_editor_comments_api_manager') ? documentPosition : selectionDraftDocumentPosition || documentPosition;
173
179
  if (!positionToAnnotate || !applyAnnotation || !options.annotationId) {
174
180
  return false;
175
181
  }
@@ -219,12 +225,9 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
219
225
  if (annotationManager) {
220
226
  var startDraft = function startDraft() {
221
227
  var _result$inlineNodeTyp;
222
- if (isDrafting) {
223
- return {
224
- success: false,
225
- reason: 'draft-in-progress'
226
- };
227
- }
228
+ // if there is a draft in progress, we ignore it and start a new draft
229
+ // this is because clearing the draft will remove the mark node from the DOM, which will cause the selection range to be invalid
230
+
228
231
  var id = (0, _v.default)();
229
232
  var result = applyDraftModeCallback({
230
233
  annotationId: id,
@@ -26,6 +26,8 @@ var SelectionRangeValidator = exports.SelectionRangeValidator = function Selecti
26
26
  draftRange = _useUserSelectionRang2[2],
27
27
  clearRange = _useUserSelectionRang2[3];
28
28
  var selectionRange = type === 'selection' ? range : null;
29
+
30
+ // !!! the draft range will become invalid after the mark DOM is inserted
29
31
  if (!selectionRange && !draftRange) {
30
32
  return null;
31
33
  }
@@ -48,7 +48,7 @@ import { PortalContext } from './PortalContext';
48
48
  export const NORMAL_SEVERITY_THRESHOLD = 2000;
49
49
  export const DEGRADED_SEVERITY_THRESHOLD = 3000;
50
50
  const packageName = "@atlaskit/renderer";
51
- const packageVersion = "118.6.5";
51
+ const packageVersion = "118.6.7";
52
52
  const setAsQueryContainerStyles = css({
53
53
  containerName: 'ak-renderer-wrapper',
54
54
  containerType: 'inline-size'
@@ -133,11 +133,13 @@ export const MarkComponent = ({
133
133
  const intl = useIntl();
134
134
  const annotationIds = useMemo(() => [...new Set([...annotationParentIds, id])], [id, annotationParentIds]);
135
135
  const {
136
+ annotationManager,
136
137
  dispatch
137
138
  } = useAnnotationManagerDispatch();
138
139
  const {
139
140
  currentSelectedAnnotationId
140
141
  } = useAnnotationManagerState();
142
+ const isAnnotationManagerEnabled = !!annotationManager;
141
143
 
142
144
  // after creating a new annotation, we need to set the markRef to the new mark
143
145
  const markRef = useCallback(node => {
@@ -176,7 +178,7 @@ export const MarkComponent = ({
176
178
  // prevents from opening link URL inside webView in Safari
177
179
  event.preventDefault();
178
180
  }
179
- if (fg('platform_editor_comments_api_manager')) {
181
+ if (isAnnotationManagerEnabled) {
180
182
  // currentTarget is the right element if there are multiple overlapping annotations
181
183
  // Ignored via go/ees005
182
184
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
@@ -192,7 +194,7 @@ export const MarkComponent = ({
192
194
  annotationIds
193
195
  });
194
196
  }
195
- }, [annotationIds, onClick, state]);
197
+ }, [annotationIds, onClick, state, isAnnotationManagerEnabled]);
196
198
  const onMarkEnter = evt => {
197
199
  var _document$activeEleme;
198
200
  const focusedElementTag = (_document$activeEleme = document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.tagName;
@@ -3,7 +3,6 @@ import { AnnotationUpdateEvent } from '@atlaskit/editor-common/types';
3
3
  import { AnnotationTypes } from '@atlaskit/adf-schema';
4
4
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
5
5
  import { FabricChannel } from '@atlaskit/analytics-listeners/types';
6
- import { fg } from '@atlaskit/platform-feature-flags';
7
6
  import { useAnnotationManagerDispatch, useAnnotationManagerState } from '../contexts/AnnotationManagerContext';
8
7
  export const useAnnotationStateByTypeEvent = ({
9
8
  type,
@@ -11,11 +10,13 @@ export const useAnnotationStateByTypeEvent = ({
11
10
  }) => {
12
11
  const [states, setStates] = useState({});
13
12
  const {
13
+ annotationManager,
14
14
  dispatch
15
15
  } = useAnnotationManagerDispatch();
16
16
  const {
17
17
  annotations
18
18
  } = useAnnotationManagerState();
19
+ const isAnnotationManagerEnabled = !!annotationManager;
19
20
  useLayoutEffect(() => {
20
21
  if (!updateSubscriber) {
21
22
  return;
@@ -40,13 +41,13 @@ export const useAnnotationStateByTypeEvent = ({
40
41
  ...nextStates
41
42
  });
42
43
  };
43
- if (!fg('platform_editor_comments_api_manager')) {
44
+ if (!isAnnotationManagerEnabled) {
44
45
  updateSubscriber.on(AnnotationUpdateEvent.SET_ANNOTATION_STATE, cb);
45
46
  return () => {
46
47
  updateSubscriber.off(AnnotationUpdateEvent.SET_ANNOTATION_STATE, cb);
47
48
  };
48
49
  }
49
- }, [states, type, updateSubscriber, dispatch]);
50
+ }, [states, type, updateSubscriber, dispatch, isAnnotationManagerEnabled]);
50
51
  const annotationMarkStates = useMemo(() => {
51
52
  return Object.values(annotations).reduce((acc, curr) => {
52
53
  return {
@@ -55,7 +56,7 @@ export const useAnnotationStateByTypeEvent = ({
55
56
  };
56
57
  }, {});
57
58
  }, [annotations]);
58
- if (fg('platform_editor_comments_api_manager')) {
59
+ if (isAnnotationManagerEnabled) {
59
60
  return annotationMarkStates;
60
61
  } else {
61
62
  return states;
@@ -71,6 +72,10 @@ export const useHasFocusEvent = ({
71
72
  currentSelectedAnnotationId,
72
73
  currentHoveredAnnotationId
73
74
  } = useAnnotationManagerState();
75
+ const {
76
+ annotationManager
77
+ } = useAnnotationManagerDispatch();
78
+ const isAnnotationManagerEnabled = !!annotationManager;
74
79
  useLayoutEffect(() => {
75
80
  if (!updateSubscriber) {
76
81
  return;
@@ -93,7 +98,7 @@ export const useHasFocusEvent = ({
93
98
  document.activeElement.blur();
94
99
  }
95
100
  };
96
- if (!fg('platform_editor_comments_api_manager')) {
101
+ if (!isAnnotationManagerEnabled) {
97
102
  updateSubscriber.on(AnnotationUpdateEvent.SET_ANNOTATION_FOCUS, cb);
98
103
  updateSubscriber.on(AnnotationUpdateEvent.SET_ANNOTATION_HOVERED, callbackForHoveredAnnotation);
99
104
  updateSubscriber.on(AnnotationUpdateEvent.REMOVE_ANNOTATION_FOCUS, removeFocus);
@@ -105,8 +110,8 @@ export const useHasFocusEvent = ({
105
110
  updateSubscriber.off(AnnotationUpdateEvent.SET_ANNOTATION_HOVERED, removeHoverEffect);
106
111
  };
107
112
  }
108
- }, [id, updateSubscriber]);
109
- if (fg('platform_editor_comments_api_manager')) {
113
+ }, [id, updateSubscriber, isAnnotationManagerEnabled]);
114
+ if (isAnnotationManagerEnabled) {
110
115
  return {
111
116
  hasFocus: currentSelectedAnnotationId === id,
112
117
  isHovered: currentHoveredAnnotationId === id
@@ -129,6 +134,10 @@ export const useAnnotationClickEvent = props => {
129
134
  createAnalyticsEvent,
130
135
  isNestedRender
131
136
  } = props;
137
+ const {
138
+ annotationManager
139
+ } = useAnnotationManagerDispatch();
140
+ const isAnnotationManagerEnabled = !!annotationManager;
132
141
  const {
133
142
  currentSelectedAnnotationId,
134
143
  currentSelectedMarkRef
@@ -187,7 +196,7 @@ export const useAnnotationClickEvent = props => {
187
196
  document.activeElement.blur();
188
197
  }
189
198
  };
190
- if (!fg('platform_editor_comments_api_manager')) {
199
+ if (!isAnnotationManagerEnabled) {
191
200
  updateSubscriber.on(AnnotationUpdateEvent.ON_ANNOTATION_CLICK, clickCb);
192
201
  updateSubscriber.on(AnnotationUpdateEvent.DESELECT_ANNOTATIONS, deselectCb);
193
202
  return () => {
@@ -195,8 +204,8 @@ export const useAnnotationClickEvent = props => {
195
204
  updateSubscriber.off(AnnotationUpdateEvent.DESELECT_ANNOTATIONS, deselectCb);
196
205
  };
197
206
  }
198
- }, [updateSubscriber, createAnalyticsEvent, isNestedRender]);
199
- if (fg('platform_editor_comments_api_manager')) {
207
+ }, [updateSubscriber, createAnalyticsEvent, isNestedRender, isAnnotationManagerEnabled]);
208
+ if (isAnnotationManagerEnabled) {
200
209
  return isNestedRender ? null : selectedAnnotation;
201
210
  } else {
202
211
  return annotationClickEvent;
@@ -12,8 +12,10 @@ export const useLoadAnnotations = ({
12
12
  const actions = useContext(ActionsContext);
13
13
  const providers = useContext(ProvidersContext);
14
14
  const {
15
+ annotationManager,
15
16
  dispatch
16
17
  } = useAnnotationManagerDispatch();
18
+ const isAnnotationManagerEnabled = !!annotationManager;
17
19
  useEffect(() => {
18
20
  if (!providers) {
19
21
  return;
@@ -45,7 +47,7 @@ export const useLoadAnnotations = ({
45
47
  ...acc,
46
48
  [value.id]: value
47
49
  }), {});
48
- if (fg('platform_editor_comments_api_manager')) {
50
+ if (isAnnotationManagerEnabled) {
49
51
  dispatch({
50
52
  type: 'loadAnnotation',
51
53
  data: Object.keys(payload).map(id => {
@@ -64,5 +66,5 @@ export const useLoadAnnotations = ({
64
66
  });
65
67
  };
66
68
  inlineCommentGetState(ids, isNestedRender).then(cb);
67
- }, [actions, providers, adfDocument, isNestedRender, onLoadComplete, dispatch]);
69
+ }, [actions, providers, adfDocument, isNestedRender, onLoadComplete, dispatch, isAnnotationManagerEnabled]);
68
70
  };
@@ -3,6 +3,7 @@ import { useAnnotationRangeDispatch, useAnnotationRangeState } from '../contexts
3
3
  import { isRangeInsideOfRendererContainer } from './utils';
4
4
  import { isRoot } from '../../../steps';
5
5
  import { fg } from '@atlaskit/platform-feature-flags';
6
+ import { useAnnotationManagerDispatch } from '../contexts/AnnotationManagerContext';
6
7
  export const useUserSelectionRange = props => {
7
8
  const {
8
9
  rendererRef: {
@@ -19,7 +20,11 @@ export const useUserSelectionRange = props => {
19
20
  type,
20
21
  selectionDraftRange
21
22
  } = useAnnotationRangeState();
23
+ const {
24
+ annotationManager
25
+ } = useAnnotationManagerDispatch();
22
26
  const lastRangeRef = useRef(null);
27
+ const isAnnotationManagerEnabled = !!annotationManager;
23
28
  const onSelectionChange = useCallback(event => {
24
29
  if (fg('platform_renderer_triple_click_selects_paragraph')) {
25
30
  if (selectionTimeoutRef.current) {
@@ -29,6 +34,9 @@ export const useUserSelectionRange = props => {
29
34
  const sel = document.getSelection();
30
35
  if (!sel || sel.type !== 'Range' || sel.rangeCount !== 1) {
31
36
  lastRangeRef.current = null; // Clear last range if selection is invalid
37
+ if (isAnnotationManagerEnabled) {
38
+ clearSelectionRange();
39
+ }
32
40
  return;
33
41
  }
34
42
  let _range = sel.getRangeAt(0);
@@ -67,6 +75,9 @@ export const useUserSelectionRange = props => {
67
75
  selectionTimeoutRef.current = setTimeout(() => {
68
76
  const sel = document.getSelection();
69
77
  if (!sel || sel.type !== 'Range' || sel.rangeCount !== 1) {
78
+ if (isAnnotationManagerEnabled) {
79
+ clearSelectionRange();
80
+ }
70
81
  return;
71
82
  }
72
83
  const _range = sel.getRangeAt(0);
@@ -103,7 +114,7 @@ export const useUserSelectionRange = props => {
103
114
  }
104
115
  }, 250);
105
116
  }
106
- }, [rendererDOM, setSelectionRange]);
117
+ }, [rendererDOM, setSelectionRange, clearSelectionRange, isAnnotationManagerEnabled]);
107
118
  useEffect(() => {
108
119
  if (!document || !rendererDOM) {
109
120
  return;
@@ -64,6 +64,7 @@ export const SelectionInlineCommentMounter = /*#__PURE__*/React.memo(props => {
64
64
  const onCreateCallback = useCallback(annotationId => {
65
65
  // We want to support creation on a documentPosition if the user is only using ranges
66
66
  // but we want to prioritize draft positions if they are being used by consumers
67
+ // !!! at this point, the documentPosition can be the wrong position if the user select something else
67
68
  const positionToAnnotate = selectionDraftDocumentPosition || documentPosition;
68
69
  if (!positionToAnnotate || !applyAnnotation) {
69
70
  // TODO: EDITOR-595 - This analytic event is temporary and should be removed once the following issue
@@ -166,7 +167,12 @@ export const SelectionInlineCommentMounter = /*#__PURE__*/React.memo(props => {
166
167
  }
167
168
  }
168
169
  });
169
- const positionToAnnotate = selectionDraftDocumentPosition || documentPosition;
170
+
171
+ // at this point, the documentPosition is the position that the user has selected,
172
+ // not the selectionDraftDocumentPosition
173
+ // because the documentPosition is not promoted to selectionDraftDocumentPosition yet
174
+ // use platform_editor_comments_api_manager here so we can clear the code path when the flag is removed
175
+ const positionToAnnotate = fg('platform_editor_comments_api_manager') ? documentPosition : selectionDraftDocumentPosition || documentPosition;
170
176
  if (!positionToAnnotate || !applyAnnotation || !options.annotationId) {
171
177
  return false;
172
178
  }
@@ -216,12 +222,9 @@ export const SelectionInlineCommentMounter = /*#__PURE__*/React.memo(props => {
216
222
  if (annotationManager) {
217
223
  const startDraft = () => {
218
224
  var _result$inlineNodeTyp;
219
- if (isDrafting) {
220
- return {
221
- success: false,
222
- reason: 'draft-in-progress'
223
- };
224
- }
225
+ // if there is a draft in progress, we ignore it and start a new draft
226
+ // this is because clearing the draft will remove the mark node from the DOM, which will cause the selection range to be invalid
227
+
225
228
  const id = uuid();
226
229
  const result = applyDraftModeCallback({
227
230
  annotationId: id,
@@ -13,6 +13,8 @@ export const SelectionRangeValidator = props => {
13
13
  rendererRef
14
14
  });
15
15
  const selectionRange = type === 'selection' ? range : null;
16
+
17
+ // !!! the draft range will become invalid after the mark DOM is inserted
16
18
  if (!selectionRange && !draftRange) {
17
19
  return null;
18
20
  }
@@ -53,7 +53,7 @@ import { PortalContext } from './PortalContext';
53
53
  export var NORMAL_SEVERITY_THRESHOLD = 2000;
54
54
  export var DEGRADED_SEVERITY_THRESHOLD = 3000;
55
55
  var packageName = "@atlaskit/renderer";
56
- var packageVersion = "118.6.5";
56
+ var packageVersion = "118.6.7";
57
57
  var setAsQueryContainerStyles = css({
58
58
  containerName: 'ak-renderer-wrapper',
59
59
  containerType: 'inline-size'
@@ -124,9 +124,11 @@ export var MarkComponent = function MarkComponent(_ref) {
124
124
  return _toConsumableArray(new Set([].concat(_toConsumableArray(annotationParentIds), [id])));
125
125
  }, [id, annotationParentIds]);
126
126
  var _useAnnotationManager = useAnnotationManagerDispatch(),
127
+ annotationManager = _useAnnotationManager.annotationManager,
127
128
  dispatch = _useAnnotationManager.dispatch;
128
129
  var _useAnnotationManager2 = useAnnotationManagerState(),
129
130
  currentSelectedAnnotationId = _useAnnotationManager2.currentSelectedAnnotationId;
131
+ var isAnnotationManagerEnabled = !!annotationManager;
130
132
 
131
133
  // after creating a new annotation, we need to set the markRef to the new mark
132
134
  var markRef = useCallback(function (node) {
@@ -165,7 +167,7 @@ export var MarkComponent = function MarkComponent(_ref) {
165
167
  // prevents from opening link URL inside webView in Safari
166
168
  event.preventDefault();
167
169
  }
168
- if (fg('platform_editor_comments_api_manager')) {
170
+ if (isAnnotationManagerEnabled) {
169
171
  // currentTarget is the right element if there are multiple overlapping annotations
170
172
  // Ignored via go/ees005
171
173
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
@@ -181,7 +183,7 @@ export var MarkComponent = function MarkComponent(_ref) {
181
183
  annotationIds: annotationIds
182
184
  });
183
185
  }
184
- }, [annotationIds, onClick, state]);
186
+ }, [annotationIds, onClick, state, isAnnotationManagerEnabled]);
185
187
  var onMarkEnter = function onMarkEnter(evt) {
186
188
  var _document$activeEleme;
187
189
  var focusedElementTag = (_document$activeEleme = document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.tagName;
@@ -7,7 +7,6 @@ import { AnnotationUpdateEvent } from '@atlaskit/editor-common/types';
7
7
  import { AnnotationTypes } from '@atlaskit/adf-schema';
8
8
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
9
9
  import { FabricChannel } from '@atlaskit/analytics-listeners/types';
10
- import { fg } from '@atlaskit/platform-feature-flags';
11
10
  import { useAnnotationManagerDispatch, useAnnotationManagerState } from '../contexts/AnnotationManagerContext';
12
11
  export var useAnnotationStateByTypeEvent = function useAnnotationStateByTypeEvent(_ref) {
13
12
  var type = _ref.type,
@@ -17,9 +16,11 @@ export var useAnnotationStateByTypeEvent = function useAnnotationStateByTypeEven
17
16
  states = _useState2[0],
18
17
  setStates = _useState2[1];
19
18
  var _useAnnotationManager = useAnnotationManagerDispatch(),
19
+ annotationManager = _useAnnotationManager.annotationManager,
20
20
  dispatch = _useAnnotationManager.dispatch;
21
21
  var _useAnnotationManager2 = useAnnotationManagerState(),
22
22
  annotations = _useAnnotationManager2.annotations;
23
+ var isAnnotationManagerEnabled = !!annotationManager;
23
24
  useLayoutEffect(function () {
24
25
  if (!updateSubscriber) {
25
26
  return;
@@ -38,19 +39,19 @@ export var useAnnotationStateByTypeEvent = function useAnnotationStateByTypeEven
38
39
  }, {});
39
40
  setStates(_objectSpread(_objectSpread({}, states), nextStates));
40
41
  };
41
- if (!fg('platform_editor_comments_api_manager')) {
42
+ if (!isAnnotationManagerEnabled) {
42
43
  updateSubscriber.on(AnnotationUpdateEvent.SET_ANNOTATION_STATE, cb);
43
44
  return function () {
44
45
  updateSubscriber.off(AnnotationUpdateEvent.SET_ANNOTATION_STATE, cb);
45
46
  };
46
47
  }
47
- }, [states, type, updateSubscriber, dispatch]);
48
+ }, [states, type, updateSubscriber, dispatch, isAnnotationManagerEnabled]);
48
49
  var annotationMarkStates = useMemo(function () {
49
50
  return Object.values(annotations).reduce(function (acc, curr) {
50
51
  return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, curr.id, curr.markState));
51
52
  }, {});
52
53
  }, [annotations]);
53
- if (fg('platform_editor_comments_api_manager')) {
54
+ if (isAnnotationManagerEnabled) {
54
55
  return annotationMarkStates;
55
56
  } else {
56
57
  return states;
@@ -70,6 +71,9 @@ export var useHasFocusEvent = function useHasFocusEvent(_ref2) {
70
71
  var _useAnnotationManager3 = useAnnotationManagerState(),
71
72
  currentSelectedAnnotationId = _useAnnotationManager3.currentSelectedAnnotationId,
72
73
  currentHoveredAnnotationId = _useAnnotationManager3.currentHoveredAnnotationId;
74
+ var _useAnnotationManager4 = useAnnotationManagerDispatch(),
75
+ annotationManager = _useAnnotationManager4.annotationManager;
76
+ var isAnnotationManagerEnabled = !!annotationManager;
73
77
  useLayoutEffect(function () {
74
78
  if (!updateSubscriber) {
75
79
  return;
@@ -92,7 +96,7 @@ export var useHasFocusEvent = function useHasFocusEvent(_ref2) {
92
96
  document.activeElement.blur();
93
97
  }
94
98
  };
95
- if (!fg('platform_editor_comments_api_manager')) {
99
+ if (!isAnnotationManagerEnabled) {
96
100
  updateSubscriber.on(AnnotationUpdateEvent.SET_ANNOTATION_FOCUS, cb);
97
101
  updateSubscriber.on(AnnotationUpdateEvent.SET_ANNOTATION_HOVERED, callbackForHoveredAnnotation);
98
102
  updateSubscriber.on(AnnotationUpdateEvent.REMOVE_ANNOTATION_FOCUS, removeFocus);
@@ -104,8 +108,8 @@ export var useHasFocusEvent = function useHasFocusEvent(_ref2) {
104
108
  updateSubscriber.off(AnnotationUpdateEvent.SET_ANNOTATION_HOVERED, removeHoverEffect);
105
109
  };
106
110
  }
107
- }, [id, updateSubscriber]);
108
- if (fg('platform_editor_comments_api_manager')) {
111
+ }, [id, updateSubscriber, isAnnotationManagerEnabled]);
112
+ if (isAnnotationManagerEnabled) {
109
113
  return {
110
114
  hasFocus: currentSelectedAnnotationId === id,
111
115
  isHovered: currentHoveredAnnotationId === id
@@ -129,9 +133,12 @@ export var useAnnotationClickEvent = function useAnnotationClickEvent(props) {
129
133
  var updateSubscriber = props.updateSubscriber,
130
134
  createAnalyticsEvent = props.createAnalyticsEvent,
131
135
  isNestedRender = props.isNestedRender;
132
- var _useAnnotationManager4 = useAnnotationManagerState(),
133
- currentSelectedAnnotationId = _useAnnotationManager4.currentSelectedAnnotationId,
134
- currentSelectedMarkRef = _useAnnotationManager4.currentSelectedMarkRef;
136
+ var _useAnnotationManager5 = useAnnotationManagerDispatch(),
137
+ annotationManager = _useAnnotationManager5.annotationManager;
138
+ var isAnnotationManagerEnabled = !!annotationManager;
139
+ var _useAnnotationManager6 = useAnnotationManagerState(),
140
+ currentSelectedAnnotationId = _useAnnotationManager6.currentSelectedAnnotationId,
141
+ currentSelectedMarkRef = _useAnnotationManager6.currentSelectedMarkRef;
135
142
  var selectedAnnotation = useMemo(function () {
136
143
  return currentSelectedAnnotationId && currentSelectedMarkRef && currentSelectedMarkRef.id === currentSelectedAnnotationId ? {
137
144
  annotations: [{
@@ -189,7 +196,7 @@ export var useAnnotationClickEvent = function useAnnotationClickEvent(props) {
189
196
  document.activeElement.blur();
190
197
  }
191
198
  };
192
- if (!fg('platform_editor_comments_api_manager')) {
199
+ if (!isAnnotationManagerEnabled) {
193
200
  updateSubscriber.on(AnnotationUpdateEvent.ON_ANNOTATION_CLICK, clickCb);
194
201
  updateSubscriber.on(AnnotationUpdateEvent.DESELECT_ANNOTATIONS, deselectCb);
195
202
  return function () {
@@ -197,8 +204,8 @@ export var useAnnotationClickEvent = function useAnnotationClickEvent(props) {
197
204
  updateSubscriber.off(AnnotationUpdateEvent.DESELECT_ANNOTATIONS, deselectCb);
198
205
  };
199
206
  }
200
- }, [updateSubscriber, createAnalyticsEvent, isNestedRender]);
201
- if (fg('platform_editor_comments_api_manager')) {
207
+ }, [updateSubscriber, createAnalyticsEvent, isNestedRender, isAnnotationManagerEnabled]);
208
+ if (isAnnotationManagerEnabled) {
202
209
  return isNestedRender ? null : selectedAnnotation;
203
210
  } else {
204
211
  return annotationClickEvent;
@@ -14,7 +14,9 @@ export var useLoadAnnotations = function useLoadAnnotations(_ref) {
14
14
  var actions = useContext(ActionsContext);
15
15
  var providers = useContext(ProvidersContext);
16
16
  var _useAnnotationManager = useAnnotationManagerDispatch(),
17
+ annotationManager = _useAnnotationManager.annotationManager,
17
18
  dispatch = _useAnnotationManager.dispatch;
19
+ var isAnnotationManagerEnabled = !!annotationManager;
18
20
  useEffect(function () {
19
21
  if (!providers) {
20
22
  return;
@@ -44,7 +46,7 @@ export var useLoadAnnotations = function useLoadAnnotations(_ref) {
44
46
  var payload = data.reduce(function (acc, value) {
45
47
  return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, value.id, value));
46
48
  }, {});
47
- if (fg('platform_editor_comments_api_manager')) {
49
+ if (isAnnotationManagerEnabled) {
48
50
  dispatch({
49
51
  type: 'loadAnnotation',
50
52
  data: Object.keys(payload).map(function (id) {
@@ -65,5 +67,5 @@ export var useLoadAnnotations = function useLoadAnnotations(_ref) {
65
67
  });
66
68
  };
67
69
  inlineCommentGetState(ids, isNestedRender).then(cb);
68
- }, [actions, providers, adfDocument, isNestedRender, onLoadComplete, dispatch]);
70
+ }, [actions, providers, adfDocument, isNestedRender, onLoadComplete, dispatch, isAnnotationManagerEnabled]);
69
71
  };
@@ -3,6 +3,7 @@ import { useAnnotationRangeDispatch, useAnnotationRangeState } from '../contexts
3
3
  import { isRangeInsideOfRendererContainer } from './utils';
4
4
  import { isRoot } from '../../../steps';
5
5
  import { fg } from '@atlaskit/platform-feature-flags';
6
+ import { useAnnotationManagerDispatch } from '../contexts/AnnotationManagerContext';
6
7
  export var useUserSelectionRange = function useUserSelectionRange(props) {
7
8
  var rendererDOM = props.rendererRef.current;
8
9
  var selectionTimeoutRef = useRef();
@@ -13,7 +14,10 @@ export var useUserSelectionRange = function useUserSelectionRange(props) {
13
14
  range = _useAnnotationRangeSt.range,
14
15
  type = _useAnnotationRangeSt.type,
15
16
  selectionDraftRange = _useAnnotationRangeSt.selectionDraftRange;
17
+ var _useAnnotationManager = useAnnotationManagerDispatch(),
18
+ annotationManager = _useAnnotationManager.annotationManager;
16
19
  var lastRangeRef = useRef(null);
20
+ var isAnnotationManagerEnabled = !!annotationManager;
17
21
  var onSelectionChange = useCallback(function (event) {
18
22
  if (fg('platform_renderer_triple_click_selects_paragraph')) {
19
23
  if (selectionTimeoutRef.current) {
@@ -23,6 +27,9 @@ export var useUserSelectionRange = function useUserSelectionRange(props) {
23
27
  var sel = document.getSelection();
24
28
  if (!sel || sel.type !== 'Range' || sel.rangeCount !== 1) {
25
29
  lastRangeRef.current = null; // Clear last range if selection is invalid
30
+ if (isAnnotationManagerEnabled) {
31
+ clearSelectionRange();
32
+ }
26
33
  return;
27
34
  }
28
35
  var _range = sel.getRangeAt(0);
@@ -60,6 +67,9 @@ export var useUserSelectionRange = function useUserSelectionRange(props) {
60
67
  selectionTimeoutRef.current = setTimeout(function () {
61
68
  var sel = document.getSelection();
62
69
  if (!sel || sel.type !== 'Range' || sel.rangeCount !== 1) {
70
+ if (isAnnotationManagerEnabled) {
71
+ clearSelectionRange();
72
+ }
63
73
  return;
64
74
  }
65
75
  var _range = sel.getRangeAt(0);
@@ -94,7 +104,7 @@ export var useUserSelectionRange = function useUserSelectionRange(props) {
94
104
  }
95
105
  }, 250);
96
106
  }
97
- }, [rendererDOM, setSelectionRange]);
107
+ }, [rendererDOM, setSelectionRange, clearSelectionRange, isAnnotationManagerEnabled]);
98
108
  useEffect(function () {
99
109
  if (!document || !rendererDOM) {
100
110
  return;
@@ -58,6 +58,7 @@ export var SelectionInlineCommentMounter = /*#__PURE__*/React.memo(function (pro
58
58
  var onCreateCallback = useCallback(function (annotationId) {
59
59
  // We want to support creation on a documentPosition if the user is only using ranges
60
60
  // but we want to prioritize draft positions if they are being used by consumers
61
+ // !!! at this point, the documentPosition can be the wrong position if the user select something else
61
62
  var positionToAnnotate = selectionDraftDocumentPosition || documentPosition;
62
63
  if (!positionToAnnotate || !applyAnnotation) {
63
64
  // TODO: EDITOR-595 - This analytic event is temporary and should be removed once the following issue
@@ -160,7 +161,12 @@ export var SelectionInlineCommentMounter = /*#__PURE__*/React.memo(function (pro
160
161
  }
161
162
  }
162
163
  });
163
- var positionToAnnotate = selectionDraftDocumentPosition || documentPosition;
164
+
165
+ // at this point, the documentPosition is the position that the user has selected,
166
+ // not the selectionDraftDocumentPosition
167
+ // because the documentPosition is not promoted to selectionDraftDocumentPosition yet
168
+ // use platform_editor_comments_api_manager here so we can clear the code path when the flag is removed
169
+ var positionToAnnotate = fg('platform_editor_comments_api_manager') ? documentPosition : selectionDraftDocumentPosition || documentPosition;
164
170
  if (!positionToAnnotate || !applyAnnotation || !options.annotationId) {
165
171
  return false;
166
172
  }
@@ -210,12 +216,9 @@ export var SelectionInlineCommentMounter = /*#__PURE__*/React.memo(function (pro
210
216
  if (annotationManager) {
211
217
  var startDraft = function startDraft() {
212
218
  var _result$inlineNodeTyp;
213
- if (isDrafting) {
214
- return {
215
- success: false,
216
- reason: 'draft-in-progress'
217
- };
218
- }
219
+ // if there is a draft in progress, we ignore it and start a new draft
220
+ // this is because clearing the draft will remove the mark node from the DOM, which will cause the selection range to be invalid
221
+
219
222
  var id = uuid();
220
223
  var result = applyDraftModeCallback({
221
224
  annotationId: id,
@@ -17,6 +17,8 @@ export var SelectionRangeValidator = function SelectionRangeValidator(props) {
17
17
  draftRange = _useUserSelectionRang2[2],
18
18
  clearRange = _useUserSelectionRang2[3];
19
19
  var selectionRange = type === 'selection' ? range : null;
20
+
21
+ // !!! the draft range will become invalid after the mark DOM is inserted
20
22
  if (!selectionRange && !draftRange) {
21
23
  return null;
22
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/renderer",
3
- "version": "118.6.5",
3
+ "version": "118.6.7",
4
4
  "description": "Renderer component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -52,13 +52,13 @@
52
52
  "@atlaskit/platform-feature-flags": "^1.1.0",
53
53
  "@atlaskit/platform-feature-flags-react": "^0.2.0",
54
54
  "@atlaskit/react-ufo": "^3.13.0",
55
- "@atlaskit/smart-card": "^38.5.0",
55
+ "@atlaskit/smart-card": "^38.6.0",
56
56
  "@atlaskit/status": "^3.0.0",
57
57
  "@atlaskit/task-decision": "^19.2.0",
58
58
  "@atlaskit/theme": "^18.0.0",
59
- "@atlaskit/tmp-editor-statsig": "^5.8.0",
59
+ "@atlaskit/tmp-editor-statsig": "^5.10.0",
60
60
  "@atlaskit/tokens": "^5.0.0",
61
- "@atlaskit/tooltip": "^20.2.0",
61
+ "@atlaskit/tooltip": "^20.3.0",
62
62
  "@atlaskit/visually-hidden": "^3.0.0",
63
63
  "@babel/runtime": "^7.0.0",
64
64
  "@emotion/react": "^11.7.1",
@@ -70,7 +70,7 @@
70
70
  "uuid": "^3.1.0"
71
71
  },
72
72
  "peerDependencies": {
73
- "@atlaskit/link-provider": "^3.2.0",
73
+ "@atlaskit/link-provider": "^3.3.0",
74
74
  "@atlaskit/media-core": "^36.1.0",
75
75
  "react": "^18.2.0",
76
76
  "react-dom": "^18.2.0"
@@ -81,7 +81,7 @@
81
81
  "@atlaskit/analytics-gas-types": "^5.1.0",
82
82
  "@atlaskit/checkbox": "^17.1.0",
83
83
  "@atlaskit/css-reset": "^7.3.0",
84
- "@atlaskit/link-provider": "^3.2.0",
84
+ "@atlaskit/link-provider": "^3.3.0",
85
85
  "@atlaskit/link-test-helpers": "^8.0.0",
86
86
  "@atlaskit/linking-common": "^9.0.0",
87
87
  "@atlaskit/media-core": "^36.1.0",