@atlaskit/renderer 124.9.9 → 124.9.11
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 +16 -0
- package/dist/cjs/react/nodes/mediaSingle/index.js +2 -2
- package/dist/cjs/ui/Renderer/index.js +1 -1
- package/dist/cjs/ui/annotations/hooks/user-selection.js +34 -81
- package/dist/es2019/react/nodes/mediaSingle/index.js +2 -2
- package/dist/es2019/ui/Renderer/index.js +1 -1
- package/dist/es2019/ui/annotations/hooks/user-selection.js +35 -84
- package/dist/esm/react/nodes/mediaSingle/index.js +2 -2
- package/dist/esm/ui/Renderer/index.js +1 -1
- package/dist/esm/ui/annotations/hooks/user-selection.js +34 -81
- package/package.json +3 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/renderer
|
|
2
2
|
|
|
3
|
+
## 124.9.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`9630c61136f9b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9630c61136f9b) -
|
|
8
|
+
Fixed bug where percentage based width attributes was being used as an aboslute pixel number
|
|
9
|
+
instead of correctly calculating the width.
|
|
10
|
+
|
|
11
|
+
## 124.9.10
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`b0103f4f35c6d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b0103f4f35c6d) -
|
|
16
|
+
Removed fg platform_renderer_triple_click_selects_paragraph
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 124.9.9
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -142,7 +142,7 @@ var MediaSingleWithChildren = function MediaSingleWithChildren(props) {
|
|
|
142
142
|
var containerWidth = getMediaContainerWidth(mediaContainerWidth, layout);
|
|
143
143
|
var cardDimensions = {};
|
|
144
144
|
if ((0, _platformFeatureFlags.fg)('media-perf-uplift-mutation-fix')) {
|
|
145
|
-
var maxWidth = widthAttr && typeof widthAttr === 'number' ? widthAttr : containerWidth;
|
|
145
|
+
var maxWidth = widthAttr && typeof widthAttr === 'number' && widthType === 'pixel' ? widthAttr : containerWidth;
|
|
146
146
|
cardDimensions = {
|
|
147
147
|
width: "".concat(maxWidth, "px"),
|
|
148
148
|
height: "100%"
|
|
@@ -170,7 +170,7 @@ var MediaSingleWithChildren = function MediaSingleWithChildren(props) {
|
|
|
170
170
|
cardDimensions: cardDimensions,
|
|
171
171
|
lineLength: lineLength
|
|
172
172
|
};
|
|
173
|
-
}, [height, isFullWidth, isInsideOfBlockNode, layout, padding, rendererAppearance, width, widthAttr]);
|
|
173
|
+
}, [height, isFullWidth, isInsideOfBlockNode, layout, padding, rendererAppearance, width, widthAttr, widthType]);
|
|
174
174
|
var originalDimensions = (0, _react.useMemo)(function () {
|
|
175
175
|
return {
|
|
176
176
|
width: width,
|
|
@@ -68,7 +68,7 @@ var DEGRADED_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
|
68
68
|
// we want to calculate all the table widths (which causes reflows) after the renderer has finished loading to mitigate performance impact
|
|
69
69
|
var TABLE_WIDTH_INFO_TIMEOUT = 10000;
|
|
70
70
|
var packageName = "@atlaskit/renderer";
|
|
71
|
-
var packageVersion = "
|
|
71
|
+
var packageVersion = "0.0.0-development";
|
|
72
72
|
var setAsQueryContainerStyles = (0, _react2.css)({
|
|
73
73
|
containerName: 'ak-renderer-wrapper',
|
|
74
74
|
containerType: 'inline-size'
|
|
@@ -7,8 +7,6 @@ exports.useUserSelectionRange = void 0;
|
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _AnnotationRangeContext = require("../contexts/AnnotationRangeContext");
|
|
9
9
|
var _utils = require("./utils");
|
|
10
|
-
var _steps = require("../../../steps");
|
|
11
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
10
|
var _AnnotationManagerContext = require("../contexts/AnnotationManagerContext");
|
|
13
11
|
var useUserSelectionRange = exports.useUserSelectionRange = function useUserSelectionRange(props) {
|
|
14
12
|
var rendererDOM = props.rendererRef.current;
|
|
@@ -25,91 +23,46 @@ var useUserSelectionRange = exports.useUserSelectionRange = function useUserSele
|
|
|
25
23
|
var lastRangeRef = (0, _react.useRef)(null);
|
|
26
24
|
var isAnnotationManagerEnabled = !!annotationManager;
|
|
27
25
|
var onSelectionChange = (0, _react.useCallback)(function (event) {
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
clearSelectionRange();
|
|
38
|
-
}
|
|
39
|
-
return;
|
|
26
|
+
if (selectionTimeoutRef.current) {
|
|
27
|
+
clearTimeout(selectionTimeoutRef.current);
|
|
28
|
+
}
|
|
29
|
+
selectionTimeoutRef.current = setTimeout(function () {
|
|
30
|
+
var sel = document.getSelection();
|
|
31
|
+
if (!sel || sel.type !== 'Range' || sel.rangeCount !== 1) {
|
|
32
|
+
lastRangeRef.current = null; // Clear last range if selection is invalid
|
|
33
|
+
if (isAnnotationManagerEnabled) {
|
|
34
|
+
clearSelectionRange();
|
|
40
35
|
}
|
|
41
|
-
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
var _range = sel.getRangeAt(0);
|
|
42
39
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
if (rendererDOM && (0, _utils.isRangeInsideOfRendererContainer)(rendererDOM, _range)) {
|
|
48
|
-
var _range2 = _range,
|
|
49
|
-
startContainer = _range2.startContainer,
|
|
50
|
-
endContainer = _range2.endContainer;
|
|
51
|
-
var isTripleClick = endContainer.nodeType !== Node.TEXT_NODE;
|
|
52
|
-
if (isTripleClick) {
|
|
53
|
-
var p = startContainer;
|
|
54
|
-
while (p && p.nodeName !== 'P' && p !== rendererDOM) {
|
|
55
|
-
p = p.parentNode;
|
|
56
|
-
}
|
|
57
|
-
if (p && p.nodeName === 'P' && p instanceof Element) {
|
|
58
|
-
var _range3 = document.createRange();
|
|
59
|
-
_range3.selectNodeContents(p);
|
|
60
|
-
sel.removeAllRanges();
|
|
61
|
-
sel.addRange(_range3);
|
|
62
|
-
_range = sel.getRangeAt(0);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
setSelectionRange(_range.cloneRange());
|
|
66
|
-
lastRangeRef.current = _range;
|
|
67
|
-
}
|
|
68
|
-
}, 100);
|
|
69
|
-
} else {
|
|
70
|
-
if (selectionTimeoutRef.current) {
|
|
71
|
-
clearTimeout(selectionTimeoutRef.current);
|
|
40
|
+
// Skip if the selection hasn't changed
|
|
41
|
+
if (lastRangeRef.current && _range.compareBoundaryPoints(Range.START_TO_START, lastRangeRef.current) === 0 && _range.compareBoundaryPoints(Range.END_TO_END, lastRangeRef.current) === 0) {
|
|
42
|
+
return;
|
|
72
43
|
}
|
|
73
|
-
|
|
74
|
-
var
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
44
|
+
if (rendererDOM && (0, _utils.isRangeInsideOfRendererContainer)(rendererDOM, _range)) {
|
|
45
|
+
var _range2 = _range,
|
|
46
|
+
startContainer = _range2.startContainer,
|
|
47
|
+
endContainer = _range2.endContainer;
|
|
48
|
+
var isTripleClick = endContainer.nodeType !== Node.TEXT_NODE;
|
|
49
|
+
if (isTripleClick) {
|
|
50
|
+
var p = startContainer;
|
|
51
|
+
while (p && p.nodeName !== 'P' && p !== rendererDOM) {
|
|
52
|
+
p = p.parentNode;
|
|
78
53
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
commonAncestorContainer = _range.commonAncestorContainer;
|
|
86
|
-
var parentNode = startContainer.parentNode;
|
|
87
|
-
|
|
88
|
-
// ED-23493
|
|
89
|
-
// On triple-click in Chrome and Safari, the native Selection API's range has endContainer as a non-text node
|
|
90
|
-
// and commonAncestorContainer as root level div.ak-renderer-document when the node is followed by div or hr.
|
|
91
|
-
|
|
92
|
-
// Triple clicks are the only case that can cause the endContainer to be a non-text node
|
|
93
|
-
// Same check for highlight range logic in confluence/next/packages/comments-util/src/domUtils.ts Line 180
|
|
94
|
-
var isTripleClick = endContainer.nodeType !== Node.TEXT_NODE;
|
|
95
|
-
|
|
96
|
-
// isAnnotationAllowedOnRange range validation is checking if the parent container is root element and disable the comment if it is.
|
|
97
|
-
// platform/packages/editor/renderer/src/steps/index.ts Line 180
|
|
98
|
-
|
|
99
|
-
// This workaround ensures the endContainer is set to a text node when endContainer is non-text and the parent container is the root element
|
|
100
|
-
if (isTripleClick && commonAncestorContainer && commonAncestorContainer.nodeType === Node.ELEMENT_NODE &&
|
|
101
|
-
// Ignored via go/ees005
|
|
102
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
103
|
-
(0, _steps.isRoot)(commonAncestorContainer) && (parentNode === null || parentNode === void 0 ? void 0 : parentNode.nodeName) === 'P' // ignore if the parent node is strong, em, etc.
|
|
104
|
-
) {
|
|
105
|
-
var _parentNode$lastChild, _parentNode$lastChild2;
|
|
106
|
-
var lastChild = parentNode !== null && parentNode !== void 0 && parentNode.lastChild && (parentNode === null || parentNode === void 0 || (_parentNode$lastChild = parentNode.lastChild) === null || _parentNode$lastChild === void 0 ? void 0 : _parentNode$lastChild.nodeType) === Node.TEXT_NODE ? parentNode === null || parentNode === void 0 ? void 0 : parentNode.lastChild : parentNode === null || parentNode === void 0 || (_parentNode$lastChild2 = parentNode.lastChild) === null || _parentNode$lastChild2 === void 0 ? void 0 : _parentNode$lastChild2.childNodes[0];
|
|
107
|
-
_range.setEnd(lastChild, lastChild.length || 0);
|
|
54
|
+
if (p && p.nodeName === 'P' && p instanceof Element) {
|
|
55
|
+
var _range3 = document.createRange();
|
|
56
|
+
_range3.selectNodeContents(p);
|
|
57
|
+
sel.removeAllRanges();
|
|
58
|
+
sel.addRange(_range3);
|
|
59
|
+
_range = sel.getRangeAt(0);
|
|
108
60
|
}
|
|
109
|
-
setSelectionRange(_range.cloneRange());
|
|
110
61
|
}
|
|
111
|
-
|
|
112
|
-
|
|
62
|
+
setSelectionRange(_range.cloneRange());
|
|
63
|
+
lastRangeRef.current = _range;
|
|
64
|
+
}
|
|
65
|
+
}, 100);
|
|
113
66
|
}, [rendererDOM, setSelectionRange, clearSelectionRange, isAnnotationManagerEnabled]);
|
|
114
67
|
(0, _react.useEffect)(function () {
|
|
115
68
|
if (!document || !rendererDOM) {
|
|
@@ -129,7 +129,7 @@ const MediaSingleWithChildren = props => {
|
|
|
129
129
|
const containerWidth = getMediaContainerWidth(mediaContainerWidth, layout);
|
|
130
130
|
let cardDimensions = {};
|
|
131
131
|
if (fg('media-perf-uplift-mutation-fix')) {
|
|
132
|
-
const maxWidth = widthAttr && typeof widthAttr === 'number' ? widthAttr : containerWidth;
|
|
132
|
+
const maxWidth = widthAttr && typeof widthAttr === 'number' && widthType === 'pixel' ? widthAttr : containerWidth;
|
|
133
133
|
cardDimensions = {
|
|
134
134
|
width: `${maxWidth}px`,
|
|
135
135
|
height: `100%`
|
|
@@ -157,7 +157,7 @@ const MediaSingleWithChildren = props => {
|
|
|
157
157
|
cardDimensions,
|
|
158
158
|
lineLength
|
|
159
159
|
};
|
|
160
|
-
}, [height, isFullWidth, isInsideOfBlockNode, layout, padding, rendererAppearance, width, widthAttr]);
|
|
160
|
+
}, [height, isFullWidth, isInsideOfBlockNode, layout, padding, rendererAppearance, width, widthAttr, widthType]);
|
|
161
161
|
const originalDimensions = useMemo(() => ({
|
|
162
162
|
width,
|
|
163
163
|
height
|
|
@@ -54,7 +54,7 @@ export const DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
|
54
54
|
// we want to calculate all the table widths (which causes reflows) after the renderer has finished loading to mitigate performance impact
|
|
55
55
|
const TABLE_WIDTH_INFO_TIMEOUT = 10000;
|
|
56
56
|
const packageName = "@atlaskit/renderer";
|
|
57
|
-
const packageVersion = "
|
|
57
|
+
const packageVersion = "0.0.0-development";
|
|
58
58
|
const setAsQueryContainerStyles = css({
|
|
59
59
|
containerName: 'ak-renderer-wrapper',
|
|
60
60
|
containerType: 'inline-size'
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { useEffect, useRef, useCallback } from 'react';
|
|
2
2
|
import { useAnnotationRangeDispatch, useAnnotationRangeState } from '../contexts/AnnotationRangeContext';
|
|
3
3
|
import { isRangeInsideOfRendererContainer } from './utils';
|
|
4
|
-
import { isRoot } from '../../../steps';
|
|
5
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
4
|
import { useAnnotationManagerDispatch } from '../contexts/AnnotationManagerContext';
|
|
7
5
|
export const useUserSelectionRange = props => {
|
|
8
6
|
const {
|
|
@@ -26,94 +24,47 @@ export const useUserSelectionRange = props => {
|
|
|
26
24
|
const lastRangeRef = useRef(null);
|
|
27
25
|
const isAnnotationManagerEnabled = !!annotationManager;
|
|
28
26
|
const onSelectionChange = useCallback(event => {
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
clearSelectionRange();
|
|
39
|
-
}
|
|
40
|
-
return;
|
|
27
|
+
if (selectionTimeoutRef.current) {
|
|
28
|
+
clearTimeout(selectionTimeoutRef.current);
|
|
29
|
+
}
|
|
30
|
+
selectionTimeoutRef.current = setTimeout(() => {
|
|
31
|
+
const sel = document.getSelection();
|
|
32
|
+
if (!sel || sel.type !== 'Range' || sel.rangeCount !== 1) {
|
|
33
|
+
lastRangeRef.current = null; // Clear last range if selection is invalid
|
|
34
|
+
if (isAnnotationManagerEnabled) {
|
|
35
|
+
clearSelectionRange();
|
|
41
36
|
}
|
|
42
|
-
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
let _range = sel.getRangeAt(0);
|
|
43
40
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
if (rendererDOM && isRangeInsideOfRendererContainer(rendererDOM, _range)) {
|
|
49
|
-
const {
|
|
50
|
-
startContainer,
|
|
51
|
-
endContainer
|
|
52
|
-
} = _range;
|
|
53
|
-
const isTripleClick = endContainer.nodeType !== Node.TEXT_NODE;
|
|
54
|
-
if (isTripleClick) {
|
|
55
|
-
let p = startContainer;
|
|
56
|
-
while (p && p.nodeName !== 'P' && p !== rendererDOM) {
|
|
57
|
-
p = p.parentNode;
|
|
58
|
-
}
|
|
59
|
-
if (p && p.nodeName === 'P' && p instanceof Element) {
|
|
60
|
-
const range = document.createRange();
|
|
61
|
-
range.selectNodeContents(p);
|
|
62
|
-
sel.removeAllRanges();
|
|
63
|
-
sel.addRange(range);
|
|
64
|
-
_range = sel.getRangeAt(0);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
setSelectionRange(_range.cloneRange());
|
|
68
|
-
lastRangeRef.current = _range;
|
|
69
|
-
}
|
|
70
|
-
}, 100);
|
|
71
|
-
} else {
|
|
72
|
-
if (selectionTimeoutRef.current) {
|
|
73
|
-
clearTimeout(selectionTimeoutRef.current);
|
|
41
|
+
// Skip if the selection hasn't changed
|
|
42
|
+
if (lastRangeRef.current && _range.compareBoundaryPoints(Range.START_TO_START, lastRangeRef.current) === 0 && _range.compareBoundaryPoints(Range.END_TO_END, lastRangeRef.current) === 0) {
|
|
43
|
+
return;
|
|
74
44
|
}
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
45
|
+
if (rendererDOM && isRangeInsideOfRendererContainer(rendererDOM, _range)) {
|
|
46
|
+
const {
|
|
47
|
+
startContainer,
|
|
48
|
+
endContainer
|
|
49
|
+
} = _range;
|
|
50
|
+
const isTripleClick = endContainer.nodeType !== Node.TEXT_NODE;
|
|
51
|
+
if (isTripleClick) {
|
|
52
|
+
let p = startContainer;
|
|
53
|
+
while (p && p.nodeName !== 'P' && p !== rendererDOM) {
|
|
54
|
+
p = p.parentNode;
|
|
80
55
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
endContainer,
|
|
88
|
-
commonAncestorContainer
|
|
89
|
-
} = _range;
|
|
90
|
-
const parentNode = startContainer.parentNode;
|
|
91
|
-
|
|
92
|
-
// ED-23493
|
|
93
|
-
// On triple-click in Chrome and Safari, the native Selection API's range has endContainer as a non-text node
|
|
94
|
-
// and commonAncestorContainer as root level div.ak-renderer-document when the node is followed by div or hr.
|
|
95
|
-
|
|
96
|
-
// Triple clicks are the only case that can cause the endContainer to be a non-text node
|
|
97
|
-
// Same check for highlight range logic in confluence/next/packages/comments-util/src/domUtils.ts Line 180
|
|
98
|
-
const isTripleClick = endContainer.nodeType !== Node.TEXT_NODE;
|
|
99
|
-
|
|
100
|
-
// isAnnotationAllowedOnRange range validation is checking if the parent container is root element and disable the comment if it is.
|
|
101
|
-
// platform/packages/editor/renderer/src/steps/index.ts Line 180
|
|
102
|
-
|
|
103
|
-
// This workaround ensures the endContainer is set to a text node when endContainer is non-text and the parent container is the root element
|
|
104
|
-
if (isTripleClick && commonAncestorContainer && commonAncestorContainer.nodeType === Node.ELEMENT_NODE &&
|
|
105
|
-
// Ignored via go/ees005
|
|
106
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
107
|
-
isRoot(commonAncestorContainer) && (parentNode === null || parentNode === void 0 ? void 0 : parentNode.nodeName) === 'P' // ignore if the parent node is strong, em, etc.
|
|
108
|
-
) {
|
|
109
|
-
var _parentNode$lastChild, _parentNode$lastChild2;
|
|
110
|
-
const lastChild = parentNode !== null && parentNode !== void 0 && parentNode.lastChild && (parentNode === null || parentNode === void 0 ? void 0 : (_parentNode$lastChild = parentNode.lastChild) === null || _parentNode$lastChild === void 0 ? void 0 : _parentNode$lastChild.nodeType) === Node.TEXT_NODE ? parentNode === null || parentNode === void 0 ? void 0 : parentNode.lastChild : parentNode === null || parentNode === void 0 ? void 0 : (_parentNode$lastChild2 = parentNode.lastChild) === null || _parentNode$lastChild2 === void 0 ? void 0 : _parentNode$lastChild2.childNodes[0];
|
|
111
|
-
_range.setEnd(lastChild, lastChild.length || 0);
|
|
56
|
+
if (p && p.nodeName === 'P' && p instanceof Element) {
|
|
57
|
+
const range = document.createRange();
|
|
58
|
+
range.selectNodeContents(p);
|
|
59
|
+
sel.removeAllRanges();
|
|
60
|
+
sel.addRange(range);
|
|
61
|
+
_range = sel.getRangeAt(0);
|
|
112
62
|
}
|
|
113
|
-
setSelectionRange(_range.cloneRange());
|
|
114
63
|
}
|
|
115
|
-
|
|
116
|
-
|
|
64
|
+
setSelectionRange(_range.cloneRange());
|
|
65
|
+
lastRangeRef.current = _range;
|
|
66
|
+
}
|
|
67
|
+
}, 100);
|
|
117
68
|
}, [rendererDOM, setSelectionRange, clearSelectionRange, isAnnotationManagerEnabled]);
|
|
118
69
|
useEffect(() => {
|
|
119
70
|
if (!document || !rendererDOM) {
|
|
@@ -132,7 +132,7 @@ var MediaSingleWithChildren = function MediaSingleWithChildren(props) {
|
|
|
132
132
|
var containerWidth = getMediaContainerWidth(mediaContainerWidth, layout);
|
|
133
133
|
var cardDimensions = {};
|
|
134
134
|
if (fg('media-perf-uplift-mutation-fix')) {
|
|
135
|
-
var maxWidth = widthAttr && typeof widthAttr === 'number' ? widthAttr : containerWidth;
|
|
135
|
+
var maxWidth = widthAttr && typeof widthAttr === 'number' && widthType === 'pixel' ? widthAttr : containerWidth;
|
|
136
136
|
cardDimensions = {
|
|
137
137
|
width: "".concat(maxWidth, "px"),
|
|
138
138
|
height: "100%"
|
|
@@ -160,7 +160,7 @@ var MediaSingleWithChildren = function MediaSingleWithChildren(props) {
|
|
|
160
160
|
cardDimensions: cardDimensions,
|
|
161
161
|
lineLength: lineLength
|
|
162
162
|
};
|
|
163
|
-
}, [height, isFullWidth, isInsideOfBlockNode, layout, padding, rendererAppearance, width, widthAttr]);
|
|
163
|
+
}, [height, isFullWidth, isInsideOfBlockNode, layout, padding, rendererAppearance, width, widthAttr, widthType]);
|
|
164
164
|
var originalDimensions = useMemo(function () {
|
|
165
165
|
return {
|
|
166
166
|
width: width,
|
|
@@ -59,7 +59,7 @@ export var DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
|
59
59
|
// we want to calculate all the table widths (which causes reflows) after the renderer has finished loading to mitigate performance impact
|
|
60
60
|
var TABLE_WIDTH_INFO_TIMEOUT = 10000;
|
|
61
61
|
var packageName = "@atlaskit/renderer";
|
|
62
|
-
var packageVersion = "
|
|
62
|
+
var packageVersion = "0.0.0-development";
|
|
63
63
|
var setAsQueryContainerStyles = css({
|
|
64
64
|
containerName: 'ak-renderer-wrapper',
|
|
65
65
|
containerType: 'inline-size'
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { useEffect, useRef, useCallback } from 'react';
|
|
2
2
|
import { useAnnotationRangeDispatch, useAnnotationRangeState } from '../contexts/AnnotationRangeContext';
|
|
3
3
|
import { isRangeInsideOfRendererContainer } from './utils';
|
|
4
|
-
import { isRoot } from '../../../steps';
|
|
5
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
4
|
import { useAnnotationManagerDispatch } from '../contexts/AnnotationManagerContext';
|
|
7
5
|
export var useUserSelectionRange = function useUserSelectionRange(props) {
|
|
8
6
|
var rendererDOM = props.rendererRef.current;
|
|
@@ -19,91 +17,46 @@ export var useUserSelectionRange = function useUserSelectionRange(props) {
|
|
|
19
17
|
var lastRangeRef = useRef(null);
|
|
20
18
|
var isAnnotationManagerEnabled = !!annotationManager;
|
|
21
19
|
var onSelectionChange = useCallback(function (event) {
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
clearSelectionRange();
|
|
32
|
-
}
|
|
33
|
-
return;
|
|
20
|
+
if (selectionTimeoutRef.current) {
|
|
21
|
+
clearTimeout(selectionTimeoutRef.current);
|
|
22
|
+
}
|
|
23
|
+
selectionTimeoutRef.current = setTimeout(function () {
|
|
24
|
+
var sel = document.getSelection();
|
|
25
|
+
if (!sel || sel.type !== 'Range' || sel.rangeCount !== 1) {
|
|
26
|
+
lastRangeRef.current = null; // Clear last range if selection is invalid
|
|
27
|
+
if (isAnnotationManagerEnabled) {
|
|
28
|
+
clearSelectionRange();
|
|
34
29
|
}
|
|
35
|
-
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
var _range = sel.getRangeAt(0);
|
|
36
33
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
if (rendererDOM && isRangeInsideOfRendererContainer(rendererDOM, _range)) {
|
|
42
|
-
var _range2 = _range,
|
|
43
|
-
startContainer = _range2.startContainer,
|
|
44
|
-
endContainer = _range2.endContainer;
|
|
45
|
-
var isTripleClick = endContainer.nodeType !== Node.TEXT_NODE;
|
|
46
|
-
if (isTripleClick) {
|
|
47
|
-
var p = startContainer;
|
|
48
|
-
while (p && p.nodeName !== 'P' && p !== rendererDOM) {
|
|
49
|
-
p = p.parentNode;
|
|
50
|
-
}
|
|
51
|
-
if (p && p.nodeName === 'P' && p instanceof Element) {
|
|
52
|
-
var _range3 = document.createRange();
|
|
53
|
-
_range3.selectNodeContents(p);
|
|
54
|
-
sel.removeAllRanges();
|
|
55
|
-
sel.addRange(_range3);
|
|
56
|
-
_range = sel.getRangeAt(0);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
setSelectionRange(_range.cloneRange());
|
|
60
|
-
lastRangeRef.current = _range;
|
|
61
|
-
}
|
|
62
|
-
}, 100);
|
|
63
|
-
} else {
|
|
64
|
-
if (selectionTimeoutRef.current) {
|
|
65
|
-
clearTimeout(selectionTimeoutRef.current);
|
|
34
|
+
// Skip if the selection hasn't changed
|
|
35
|
+
if (lastRangeRef.current && _range.compareBoundaryPoints(Range.START_TO_START, lastRangeRef.current) === 0 && _range.compareBoundaryPoints(Range.END_TO_END, lastRangeRef.current) === 0) {
|
|
36
|
+
return;
|
|
66
37
|
}
|
|
67
|
-
|
|
68
|
-
var
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
38
|
+
if (rendererDOM && isRangeInsideOfRendererContainer(rendererDOM, _range)) {
|
|
39
|
+
var _range2 = _range,
|
|
40
|
+
startContainer = _range2.startContainer,
|
|
41
|
+
endContainer = _range2.endContainer;
|
|
42
|
+
var isTripleClick = endContainer.nodeType !== Node.TEXT_NODE;
|
|
43
|
+
if (isTripleClick) {
|
|
44
|
+
var p = startContainer;
|
|
45
|
+
while (p && p.nodeName !== 'P' && p !== rendererDOM) {
|
|
46
|
+
p = p.parentNode;
|
|
72
47
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
commonAncestorContainer = _range.commonAncestorContainer;
|
|
80
|
-
var parentNode = startContainer.parentNode;
|
|
81
|
-
|
|
82
|
-
// ED-23493
|
|
83
|
-
// On triple-click in Chrome and Safari, the native Selection API's range has endContainer as a non-text node
|
|
84
|
-
// and commonAncestorContainer as root level div.ak-renderer-document when the node is followed by div or hr.
|
|
85
|
-
|
|
86
|
-
// Triple clicks are the only case that can cause the endContainer to be a non-text node
|
|
87
|
-
// Same check for highlight range logic in confluence/next/packages/comments-util/src/domUtils.ts Line 180
|
|
88
|
-
var isTripleClick = endContainer.nodeType !== Node.TEXT_NODE;
|
|
89
|
-
|
|
90
|
-
// isAnnotationAllowedOnRange range validation is checking if the parent container is root element and disable the comment if it is.
|
|
91
|
-
// platform/packages/editor/renderer/src/steps/index.ts Line 180
|
|
92
|
-
|
|
93
|
-
// This workaround ensures the endContainer is set to a text node when endContainer is non-text and the parent container is the root element
|
|
94
|
-
if (isTripleClick && commonAncestorContainer && commonAncestorContainer.nodeType === Node.ELEMENT_NODE &&
|
|
95
|
-
// Ignored via go/ees005
|
|
96
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
97
|
-
isRoot(commonAncestorContainer) && (parentNode === null || parentNode === void 0 ? void 0 : parentNode.nodeName) === 'P' // ignore if the parent node is strong, em, etc.
|
|
98
|
-
) {
|
|
99
|
-
var _parentNode$lastChild, _parentNode$lastChild2;
|
|
100
|
-
var lastChild = parentNode !== null && parentNode !== void 0 && parentNode.lastChild && (parentNode === null || parentNode === void 0 || (_parentNode$lastChild = parentNode.lastChild) === null || _parentNode$lastChild === void 0 ? void 0 : _parentNode$lastChild.nodeType) === Node.TEXT_NODE ? parentNode === null || parentNode === void 0 ? void 0 : parentNode.lastChild : parentNode === null || parentNode === void 0 || (_parentNode$lastChild2 = parentNode.lastChild) === null || _parentNode$lastChild2 === void 0 ? void 0 : _parentNode$lastChild2.childNodes[0];
|
|
101
|
-
_range.setEnd(lastChild, lastChild.length || 0);
|
|
48
|
+
if (p && p.nodeName === 'P' && p instanceof Element) {
|
|
49
|
+
var _range3 = document.createRange();
|
|
50
|
+
_range3.selectNodeContents(p);
|
|
51
|
+
sel.removeAllRanges();
|
|
52
|
+
sel.addRange(_range3);
|
|
53
|
+
_range = sel.getRangeAt(0);
|
|
102
54
|
}
|
|
103
|
-
setSelectionRange(_range.cloneRange());
|
|
104
55
|
}
|
|
105
|
-
|
|
106
|
-
|
|
56
|
+
setSelectionRange(_range.cloneRange());
|
|
57
|
+
lastRangeRef.current = _range;
|
|
58
|
+
}
|
|
59
|
+
}, 100);
|
|
107
60
|
}, [rendererDOM, setSelectionRange, clearSelectionRange, isAnnotationManagerEnabled]);
|
|
108
61
|
useEffect(function () {
|
|
109
62
|
if (!document || !rendererDOM) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/renderer",
|
|
3
|
-
"version": "124.9.
|
|
3
|
+
"version": "124.9.11",
|
|
4
4
|
"description": "Renderer component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@atlaskit/feature-gate-js-client": "^5.5.0",
|
|
42
42
|
"@atlaskit/icon": "^28.5.0",
|
|
43
43
|
"@atlaskit/link": "^3.2.0",
|
|
44
|
-
"@atlaskit/link-datasource": "^4.
|
|
44
|
+
"@atlaskit/link-datasource": "^4.29.0",
|
|
45
45
|
"@atlaskit/link-extractors": "^2.4.0",
|
|
46
46
|
"@atlaskit/media-card": "^79.6.0",
|
|
47
47
|
"@atlaskit/media-client": "^35.5.0",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"uuid": "^3.1.0"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
|
-
"@atlaskit/editor-common": "^110.
|
|
74
|
+
"@atlaskit/editor-common": "^110.22.0",
|
|
75
75
|
"@atlaskit/link-provider": "^4.0.0",
|
|
76
76
|
"@atlaskit/media-core": "^37.0.0",
|
|
77
77
|
"react": "^18.2.0",
|
|
@@ -182,9 +182,6 @@
|
|
|
182
182
|
"platform_renderer_isPresentational": {
|
|
183
183
|
"type": "boolean"
|
|
184
184
|
},
|
|
185
|
-
"platform_renderer_triple_click_selects_paragraph": {
|
|
186
|
-
"type": "boolean"
|
|
187
|
-
},
|
|
188
185
|
"platform_ssr_smartlink_embeds": {
|
|
189
186
|
"type": "boolean"
|
|
190
187
|
},
|