@atlaskit/renderer 126.7.0 → 126.8.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 +26 -0
- package/dist/cjs/ui/Renderer/index.js +6 -2
- package/dist/cjs/ui/hooks/useScrollToBlock.js +250 -0
- package/dist/cjs/ui/hooks/useScrollToLocalId.js +14 -0
- package/dist/cjs/ui/hooks/useStableScroll.js +95 -0
- package/dist/es2019/ui/Renderer/index.js +6 -2
- package/dist/es2019/ui/hooks/useScrollToBlock.js +229 -0
- package/dist/es2019/ui/hooks/useScrollToLocalId.js +14 -0
- package/dist/es2019/ui/hooks/useStableScroll.js +88 -0
- package/dist/esm/ui/Renderer/index.js +6 -2
- package/dist/esm/ui/hooks/useScrollToBlock.js +245 -0
- package/dist/esm/ui/hooks/useScrollToLocalId.js +14 -0
- package/dist/esm/ui/hooks/useStableScroll.js +89 -0
- package/dist/types/analytics/events.d.ts +3 -0
- package/dist/types/renderer-context.d.ts +2 -1
- package/dist/types/ui/Renderer/types.d.ts +1 -0
- package/dist/types/ui/hooks/useScrollToBlock.d.ts +23 -0
- package/dist/types/ui/hooks/useScrollToLocalId.d.ts +9 -0
- package/dist/types/ui/hooks/useStableScroll.d.ts +27 -0
- package/dist/types-ts4.5/analytics/events.d.ts +3 -0
- package/dist/types-ts4.5/renderer-context.d.ts +2 -1
- package/dist/types-ts4.5/ui/Renderer/types.d.ts +1 -0
- package/dist/types-ts4.5/ui/hooks/useScrollToBlock.d.ts +23 -0
- package/dist/types-ts4.5/ui/hooks/useScrollToLocalId.d.ts +9 -0
- package/dist/types-ts4.5/ui/hooks/useStableScroll.d.ts +27 -0
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @atlaskit/renderer
|
|
2
2
|
|
|
3
|
+
## 126.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`41941e55fa9b1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/41941e55fa9b1) -
|
|
8
|
+
[ux] Block link scroll behavior now expands collapsed parent expand/nestedExpand nodes before
|
|
9
|
+
scrolling. New feature gate `platform_editor_expand_on_scroll_to_block` controls this behavior:
|
|
10
|
+
- When enabled: Expands parent expand nodes before scrolling (new behavior with better UX)
|
|
11
|
+
- When disabled: Simple scroll without expand handling (safe fallback to original behavior)
|
|
12
|
+
|
|
13
|
+
This ensures the "Copy link to block" feature works correctly when the target block is inside a
|
|
14
|
+
collapsed expand.
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [`b296c8dca4192`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b296c8dca4192) -
|
|
19
|
+
EDITOR-4991 add new value to renderer context to track nested renderer type, used in analytics
|
|
20
|
+
event to track what renderer we are in for synced blocks
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
23
|
+
## 126.7.1
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies
|
|
28
|
+
|
|
3
29
|
## 126.7.0
|
|
4
30
|
|
|
5
31
|
### Minor Changes
|
|
@@ -21,6 +21,7 @@ var _browser = require("@atlaskit/editor-common/browser");
|
|
|
21
21
|
var _performanceMeasures = require("@atlaskit/editor-common/performance-measures");
|
|
22
22
|
var _measureRender = require("@atlaskit/editor-common/performance/measure-render");
|
|
23
23
|
var _navigation = require("@atlaskit/editor-common/performance/navigation");
|
|
24
|
+
var _useScrollToBlock = require("../hooks/useScrollToBlock");
|
|
24
25
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
25
26
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
26
27
|
var _types = require("@atlaskit/analytics-listeners/types");
|
|
@@ -70,7 +71,7 @@ var DEGRADED_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
|
70
71
|
var TABLE_INFO_TIMEOUT = 10000;
|
|
71
72
|
var RENDER_EVENT_SAMPLE_RATE = 0.2;
|
|
72
73
|
var packageName = "@atlaskit/renderer";
|
|
73
|
-
var packageVersion = "
|
|
74
|
+
var packageVersion = "126.7.1";
|
|
74
75
|
var setAsQueryContainerStyles = (0, _react2.css)({
|
|
75
76
|
containerName: 'ak-renderer-wrapper',
|
|
76
77
|
containerType: 'inline-size'
|
|
@@ -192,7 +193,8 @@ var RendererFunctionalComponent = exports.RendererFunctionalComponent = function
|
|
|
192
193
|
return props.dataProviders || new _providerFactory.ProviderFactory();
|
|
193
194
|
}, [props.dataProviders]);
|
|
194
195
|
var _useRendererContext = (0, _rendererContext.useRendererContext)(),
|
|
195
|
-
parentContextContentMode = _useRendererContext.contentMode
|
|
196
|
+
parentContextContentMode = _useRendererContext.contentMode,
|
|
197
|
+
nestedRendererType = _useRendererContext.nestedRendererType;
|
|
196
198
|
var createRendererContext = (0, _react.useMemo)(function () {
|
|
197
199
|
return function (featureFlags, isTopLevelRenderer, contentMode) {
|
|
198
200
|
var normalizedFeatureFlags = (0, _normalizeFeatureFlags.normalizeFeatureFlags)(featureFlags);
|
|
@@ -362,6 +364,7 @@ var RendererFunctionalComponent = exports.RendererFunctionalComponent = function
|
|
|
362
364
|
distortedDuration: renderedMeasurementDistortedDurationMonitor.distortedDuration,
|
|
363
365
|
ttfb: (0, _navigation.getResponseEndTime)(),
|
|
364
366
|
nodes: (0, _countNodes.countNodes)(props.document),
|
|
367
|
+
nestedRendererType: (0, _experiments.editorExperiment)('platform_synced_block', true) && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_1') ? nestedRendererType : undefined,
|
|
365
368
|
severity: severity
|
|
366
369
|
},
|
|
367
370
|
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
@@ -437,6 +440,7 @@ var RendererFunctionalComponent = exports.RendererFunctionalComponent = function
|
|
|
437
440
|
var rendererContext = (0, _react.useMemo)(function () {
|
|
438
441
|
return createRendererContext(props.featureFlags, props.isTopLevelRenderer, props.contentMode);
|
|
439
442
|
}, [props.featureFlags, props.isTopLevelRenderer, createRendererContext, props.contentMode]);
|
|
443
|
+
(0, _useScrollToBlock.useScrollToBlock)(editorRef, props.document);
|
|
440
444
|
try {
|
|
441
445
|
var _rendererContext$feat, _props$media;
|
|
442
446
|
var schema = getSchema(props.schema, props.adfStage);
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useScrollToBlock = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _browserApis = require("@atlaskit/browser-apis");
|
|
9
|
+
var _blockMenu = require("@atlaskit/editor-common/block-menu");
|
|
10
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
11
|
+
var _useStableScroll2 = require("./useStableScroll");
|
|
12
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
13
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
14
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
15
|
+
/**
|
|
16
|
+
* useScrollToBlock - Handler for block link scrolling in the renderer with expand support
|
|
17
|
+
*
|
|
18
|
+
* This hook enables scroll-to-block functionality when blocks may be hidden inside collapsed expands.
|
|
19
|
+
* It searches the ADF document for the target block, identifies any parent expand nodes,
|
|
20
|
+
* expands them if needed, and waits for layout stability before scrolling to the block.
|
|
21
|
+
*
|
|
22
|
+
* This implementation waits for the container to stabilize (no layout shifts) before scrolling,
|
|
23
|
+
* which prevents issues with images loading, dynamic content, or other async operations that
|
|
24
|
+
* cause layout changes.
|
|
25
|
+
*
|
|
26
|
+
* This hook replaces useScrollToLocalId when the platform_editor_expand_on_scroll_to_block experiment is enabled.
|
|
27
|
+
*
|
|
28
|
+
* When platform_editor_expand_on_scroll_to_block experiment is cleaned up:
|
|
29
|
+
* - Remove the experiment check
|
|
30
|
+
* - Delete the deprecated useScrollToLocalId hook
|
|
31
|
+
* - Make this the default scroll-to-block behavior
|
|
32
|
+
*
|
|
33
|
+
* @param containerRef - Optional ref to the renderer container (RendererStyleContainer)
|
|
34
|
+
* @param adfDoc - The ADF document to search for nodes and expand parents
|
|
35
|
+
*/
|
|
36
|
+
var useScrollToBlock = exports.useScrollToBlock = function useScrollToBlock(containerRef, adfDoc) {
|
|
37
|
+
var _useStableScroll = (0, _useStableScroll2.useStableScroll)({
|
|
38
|
+
stabilityWaitTime: 750,
|
|
39
|
+
maxStabilityWaitTime: 10000
|
|
40
|
+
}),
|
|
41
|
+
waitForStability = _useStableScroll.waitForStability,
|
|
42
|
+
cleanupStability = _useStableScroll.cleanup;
|
|
43
|
+
(0, _react.useEffect)(function () {
|
|
44
|
+
var _getDocument;
|
|
45
|
+
// Only run in browser environment.
|
|
46
|
+
if (typeof window === 'undefined' || !(containerRef !== null && containerRef !== void 0 && containerRef.current)) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (!(0, _expValEquals.expValEquals)('platform_editor_expand_on_scroll_to_block', 'isEnabled', true)) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Parse hash fragment for block ID (format: #block-{localId}).
|
|
54
|
+
var hash = window.location.hash;
|
|
55
|
+
var defaultPrefixWithHash = "#".concat(_blockMenu.DEFAULT_BLOCK_LINK_HASH_PREFIX);
|
|
56
|
+
var blockId = hash.startsWith(defaultPrefixWithHash) ? hash.slice(defaultPrefixWithHash.length) : null;
|
|
57
|
+
if (!blockId) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
var retryCount = 0;
|
|
61
|
+
var maxRetries = 40;
|
|
62
|
+
var retryInterval = 250;
|
|
63
|
+
var intervalId = null;
|
|
64
|
+
var hasScrolled = false;
|
|
65
|
+
var cancelExpandAndScroll = null;
|
|
66
|
+
var scrollToElement = function scrollToElement() {
|
|
67
|
+
// Step 1: Search the ADF document for the node with the given blockId.
|
|
68
|
+
// This works even if the node is hidden inside a collapsed expand.
|
|
69
|
+
if (!adfDoc || !(containerRef !== null && containerRef !== void 0 && containerRef.current)) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
var nodeWithExpandParents = (0, _blockMenu.findNodeWithExpandParents)(adfDoc, blockId);
|
|
73
|
+
if (!nodeWithExpandParents) {
|
|
74
|
+
// Node not found in ADF document.
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
var expandParentLocalIds = nodeWithExpandParents.expandParentLocalIds;
|
|
78
|
+
|
|
79
|
+
// Step 2: If the node has expand parents, we need to expand them first.
|
|
80
|
+
if (expandParentLocalIds.length > 0) {
|
|
81
|
+
// Find the expand elements in the DOM using their localIds.
|
|
82
|
+
// Note: We need to expand from outermost to innermost.
|
|
83
|
+
var allExpandsFound = true;
|
|
84
|
+
var anyExpandsCollapsed = false;
|
|
85
|
+
var _iterator = _createForOfIteratorHelper(expandParentLocalIds),
|
|
86
|
+
_step;
|
|
87
|
+
try {
|
|
88
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
89
|
+
var expandLocalId = _step.value;
|
|
90
|
+
var expandContainer = containerRef.current.querySelector("[data-local-id=\"".concat(expandLocalId, "\"]"));
|
|
91
|
+
if (!expandContainer) {
|
|
92
|
+
// Expand not found in DOM yet (shouldn't happen but handle it).
|
|
93
|
+
allExpandsFound = false;
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Check if this expand is collapsed.
|
|
98
|
+
if ((0, _blockMenu.isExpandCollapsed)(expandContainer)) {
|
|
99
|
+
anyExpandsCollapsed = true;
|
|
100
|
+
// Expand it.
|
|
101
|
+
(0, _blockMenu.expandElement)(expandContainer);
|
|
102
|
+
// After expanding, we need to retry to handle nested expands.
|
|
103
|
+
// The DOM needs time to update.
|
|
104
|
+
return false; // Will retry after interval.
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
} catch (err) {
|
|
108
|
+
_iterator.e(err);
|
|
109
|
+
} finally {
|
|
110
|
+
_iterator.f();
|
|
111
|
+
}
|
|
112
|
+
if (!allExpandsFound) {
|
|
113
|
+
// Retry later when expands are in DOM.
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// All parent expands are now open (or we just expanded one and need to wait).
|
|
118
|
+
if (anyExpandsCollapsed) {
|
|
119
|
+
// Just expanded something, wait for DOM update.
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Step 3: Now the target element should be visible in the DOM, find it and scroll.
|
|
125
|
+
var element = (0, _blockMenu.getLocalIdSelector)(blockId, containerRef.current);
|
|
126
|
+
if (!element) {
|
|
127
|
+
// Element still not in DOM, retry.
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Element found and all parent expands are open! Use the utility to scroll.
|
|
132
|
+
// (This will handle any final edge cases and do the actual scrolling).
|
|
133
|
+
// Capture cleanup function to cancel pending timeouts.
|
|
134
|
+
cancelExpandAndScroll = (0, _blockMenu.expandAllParentsThenScroll)(element);
|
|
135
|
+
return true;
|
|
136
|
+
};
|
|
137
|
+
var performScroll = function performScroll() {
|
|
138
|
+
if (hasScrolled) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Try to scroll to element.
|
|
143
|
+
if (scrollToElement()) {
|
|
144
|
+
hasScrolled = true;
|
|
145
|
+
cleanup();
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
var attemptScroll = function attemptScroll() {
|
|
149
|
+
retryCount++;
|
|
150
|
+
|
|
151
|
+
// Try to find the element first.
|
|
152
|
+
if (!adfDoc || !(containerRef !== null && containerRef !== void 0 && containerRef.current)) {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
var nodeWithExpandParents = (0, _blockMenu.findNodeWithExpandParents)(adfDoc, blockId);
|
|
156
|
+
if (!nodeWithExpandParents) {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
var expandParentLocalIds = nodeWithExpandParents.expandParentLocalIds;
|
|
160
|
+
|
|
161
|
+
// Check if all expands are expanded and element exists.
|
|
162
|
+
var allReady = true;
|
|
163
|
+
if (expandParentLocalIds.length > 0) {
|
|
164
|
+
var _iterator2 = _createForOfIteratorHelper(expandParentLocalIds),
|
|
165
|
+
_step2;
|
|
166
|
+
try {
|
|
167
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
168
|
+
var expandLocalId = _step2.value;
|
|
169
|
+
var expandContainer = containerRef.current.querySelector("[data-local-id=\"".concat(expandLocalId, "\"]"));
|
|
170
|
+
if (!expandContainer) {
|
|
171
|
+
allReady = false;
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
if ((0, _blockMenu.isExpandCollapsed)(expandContainer)) {
|
|
175
|
+
(0, _blockMenu.expandElement)(expandContainer);
|
|
176
|
+
allReady = false;
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
} catch (err) {
|
|
181
|
+
_iterator2.e(err);
|
|
182
|
+
} finally {
|
|
183
|
+
_iterator2.f();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
var element = (0, _blockMenu.getLocalIdSelector)(blockId, containerRef.current);
|
|
187
|
+
if (!element) {
|
|
188
|
+
allReady = false;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// If everything is ready, start monitoring for stability.
|
|
192
|
+
if (allReady) {
|
|
193
|
+
if (intervalId) {
|
|
194
|
+
clearInterval(intervalId);
|
|
195
|
+
intervalId = null;
|
|
196
|
+
}
|
|
197
|
+
waitForStability(containerRef.current, performScroll);
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Stop retrying if we've exceeded max retries.
|
|
202
|
+
if (retryCount >= maxRetries) {
|
|
203
|
+
cleanup();
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
return false;
|
|
207
|
+
};
|
|
208
|
+
var cleanup = function cleanup() {
|
|
209
|
+
if (intervalId) {
|
|
210
|
+
clearInterval(intervalId);
|
|
211
|
+
intervalId = null;
|
|
212
|
+
}
|
|
213
|
+
cleanupStability();
|
|
214
|
+
// Cancel any pending expand and scroll operations.
|
|
215
|
+
if (cancelExpandAndScroll) {
|
|
216
|
+
cancelExpandAndScroll();
|
|
217
|
+
cancelExpandAndScroll = null;
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
// Try to scroll immediately.
|
|
222
|
+
if (attemptScroll()) {
|
|
223
|
+
return cleanup;
|
|
224
|
+
}
|
|
225
|
+
if (((_getDocument = (0, _browserApis.getDocument)()) === null || _getDocument === void 0 ? void 0 : _getDocument.readyState) === 'complete') {
|
|
226
|
+
// Document is already ready, try a few more times with delays.
|
|
227
|
+
// This handles cases where elements are added after document ready.
|
|
228
|
+
intervalId = setInterval(function () {
|
|
229
|
+
attemptScroll();
|
|
230
|
+
}, retryInterval);
|
|
231
|
+
} else {
|
|
232
|
+
// Document not ready yet, wait for it and then retry.
|
|
233
|
+
intervalId = setInterval(function () {
|
|
234
|
+
var _getDocument2;
|
|
235
|
+
if (((_getDocument2 = (0, _browserApis.getDocument)()) === null || _getDocument2 === void 0 ? void 0 : _getDocument2.readyState) === 'complete') {
|
|
236
|
+
attemptScroll();
|
|
237
|
+
} else if (retryCount >= maxRetries) {
|
|
238
|
+
cleanup();
|
|
239
|
+
} else {
|
|
240
|
+
retryCount++;
|
|
241
|
+
}
|
|
242
|
+
}, retryInterval);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Cleanup function.
|
|
246
|
+
return cleanup;
|
|
247
|
+
// Intentionally not including adfDoc in the dependency array to avoid unnecessary re-renders.
|
|
248
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
249
|
+
}, [containerRef, waitForStability, cleanupStability]);
|
|
250
|
+
};
|
|
@@ -7,6 +7,7 @@ exports.useScrollToLocalId = void 0;
|
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _browserApis = require("@atlaskit/browser-apis");
|
|
9
9
|
var _blockMenu = require("@atlaskit/editor-common/block-menu");
|
|
10
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
10
11
|
// Find editor node dom with localId - similar to confluence useScrollOnUrlChange.ts
|
|
11
12
|
var getLocalIdSelector = function getLocalIdSelector(localId, container) {
|
|
12
13
|
// Check if the element with data-local-id exists
|
|
@@ -38,6 +39,16 @@ var getLocalIdSelector = function getLocalIdSelector(localId, container) {
|
|
|
38
39
|
}
|
|
39
40
|
return null;
|
|
40
41
|
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* useScrollToLocalId - Handler for block link scrolling in the renderer (traditional pages)
|
|
45
|
+
*
|
|
46
|
+
* This hook is deprecated in favor of useScrollToBlock which supports expanding parent nodes.
|
|
47
|
+
* This hook will be removed when the platform_editor_expand_on_scroll_to_block experiment is cleaned up.
|
|
48
|
+
*
|
|
49
|
+
* @param containerRef - Optional ref to the renderer container (RendererStyleContainer).
|
|
50
|
+
* @param shouldScrollToLocalId - Whether scroll-to-block functionality should be enabled
|
|
51
|
+
*/
|
|
41
52
|
var useScrollToLocalId = exports.useScrollToLocalId = function useScrollToLocalId(containerRef, shouldScrollToLocalId) {
|
|
42
53
|
(0, _react.useEffect)(function () {
|
|
43
54
|
var _getDocument;
|
|
@@ -45,6 +56,9 @@ var useScrollToLocalId = exports.useScrollToLocalId = function useScrollToLocalI
|
|
|
45
56
|
if (typeof window === 'undefined' || !(containerRef !== null && containerRef !== void 0 && containerRef.current) || !shouldScrollToLocalId) {
|
|
46
57
|
return;
|
|
47
58
|
}
|
|
59
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_expand_on_scroll_to_block', 'isEnabled', true)) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
48
62
|
|
|
49
63
|
// Parse hash fragment for block ID (format: #block-{localId})
|
|
50
64
|
var hash = window.location.hash;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useStableScroll = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
/**
|
|
9
|
+
* Hook that provides functionality to wait for layout stability before performing an action.
|
|
10
|
+
* Uses ResizeObserver to detect when a container has stopped resizing (e.g., images finished loading).
|
|
11
|
+
*/
|
|
12
|
+
var useStableScroll = exports.useStableScroll = function useStableScroll() {
|
|
13
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
14
|
+
var _options$stabilityWai = options.stabilityWaitTime,
|
|
15
|
+
stabilityWaitTime = _options$stabilityWai === void 0 ? 200 : _options$stabilityWai,
|
|
16
|
+
_options$maxStability = options.maxStabilityWaitTime,
|
|
17
|
+
maxStabilityWaitTime = _options$maxStability === void 0 ? 10000 : _options$maxStability;
|
|
18
|
+
var stabilityTimeoutRef = (0, _react.useRef)(null);
|
|
19
|
+
var resizeObserverRef = (0, _react.useRef)(null);
|
|
20
|
+
var lastStableTimeRef = (0, _react.useRef)(0);
|
|
21
|
+
var onStableCallbackRef = (0, _react.useRef)(null);
|
|
22
|
+
var cleanup = (0, _react.useCallback)(function () {
|
|
23
|
+
if (stabilityTimeoutRef.current) {
|
|
24
|
+
clearTimeout(stabilityTimeoutRef.current);
|
|
25
|
+
stabilityTimeoutRef.current = null;
|
|
26
|
+
}
|
|
27
|
+
if (resizeObserverRef.current) {
|
|
28
|
+
resizeObserverRef.current.disconnect();
|
|
29
|
+
resizeObserverRef.current = null;
|
|
30
|
+
}
|
|
31
|
+
onStableCallbackRef.current = null;
|
|
32
|
+
lastStableTimeRef.current = 0;
|
|
33
|
+
}, []);
|
|
34
|
+
var scheduleStabilityCheck = (0, _react.useCallback)(function () {
|
|
35
|
+
// Clear any existing stability timeout.
|
|
36
|
+
if (stabilityTimeoutRef.current) {
|
|
37
|
+
clearTimeout(stabilityTimeoutRef.current);
|
|
38
|
+
stabilityTimeoutRef.current = null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Check if we've exceeded the maximum stability wait time.
|
|
42
|
+
var now = Date.now();
|
|
43
|
+
if (lastStableTimeRef.current === 0) {
|
|
44
|
+
lastStableTimeRef.current = now;
|
|
45
|
+
} else if (now - lastStableTimeRef.current > maxStabilityWaitTime) {
|
|
46
|
+
// We've waited too long for stability, call the callback now.
|
|
47
|
+
if (onStableCallbackRef.current) {
|
|
48
|
+
onStableCallbackRef.current();
|
|
49
|
+
cleanup();
|
|
50
|
+
}
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Set a timeout to call the callback after the stability wait time.
|
|
55
|
+
stabilityTimeoutRef.current = setTimeout(function () {
|
|
56
|
+
if (onStableCallbackRef.current) {
|
|
57
|
+
onStableCallbackRef.current();
|
|
58
|
+
cleanup();
|
|
59
|
+
}
|
|
60
|
+
}, stabilityWaitTime);
|
|
61
|
+
}, [stabilityWaitTime, maxStabilityWaitTime, cleanup]);
|
|
62
|
+
var waitForStability = (0, _react.useCallback)(function (container, onStable) {
|
|
63
|
+
// Clean up any existing observer
|
|
64
|
+
cleanup();
|
|
65
|
+
|
|
66
|
+
// Store the callback
|
|
67
|
+
onStableCallbackRef.current = onStable;
|
|
68
|
+
|
|
69
|
+
// Check if ResizeObserver is available
|
|
70
|
+
if (typeof ResizeObserver === 'undefined') {
|
|
71
|
+
// Fallback: just call the callback after the stability wait time
|
|
72
|
+
stabilityTimeoutRef.current = setTimeout(function () {
|
|
73
|
+
if (onStableCallbackRef.current) {
|
|
74
|
+
onStableCallbackRef.current();
|
|
75
|
+
cleanup();
|
|
76
|
+
}
|
|
77
|
+
}, stabilityWaitTime);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Create a ResizeObserver to monitor the container for size changes.
|
|
82
|
+
resizeObserverRef.current = new ResizeObserver(function () {
|
|
83
|
+
// Container size changed, reset stability timer.
|
|
84
|
+
scheduleStabilityCheck();
|
|
85
|
+
});
|
|
86
|
+
resizeObserverRef.current.observe(container);
|
|
87
|
+
|
|
88
|
+
// Start the initial stability check
|
|
89
|
+
scheduleStabilityCheck();
|
|
90
|
+
}, [stabilityWaitTime, scheduleStabilityCheck, cleanup]);
|
|
91
|
+
return {
|
|
92
|
+
waitForStability: waitForStability,
|
|
93
|
+
cleanup: cleanup
|
|
94
|
+
};
|
|
95
|
+
};
|
|
@@ -15,6 +15,7 @@ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-commo
|
|
|
15
15
|
import { startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
|
|
16
16
|
import { getDistortedDurationMonitor } from '@atlaskit/editor-common/performance/measure-render';
|
|
17
17
|
import { getResponseEndTime } from '@atlaskit/editor-common/performance/navigation';
|
|
18
|
+
import { useScrollToBlock } from '../hooks/useScrollToBlock';
|
|
18
19
|
import { getAnalyticsAppearance, getAnalyticsEventSeverity, shouldForceTracking } from '@atlaskit/editor-common/utils';
|
|
19
20
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
20
21
|
import { FabricChannel } from '@atlaskit/analytics-listeners/types';
|
|
@@ -56,7 +57,7 @@ export const DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
|
56
57
|
const TABLE_INFO_TIMEOUT = 10000;
|
|
57
58
|
const RENDER_EVENT_SAMPLE_RATE = 0.2;
|
|
58
59
|
const packageName = "@atlaskit/renderer";
|
|
59
|
-
const packageVersion = "
|
|
60
|
+
const packageVersion = "126.7.1";
|
|
60
61
|
const setAsQueryContainerStyles = css({
|
|
61
62
|
containerName: 'ak-renderer-wrapper',
|
|
62
63
|
containerType: 'inline-size'
|
|
@@ -180,7 +181,8 @@ export const RendererFunctionalComponent = props => {
|
|
|
180
181
|
const mouseDownSelection = useRef(undefined);
|
|
181
182
|
const providerFactory = useMemo(() => props.dataProviders || new ProviderFactory(), [props.dataProviders]);
|
|
182
183
|
const {
|
|
183
|
-
contentMode: parentContextContentMode
|
|
184
|
+
contentMode: parentContextContentMode,
|
|
185
|
+
nestedRendererType
|
|
184
186
|
} = useRendererContext();
|
|
185
187
|
const createRendererContext = useMemo(() => (featureFlags, isTopLevelRenderer, contentMode) => {
|
|
186
188
|
const normalizedFeatureFlags = normalizeFeatureFlags(featureFlags);
|
|
@@ -354,6 +356,7 @@ export const RendererFunctionalComponent = props => {
|
|
|
354
356
|
distortedDuration: renderedMeasurementDistortedDurationMonitor.distortedDuration,
|
|
355
357
|
ttfb: getResponseEndTime(),
|
|
356
358
|
nodes: countNodes(props.document),
|
|
359
|
+
nestedRendererType: editorExperiment('platform_synced_block', true) && fg('platform_synced_block_patch_1') ? nestedRendererType : undefined,
|
|
357
360
|
severity
|
|
358
361
|
},
|
|
359
362
|
eventType: EVENT_TYPE.OPERATIONAL
|
|
@@ -428,6 +431,7 @@ export const RendererFunctionalComponent = props => {
|
|
|
428
431
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
429
432
|
}, []);
|
|
430
433
|
const rendererContext = useMemo(() => createRendererContext(props.featureFlags, props.isTopLevelRenderer, props.contentMode), [props.featureFlags, props.isTopLevelRenderer, createRendererContext, props.contentMode]);
|
|
434
|
+
useScrollToBlock(editorRef, props.document);
|
|
431
435
|
try {
|
|
432
436
|
var _rendererContext$feat, _props$media;
|
|
433
437
|
const schema = getSchema(props.schema, props.adfStage);
|