@atlaskit/renderer 123.2.0 → 123.2.1
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/afm-cc/tsconfig.json +3 -0
- package/dist/cjs/react/nodes/blockCard.js +5 -2
- package/dist/cjs/react/nodes/bodiedExtension.js +4 -3
- package/dist/cjs/react/nodes/multiBodiedExtension.js +2 -1
- package/dist/cjs/ui/Renderer/index.js +1 -1
- package/dist/cjs/ui/hooks/useScrollToLocalId.js +78 -7
- package/dist/es2019/react/nodes/blockCard.js +5 -2
- package/dist/es2019/react/nodes/bodiedExtension.js +4 -3
- package/dist/es2019/react/nodes/multiBodiedExtension.js +2 -1
- package/dist/es2019/ui/Renderer/index.js +1 -1
- package/dist/es2019/ui/hooks/useScrollToLocalId.js +78 -7
- package/dist/esm/react/nodes/blockCard.js +5 -2
- package/dist/esm/react/nodes/bodiedExtension.js +4 -3
- package/dist/esm/react/nodes/multiBodiedExtension.js +2 -1
- package/dist/esm/ui/Renderer/index.js +1 -1
- package/dist/esm/ui/hooks/useScrollToLocalId.js +78 -7
- package/dist/types/react/nodes/blockCard.d.ts +1 -0
- package/dist/types/react/nodes/index.d.ts +1 -0
- package/dist/types-ts4.5/react/nodes/blockCard.d.ts +1 -0
- package/dist/types-ts4.5/react/nodes/index.d.ts +1 -0
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/renderer
|
|
2
2
|
|
|
3
|
+
## 123.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`10f7cde204c1e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/10f7cde204c1e) -
|
|
8
|
+
Increase heading 1 ranking in block menu and add date-local-id on bodiedExtension and blockCard in
|
|
9
|
+
renderer
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 123.2.0
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
package/afm-cc/tsconfig.json
CHANGED
|
@@ -39,7 +39,8 @@ function BlockCard(props) {
|
|
|
39
39
|
data = props.data,
|
|
40
40
|
eventHandlers = props.eventHandlers,
|
|
41
41
|
smartLinks = props.smartLinks,
|
|
42
|
-
isNodeNested = props.isNodeNested
|
|
42
|
+
isNodeNested = props.isNodeNested,
|
|
43
|
+
localId = props.localId;
|
|
43
44
|
var portal = (0, _PortalContext.usePortal)(props);
|
|
44
45
|
var _ref = smartLinks || {},
|
|
45
46
|
actionOptions = _ref.actionOptions;
|
|
@@ -107,6 +108,7 @@ function BlockCard(props) {
|
|
|
107
108
|
return (0, _react.jsx)("div", {
|
|
108
109
|
css: datasourceContainerStyle,
|
|
109
110
|
"data-testid": "renderer-datasource-table",
|
|
111
|
+
"data-local-id": localId,
|
|
110
112
|
style: {
|
|
111
113
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
112
114
|
width: isNodeNested ? '100%' : (0, _utils.calcBreakoutWidth)(layout, width)
|
|
@@ -155,7 +157,8 @@ function BlockCard(props) {
|
|
|
155
157
|
className: "blockCardView-content-wrap",
|
|
156
158
|
"data-block-card": true,
|
|
157
159
|
"data-card-data": data ? JSON.stringify(data) : undefined,
|
|
158
|
-
"data-card-url": url
|
|
160
|
+
"data-card-url": url,
|
|
161
|
+
"data-local-id": localId
|
|
159
162
|
}, (0, _react.jsx)(_fallback.CardErrorBoundary, (0, _extends2.default)({
|
|
160
163
|
unsupportedComponent: _ui.UnsupportedBlock
|
|
161
164
|
// Ignored via go/ees005
|
|
@@ -45,7 +45,8 @@ var BodiedExtension = function BodiedExtension(props) {
|
|
|
45
45
|
extensionKey = props.extensionKey,
|
|
46
46
|
extensionType = props.extensionType,
|
|
47
47
|
parameters = props.parameters,
|
|
48
|
-
extensionViewportSizes = props.extensionViewportSizes
|
|
48
|
+
extensionViewportSizes = props.extensionViewportSizes,
|
|
49
|
+
localId = props.localId;
|
|
49
50
|
var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
|
|
50
51
|
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
51
52
|
var removeOverflow = _react.default.Children.toArray(children)
|
|
@@ -75,7 +76,7 @@ var BodiedExtension = function BodiedExtension(props) {
|
|
|
75
76
|
// Return the content directly if it's a valid JSX.Element
|
|
76
77
|
return (0, _extension.renderExtension)(result, layout, {
|
|
77
78
|
isTopLevel: path.length < 1
|
|
78
|
-
}, removeOverflow, parameters === null || parameters === void 0 ? void 0 : parameters.extensionId, extensionViewportSizes);
|
|
79
|
+
}, removeOverflow, parameters === null || parameters === void 0 ? void 0 : parameters.extensionId, extensionViewportSizes, undefined, localId);
|
|
79
80
|
}
|
|
80
81
|
} catch (e) {
|
|
81
82
|
/** We don't want this error to block renderer */
|
|
@@ -85,7 +86,7 @@ var BodiedExtension = function BodiedExtension(props) {
|
|
|
85
86
|
// Always return default content if anything goes wrong
|
|
86
87
|
return (0, _extension.renderExtension)(children, layout, {
|
|
87
88
|
isTopLevel: path.length < 1
|
|
88
|
-
}, removeOverflow, parameters === null || parameters === void 0 ? void 0 : parameters.extensionId, extensionViewportSizes);
|
|
89
|
+
}, removeOverflow, parameters === null || parameters === void 0 ? void 0 : parameters.extensionId, extensionViewportSizes, undefined, localId);
|
|
89
90
|
}))));
|
|
90
91
|
};
|
|
91
92
|
var _default = exports.default = BodiedExtension;
|
|
@@ -135,7 +135,8 @@ var MultiBodiedExtension = function MultiBodiedExtension(props) {
|
|
|
135
135
|
"data-testid": "multiBodiedExtension--container",
|
|
136
136
|
"data-multiBodiedExtension-container": true,
|
|
137
137
|
"data-active-child-index": activeChildIndex,
|
|
138
|
-
"data-layout": layout
|
|
138
|
+
"data-layout": layout,
|
|
139
|
+
"data-local-id": localId
|
|
139
140
|
}, (0, _react.jsx)(_ui.WidthConsumer, null, function (_ref4) {
|
|
140
141
|
var width = _ref4.width;
|
|
141
142
|
return (0, _react.jsx)(MultiBodiedExtensionWrapper, {
|
|
@@ -63,7 +63,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
63
63
|
var NORMAL_SEVERITY_THRESHOLD = exports.NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
64
64
|
var DEGRADED_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
65
65
|
var packageName = "@atlaskit/renderer";
|
|
66
|
-
var packageVersion = "
|
|
66
|
+
var packageVersion = "0.0.0-development";
|
|
67
67
|
var setAsQueryContainerStyles = (0, _react2.css)({
|
|
68
68
|
containerName: 'ak-renderer-wrapper',
|
|
69
69
|
containerType: 'inline-size'
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useScrollToLocalId = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
|
+
var _browserApis = require("@atlaskit/browser-apis");
|
|
8
9
|
// Find editor node dom with localId - similar to confluence useScrollOnUrlChange.ts
|
|
9
10
|
var getLocalIdSelector = function getLocalIdSelector(localId, container) {
|
|
10
11
|
// Check if the element with data-local-id exists
|
|
@@ -38,6 +39,7 @@ var getLocalIdSelector = function getLocalIdSelector(localId, container) {
|
|
|
38
39
|
};
|
|
39
40
|
var useScrollToLocalId = exports.useScrollToLocalId = function useScrollToLocalId(containerRef, shouldScrollToLocalId) {
|
|
40
41
|
(0, _react.useEffect)(function () {
|
|
42
|
+
var _getDocument;
|
|
41
43
|
// Only run in browser environment
|
|
42
44
|
if (typeof window === 'undefined' || !(containerRef !== null && containerRef !== void 0 && containerRef.current) || !shouldScrollToLocalId) {
|
|
43
45
|
return;
|
|
@@ -46,14 +48,83 @@ var useScrollToLocalId = exports.useScrollToLocalId = function useScrollToLocalI
|
|
|
46
48
|
// Parse URL parameters for block ID
|
|
47
49
|
var urlParams = new URLSearchParams(window.location.search);
|
|
48
50
|
var blockId = urlParams.get('block');
|
|
49
|
-
if (blockId) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
if (!blockId) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
var retryCount = 0;
|
|
55
|
+
// 5 second timeout based on dashboard showing ~4.96s TTI load time
|
|
56
|
+
var maxRetries = 20; // Maximum 20 retries (5 seconds at 250ms intervals)
|
|
57
|
+
var retryInterval = 250; // Check every 250ms
|
|
58
|
+
var intervalId = null;
|
|
59
|
+
var scrollToElement = function scrollToElement() {
|
|
60
|
+
if (containerRef !== null && containerRef !== void 0 && containerRef.current) {
|
|
61
|
+
var element = getLocalIdSelector(blockId, containerRef.current);
|
|
62
|
+
if (element) {
|
|
63
|
+
element.scrollIntoView({
|
|
64
|
+
behavior: 'smooth'
|
|
65
|
+
});
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
};
|
|
71
|
+
var attemptScroll = function attemptScroll() {
|
|
72
|
+
retryCount++;
|
|
73
|
+
|
|
74
|
+
// Try to scroll to element
|
|
75
|
+
if (scrollToElement()) {
|
|
76
|
+
if (intervalId) {
|
|
77
|
+
clearInterval(intervalId);
|
|
78
|
+
intervalId = null;
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Stop retrying if we've exceeded max retries
|
|
84
|
+
if (retryCount >= maxRetries) {
|
|
85
|
+
if (intervalId) {
|
|
86
|
+
clearInterval(intervalId);
|
|
87
|
+
intervalId = null;
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
56
90
|
}
|
|
91
|
+
return false;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// Try to scroll immediately
|
|
95
|
+
if (attemptScroll()) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (((_getDocument = (0, _browserApis.getDocument)()) === null || _getDocument === void 0 ? void 0 : _getDocument.readyState) === 'complete') {
|
|
99
|
+
// Document is already ready, try a few more times with delays
|
|
100
|
+
// This handles cases where elements are added after document ready
|
|
101
|
+
intervalId = setInterval(function () {
|
|
102
|
+
attemptScroll();
|
|
103
|
+
}, retryInterval);
|
|
104
|
+
} else {
|
|
105
|
+
// Document not ready yet, wait for it and then retry
|
|
106
|
+
intervalId = setInterval(function () {
|
|
107
|
+
var _getDocument2;
|
|
108
|
+
if (((_getDocument2 = (0, _browserApis.getDocument)()) === null || _getDocument2 === void 0 ? void 0 : _getDocument2.readyState) === 'complete') {
|
|
109
|
+
attemptScroll();
|
|
110
|
+
} else if (retryCount >= maxRetries) {
|
|
111
|
+
// Stop retrying even if document isn't ready
|
|
112
|
+
if (intervalId) {
|
|
113
|
+
clearInterval(intervalId);
|
|
114
|
+
intervalId = null;
|
|
115
|
+
}
|
|
116
|
+
} else {
|
|
117
|
+
retryCount++;
|
|
118
|
+
}
|
|
119
|
+
}, retryInterval);
|
|
57
120
|
}
|
|
121
|
+
|
|
122
|
+
// Cleanup function
|
|
123
|
+
return function () {
|
|
124
|
+
if (intervalId) {
|
|
125
|
+
clearInterval(intervalId);
|
|
126
|
+
intervalId = null;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
58
129
|
}, [containerRef, shouldScrollToLocalId]);
|
|
59
130
|
};
|
|
@@ -32,7 +32,8 @@ export default function BlockCard(props) {
|
|
|
32
32
|
data,
|
|
33
33
|
eventHandlers,
|
|
34
34
|
smartLinks,
|
|
35
|
-
isNodeNested
|
|
35
|
+
isNodeNested,
|
|
36
|
+
localId
|
|
36
37
|
} = props;
|
|
37
38
|
const portal = usePortal(props);
|
|
38
39
|
const {
|
|
@@ -95,6 +96,7 @@ export default function BlockCard(props) {
|
|
|
95
96
|
}) => jsx("div", {
|
|
96
97
|
css: datasourceContainerStyle,
|
|
97
98
|
"data-testid": "renderer-datasource-table",
|
|
99
|
+
"data-local-id": localId,
|
|
98
100
|
style: {
|
|
99
101
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
100
102
|
width: isNodeNested ? '100%' : calcBreakoutWidth(layout, width)
|
|
@@ -142,7 +144,8 @@ export default function BlockCard(props) {
|
|
|
142
144
|
className: "blockCardView-content-wrap",
|
|
143
145
|
"data-block-card": true,
|
|
144
146
|
"data-card-data": data ? JSON.stringify(data) : undefined,
|
|
145
|
-
"data-card-url": url
|
|
147
|
+
"data-card-url": url,
|
|
148
|
+
"data-local-id": localId
|
|
146
149
|
}, jsx(CardErrorBoundary, _extends({
|
|
147
150
|
unsupportedComponent: UnsupportedBlock
|
|
148
151
|
// Ignored via go/ees005
|
|
@@ -34,7 +34,8 @@ const BodiedExtension = props => {
|
|
|
34
34
|
extensionKey,
|
|
35
35
|
extensionType,
|
|
36
36
|
parameters,
|
|
37
|
-
extensionViewportSizes
|
|
37
|
+
extensionViewportSizes,
|
|
38
|
+
localId
|
|
38
39
|
} = props;
|
|
39
40
|
const {
|
|
40
41
|
createAnalyticsEvent
|
|
@@ -65,7 +66,7 @@ const BodiedExtension = props => {
|
|
|
65
66
|
// Return the content directly if it's a valid JSX.Element
|
|
66
67
|
return renderExtension(result, layout, {
|
|
67
68
|
isTopLevel: path.length < 1
|
|
68
|
-
}, removeOverflow, parameters === null || parameters === void 0 ? void 0 : parameters.extensionId, extensionViewportSizes);
|
|
69
|
+
}, removeOverflow, parameters === null || parameters === void 0 ? void 0 : parameters.extensionId, extensionViewportSizes, undefined, localId);
|
|
69
70
|
}
|
|
70
71
|
} catch (e) {
|
|
71
72
|
/** We don't want this error to block renderer */
|
|
@@ -75,7 +76,7 @@ const BodiedExtension = props => {
|
|
|
75
76
|
// Always return default content if anything goes wrong
|
|
76
77
|
return renderExtension(children, layout, {
|
|
77
78
|
isTopLevel: path.length < 1
|
|
78
|
-
}, removeOverflow, parameters === null || parameters === void 0 ? void 0 : parameters.extensionId, extensionViewportSizes);
|
|
79
|
+
}, removeOverflow, parameters === null || parameters === void 0 ? void 0 : parameters.extensionId, extensionViewportSizes, undefined, localId);
|
|
79
80
|
}))));
|
|
80
81
|
};
|
|
81
82
|
export default BodiedExtension;
|
|
@@ -129,7 +129,8 @@ const MultiBodiedExtension = props => {
|
|
|
129
129
|
"data-testid": "multiBodiedExtension--container",
|
|
130
130
|
"data-multiBodiedExtension-container": true,
|
|
131
131
|
"data-active-child-index": activeChildIndex,
|
|
132
|
-
"data-layout": layout
|
|
132
|
+
"data-layout": layout,
|
|
133
|
+
"data-local-id": localId
|
|
133
134
|
}, jsx(WidthConsumer, null, ({
|
|
134
135
|
width
|
|
135
136
|
}) => jsx(MultiBodiedExtensionWrapper, {
|
|
@@ -49,7 +49,7 @@ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equ
|
|
|
49
49
|
export const NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
50
50
|
export const DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
51
51
|
const packageName = "@atlaskit/renderer";
|
|
52
|
-
const packageVersion = "
|
|
52
|
+
const packageVersion = "0.0.0-development";
|
|
53
53
|
const setAsQueryContainerStyles = css({
|
|
54
54
|
containerName: 'ak-renderer-wrapper',
|
|
55
55
|
containerType: 'inline-size'
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
|
+
import { getDocument } from '@atlaskit/browser-apis';
|
|
2
3
|
|
|
3
4
|
// Find editor node dom with localId - similar to confluence useScrollOnUrlChange.ts
|
|
4
5
|
const getLocalIdSelector = (localId, container) => {
|
|
@@ -33,6 +34,7 @@ const getLocalIdSelector = (localId, container) => {
|
|
|
33
34
|
};
|
|
34
35
|
export const useScrollToLocalId = (containerRef, shouldScrollToLocalId) => {
|
|
35
36
|
useEffect(() => {
|
|
37
|
+
var _getDocument;
|
|
36
38
|
// Only run in browser environment
|
|
37
39
|
if (typeof window === 'undefined' || !(containerRef !== null && containerRef !== void 0 && containerRef.current) || !shouldScrollToLocalId) {
|
|
38
40
|
return;
|
|
@@ -41,14 +43,83 @@ export const useScrollToLocalId = (containerRef, shouldScrollToLocalId) => {
|
|
|
41
43
|
// Parse URL parameters for block ID
|
|
42
44
|
const urlParams = new URLSearchParams(window.location.search);
|
|
43
45
|
const blockId = urlParams.get('block');
|
|
44
|
-
if (blockId) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
if (!blockId) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
let retryCount = 0;
|
|
50
|
+
// 5 second timeout based on dashboard showing ~4.96s TTI load time
|
|
51
|
+
const maxRetries = 20; // Maximum 20 retries (5 seconds at 250ms intervals)
|
|
52
|
+
const retryInterval = 250; // Check every 250ms
|
|
53
|
+
let intervalId = null;
|
|
54
|
+
const scrollToElement = () => {
|
|
55
|
+
if (containerRef !== null && containerRef !== void 0 && containerRef.current) {
|
|
56
|
+
const element = getLocalIdSelector(blockId, containerRef.current);
|
|
57
|
+
if (element) {
|
|
58
|
+
element.scrollIntoView({
|
|
59
|
+
behavior: 'smooth'
|
|
60
|
+
});
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return false;
|
|
65
|
+
};
|
|
66
|
+
const attemptScroll = () => {
|
|
67
|
+
retryCount++;
|
|
68
|
+
|
|
69
|
+
// Try to scroll to element
|
|
70
|
+
if (scrollToElement()) {
|
|
71
|
+
if (intervalId) {
|
|
72
|
+
clearInterval(intervalId);
|
|
73
|
+
intervalId = null;
|
|
74
|
+
}
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Stop retrying if we've exceeded max retries
|
|
79
|
+
if (retryCount >= maxRetries) {
|
|
80
|
+
if (intervalId) {
|
|
81
|
+
clearInterval(intervalId);
|
|
82
|
+
intervalId = null;
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
51
85
|
}
|
|
86
|
+
return false;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// Try to scroll immediately
|
|
90
|
+
if (attemptScroll()) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (((_getDocument = getDocument()) === null || _getDocument === void 0 ? void 0 : _getDocument.readyState) === 'complete') {
|
|
94
|
+
// Document is already ready, try a few more times with delays
|
|
95
|
+
// This handles cases where elements are added after document ready
|
|
96
|
+
intervalId = setInterval(() => {
|
|
97
|
+
attemptScroll();
|
|
98
|
+
}, retryInterval);
|
|
99
|
+
} else {
|
|
100
|
+
// Document not ready yet, wait for it and then retry
|
|
101
|
+
intervalId = setInterval(() => {
|
|
102
|
+
var _getDocument2;
|
|
103
|
+
if (((_getDocument2 = getDocument()) === null || _getDocument2 === void 0 ? void 0 : _getDocument2.readyState) === 'complete') {
|
|
104
|
+
attemptScroll();
|
|
105
|
+
} else if (retryCount >= maxRetries) {
|
|
106
|
+
// Stop retrying even if document isn't ready
|
|
107
|
+
if (intervalId) {
|
|
108
|
+
clearInterval(intervalId);
|
|
109
|
+
intervalId = null;
|
|
110
|
+
}
|
|
111
|
+
} else {
|
|
112
|
+
retryCount++;
|
|
113
|
+
}
|
|
114
|
+
}, retryInterval);
|
|
52
115
|
}
|
|
116
|
+
|
|
117
|
+
// Cleanup function
|
|
118
|
+
return () => {
|
|
119
|
+
if (intervalId) {
|
|
120
|
+
clearInterval(intervalId);
|
|
121
|
+
intervalId = null;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
53
124
|
}, [containerRef, shouldScrollToLocalId]);
|
|
54
125
|
};
|
|
@@ -31,7 +31,8 @@ export default function BlockCard(props) {
|
|
|
31
31
|
data = props.data,
|
|
32
32
|
eventHandlers = props.eventHandlers,
|
|
33
33
|
smartLinks = props.smartLinks,
|
|
34
|
-
isNodeNested = props.isNodeNested
|
|
34
|
+
isNodeNested = props.isNodeNested,
|
|
35
|
+
localId = props.localId;
|
|
35
36
|
var portal = usePortal(props);
|
|
36
37
|
var _ref = smartLinks || {},
|
|
37
38
|
actionOptions = _ref.actionOptions;
|
|
@@ -99,6 +100,7 @@ export default function BlockCard(props) {
|
|
|
99
100
|
return jsx("div", {
|
|
100
101
|
css: datasourceContainerStyle,
|
|
101
102
|
"data-testid": "renderer-datasource-table",
|
|
103
|
+
"data-local-id": localId,
|
|
102
104
|
style: {
|
|
103
105
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
104
106
|
width: isNodeNested ? '100%' : calcBreakoutWidth(layout, width)
|
|
@@ -147,7 +149,8 @@ export default function BlockCard(props) {
|
|
|
147
149
|
className: "blockCardView-content-wrap",
|
|
148
150
|
"data-block-card": true,
|
|
149
151
|
"data-card-data": data ? JSON.stringify(data) : undefined,
|
|
150
|
-
"data-card-url": url
|
|
152
|
+
"data-card-url": url,
|
|
153
|
+
"data-local-id": localId
|
|
151
154
|
}, jsx(CardErrorBoundary, _extends({
|
|
152
155
|
unsupportedComponent: UnsupportedBlock
|
|
153
156
|
// Ignored via go/ees005
|
|
@@ -36,7 +36,8 @@ var BodiedExtension = function BodiedExtension(props) {
|
|
|
36
36
|
extensionKey = props.extensionKey,
|
|
37
37
|
extensionType = props.extensionType,
|
|
38
38
|
parameters = props.parameters,
|
|
39
|
-
extensionViewportSizes = props.extensionViewportSizes
|
|
39
|
+
extensionViewportSizes = props.extensionViewportSizes,
|
|
40
|
+
localId = props.localId;
|
|
40
41
|
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
41
42
|
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
42
43
|
var removeOverflow = React.Children.toArray(children)
|
|
@@ -66,7 +67,7 @@ var BodiedExtension = function BodiedExtension(props) {
|
|
|
66
67
|
// Return the content directly if it's a valid JSX.Element
|
|
67
68
|
return renderExtension(result, layout, {
|
|
68
69
|
isTopLevel: path.length < 1
|
|
69
|
-
}, removeOverflow, parameters === null || parameters === void 0 ? void 0 : parameters.extensionId, extensionViewportSizes);
|
|
70
|
+
}, removeOverflow, parameters === null || parameters === void 0 ? void 0 : parameters.extensionId, extensionViewportSizes, undefined, localId);
|
|
70
71
|
}
|
|
71
72
|
} catch (e) {
|
|
72
73
|
/** We don't want this error to block renderer */
|
|
@@ -76,7 +77,7 @@ var BodiedExtension = function BodiedExtension(props) {
|
|
|
76
77
|
// Always return default content if anything goes wrong
|
|
77
78
|
return renderExtension(children, layout, {
|
|
78
79
|
isTopLevel: path.length < 1
|
|
79
|
-
}, removeOverflow, parameters === null || parameters === void 0 ? void 0 : parameters.extensionId, extensionViewportSizes);
|
|
80
|
+
}, removeOverflow, parameters === null || parameters === void 0 ? void 0 : parameters.extensionId, extensionViewportSizes, undefined, localId);
|
|
80
81
|
}))));
|
|
81
82
|
};
|
|
82
83
|
export default BodiedExtension;
|
|
@@ -127,7 +127,8 @@ var MultiBodiedExtension = function MultiBodiedExtension(props) {
|
|
|
127
127
|
"data-testid": "multiBodiedExtension--container",
|
|
128
128
|
"data-multiBodiedExtension-container": true,
|
|
129
129
|
"data-active-child-index": activeChildIndex,
|
|
130
|
-
"data-layout": layout
|
|
130
|
+
"data-layout": layout,
|
|
131
|
+
"data-local-id": localId
|
|
131
132
|
}, jsx(WidthConsumer, null, function (_ref4) {
|
|
132
133
|
var width = _ref4.width;
|
|
133
134
|
return jsx(MultiBodiedExtensionWrapper, {
|
|
@@ -54,7 +54,7 @@ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equ
|
|
|
54
54
|
export var NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
55
55
|
export var DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
56
56
|
var packageName = "@atlaskit/renderer";
|
|
57
|
-
var packageVersion = "
|
|
57
|
+
var packageVersion = "0.0.0-development";
|
|
58
58
|
var setAsQueryContainerStyles = css({
|
|
59
59
|
containerName: 'ak-renderer-wrapper',
|
|
60
60
|
containerType: 'inline-size'
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
|
+
import { getDocument } from '@atlaskit/browser-apis';
|
|
2
3
|
|
|
3
4
|
// Find editor node dom with localId - similar to confluence useScrollOnUrlChange.ts
|
|
4
5
|
var getLocalIdSelector = function getLocalIdSelector(localId, container) {
|
|
@@ -33,6 +34,7 @@ var getLocalIdSelector = function getLocalIdSelector(localId, container) {
|
|
|
33
34
|
};
|
|
34
35
|
export var useScrollToLocalId = function useScrollToLocalId(containerRef, shouldScrollToLocalId) {
|
|
35
36
|
useEffect(function () {
|
|
37
|
+
var _getDocument;
|
|
36
38
|
// Only run in browser environment
|
|
37
39
|
if (typeof window === 'undefined' || !(containerRef !== null && containerRef !== void 0 && containerRef.current) || !shouldScrollToLocalId) {
|
|
38
40
|
return;
|
|
@@ -41,14 +43,83 @@ export var useScrollToLocalId = function useScrollToLocalId(containerRef, should
|
|
|
41
43
|
// Parse URL parameters for block ID
|
|
42
44
|
var urlParams = new URLSearchParams(window.location.search);
|
|
43
45
|
var blockId = urlParams.get('block');
|
|
44
|
-
if (blockId) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
if (!blockId) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
var retryCount = 0;
|
|
50
|
+
// 5 second timeout based on dashboard showing ~4.96s TTI load time
|
|
51
|
+
var maxRetries = 20; // Maximum 20 retries (5 seconds at 250ms intervals)
|
|
52
|
+
var retryInterval = 250; // Check every 250ms
|
|
53
|
+
var intervalId = null;
|
|
54
|
+
var scrollToElement = function scrollToElement() {
|
|
55
|
+
if (containerRef !== null && containerRef !== void 0 && containerRef.current) {
|
|
56
|
+
var element = getLocalIdSelector(blockId, containerRef.current);
|
|
57
|
+
if (element) {
|
|
58
|
+
element.scrollIntoView({
|
|
59
|
+
behavior: 'smooth'
|
|
60
|
+
});
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return false;
|
|
65
|
+
};
|
|
66
|
+
var attemptScroll = function attemptScroll() {
|
|
67
|
+
retryCount++;
|
|
68
|
+
|
|
69
|
+
// Try to scroll to element
|
|
70
|
+
if (scrollToElement()) {
|
|
71
|
+
if (intervalId) {
|
|
72
|
+
clearInterval(intervalId);
|
|
73
|
+
intervalId = null;
|
|
74
|
+
}
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Stop retrying if we've exceeded max retries
|
|
79
|
+
if (retryCount >= maxRetries) {
|
|
80
|
+
if (intervalId) {
|
|
81
|
+
clearInterval(intervalId);
|
|
82
|
+
intervalId = null;
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
51
85
|
}
|
|
86
|
+
return false;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// Try to scroll immediately
|
|
90
|
+
if (attemptScroll()) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (((_getDocument = getDocument()) === null || _getDocument === void 0 ? void 0 : _getDocument.readyState) === 'complete') {
|
|
94
|
+
// Document is already ready, try a few more times with delays
|
|
95
|
+
// This handles cases where elements are added after document ready
|
|
96
|
+
intervalId = setInterval(function () {
|
|
97
|
+
attemptScroll();
|
|
98
|
+
}, retryInterval);
|
|
99
|
+
} else {
|
|
100
|
+
// Document not ready yet, wait for it and then retry
|
|
101
|
+
intervalId = setInterval(function () {
|
|
102
|
+
var _getDocument2;
|
|
103
|
+
if (((_getDocument2 = getDocument()) === null || _getDocument2 === void 0 ? void 0 : _getDocument2.readyState) === 'complete') {
|
|
104
|
+
attemptScroll();
|
|
105
|
+
} else if (retryCount >= maxRetries) {
|
|
106
|
+
// Stop retrying even if document isn't ready
|
|
107
|
+
if (intervalId) {
|
|
108
|
+
clearInterval(intervalId);
|
|
109
|
+
intervalId = null;
|
|
110
|
+
}
|
|
111
|
+
} else {
|
|
112
|
+
retryCount++;
|
|
113
|
+
}
|
|
114
|
+
}, retryInterval);
|
|
52
115
|
}
|
|
116
|
+
|
|
117
|
+
// Cleanup function
|
|
118
|
+
return function () {
|
|
119
|
+
if (intervalId) {
|
|
120
|
+
clearInterval(intervalId);
|
|
121
|
+
intervalId = null;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
53
124
|
}, [containerRef, shouldScrollToLocalId]);
|
|
54
125
|
};
|
|
@@ -55,6 +55,7 @@ declare const BlockCard: React.ComponentType<{
|
|
|
55
55
|
eventHandlers?: import("@atlaskit/editor-common/ui").EventHandlers;
|
|
56
56
|
isNodeNested?: boolean;
|
|
57
57
|
layout?: string;
|
|
58
|
+
localId?: string;
|
|
58
59
|
portal?: HTMLElement;
|
|
59
60
|
rendererAppearance?: import("../../ui/Renderer/types").RendererAppearance;
|
|
60
61
|
smartLinks?: import("../../types/smartLinksOptions").SmartLinksOptions;
|
|
@@ -55,6 +55,7 @@ declare const BlockCard: React.ComponentType<{
|
|
|
55
55
|
eventHandlers?: import("@atlaskit/editor-common/ui").EventHandlers;
|
|
56
56
|
isNodeNested?: boolean;
|
|
57
57
|
layout?: string;
|
|
58
|
+
localId?: string;
|
|
58
59
|
portal?: HTMLElement;
|
|
59
60
|
rendererAppearance?: import("../../ui/Renderer/types").RendererAppearance;
|
|
60
61
|
smartLinks?: import("../../types/smartLinksOptions").SmartLinksOptions;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/renderer",
|
|
3
|
-
"version": "123.2.
|
|
3
|
+
"version": "123.2.1",
|
|
4
4
|
"description": "Renderer component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"@atlaskit/analytics-listeners": "^9.0.0",
|
|
29
29
|
"@atlaskit/analytics-namespaced-context": "^7.0.0",
|
|
30
30
|
"@atlaskit/analytics-next": "^11.1.0",
|
|
31
|
+
"@atlaskit/browser-apis": "^0.0.1",
|
|
31
32
|
"@atlaskit/button": "^23.4.0",
|
|
32
33
|
"@atlaskit/code": "^17.2.0",
|
|
33
34
|
"@atlaskit/editor-json-transformer": "^8.29.0",
|