@atlaskit/renderer 133.10.6 → 133.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/cjs/ui/Renderer/index.js +1 -1
- package/dist/cjs/ui/annotations/hover/mounter.js +16 -3
- package/dist/cjs/ui/annotations/selection/mounter.js +17 -12
- package/dist/es2019/ui/Renderer/index.js +1 -1
- package/dist/es2019/ui/annotations/hover/mounter.js +16 -3
- package/dist/es2019/ui/annotations/selection/mounter.js +17 -12
- package/dist/esm/ui/Renderer/index.js +1 -1
- package/dist/esm/ui/annotations/hover/mounter.js +16 -3
- package/dist/esm/ui/annotations/selection/mounter.js +17 -12
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/renderer
|
|
2
2
|
|
|
3
|
+
## 133.11.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`d3536d2e15575`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d3536d2e15575) -
|
|
8
|
+
Fix inline comment anchoring to wrong text when a new selection is made while a draft is active.
|
|
9
|
+
Clears stale hover/selection draft position before promoting new selection, and adds missing deps
|
|
10
|
+
to useCallback arrays.
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
3
16
|
## 133.10.6
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -72,7 +72,7 @@ var DEGRADED_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
|
72
72
|
var TABLE_INFO_TIMEOUT = 10000;
|
|
73
73
|
var RENDER_EVENT_SAMPLE_RATE = 0.1;
|
|
74
74
|
var packageName = "@atlaskit/renderer";
|
|
75
|
-
var packageVersion = "133.10.
|
|
75
|
+
var packageVersion = "133.10.6";
|
|
76
76
|
var setAsQueryContainerStyles = (0, _react2.css)({
|
|
77
77
|
containerName: 'ak-renderer-wrapper',
|
|
78
78
|
containerType: 'inline-size'
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.Mounter = void 0;
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
9
10
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
10
11
|
var _dom = require("../draft/dom");
|
|
11
12
|
var _types = require("@atlaskit/analytics-listeners/types");
|
|
@@ -31,7 +32,9 @@ var Mounter = exports.Mounter = /*#__PURE__*/_react.default.memo(function (props
|
|
|
31
32
|
hoverDraftDocumentPosition = _useAnnotationRangeSt.hoverDraftDocumentPosition;
|
|
32
33
|
var actions = (0, _react.useContext)(_RendererActionsContext.RendererContext);
|
|
33
34
|
var onCreateCallback = (0, _react.useCallback)(function (annotationId) {
|
|
34
|
-
|
|
35
|
+
// Always use documentPosition directly when gate is on — hoverDraftDocumentPosition
|
|
36
|
+
// in this closure may be stale (captured before state update) (COMMENTS-6594).
|
|
37
|
+
var positionToAnnotate = (0, _expValEquals.expValEquals)('confluence_inline_comments_fix_stale_selection', 'isEnabled', true) ? documentPosition : hoverDraftDocumentPosition || documentPosition;
|
|
35
38
|
if (!isAnnotationAllowed || !positionToAnnotate || !applyAnnotation) {
|
|
36
39
|
return false;
|
|
37
40
|
}
|
|
@@ -76,6 +79,13 @@ var Mounter = exports.Mounter = /*#__PURE__*/_react.default.memo(function (props
|
|
|
76
79
|
}
|
|
77
80
|
return false;
|
|
78
81
|
}
|
|
82
|
+
|
|
83
|
+
// Clear any stale draft position before promoting the new one.
|
|
84
|
+
// Without this, if a previous draft was not explicitly closed, hoverDraftDocumentPosition
|
|
85
|
+
// retains the old position and the comment anchors to the wrong text (COMMENTS-6594).
|
|
86
|
+
if ((0, _expValEquals.expValEquals)('confluence_inline_comments_fix_stale_selection', 'isEnabled', true)) {
|
|
87
|
+
clearHoverDraft();
|
|
88
|
+
}
|
|
79
89
|
promoteHoverToDraft(documentPosition);
|
|
80
90
|
if (createAnalyticsEvent) {
|
|
81
91
|
var uniqueAnnotationsInRange = actions.getAnnotationsByPosition(range);
|
|
@@ -99,7 +109,10 @@ var Mounter = exports.Mounter = /*#__PURE__*/_react.default.memo(function (props
|
|
|
99
109
|
}
|
|
100
110
|
}
|
|
101
111
|
});
|
|
102
|
-
|
|
112
|
+
|
|
113
|
+
// Always use documentPosition directly when gate is on — hoverDraftDocumentPosition
|
|
114
|
+
// in this closure may be stale (captured before state update) (COMMENTS-6594).
|
|
115
|
+
var positionToAnnotate = (0, _expValEquals.expValEquals)('confluence_inline_comments_fix_stale_selection', 'isEnabled', true) ? documentPosition : hoverDraftDocumentPosition || documentPosition;
|
|
103
116
|
if (!positionToAnnotate || !applyAnnotation || !options.annotationId) {
|
|
104
117
|
if (createAnalyticsEvent) {
|
|
105
118
|
createAnalyticsEvent({
|
|
@@ -121,7 +134,7 @@ var Mounter = exports.Mounter = /*#__PURE__*/_react.default.memo(function (props
|
|
|
121
134
|
annotationType: _adfSchema.AnnotationTypes.INLINE_COMMENT
|
|
122
135
|
};
|
|
123
136
|
return applyAnnotation(positionToAnnotate, annotation);
|
|
124
|
-
}, [documentPosition, isAnnotationAllowed, createAnalyticsEvent, applyAnnotation, actions, range, promoteHoverToDraft,
|
|
137
|
+
}, [documentPosition, hoverDraftDocumentPosition, isAnnotationAllowed, createAnalyticsEvent, applyAnnotation, actions, range, promoteHoverToDraft, clearHoverDraft]);
|
|
125
138
|
var removeDraftModeCallback = (0, _react.useCallback)(function () {
|
|
126
139
|
clearHoverDraft();
|
|
127
140
|
var sel = window.getSelection();
|
|
@@ -7,9 +7,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.SelectionInlineCommentMounter = void 0;
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
11
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
12
|
var _v = _interopRequireDefault(require("uuid/v4"));
|
|
11
13
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
12
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
14
|
var _dom = require("../draft/dom");
|
|
14
15
|
var _types = require("@atlaskit/analytics-listeners/types");
|
|
15
16
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
@@ -53,10 +54,9 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
|
|
|
53
54
|
});
|
|
54
55
|
}, [documentPosition, actions, range]);
|
|
55
56
|
var onCreateCallback = (0, _react.useCallback)(function (annotationId) {
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
var positionToAnnotate = selectionDraftDocumentPosition || documentPosition;
|
|
57
|
+
// Use documentPosition directly when gate is on — selectionDraftDocumentPosition may be stale
|
|
58
|
+
// (from a previous selection) causing the comment to anchor to the wrong text (COMMENTS-6594).
|
|
59
|
+
var positionToAnnotate = (0, _expValEquals.expValEquals)('confluence_inline_comments_fix_stale_selection', 'isEnabled', true) ? documentPosition : selectionDraftDocumentPosition || documentPosition;
|
|
60
60
|
if (!positionToAnnotate || !applyAnnotation) {
|
|
61
61
|
return false;
|
|
62
62
|
}
|
|
@@ -82,7 +82,7 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
|
|
|
82
82
|
}).fire(_types.FabricChannel.editor);
|
|
83
83
|
}
|
|
84
84
|
return applyAnnotation(positionToAnnotate, annotation);
|
|
85
|
-
}, [actions, documentPosition, applyAnnotation, createAnalyticsEvent, inlineNodeTypes
|
|
85
|
+
}, [actions, documentPosition, selectionDraftDocumentPosition, applyAnnotation, createAnalyticsEvent, inlineNodeTypes]);
|
|
86
86
|
var createIndexCallback = (0, _react.useCallback)(function () {
|
|
87
87
|
if (!documentPosition || !generateIndexMatch) {
|
|
88
88
|
return false;
|
|
@@ -110,6 +110,11 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
|
|
|
110
110
|
}
|
|
111
111
|
return false;
|
|
112
112
|
}
|
|
113
|
+
|
|
114
|
+
// Clear any stale draft position before promoting the new one (COMMENTS-6594).
|
|
115
|
+
if ((0, _expValEquals.expValEquals)('confluence_inline_comments_fix_stale_selection', 'isEnabled', true)) {
|
|
116
|
+
clearSelectionDraft();
|
|
117
|
+
}
|
|
113
118
|
promoteSelectionToDraft(documentPosition);
|
|
114
119
|
if (createAnalyticsEvent) {
|
|
115
120
|
var uniqueAnnotationsInRange = range ? actions.getAnnotationsByPosition(range) : [];
|
|
@@ -135,11 +140,11 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
|
|
|
135
140
|
}
|
|
136
141
|
});
|
|
137
142
|
|
|
138
|
-
//
|
|
139
|
-
//
|
|
140
|
-
//
|
|
141
|
-
//
|
|
142
|
-
var positionToAnnotate = (0, _platformFeatureFlags.fg)('platform_editor_comments_api_manager') ? documentPosition : selectionDraftDocumentPosition || documentPosition;
|
|
143
|
+
// Use documentPosition directly when either:
|
|
144
|
+
// - platform_editor_comments_api_manager is on (existing behaviour), OR
|
|
145
|
+
// - COMMENTS-6594 experiment is on (fix: avoids stale closure value)
|
|
146
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
147
|
+
var positionToAnnotate = (0, _platformFeatureFlags.fg)('platform_editor_comments_api_manager') || (0, _expValEquals.expValEquals)('confluence_inline_comments_fix_stale_selection', 'isEnabled', true) ? documentPosition : selectionDraftDocumentPosition || documentPosition;
|
|
143
148
|
if (!positionToAnnotate || !applyAnnotation || !options.annotationId) {
|
|
144
149
|
if (createAnalyticsEvent) {
|
|
145
150
|
createAnalyticsEvent({
|
|
@@ -161,7 +166,7 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
|
|
|
161
166
|
annotationType: _adfSchema.AnnotationTypes.INLINE_COMMENT
|
|
162
167
|
};
|
|
163
168
|
return applyAnnotation(positionToAnnotate, annotation);
|
|
164
|
-
}, [documentPosition, isAnnotationAllowed, createAnalyticsEvent, applyAnnotation, actions, range, inlineNodeTypes, promoteSelectionToDraft, selectionDraftDocumentPosition]);
|
|
169
|
+
}, [documentPosition, isAnnotationAllowed, createAnalyticsEvent, applyAnnotation, actions, range, inlineNodeTypes, promoteSelectionToDraft, clearSelectionDraft, selectionDraftDocumentPosition]);
|
|
165
170
|
var removeDraftModeCallback = (0, _react.useCallback)(function () {
|
|
166
171
|
clearSelectionDraft();
|
|
167
172
|
var sel = window.getSelection();
|
|
@@ -58,7 +58,7 @@ export const DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
|
58
58
|
const TABLE_INFO_TIMEOUT = 10000;
|
|
59
59
|
const RENDER_EVENT_SAMPLE_RATE = 0.1;
|
|
60
60
|
const packageName = "@atlaskit/renderer";
|
|
61
|
-
const packageVersion = "133.10.
|
|
61
|
+
const packageVersion = "133.10.6";
|
|
62
62
|
const setAsQueryContainerStyles = css({
|
|
63
63
|
containerName: 'ak-renderer-wrapper',
|
|
64
64
|
containerType: 'inline-size'
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useCallback, useContext } from 'react';
|
|
2
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
2
3
|
import { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
3
4
|
import { updateWindowSelectionAroundDraft } from '../draft/dom';
|
|
4
5
|
import { FabricChannel } from '@atlaskit/analytics-listeners/types';
|
|
@@ -27,7 +28,9 @@ export const Mounter = /*#__PURE__*/React.memo(props => {
|
|
|
27
28
|
} = useAnnotationRangeState();
|
|
28
29
|
const actions = useContext(ActionsContext);
|
|
29
30
|
const onCreateCallback = useCallback(annotationId => {
|
|
30
|
-
|
|
31
|
+
// Always use documentPosition directly when gate is on — hoverDraftDocumentPosition
|
|
32
|
+
// in this closure may be stale (captured before state update) (COMMENTS-6594).
|
|
33
|
+
const positionToAnnotate = expValEquals('confluence_inline_comments_fix_stale_selection', 'isEnabled', true) ? documentPosition : hoverDraftDocumentPosition || documentPosition;
|
|
31
34
|
if (!isAnnotationAllowed || !positionToAnnotate || !applyAnnotation) {
|
|
32
35
|
return false;
|
|
33
36
|
}
|
|
@@ -72,6 +75,13 @@ export const Mounter = /*#__PURE__*/React.memo(props => {
|
|
|
72
75
|
}
|
|
73
76
|
return false;
|
|
74
77
|
}
|
|
78
|
+
|
|
79
|
+
// Clear any stale draft position before promoting the new one.
|
|
80
|
+
// Without this, if a previous draft was not explicitly closed, hoverDraftDocumentPosition
|
|
81
|
+
// retains the old position and the comment anchors to the wrong text (COMMENTS-6594).
|
|
82
|
+
if (expValEquals('confluence_inline_comments_fix_stale_selection', 'isEnabled', true)) {
|
|
83
|
+
clearHoverDraft();
|
|
84
|
+
}
|
|
75
85
|
promoteHoverToDraft(documentPosition);
|
|
76
86
|
if (createAnalyticsEvent) {
|
|
77
87
|
const uniqueAnnotationsInRange = actions.getAnnotationsByPosition(range);
|
|
@@ -95,7 +105,10 @@ export const Mounter = /*#__PURE__*/React.memo(props => {
|
|
|
95
105
|
}
|
|
96
106
|
}
|
|
97
107
|
});
|
|
98
|
-
|
|
108
|
+
|
|
109
|
+
// Always use documentPosition directly when gate is on — hoverDraftDocumentPosition
|
|
110
|
+
// in this closure may be stale (captured before state update) (COMMENTS-6594).
|
|
111
|
+
const positionToAnnotate = expValEquals('confluence_inline_comments_fix_stale_selection', 'isEnabled', true) ? documentPosition : hoverDraftDocumentPosition || documentPosition;
|
|
99
112
|
if (!positionToAnnotate || !applyAnnotation || !options.annotationId) {
|
|
100
113
|
if (createAnalyticsEvent) {
|
|
101
114
|
createAnalyticsEvent({
|
|
@@ -117,7 +130,7 @@ export const Mounter = /*#__PURE__*/React.memo(props => {
|
|
|
117
130
|
annotationType: AnnotationTypes.INLINE_COMMENT
|
|
118
131
|
};
|
|
119
132
|
return applyAnnotation(positionToAnnotate, annotation);
|
|
120
|
-
}, [documentPosition, isAnnotationAllowed, createAnalyticsEvent, applyAnnotation, actions, range, promoteHoverToDraft,
|
|
133
|
+
}, [documentPosition, hoverDraftDocumentPosition, isAnnotationAllowed, createAnalyticsEvent, applyAnnotation, actions, range, promoteHoverToDraft, clearHoverDraft]);
|
|
121
134
|
const removeDraftModeCallback = useCallback(() => {
|
|
122
135
|
clearHoverDraft();
|
|
123
136
|
const sel = window.getSelection();
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React, { useCallback, useContext, useMemo, useEffect } from 'react';
|
|
2
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
4
|
|
|
3
5
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
4
6
|
import uuid from 'uuid/v4';
|
|
5
7
|
import { AnnotationTypes, AnnotationMarkStates } from '@atlaskit/adf-schema';
|
|
6
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { updateWindowSelectionAroundDraft } from '../draft/dom';
|
|
8
9
|
import { FabricChannel } from '@atlaskit/analytics-listeners/types';
|
|
9
10
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
@@ -50,10 +51,9 @@ export const SelectionInlineCommentMounter = /*#__PURE__*/React.memo(props => {
|
|
|
50
51
|
});
|
|
51
52
|
}, [documentPosition, actions, range]);
|
|
52
53
|
const onCreateCallback = useCallback(annotationId => {
|
|
53
|
-
//
|
|
54
|
-
//
|
|
55
|
-
|
|
56
|
-
const positionToAnnotate = selectionDraftDocumentPosition || documentPosition;
|
|
54
|
+
// Use documentPosition directly when gate is on — selectionDraftDocumentPosition may be stale
|
|
55
|
+
// (from a previous selection) causing the comment to anchor to the wrong text (COMMENTS-6594).
|
|
56
|
+
const positionToAnnotate = expValEquals('confluence_inline_comments_fix_stale_selection', 'isEnabled', true) ? documentPosition : selectionDraftDocumentPosition || documentPosition;
|
|
57
57
|
if (!positionToAnnotate || !applyAnnotation) {
|
|
58
58
|
return false;
|
|
59
59
|
}
|
|
@@ -79,7 +79,7 @@ export const SelectionInlineCommentMounter = /*#__PURE__*/React.memo(props => {
|
|
|
79
79
|
}).fire(FabricChannel.editor);
|
|
80
80
|
}
|
|
81
81
|
return applyAnnotation(positionToAnnotate, annotation);
|
|
82
|
-
}, [actions, documentPosition, applyAnnotation, createAnalyticsEvent, inlineNodeTypes
|
|
82
|
+
}, [actions, documentPosition, selectionDraftDocumentPosition, applyAnnotation, createAnalyticsEvent, inlineNodeTypes]);
|
|
83
83
|
const createIndexCallback = useCallback(() => {
|
|
84
84
|
if (!documentPosition || !generateIndexMatch) {
|
|
85
85
|
return false;
|
|
@@ -107,6 +107,11 @@ export const SelectionInlineCommentMounter = /*#__PURE__*/React.memo(props => {
|
|
|
107
107
|
}
|
|
108
108
|
return false;
|
|
109
109
|
}
|
|
110
|
+
|
|
111
|
+
// Clear any stale draft position before promoting the new one (COMMENTS-6594).
|
|
112
|
+
if (expValEquals('confluence_inline_comments_fix_stale_selection', 'isEnabled', true)) {
|
|
113
|
+
clearSelectionDraft();
|
|
114
|
+
}
|
|
110
115
|
promoteSelectionToDraft(documentPosition);
|
|
111
116
|
if (createAnalyticsEvent) {
|
|
112
117
|
const uniqueAnnotationsInRange = range ? actions.getAnnotationsByPosition(range) : [];
|
|
@@ -132,11 +137,11 @@ export const SelectionInlineCommentMounter = /*#__PURE__*/React.memo(props => {
|
|
|
132
137
|
}
|
|
133
138
|
});
|
|
134
139
|
|
|
135
|
-
//
|
|
136
|
-
//
|
|
137
|
-
//
|
|
138
|
-
//
|
|
139
|
-
const positionToAnnotate = fg('platform_editor_comments_api_manager') ? documentPosition : selectionDraftDocumentPosition || documentPosition;
|
|
140
|
+
// Use documentPosition directly when either:
|
|
141
|
+
// - platform_editor_comments_api_manager is on (existing behaviour), OR
|
|
142
|
+
// - COMMENTS-6594 experiment is on (fix: avoids stale closure value)
|
|
143
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
144
|
+
const positionToAnnotate = fg('platform_editor_comments_api_manager') || expValEquals('confluence_inline_comments_fix_stale_selection', 'isEnabled', true) ? documentPosition : selectionDraftDocumentPosition || documentPosition;
|
|
140
145
|
if (!positionToAnnotate || !applyAnnotation || !options.annotationId) {
|
|
141
146
|
if (createAnalyticsEvent) {
|
|
142
147
|
createAnalyticsEvent({
|
|
@@ -158,7 +163,7 @@ export const SelectionInlineCommentMounter = /*#__PURE__*/React.memo(props => {
|
|
|
158
163
|
annotationType: AnnotationTypes.INLINE_COMMENT
|
|
159
164
|
};
|
|
160
165
|
return applyAnnotation(positionToAnnotate, annotation);
|
|
161
|
-
}, [documentPosition, isAnnotationAllowed, createAnalyticsEvent, applyAnnotation, actions, range, inlineNodeTypes, promoteSelectionToDraft, selectionDraftDocumentPosition]);
|
|
166
|
+
}, [documentPosition, isAnnotationAllowed, createAnalyticsEvent, applyAnnotation, actions, range, inlineNodeTypes, promoteSelectionToDraft, clearSelectionDraft, selectionDraftDocumentPosition]);
|
|
162
167
|
const removeDraftModeCallback = useCallback(() => {
|
|
163
168
|
clearSelectionDraft();
|
|
164
169
|
const sel = window.getSelection();
|
|
@@ -63,7 +63,7 @@ export var DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
|
63
63
|
var TABLE_INFO_TIMEOUT = 10000;
|
|
64
64
|
var RENDER_EVENT_SAMPLE_RATE = 0.1;
|
|
65
65
|
var packageName = "@atlaskit/renderer";
|
|
66
|
-
var packageVersion = "133.10.
|
|
66
|
+
var packageVersion = "133.10.6";
|
|
67
67
|
var setAsQueryContainerStyles = css({
|
|
68
68
|
containerName: 'ak-renderer-wrapper',
|
|
69
69
|
containerType: 'inline-size'
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useCallback, useContext } from 'react';
|
|
2
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
2
3
|
import { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
3
4
|
import { updateWindowSelectionAroundDraft } from '../draft/dom';
|
|
4
5
|
import { FabricChannel } from '@atlaskit/analytics-listeners/types';
|
|
@@ -23,7 +24,9 @@ export var Mounter = /*#__PURE__*/React.memo(function (props) {
|
|
|
23
24
|
hoverDraftDocumentPosition = _useAnnotationRangeSt.hoverDraftDocumentPosition;
|
|
24
25
|
var actions = useContext(ActionsContext);
|
|
25
26
|
var onCreateCallback = useCallback(function (annotationId) {
|
|
26
|
-
|
|
27
|
+
// Always use documentPosition directly when gate is on — hoverDraftDocumentPosition
|
|
28
|
+
// in this closure may be stale (captured before state update) (COMMENTS-6594).
|
|
29
|
+
var positionToAnnotate = expValEquals('confluence_inline_comments_fix_stale_selection', 'isEnabled', true) ? documentPosition : hoverDraftDocumentPosition || documentPosition;
|
|
27
30
|
if (!isAnnotationAllowed || !positionToAnnotate || !applyAnnotation) {
|
|
28
31
|
return false;
|
|
29
32
|
}
|
|
@@ -68,6 +71,13 @@ export var Mounter = /*#__PURE__*/React.memo(function (props) {
|
|
|
68
71
|
}
|
|
69
72
|
return false;
|
|
70
73
|
}
|
|
74
|
+
|
|
75
|
+
// Clear any stale draft position before promoting the new one.
|
|
76
|
+
// Without this, if a previous draft was not explicitly closed, hoverDraftDocumentPosition
|
|
77
|
+
// retains the old position and the comment anchors to the wrong text (COMMENTS-6594).
|
|
78
|
+
if (expValEquals('confluence_inline_comments_fix_stale_selection', 'isEnabled', true)) {
|
|
79
|
+
clearHoverDraft();
|
|
80
|
+
}
|
|
71
81
|
promoteHoverToDraft(documentPosition);
|
|
72
82
|
if (createAnalyticsEvent) {
|
|
73
83
|
var uniqueAnnotationsInRange = actions.getAnnotationsByPosition(range);
|
|
@@ -91,7 +101,10 @@ export var Mounter = /*#__PURE__*/React.memo(function (props) {
|
|
|
91
101
|
}
|
|
92
102
|
}
|
|
93
103
|
});
|
|
94
|
-
|
|
104
|
+
|
|
105
|
+
// Always use documentPosition directly when gate is on — hoverDraftDocumentPosition
|
|
106
|
+
// in this closure may be stale (captured before state update) (COMMENTS-6594).
|
|
107
|
+
var positionToAnnotate = expValEquals('confluence_inline_comments_fix_stale_selection', 'isEnabled', true) ? documentPosition : hoverDraftDocumentPosition || documentPosition;
|
|
95
108
|
if (!positionToAnnotate || !applyAnnotation || !options.annotationId) {
|
|
96
109
|
if (createAnalyticsEvent) {
|
|
97
110
|
createAnalyticsEvent({
|
|
@@ -113,7 +126,7 @@ export var Mounter = /*#__PURE__*/React.memo(function (props) {
|
|
|
113
126
|
annotationType: AnnotationTypes.INLINE_COMMENT
|
|
114
127
|
};
|
|
115
128
|
return applyAnnotation(positionToAnnotate, annotation);
|
|
116
|
-
}, [documentPosition, isAnnotationAllowed, createAnalyticsEvent, applyAnnotation, actions, range, promoteHoverToDraft,
|
|
129
|
+
}, [documentPosition, hoverDraftDocumentPosition, isAnnotationAllowed, createAnalyticsEvent, applyAnnotation, actions, range, promoteHoverToDraft, clearHoverDraft]);
|
|
117
130
|
var removeDraftModeCallback = useCallback(function () {
|
|
118
131
|
clearHoverDraft();
|
|
119
132
|
var sel = window.getSelection();
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React, { useCallback, useContext, useMemo, useEffect } from 'react';
|
|
2
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
4
|
|
|
3
5
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
4
6
|
import uuid from 'uuid/v4';
|
|
5
7
|
import { AnnotationTypes, AnnotationMarkStates } from '@atlaskit/adf-schema';
|
|
6
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { updateWindowSelectionAroundDraft } from '../draft/dom';
|
|
8
9
|
import { FabricChannel } from '@atlaskit/analytics-listeners/types';
|
|
9
10
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
@@ -44,10 +45,9 @@ export var SelectionInlineCommentMounter = /*#__PURE__*/React.memo(function (pro
|
|
|
44
45
|
});
|
|
45
46
|
}, [documentPosition, actions, range]);
|
|
46
47
|
var onCreateCallback = useCallback(function (annotationId) {
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
|
|
50
|
-
var positionToAnnotate = selectionDraftDocumentPosition || documentPosition;
|
|
48
|
+
// Use documentPosition directly when gate is on — selectionDraftDocumentPosition may be stale
|
|
49
|
+
// (from a previous selection) causing the comment to anchor to the wrong text (COMMENTS-6594).
|
|
50
|
+
var positionToAnnotate = expValEquals('confluence_inline_comments_fix_stale_selection', 'isEnabled', true) ? documentPosition : selectionDraftDocumentPosition || documentPosition;
|
|
51
51
|
if (!positionToAnnotate || !applyAnnotation) {
|
|
52
52
|
return false;
|
|
53
53
|
}
|
|
@@ -73,7 +73,7 @@ export var SelectionInlineCommentMounter = /*#__PURE__*/React.memo(function (pro
|
|
|
73
73
|
}).fire(FabricChannel.editor);
|
|
74
74
|
}
|
|
75
75
|
return applyAnnotation(positionToAnnotate, annotation);
|
|
76
|
-
}, [actions, documentPosition, applyAnnotation, createAnalyticsEvent, inlineNodeTypes
|
|
76
|
+
}, [actions, documentPosition, selectionDraftDocumentPosition, applyAnnotation, createAnalyticsEvent, inlineNodeTypes]);
|
|
77
77
|
var createIndexCallback = useCallback(function () {
|
|
78
78
|
if (!documentPosition || !generateIndexMatch) {
|
|
79
79
|
return false;
|
|
@@ -101,6 +101,11 @@ export var SelectionInlineCommentMounter = /*#__PURE__*/React.memo(function (pro
|
|
|
101
101
|
}
|
|
102
102
|
return false;
|
|
103
103
|
}
|
|
104
|
+
|
|
105
|
+
// Clear any stale draft position before promoting the new one (COMMENTS-6594).
|
|
106
|
+
if (expValEquals('confluence_inline_comments_fix_stale_selection', 'isEnabled', true)) {
|
|
107
|
+
clearSelectionDraft();
|
|
108
|
+
}
|
|
104
109
|
promoteSelectionToDraft(documentPosition);
|
|
105
110
|
if (createAnalyticsEvent) {
|
|
106
111
|
var uniqueAnnotationsInRange = range ? actions.getAnnotationsByPosition(range) : [];
|
|
@@ -126,11 +131,11 @@ export var SelectionInlineCommentMounter = /*#__PURE__*/React.memo(function (pro
|
|
|
126
131
|
}
|
|
127
132
|
});
|
|
128
133
|
|
|
129
|
-
//
|
|
130
|
-
//
|
|
131
|
-
//
|
|
132
|
-
//
|
|
133
|
-
var positionToAnnotate = fg('platform_editor_comments_api_manager') ? documentPosition : selectionDraftDocumentPosition || documentPosition;
|
|
134
|
+
// Use documentPosition directly when either:
|
|
135
|
+
// - platform_editor_comments_api_manager is on (existing behaviour), OR
|
|
136
|
+
// - COMMENTS-6594 experiment is on (fix: avoids stale closure value)
|
|
137
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
138
|
+
var positionToAnnotate = fg('platform_editor_comments_api_manager') || expValEquals('confluence_inline_comments_fix_stale_selection', 'isEnabled', true) ? documentPosition : selectionDraftDocumentPosition || documentPosition;
|
|
134
139
|
if (!positionToAnnotate || !applyAnnotation || !options.annotationId) {
|
|
135
140
|
if (createAnalyticsEvent) {
|
|
136
141
|
createAnalyticsEvent({
|
|
@@ -152,7 +157,7 @@ export var SelectionInlineCommentMounter = /*#__PURE__*/React.memo(function (pro
|
|
|
152
157
|
annotationType: AnnotationTypes.INLINE_COMMENT
|
|
153
158
|
};
|
|
154
159
|
return applyAnnotation(positionToAnnotate, annotation);
|
|
155
|
-
}, [documentPosition, isAnnotationAllowed, createAnalyticsEvent, applyAnnotation, actions, range, inlineNodeTypes, promoteSelectionToDraft, selectionDraftDocumentPosition]);
|
|
160
|
+
}, [documentPosition, isAnnotationAllowed, createAnalyticsEvent, applyAnnotation, actions, range, inlineNodeTypes, promoteSelectionToDraft, clearSelectionDraft, selectionDraftDocumentPosition]);
|
|
156
161
|
var removeDraftModeCallback = useCallback(function () {
|
|
157
162
|
clearSelectionDraft();
|
|
158
163
|
var sel = window.getSelection();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/renderer",
|
|
3
|
-
"version": "133.
|
|
3
|
+
"version": "133.11.0",
|
|
4
4
|
"description": "Renderer component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"@atlaskit/status": "^5.4.0",
|
|
68
68
|
"@atlaskit/task-decision": "^21.4.0",
|
|
69
69
|
"@atlaskit/theme": "^26.1.0",
|
|
70
|
-
"@atlaskit/tmp-editor-statsig": "^126.
|
|
70
|
+
"@atlaskit/tmp-editor-statsig": "^126.1.0",
|
|
71
71
|
"@atlaskit/tokens": "^15.8.0",
|
|
72
72
|
"@atlaskit/tooltip": "^23.1.0",
|
|
73
73
|
"@atlaskit/visually-hidden": "^4.1.0",
|