@atlaskit/renderer 137.1.3 → 137.1.4
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 +30 -0
- package/dist/cjs/react/index.js +7 -19
- package/dist/cjs/react/utils/EditorMediaClientProvider.js +1 -1
- package/dist/cjs/ui/Expand.js +65 -81
- package/dist/cjs/ui/Renderer/index.js +1 -1
- package/dist/cjs/ui/utils/expand-search-text.js +98 -0
- package/dist/es2019/react/index.js +8 -18
- package/dist/es2019/react/utils/EditorMediaClientProvider.js +1 -1
- package/dist/es2019/ui/Expand.js +42 -61
- package/dist/es2019/ui/Renderer/index.js +1 -1
- package/dist/es2019/ui/utils/expand-search-text.js +84 -0
- package/dist/esm/react/index.js +8 -20
- package/dist/esm/react/utils/EditorMediaClientProvider.js +1 -1
- package/dist/esm/ui/Expand.js +65 -81
- package/dist/esm/ui/Renderer/index.js +1 -1
- package/dist/esm/ui/utils/expand-search-text.js +93 -0
- package/dist/types/ui/Expand.d.ts +8 -2
- package/dist/types/ui/utils/expand-search-text.d.ts +12 -0
- package/package.json +3 -6
package/dist/es2019/ui/Expand.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
6
6
|
import { css, jsx } from '@emotion/react';
|
|
7
|
-
import React, { useCallback,
|
|
7
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
8
8
|
import { bind } from 'bind-event-listener';
|
|
9
9
|
import { getDocument } from '@atlaskit/browser-apis';
|
|
10
10
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
@@ -12,8 +12,9 @@ import { ExpandIconWrapper, ExpandLayoutWrapperWithRef, expandMessages, WidthPro
|
|
|
12
12
|
import { akEditorLineHeight, akEditorSwoopCubicBezier, akLayoutGutterOffset } from '@atlaskit/editor-shared-styles';
|
|
13
13
|
import ChevronRightIcon from '@atlaskit/icon/core/chevron-right';
|
|
14
14
|
import Tooltip from '@atlaskit/tooltip/Tooltip';
|
|
15
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
15
16
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
16
|
-
import {
|
|
17
|
+
import { getExpandSearchText } from './utils/expand-search-text';
|
|
17
18
|
import _uniqueId from 'lodash/uniqueId';
|
|
18
19
|
import { injectIntl } from 'react-intl';
|
|
19
20
|
import { MODE, PLATFORM } from '../analytics/events';
|
|
@@ -153,17 +154,6 @@ const clearNextSiblingMarginTopStyle = css({
|
|
|
153
154
|
marginTop: '0 !important'
|
|
154
155
|
}
|
|
155
156
|
});
|
|
156
|
-
|
|
157
|
-
// Lazy-loaded children component
|
|
158
|
-
const LazyChildren = /*#__PURE__*/lazy(() => {
|
|
159
|
-
return Promise.resolve({
|
|
160
|
-
default: ({
|
|
161
|
-
children
|
|
162
|
-
}) => {
|
|
163
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
157
|
const Container = props => {
|
|
168
158
|
return jsx("div", {
|
|
169
159
|
css: [containerStyles, props['data-node-type'] === 'expand' && containerStylesDataNodeTypeExpand, props.expanded && containerStylesExpanded, props.focused && containerStylesFocused],
|
|
@@ -223,12 +213,19 @@ function Expand({
|
|
|
223
213
|
localId,
|
|
224
214
|
nestedHeaderIds,
|
|
225
215
|
rendererContentMode,
|
|
226
|
-
|
|
227
|
-
searchText
|
|
216
|
+
node
|
|
228
217
|
}) {
|
|
229
|
-
const [expanded, setExpanded] =
|
|
230
|
-
const [focused, setFocused] =
|
|
231
|
-
|
|
218
|
+
const [expanded, setExpanded] = useState(false);
|
|
219
|
+
const [focused, setFocused] = useState(false);
|
|
220
|
+
/**
|
|
221
|
+
* PGXT-9021: latches on the first open so the body stays mounted once rendered, including after
|
|
222
|
+
* the expand is collapsed again. Remounting it would re-run every macro and Forge data fetch
|
|
223
|
+
* inside on each reopen, which is both slower and visibly reloads content the reader has already
|
|
224
|
+
* seen. The saving this gate exists for is at initial load, where the body has never been opened,
|
|
225
|
+
* so nothing is given up by keeping it after that. Never set on the server, so the server and the
|
|
226
|
+
* client's first render agree and hydration cannot desync.
|
|
227
|
+
*/
|
|
228
|
+
const [hasBeenExpanded, setHasBeenExpanded] = useState(false);
|
|
232
229
|
const isMobile = false;
|
|
233
230
|
const label = intl.formatMessage(expanded ? expandMessages.collapseNode : expandMessages.expandNode);
|
|
234
231
|
const {
|
|
@@ -238,16 +235,12 @@ function Expand({
|
|
|
238
235
|
const contentWrapperRef = useRef(null);
|
|
239
236
|
const handleFocus = useCallback(() => setFocused(true), []);
|
|
240
237
|
const handleBlur = useCallback(() => setFocused(false), []);
|
|
241
|
-
|
|
242
|
-
|
|
238
|
+
// Both state updates happen in the same handler so they land in one render, rather than the
|
|
239
|
+
// latch reacting to `expanded` from an effect.
|
|
240
|
+
const openBody = useCallback(() => {
|
|
243
241
|
setExpanded(true);
|
|
242
|
+
setHasBeenExpanded(true);
|
|
244
243
|
}, []);
|
|
245
|
-
const shouldRenderLazyChildren = hasLoadedChildren || loadBodyContent;
|
|
246
|
-
// Only render the lightweight text placeholder when lazy load is ON and
|
|
247
|
-
// children haven't been loaded yet. When lazy load is OFF, children are
|
|
248
|
-
// always in the DOM — hidden="until-found" on the wrapper already makes
|
|
249
|
-
// them searchable by browser find, so no placeholder is needed.
|
|
250
|
-
const shouldRenderBrowserFindText = !shouldRenderLazyChildren && searchText && fg('hot-121622_lazy_load_expand_content') && expValEquals('platform_editor_close_expand_find', 'isEnabled', true);
|
|
251
244
|
|
|
252
245
|
// Feature-detect hidden="until-found" support via the beforematch event.
|
|
253
246
|
// Chrome 102+ and Firefox 130+ support it; Safari does not yet.
|
|
@@ -256,8 +249,8 @@ function Expand({
|
|
|
256
249
|
// Initialised as false and set in useEffect to avoid SSR/client hydration mismatch —
|
|
257
250
|
// useMemo would return true on the client's first render in supported browsers,
|
|
258
251
|
// differing from the server snapshot which always produces false.
|
|
259
|
-
const [supportsHiddenUntilFound, setSupportsHiddenUntilFound] =
|
|
260
|
-
|
|
252
|
+
const [supportsHiddenUntilFound, setSupportsHiddenUntilFound] = useState(false);
|
|
253
|
+
useEffect(() => {
|
|
261
254
|
const doc = getDocument();
|
|
262
255
|
setSupportsHiddenUntilFound(doc !== null && doc !== void 0 && doc.body ? 'onbeforematch' in doc.body : false);
|
|
263
256
|
}, []);
|
|
@@ -273,13 +266,13 @@ function Expand({
|
|
|
273
266
|
// In unsupported browsers (Safari), we skip this entirely and fall back to the normal
|
|
274
267
|
// CSS hiding (visibility:hidden + height:0), which doesn't support find-in-page but
|
|
275
268
|
// still works correctly for expand/collapse.
|
|
276
|
-
|
|
269
|
+
useEffect(() => {
|
|
277
270
|
const contentContainer = contentContainerRef.current;
|
|
278
271
|
const contentWrapper = contentWrapperRef.current;
|
|
279
272
|
if (!contentWrapper) {
|
|
280
273
|
return;
|
|
281
274
|
}
|
|
282
|
-
if (supportsHiddenUntilFound &&
|
|
275
|
+
if (supportsHiddenUntilFound && isExperimentEnabled('platform_editor_close_expand_find') && !expanded) {
|
|
283
276
|
contentWrapper.setAttribute('hidden', 'until-found');
|
|
284
277
|
// Override the CSS visibility:hidden from contentContainerStyles — hidden="until-found"
|
|
285
278
|
// now handles hiding via content-visibility:hidden, which allows browser find to index
|
|
@@ -293,31 +286,27 @@ function Expand({
|
|
|
293
286
|
contentWrapper.style.visibility = '';
|
|
294
287
|
}
|
|
295
288
|
}, [expanded, supportsHiddenUntilFound]);
|
|
296
|
-
|
|
297
|
-
if (!
|
|
289
|
+
useEffect(() => {
|
|
290
|
+
if (!isExperimentEnabled('platform_editor_close_expand_find') || expanded) {
|
|
298
291
|
return;
|
|
299
292
|
}
|
|
300
293
|
const contentWrapper = contentWrapperRef.current;
|
|
301
294
|
const unbindWrapperBeforeMatch = contentWrapper && supportsHiddenUntilFound ? bind(contentWrapper, {
|
|
302
295
|
type: 'beforematch',
|
|
303
|
-
listener:
|
|
296
|
+
listener: openBody
|
|
304
297
|
}) : undefined;
|
|
305
298
|
return () => {
|
|
306
299
|
unbindWrapperBeforeMatch === null || unbindWrapperBeforeMatch === void 0 ? void 0 : unbindWrapperBeforeMatch();
|
|
307
300
|
};
|
|
308
|
-
}, [
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
expandContent = jsx(Suspense, {
|
|
318
|
-
fallback: jsx("div", null, intl.formatMessage(expandMessages.loading))
|
|
319
|
-
}, jsx(LazyChildren, null, children));
|
|
320
|
-
}
|
|
301
|
+
}, [expanded, openBody, supportsHiddenUntilFound]);
|
|
302
|
+
|
|
303
|
+
// Until the expand is first opened, stand in a plain-text mirror of the body so
|
|
304
|
+
// hidden="until-found" keeps the content findable by browser find without mounting the real
|
|
305
|
+
// subtree. The beforematch listener above expands before the browser scrolls to its match.
|
|
306
|
+
// Computed lazily: a nested expand is not mounted until its ancestor opens, so its mirror is
|
|
307
|
+
// never built on initial load.
|
|
308
|
+
const searchText = useMemo(() => node && fg('hot-121622_lazy_load_expand_content') ? getExpandSearchText(node) : undefined, [node]);
|
|
309
|
+
const expandContent = searchText && !expanded && !hasBeenExpanded ? jsx("span", null, searchText) : children;
|
|
321
310
|
return jsx(Container, {
|
|
322
311
|
"data-testid": `expand-container-${nodeType}-${id}`,
|
|
323
312
|
"data-node-type": nodeType,
|
|
@@ -327,15 +316,8 @@ function Expand({
|
|
|
327
316
|
expanded: expanded,
|
|
328
317
|
focused: focused
|
|
329
318
|
}, nestedHeaderIds && nestedHeaderIds.length > 0 ? jsx(ActiveHeaderIdConsumer, {
|
|
330
|
-
nestedHeaderIds: nestedHeaderIds
|
|
331
|
-
|
|
332
|
-
,
|
|
333
|
-
onNestedHeaderIdMatch: () => {
|
|
334
|
-
if (!hasLoadedChildren) {
|
|
335
|
-
setHasLoadedChildren(true);
|
|
336
|
-
}
|
|
337
|
-
setExpanded(true);
|
|
338
|
-
}
|
|
319
|
+
nestedHeaderIds: nestedHeaderIds,
|
|
320
|
+
onNestedHeaderIdMatch: openBody
|
|
339
321
|
}) : null, jsx(TitleContainer
|
|
340
322
|
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
341
323
|
, {
|
|
@@ -343,12 +325,11 @@ function Expand({
|
|
|
343
325
|
e.preventDefault();
|
|
344
326
|
e.stopPropagation();
|
|
345
327
|
fireExpandToggleAnalytics(nodeType, expanded, fireAnalyticsEvent);
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
328
|
+
if (expanded) {
|
|
329
|
+
setExpanded(false);
|
|
330
|
+
} else {
|
|
331
|
+
openBody();
|
|
350
332
|
}
|
|
351
|
-
setExpanded(!expanded);
|
|
352
333
|
e.persist();
|
|
353
334
|
// @ts-ignore detail doesn't exist on type
|
|
354
335
|
e.detail ? handleBlur() : handleFocus();
|
|
@@ -383,7 +364,7 @@ function Expand({
|
|
|
383
364
|
id: id
|
|
384
365
|
}, title || intl.formatMessage(expandMessages.expandDefaultTitle))), jsx(ContentContainer, {
|
|
385
366
|
expanded: expanded,
|
|
386
|
-
enableBrowserFind: supportsHiddenUntilFound &&
|
|
367
|
+
enableBrowserFind: supportsHiddenUntilFound && isExperimentEnabled('platform_editor_close_expand_find'),
|
|
387
368
|
contentRef: contentContainerRef
|
|
388
369
|
}, jsx("div", {
|
|
389
370
|
className: `${nodeType}-content-wrapper`,
|
|
@@ -60,7 +60,7 @@ export const DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
|
60
60
|
const TABLE_INFO_TIMEOUT = 10000;
|
|
61
61
|
const RENDER_EVENT_SAMPLE_RATE = 0.1;
|
|
62
62
|
const packageName = "@atlaskit/renderer";
|
|
63
|
-
const packageVersion = "137.1.
|
|
63
|
+
const packageVersion = "137.1.3";
|
|
64
64
|
const setAsQueryContainerStyles = css({
|
|
65
65
|
containerName: 'ak-renderer-wrapper',
|
|
66
66
|
containerType: 'inline-size'
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { findChildrenByMark } from '@atlaskit/editor-prosemirror/utils';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Minimal structural view of an ADF entity. `parameters.nestedContent` holds raw ADF JSON rather
|
|
5
|
+
* than ProseMirror nodes, so it cannot be walked with the model API.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** Separates text from adjacent blocks so phrases cannot fuse across block boundaries. */
|
|
9
|
+
const BLOCK_SEPARATOR = ' ';
|
|
10
|
+
const asText = value => typeof value === 'string' ? value : '';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Extracts text from raw ADF JSON.
|
|
14
|
+
*
|
|
15
|
+
* Needed because some extensions stash a whole ADF subtree in `attrs.parameters.nestedContent`
|
|
16
|
+
* instead of in their node content — Confluence does this when it coerces nesting the schema
|
|
17
|
+
* cannot represent (an expand more than two collapsible layers deep, say). Such a node is a
|
|
18
|
+
* ProseMirror leaf, so the model walk cannot see the subtree even though it renders on the page
|
|
19
|
+
* via a nested renderer. Recurses, because nestedContent routinely holds further nested content.
|
|
20
|
+
*/
|
|
21
|
+
const adfEntityText = entity => {
|
|
22
|
+
var _entity$attrs, _entity$attrs$paramet, _entity$content;
|
|
23
|
+
if (!entity) {
|
|
24
|
+
return '';
|
|
25
|
+
}
|
|
26
|
+
const parts = [];
|
|
27
|
+
if (entity.type === 'text') {
|
|
28
|
+
parts.push(asText(entity.text));
|
|
29
|
+
}
|
|
30
|
+
const nestedContent = (_entity$attrs = entity.attrs) === null || _entity$attrs === void 0 ? void 0 : (_entity$attrs$paramet = _entity$attrs.parameters) === null || _entity$attrs$paramet === void 0 ? void 0 : _entity$attrs$paramet.nestedContent;
|
|
31
|
+
if (nestedContent) {
|
|
32
|
+
// Prefer the real subtree over `attrs.text`, which is only a placeholder label for it.
|
|
33
|
+
parts.push(adfEntityText(nestedContent));
|
|
34
|
+
} else {
|
|
35
|
+
var _entity$attrs2;
|
|
36
|
+
parts.push(asText((_entity$attrs2 = entity.attrs) === null || _entity$attrs2 === void 0 ? void 0 : _entity$attrs2.text));
|
|
37
|
+
}
|
|
38
|
+
(_entity$content = entity.content) === null || _entity$content === void 0 ? void 0 : _entity$content.forEach(child => parts.push(adfEntityText(child)));
|
|
39
|
+
return parts.filter(Boolean).join(BLOCK_SEPARATOR);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* `textBetween` drops every non-text leaf unless the node spec declares `leafText`, and no ADF
|
|
44
|
+
* node does. Leaves carry their visible text in attrs, so recover it here.
|
|
45
|
+
*/
|
|
46
|
+
const leafText = leaf => {
|
|
47
|
+
var _leaf$attrs, _leaf$attrs$parameter, _leaf$attrs2;
|
|
48
|
+
const nestedContent = (_leaf$attrs = leaf.attrs) === null || _leaf$attrs === void 0 ? void 0 : (_leaf$attrs$parameter = _leaf$attrs.parameters) === null || _leaf$attrs$parameter === void 0 ? void 0 : _leaf$attrs$parameter.nestedContent;
|
|
49
|
+
if (nestedContent) {
|
|
50
|
+
return adfEntityText(nestedContent);
|
|
51
|
+
}
|
|
52
|
+
return asText((_leaf$attrs2 = leaf.attrs) === null || _leaf$attrs2 === void 0 ? void 0 : _leaf$attrs2.text);
|
|
53
|
+
};
|
|
54
|
+
const hasInlineComment = node => findChildrenByMark(node, node.type.schema.marks.annotation, true).some(annotation => annotation.node.marks.some(mark => mark.attrs.annotationType === 'inlineComment'));
|
|
55
|
+
|
|
56
|
+
/** `null` is a cached "no mirror for this node", as distinct from `undefined` for a cache miss. */
|
|
57
|
+
const searchTextCache = new WeakMap();
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Plain-text mirror of an expand's body, rendered in its place while collapsed so browser
|
|
61
|
+
* find-in-page can still reach the content.
|
|
62
|
+
*
|
|
63
|
+
* Cached on the node. ProseMirror nodes are immutable and `render-document` memoises
|
|
64
|
+
* `nodeFromJSON`, so the same node instance is reused across renders — including across the
|
|
65
|
+
* serializer rebuilds that invalidate the module-level `memoizeOne` caches.
|
|
66
|
+
*
|
|
67
|
+
* @returns the mirror text, or `undefined` if this expand must keep its body rendered.
|
|
68
|
+
*/
|
|
69
|
+
export const getExpandSearchText = node => {
|
|
70
|
+
var _cached;
|
|
71
|
+
let cached = searchTextCache.get(node);
|
|
72
|
+
if (cached === undefined) {
|
|
73
|
+
cached = hasInlineComment(node) ?
|
|
74
|
+
// Withhold the mirror, which makes Expand keep rendering `children`. Comment
|
|
75
|
+
// navigation walks the DOM to find the annotated node and scrolls it into view, so
|
|
76
|
+
// the annotation has to exist as a real element — a flat text mirror carries no
|
|
77
|
+
// annotation marks and cannot stand in for it. Without this, stepping through
|
|
78
|
+
// comments with the arrow keys silently fails to reach any comment inside a
|
|
79
|
+
// collapsed expand. Costs the lazy-load win for these expands, deliberately.
|
|
80
|
+
null : node.textBetween(0, node.content.size, BLOCK_SEPARATOR, leafText);
|
|
81
|
+
searchTextCache.set(node, cached);
|
|
82
|
+
}
|
|
83
|
+
return (_cached = cached) !== null && _cached !== void 0 ? _cached : undefined;
|
|
84
|
+
};
|
package/dist/esm/react/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import TextWrapperComponent from './nodes/text-wrapper';
|
|
|
16
16
|
import { isNestedHeaderLinksEnabled } from './utils/links';
|
|
17
17
|
import { getColumnWidths } from '@atlaskit/editor-common/utils';
|
|
18
18
|
import { getMarksByOrder, isSameMark } from '@atlaskit/editor-common/validator';
|
|
19
|
-
import {
|
|
19
|
+
import { findChildrenByType } from '@atlaskit/editor-prosemirror/utils';
|
|
20
20
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
21
21
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
22
22
|
import { getText } from '../utils';
|
|
@@ -729,25 +729,14 @@ var ReactSerializer = /*#__PURE__*/function () {
|
|
|
729
729
|
value: function getExpandProps(node) {
|
|
730
730
|
var _this7 = this;
|
|
731
731
|
var _path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
loadBodyContent = annotations.some(function (annotation) {
|
|
738
|
-
return annotation.node.marks.some(function (mark) {
|
|
739
|
-
return mark.attrs.annotationType === 'inlineComment';
|
|
740
|
-
});
|
|
741
|
-
});
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
// Only compute searchText when the browser find experiment is enabled,
|
|
745
|
-
// to avoid unnecessary node.textContent string allocations per expand node.
|
|
746
|
-
var searchText = expValEquals('platform_editor_close_expand_find', 'isEnabled', true) ? node.textContent : undefined;
|
|
732
|
+
// Expand receives the node rather than a precomputed string so it can derive the collapsed
|
|
733
|
+
// text mirror only when it actually renders one — a nested expand is not mounted until its
|
|
734
|
+
// ancestor opens — and so that derivation can reach content the model walk cannot, such as
|
|
735
|
+
// the ADF stashed in a coerced extension's `parameters.nestedContent`. Expand owns the
|
|
736
|
+
// feature gate check.
|
|
747
737
|
if (!isNestedHeaderLinksEnabled(this.allowHeadingAnchorLinks)) {
|
|
748
738
|
return _objectSpread(_objectSpread({}, this.getProps(node)), {}, {
|
|
749
|
-
|
|
750
|
-
searchText: searchText
|
|
739
|
+
node: node
|
|
751
740
|
});
|
|
752
741
|
}
|
|
753
742
|
var nestedHeaderIds = findChildrenByType(node, node.type.schema.nodes.heading).map(function (_ref4) {
|
|
@@ -756,8 +745,7 @@ var ReactSerializer = /*#__PURE__*/function () {
|
|
|
756
745
|
});
|
|
757
746
|
return _objectSpread(_objectSpread({}, this.getProps(node)), {}, {
|
|
758
747
|
nestedHeaderIds: nestedHeaderIds,
|
|
759
|
-
|
|
760
|
-
searchText: searchText
|
|
748
|
+
node: node
|
|
761
749
|
});
|
|
762
750
|
}
|
|
763
751
|
|
|
@@ -7,7 +7,7 @@ import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
|
7
7
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
8
8
|
var getMediaClientConfigForRenderer = function getMediaClientConfigForRenderer(provider) {
|
|
9
9
|
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
10
|
-
return provider.viewAndUploadMediaClientConfig && fg('platform_media_video_captions')
|
|
10
|
+
return provider.viewAndUploadMediaClientConfig && fg('platform_media_video_captions') ? provider.viewAndUploadMediaClientConfig : provider.viewMediaClientConfig;
|
|
11
11
|
};
|
|
12
12
|
export var EditorMediaClientProvider = function EditorMediaClientProvider(_ref) {
|
|
13
13
|
var children = _ref.children,
|
package/dist/esm/ui/Expand.js
CHANGED
|
@@ -5,7 +5,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
5
5
|
*/
|
|
6
6
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
7
7
|
import { css, jsx } from '@emotion/react';
|
|
8
|
-
import React, { useCallback,
|
|
8
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
9
9
|
import { bind } from 'bind-event-listener';
|
|
10
10
|
import { getDocument } from '@atlaskit/browser-apis';
|
|
11
11
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
@@ -13,8 +13,9 @@ import { ExpandIconWrapper, ExpandLayoutWrapperWithRef, expandMessages, WidthPro
|
|
|
13
13
|
import { akEditorLineHeight, akEditorSwoopCubicBezier, akLayoutGutterOffset } from '@atlaskit/editor-shared-styles';
|
|
14
14
|
import ChevronRightIcon from '@atlaskit/icon/core/chevron-right';
|
|
15
15
|
import Tooltip from '@atlaskit/tooltip/Tooltip';
|
|
16
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
16
17
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
17
|
-
import {
|
|
18
|
+
import { getExpandSearchText } from './utils/expand-search-text';
|
|
18
19
|
import _uniqueId from 'lodash/uniqueId';
|
|
19
20
|
import { injectIntl } from 'react-intl';
|
|
20
21
|
import { MODE, PLATFORM } from '../analytics/events';
|
|
@@ -154,16 +155,6 @@ var clearNextSiblingMarginTopStyle = css({
|
|
|
154
155
|
marginTop: '0 !important'
|
|
155
156
|
}
|
|
156
157
|
});
|
|
157
|
-
|
|
158
|
-
// Lazy-loaded children component
|
|
159
|
-
var LazyChildren = /*#__PURE__*/lazy(function () {
|
|
160
|
-
return Promise.resolve({
|
|
161
|
-
default: function _default(_ref) {
|
|
162
|
-
var children = _ref.children;
|
|
163
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
158
|
var Container = function Container(props) {
|
|
168
159
|
return jsx("div", {
|
|
169
160
|
css: [containerStyles, props['data-node-type'] === 'expand' && containerStylesDataNodeTypeExpand, props.expanded && containerStylesExpanded, props.focused && containerStylesFocused],
|
|
@@ -212,29 +203,36 @@ function fireExpandToggleAnalytics(nodeType, expanded, fireAnalyticsEvent) {
|
|
|
212
203
|
eventType: EVENT_TYPE.TRACK
|
|
213
204
|
});
|
|
214
205
|
}
|
|
215
|
-
function Expand(
|
|
216
|
-
var title =
|
|
217
|
-
children =
|
|
218
|
-
nodeType =
|
|
219
|
-
intl =
|
|
220
|
-
fireAnalyticsEvent =
|
|
221
|
-
localId =
|
|
222
|
-
nestedHeaderIds =
|
|
223
|
-
rendererContentMode =
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
206
|
+
function Expand(_ref) {
|
|
207
|
+
var title = _ref.title,
|
|
208
|
+
children = _ref.children,
|
|
209
|
+
nodeType = _ref.nodeType,
|
|
210
|
+
intl = _ref.intl,
|
|
211
|
+
fireAnalyticsEvent = _ref.fireAnalyticsEvent,
|
|
212
|
+
localId = _ref.localId,
|
|
213
|
+
nestedHeaderIds = _ref.nestedHeaderIds,
|
|
214
|
+
rendererContentMode = _ref.rendererContentMode,
|
|
215
|
+
node = _ref.node;
|
|
216
|
+
var _useState = useState(false),
|
|
217
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
218
|
+
expanded = _useState2[0],
|
|
219
|
+
setExpanded = _useState2[1];
|
|
220
|
+
var _useState3 = useState(false),
|
|
221
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
222
|
+
focused = _useState4[0],
|
|
223
|
+
setFocused = _useState4[1];
|
|
224
|
+
/**
|
|
225
|
+
* PGXT-9021: latches on the first open so the body stays mounted once rendered, including after
|
|
226
|
+
* the expand is collapsed again. Remounting it would re-run every macro and Forge data fetch
|
|
227
|
+
* inside on each reopen, which is both slower and visibly reloads content the reader has already
|
|
228
|
+
* seen. The saving this gate exists for is at initial load, where the body has never been opened,
|
|
229
|
+
* so nothing is given up by keeping it after that. Never set on the server, so the server and the
|
|
230
|
+
* client's first render agree and hydration cannot desync.
|
|
231
|
+
*/
|
|
232
|
+
var _useState5 = useState(false),
|
|
233
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
234
|
+
hasBeenExpanded = _useState6[0],
|
|
235
|
+
setHasBeenExpanded = _useState6[1];
|
|
238
236
|
var isMobile = false;
|
|
239
237
|
var label = intl.formatMessage(expanded ? expandMessages.collapseNode : expandMessages.expandNode);
|
|
240
238
|
var _useRef = useRef(_uniqueId('expand-title-')),
|
|
@@ -247,16 +245,12 @@ function Expand(_ref2) {
|
|
|
247
245
|
var handleBlur = useCallback(function () {
|
|
248
246
|
return setFocused(false);
|
|
249
247
|
}, []);
|
|
250
|
-
|
|
251
|
-
|
|
248
|
+
// Both state updates happen in the same handler so they land in one render, rather than the
|
|
249
|
+
// latch reacting to `expanded` from an effect.
|
|
250
|
+
var openBody = useCallback(function () {
|
|
252
251
|
setExpanded(true);
|
|
252
|
+
setHasBeenExpanded(true);
|
|
253
253
|
}, []);
|
|
254
|
-
var shouldRenderLazyChildren = hasLoadedChildren || loadBodyContent;
|
|
255
|
-
// Only render the lightweight text placeholder when lazy load is ON and
|
|
256
|
-
// children haven't been loaded yet. When lazy load is OFF, children are
|
|
257
|
-
// always in the DOM — hidden="until-found" on the wrapper already makes
|
|
258
|
-
// them searchable by browser find, so no placeholder is needed.
|
|
259
|
-
var shouldRenderBrowserFindText = !shouldRenderLazyChildren && searchText && fg('hot-121622_lazy_load_expand_content') && expValEquals('platform_editor_close_expand_find', 'isEnabled', true);
|
|
260
254
|
|
|
261
255
|
// Feature-detect hidden="until-found" support via the beforematch event.
|
|
262
256
|
// Chrome 102+ and Firefox 130+ support it; Safari does not yet.
|
|
@@ -265,11 +259,11 @@ function Expand(_ref2) {
|
|
|
265
259
|
// Initialised as false and set in useEffect to avoid SSR/client hydration mismatch —
|
|
266
260
|
// useMemo would return true on the client's first render in supported browsers,
|
|
267
261
|
// differing from the server snapshot which always produces false.
|
|
268
|
-
var
|
|
269
|
-
|
|
270
|
-
supportsHiddenUntilFound =
|
|
271
|
-
setSupportsHiddenUntilFound =
|
|
272
|
-
|
|
262
|
+
var _useState7 = useState(false),
|
|
263
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
264
|
+
supportsHiddenUntilFound = _useState8[0],
|
|
265
|
+
setSupportsHiddenUntilFound = _useState8[1];
|
|
266
|
+
useEffect(function () {
|
|
273
267
|
var doc = getDocument();
|
|
274
268
|
setSupportsHiddenUntilFound(doc !== null && doc !== void 0 && doc.body ? 'onbeforematch' in doc.body : false);
|
|
275
269
|
}, []);
|
|
@@ -285,13 +279,13 @@ function Expand(_ref2) {
|
|
|
285
279
|
// In unsupported browsers (Safari), we skip this entirely and fall back to the normal
|
|
286
280
|
// CSS hiding (visibility:hidden + height:0), which doesn't support find-in-page but
|
|
287
281
|
// still works correctly for expand/collapse.
|
|
288
|
-
|
|
282
|
+
useEffect(function () {
|
|
289
283
|
var contentContainer = contentContainerRef.current;
|
|
290
284
|
var contentWrapper = contentWrapperRef.current;
|
|
291
285
|
if (!contentWrapper) {
|
|
292
286
|
return;
|
|
293
287
|
}
|
|
294
|
-
if (supportsHiddenUntilFound &&
|
|
288
|
+
if (supportsHiddenUntilFound && isExperimentEnabled('platform_editor_close_expand_find') && !expanded) {
|
|
295
289
|
contentWrapper.setAttribute('hidden', 'until-found');
|
|
296
290
|
// Override the CSS visibility:hidden from contentContainerStyles — hidden="until-found"
|
|
297
291
|
// now handles hiding via content-visibility:hidden, which allows browser find to index
|
|
@@ -305,31 +299,29 @@ function Expand(_ref2) {
|
|
|
305
299
|
contentWrapper.style.visibility = '';
|
|
306
300
|
}
|
|
307
301
|
}, [expanded, supportsHiddenUntilFound]);
|
|
308
|
-
|
|
309
|
-
if (!
|
|
302
|
+
useEffect(function () {
|
|
303
|
+
if (!isExperimentEnabled('platform_editor_close_expand_find') || expanded) {
|
|
310
304
|
return;
|
|
311
305
|
}
|
|
312
306
|
var contentWrapper = contentWrapperRef.current;
|
|
313
307
|
var unbindWrapperBeforeMatch = contentWrapper && supportsHiddenUntilFound ? bind(contentWrapper, {
|
|
314
308
|
type: 'beforematch',
|
|
315
|
-
listener:
|
|
309
|
+
listener: openBody
|
|
316
310
|
}) : undefined;
|
|
317
311
|
return function () {
|
|
318
312
|
unbindWrapperBeforeMatch === null || unbindWrapperBeforeMatch === void 0 || unbindWrapperBeforeMatch();
|
|
319
313
|
};
|
|
320
|
-
}, [
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
}, jsx(LazyChildren, null, children));
|
|
332
|
-
}
|
|
314
|
+
}, [expanded, openBody, supportsHiddenUntilFound]);
|
|
315
|
+
|
|
316
|
+
// Until the expand is first opened, stand in a plain-text mirror of the body so
|
|
317
|
+
// hidden="until-found" keeps the content findable by browser find without mounting the real
|
|
318
|
+
// subtree. The beforematch listener above expands before the browser scrolls to its match.
|
|
319
|
+
// Computed lazily: a nested expand is not mounted until its ancestor opens, so its mirror is
|
|
320
|
+
// never built on initial load.
|
|
321
|
+
var searchText = useMemo(function () {
|
|
322
|
+
return node && fg('hot-121622_lazy_load_expand_content') ? getExpandSearchText(node) : undefined;
|
|
323
|
+
}, [node]);
|
|
324
|
+
var expandContent = searchText && !expanded && !hasBeenExpanded ? jsx("span", null, searchText) : children;
|
|
333
325
|
return jsx(Container, {
|
|
334
326
|
"data-testid": "expand-container-".concat(nodeType, "-").concat(id),
|
|
335
327
|
"data-node-type": nodeType,
|
|
@@ -339,15 +331,8 @@ function Expand(_ref2) {
|
|
|
339
331
|
expanded: expanded,
|
|
340
332
|
focused: focused
|
|
341
333
|
}, nestedHeaderIds && nestedHeaderIds.length > 0 ? jsx(ActiveHeaderIdConsumer, {
|
|
342
|
-
nestedHeaderIds: nestedHeaderIds
|
|
343
|
-
|
|
344
|
-
,
|
|
345
|
-
onNestedHeaderIdMatch: function onNestedHeaderIdMatch() {
|
|
346
|
-
if (!hasLoadedChildren) {
|
|
347
|
-
setHasLoadedChildren(true);
|
|
348
|
-
}
|
|
349
|
-
setExpanded(true);
|
|
350
|
-
}
|
|
334
|
+
nestedHeaderIds: nestedHeaderIds,
|
|
335
|
+
onNestedHeaderIdMatch: openBody
|
|
351
336
|
}) : null, jsx(TitleContainer
|
|
352
337
|
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
353
338
|
, {
|
|
@@ -355,12 +340,11 @@ function Expand(_ref2) {
|
|
|
355
340
|
e.preventDefault();
|
|
356
341
|
e.stopPropagation();
|
|
357
342
|
fireExpandToggleAnalytics(nodeType, expanded, fireAnalyticsEvent);
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
343
|
+
if (expanded) {
|
|
344
|
+
setExpanded(false);
|
|
345
|
+
} else {
|
|
346
|
+
openBody();
|
|
362
347
|
}
|
|
363
|
-
setExpanded(!expanded);
|
|
364
348
|
e.persist();
|
|
365
349
|
// @ts-ignore detail doesn't exist on type
|
|
366
350
|
e.detail ? handleBlur() : handleFocus();
|
|
@@ -395,7 +379,7 @@ function Expand(_ref2) {
|
|
|
395
379
|
id: id
|
|
396
380
|
}, title || intl.formatMessage(expandMessages.expandDefaultTitle))), jsx(ContentContainer, {
|
|
397
381
|
expanded: expanded,
|
|
398
|
-
enableBrowserFind: supportsHiddenUntilFound &&
|
|
382
|
+
enableBrowserFind: supportsHiddenUntilFound && isExperimentEnabled('platform_editor_close_expand_find'),
|
|
399
383
|
contentRef: contentContainerRef
|
|
400
384
|
}, jsx("div", {
|
|
401
385
|
className: "".concat(nodeType, "-content-wrapper"),
|
|
@@ -65,7 +65,7 @@ export var DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
|
65
65
|
var TABLE_INFO_TIMEOUT = 10000;
|
|
66
66
|
var RENDER_EVENT_SAMPLE_RATE = 0.1;
|
|
67
67
|
var packageName = "@atlaskit/renderer";
|
|
68
|
-
var packageVersion = "137.1.
|
|
68
|
+
var packageVersion = "137.1.3";
|
|
69
69
|
var setAsQueryContainerStyles = css({
|
|
70
70
|
containerName: 'ak-renderer-wrapper',
|
|
71
71
|
containerType: 'inline-size'
|