@atlaskit/renderer 137.1.7 → 137.1.9
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/react/index.js +1 -1
- package/dist/cjs/react/nodes/tableNew.js +1 -31
- package/dist/cjs/ui/Expand.js +33 -7
- package/dist/cjs/ui/Renderer/index.js +1 -1
- 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/tableNew.js +1 -31
- package/dist/es2019/ui/Expand.js +33 -7
- package/dist/es2019/ui/Renderer/index.js +1 -1
- 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/tableNew.js +1 -31
- package/dist/esm/ui/Expand.js +33 -7
- package/dist/esm/ui/Renderer/index.js +1 -1
- package/dist/esm/ui/utils/expand-body.js +210 -0
- package/dist/esm/ui/utils/expand-search-text.js +38 -0
- 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 +10 -10
- package/dist/cjs/ui/expand-body.js +0 -122
- package/dist/es2019/ui/expand-body.js +0 -107
- package/dist/esm/ui/expand-body.js +0 -114
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @atlaskit/renderer
|
|
2
2
|
|
|
3
|
+
## 137.1.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`c967639892512`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c967639892512) -
|
|
8
|
+
Cleanup experiment `platform_editor_table_q4_patch_5` and permanently restrict sticky table
|
|
9
|
+
headers to the first header row.
|
|
10
|
+
- [`5b8bba86d7b3d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5b8bba86d7b3d) -
|
|
11
|
+
A table in the body of a collapsed expand no longer renders in full just because a nested expand
|
|
12
|
+
sits in one of its rows. It shows the text of its rows instead, keeping only the rows that hold a
|
|
13
|
+
nested expand — those still need an element of their own for browser find to reveal. Opening the
|
|
14
|
+
expand renders the table, and a nested expand that find had opened stays open through it.
|
|
15
|
+
|
|
16
|
+
Behind the `platform_editor_defer_collapsed_expand_body` experiment, which controls whether a
|
|
17
|
+
collapsed expand holds its body back at all. The find-in-page behaviour described here also needs
|
|
18
|
+
`platform_editor_close_expand_find`, which is what applies `hidden="until-found"` to the collapsed
|
|
19
|
+
body.
|
|
20
|
+
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
23
|
+
## 137.1.8
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies
|
|
28
|
+
|
|
3
29
|
## 137.1.7
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/dist/cjs/react/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
15
15
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
16
16
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
17
17
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
18
|
-
var _expandBody = require("../ui/expand-body");
|
|
18
|
+
var _expandBody = require("../ui/utils/expand-body");
|
|
19
19
|
var _nodes = require("./nodes");
|
|
20
20
|
var _textWrapper = _interopRequireDefault(require("./nodes/text-wrapper"));
|
|
21
21
|
var _links = require("./utils/links");
|
|
@@ -897,36 +897,6 @@ var addTableCellEdgePropsThroughWrappers = function addTableCellEdgePropsThrough
|
|
|
897
897
|
return rows;
|
|
898
898
|
}
|
|
899
899
|
};
|
|
900
|
-
var addTableCellEdgeProps = function addTableCellEdgeProps(rows, tableNode, isNumberColumnEnabled) {
|
|
901
|
-
try {
|
|
902
|
-
if (!tableNode) {
|
|
903
|
-
return rows;
|
|
904
|
-
}
|
|
905
|
-
var cellEdgePropsByCellOffset = getCellEdgePropsByCellOffset(tableNode, isNumberColumnEnabled);
|
|
906
|
-
var cellOffset = 0;
|
|
907
|
-
return _react.default.Children.map(rows, function (row, rowIndex) {
|
|
908
|
-
var rowNode = tableNode.child(rowIndex);
|
|
909
|
-
cellOffset += 1;
|
|
910
|
-
var cellIndex = 0;
|
|
911
|
-
var rowChildren = _react.default.Children.map(row.props.children, function (child) {
|
|
912
|
-
if (! /*#__PURE__*/_react.default.isValidElement(child)) {
|
|
913
|
-
return child;
|
|
914
|
-
}
|
|
915
|
-
var cellNode = rowNode.child(cellIndex);
|
|
916
|
-
var edgeProps = cellEdgePropsByCellOffset.get(cellOffset);
|
|
917
|
-
cellIndex += 1;
|
|
918
|
-
cellOffset += cellNode.nodeSize;
|
|
919
|
-
return edgeProps ? /*#__PURE__*/_react.default.cloneElement(child, edgeProps) : child;
|
|
920
|
-
});
|
|
921
|
-
cellOffset += 1;
|
|
922
|
-
return /*#__PURE__*/_react.default.cloneElement(row, undefined, rowChildren);
|
|
923
|
-
});
|
|
924
|
-
} catch (_unused2) {
|
|
925
|
-
// Renderer can receive malformed historical ADF. If the table shape cannot
|
|
926
|
-
// be described safely, keep rendering without rounded edge metadata.
|
|
927
|
-
return rows;
|
|
928
|
-
}
|
|
929
|
-
};
|
|
930
900
|
|
|
931
901
|
/**
|
|
932
902
|
* Processes table children before passing them to the styled table container.
|
|
@@ -1018,7 +988,7 @@ var TableProcessorWithContainerStyles = exports.TableProcessorWithContainerStyle
|
|
|
1018
988
|
return null;
|
|
1019
989
|
}
|
|
1020
990
|
var childrenArray = _react.default.Children.toArray(children);
|
|
1021
|
-
var childrenWithTableEdgeProps = (0, _expValEquals.expValEquals)('platform_editor_table_q4_loveability', 'isEnabled', true) ?
|
|
991
|
+
var childrenWithTableEdgeProps = (0, _expValEquals.expValEquals)('platform_editor_table_q4_loveability', 'isEnabled', true) ? addTableCellEdgePropsThroughWrappers(childrenArray, tableNode, isNumberColumnEnabled) : childrenArray;
|
|
1022
992
|
var orderedChildren = (0, _utils.compose)(this.addNumberColumnIndexes, this.addSortableColumn
|
|
1023
993
|
// @ts-expect-error TS2345: Argument of type '(ReactChild | ReactFragment | ReactPortal)[]' is not assignable to parameter of type 'ReactElement<any, string | JSXElementConstructor<any>>[]'
|
|
1024
994
|
)(childrenWithTableEdgeProps);
|
package/dist/cjs/ui/Expand.js
CHANGED
|
@@ -17,7 +17,7 @@ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
|
17
17
|
var _chevronRight = _interopRequireDefault(require("@atlaskit/icon/core/chevron-right"));
|
|
18
18
|
var _Tooltip = _interopRequireDefault(require("@atlaskit/tooltip/Tooltip"));
|
|
19
19
|
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
20
|
-
var _expandBody = require("./expand-body");
|
|
20
|
+
var _expandBody = require("./utils/expand-body");
|
|
21
21
|
var _uniqueId2 = _interopRequireDefault(require("lodash/uniqueId"));
|
|
22
22
|
var _reactIntl = require("react-intl");
|
|
23
23
|
var _events = require("../analytics/events");
|
|
@@ -219,6 +219,7 @@ function fireExpandToggleAnalytics(nodeType, expanded, fireAnalyticsEvent) {
|
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
221
|
function Expand(_ref) {
|
|
222
|
+
var _ancestorBody$reveale;
|
|
222
223
|
var title = _ref.title,
|
|
223
224
|
children = _ref.children,
|
|
224
225
|
nodeType = _ref.nodeType,
|
|
@@ -229,7 +230,25 @@ function Expand(_ref) {
|
|
|
229
230
|
rendererContentMode = _ref.rendererContentMode,
|
|
230
231
|
node = _ref.node;
|
|
231
232
|
var ancestorBody = (0, _expandBody.useExpandBody)();
|
|
232
|
-
|
|
233
|
+
|
|
234
|
+
// Shared with every expand in the chain: the element that stood in for this expand and caught the
|
|
235
|
+
// find sits under an expand further out, and by the time this one mounts that element is gone.
|
|
236
|
+
//
|
|
237
|
+
// Built on first render rather than passed to `useRef`, which would evaluate and discard a new set
|
|
238
|
+
// on every render for the life of the expand.
|
|
239
|
+
var ownRevealedByFind = (0, _react2.useRef)(null);
|
|
240
|
+
if (!ownRevealedByFind.current) {
|
|
241
|
+
ownRevealedByFind.current = new WeakSet();
|
|
242
|
+
}
|
|
243
|
+
var revealedByFind = (_ancestorBody$reveale = ancestorBody === null || ancestorBody === void 0 ? void 0 : ancestorBody.revealedByFind) !== null && _ancestorBody$reveale !== void 0 ? _ancestorBody$reveale : ownRevealedByFind.current;
|
|
244
|
+
/**
|
|
245
|
+
* Browser find matched inside this expand while the expand above it was still collapsed, so it
|
|
246
|
+
* opens as soon as it mounts — otherwise the reader would watch the outer expand open onto a
|
|
247
|
+
* closed one, with the match nowhere to be seen. Empty on the server and on the first client
|
|
248
|
+
* render, so hydration cannot disagree; only a find on the client ever puts anything in it.
|
|
249
|
+
*/
|
|
250
|
+
var revealedByFindOnMount = node !== undefined && revealedByFind.has(node);
|
|
251
|
+
var _useState = (0, _react2.useState)(revealedByFindOnMount),
|
|
233
252
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
234
253
|
expanded = _useState2[0],
|
|
235
254
|
setExpanded = _useState2[1];
|
|
@@ -242,9 +261,9 @@ function Expand(_ref) {
|
|
|
242
261
|
* Throwing it away would re-run every macro and Forge fetch inside it on the next open, which is
|
|
243
262
|
* slower and visibly reloads content the reader has already seen. We only wanted to save work on
|
|
244
263
|
* the first page load, and by now that has happened. Starts false on both the server and the
|
|
245
|
-
* client, so hydration cannot disagree.
|
|
264
|
+
* first client render, so hydration cannot disagree.
|
|
246
265
|
*/
|
|
247
|
-
var _useState5 = (0, _react2.useState)(
|
|
266
|
+
var _useState5 = (0, _react2.useState)(revealedByFindOnMount),
|
|
248
267
|
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
249
268
|
hasBeenExpanded = _useState6[0],
|
|
250
269
|
setHasBeenExpanded = _useState6[1];
|
|
@@ -270,9 +289,15 @@ function Expand(_ref) {
|
|
|
270
289
|
// inside other expands, those have to open too or the reader still cannot see it. Each expand
|
|
271
290
|
// asks the one above it, so a single match opens the whole chain and nothing else.
|
|
272
291
|
var openWithAncestors = (0, _react2.useCallback)(function () {
|
|
292
|
+
// Remembered before anything opens: a block above this expand may have been standing in for
|
|
293
|
+
// itself, and rendering it rebuilds this expand. Without this it would come back closed over
|
|
294
|
+
// the match the reader was just taken to.
|
|
295
|
+
if (node) {
|
|
296
|
+
revealedByFind.add(node);
|
|
297
|
+
}
|
|
273
298
|
openBody();
|
|
274
299
|
ancestorBody === null || ancestorBody === void 0 || ancestorBody.openWithAncestors();
|
|
275
|
-
}, [ancestorBody, openBody]);
|
|
300
|
+
}, [ancestorBody, node, openBody, revealedByFind]);
|
|
276
301
|
|
|
277
302
|
// Feature-detect hidden="until-found" support via the beforematch event. Chrome 102+,
|
|
278
303
|
// Firefox 139+ and Safari 26.2+ all have it; in a browser without it, hidden="until-found" is
|
|
@@ -354,9 +379,10 @@ function Expand(_ref) {
|
|
|
354
379
|
var expandBody = (0, _react2.useMemo)(function () {
|
|
355
380
|
return {
|
|
356
381
|
revealed: revealed,
|
|
357
|
-
openWithAncestors: openWithAncestors
|
|
382
|
+
openWithAncestors: openWithAncestors,
|
|
383
|
+
revealedByFind: revealedByFind
|
|
358
384
|
};
|
|
359
|
-
}, [revealed, openWithAncestors]);
|
|
385
|
+
}, [revealed, openWithAncestors, revealedByFind]);
|
|
360
386
|
return (0, _react.jsx)(Container, {
|
|
361
387
|
"data-testid": "expand-container-".concat(nodeType, "-").concat(id),
|
|
362
388
|
"data-node-type": nodeType,
|
|
@@ -74,7 +74,7 @@ var DEGRADED_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
|
74
74
|
var TABLE_INFO_TIMEOUT = 10000;
|
|
75
75
|
var RENDER_EVENT_SAMPLE_RATE = 0.1;
|
|
76
76
|
var packageName = "@atlaskit/renderer";
|
|
77
|
-
var packageVersion = "137.1.
|
|
77
|
+
var packageVersion = "137.1.8";
|
|
78
78
|
var setAsQueryContainerStyles = (0, _react2.css)({
|
|
79
79
|
containerName: 'ak-renderer-wrapper',
|
|
80
80
|
containerType: 'inline-size'
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.withExpandBodyBlock = exports.useExpandBody = exports.mergeExpandBodyText = exports.ExpandBodyTable = exports.ExpandBodyProvider = exports.ExpandBodyBlock = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
10
|
+
var _expandSearchText = require("./expand-search-text");
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
12
|
+
var ExpandBodyContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
13
|
+
var ExpandBodyProvider = exports.ExpandBodyProvider = ExpandBodyContext.Provider;
|
|
14
|
+
var useExpandBody = exports.useExpandBody = function useExpandBody() {
|
|
15
|
+
return (0, _react.useContext)(ExpandBodyContext);
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* One or more neighbouring blocks of an expand's body. Shows their text until the expand is
|
|
19
|
+
* opened, then renders them. Falls back to rendering if there is no text, or if there is no
|
|
20
|
+
* expand above it.
|
|
21
|
+
*
|
|
22
|
+
* The text is rendered as-is, with no element around it. Nothing reads it but browser find,
|
|
23
|
+
* which only needs the characters to be in the DOM.
|
|
24
|
+
*/
|
|
25
|
+
var ExpandBodyBlock = exports.ExpandBodyBlock = function ExpandBodyBlock(_ref) {
|
|
26
|
+
var children = _ref.children,
|
|
27
|
+
searchText = _ref.searchText;
|
|
28
|
+
var body = useExpandBody();
|
|
29
|
+
if (searchText === undefined || body === null || body.revealed) {
|
|
30
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
|
|
31
|
+
}
|
|
32
|
+
return searchText;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Called for every node the serializer renders. If the node is a block of an expand's body,
|
|
37
|
+
* wraps it so it can show its text instead of rendering while that expand is collapsed.
|
|
38
|
+
* Everything else is returned untouched.
|
|
39
|
+
*
|
|
40
|
+
* A block holding an expand of its own is returned untouched, because standing in for the whole
|
|
41
|
+
* block would take that expand with it, and the expand needs an element of its own: the element
|
|
42
|
+
* browser find reveals is the only way we learn the match was inside it rather than higher up. A
|
|
43
|
+
* table is handed to `ExpandBodyTable`, which stands in for its own rows and keeps only the rows
|
|
44
|
+
* that hold an expand. Everything else — a panel, a list, an extension with stashed ADF — renders
|
|
45
|
+
* in full, so the reader searches once instead of once per level.
|
|
46
|
+
*
|
|
47
|
+
* `ancestors` is the node's ancestor chain, nearest last.
|
|
48
|
+
*/
|
|
49
|
+
var withExpandBodyBlock = exports.withExpandBodyBlock = function withExpandBodyBlock(node, ancestors, index, serialized) {
|
|
50
|
+
var parent = ancestors[ancestors.length - 1];
|
|
51
|
+
if (!parent || !(0, _expandSearchText.isExpandNode)(parent)) {
|
|
52
|
+
return serialized;
|
|
53
|
+
}
|
|
54
|
+
if (!(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_defer_collapsed_expand_body')) {
|
|
55
|
+
return serialized;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// `serialized` is only null for a node the renderer has no component for, which a table is not.
|
|
59
|
+
// Such a table falls through to the paths below, which do not reach into it.
|
|
60
|
+
if (node.type.name === 'table' && serialized !== null) {
|
|
61
|
+
var parts = (0, _expandSearchText.getTableStandInParts)(node);
|
|
62
|
+
|
|
63
|
+
// With no row to keep, one string can stand in for the whole table — the table then renders
|
|
64
|
+
// nothing at all, and its text joins with the blocks either side of it.
|
|
65
|
+
return parts.every(function (part) {
|
|
66
|
+
return typeof part === 'string';
|
|
67
|
+
}) ? /*#__PURE__*/_react.default.createElement(ExpandBodyBlock, {
|
|
68
|
+
key: "expand-body-block-".concat(index),
|
|
69
|
+
searchText: parts.join('')
|
|
70
|
+
}, serialized) : /*#__PURE__*/_react.default.createElement(ExpandBodyTable, {
|
|
71
|
+
key: "expand-body-table-".concat(index),
|
|
72
|
+
node: node
|
|
73
|
+
}, serialized);
|
|
74
|
+
}
|
|
75
|
+
if ((0, _expandSearchText.holdsRevealableContent)(node)) {
|
|
76
|
+
return serialized;
|
|
77
|
+
}
|
|
78
|
+
var searchText = (0, _expandSearchText.getBlockSearchText)(node);
|
|
79
|
+
if (searchText === undefined) {
|
|
80
|
+
return serialized;
|
|
81
|
+
}
|
|
82
|
+
return /*#__PURE__*/_react.default.createElement(ExpandBodyBlock, {
|
|
83
|
+
key: "expand-body-block-".concat(index),
|
|
84
|
+
searchText: searchText
|
|
85
|
+
}, serialized);
|
|
86
|
+
};
|
|
87
|
+
var isRow = function isRow(child) {
|
|
88
|
+
return /*#__PURE__*/(0, _react.isValidElement)(child) && child.props.nodeType === 'tableRow';
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The rows inside the serialized table, wherever they sit.
|
|
93
|
+
*
|
|
94
|
+
* What the serializer hands over is not reliably the element whose children are the rows. Marks are
|
|
95
|
+
* folded around the node afterwards, and a product's own serializer may wrap the rows themselves —
|
|
96
|
+
* Confluence's progressive renderer wraps every row but the first. Assuming either a depth or a set
|
|
97
|
+
* of direct children means any wrapper added later silently costs the saving, so the rows are found
|
|
98
|
+
* instead by the `nodeType` the serializer puts on every node.
|
|
99
|
+
*
|
|
100
|
+
* Descent stops at each row: a nested table's rows sit inside a row of this one, and would
|
|
101
|
+
* otherwise be counted among them.
|
|
102
|
+
*
|
|
103
|
+
* The count is only a consistency check. `getTableStandInParts` indexes the rows by position, so a
|
|
104
|
+
* partial match cannot be lined up and the table has to render instead.
|
|
105
|
+
*/
|
|
106
|
+
var rowsOf = function rowsOf(serialized, rowCount) {
|
|
107
|
+
var rows = [];
|
|
108
|
+
var _collect = function collect(node) {
|
|
109
|
+
_react.default.Children.toArray(node).forEach(function (child) {
|
|
110
|
+
if (! /*#__PURE__*/(0, _react.isValidElement)(child)) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (isRow(child)) {
|
|
114
|
+
rows.push(child);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
_collect(child.props.children);
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
_collect(serialized);
|
|
121
|
+
return rows.length === rowCount ? rows : undefined;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* A table in the body of a collapsed expand. Shows the text of its rows until the expand is opened,
|
|
126
|
+
* keeping the rows that hold an expand of their own — those need an element for find to reveal.
|
|
127
|
+
*
|
|
128
|
+
* Standing in for the whole table, the way an ordinary block does, would take that expand with it.
|
|
129
|
+
*/
|
|
130
|
+
var ExpandBodyTable = exports.ExpandBodyTable = function ExpandBodyTable(_ref2) {
|
|
131
|
+
var children = _ref2.children,
|
|
132
|
+
node = _ref2.node;
|
|
133
|
+
var body = useExpandBody();
|
|
134
|
+
if (body === null || body.revealed) {
|
|
135
|
+
return children;
|
|
136
|
+
}
|
|
137
|
+
var rows = rowsOf(children, node.childCount);
|
|
138
|
+
if (!rows) {
|
|
139
|
+
// Nothing is wrong: the table renders as it always did, only without the saving. Still worth
|
|
140
|
+
// saying, because a silent fallback looks exactly like the feature being switched off.
|
|
141
|
+
// Every environment but production says it: a wrapper added by a product is only ever seen
|
|
142
|
+
// once that product has deployed, which a `NODE_ENV` check never reaches.
|
|
143
|
+
if (process.env.CLOUD_ENV !== 'production') {
|
|
144
|
+
// eslint-disable-next-line no-console
|
|
145
|
+
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');
|
|
146
|
+
}
|
|
147
|
+
return children;
|
|
148
|
+
}
|
|
149
|
+
return (0, _expandSearchText.getTableStandInParts)(node).map(function (part) {
|
|
150
|
+
return typeof part === 'string' ? part :
|
|
151
|
+
/*#__PURE__*/
|
|
152
|
+
// A row cannot stand in the page on its own — `<tr>` is only valid inside a table — so it
|
|
153
|
+
// keeps the least table around it that makes the markup valid. None of this is laid out: the
|
|
154
|
+
// body is hidden until the reader or find opens the expand, and opening it renders the real
|
|
155
|
+
// table in place of all this.
|
|
156
|
+
_react.default.createElement("table", {
|
|
157
|
+
key: "expand-body-row-".concat(part)
|
|
158
|
+
}, /*#__PURE__*/_react.default.createElement("tbody", null, rows[part]));
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
/** Whatever the serializer produced for one child: an element, a string, an array of either. */
|
|
163
|
+
|
|
164
|
+
var searchTextOf = function searchTextOf(child) {
|
|
165
|
+
return /*#__PURE__*/(0, _react.isValidElement)(child) && child.type === ExpandBodyBlock ? child.props.searchText : undefined;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Joins neighbouring blocks that are showing text into one, so a run of them is a single string in
|
|
170
|
+
* the DOM rather than one per block. A body of twenty paragraphs becomes one text node instead of
|
|
171
|
+
* twenty.
|
|
172
|
+
*
|
|
173
|
+
* A block that is being rendered — a nested expand, say — ends the run, because the text either
|
|
174
|
+
* side of it has to stay either side of it.
|
|
175
|
+
*/
|
|
176
|
+
var mergeExpandBodyText = exports.mergeExpandBodyText = function mergeExpandBodyText(children) {
|
|
177
|
+
// Called for every fragment in the document, and only an expand's body has anything to merge, so
|
|
178
|
+
// leave the array alone unless two neighbours are actually showing text.
|
|
179
|
+
var hasRun = children.some(function (child, index) {
|
|
180
|
+
return index > 0 && searchTextOf(child) !== undefined && searchTextOf(children[index - 1]) !== undefined;
|
|
181
|
+
});
|
|
182
|
+
if (!hasRun) {
|
|
183
|
+
return children;
|
|
184
|
+
}
|
|
185
|
+
var merged = [];
|
|
186
|
+
var run = [];
|
|
187
|
+
var endRun = function endRun() {
|
|
188
|
+
if (run.length === 0) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (run.length === 1) {
|
|
192
|
+
merged.push(run[0]);
|
|
193
|
+
} else {
|
|
194
|
+
var _key;
|
|
195
|
+
var text = run.map(searchTextOf).filter(Boolean).join(_expandSearchText.BLOCK_SEPARATOR);
|
|
196
|
+
// The blocks themselves, not the wrappers around them: nesting the wrappers would show
|
|
197
|
+
// each block's text again inside the joined run.
|
|
198
|
+
var blocks = run.map(function (child) {
|
|
199
|
+
return child.props.children;
|
|
200
|
+
});
|
|
201
|
+
merged.push( /*#__PURE__*/_react.default.createElement(ExpandBodyBlock, {
|
|
202
|
+
key: (_key = run[0].key) !== null && _key !== void 0 ? _key : undefined,
|
|
203
|
+
searchText: text
|
|
204
|
+
}, blocks));
|
|
205
|
+
}
|
|
206
|
+
run = [];
|
|
207
|
+
};
|
|
208
|
+
children.forEach(function (child) {
|
|
209
|
+
if (searchTextOf(child) === undefined) {
|
|
210
|
+
endRun();
|
|
211
|
+
merged.push(child);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
run.push(child);
|
|
215
|
+
});
|
|
216
|
+
endRun();
|
|
217
|
+
return merged;
|
|
218
|
+
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isExpandNode = exports.holdsRevealableContent = exports.getBlockSearchText = exports.BLOCK_SEPARATOR = void 0;
|
|
6
|
+
exports.isExpandNode = exports.holdsRevealableContent = exports.getTableStandInParts = exports.getBlockSearchText = exports.BLOCK_SEPARATOR = void 0;
|
|
7
7
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
8
8
|
/**
|
|
9
9
|
* Minimal structural view of an ADF entity. `parameters.nestedContent` holds raw ADF JSON rather
|
|
@@ -135,4 +135,42 @@ var getBlockSearchText = exports.getBlockSearchText = function getBlockSearchTex
|
|
|
135
135
|
searchTextCache.set(node, cached);
|
|
136
136
|
}
|
|
137
137
|
return cached !== null && cached !== void 0 ? cached : undefined;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* One piece of what a collapsed table shows: either the text of the rows being stood in for, or the
|
|
142
|
+
* index of a row that has to keep rendering.
|
|
143
|
+
*/
|
|
144
|
+
|
|
145
|
+
var tableStandInCache = new WeakMap();
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* What a table inside a collapsed expand shows in place of rendering, in table order so that find
|
|
149
|
+
* walks it the way the reader reads it.
|
|
150
|
+
*
|
|
151
|
+
* A row keeps rendering when it holds an expand of its own, which needs a real element for browser
|
|
152
|
+
* find to reveal, or when its text carries an inline comment. Its text is left out of the runs
|
|
153
|
+
* either side of it, since the row itself puts that text in the DOM.
|
|
154
|
+
*/
|
|
155
|
+
var getTableStandInParts = exports.getTableStandInParts = function getTableStandInParts(table) {
|
|
156
|
+
var cached = tableStandInCache.get(table);
|
|
157
|
+
if (cached !== undefined) {
|
|
158
|
+
return cached;
|
|
159
|
+
}
|
|
160
|
+
var parts = [];
|
|
161
|
+
table.forEach(function (row, _offset, index) {
|
|
162
|
+
var text = holdsRevealableContent(row) ? undefined : getBlockSearchText(row);
|
|
163
|
+
if (text === undefined) {
|
|
164
|
+
parts.push(index);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
var last = parts[parts.length - 1];
|
|
168
|
+
if (typeof last === 'string') {
|
|
169
|
+
parts[parts.length - 1] = "".concat(last).concat(BLOCK_SEPARATOR).concat(text);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
parts.push(text);
|
|
173
|
+
});
|
|
174
|
+
tableStandInCache.set(table, parts);
|
|
175
|
+
return parts;
|
|
138
176
|
};
|
|
@@ -4,7 +4,7 @@ import React from 'react';
|
|
|
4
4
|
import { MarkType } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
6
6
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
|
-
import { mergeExpandBodyText, withExpandBodyBlock } from '../ui/expand-body';
|
|
7
|
+
import { mergeExpandBodyText, withExpandBodyBlock } from '../ui/utils/expand-body';
|
|
8
8
|
import { Doc, DocWithSelectAllTrap, isTextNode, isTextWrapper, mergeTextNodes, toReact } from './nodes';
|
|
9
9
|
import TextWrapperComponent from './nodes/text-wrapper';
|
|
10
10
|
import { isNestedHeaderLinksEnabled } from './utils/links';
|
|
@@ -838,36 +838,6 @@ const addTableCellEdgePropsThroughWrappers = (rows, tableNode, isNumberColumnEna
|
|
|
838
838
|
return rows;
|
|
839
839
|
}
|
|
840
840
|
};
|
|
841
|
-
const addTableCellEdgeProps = (rows, tableNode, isNumberColumnEnabled) => {
|
|
842
|
-
try {
|
|
843
|
-
if (!tableNode) {
|
|
844
|
-
return rows;
|
|
845
|
-
}
|
|
846
|
-
const cellEdgePropsByCellOffset = getCellEdgePropsByCellOffset(tableNode, isNumberColumnEnabled);
|
|
847
|
-
let cellOffset = 0;
|
|
848
|
-
return React.Children.map(rows, (row, rowIndex) => {
|
|
849
|
-
const rowNode = tableNode.child(rowIndex);
|
|
850
|
-
cellOffset += 1;
|
|
851
|
-
let cellIndex = 0;
|
|
852
|
-
const rowChildren = React.Children.map(row.props.children, child => {
|
|
853
|
-
if (! /*#__PURE__*/React.isValidElement(child)) {
|
|
854
|
-
return child;
|
|
855
|
-
}
|
|
856
|
-
const cellNode = rowNode.child(cellIndex);
|
|
857
|
-
const edgeProps = cellEdgePropsByCellOffset.get(cellOffset);
|
|
858
|
-
cellIndex += 1;
|
|
859
|
-
cellOffset += cellNode.nodeSize;
|
|
860
|
-
return edgeProps ? /*#__PURE__*/React.cloneElement(child, edgeProps) : child;
|
|
861
|
-
});
|
|
862
|
-
cellOffset += 1;
|
|
863
|
-
return /*#__PURE__*/React.cloneElement(row, undefined, rowChildren);
|
|
864
|
-
});
|
|
865
|
-
} catch {
|
|
866
|
-
// Renderer can receive malformed historical ADF. If the table shape cannot
|
|
867
|
-
// be described safely, keep rendering without rounded edge metadata.
|
|
868
|
-
return rows;
|
|
869
|
-
}
|
|
870
|
-
};
|
|
871
841
|
|
|
872
842
|
/**
|
|
873
843
|
* Processes table children before passing them to the styled table container.
|
|
@@ -955,7 +925,7 @@ export class TableProcessorWithContainerStyles extends React.Component {
|
|
|
955
925
|
return null;
|
|
956
926
|
}
|
|
957
927
|
const childrenArray = React.Children.toArray(children);
|
|
958
|
-
const childrenWithTableEdgeProps = expValEquals('platform_editor_table_q4_loveability', 'isEnabled', true) ?
|
|
928
|
+
const childrenWithTableEdgeProps = expValEquals('platform_editor_table_q4_loveability', 'isEnabled', true) ? addTableCellEdgePropsThroughWrappers(childrenArray, tableNode, isNumberColumnEnabled) : childrenArray;
|
|
959
929
|
const orderedChildren = compose(this.addNumberColumnIndexes, this.addSortableColumn
|
|
960
930
|
// @ts-expect-error TS2345: Argument of type '(ReactChild | ReactFragment | ReactPortal)[]' is not assignable to parameter of type 'ReactElement<any, string | JSXElementConstructor<any>>[]'
|
|
961
931
|
)(childrenWithTableEdgeProps);
|
package/dist/es2019/ui/Expand.js
CHANGED
|
@@ -13,7 +13,7 @@ import { akEditorLineHeight, akEditorSwoopCubicBezier, akLayoutGutterOffset } fr
|
|
|
13
13
|
import ChevronRightIcon from '@atlaskit/icon/core/chevron-right';
|
|
14
14
|
import Tooltip from '@atlaskit/tooltip/Tooltip';
|
|
15
15
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
16
|
-
import { ExpandBodyProvider, useExpandBody } from './expand-body';
|
|
16
|
+
import { ExpandBodyProvider, useExpandBody } from './utils/expand-body';
|
|
17
17
|
import _uniqueId from 'lodash/uniqueId';
|
|
18
18
|
import { injectIntl } from 'react-intl';
|
|
19
19
|
import { MODE, PLATFORM } from '../analytics/events';
|
|
@@ -220,17 +220,36 @@ function Expand({
|
|
|
220
220
|
rendererContentMode,
|
|
221
221
|
node
|
|
222
222
|
}) {
|
|
223
|
+
var _ancestorBody$reveale;
|
|
223
224
|
const ancestorBody = useExpandBody();
|
|
224
|
-
|
|
225
|
+
|
|
226
|
+
// Shared with every expand in the chain: the element that stood in for this expand and caught the
|
|
227
|
+
// find sits under an expand further out, and by the time this one mounts that element is gone.
|
|
228
|
+
//
|
|
229
|
+
// Built on first render rather than passed to `useRef`, which would evaluate and discard a new set
|
|
230
|
+
// on every render for the life of the expand.
|
|
231
|
+
const ownRevealedByFind = useRef(null);
|
|
232
|
+
if (!ownRevealedByFind.current) {
|
|
233
|
+
ownRevealedByFind.current = new WeakSet();
|
|
234
|
+
}
|
|
235
|
+
const revealedByFind = (_ancestorBody$reveale = ancestorBody === null || ancestorBody === void 0 ? void 0 : ancestorBody.revealedByFind) !== null && _ancestorBody$reveale !== void 0 ? _ancestorBody$reveale : ownRevealedByFind.current;
|
|
236
|
+
/**
|
|
237
|
+
* Browser find matched inside this expand while the expand above it was still collapsed, so it
|
|
238
|
+
* opens as soon as it mounts — otherwise the reader would watch the outer expand open onto a
|
|
239
|
+
* closed one, with the match nowhere to be seen. Empty on the server and on the first client
|
|
240
|
+
* render, so hydration cannot disagree; only a find on the client ever puts anything in it.
|
|
241
|
+
*/
|
|
242
|
+
const revealedByFindOnMount = node !== undefined && revealedByFind.has(node);
|
|
243
|
+
const [expanded, setExpanded] = useState(revealedByFindOnMount);
|
|
225
244
|
const [focused, setFocused] = useState(false);
|
|
226
245
|
/**
|
|
227
246
|
* PGXT-9021: once opened, the body stays rendered even if the reader closes the expand again.
|
|
228
247
|
* Throwing it away would re-run every macro and Forge fetch inside it on the next open, which is
|
|
229
248
|
* slower and visibly reloads content the reader has already seen. We only wanted to save work on
|
|
230
249
|
* the first page load, and by now that has happened. Starts false on both the server and the
|
|
231
|
-
* client, so hydration cannot disagree.
|
|
250
|
+
* first client render, so hydration cannot disagree.
|
|
232
251
|
*/
|
|
233
|
-
const [hasBeenExpanded, setHasBeenExpanded] = useState(
|
|
252
|
+
const [hasBeenExpanded, setHasBeenExpanded] = useState(revealedByFindOnMount);
|
|
234
253
|
const isMobile = false;
|
|
235
254
|
const label = intl.formatMessage(expanded ? expandMessages.collapseNode : expandMessages.expandNode);
|
|
236
255
|
const {
|
|
@@ -250,9 +269,15 @@ function Expand({
|
|
|
250
269
|
// inside other expands, those have to open too or the reader still cannot see it. Each expand
|
|
251
270
|
// asks the one above it, so a single match opens the whole chain and nothing else.
|
|
252
271
|
const openWithAncestors = useCallback(() => {
|
|
272
|
+
// Remembered before anything opens: a block above this expand may have been standing in for
|
|
273
|
+
// itself, and rendering it rebuilds this expand. Without this it would come back closed over
|
|
274
|
+
// the match the reader was just taken to.
|
|
275
|
+
if (node) {
|
|
276
|
+
revealedByFind.add(node);
|
|
277
|
+
}
|
|
253
278
|
openBody();
|
|
254
279
|
ancestorBody === null || ancestorBody === void 0 ? void 0 : ancestorBody.openWithAncestors();
|
|
255
|
-
}, [ancestorBody, openBody]);
|
|
280
|
+
}, [ancestorBody, node, openBody, revealedByFind]);
|
|
256
281
|
|
|
257
282
|
// Feature-detect hidden="until-found" support via the beforematch event. Chrome 102+,
|
|
258
283
|
// Firefox 139+ and Safari 26.2+ all have it; in a browser without it, hidden="until-found" is
|
|
@@ -330,8 +355,9 @@ function Expand({
|
|
|
330
355
|
const revealed = expanded || hasBeenExpanded || !node || supportsHiddenUntilFound === false || !isExperimentEnabled('platform_editor_defer_collapsed_expand_body');
|
|
331
356
|
const expandBody = useMemo(() => ({
|
|
332
357
|
revealed,
|
|
333
|
-
openWithAncestors
|
|
334
|
-
|
|
358
|
+
openWithAncestors,
|
|
359
|
+
revealedByFind
|
|
360
|
+
}), [revealed, openWithAncestors, revealedByFind]);
|
|
335
361
|
return jsx(Container, {
|
|
336
362
|
"data-testid": `expand-container-${nodeType}-${id}`,
|
|
337
363
|
"data-node-type": nodeType,
|
|
@@ -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.8";
|
|
64
64
|
const setAsQueryContainerStyles = css({
|
|
65
65
|
containerName: 'ak-renderer-wrapper',
|
|
66
66
|
containerType: 'inline-size'
|