@atlaskit/renderer 114.2.1 → 114.3.1
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 +18 -0
- package/dist/cjs/react/nodes/extensionFrame.js +8 -6
- package/dist/cjs/react/nodes/index.js +4 -1
- package/dist/cjs/react/nodes/multiBodiedExtension/actions.js +43 -0
- package/dist/cjs/react/nodes/multiBodiedExtension/context.js +71 -0
- package/dist/cjs/react/nodes/multiBodiedExtension.js +109 -102
- package/dist/cjs/react/nodes/multiBodiedExtensionOld.js +157 -0
- package/dist/cjs/ui/Renderer/index.js +1 -1
- package/dist/es2019/react/nodes/extensionFrame.js +8 -6
- package/dist/es2019/react/nodes/index.js +4 -1
- package/dist/es2019/react/nodes/multiBodiedExtension/actions.js +37 -0
- package/dist/es2019/react/nodes/multiBodiedExtension/context.js +56 -0
- package/dist/es2019/react/nodes/multiBodiedExtension.js +127 -118
- package/dist/es2019/react/nodes/multiBodiedExtensionOld.js +168 -0
- package/dist/es2019/ui/Renderer/index.js +1 -1
- package/dist/esm/react/nodes/extensionFrame.js +8 -6
- package/dist/esm/react/nodes/index.js +4 -1
- package/dist/esm/react/nodes/multiBodiedExtension/actions.js +36 -0
- package/dist/esm/react/nodes/multiBodiedExtension/context.js +64 -0
- package/dist/esm/react/nodes/multiBodiedExtension.js +108 -101
- package/dist/esm/react/nodes/multiBodiedExtensionOld.js +148 -0
- package/dist/esm/ui/Renderer/index.js +1 -1
- package/dist/types/react/nodes/multiBodiedExtension/actions.d.ts +10 -0
- package/dist/types/react/nodes/multiBodiedExtension/context.d.ts +17 -0
- package/dist/types/react/nodes/multiBodiedExtension.d.ts +1 -0
- package/dist/types/react/nodes/multiBodiedExtensionOld.d.ts +29 -0
- package/dist/types-ts4.5/react/nodes/multiBodiedExtension/actions.d.ts +10 -0
- package/dist/types-ts4.5/react/nodes/multiBodiedExtension/context.d.ts +17 -0
- package/dist/types-ts4.5/react/nodes/multiBodiedExtension.d.ts +1 -0
- package/dist/types-ts4.5/react/nodes/multiBodiedExtensionOld.d.ts +29 -0
- package/package.json +13 -6
|
@@ -5,16 +5,18 @@
|
|
|
5
5
|
|
|
6
6
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
7
7
|
import { jsx, css } from '@emotion/react';
|
|
8
|
+
import { sharedMultiBodiedExtensionStyles } from '@atlaskit/editor-common/ui';
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
10
|
const containerCSS = css({
|
|
9
|
-
minHeight: '100px'
|
|
11
|
+
minHeight: '100px',
|
|
12
|
+
flexBasis: '100%'
|
|
10
13
|
});
|
|
11
14
|
const ExtensionFrame = props => {
|
|
12
15
|
return jsx("div", {
|
|
13
|
-
css: containerCSS,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
16
|
+
css: [containerCSS, fg('platform_editor_multi_body_extension_extensibility') &&
|
|
17
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
18
|
+
sharedMultiBodiedExtensionStyles.extensionFrameContent],
|
|
19
|
+
"data-extension-frame": "true"
|
|
18
20
|
}, props.children);
|
|
19
21
|
};
|
|
20
22
|
export default ExtensionFrame;
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
// Mapping file
|
|
3
3
|
|
|
4
4
|
import Loadable from 'react-loadable';
|
|
5
|
+
import { UnsupportedBlock, UnsupportedInline } from '@atlaskit/editor-common/ui';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
7
|
import Blockquote from './blockquote';
|
|
6
8
|
import BodiedExtension from './bodiedExtension';
|
|
9
|
+
import MultiBodiedExtensionOld from './multiBodiedExtensionOld';
|
|
7
10
|
import MultiBodiedExtension from './multiBodiedExtension';
|
|
8
11
|
import ExtensionFrame from './extensionFrame';
|
|
9
12
|
import BulletList from './bulletList';
|
|
@@ -24,7 +27,6 @@ import Table from './table';
|
|
|
24
27
|
import { TableCell, TableHeader } from './tableCell';
|
|
25
28
|
import TableRow from './tableRow';
|
|
26
29
|
import UnknownBlock from './unknownBlock';
|
|
27
|
-
import { UnsupportedBlock, UnsupportedInline } from '@atlaskit/editor-common/ui';
|
|
28
30
|
|
|
29
31
|
// Ignored via go/ees005
|
|
30
32
|
// eslint-disable-next-line import/no-named-as-default
|
|
@@ -188,6 +190,7 @@ export const toReact = (node, flags, nodeComponents
|
|
|
188
190
|
...nodeToReact,
|
|
189
191
|
...nodeComponents
|
|
190
192
|
};
|
|
193
|
+
nodes['multiBodiedExtension'] = fg('platform_editor_multi_body_extension_extensibility') ? MultiBodiedExtension : MultiBodiedExtensionOld;
|
|
191
194
|
return nodes[node.type.name];
|
|
192
195
|
};
|
|
193
196
|
/*
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export const useMultiBodiedExtensionActions = ({
|
|
3
|
+
updateActiveChild,
|
|
4
|
+
children,
|
|
5
|
+
allowBodiedOverride,
|
|
6
|
+
childrenContainer
|
|
7
|
+
}) => {
|
|
8
|
+
return React.useMemo(() => {
|
|
9
|
+
return {
|
|
10
|
+
changeActive(index) {
|
|
11
|
+
if (!Number.isInteger(index)) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
updateActiveChild(index);
|
|
15
|
+
return true;
|
|
16
|
+
},
|
|
17
|
+
addChild() {
|
|
18
|
+
return false;
|
|
19
|
+
},
|
|
20
|
+
getChildrenCount() {
|
|
21
|
+
return children && Array.isArray(children) ? children.length : 0;
|
|
22
|
+
},
|
|
23
|
+
removeChild(_index) {
|
|
24
|
+
return false;
|
|
25
|
+
},
|
|
26
|
+
updateParameters(_parameters) {
|
|
27
|
+
return false;
|
|
28
|
+
},
|
|
29
|
+
getChildren() {
|
|
30
|
+
return [];
|
|
31
|
+
},
|
|
32
|
+
getChildrenContainer() {
|
|
33
|
+
return allowBodiedOverride ? childrenContainer : null;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}, [updateActiveChild, children, allowBodiedOverride, childrenContainer]);
|
|
37
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import memoizeOne from 'memoize-one';
|
|
3
|
+
import { getExtensionModuleNodePrivateProps, getNodeRenderer } from '@atlaskit/editor-common/extensions';
|
|
4
|
+
import { useProvider } from '@atlaskit/editor-common/provider-factory';
|
|
5
|
+
export const useMultiBodiedExtensionContext = ({
|
|
6
|
+
extensionType,
|
|
7
|
+
extensionKey
|
|
8
|
+
}) => {
|
|
9
|
+
const isMounted = React.useRef(true);
|
|
10
|
+
const localGetNodeRenderer = React.useMemo(() => memoizeOne(getNodeRenderer), []);
|
|
11
|
+
const [provider, setProvider] = React.useState();
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
+
const [privateProps, setPrivateProps] = React.useState();
|
|
14
|
+
const providerPromise = useProvider('extensionProvider');
|
|
15
|
+
React.useEffect(() => {
|
|
16
|
+
if (providerPromise) {
|
|
17
|
+
providerPromise.then(p => {
|
|
18
|
+
if (isMounted.current) {
|
|
19
|
+
setProvider(p);
|
|
20
|
+
}
|
|
21
|
+
return getExtensionModuleNodePrivateProps(p, extensionType, extensionKey);
|
|
22
|
+
}).then(pr => {
|
|
23
|
+
if (isMounted.current) {
|
|
24
|
+
setPrivateProps(pr);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}, [providerPromise, extensionType, extensionKey]);
|
|
29
|
+
const NodeRenderer = React.useMemo(() => {
|
|
30
|
+
if (!provider) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return localGetNodeRenderer(provider, extensionType, extensionKey);
|
|
34
|
+
}, [provider, extensionType, extensionKey, localGetNodeRenderer]);
|
|
35
|
+
React.useEffect(() => {
|
|
36
|
+
isMounted.current = true;
|
|
37
|
+
return () => {
|
|
38
|
+
isMounted.current = false;
|
|
39
|
+
};
|
|
40
|
+
}, []);
|
|
41
|
+
return React.useMemo(() => {
|
|
42
|
+
if (!provider || !NodeRenderer || !privateProps) {
|
|
43
|
+
return {
|
|
44
|
+
extensionContext: null,
|
|
45
|
+
loading: true
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
extensionContext: {
|
|
50
|
+
NodeRenderer,
|
|
51
|
+
privateProps
|
|
52
|
+
},
|
|
53
|
+
loading: false
|
|
54
|
+
};
|
|
55
|
+
}, [provider, NodeRenderer, privateProps]);
|
|
56
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
1
|
+
/* eslint-disable @atlaskit/design-system/prefer-primitives, @atlaskit/design-system/consistent-css-prop-usage */
|
|
3
2
|
/**
|
|
4
3
|
* @jsxRuntime classic
|
|
5
4
|
* @jsx jsx
|
|
5
|
+
* @jsxFrag
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
@@ -10,46 +10,13 @@ import { jsx, css } from '@emotion/react';
|
|
|
10
10
|
import { N40 } from '@atlaskit/theme/colors';
|
|
11
11
|
import React, { useState } from 'react';
|
|
12
12
|
import { renderExtension } from './extension';
|
|
13
|
-
import ExtensionRenderer from '../../ui/ExtensionRenderer';
|
|
14
13
|
import { WidthConsumer, sharedMultiBodiedExtensionStyles } from '@atlaskit/editor-common/ui';
|
|
15
14
|
import { RendererCssClassName } from '../../consts';
|
|
16
15
|
import { calcBreakoutWidth } from '@atlaskit/editor-common/utils';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const actions = React.useMemo(() => {
|
|
22
|
-
return {
|
|
23
|
-
changeActive(index) {
|
|
24
|
-
return updateActiveChild(index);
|
|
25
|
-
},
|
|
26
|
-
addChild() {
|
|
27
|
-
return false;
|
|
28
|
-
},
|
|
29
|
-
getChildrenCount() {
|
|
30
|
-
return children ? children === null || children === void 0 ? void 0 : children.length : 0;
|
|
31
|
-
},
|
|
32
|
-
removeChild(index) {
|
|
33
|
-
return false;
|
|
34
|
-
},
|
|
35
|
-
updateParameters(parameters) {
|
|
36
|
-
return false;
|
|
37
|
-
},
|
|
38
|
-
// Ignored via go/ees005
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
-
getChildren() {
|
|
41
|
-
return [];
|
|
42
|
-
},
|
|
43
|
-
getChildrenContainer() {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
}, [updateActiveChild, children]);
|
|
48
|
-
return actions;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
// eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
52
|
-
const navigationCssExtended = css`
|
|
16
|
+
import { useMultiBodiedExtensionActions } from './multiBodiedExtension/actions';
|
|
17
|
+
import { useMultiBodiedExtensionContext } from './multiBodiedExtension/context';
|
|
18
|
+
// eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- Ignored via go/DSP-18766
|
|
19
|
+
const navigationStyles = css`
|
|
53
20
|
${sharedMultiBodiedExtensionStyles.mbeNavigation};
|
|
54
21
|
margin-left: 0 !important;
|
|
55
22
|
margin-right: 0 !important;
|
|
@@ -58,83 +25,115 @@ const navigationCssExtended = css`
|
|
|
58
25
|
display: none;
|
|
59
26
|
}
|
|
60
27
|
`;
|
|
28
|
+
|
|
29
|
+
// eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- needs manual remediation
|
|
30
|
+
const containerStyles = css`
|
|
31
|
+
${sharedMultiBodiedExtensionStyles.mbeExtensionContainer};
|
|
32
|
+
.ak-renderer-extension {
|
|
33
|
+
margin-top: 0 !important;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
[data-layout='full-width'],
|
|
37
|
+
[data-layout='wide'] {
|
|
38
|
+
.multiBodiedExtension-navigation {
|
|
39
|
+
border-right: 3px solid ${`var(--ds-border, ${N40})`} !important;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
const MultiBodiedExtensionChildrenContainer = ({
|
|
44
|
+
children
|
|
45
|
+
}) => {
|
|
46
|
+
return jsx("article", {
|
|
47
|
+
"data-testid": "multiBodiedExtension--frames"
|
|
48
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
49
|
+
,
|
|
50
|
+
className: `multiBodiedExtension--frames`
|
|
51
|
+
}, children);
|
|
52
|
+
};
|
|
53
|
+
const MultiBodiedExtensionNavigation = ({
|
|
54
|
+
children
|
|
55
|
+
}) => {
|
|
56
|
+
return jsx("nav", {
|
|
57
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
58
|
+
className: "multiBodiedExtension-navigation",
|
|
59
|
+
css: navigationStyles,
|
|
60
|
+
"data-testid": "multiBodiedExtension-navigation"
|
|
61
|
+
}, children);
|
|
62
|
+
};
|
|
63
|
+
const MultiBodiedExtensionWrapper = ({
|
|
64
|
+
width,
|
|
65
|
+
path,
|
|
66
|
+
layout,
|
|
67
|
+
children
|
|
68
|
+
}) => {
|
|
69
|
+
const isTopLevel = path.length < 1;
|
|
70
|
+
const centerAlignClass = isTopLevel && ['wide', 'full-width'].includes(layout) ? RendererCssClassName.EXTENSION_CENTER_ALIGN : '';
|
|
71
|
+
return jsx("div", {
|
|
72
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
73
|
+
className: `${RendererCssClassName.EXTENSION} ${centerAlignClass} ${RendererCssClassName.EXTENSION_OVERFLOW_CONTAINER}`,
|
|
74
|
+
style: {
|
|
75
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
76
|
+
width: isTopLevel ? calcBreakoutWidth(layout, width) : '100%'
|
|
77
|
+
},
|
|
78
|
+
"data-layout": layout,
|
|
79
|
+
"data-testid": "multiBodiedExtension--wrapper"
|
|
80
|
+
}, children);
|
|
81
|
+
};
|
|
61
82
|
const MultiBodiedExtension = props => {
|
|
83
|
+
var _extensionContext$pri;
|
|
62
84
|
const {
|
|
63
85
|
children,
|
|
64
86
|
layout = 'default',
|
|
65
|
-
path = []
|
|
87
|
+
path = [],
|
|
88
|
+
parameters,
|
|
89
|
+
extensionType,
|
|
90
|
+
extensionKey,
|
|
91
|
+
content,
|
|
92
|
+
marks,
|
|
93
|
+
localId
|
|
66
94
|
} = props;
|
|
67
95
|
const [activeChildIndex, setActiveChildIndex] = useState(0);
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
// Ignored via go/ees007
|
|
76
|
-
// eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
|
|
77
|
-
// TODO: Make sure we log this somewhere if this happens
|
|
78
|
-
setActiveChildIndex(0);
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
setActiveChildIndex(index);
|
|
82
|
-
return true;
|
|
83
|
-
}, [setActiveChildIndex]);
|
|
96
|
+
const {
|
|
97
|
+
loading,
|
|
98
|
+
extensionContext
|
|
99
|
+
} = useMultiBodiedExtensionContext({
|
|
100
|
+
extensionType,
|
|
101
|
+
extensionKey
|
|
102
|
+
});
|
|
84
103
|
const actions = useMultiBodiedExtensionActions({
|
|
85
|
-
updateActiveChild,
|
|
86
|
-
children
|
|
104
|
+
updateActiveChild: setActiveChildIndex,
|
|
105
|
+
children,
|
|
106
|
+
childrenContainer: jsx(MultiBodiedExtensionChildrenContainer, null, children),
|
|
107
|
+
allowBodiedOverride: extensionContext === null || extensionContext === void 0 ? void 0 : (_extensionContext$pri = extensionContext.privateProps) === null || _extensionContext$pri === void 0 ? void 0 : _extensionContext$pri.__allowBodiedOverride
|
|
87
108
|
});
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return jsx("div", {
|
|
113
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
114
|
-
className: `${RendererCssClassName.EXTENSION} ${centerAlignClass} ${overflowContainerClass}`,
|
|
115
|
-
style: {
|
|
116
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
117
|
-
width: isTopLevel ? calcBreakoutWidth(layout, width) : '100%'
|
|
118
|
-
},
|
|
119
|
-
"data-layout": layout
|
|
120
|
-
}, jsx("nav", {
|
|
121
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
122
|
-
className: "multiBodiedExtension-navigation",
|
|
123
|
-
css: navigationCssExtended,
|
|
124
|
-
"data-testid": "multiBodiedExtension-navigation"
|
|
125
|
-
}, jsx(ExtensionRenderer
|
|
126
|
-
// Ignored via go/ees005
|
|
127
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
128
|
-
, _extends({}, props, {
|
|
129
|
-
actions: actions,
|
|
130
|
-
type: "multiBodiedExtension"
|
|
131
|
-
}), ({
|
|
132
|
-
result
|
|
133
|
-
}) => {
|
|
109
|
+
const renderContent = React.useCallback(() => {
|
|
110
|
+
var _marks$find, _marks$find$attrs;
|
|
111
|
+
if (loading || !extensionContext) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
const {
|
|
115
|
+
NodeRenderer,
|
|
116
|
+
privateProps
|
|
117
|
+
} = extensionContext;
|
|
118
|
+
const fragmentLocalId = marks === null || marks === void 0 ? void 0 : (_marks$find = marks.find(m => m.type.name === 'fragment')) === null || _marks$find === void 0 ? void 0 : (_marks$find$attrs = _marks$find.attrs) === null || _marks$find$attrs === void 0 ? void 0 : _marks$find$attrs.localId;
|
|
119
|
+
const node = {
|
|
120
|
+
type: 'multiBodiedExtension',
|
|
121
|
+
extensionKey,
|
|
122
|
+
extensionType,
|
|
123
|
+
parameters,
|
|
124
|
+
content,
|
|
125
|
+
localId,
|
|
126
|
+
fragmentLocalId
|
|
127
|
+
};
|
|
128
|
+
const renderMultiBodiedExtension = () => {
|
|
129
|
+
const MultiBodiedExtensionNodeRenderer = jsx(NodeRenderer, {
|
|
130
|
+
node: node,
|
|
131
|
+
actions: actions
|
|
132
|
+
});
|
|
134
133
|
try {
|
|
135
|
-
if (
|
|
134
|
+
if ( /*#__PURE__*/React.isValidElement(MultiBodiedExtensionNodeRenderer)) {
|
|
136
135
|
// Return the content directly if it's a valid JSX.Element
|
|
137
|
-
return renderExtension(
|
|
136
|
+
return renderExtension(MultiBodiedExtensionNodeRenderer, layout, {
|
|
138
137
|
isTopLevel: path.length < 1
|
|
139
138
|
});
|
|
140
139
|
}
|
|
@@ -147,24 +146,34 @@ const MultiBodiedExtension = props => {
|
|
|
147
146
|
return renderExtension(children, layout, {
|
|
148
147
|
isTopLevel: path.length < 1
|
|
149
148
|
});
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
}
|
|
149
|
+
};
|
|
150
|
+
if (privateProps.__allowBodiedOverride) {
|
|
151
|
+
return renderMultiBodiedExtension();
|
|
152
|
+
} else {
|
|
153
|
+
return jsx(React.Fragment, null, jsx(MultiBodiedExtensionNavigation, null, renderMultiBodiedExtension()), jsx(MultiBodiedExtensionChildrenContainer, null, children));
|
|
154
|
+
}
|
|
155
|
+
}, [loading, extensionContext, layout, path, marks, extensionKey, extensionType, parameters, content, localId, actions, children]);
|
|
156
|
+
|
|
157
|
+
// eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression
|
|
158
|
+
const containerActiveFrameStyles = css`
|
|
159
|
+
.multiBodiedExtension--frames
|
|
160
|
+
> [data-extension-frame='true']:nth-of-type(${activeChildIndex + 1}) {
|
|
161
|
+
display: block;
|
|
162
|
+
}
|
|
163
|
+
`;
|
|
157
164
|
return jsx("section", {
|
|
158
165
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
159
|
-
className: "multiBodiedExtension--container"
|
|
160
|
-
|
|
161
|
-
,
|
|
162
|
-
css: containerCssExtended,
|
|
166
|
+
className: "multiBodiedExtension--container",
|
|
167
|
+
css: [containerStyles, containerActiveFrameStyles],
|
|
163
168
|
"data-testid": "multiBodiedExtension--container",
|
|
164
169
|
"data-active-child-index": activeChildIndex,
|
|
165
170
|
"data-layout": layout
|
|
166
171
|
}, jsx(WidthConsumer, null, ({
|
|
167
172
|
width
|
|
168
|
-
}) =>
|
|
173
|
+
}) => jsx(MultiBodiedExtensionWrapper, {
|
|
174
|
+
layout: layout,
|
|
175
|
+
width: width,
|
|
176
|
+
path: path
|
|
177
|
+
}, renderContent())));
|
|
169
178
|
};
|
|
170
179
|
export default MultiBodiedExtension;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/* eslint-disable @atlaskit/design-system/prefer-primitives, @atlaskit/design-system/consistent-css-prop-usage */
|
|
3
|
+
/**
|
|
4
|
+
* @jsxRuntime classic
|
|
5
|
+
* @jsx jsx
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
9
|
+
import { jsx, css } from '@emotion/react';
|
|
10
|
+
import { N40 } from '@atlaskit/theme/colors';
|
|
11
|
+
import React, { useState } from 'react';
|
|
12
|
+
import { renderExtension } from './extension';
|
|
13
|
+
import ExtensionRenderer from '../../ui/ExtensionRenderer';
|
|
14
|
+
import { WidthConsumer, sharedMultiBodiedExtensionStyles } from '@atlaskit/editor-common/ui';
|
|
15
|
+
import { RendererCssClassName } from '../../consts';
|
|
16
|
+
import { calcBreakoutWidth } from '@atlaskit/editor-common/utils';
|
|
17
|
+
const useMultiBodiedExtensionActions = ({
|
|
18
|
+
updateActiveChild,
|
|
19
|
+
children
|
|
20
|
+
}) => {
|
|
21
|
+
const actions = React.useMemo(() => {
|
|
22
|
+
return {
|
|
23
|
+
changeActive(index) {
|
|
24
|
+
return updateActiveChild(index);
|
|
25
|
+
},
|
|
26
|
+
addChild() {
|
|
27
|
+
return false;
|
|
28
|
+
},
|
|
29
|
+
getChildrenCount() {
|
|
30
|
+
return children ? children === null || children === void 0 ? void 0 : children.length : 0;
|
|
31
|
+
},
|
|
32
|
+
removeChild(index) {
|
|
33
|
+
return false;
|
|
34
|
+
},
|
|
35
|
+
updateParameters(parameters) {
|
|
36
|
+
return false;
|
|
37
|
+
},
|
|
38
|
+
// Ignored via go/ees005
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
+
getChildren() {
|
|
41
|
+
return [];
|
|
42
|
+
},
|
|
43
|
+
getChildrenContainer() {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}, [updateActiveChild, children]);
|
|
48
|
+
return actions;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- Ignored via go/DSP-18766
|
|
52
|
+
const navigationCssExtended = css`
|
|
53
|
+
${sharedMultiBodiedExtensionStyles.mbeNavigation};
|
|
54
|
+
margin-left: 0 !important;
|
|
55
|
+
margin-right: 0 !important;
|
|
56
|
+
.mbe-add-tab-button,
|
|
57
|
+
.mbe-remove-tab {
|
|
58
|
+
display: none;
|
|
59
|
+
}
|
|
60
|
+
`;
|
|
61
|
+
const MultiBodiedExtension = props => {
|
|
62
|
+
const {
|
|
63
|
+
children,
|
|
64
|
+
layout = 'default',
|
|
65
|
+
path = []
|
|
66
|
+
} = props;
|
|
67
|
+
const [activeChildIndex, setActiveChildIndex] = useState(0);
|
|
68
|
+
const removeOverflow = React.Children.toArray(children)
|
|
69
|
+
// Ignored via go/ees005
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
71
|
+
.map(child => /*#__PURE__*/React.isValidElement(child) ? child.props.nodeType === 'table' : false).every(Boolean);
|
|
72
|
+
const overflowContainerClass = !removeOverflow ? RendererCssClassName.EXTENSION_OVERFLOW_CONTAINER : '';
|
|
73
|
+
const updateActiveChild = React.useCallback(index => {
|
|
74
|
+
if (typeof index !== 'number') {
|
|
75
|
+
// Ignored via go/ees007
|
|
76
|
+
// eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
|
|
77
|
+
// TODO: Make sure we log this somewhere if this happens
|
|
78
|
+
setActiveChildIndex(0);
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
setActiveChildIndex(index);
|
|
82
|
+
return true;
|
|
83
|
+
}, [setActiveChildIndex]);
|
|
84
|
+
const actions = useMultiBodiedExtensionActions({
|
|
85
|
+
updateActiveChild,
|
|
86
|
+
children
|
|
87
|
+
});
|
|
88
|
+
// eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- needs manual remediation
|
|
89
|
+
const containerCssExtended = css`
|
|
90
|
+
${sharedMultiBodiedExtensionStyles.mbeExtensionContainer};
|
|
91
|
+
.ak-renderer-extension {
|
|
92
|
+
margin-top: 0 !important;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
[data-layout='full-width'],
|
|
96
|
+
[data-layout='wide'] {
|
|
97
|
+
.multiBodiedExtension-navigation {
|
|
98
|
+
border-right: 3px solid ${`var(--ds-border, ${N40})`} !important;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.multiBodiedExtension--frames
|
|
103
|
+
> [data-extension-frame='true']:nth-of-type(${activeChildIndex + 1}) {
|
|
104
|
+
${sharedMultiBodiedExtensionStyles.extensionFrameContent}
|
|
105
|
+
margin-left: 0;
|
|
106
|
+
margin-right: 0;
|
|
107
|
+
}
|
|
108
|
+
`;
|
|
109
|
+
const isTopLevel = path.length < 1;
|
|
110
|
+
const centerAlignClass = isTopLevel && ['wide', 'full-width'].includes(layout) ? RendererCssClassName.EXTENSION_CENTER_ALIGN : '';
|
|
111
|
+
function renderMbeContent(width) {
|
|
112
|
+
return jsx("div", {
|
|
113
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
114
|
+
className: `${RendererCssClassName.EXTENSION} ${centerAlignClass} ${overflowContainerClass}`,
|
|
115
|
+
style: {
|
|
116
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
117
|
+
width: isTopLevel ? calcBreakoutWidth(layout, width) : '100%'
|
|
118
|
+
},
|
|
119
|
+
"data-layout": layout
|
|
120
|
+
}, jsx("nav", {
|
|
121
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
122
|
+
className: "multiBodiedExtension-navigation",
|
|
123
|
+
css: navigationCssExtended,
|
|
124
|
+
"data-testid": "multiBodiedExtension-navigation"
|
|
125
|
+
}, jsx(ExtensionRenderer
|
|
126
|
+
// Ignored via go/ees005
|
|
127
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
128
|
+
, _extends({}, props, {
|
|
129
|
+
actions: actions,
|
|
130
|
+
type: "multiBodiedExtension"
|
|
131
|
+
}), ({
|
|
132
|
+
result
|
|
133
|
+
}) => {
|
|
134
|
+
try {
|
|
135
|
+
if (result && /*#__PURE__*/React.isValidElement(result)) {
|
|
136
|
+
// Return the content directly if it's a valid JSX.Element
|
|
137
|
+
return renderExtension(result, layout, {
|
|
138
|
+
isTopLevel: path.length < 1
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
} catch (e) {
|
|
142
|
+
/** We don't want this error to block renderer */
|
|
143
|
+
/** We keep rendering the default content */
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Always return default content if anything goes wrong
|
|
147
|
+
return renderExtension(children, layout, {
|
|
148
|
+
isTopLevel: path.length < 1
|
|
149
|
+
});
|
|
150
|
+
})), jsx("article", {
|
|
151
|
+
"data-testid": "multiBodiedExtension--frames"
|
|
152
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
153
|
+
,
|
|
154
|
+
className: `multiBodiedExtension--frames`
|
|
155
|
+
}, children));
|
|
156
|
+
}
|
|
157
|
+
return jsx("section", {
|
|
158
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
159
|
+
className: "multiBodiedExtension--container",
|
|
160
|
+
css: containerCssExtended,
|
|
161
|
+
"data-testid": "multiBodiedExtension--container",
|
|
162
|
+
"data-active-child-index": activeChildIndex,
|
|
163
|
+
"data-layout": layout
|
|
164
|
+
}, jsx(WidthConsumer, null, ({
|
|
165
|
+
width
|
|
166
|
+
}) => renderMbeContent(width)));
|
|
167
|
+
};
|
|
168
|
+
export default MultiBodiedExtension;
|
|
@@ -48,7 +48,7 @@ import { removeEmptySpaceAroundContent } from './rendererHelper';
|
|
|
48
48
|
export const NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
49
49
|
export const DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
50
50
|
const packageName = "@atlaskit/renderer";
|
|
51
|
-
const packageVersion = "114.
|
|
51
|
+
const packageVersion = "114.3.1";
|
|
52
52
|
const setAsQueryContainerStyles = css({
|
|
53
53
|
containerName: 'ak-renderer-wrapper',
|
|
54
54
|
containerType: 'inline-size',
|
|
@@ -5,16 +5,18 @@
|
|
|
5
5
|
|
|
6
6
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
7
7
|
import { jsx, css } from '@emotion/react';
|
|
8
|
+
import { sharedMultiBodiedExtensionStyles } from '@atlaskit/editor-common/ui';
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
10
|
var containerCSS = css({
|
|
9
|
-
minHeight: '100px'
|
|
11
|
+
minHeight: '100px',
|
|
12
|
+
flexBasis: '100%'
|
|
10
13
|
});
|
|
11
14
|
var ExtensionFrame = function ExtensionFrame(props) {
|
|
12
15
|
return jsx("div", {
|
|
13
|
-
css: containerCSS,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
16
|
+
css: [containerCSS, fg('platform_editor_multi_body_extension_extensibility') &&
|
|
17
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
18
|
+
sharedMultiBodiedExtensionStyles.extensionFrameContent],
|
|
19
|
+
"data-extension-frame": "true"
|
|
18
20
|
}, props.children);
|
|
19
21
|
};
|
|
20
22
|
export default ExtensionFrame;
|
|
@@ -5,8 +5,11 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
5
5
|
// Mapping file
|
|
6
6
|
|
|
7
7
|
import Loadable from 'react-loadable';
|
|
8
|
+
import { UnsupportedBlock, UnsupportedInline } from '@atlaskit/editor-common/ui';
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
10
|
import Blockquote from './blockquote';
|
|
9
11
|
import BodiedExtension from './bodiedExtension';
|
|
12
|
+
import MultiBodiedExtensionOld from './multiBodiedExtensionOld';
|
|
10
13
|
import MultiBodiedExtension from './multiBodiedExtension';
|
|
11
14
|
import ExtensionFrame from './extensionFrame';
|
|
12
15
|
import BulletList from './bulletList';
|
|
@@ -27,7 +30,6 @@ import Table from './table';
|
|
|
27
30
|
import { TableCell, TableHeader } from './tableCell';
|
|
28
31
|
import TableRow from './tableRow';
|
|
29
32
|
import UnknownBlock from './unknownBlock';
|
|
30
|
-
import { UnsupportedBlock, UnsupportedInline } from '@atlaskit/editor-common/ui';
|
|
31
33
|
|
|
32
34
|
// Ignored via go/ees005
|
|
33
35
|
// eslint-disable-next-line import/no-named-as-default
|
|
@@ -302,6 +304,7 @@ export var toReact = function toReact(node, flags, nodeComponents
|
|
|
302
304
|
|
|
303
305
|
// Allowing custom components to override those provided in nodeToReact
|
|
304
306
|
var nodes = _objectSpread(_objectSpread({}, nodeToReact), nodeComponents);
|
|
307
|
+
nodes['multiBodiedExtension'] = fg('platform_editor_multi_body_extension_extensibility') ? MultiBodiedExtension : MultiBodiedExtensionOld;
|
|
305
308
|
return nodes[node.type.name];
|
|
306
309
|
};
|
|
307
310
|
/*
|