@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.
@@ -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 also returned untouched, so a table with a nested
45
- * expand in it, or an extension holding stashed ADF, renders even while collapsed. That
46
- * expand needs an element of its own, because the element browser find reveals is the only
47
- * way we learn the match was inside it rather than higher up. We give up the saving on those
48
- * blocks so the reader searches once instead of once per level.
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.7",
3
+ "version": "137.1.9",
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.1.0",
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",
@@ -41,7 +41,7 @@
41
41
  "@atlaskit/code": "^19.1.0",
42
42
  "@atlaskit/css": "^1.1.0",
43
43
  "@atlaskit/editor-card-provider": "^7.2.0",
44
- "@atlaskit/editor-json-transformer": "^9.6.0",
44
+ "@atlaskit/editor-json-transformer": "^9.7.0",
45
45
  "@atlaskit/editor-palette": "^3.4.0",
46
46
  "@atlaskit/editor-prosemirror": "^8.0.0",
47
47
  "@atlaskit/editor-shared-styles": "^4.0.0",
@@ -62,7 +62,7 @@
62
62
  "@atlaskit/media-viewer": "^54.7.0",
63
63
  "@atlaskit/platform-feature-experiments": "^0.3.0",
64
64
  "@atlaskit/platform-feature-flags": "^2.1.0",
65
- "@atlaskit/platform-feature-flags-react": "^1.1.0",
65
+ "@atlaskit/platform-feature-flags-react": "^1.2.0",
66
66
  "@atlaskit/pragmatic-drag-and-drop": "^3.0.0",
67
67
  "@atlaskit/react-compiler-gating": "^0.2.0",
68
68
  "@atlaskit/react-ufo": "^7.7.0",
@@ -70,7 +70,7 @@
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": "^164.0.0",
73
+ "@atlaskit/tmp-editor-statsig": "^166.0.0",
74
74
  "@atlaskit/tokens": "^16.8.0",
75
75
  "@atlaskit/tooltip": "^24.2.0",
76
76
  "@atlaskit/visually-hidden": "^4.3.0",
@@ -85,9 +85,9 @@
85
85
  "uuid": "^3.1.0"
86
86
  },
87
87
  "peerDependencies": {
88
- "@atlaskit/editor-common": "^120.3.0",
88
+ "@atlaskit/editor-common": "^120.6.0",
89
89
  "@atlaskit/link-provider": "^5.4.0",
90
- "@atlaskit/media-core": "^38.0.0",
90
+ "@atlaskit/media-core": "^38.1.0",
91
91
  "react": "^18.2.0",
92
92
  "react-dom": "^18.2.0",
93
93
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
@@ -95,21 +95,21 @@
95
95
  "devDependencies": {
96
96
  "@af/integration-testing": "workspace:^",
97
97
  "@af/visual-regression": "workspace:^",
98
- "@atlaskit/analytics-gas-types": "^6.0.0",
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:^",
102
102
  "@atlaskit/inline-edit": "^16.3.0",
103
103
  "@atlaskit/link-provider": "^5.4.0",
104
104
  "@atlaskit/link-test-helpers": "^11.1.0",
105
- "@atlaskit/media-core": "^38.0.0",
105
+ "@atlaskit/media-core": "^38.1.0",
106
106
  "@atlaskit/media-integration-test-helpers": "workspace:^",
107
107
  "@atlaskit/media-test-helpers": "^42.3.0",
108
108
  "@atlaskit/mention": "^27.18.0",
109
109
  "@atlaskit/modal-dialog": "^16.5.0",
110
110
  "@atlaskit/navigation-system": "^10.16.0",
111
111
  "@atlaskit/primitives": "^22.4.0",
112
- "@atlaskit/profilecard": "^26.19.0",
112
+ "@atlaskit/profilecard": "^26.20.0",
113
113
  "@atlaskit/radio": "^10.1.0",
114
114
  "@atlaskit/range": "^12.1.0",
115
115
  "@atlaskit/section-message": "^10.1.0",
@@ -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
- };
@@ -1,107 +0,0 @@
1
- import React, { createContext, isValidElement, useContext } from 'react';
2
- import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
3
- import { BLOCK_SEPARATOR, getBlockSearchText, holdsRevealableContent, isExpandNode } from './utils/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 also returned untouched, so a table with a nested
32
- * expand in it, or an extension holding stashed ADF, renders even while collapsed. That
33
- * expand needs an element of its own, because the element browser find reveals is the only
34
- * way we learn the match was inside it rather than higher up. We give up the saving on those
35
- * blocks so the reader searches once instead of once per level.
36
- *
37
- * `ancestors` is the node's ancestor chain, nearest last.
38
- */
39
- export const withExpandBodyBlock = (node, ancestors, index, serialized) => {
40
- const parent = ancestors[ancestors.length - 1];
41
- if (!parent || !isExpandNode(parent)) {
42
- return serialized;
43
- }
44
- if (!isExperimentEnabled('platform_editor_defer_collapsed_expand_body') || holdsRevealableContent(node)) {
45
- return serialized;
46
- }
47
- const searchText = getBlockSearchText(node);
48
- if (searchText === undefined) {
49
- return serialized;
50
- }
51
- return /*#__PURE__*/React.createElement(ExpandBodyBlock, {
52
- key: `expand-body-block-${index}`,
53
- searchText: searchText
54
- }, serialized);
55
- };
56
-
57
- /** Whatever the serializer produced for one child: an element, a string, an array of either. */
58
-
59
- const searchTextOf = child => /*#__PURE__*/isValidElement(child) && child.type === ExpandBodyBlock ? child.props.searchText : undefined;
60
-
61
- /**
62
- * Joins neighbouring blocks that are showing text into one, so a run of them is a single string in
63
- * the DOM rather than one per block. A body of twenty paragraphs becomes one text node instead of
64
- * twenty.
65
- *
66
- * A block that is being rendered — a nested expand, say — ends the run, because the text either
67
- * side of it has to stay either side of it.
68
- */
69
- export const mergeExpandBodyText = children => {
70
- // Called for every fragment in the document, and only an expand's body has anything to merge, so
71
- // leave the array alone unless two neighbours are actually showing text.
72
- const hasRun = children.some((child, index) => index > 0 && searchTextOf(child) !== undefined && searchTextOf(children[index - 1]) !== undefined);
73
- if (!hasRun) {
74
- return children;
75
- }
76
- const merged = [];
77
- let run = [];
78
- const endRun = () => {
79
- if (run.length === 0) {
80
- return;
81
- }
82
- if (run.length === 1) {
83
- merged.push(run[0]);
84
- } else {
85
- var _key;
86
- const text = run.map(searchTextOf).filter(Boolean).join(BLOCK_SEPARATOR);
87
- // The blocks themselves, not the wrappers around them: nesting the wrappers would show
88
- // each block's text again inside the joined run.
89
- const blocks = run.map(child => child.props.children);
90
- merged.push( /*#__PURE__*/React.createElement(ExpandBodyBlock, {
91
- key: (_key = run[0].key) !== null && _key !== void 0 ? _key : undefined,
92
- searchText: text
93
- }, blocks));
94
- }
95
- run = [];
96
- };
97
- children.forEach(child => {
98
- if (searchTextOf(child) === undefined) {
99
- endRun();
100
- merged.push(child);
101
- return;
102
- }
103
- run.push(child);
104
- });
105
- endRun();
106
- return merged;
107
- };
@@ -1,114 +0,0 @@
1
- import React, { createContext, isValidElement, useContext } from 'react';
2
- import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
3
- import { BLOCK_SEPARATOR, getBlockSearchText, holdsRevealableContent, isExpandNode } from './utils/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 also returned untouched, so a table with a nested
33
- * expand in it, or an extension holding stashed ADF, renders even while collapsed. That
34
- * expand needs an element of its own, because the element browser find reveals is the only
35
- * way we learn the match was inside it rather than higher up. We give up the saving on those
36
- * blocks so the reader searches once instead of once per level.
37
- *
38
- * `ancestors` is the node's ancestor chain, nearest last.
39
- */
40
- export var withExpandBodyBlock = function withExpandBodyBlock(node, ancestors, index, serialized) {
41
- var parent = ancestors[ancestors.length - 1];
42
- if (!parent || !isExpandNode(parent)) {
43
- return serialized;
44
- }
45
- if (!isExperimentEnabled('platform_editor_defer_collapsed_expand_body') || holdsRevealableContent(node)) {
46
- return serialized;
47
- }
48
- var searchText = getBlockSearchText(node);
49
- if (searchText === undefined) {
50
- return serialized;
51
- }
52
- return /*#__PURE__*/React.createElement(ExpandBodyBlock, {
53
- key: "expand-body-block-".concat(index),
54
- searchText: searchText
55
- }, serialized);
56
- };
57
-
58
- /** Whatever the serializer produced for one child: an element, a string, an array of either. */
59
-
60
- var searchTextOf = function searchTextOf(child) {
61
- return /*#__PURE__*/isValidElement(child) && child.type === ExpandBodyBlock ? child.props.searchText : undefined;
62
- };
63
-
64
- /**
65
- * Joins neighbouring blocks that are showing text into one, so a run of them is a single string in
66
- * the DOM rather than one per block. A body of twenty paragraphs becomes one text node instead of
67
- * twenty.
68
- *
69
- * A block that is being rendered — a nested expand, say — ends the run, because the text either
70
- * side of it has to stay either side of it.
71
- */
72
- export var mergeExpandBodyText = function mergeExpandBodyText(children) {
73
- // Called for every fragment in the document, and only an expand's body has anything to merge, so
74
- // leave the array alone unless two neighbours are actually showing text.
75
- var hasRun = children.some(function (child, index) {
76
- return index > 0 && searchTextOf(child) !== undefined && searchTextOf(children[index - 1]) !== undefined;
77
- });
78
- if (!hasRun) {
79
- return children;
80
- }
81
- var merged = [];
82
- var run = [];
83
- var endRun = function endRun() {
84
- if (run.length === 0) {
85
- return;
86
- }
87
- if (run.length === 1) {
88
- merged.push(run[0]);
89
- } else {
90
- var _key;
91
- var text = run.map(searchTextOf).filter(Boolean).join(BLOCK_SEPARATOR);
92
- // The blocks themselves, not the wrappers around them: nesting the wrappers would show
93
- // each block's text again inside the joined run.
94
- var blocks = run.map(function (child) {
95
- return child.props.children;
96
- });
97
- merged.push( /*#__PURE__*/React.createElement(ExpandBodyBlock, {
98
- key: (_key = run[0].key) !== null && _key !== void 0 ? _key : undefined,
99
- searchText: text
100
- }, blocks));
101
- }
102
- run = [];
103
- };
104
- children.forEach(function (child) {
105
- if (searchTextOf(child) === undefined) {
106
- endRun();
107
- merged.push(child);
108
- return;
109
- }
110
- run.push(child);
111
- });
112
- endRun();
113
- return merged;
114
- };