@atlaskit/renderer 118.6.5 → 118.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/cjs/ui/Renderer/index.js +1 -1
- package/dist/cjs/ui/annotations/hooks/user-selection.js +7 -1
- package/dist/cjs/ui/annotations/selection/mounter.js +10 -7
- package/dist/cjs/ui/annotations/selection/range-validator.js +2 -0
- package/dist/es2019/ui/Renderer/index.js +1 -1
- package/dist/es2019/ui/annotations/hooks/user-selection.js +7 -1
- package/dist/es2019/ui/annotations/selection/mounter.js +10 -7
- package/dist/es2019/ui/annotations/selection/range-validator.js +2 -0
- package/dist/esm/ui/Renderer/index.js +1 -1
- package/dist/esm/ui/annotations/hooks/user-selection.js +7 -1
- package/dist/esm/ui/annotations/selection/mounter.js +10 -7
- package/dist/esm/ui/annotations/selection/range-validator.js +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/renderer
|
|
2
2
|
|
|
3
|
+
## 118.6.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#163587](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/163587)
|
|
8
|
+
[`59a3ee21507aa`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/59a3ee21507aa) -
|
|
9
|
+
EDITOR-835 - Can not start another draft after starting a draft in renderer
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 118.6.5
|
|
4
13
|
|
|
5
14
|
### 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.
|
|
65
|
+
var packageVersion = "118.6.6";
|
|
66
66
|
var setAsQueryContainerStyles = (0, _react2.css)({
|
|
67
67
|
containerName: 'ak-renderer-wrapper',
|
|
68
68
|
containerType: 'inline-size'
|
|
@@ -29,6 +29,9 @@ var useUserSelectionRange = exports.useUserSelectionRange = function useUserSele
|
|
|
29
29
|
var sel = document.getSelection();
|
|
30
30
|
if (!sel || sel.type !== 'Range' || sel.rangeCount !== 1) {
|
|
31
31
|
lastRangeRef.current = null; // Clear last range if selection is invalid
|
|
32
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_comments_api_manager')) {
|
|
33
|
+
clearSelectionRange();
|
|
34
|
+
}
|
|
32
35
|
return;
|
|
33
36
|
}
|
|
34
37
|
var _range = sel.getRangeAt(0);
|
|
@@ -66,6 +69,9 @@ var useUserSelectionRange = exports.useUserSelectionRange = function useUserSele
|
|
|
66
69
|
selectionTimeoutRef.current = setTimeout(function () {
|
|
67
70
|
var sel = document.getSelection();
|
|
68
71
|
if (!sel || sel.type !== 'Range' || sel.rangeCount !== 1) {
|
|
72
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_comments_api_manager')) {
|
|
73
|
+
clearSelectionRange();
|
|
74
|
+
}
|
|
69
75
|
return;
|
|
70
76
|
}
|
|
71
77
|
var _range = sel.getRangeAt(0);
|
|
@@ -100,7 +106,7 @@ var useUserSelectionRange = exports.useUserSelectionRange = function useUserSele
|
|
|
100
106
|
}
|
|
101
107
|
}, 250);
|
|
102
108
|
}
|
|
103
|
-
}, [rendererDOM, setSelectionRange]);
|
|
109
|
+
}, [rendererDOM, setSelectionRange, clearSelectionRange]);
|
|
104
110
|
(0, _react.useEffect)(function () {
|
|
105
111
|
if (!document || !rendererDOM) {
|
|
106
112
|
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
|
-
|
|
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
|
|
223
|
-
|
|
224
|
-
|
|
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.
|
|
51
|
+
const packageVersion = "118.6.6";
|
|
52
52
|
const setAsQueryContainerStyles = css({
|
|
53
53
|
containerName: 'ak-renderer-wrapper',
|
|
54
54
|
containerType: 'inline-size'
|
|
@@ -29,6 +29,9 @@ export const useUserSelectionRange = props => {
|
|
|
29
29
|
const sel = document.getSelection();
|
|
30
30
|
if (!sel || sel.type !== 'Range' || sel.rangeCount !== 1) {
|
|
31
31
|
lastRangeRef.current = null; // Clear last range if selection is invalid
|
|
32
|
+
if (fg('platform_editor_comments_api_manager')) {
|
|
33
|
+
clearSelectionRange();
|
|
34
|
+
}
|
|
32
35
|
return;
|
|
33
36
|
}
|
|
34
37
|
let _range = sel.getRangeAt(0);
|
|
@@ -67,6 +70,9 @@ export const useUserSelectionRange = props => {
|
|
|
67
70
|
selectionTimeoutRef.current = setTimeout(() => {
|
|
68
71
|
const sel = document.getSelection();
|
|
69
72
|
if (!sel || sel.type !== 'Range' || sel.rangeCount !== 1) {
|
|
73
|
+
if (fg('platform_editor_comments_api_manager')) {
|
|
74
|
+
clearSelectionRange();
|
|
75
|
+
}
|
|
70
76
|
return;
|
|
71
77
|
}
|
|
72
78
|
const _range = sel.getRangeAt(0);
|
|
@@ -103,7 +109,7 @@ export const useUserSelectionRange = props => {
|
|
|
103
109
|
}
|
|
104
110
|
}, 250);
|
|
105
111
|
}
|
|
106
|
-
}, [rendererDOM, setSelectionRange]);
|
|
112
|
+
}, [rendererDOM, setSelectionRange, clearSelectionRange]);
|
|
107
113
|
useEffect(() => {
|
|
108
114
|
if (!document || !rendererDOM) {
|
|
109
115
|
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
|
-
|
|
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
|
|
220
|
-
|
|
221
|
-
|
|
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.
|
|
56
|
+
var packageVersion = "118.6.6";
|
|
57
57
|
var setAsQueryContainerStyles = css({
|
|
58
58
|
containerName: 'ak-renderer-wrapper',
|
|
59
59
|
containerType: 'inline-size'
|
|
@@ -23,6 +23,9 @@ export var useUserSelectionRange = function useUserSelectionRange(props) {
|
|
|
23
23
|
var sel = document.getSelection();
|
|
24
24
|
if (!sel || sel.type !== 'Range' || sel.rangeCount !== 1) {
|
|
25
25
|
lastRangeRef.current = null; // Clear last range if selection is invalid
|
|
26
|
+
if (fg('platform_editor_comments_api_manager')) {
|
|
27
|
+
clearSelectionRange();
|
|
28
|
+
}
|
|
26
29
|
return;
|
|
27
30
|
}
|
|
28
31
|
var _range = sel.getRangeAt(0);
|
|
@@ -60,6 +63,9 @@ export var useUserSelectionRange = function useUserSelectionRange(props) {
|
|
|
60
63
|
selectionTimeoutRef.current = setTimeout(function () {
|
|
61
64
|
var sel = document.getSelection();
|
|
62
65
|
if (!sel || sel.type !== 'Range' || sel.rangeCount !== 1) {
|
|
66
|
+
if (fg('platform_editor_comments_api_manager')) {
|
|
67
|
+
clearSelectionRange();
|
|
68
|
+
}
|
|
63
69
|
return;
|
|
64
70
|
}
|
|
65
71
|
var _range = sel.getRangeAt(0);
|
|
@@ -94,7 +100,7 @@ export var useUserSelectionRange = function useUserSelectionRange(props) {
|
|
|
94
100
|
}
|
|
95
101
|
}, 250);
|
|
96
102
|
}
|
|
97
|
-
}, [rendererDOM, setSelectionRange]);
|
|
103
|
+
}, [rendererDOM, setSelectionRange, clearSelectionRange]);
|
|
98
104
|
useEffect(function () {
|
|
99
105
|
if (!document || !rendererDOM) {
|
|
100
106
|
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
|
-
|
|
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
|
|
214
|
-
|
|
215
|
-
|
|
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
|
}
|