@atlaskit/renderer 137.1.8 → 137.1.10
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 +28 -0
- package/dist/cjs/react/index.js +1 -1
- package/dist/cjs/react/nodes/table/colgroup.js +1 -2
- package/dist/cjs/react/nodes/table/sticky.js +2 -4
- package/dist/cjs/react/nodes/table/table.js +1 -12
- package/dist/cjs/react/nodes/table.js +471 -203
- package/dist/cjs/ui/Expand.js +33 -7
- package/dist/cjs/ui/Renderer/breakout-ssr.js +1 -2
- package/dist/cjs/ui/Renderer/index.js +3 -3
- package/dist/cjs/ui/utils/expand-body.js +218 -0
- package/dist/cjs/ui/utils/expand-search-text.js +39 -1
- package/dist/es2019/react/index.js +1 -1
- package/dist/es2019/react/nodes/table/colgroup.js +1 -2
- package/dist/es2019/react/nodes/table/sticky.js +2 -3
- package/dist/es2019/react/nodes/table/table.js +1 -12
- package/dist/es2019/react/nodes/table.js +457 -190
- package/dist/es2019/ui/Expand.js +33 -7
- package/dist/es2019/ui/Renderer/breakout-ssr.js +1 -2
- package/dist/es2019/ui/Renderer/index.js +3 -3
- package/dist/es2019/ui/utils/expand-body.js +198 -0
- package/dist/es2019/ui/utils/expand-search-text.js +38 -0
- package/dist/esm/react/index.js +1 -1
- package/dist/esm/react/nodes/table/colgroup.js +1 -2
- package/dist/esm/react/nodes/table/sticky.js +2 -4
- package/dist/esm/react/nodes/table/table.js +1 -12
- package/dist/esm/react/nodes/table.js +471 -202
- package/dist/esm/ui/Expand.js +33 -7
- package/dist/esm/ui/Renderer/breakout-ssr.js +1 -2
- package/dist/esm/ui/Renderer/index.js +3 -3
- package/dist/esm/ui/utils/expand-body.js +210 -0
- package/dist/esm/ui/utils/expand-search-text.js +38 -0
- package/dist/types/react/nodes/table/sticky.d.ts +1 -2
- package/dist/types/react/nodes/table.d.ts +78 -8
- package/dist/types/ui/{expand-body.d.ts → utils/expand-body.d.ts} +26 -5
- package/dist/types/ui/utils/expand-search-text.d.ts +14 -0
- package/package.json +6 -9
- package/dist/cjs/react/nodes/tableNew.js +0 -1050
- package/dist/cjs/ui/expand-body.js +0 -122
- package/dist/es2019/react/nodes/tableNew.js +0 -986
- package/dist/es2019/ui/expand-body.js +0 -107
- package/dist/esm/react/nodes/tableNew.js +0 -1044
- package/dist/esm/ui/expand-body.js +0 -114
- package/dist/types/react/nodes/tableNew.d.ts +0 -189
package/dist/esm/ui/Expand.js
CHANGED
|
@@ -14,7 +14,7 @@ import { akEditorLineHeight, akEditorSwoopCubicBezier, akLayoutGutterOffset } fr
|
|
|
14
14
|
import ChevronRightIcon from '@atlaskit/icon/core/chevron-right';
|
|
15
15
|
import Tooltip from '@atlaskit/tooltip/Tooltip';
|
|
16
16
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
17
|
-
import { ExpandBodyProvider, useExpandBody } from './expand-body';
|
|
17
|
+
import { ExpandBodyProvider, useExpandBody } from './utils/expand-body';
|
|
18
18
|
import _uniqueId from 'lodash/uniqueId';
|
|
19
19
|
import { injectIntl } from 'react-intl';
|
|
20
20
|
import { MODE, PLATFORM } from '../analytics/events';
|
|
@@ -209,6 +209,7 @@ function fireExpandToggleAnalytics(nodeType, expanded, fireAnalyticsEvent) {
|
|
|
209
209
|
});
|
|
210
210
|
}
|
|
211
211
|
function Expand(_ref) {
|
|
212
|
+
var _ancestorBody$reveale;
|
|
212
213
|
var title = _ref.title,
|
|
213
214
|
children = _ref.children,
|
|
214
215
|
nodeType = _ref.nodeType,
|
|
@@ -219,7 +220,25 @@ function Expand(_ref) {
|
|
|
219
220
|
rendererContentMode = _ref.rendererContentMode,
|
|
220
221
|
node = _ref.node;
|
|
221
222
|
var ancestorBody = useExpandBody();
|
|
222
|
-
|
|
223
|
+
|
|
224
|
+
// Shared with every expand in the chain: the element that stood in for this expand and caught the
|
|
225
|
+
// find sits under an expand further out, and by the time this one mounts that element is gone.
|
|
226
|
+
//
|
|
227
|
+
// Built on first render rather than passed to `useRef`, which would evaluate and discard a new set
|
|
228
|
+
// on every render for the life of the expand.
|
|
229
|
+
var ownRevealedByFind = useRef(null);
|
|
230
|
+
if (!ownRevealedByFind.current) {
|
|
231
|
+
ownRevealedByFind.current = new WeakSet();
|
|
232
|
+
}
|
|
233
|
+
var revealedByFind = (_ancestorBody$reveale = ancestorBody === null || ancestorBody === void 0 ? void 0 : ancestorBody.revealedByFind) !== null && _ancestorBody$reveale !== void 0 ? _ancestorBody$reveale : ownRevealedByFind.current;
|
|
234
|
+
/**
|
|
235
|
+
* Browser find matched inside this expand while the expand above it was still collapsed, so it
|
|
236
|
+
* opens as soon as it mounts — otherwise the reader would watch the outer expand open onto a
|
|
237
|
+
* closed one, with the match nowhere to be seen. Empty on the server and on the first client
|
|
238
|
+
* render, so hydration cannot disagree; only a find on the client ever puts anything in it.
|
|
239
|
+
*/
|
|
240
|
+
var revealedByFindOnMount = node !== undefined && revealedByFind.has(node);
|
|
241
|
+
var _useState = useState(revealedByFindOnMount),
|
|
223
242
|
_useState2 = _slicedToArray(_useState, 2),
|
|
224
243
|
expanded = _useState2[0],
|
|
225
244
|
setExpanded = _useState2[1];
|
|
@@ -232,9 +251,9 @@ function Expand(_ref) {
|
|
|
232
251
|
* Throwing it away would re-run every macro and Forge fetch inside it on the next open, which is
|
|
233
252
|
* slower and visibly reloads content the reader has already seen. We only wanted to save work on
|
|
234
253
|
* the first page load, and by now that has happened. Starts false on both the server and the
|
|
235
|
-
* client, so hydration cannot disagree.
|
|
254
|
+
* first client render, so hydration cannot disagree.
|
|
236
255
|
*/
|
|
237
|
-
var _useState5 = useState(
|
|
256
|
+
var _useState5 = useState(revealedByFindOnMount),
|
|
238
257
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
239
258
|
hasBeenExpanded = _useState6[0],
|
|
240
259
|
setHasBeenExpanded = _useState6[1];
|
|
@@ -260,9 +279,15 @@ function Expand(_ref) {
|
|
|
260
279
|
// inside other expands, those have to open too or the reader still cannot see it. Each expand
|
|
261
280
|
// asks the one above it, so a single match opens the whole chain and nothing else.
|
|
262
281
|
var openWithAncestors = useCallback(function () {
|
|
282
|
+
// Remembered before anything opens: a block above this expand may have been standing in for
|
|
283
|
+
// itself, and rendering it rebuilds this expand. Without this it would come back closed over
|
|
284
|
+
// the match the reader was just taken to.
|
|
285
|
+
if (node) {
|
|
286
|
+
revealedByFind.add(node);
|
|
287
|
+
}
|
|
263
288
|
openBody();
|
|
264
289
|
ancestorBody === null || ancestorBody === void 0 || ancestorBody.openWithAncestors();
|
|
265
|
-
}, [ancestorBody, openBody]);
|
|
290
|
+
}, [ancestorBody, node, openBody, revealedByFind]);
|
|
266
291
|
|
|
267
292
|
// Feature-detect hidden="until-found" support via the beforematch event. Chrome 102+,
|
|
268
293
|
// Firefox 139+ and Safari 26.2+ all have it; in a browser without it, hidden="until-found" is
|
|
@@ -344,9 +369,10 @@ function Expand(_ref) {
|
|
|
344
369
|
var expandBody = useMemo(function () {
|
|
345
370
|
return {
|
|
346
371
|
revealed: revealed,
|
|
347
|
-
openWithAncestors: openWithAncestors
|
|
372
|
+
openWithAncestors: openWithAncestors,
|
|
373
|
+
revealedByFind: revealedByFind
|
|
348
374
|
};
|
|
349
|
-
}, [revealed, openWithAncestors]);
|
|
375
|
+
}, [revealed, openWithAncestors, revealedByFind]);
|
|
350
376
|
return jsx(Container, {
|
|
351
377
|
"data-testid": "expand-container-".concat(nodeType, "-").concat(id),
|
|
352
378
|
"data-node-type": nodeType,
|
|
@@ -27,7 +27,7 @@ export function BreakoutSSRInlineScript(_ref) {
|
|
|
27
27
|
}
|
|
28
28
|
var id = Math.floor(Math.random() * (9999999999 - 9999 + 1)) + 9999;
|
|
29
29
|
var shouldSkipScript = {
|
|
30
|
-
table:
|
|
30
|
+
table: true
|
|
31
31
|
};
|
|
32
32
|
return /*#__PURE__*/React.createElement("script", {
|
|
33
33
|
"data-breakout-script-id": id
|
|
@@ -86,7 +86,6 @@ function applyBreakoutAfterSSR(id, breakoutConsts, shouldSkipBreakoutScript, fla
|
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
// Remove with feature gate 'platform-ssr-table-resize'
|
|
90
89
|
// Ignored via go/ees005
|
|
91
90
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
92
91
|
if (item.target.classList.contains('ak-renderer-document')) {
|
|
@@ -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.9";
|
|
69
69
|
var setAsQueryContainerStyles = css({
|
|
70
70
|
containerName: 'ak-renderer-wrapper',
|
|
71
71
|
containerType: 'inline-size'
|
|
@@ -775,7 +775,7 @@ var RendererWrapper = /*#__PURE__*/React.memo(function (props) {
|
|
|
775
775
|
//
|
|
776
776
|
|
|
777
777
|
// allowRendererContainerStyles is not needed for comment container styling as container should always be set for comments
|
|
778
|
-
if (appearance === 'comment' && isTopLevelRenderer
|
|
778
|
+
if (appearance === 'comment' && isTopLevelRenderer) {
|
|
779
779
|
return jsx("div", {
|
|
780
780
|
css: setAsQueryContainerStyles
|
|
781
781
|
}, renderer);
|
|
@@ -788,7 +788,7 @@ var RendererWrapper = /*#__PURE__*/React.memo(function (props) {
|
|
|
788
788
|
return (appearance === 'full-page' || appearance === 'full-width' || (expValEqualsNoExposure('editor_tinymce_full_width_mode', 'isEnabled', true) || expValEquals('confluence_max_width_content_appearance', 'isEnabled', true)) && appearance === 'max') &&
|
|
789
789
|
// In case of having excerpt-include on page there are multiple renderers nested.
|
|
790
790
|
// Make sure only the root renderer is set to be query container.
|
|
791
|
-
isTopLevelRenderer && allowRendererContainerStyles
|
|
791
|
+
isTopLevelRenderer && allowRendererContainerStyles ? jsx("div", {
|
|
792
792
|
css: setAsQueryContainerStyles
|
|
793
793
|
}, renderer) : renderer;
|
|
794
794
|
});
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import React, { createContext, isValidElement, useContext } from 'react';
|
|
2
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
3
|
+
import { BLOCK_SEPARATOR, getBlockSearchText, getTableStandInParts, holdsRevealableContent, isExpandNode } from './expand-search-text';
|
|
4
|
+
var ExpandBodyContext = /*#__PURE__*/createContext(null);
|
|
5
|
+
export var ExpandBodyProvider = ExpandBodyContext.Provider;
|
|
6
|
+
export var useExpandBody = function useExpandBody() {
|
|
7
|
+
return useContext(ExpandBodyContext);
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* One or more neighbouring blocks of an expand's body. Shows their text until the expand is
|
|
11
|
+
* opened, then renders them. Falls back to rendering if there is no text, or if there is no
|
|
12
|
+
* expand above it.
|
|
13
|
+
*
|
|
14
|
+
* The text is rendered as-is, with no element around it. Nothing reads it but browser find,
|
|
15
|
+
* which only needs the characters to be in the DOM.
|
|
16
|
+
*/
|
|
17
|
+
export var ExpandBodyBlock = function ExpandBodyBlock(_ref) {
|
|
18
|
+
var children = _ref.children,
|
|
19
|
+
searchText = _ref.searchText;
|
|
20
|
+
var body = useExpandBody();
|
|
21
|
+
if (searchText === undefined || body === null || body.revealed) {
|
|
22
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
23
|
+
}
|
|
24
|
+
return searchText;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Called for every node the serializer renders. If the node is a block of an expand's body,
|
|
29
|
+
* wraps it so it can show its text instead of rendering while that expand is collapsed.
|
|
30
|
+
* Everything else is returned untouched.
|
|
31
|
+
*
|
|
32
|
+
* A block holding an expand of its own is returned untouched, because standing in for the whole
|
|
33
|
+
* block would take that expand with it, and the expand needs an element of its own: the element
|
|
34
|
+
* browser find reveals is the only way we learn the match was inside it rather than higher up. A
|
|
35
|
+
* table is handed to `ExpandBodyTable`, which stands in for its own rows and keeps only the rows
|
|
36
|
+
* that hold an expand. Everything else — a panel, a list, an extension with stashed ADF — renders
|
|
37
|
+
* in full, so the reader searches once instead of once per level.
|
|
38
|
+
*
|
|
39
|
+
* `ancestors` is the node's ancestor chain, nearest last.
|
|
40
|
+
*/
|
|
41
|
+
export var withExpandBodyBlock = function withExpandBodyBlock(node, ancestors, index, serialized) {
|
|
42
|
+
var parent = ancestors[ancestors.length - 1];
|
|
43
|
+
if (!parent || !isExpandNode(parent)) {
|
|
44
|
+
return serialized;
|
|
45
|
+
}
|
|
46
|
+
if (!isExperimentEnabled('platform_editor_defer_collapsed_expand_body')) {
|
|
47
|
+
return serialized;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// `serialized` is only null for a node the renderer has no component for, which a table is not.
|
|
51
|
+
// Such a table falls through to the paths below, which do not reach into it.
|
|
52
|
+
if (node.type.name === 'table' && serialized !== null) {
|
|
53
|
+
var parts = getTableStandInParts(node);
|
|
54
|
+
|
|
55
|
+
// With no row to keep, one string can stand in for the whole table — the table then renders
|
|
56
|
+
// nothing at all, and its text joins with the blocks either side of it.
|
|
57
|
+
return parts.every(function (part) {
|
|
58
|
+
return typeof part === 'string';
|
|
59
|
+
}) ? /*#__PURE__*/React.createElement(ExpandBodyBlock, {
|
|
60
|
+
key: "expand-body-block-".concat(index),
|
|
61
|
+
searchText: parts.join('')
|
|
62
|
+
}, serialized) : /*#__PURE__*/React.createElement(ExpandBodyTable, {
|
|
63
|
+
key: "expand-body-table-".concat(index),
|
|
64
|
+
node: node
|
|
65
|
+
}, serialized);
|
|
66
|
+
}
|
|
67
|
+
if (holdsRevealableContent(node)) {
|
|
68
|
+
return serialized;
|
|
69
|
+
}
|
|
70
|
+
var searchText = getBlockSearchText(node);
|
|
71
|
+
if (searchText === undefined) {
|
|
72
|
+
return serialized;
|
|
73
|
+
}
|
|
74
|
+
return /*#__PURE__*/React.createElement(ExpandBodyBlock, {
|
|
75
|
+
key: "expand-body-block-".concat(index),
|
|
76
|
+
searchText: searchText
|
|
77
|
+
}, serialized);
|
|
78
|
+
};
|
|
79
|
+
var isRow = function isRow(child) {
|
|
80
|
+
return /*#__PURE__*/isValidElement(child) && child.props.nodeType === 'tableRow';
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The rows inside the serialized table, wherever they sit.
|
|
85
|
+
*
|
|
86
|
+
* What the serializer hands over is not reliably the element whose children are the rows. Marks are
|
|
87
|
+
* folded around the node afterwards, and a product's own serializer may wrap the rows themselves —
|
|
88
|
+
* Confluence's progressive renderer wraps every row but the first. Assuming either a depth or a set
|
|
89
|
+
* of direct children means any wrapper added later silently costs the saving, so the rows are found
|
|
90
|
+
* instead by the `nodeType` the serializer puts on every node.
|
|
91
|
+
*
|
|
92
|
+
* Descent stops at each row: a nested table's rows sit inside a row of this one, and would
|
|
93
|
+
* otherwise be counted among them.
|
|
94
|
+
*
|
|
95
|
+
* The count is only a consistency check. `getTableStandInParts` indexes the rows by position, so a
|
|
96
|
+
* partial match cannot be lined up and the table has to render instead.
|
|
97
|
+
*/
|
|
98
|
+
var rowsOf = function rowsOf(serialized, rowCount) {
|
|
99
|
+
var rows = [];
|
|
100
|
+
var _collect = function collect(node) {
|
|
101
|
+
React.Children.toArray(node).forEach(function (child) {
|
|
102
|
+
if (! /*#__PURE__*/isValidElement(child)) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (isRow(child)) {
|
|
106
|
+
rows.push(child);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
_collect(child.props.children);
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
_collect(serialized);
|
|
113
|
+
return rows.length === rowCount ? rows : undefined;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* A table in the body of a collapsed expand. Shows the text of its rows until the expand is opened,
|
|
118
|
+
* keeping the rows that hold an expand of their own — those need an element for find to reveal.
|
|
119
|
+
*
|
|
120
|
+
* Standing in for the whole table, the way an ordinary block does, would take that expand with it.
|
|
121
|
+
*/
|
|
122
|
+
export var ExpandBodyTable = function ExpandBodyTable(_ref2) {
|
|
123
|
+
var children = _ref2.children,
|
|
124
|
+
node = _ref2.node;
|
|
125
|
+
var body = useExpandBody();
|
|
126
|
+
if (body === null || body.revealed) {
|
|
127
|
+
return children;
|
|
128
|
+
}
|
|
129
|
+
var rows = rowsOf(children, node.childCount);
|
|
130
|
+
if (!rows) {
|
|
131
|
+
// Nothing is wrong: the table renders as it always did, only without the saving. Still worth
|
|
132
|
+
// saying, because a silent fallback looks exactly like the feature being switched off.
|
|
133
|
+
// Every environment but production says it: a wrapper added by a product is only ever seen
|
|
134
|
+
// once that product has deployed, which a `NODE_ENV` check never reaches.
|
|
135
|
+
if (process.env.CLOUD_ENV !== 'production') {
|
|
136
|
+
// eslint-disable-next-line no-console
|
|
137
|
+
console.info('@atlaskit/renderer: the rows of a table in a collapsed expand were not found, so the table renders in full rather than showing their text');
|
|
138
|
+
}
|
|
139
|
+
return children;
|
|
140
|
+
}
|
|
141
|
+
return getTableStandInParts(node).map(function (part) {
|
|
142
|
+
return typeof part === 'string' ? part :
|
|
143
|
+
/*#__PURE__*/
|
|
144
|
+
// A row cannot stand in the page on its own — `<tr>` is only valid inside a table — so it
|
|
145
|
+
// keeps the least table around it that makes the markup valid. None of this is laid out: the
|
|
146
|
+
// body is hidden until the reader or find opens the expand, and opening it renders the real
|
|
147
|
+
// table in place of all this.
|
|
148
|
+
React.createElement("table", {
|
|
149
|
+
key: "expand-body-row-".concat(part)
|
|
150
|
+
}, /*#__PURE__*/React.createElement("tbody", null, rows[part]));
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
/** Whatever the serializer produced for one child: an element, a string, an array of either. */
|
|
155
|
+
|
|
156
|
+
var searchTextOf = function searchTextOf(child) {
|
|
157
|
+
return /*#__PURE__*/isValidElement(child) && child.type === ExpandBodyBlock ? child.props.searchText : undefined;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Joins neighbouring blocks that are showing text into one, so a run of them is a single string in
|
|
162
|
+
* the DOM rather than one per block. A body of twenty paragraphs becomes one text node instead of
|
|
163
|
+
* twenty.
|
|
164
|
+
*
|
|
165
|
+
* A block that is being rendered — a nested expand, say — ends the run, because the text either
|
|
166
|
+
* side of it has to stay either side of it.
|
|
167
|
+
*/
|
|
168
|
+
export var mergeExpandBodyText = function mergeExpandBodyText(children) {
|
|
169
|
+
// Called for every fragment in the document, and only an expand's body has anything to merge, so
|
|
170
|
+
// leave the array alone unless two neighbours are actually showing text.
|
|
171
|
+
var hasRun = children.some(function (child, index) {
|
|
172
|
+
return index > 0 && searchTextOf(child) !== undefined && searchTextOf(children[index - 1]) !== undefined;
|
|
173
|
+
});
|
|
174
|
+
if (!hasRun) {
|
|
175
|
+
return children;
|
|
176
|
+
}
|
|
177
|
+
var merged = [];
|
|
178
|
+
var run = [];
|
|
179
|
+
var endRun = function endRun() {
|
|
180
|
+
if (run.length === 0) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (run.length === 1) {
|
|
184
|
+
merged.push(run[0]);
|
|
185
|
+
} else {
|
|
186
|
+
var _key;
|
|
187
|
+
var text = run.map(searchTextOf).filter(Boolean).join(BLOCK_SEPARATOR);
|
|
188
|
+
// The blocks themselves, not the wrappers around them: nesting the wrappers would show
|
|
189
|
+
// each block's text again inside the joined run.
|
|
190
|
+
var blocks = run.map(function (child) {
|
|
191
|
+
return child.props.children;
|
|
192
|
+
});
|
|
193
|
+
merged.push( /*#__PURE__*/React.createElement(ExpandBodyBlock, {
|
|
194
|
+
key: (_key = run[0].key) !== null && _key !== void 0 ? _key : undefined,
|
|
195
|
+
searchText: text
|
|
196
|
+
}, blocks));
|
|
197
|
+
}
|
|
198
|
+
run = [];
|
|
199
|
+
};
|
|
200
|
+
children.forEach(function (child) {
|
|
201
|
+
if (searchTextOf(child) === undefined) {
|
|
202
|
+
endRun();
|
|
203
|
+
merged.push(child);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
run.push(child);
|
|
207
|
+
});
|
|
208
|
+
endRun();
|
|
209
|
+
return merged;
|
|
210
|
+
};
|
|
@@ -130,4 +130,42 @@ export var getBlockSearchText = function getBlockSearchText(node) {
|
|
|
130
130
|
searchTextCache.set(node, cached);
|
|
131
131
|
}
|
|
132
132
|
return cached !== null && cached !== void 0 ? cached : undefined;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* One piece of what a collapsed table shows: either the text of the rows being stood in for, or the
|
|
137
|
+
* index of a row that has to keep rendering.
|
|
138
|
+
*/
|
|
139
|
+
|
|
140
|
+
var tableStandInCache = new WeakMap();
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* What a table inside a collapsed expand shows in place of rendering, in table order so that find
|
|
144
|
+
* walks it the way the reader reads it.
|
|
145
|
+
*
|
|
146
|
+
* A row keeps rendering when it holds an expand of its own, which needs a real element for browser
|
|
147
|
+
* find to reveal, or when its text carries an inline comment. Its text is left out of the runs
|
|
148
|
+
* either side of it, since the row itself puts that text in the DOM.
|
|
149
|
+
*/
|
|
150
|
+
export var getTableStandInParts = function getTableStandInParts(table) {
|
|
151
|
+
var cached = tableStandInCache.get(table);
|
|
152
|
+
if (cached !== undefined) {
|
|
153
|
+
return cached;
|
|
154
|
+
}
|
|
155
|
+
var parts = [];
|
|
156
|
+
table.forEach(function (row, _offset, index) {
|
|
157
|
+
var text = holdsRevealableContent(row) ? undefined : getBlockSearchText(row);
|
|
158
|
+
if (text === undefined) {
|
|
159
|
+
parts.push(index);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
var last = parts[parts.length - 1];
|
|
163
|
+
if (typeof last === 'string') {
|
|
164
|
+
parts[parts.length - 1] = "".concat(last).concat(BLOCK_SEPARATOR).concat(text);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
parts.push(text);
|
|
168
|
+
});
|
|
169
|
+
tableStandInCache.set(table, parts);
|
|
170
|
+
return parts;
|
|
133
171
|
};
|
|
@@ -15,7 +15,6 @@ type StickyTableProps = {
|
|
|
15
15
|
allowTableResizing?: boolean;
|
|
16
16
|
children: React.ReactNode[];
|
|
17
17
|
columnWidths?: number[];
|
|
18
|
-
fixTableSSRResizing?: boolean;
|
|
19
18
|
innerRef: React.RefObject<HTMLDivElement>;
|
|
20
19
|
isNumberColumnEnabled: boolean;
|
|
21
20
|
layout: TableLayout;
|
|
@@ -29,7 +28,7 @@ type StickyTableProps = {
|
|
|
29
28
|
top?: number;
|
|
30
29
|
wrapperWidth: number;
|
|
31
30
|
} & OverflowShadowProps;
|
|
32
|
-
export declare const StickyTable: ({ top, left, mode, shadowClassNames, innerRef, wrapperWidth, tableWidth, isNumberColumnEnabled, layout, children, columnWidths, renderWidth, rowHeight, tableNode, rendererAppearance, allowTableResizing,
|
|
31
|
+
export declare const StickyTable: ({ top, left, mode, shadowClassNames, innerRef, wrapperWidth, tableWidth, isNumberColumnEnabled, layout, children, columnWidths, renderWidth, rowHeight, tableNode, rendererAppearance, allowTableResizing, allowFixedColumnWidthOption, }: StickyTableProps) => jsx.JSX.Element;
|
|
33
32
|
/**
|
|
34
33
|
*
|
|
35
34
|
*/
|
|
@@ -26,7 +26,6 @@ export type TableProps = SharedTableProps & {
|
|
|
26
26
|
allowTableAlignment?: boolean;
|
|
27
27
|
allowTableResizing?: boolean;
|
|
28
28
|
children: React.ReactElement<any> | Array<React.ReactElement<any>>;
|
|
29
|
-
disableTableOverflowShadow?: boolean;
|
|
30
29
|
isPresentational?: boolean;
|
|
31
30
|
rendererAppearance?: RendererAppearance;
|
|
32
31
|
stickyHeaders?: StickyHeaderConfig;
|
|
@@ -42,8 +41,17 @@ export interface TableState {
|
|
|
42
41
|
headerRowHeight: number;
|
|
43
42
|
stickyMode: StickyMode;
|
|
44
43
|
wrapperWidth: number;
|
|
45
|
-
}
|
|
46
|
-
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Reads `nestedRendererType` from RendererContext and renders the fake left/right
|
|
47
|
+
* borders only when the current renderer is the nested renderer for a reference
|
|
48
|
+
* synced block.
|
|
49
|
+
*/
|
|
50
|
+
export declare const RefSyncBlockFakeBorders: ({ isNumberColumnEnabled, }: {
|
|
51
|
+
isNumberColumnEnabled: boolean;
|
|
52
|
+
}) => React.JSX.Element | null;
|
|
53
|
+
/**
|
|
54
|
+
* TableContainer renders tables using only CSS-based rules
|
|
47
55
|
*/
|
|
48
56
|
export declare class TableContainer extends React.Component<TableProps & OverflowShadowProps & WithSmartCardStorageProps, TableState> {
|
|
49
57
|
state: TableState;
|
|
@@ -55,14 +63,74 @@ export declare class TableContainer extends React.Component<TableProps & Overflo
|
|
|
55
63
|
stickyScrollbar?: TableStickyScrollbar;
|
|
56
64
|
nextFrame: number | undefined;
|
|
57
65
|
overflowParent: OverflowParent | null;
|
|
66
|
+
private containerRef;
|
|
67
|
+
private _isInsideNestedRenderer;
|
|
68
|
+
private _isInsideTableCell;
|
|
69
|
+
private lastComputedStyle;
|
|
58
70
|
private resizeObserver;
|
|
59
71
|
private applyResizerChange;
|
|
60
72
|
/**
|
|
73
|
+
* Checks if this table is inside a nested renderer (e.g. Include Page macro)
|
|
74
|
+
* by looking for multiple .ak-renderer-document ancestors in the DOM.
|
|
75
|
+
* The result is cached since a table's position in the DOM tree is stable after mount.
|
|
76
|
+
*/
|
|
77
|
+
private isInsideNestedRenderer;
|
|
78
|
+
/**
|
|
79
|
+
* Checks if this table is inside a table cell in the DOM. The result is cached
|
|
80
|
+
* since a table's position in the DOM tree is stable after mount.
|
|
81
|
+
*/
|
|
82
|
+
private isInsideTableCell;
|
|
83
|
+
private isInsideTableContext;
|
|
84
|
+
/**
|
|
85
|
+
* For tables inside nested renderers (e.g. Include Page macro), the parent
|
|
86
|
+
* renderer's CSS override forces width:100%!important and left:0!important
|
|
87
|
+
* which overrides the inline styles set by this component. Using
|
|
88
|
+
* style.setProperty with 'important' priority on inline styles beats
|
|
89
|
+
* stylesheet !important rules per the CSS cascade.
|
|
90
|
+
*
|
|
91
|
+
* Tables that are nested inside another table need to remain constrained by
|
|
92
|
+
* their table-cell context. Do not promote their width to inline !important,
|
|
93
|
+
* otherwise nested tables rendered through macros such as Excerpt Include can
|
|
94
|
+
* overflow and overlap adjacent cells.
|
|
95
|
+
*
|
|
96
|
+
* Top-level tables in nested renderers still preserve their saved width, but
|
|
97
|
+
* are capped to their containing block so wide tables do not escape constrained
|
|
98
|
+
* macro bodies such as Excerpt Include panels.
|
|
99
|
+
*
|
|
100
|
+
* Uses lastComputedStyle (populated during render) rather than reading from
|
|
101
|
+
* element.style, because React may remove properties from the DOM when their
|
|
102
|
+
* values transition to undefined between renders.
|
|
103
|
+
*
|
|
104
|
+
* `platform_nested_table_style_override_2` fixes a follow-up regression where a
|
|
105
|
+
* NON-resized table inside an Excerpt macro (not Excerpt Include) on a
|
|
106
|
+
* wide/full-width page shrinks to only show its first columns in the renderer.
|
|
107
|
+
* Inside a nested renderer (a macro body) a non-resized table's computed width
|
|
108
|
+
* is a default layout cap (760px/1800px, or a `cqw` length for full-page
|
|
109
|
+
* appearances) taken from the outer renderer's width context. That value does
|
|
110
|
+
* not match the macro's own box, so promoting it to inline `!important` makes
|
|
111
|
+
* the table collapse. Such tables have no author-chosen size to preserve, so
|
|
112
|
+
* under this gate we re-assert the parent stylesheet's intent (fill the box:
|
|
113
|
+
* `width: 100%; left: 0`) with inline `!important`.
|
|
114
|
+
*
|
|
115
|
+
* Explicitly resized tables (`tableNode.attrs.width` set) are excluded and keep
|
|
116
|
+
* the original PGXT-10226 behavior: their author-chosen width/left is promoted
|
|
117
|
+
* verbatim so the Include Page macro does not stretch or indent them. The
|
|
118
|
+
* table-cell short-circuit (PGXT-10294) above also still applies.
|
|
119
|
+
*/
|
|
120
|
+
private applyNestedRendererTableFix;
|
|
121
|
+
/**
|
|
122
|
+
* Callback ref that captures the container DOM element and also forwards
|
|
123
|
+
* to the handleRef prop from the overflow shadow HOC.
|
|
124
|
+
*/
|
|
125
|
+
private setContainerRef;
|
|
126
|
+
/**
|
|
127
|
+
* Starts observing table dimensions and wires sticky header/scrollbar behavior after mount.
|
|
61
128
|
*
|
|
62
129
|
* @example
|
|
63
130
|
*/
|
|
64
131
|
componentDidMount(): void;
|
|
65
132
|
/**
|
|
133
|
+
* Updates sticky header wiring and scroll synchronization after prop or state changes.
|
|
66
134
|
*
|
|
67
135
|
* @param prevProps
|
|
68
136
|
* @param prevState
|
|
@@ -75,18 +143,19 @@ export declare class TableContainer extends React.Component<TableProps & Overflo
|
|
|
75
143
|
onScroll: () => void;
|
|
76
144
|
onWrapperScrolled: () => void;
|
|
77
145
|
/**
|
|
78
|
-
*
|
|
146
|
+
* Calculates the top offset used when the sticky header is pinned to the table bottom.
|
|
79
147
|
*/
|
|
80
148
|
get pinTop(): number | undefined;
|
|
81
149
|
/**
|
|
82
|
-
*
|
|
150
|
+
* Determines whether sticky header positioning should include the default scroll root offset.
|
|
83
151
|
*/
|
|
84
152
|
get shouldAddOverflowParentOffsetTop_DO_NOT_USE(): boolean | null | undefined;
|
|
85
153
|
/**
|
|
86
|
-
*
|
|
154
|
+
* Resolves the top position for the sticky header based on the current sticky mode.
|
|
87
155
|
*/
|
|
88
156
|
get stickyTop(): number | undefined;
|
|
89
157
|
/**
|
|
158
|
+
* Renders the table container, sticky header, table content, sticky scrollbar, and synced block borders.
|
|
90
159
|
*
|
|
91
160
|
* @example
|
|
92
161
|
*/
|
|
@@ -97,13 +166,14 @@ type TableProcessorState = {
|
|
|
97
166
|
tableOrderStatus?: TableOrderStatus;
|
|
98
167
|
};
|
|
99
168
|
/**
|
|
100
|
-
*
|
|
169
|
+
* Processes table children before passing them to the styled table container.
|
|
101
170
|
*/
|
|
102
|
-
export declare class
|
|
171
|
+
export declare class TableProcessorWithContainerStyles extends React.Component<TableProps & OverflowShadowProps & WithSmartCardStorageProps, TableProcessorState> {
|
|
103
172
|
state: {
|
|
104
173
|
tableOrderStatus: undefined;
|
|
105
174
|
};
|
|
106
175
|
/**
|
|
176
|
+
* Renders processed table children inside the table container.
|
|
107
177
|
*
|
|
108
178
|
* @example
|
|
109
179
|
*/
|
|
@@ -19,6 +19,14 @@ type ExpandBody = {
|
|
|
19
19
|
* expand find had just opened, and any nested renderer that had already loaded.
|
|
20
20
|
*/
|
|
21
21
|
revealed: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* The expands browser find has opened. One set is shared by a whole chain of expands.
|
|
24
|
+
*
|
|
25
|
+
* A table standing in for itself does swap out what it renders, and a nested expand in one of its
|
|
26
|
+
* rows is rebuilt when it does. This is how that expand knows to come back open rather than
|
|
27
|
+
* closed over the match the reader was just taken to.
|
|
28
|
+
*/
|
|
29
|
+
revealedByFind: WeakSet<PMNode>;
|
|
22
30
|
};
|
|
23
31
|
export declare const ExpandBodyProvider: Provider<ExpandBody | null>;
|
|
24
32
|
export declare const useExpandBody: () => ExpandBody | null;
|
|
@@ -41,15 +49,28 @@ export declare const ExpandBodyBlock: ({ children, searchText }: ExpandBodyBlock
|
|
|
41
49
|
* wraps it so it can show its text instead of rendering while that expand is collapsed.
|
|
42
50
|
* Everything else is returned untouched.
|
|
43
51
|
*
|
|
44
|
-
* A block holding an expand of its own is
|
|
45
|
-
* expand
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
52
|
+
* A block holding an expand of its own is returned untouched, because standing in for the whole
|
|
53
|
+
* block would take that expand with it, and the expand needs an element of its own: the element
|
|
54
|
+
* browser find reveals is the only way we learn the match was inside it rather than higher up. A
|
|
55
|
+
* table is handed to `ExpandBodyTable`, which stands in for its own rows and keeps only the rows
|
|
56
|
+
* that hold an expand. Everything else — a panel, a list, an extension with stashed ADF — renders
|
|
57
|
+
* in full, so the reader searches once instead of once per level.
|
|
49
58
|
*
|
|
50
59
|
* `ancestors` is the node's ancestor chain, nearest last.
|
|
51
60
|
*/
|
|
52
61
|
export declare const withExpandBodyBlock: (node: PMNode, ancestors: readonly PMNode[], index: number, serialized: JSX.Element | null) => JSX.Element | null;
|
|
62
|
+
type ExpandBodyTableProps = {
|
|
63
|
+
/** The serialized table, as `serializeFragmentChild` returned it. */
|
|
64
|
+
children: JSX.Element;
|
|
65
|
+
node: PMNode;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* A table in the body of a collapsed expand. Shows the text of its rows until the expand is opened,
|
|
69
|
+
* keeping the rows that hold an expand of their own — those need an element for find to reveal.
|
|
70
|
+
*
|
|
71
|
+
* Standing in for the whole table, the way an ordinary block does, would take that expand with it.
|
|
72
|
+
*/
|
|
73
|
+
export declare const ExpandBodyTable: ({ children, node }: ExpandBodyTableProps) => ReactNode;
|
|
53
74
|
/** Whatever the serializer produced for one child: an element, a string, an array of either. */
|
|
54
75
|
type SerializedChild = ReactNode;
|
|
55
76
|
/**
|
|
@@ -21,3 +21,17 @@ export declare const holdsRevealableContent: (node: PMNode) => boolean;
|
|
|
21
21
|
* @returns the text, or `undefined` if this block has to be rendered instead.
|
|
22
22
|
*/
|
|
23
23
|
export declare const getBlockSearchText: (node: PMNode) => string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* One piece of what a collapsed table shows: either the text of the rows being stood in for, or the
|
|
26
|
+
* index of a row that has to keep rendering.
|
|
27
|
+
*/
|
|
28
|
+
export type TableStandInPart = string | number;
|
|
29
|
+
/**
|
|
30
|
+
* What a table inside a collapsed expand shows in place of rendering, in table order so that find
|
|
31
|
+
* walks it the way the reader reads it.
|
|
32
|
+
*
|
|
33
|
+
* A row keeps rendering when it holds an expand of its own, which needs a real element for browser
|
|
34
|
+
* find to reveal, or when its text carries an inline comment. Its text is left out of the runs
|
|
35
|
+
* either side of it, since the row itself puts that text in the DOM.
|
|
36
|
+
*/
|
|
37
|
+
export declare const getTableStandInParts: (table: PMNode) => TableStandInPart[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/renderer",
|
|
3
|
-
"version": "137.1.
|
|
3
|
+
"version": "137.1.10",
|
|
4
4
|
"description": "Renderer component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@atlaskit/adf-schema": "^57.2.0",
|
|
34
34
|
"@atlaskit/adf-utils": "^20.7.0",
|
|
35
35
|
"@atlaskit/afm-i18n-platform-editor-renderer": "2.200.0",
|
|
36
|
-
"@atlaskit/analytics-listeners": "^11.
|
|
36
|
+
"@atlaskit/analytics-listeners": "^11.2.0",
|
|
37
37
|
"@atlaskit/analytics-namespaced-context": "^8.1.0",
|
|
38
38
|
"@atlaskit/analytics-next": "^12.4.0",
|
|
39
39
|
"@atlaskit/browser-apis": "^1.2.0",
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
"@atlaskit/status": "^5.8.0",
|
|
71
71
|
"@atlaskit/task-decision": "^21.8.0",
|
|
72
72
|
"@atlaskit/theme": "^28.1.0",
|
|
73
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
74
|
-
"@atlaskit/tokens": "^16.
|
|
73
|
+
"@atlaskit/tmp-editor-statsig": "^167.0.0",
|
|
74
|
+
"@atlaskit/tokens": "^16.9.0",
|
|
75
75
|
"@atlaskit/tooltip": "^24.2.0",
|
|
76
76
|
"@atlaskit/visually-hidden": "^4.3.0",
|
|
77
77
|
"@babel/runtime": "^7.0.0",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"uuid": "^3.1.0"
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
|
-
"@atlaskit/editor-common": "^120.
|
|
88
|
+
"@atlaskit/editor-common": "^120.7.0",
|
|
89
89
|
"@atlaskit/link-provider": "^5.4.0",
|
|
90
90
|
"@atlaskit/media-core": "^38.1.0",
|
|
91
91
|
"react": "^18.2.0",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"devDependencies": {
|
|
96
96
|
"@af/integration-testing": "workspace:^",
|
|
97
97
|
"@af/visual-regression": "workspace:^",
|
|
98
|
-
"@atlaskit/analytics-gas-types": "^6.
|
|
98
|
+
"@atlaskit/analytics-gas-types": "^6.1.0",
|
|
99
99
|
"@atlaskit/checkbox": "^19.1.0",
|
|
100
100
|
"@atlaskit/editor-plugin-media": "^18.0.0",
|
|
101
101
|
"@atlaskit/editor-test-helpers": "workspace:^",
|
|
@@ -164,9 +164,6 @@
|
|
|
164
164
|
"cc_comments_log_draft_annotation_ancestor_nodes": {
|
|
165
165
|
"type": "boolean"
|
|
166
166
|
},
|
|
167
|
-
"platform-ssr-table-resize": {
|
|
168
|
-
"type": "boolean"
|
|
169
|
-
},
|
|
170
167
|
"platform_fix_nested_num_column_scaling": {
|
|
171
168
|
"type": "boolean"
|
|
172
169
|
},
|