@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/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,
|
|
@@ -28,7 +28,7 @@ export function BreakoutSSRInlineScript({
|
|
|
28
28
|
}
|
|
29
29
|
const id = Math.floor(Math.random() * (9999999999 - 9999 + 1)) + 9999;
|
|
30
30
|
const shouldSkipScript = {
|
|
31
|
-
table:
|
|
31
|
+
table: true
|
|
32
32
|
};
|
|
33
33
|
return /*#__PURE__*/React.createElement("script", {
|
|
34
34
|
"data-breakout-script-id": id
|
|
@@ -100,7 +100,6 @@ function applyBreakoutAfterSSR(id, breakoutConsts, shouldSkipBreakoutScript, fla
|
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
// Remove with feature gate 'platform-ssr-table-resize'
|
|
104
103
|
// Ignored via go/ees005
|
|
105
104
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
106
105
|
if (item.target.classList.contains('ak-renderer-document')) {
|
|
@@ -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.9";
|
|
64
64
|
const setAsQueryContainerStyles = css({
|
|
65
65
|
containerName: 'ak-renderer-wrapper',
|
|
66
66
|
containerType: 'inline-size'
|
|
@@ -776,7 +776,7 @@ const RendererWrapper = /*#__PURE__*/React.memo(props => {
|
|
|
776
776
|
//
|
|
777
777
|
|
|
778
778
|
// allowRendererContainerStyles is not needed for comment container styling as container should always be set for comments
|
|
779
|
-
if (appearance === 'comment' && isTopLevelRenderer
|
|
779
|
+
if (appearance === 'comment' && isTopLevelRenderer) {
|
|
780
780
|
return jsx("div", {
|
|
781
781
|
css: setAsQueryContainerStyles
|
|
782
782
|
}, renderer);
|
|
@@ -789,7 +789,7 @@ const RendererWrapper = /*#__PURE__*/React.memo(props => {
|
|
|
789
789
|
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') &&
|
|
790
790
|
// In case of having excerpt-include on page there are multiple renderers nested.
|
|
791
791
|
// Make sure only the root renderer is set to be query container.
|
|
792
|
-
isTopLevelRenderer && allowRendererContainerStyles
|
|
792
|
+
isTopLevelRenderer && allowRendererContainerStyles ? jsx("div", {
|
|
793
793
|
css: setAsQueryContainerStyles
|
|
794
794
|
}, renderer) : renderer;
|
|
795
795
|
});
|
|
@@ -0,0 +1,198 @@
|
|
|
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
|
+
const ExpandBodyContext = /*#__PURE__*/createContext(null);
|
|
5
|
+
export const ExpandBodyProvider = ExpandBodyContext.Provider;
|
|
6
|
+
export const useExpandBody = () => useContext(ExpandBodyContext);
|
|
7
|
+
/**
|
|
8
|
+
* One or more neighbouring blocks of an expand's body. Shows their text until the expand is
|
|
9
|
+
* opened, then renders them. Falls back to rendering if there is no text, or if there is no
|
|
10
|
+
* expand above it.
|
|
11
|
+
*
|
|
12
|
+
* The text is rendered as-is, with no element around it. Nothing reads it but browser find,
|
|
13
|
+
* which only needs the characters to be in the DOM.
|
|
14
|
+
*/
|
|
15
|
+
export const ExpandBodyBlock = ({
|
|
16
|
+
children,
|
|
17
|
+
searchText
|
|
18
|
+
}) => {
|
|
19
|
+
const body = useExpandBody();
|
|
20
|
+
if (searchText === undefined || body === null || body.revealed) {
|
|
21
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
22
|
+
}
|
|
23
|
+
return searchText;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Called for every node the serializer renders. If the node is a block of an expand's body,
|
|
28
|
+
* wraps it so it can show its text instead of rendering while that expand is collapsed.
|
|
29
|
+
* Everything else is returned untouched.
|
|
30
|
+
*
|
|
31
|
+
* A block holding an expand of its own is returned untouched, because standing in for the whole
|
|
32
|
+
* block would take that expand with it, and the expand needs an element of its own: the element
|
|
33
|
+
* browser find reveals is the only way we learn the match was inside it rather than higher up. A
|
|
34
|
+
* table is handed to `ExpandBodyTable`, which stands in for its own rows and keeps only the rows
|
|
35
|
+
* that hold an expand. Everything else — a panel, a list, an extension with stashed ADF — renders
|
|
36
|
+
* in full, so the reader searches once instead of once per level.
|
|
37
|
+
*
|
|
38
|
+
* `ancestors` is the node's ancestor chain, nearest last.
|
|
39
|
+
*/
|
|
40
|
+
export const withExpandBodyBlock = (node, ancestors, index, serialized) => {
|
|
41
|
+
const parent = ancestors[ancestors.length - 1];
|
|
42
|
+
if (!parent || !isExpandNode(parent)) {
|
|
43
|
+
return serialized;
|
|
44
|
+
}
|
|
45
|
+
if (!isExperimentEnabled('platform_editor_defer_collapsed_expand_body')) {
|
|
46
|
+
return serialized;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// `serialized` is only null for a node the renderer has no component for, which a table is not.
|
|
50
|
+
// Such a table falls through to the paths below, which do not reach into it.
|
|
51
|
+
if (node.type.name === 'table' && serialized !== null) {
|
|
52
|
+
const parts = getTableStandInParts(node);
|
|
53
|
+
|
|
54
|
+
// With no row to keep, one string can stand in for the whole table — the table then renders
|
|
55
|
+
// nothing at all, and its text joins with the blocks either side of it.
|
|
56
|
+
return parts.every(part => typeof part === 'string') ? /*#__PURE__*/React.createElement(ExpandBodyBlock, {
|
|
57
|
+
key: `expand-body-block-${index}`,
|
|
58
|
+
searchText: parts.join('')
|
|
59
|
+
}, serialized) : /*#__PURE__*/React.createElement(ExpandBodyTable, {
|
|
60
|
+
key: `expand-body-table-${index}`,
|
|
61
|
+
node: node
|
|
62
|
+
}, serialized);
|
|
63
|
+
}
|
|
64
|
+
if (holdsRevealableContent(node)) {
|
|
65
|
+
return serialized;
|
|
66
|
+
}
|
|
67
|
+
const searchText = getBlockSearchText(node);
|
|
68
|
+
if (searchText === undefined) {
|
|
69
|
+
return serialized;
|
|
70
|
+
}
|
|
71
|
+
return /*#__PURE__*/React.createElement(ExpandBodyBlock, {
|
|
72
|
+
key: `expand-body-block-${index}`,
|
|
73
|
+
searchText: searchText
|
|
74
|
+
}, serialized);
|
|
75
|
+
};
|
|
76
|
+
const isRow = child => /*#__PURE__*/isValidElement(child) && child.props.nodeType === 'tableRow';
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The rows inside the serialized table, wherever they sit.
|
|
80
|
+
*
|
|
81
|
+
* What the serializer hands over is not reliably the element whose children are the rows. Marks are
|
|
82
|
+
* folded around the node afterwards, and a product's own serializer may wrap the rows themselves —
|
|
83
|
+
* Confluence's progressive renderer wraps every row but the first. Assuming either a depth or a set
|
|
84
|
+
* of direct children means any wrapper added later silently costs the saving, so the rows are found
|
|
85
|
+
* instead by the `nodeType` the serializer puts on every node.
|
|
86
|
+
*
|
|
87
|
+
* Descent stops at each row: a nested table's rows sit inside a row of this one, and would
|
|
88
|
+
* otherwise be counted among them.
|
|
89
|
+
*
|
|
90
|
+
* The count is only a consistency check. `getTableStandInParts` indexes the rows by position, so a
|
|
91
|
+
* partial match cannot be lined up and the table has to render instead.
|
|
92
|
+
*/
|
|
93
|
+
const rowsOf = (serialized, rowCount) => {
|
|
94
|
+
const rows = [];
|
|
95
|
+
const collect = node => {
|
|
96
|
+
React.Children.toArray(node).forEach(child => {
|
|
97
|
+
if (! /*#__PURE__*/isValidElement(child)) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (isRow(child)) {
|
|
101
|
+
rows.push(child);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
collect(child.props.children);
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
collect(serialized);
|
|
108
|
+
return rows.length === rowCount ? rows : undefined;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* A table in the body of a collapsed expand. Shows the text of its rows until the expand is opened,
|
|
113
|
+
* keeping the rows that hold an expand of their own — those need an element for find to reveal.
|
|
114
|
+
*
|
|
115
|
+
* Standing in for the whole table, the way an ordinary block does, would take that expand with it.
|
|
116
|
+
*/
|
|
117
|
+
export const ExpandBodyTable = ({
|
|
118
|
+
children,
|
|
119
|
+
node
|
|
120
|
+
}) => {
|
|
121
|
+
const body = useExpandBody();
|
|
122
|
+
if (body === null || body.revealed) {
|
|
123
|
+
return children;
|
|
124
|
+
}
|
|
125
|
+
const rows = rowsOf(children, node.childCount);
|
|
126
|
+
if (!rows) {
|
|
127
|
+
// Nothing is wrong: the table renders as it always did, only without the saving. Still worth
|
|
128
|
+
// saying, because a silent fallback looks exactly like the feature being switched off.
|
|
129
|
+
// Every environment but production says it: a wrapper added by a product is only ever seen
|
|
130
|
+
// once that product has deployed, which a `NODE_ENV` check never reaches.
|
|
131
|
+
if (process.env.CLOUD_ENV !== 'production') {
|
|
132
|
+
// eslint-disable-next-line no-console
|
|
133
|
+
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');
|
|
134
|
+
}
|
|
135
|
+
return children;
|
|
136
|
+
}
|
|
137
|
+
return getTableStandInParts(node).map(part => typeof part === 'string' ? part :
|
|
138
|
+
/*#__PURE__*/
|
|
139
|
+
// A row cannot stand in the page on its own — `<tr>` is only valid inside a table — so it
|
|
140
|
+
// keeps the least table around it that makes the markup valid. None of this is laid out: the
|
|
141
|
+
// body is hidden until the reader or find opens the expand, and opening it renders the real
|
|
142
|
+
// table in place of all this.
|
|
143
|
+
React.createElement("table", {
|
|
144
|
+
key: `expand-body-row-${part}`
|
|
145
|
+
}, /*#__PURE__*/React.createElement("tbody", null, rows[part])));
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
/** Whatever the serializer produced for one child: an element, a string, an array of either. */
|
|
149
|
+
|
|
150
|
+
const searchTextOf = child => /*#__PURE__*/isValidElement(child) && child.type === ExpandBodyBlock ? child.props.searchText : undefined;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Joins neighbouring blocks that are showing text into one, so a run of them is a single string in
|
|
154
|
+
* the DOM rather than one per block. A body of twenty paragraphs becomes one text node instead of
|
|
155
|
+
* twenty.
|
|
156
|
+
*
|
|
157
|
+
* A block that is being rendered — a nested expand, say — ends the run, because the text either
|
|
158
|
+
* side of it has to stay either side of it.
|
|
159
|
+
*/
|
|
160
|
+
export const mergeExpandBodyText = children => {
|
|
161
|
+
// Called for every fragment in the document, and only an expand's body has anything to merge, so
|
|
162
|
+
// leave the array alone unless two neighbours are actually showing text.
|
|
163
|
+
const hasRun = children.some((child, index) => index > 0 && searchTextOf(child) !== undefined && searchTextOf(children[index - 1]) !== undefined);
|
|
164
|
+
if (!hasRun) {
|
|
165
|
+
return children;
|
|
166
|
+
}
|
|
167
|
+
const merged = [];
|
|
168
|
+
let run = [];
|
|
169
|
+
const endRun = () => {
|
|
170
|
+
if (run.length === 0) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (run.length === 1) {
|
|
174
|
+
merged.push(run[0]);
|
|
175
|
+
} else {
|
|
176
|
+
var _key;
|
|
177
|
+
const text = run.map(searchTextOf).filter(Boolean).join(BLOCK_SEPARATOR);
|
|
178
|
+
// The blocks themselves, not the wrappers around them: nesting the wrappers would show
|
|
179
|
+
// each block's text again inside the joined run.
|
|
180
|
+
const blocks = run.map(child => child.props.children);
|
|
181
|
+
merged.push( /*#__PURE__*/React.createElement(ExpandBodyBlock, {
|
|
182
|
+
key: (_key = run[0].key) !== null && _key !== void 0 ? _key : undefined,
|
|
183
|
+
searchText: text
|
|
184
|
+
}, blocks));
|
|
185
|
+
}
|
|
186
|
+
run = [];
|
|
187
|
+
};
|
|
188
|
+
children.forEach(child => {
|
|
189
|
+
if (searchTextOf(child) === undefined) {
|
|
190
|
+
endRun();
|
|
191
|
+
merged.push(child);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
run.push(child);
|
|
195
|
+
});
|
|
196
|
+
endRun();
|
|
197
|
+
return merged;
|
|
198
|
+
};
|
|
@@ -117,4 +117,42 @@ export const getBlockSearchText = node => {
|
|
|
117
117
|
searchTextCache.set(node, cached);
|
|
118
118
|
}
|
|
119
119
|
return (_cached = cached) !== null && _cached !== void 0 ? _cached : undefined;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* One piece of what a collapsed table shows: either the text of the rows being stood in for, or the
|
|
124
|
+
* index of a row that has to keep rendering.
|
|
125
|
+
*/
|
|
126
|
+
|
|
127
|
+
const tableStandInCache = new WeakMap();
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* What a table inside a collapsed expand shows in place of rendering, in table order so that find
|
|
131
|
+
* walks it the way the reader reads it.
|
|
132
|
+
*
|
|
133
|
+
* A row keeps rendering when it holds an expand of its own, which needs a real element for browser
|
|
134
|
+
* find to reveal, or when its text carries an inline comment. Its text is left out of the runs
|
|
135
|
+
* either side of it, since the row itself puts that text in the DOM.
|
|
136
|
+
*/
|
|
137
|
+
export const getTableStandInParts = table => {
|
|
138
|
+
const cached = tableStandInCache.get(table);
|
|
139
|
+
if (cached !== undefined) {
|
|
140
|
+
return cached;
|
|
141
|
+
}
|
|
142
|
+
const parts = [];
|
|
143
|
+
table.forEach((row, _offset, index) => {
|
|
144
|
+
const text = holdsRevealableContent(row) ? undefined : getBlockSearchText(row);
|
|
145
|
+
if (text === undefined) {
|
|
146
|
+
parts.push(index);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const last = parts[parts.length - 1];
|
|
150
|
+
if (typeof last === 'string') {
|
|
151
|
+
parts[parts.length - 1] = `${last}${BLOCK_SEPARATOR}${text}`;
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
parts.push(text);
|
|
155
|
+
});
|
|
156
|
+
tableStandInCache.set(table, parts);
|
|
157
|
+
return parts;
|
|
120
158
|
};
|
package/dist/esm/react/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import React from 'react';
|
|
|
11
11
|
import { MarkType } from '@atlaskit/editor-prosemirror/model';
|
|
12
12
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
13
13
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
14
|
-
import { mergeExpandBodyText, withExpandBodyBlock } from '../ui/expand-body';
|
|
14
|
+
import { mergeExpandBodyText, withExpandBodyBlock } from '../ui/utils/expand-body';
|
|
15
15
|
import { Doc, DocWithSelectAllTrap, isTextNode, isTextWrapper, mergeTextNodes, toReact } from './nodes';
|
|
16
16
|
import TextWrapperComponent from './nodes/text-wrapper';
|
|
17
17
|
import { isNestedHeaderLinksEnabled } from './utils/links';
|
|
@@ -281,11 +281,10 @@ var renderScaleDownColgroup = function renderScaleDownColgroup(props) {
|
|
|
281
281
|
}
|
|
282
282
|
// scaling down
|
|
283
283
|
else if (renderWidth < tableWidth && !isTableWidthFixed) {
|
|
284
|
-
var shouldTable100ScaleDown = rendererAppearance === 'comment' && allowTableResizing && !(tableNode !== null && tableNode !== void 0 && tableNode.attrs.width);
|
|
285
284
|
scaleDownPercent = calcScalePercent({
|
|
286
285
|
renderWidth: renderWidth,
|
|
287
286
|
tableWidth: tableWidth,
|
|
288
|
-
maxScale:
|
|
287
|
+
maxScale: maxScalingPercent,
|
|
289
288
|
isNumberColumnEnabled: isNumberColumnEnabled
|
|
290
289
|
});
|
|
291
290
|
}
|
|
@@ -109,8 +109,6 @@ export var StickyTable = function StickyTable(_ref) {
|
|
|
109
109
|
tableNode = _ref.tableNode,
|
|
110
110
|
rendererAppearance = _ref.rendererAppearance,
|
|
111
111
|
allowTableResizing = _ref.allowTableResizing,
|
|
112
|
-
_ref$fixTableSSRResiz = _ref.fixTableSSRResizing,
|
|
113
|
-
fixTableSSRResizing = _ref$fixTableSSRResiz === void 0 ? false : _ref$fixTableSSRResiz,
|
|
114
112
|
allowFixedColumnWidthOption = _ref.allowFixedColumnWidthOption;
|
|
115
113
|
var styles;
|
|
116
114
|
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
@@ -146,7 +144,7 @@ export var StickyTable = function StickyTable(_ref) {
|
|
|
146
144
|
style: {
|
|
147
145
|
width: tableWidth,
|
|
148
146
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
149
|
-
marginBottom:
|
|
147
|
+
marginBottom: 0
|
|
150
148
|
}
|
|
151
149
|
}, jsx("div", {
|
|
152
150
|
ref: innerRef
|
|
@@ -164,7 +162,7 @@ export var StickyTable = function StickyTable(_ref) {
|
|
|
164
162
|
renderWidth: renderWidth,
|
|
165
163
|
tableNode: tableNode,
|
|
166
164
|
rendererAppearance: rendererAppearance,
|
|
167
|
-
fixTableSSRResizing:
|
|
165
|
+
fixTableSSRResizing: true,
|
|
168
166
|
allowFixedColumnWidthOption: allowFixedColumnWidthOption
|
|
169
167
|
},
|
|
170
168
|
/**
|
|
@@ -32,21 +32,10 @@ export var Table = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
32
32
|
if (rendererAppearance === 'comment' && allowTableResizing && tableNode && !((_tableNode$attrs = tableNode.attrs) !== null && _tableNode$attrs !== void 0 && _tableNode$attrs.width)) {
|
|
33
33
|
tableWidth = 'inherit';
|
|
34
34
|
}
|
|
35
|
-
if (rendererAppearance === 'comment' && !allowTableResizing) {
|
|
36
|
-
// in the case we have css container stylings,
|
|
37
|
-
// we don't need to calculate width here as this
|
|
38
|
-
// is done via css
|
|
39
|
-
if (!fg('platform-ssr-table-resize')) {
|
|
40
|
-
tableWidth = renderWidth;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
35
|
// for columns that are evenly distributed, do not return `colgroup` since existing table containerQuery
|
|
45
36
|
// scales up the columns width. This ensures columns always have 42px.
|
|
46
37
|
if (rendererAppearance === 'comment') {
|
|
47
|
-
|
|
48
|
-
tableColumnWidths = columnWidths && colWidthSum(columnWidths) ? columnWidths : undefined;
|
|
49
|
-
}
|
|
38
|
+
tableColumnWidths = columnWidths && colWidthSum(columnWidths) ? columnWidths : undefined;
|
|
50
39
|
}
|
|
51
40
|
var tableLayout = tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.layout;
|
|
52
41
|
var tableDisplayMode = tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.displayMode;
|