@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
|
@@ -1,122 +0,0 @@
|
|
|
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.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("./utils/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 also returned untouched, so a table with a nested
|
|
41
|
-
* expand in it, or an extension holding stashed ADF, renders even while collapsed. That
|
|
42
|
-
* expand needs an element of its own, because the element browser find reveals is the only
|
|
43
|
-
* way we learn the match was inside it rather than higher up. We give up the saving on those
|
|
44
|
-
* blocks so the reader searches once instead of once per level.
|
|
45
|
-
*
|
|
46
|
-
* `ancestors` is the node's ancestor chain, nearest last.
|
|
47
|
-
*/
|
|
48
|
-
var withExpandBodyBlock = exports.withExpandBodyBlock = function withExpandBodyBlock(node, ancestors, index, serialized) {
|
|
49
|
-
var parent = ancestors[ancestors.length - 1];
|
|
50
|
-
if (!parent || !(0, _expandSearchText.isExpandNode)(parent)) {
|
|
51
|
-
return serialized;
|
|
52
|
-
}
|
|
53
|
-
if (!(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_defer_collapsed_expand_body') || (0, _expandSearchText.holdsRevealableContent)(node)) {
|
|
54
|
-
return serialized;
|
|
55
|
-
}
|
|
56
|
-
var searchText = (0, _expandSearchText.getBlockSearchText)(node);
|
|
57
|
-
if (searchText === undefined) {
|
|
58
|
-
return serialized;
|
|
59
|
-
}
|
|
60
|
-
return /*#__PURE__*/_react.default.createElement(ExpandBodyBlock, {
|
|
61
|
-
key: "expand-body-block-".concat(index),
|
|
62
|
-
searchText: searchText
|
|
63
|
-
}, serialized);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
/** Whatever the serializer produced for one child: an element, a string, an array of either. */
|
|
67
|
-
|
|
68
|
-
var searchTextOf = function searchTextOf(child) {
|
|
69
|
-
return /*#__PURE__*/(0, _react.isValidElement)(child) && child.type === ExpandBodyBlock ? child.props.searchText : undefined;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Joins neighbouring blocks that are showing text into one, so a run of them is a single string in
|
|
74
|
-
* the DOM rather than one per block. A body of twenty paragraphs becomes one text node instead of
|
|
75
|
-
* twenty.
|
|
76
|
-
*
|
|
77
|
-
* A block that is being rendered — a nested expand, say — ends the run, because the text either
|
|
78
|
-
* side of it has to stay either side of it.
|
|
79
|
-
*/
|
|
80
|
-
var mergeExpandBodyText = exports.mergeExpandBodyText = function mergeExpandBodyText(children) {
|
|
81
|
-
// Called for every fragment in the document, and only an expand's body has anything to merge, so
|
|
82
|
-
// leave the array alone unless two neighbours are actually showing text.
|
|
83
|
-
var hasRun = children.some(function (child, index) {
|
|
84
|
-
return index > 0 && searchTextOf(child) !== undefined && searchTextOf(children[index - 1]) !== undefined;
|
|
85
|
-
});
|
|
86
|
-
if (!hasRun) {
|
|
87
|
-
return children;
|
|
88
|
-
}
|
|
89
|
-
var merged = [];
|
|
90
|
-
var run = [];
|
|
91
|
-
var endRun = function endRun() {
|
|
92
|
-
if (run.length === 0) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
if (run.length === 1) {
|
|
96
|
-
merged.push(run[0]);
|
|
97
|
-
} else {
|
|
98
|
-
var _key;
|
|
99
|
-
var text = run.map(searchTextOf).filter(Boolean).join(_expandSearchText.BLOCK_SEPARATOR);
|
|
100
|
-
// The blocks themselves, not the wrappers around them: nesting the wrappers would show
|
|
101
|
-
// each block's text again inside the joined run.
|
|
102
|
-
var blocks = run.map(function (child) {
|
|
103
|
-
return child.props.children;
|
|
104
|
-
});
|
|
105
|
-
merged.push( /*#__PURE__*/_react.default.createElement(ExpandBodyBlock, {
|
|
106
|
-
key: (_key = run[0].key) !== null && _key !== void 0 ? _key : undefined,
|
|
107
|
-
searchText: text
|
|
108
|
-
}, blocks));
|
|
109
|
-
}
|
|
110
|
-
run = [];
|
|
111
|
-
};
|
|
112
|
-
children.forEach(function (child) {
|
|
113
|
-
if (searchTextOf(child) === undefined) {
|
|
114
|
-
endRun();
|
|
115
|
-
merged.push(child);
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
run.push(child);
|
|
119
|
-
});
|
|
120
|
-
endRun();
|
|
121
|
-
return merged;
|
|
122
|
-
};
|