@atlaskit/editor-common 130.4.1 → 131.0.0
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 +65 -0
- package/dist/cjs/ai-messages/ai-suggestions.js +5 -0
- package/dist/cjs/element-browser/components/ElementBrowserLoader.js +31 -8
- package/dist/cjs/extensions/extension-handlers.js +164 -33
- package/dist/cjs/floating-toolbar/DropdownMenuExtensionItems.js +25 -4
- package/dist/cjs/icons/index.js +33 -10
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/quick-insert/assets/index.js +888 -257
- package/dist/cjs/quick-insert/{get-matching-quick-insert-components.js → get-quick-insert-menu-model.js} +133 -73
- package/dist/cjs/quick-insert/registered-menu-model.js +4 -11
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/ui/FloatingToolbar/Button.js +2 -0
- package/dist/cjs/ui/Mention/mention-with-profilecard.js +30 -11
- package/dist/cjs/utils/is-non-production-build.js +2 -6
- package/dist/es2019/ai-messages/ai-suggestions.js +5 -0
- package/dist/es2019/element-browser/components/ElementBrowserLoader.js +16 -2
- package/dist/es2019/extensions/extension-handlers.js +88 -15
- package/dist/es2019/floating-toolbar/DropdownMenuExtensionItems.js +16 -2
- package/dist/es2019/icons/index.js +17 -3
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/quick-insert/assets/index.js +386 -66
- package/dist/es2019/quick-insert/{get-matching-quick-insert-components.js → get-quick-insert-menu-model.js} +101 -54
- package/dist/es2019/quick-insert/registered-menu-model.js +2 -3
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/ui/FloatingToolbar/Button.js +2 -0
- package/dist/es2019/ui/Mention/mention-with-profilecard.js +15 -4
- package/dist/es2019/utils/is-non-production-build.js +2 -6
- package/dist/esm/ai-messages/ai-suggestions.js +5 -0
- package/dist/esm/element-browser/components/ElementBrowserLoader.js +28 -6
- package/dist/esm/extensions/extension-handlers.js +165 -33
- package/dist/esm/floating-toolbar/DropdownMenuExtensionItems.js +24 -4
- package/dist/esm/icons/index.js +29 -7
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/quick-insert/assets/index.js +764 -194
- package/dist/esm/quick-insert/{get-matching-quick-insert-components.js → get-quick-insert-menu-model.js} +132 -72
- package/dist/esm/quick-insert/registered-menu-model.js +2 -3
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/ui/FloatingToolbar/Button.js +2 -0
- package/dist/esm/ui/Mention/mention-with-profilecard.js +25 -8
- package/dist/esm/utils/is-non-production-build.js +2 -6
- package/dist/types/ai-messages/ai-suggestions.d.ts +5 -0
- package/dist/types/icons/index.d.ts +5 -3
- package/dist/types/quick-insert/assets/index.d.ts +34 -32
- package/dist/types/quick-insert/{build-quick-insert-menu-model.d.ts → get-quick-insert-menu-model.d.ts} +14 -1
- package/dist/types/quick-insert/getQuickInsertMenuRows.d.ts +1 -1
- package/dist/types/quick-insert/registered-menu-model.d.ts +2 -3
- package/dist/types/ui/FloatingToolbar/Button.d.ts +3 -2
- package/dist/types/utils/is-non-production-build.d.ts +2 -2
- package/package.json +5 -4
- package/dist/cjs/quick-insert/build-quick-insert-menu-model.js +0 -78
- package/dist/es2019/quick-insert/build-quick-insert-menu-model.js +0 -55
- package/dist/esm/quick-insert/build-quick-insert-menu-model.js +0 -71
- package/dist/types/quick-insert/get-matching-quick-insert-components.d.ts +0 -17
|
@@ -22,42 +22,51 @@ const getSearchResults = matches => {
|
|
|
22
22
|
item
|
|
23
23
|
}) => item);
|
|
24
24
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
const getRenderedMenuItems = (section, childrenMap, surfaceContext) => {
|
|
26
|
+
var _childrenMap$get;
|
|
27
|
+
return ((_childrenMap$get = childrenMap.get(getComponentIdentity(section))) !== null && _childrenMap$get !== void 0 ? _childrenMap$get : []).filter(child => child.type === 'menu-item' && willComponentRender(child, childrenMap, surfaceContext));
|
|
28
|
+
};
|
|
29
|
+
const buildBrowseSections = ({
|
|
30
|
+
childrenMap,
|
|
31
|
+
contentSections,
|
|
32
|
+
selectCategoryItems,
|
|
33
|
+
surfaceContext
|
|
34
|
+
}) => {
|
|
35
|
+
const sections = [];
|
|
36
|
+
for (const section of contentSections) {
|
|
37
|
+
const children = getRenderedMenuItems(section, childrenMap, surfaceContext);
|
|
38
|
+
const overflowItems = children.filter(child => isSectionOverflowItemKey(child.key));
|
|
39
|
+
const viewMoreItem = overflowItems[overflowItems.length - 1];
|
|
40
|
+
const items = children.filter(child => !isSectionOverflowItemKey(child.key));
|
|
41
|
+
if (items.length === 0) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
const selectedItems = viewMoreItem !== undefined && selectCategoryItems !== undefined ? selectCategoryItems(items) : items;
|
|
45
|
+
if (selectedItems.length < items.length && viewMoreItem !== undefined) {
|
|
46
|
+
sections.push([section, ...selectedItems, viewMoreItem]);
|
|
47
|
+
} else {
|
|
48
|
+
sections.push([section, ...selectedItems]);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
sections
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
const buildSearchSections = ({
|
|
56
|
+
childrenMap,
|
|
31
57
|
components,
|
|
32
|
-
|
|
33
|
-
query,
|
|
58
|
+
contentSections,
|
|
34
59
|
formatMessage,
|
|
35
|
-
|
|
36
|
-
|
|
60
|
+
query,
|
|
61
|
+
root,
|
|
62
|
+
surfaceContext
|
|
37
63
|
}) => {
|
|
38
|
-
var _childrenMap$get2;
|
|
39
|
-
const rankedComponents = applyRegisteredItemRanks(components, getItemRank);
|
|
40
|
-
const {
|
|
41
|
-
childrenMap,
|
|
42
|
-
root,
|
|
43
|
-
topLevelChildren
|
|
44
|
-
} = resolveSurface(rankedComponents, rootComponent);
|
|
45
|
-
if (!root || !willComponentRender(root, childrenMap, surfaceContext) || !topLevelChildren) {
|
|
46
|
-
return {
|
|
47
|
-
footer: undefined,
|
|
48
|
-
root: undefined,
|
|
49
|
-
sections: []
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
64
|
const matches = new Map();
|
|
53
|
-
const sourceIndexByComponent = new Map(
|
|
54
|
-
for (const section of
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
for (const item of (_childrenMap$get = childrenMap.get(getComponentIdentity(section))) !== null && _childrenMap$get !== void 0 ? _childrenMap$get : []) {
|
|
59
|
-
var _childrenMap$get, _item$match, _match$score, _sourceIndexByCompone;
|
|
60
|
-
if (item.type !== 'menu-item' || isSectionOverflowItemKey(item.key) || !willComponentRender(item, childrenMap, surfaceContext)) {
|
|
65
|
+
const sourceIndexByComponent = new Map(components.map((component, index) => [component, index]));
|
|
66
|
+
for (const section of contentSections) {
|
|
67
|
+
for (const item of getRenderedMenuItems(section, childrenMap, surfaceContext)) {
|
|
68
|
+
var _item$match, _match$score, _sourceIndexByCompone;
|
|
69
|
+
if (isSectionOverflowItemKey(item.key)) {
|
|
61
70
|
continue;
|
|
62
71
|
}
|
|
63
72
|
const match = (_item$match = item.match) === null || _item$match === void 0 ? void 0 : _item$match.call(item, {
|
|
@@ -83,7 +92,7 @@ export const getMatchingQuickInsertComponents = ({
|
|
|
83
92
|
}
|
|
84
93
|
}
|
|
85
94
|
const uniqueMatches = Array.from(matches.values()).sort(compareMatchedItems);
|
|
86
|
-
const searchResults =
|
|
95
|
+
const searchResults = getSearchResults(uniqueMatches);
|
|
87
96
|
const sectionsByKey = new Map();
|
|
88
97
|
for (const match of uniqueMatches) {
|
|
89
98
|
const existing = sectionsByKey.get(match.section.key);
|
|
@@ -94,36 +103,74 @@ export const getMatchingQuickInsertComponents = ({
|
|
|
94
103
|
}
|
|
95
104
|
}
|
|
96
105
|
const sections = Array.from(sectionsByKey.values());
|
|
97
|
-
// An empty query is browse mode: `buildQuickInsertMenuModel` supplies the footer there,
|
|
98
|
-
// so this search model must not add a second one.
|
|
99
|
-
if (query === '') {
|
|
100
|
-
return {
|
|
101
|
-
footer: undefined,
|
|
102
|
-
root,
|
|
103
|
-
searchResults,
|
|
104
|
-
sections
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
const footerSection = topLevelChildren.find(section => section.type === 'menu-section' && isMenuFooterSectionKey(section.key) && willComponentRender(section, childrenMap, surfaceContext));
|
|
108
|
-
const footer = footerSection ? ((_childrenMap$get2 = childrenMap.get(getComponentIdentity(footerSection))) !== null && _childrenMap$get2 !== void 0 ? _childrenMap$get2 : []).find(child => child.type === 'menu-item' && willComponentRender(child, childrenMap, surfaceContext)) : undefined;
|
|
109
106
|
if (sections.length > 0) {
|
|
110
107
|
return {
|
|
111
|
-
footer,
|
|
112
|
-
root,
|
|
113
108
|
searchResults,
|
|
114
109
|
sections
|
|
115
110
|
};
|
|
116
111
|
}
|
|
117
|
-
const fallbackItem =
|
|
118
|
-
var _childrenMap$
|
|
119
|
-
return (_childrenMap$
|
|
112
|
+
const fallbackItem = contentSections.flatMap(section => {
|
|
113
|
+
var _childrenMap$get2;
|
|
114
|
+
return (_childrenMap$get2 = childrenMap.get(getComponentIdentity(section))) !== null && _childrenMap$get2 !== void 0 ? _childrenMap$get2 : [];
|
|
120
115
|
}).find(component => component.type === ASK_ROVO_MENU_ITEM.type && component.key === ASK_ROVO_MENU_ITEM.key && willComponentRender(component, childrenMap, surfaceContext));
|
|
121
|
-
const fallbackItems = fallbackItem ? [fallbackItem] : [];
|
|
122
116
|
return {
|
|
123
|
-
fallbackItems,
|
|
124
|
-
footer,
|
|
125
|
-
root,
|
|
117
|
+
fallbackItems: fallbackItem ? [fallbackItem] : [],
|
|
126
118
|
searchResults,
|
|
127
119
|
sections
|
|
128
120
|
};
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Builds the registered quick-insert menu model. An empty query browses every
|
|
125
|
+
* category; a non-empty query returns ranked matches. The footer is shared by both.
|
|
126
|
+
*/
|
|
127
|
+
export const getQuickInsertMenuModel = ({
|
|
128
|
+
components,
|
|
129
|
+
formatMessage,
|
|
130
|
+
getItemRank,
|
|
131
|
+
query,
|
|
132
|
+
rootComponent,
|
|
133
|
+
selectCategoryItems,
|
|
134
|
+
surfaceContext
|
|
135
|
+
}) => {
|
|
136
|
+
const rankedComponents = applyRegisteredItemRanks(components, getItemRank);
|
|
137
|
+
const {
|
|
138
|
+
childrenMap,
|
|
139
|
+
root,
|
|
140
|
+
topLevelChildren = []
|
|
141
|
+
} = resolveSurface(rankedComponents, rootComponent);
|
|
142
|
+
if (!root || !willComponentRender(root, childrenMap, surfaceContext)) {
|
|
143
|
+
return {
|
|
144
|
+
footer: undefined,
|
|
145
|
+
root: undefined,
|
|
146
|
+
sections: []
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
const renderedSections = topLevelChildren.filter(section => section.type === 'menu-section' && willComponentRender(section, childrenMap, surfaceContext));
|
|
150
|
+
const footerSection = renderedSections.find(({
|
|
151
|
+
key
|
|
152
|
+
}) => isMenuFooterSectionKey(key));
|
|
153
|
+
const contentSections = renderedSections.filter(({
|
|
154
|
+
key
|
|
155
|
+
}) => !isMenuFooterSectionKey(key));
|
|
156
|
+
const content = query === '' ? buildBrowseSections({
|
|
157
|
+
childrenMap,
|
|
158
|
+
contentSections,
|
|
159
|
+
selectCategoryItems,
|
|
160
|
+
surfaceContext
|
|
161
|
+
}) : buildSearchSections({
|
|
162
|
+
childrenMap,
|
|
163
|
+
components: rankedComponents,
|
|
164
|
+
contentSections,
|
|
165
|
+
formatMessage,
|
|
166
|
+
query,
|
|
167
|
+
root,
|
|
168
|
+
surfaceContext
|
|
169
|
+
});
|
|
170
|
+
const footer = footerSection ? getRenderedMenuItems(footerSection, childrenMap, surfaceContext)[0] : undefined;
|
|
171
|
+
return {
|
|
172
|
+
...content,
|
|
173
|
+
footer,
|
|
174
|
+
root
|
|
175
|
+
};
|
|
129
176
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { getQuickInsertMenuModel } from './get-quick-insert-menu-model';
|
|
4
4
|
export { getQuickInsertMenuRows } from './getQuickInsertMenuRows';
|
|
5
5
|
export { quickInsertProviderMenuItemKey } from './getQuickInsertProviderMenuItemKey';
|
|
6
|
-
export { selectQuickInsertCategoryItems } from './selectQuickInsertCategoryItems';
|
|
7
|
-
export { getMatchingQuickInsertComponents } from './get-matching-quick-insert-components';
|
|
6
|
+
export { selectQuickInsertCategoryItems } from './selectQuickInsertCategoryItems';
|
|
@@ -14,7 +14,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
|
14
14
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
15
15
|
import Layer from '../Layer';
|
|
16
16
|
const packageName = "@atlaskit/editor-common";
|
|
17
|
-
const packageVersion = "
|
|
17
|
+
const packageVersion = "131.0.0";
|
|
18
18
|
const halfFocusRing = 1;
|
|
19
19
|
const dropOffset = '0, 8';
|
|
20
20
|
const fadeIn = keyframes({
|
|
@@ -38,6 +38,7 @@ const FloatingToolbarButton = ({
|
|
|
38
38
|
areaControls,
|
|
39
39
|
ariaLabel,
|
|
40
40
|
isRadioButton,
|
|
41
|
+
isLoading,
|
|
41
42
|
pulse,
|
|
42
43
|
areAnyNewToolbarFlagsEnabled
|
|
43
44
|
}, forwardedRef) => {
|
|
@@ -123,6 +124,7 @@ const FloatingToolbarButton = ({
|
|
|
123
124
|
onKeyDown: onKeyDown,
|
|
124
125
|
isSelected: selected,
|
|
125
126
|
isDisabled: disabled,
|
|
127
|
+
isLoading: isLoading,
|
|
126
128
|
testId: testId,
|
|
127
129
|
interactionName: interactionName,
|
|
128
130
|
onMouseEnter: expValEquals('editor_a11y__enghealth-46814_fy26', 'isEnabled', true) ? onMouseEnter : undefined,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import Loadable from 'react-loadable';
|
|
3
|
+
// oxlint-disable-next-line @atlassian/no-restricted-imports
|
|
4
|
+
import { lazy, LazySuspense } from 'react-loosely-lazy';
|
|
3
5
|
import ResourcedMention from '@atlaskit/mention/resourced-mention';
|
|
4
6
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
5
7
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
@@ -11,12 +13,21 @@ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
|
11
13
|
// Lazy-loaded so the agent profile card chunk (and its `@atlaskit/rovo-agent-components`
|
|
12
14
|
// dependency) stays off the critical path — it is only fetched when an agent mention
|
|
13
15
|
// (`userType === 'APP'`) actually renders, never for person mentions.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const loadAgentProfileCardTrigger = () => import( /* webpackChunkName: "@atlaskit-internal_profilecard/agent-profile-card-trigger" */
|
|
17
|
+
'@atlaskit/profilecard/agent-profile-card-trigger').then(mod => mod.AgentProfileCardTrigger);
|
|
18
|
+
const AgentProfileCardTriggerLazy = lazy(() => import( /* webpackChunkName: "@atlaskit-internal_profilecard/agent-profile-card-trigger" */
|
|
19
|
+
'@atlaskit/profilecard/agent-profile-card-trigger').then(mod => mod.AgentProfileCardTrigger));
|
|
20
|
+
AgentProfileCardTriggerLazy.displayName = 'lazy(AgentProfileCardTrigger)';
|
|
21
|
+
const AgentProfileCardTriggerLoadable = Loadable({
|
|
22
|
+
loader: loadAgentProfileCardTrigger,
|
|
18
23
|
loading: () => null
|
|
19
24
|
});
|
|
25
|
+
const AgentProfileCardTrigger = props => isExperimentEnabled('platform_editor_loosely_lazy_migration') ? /*#__PURE__*/React.createElement(LazySuspense, {
|
|
26
|
+
fallback: null
|
|
27
|
+
}, /*#__PURE__*/React.createElement(AgentProfileCardTriggerLazy, props)) :
|
|
28
|
+
/*#__PURE__*/
|
|
29
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
30
|
+
React.createElement(AgentProfileCardTriggerLoadable, props);
|
|
20
31
|
|
|
21
32
|
// Ignored via go/ees005
|
|
22
33
|
// eslint-disable-next-line require-unicode-regexp
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
2
1
|
/**
|
|
3
|
-
* Adds a product-owned build classification
|
|
4
|
-
* A classifier callback is
|
|
2
|
+
* Adds a product-owned build classification to analytics attributes.
|
|
3
|
+
* A classifier callback is evaluated lazily, so the caller controls when browser reads happen.
|
|
5
4
|
* An unknown classification is omitted; an explicit false is preserved.
|
|
6
5
|
*/
|
|
7
6
|
export const getNonProductionBuildAnalyticsAttributes = classification => {
|
|
8
|
-
if (!isExperimentEnabled('platform_editor_non_production_build_analytics')) {
|
|
9
|
-
return {};
|
|
10
|
-
}
|
|
11
7
|
const isNonProductionBuild = typeof classification === 'function' ? classification() : classification;
|
|
12
8
|
return isNonProductionBuild !== undefined ? {
|
|
13
9
|
isNonProductionBuild
|
|
@@ -300,6 +300,11 @@ export var aiSuggestionsMessages = defineMessages({
|
|
|
300
300
|
defaultMessage: 'Rovo is reviewing your page',
|
|
301
301
|
description: 'First loading message on the AI suggestions thinking bar, shown when the name of the reviewing agent is unknown'
|
|
302
302
|
},
|
|
303
|
+
thinkingPreparingAgent: {
|
|
304
|
+
id: 'fabric.editor.ai.suggestions.thinking.preparingAgent.non-final',
|
|
305
|
+
defaultMessage: 'Preparing agent',
|
|
306
|
+
description: 'First loading message on the AI suggestions thinking bar, shown while the reviewing agent is still being loaded and its name is not yet known. Animated dots are appended by the UI.'
|
|
307
|
+
},
|
|
303
308
|
thinkingReviewingContentWithAgent: {
|
|
304
309
|
id: 'fabric.editor.ai.suggestions.thinking.agentAnalyzing.non-final',
|
|
305
310
|
defaultMessage: '{agentName} is analyzing',
|
|
@@ -7,6 +7,11 @@ import React from 'react';
|
|
|
7
7
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
8
|
import { css, jsx } from '@emotion/react';
|
|
9
9
|
import Loadable from 'react-loadable';
|
|
10
|
+
// oxlint-disable-next-line @atlassian/no-restricted-imports
|
|
11
|
+
import { lazy, LazySuspense } from 'react-loosely-lazy';
|
|
12
|
+
|
|
13
|
+
// oxlint-disable-next-line @atlassian/no-restricted-imports
|
|
14
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
10
15
|
import Spinner from '@atlaskit/spinner/spinner';
|
|
11
16
|
var spinnerContainer = css({
|
|
12
17
|
display: 'flex',
|
|
@@ -15,12 +20,19 @@ var spinnerContainer = css({
|
|
|
15
20
|
height: '100%',
|
|
16
21
|
width: '100%'
|
|
17
22
|
});
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
var loadElementBrowser = function loadElementBrowser() {
|
|
24
|
+
return import( /* webpackChunkName: "@atlaskit-internal_editor-element-browser" */'../ElementBrowser').then(function (module) {
|
|
25
|
+
return module.default;
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
var ElementBrowserLazy = lazy(function () {
|
|
29
|
+
return import( /* webpackChunkName: "@atlaskit-internal_editor-element-browser" */'../ElementBrowser').then(function (module) {
|
|
30
|
+
return module.default;
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
ElementBrowserLazy.displayName = 'lazy(ElementBrowser)';
|
|
34
|
+
var ElementBrowserLoadable = Loadable({
|
|
35
|
+
loader: loadElementBrowser,
|
|
24
36
|
loading: function loading() {
|
|
25
37
|
return jsx("div", {
|
|
26
38
|
css: spinnerContainer
|
|
@@ -30,4 +42,14 @@ var ElementBrowserLoader = Loadable({
|
|
|
30
42
|
}));
|
|
31
43
|
}
|
|
32
44
|
});
|
|
45
|
+
var ElementBrowserLoader = function ElementBrowserLoader(props) {
|
|
46
|
+
return isExperimentEnabled('platform_editor_loosely_lazy_migration') ? jsx(LazySuspense, {
|
|
47
|
+
fallback: null
|
|
48
|
+
}, jsx(ElementBrowserLazy, props)) :
|
|
49
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
50
|
+
jsx(ElementBrowserLoadable, props);
|
|
51
|
+
};
|
|
52
|
+
ElementBrowserLoader.preload = function () {
|
|
53
|
+
return isExperimentEnabled('platform_editor_loosely_lazy_migration') ? ElementBrowserLazy.preload() : ElementBrowserLoadable.preload();
|
|
54
|
+
};
|
|
33
55
|
export default ElementBrowserLoader;
|
|
@@ -1,9 +1,21 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
8
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
9
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
10
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
11
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
12
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
4
13
|
import React from 'react';
|
|
5
14
|
import { useIntl } from 'react-intl';
|
|
6
15
|
import Loadable from 'react-loadable';
|
|
16
|
+
// oxlint-disable-next-line @atlassian/no-restricted-imports
|
|
17
|
+
import { lazy, LazySuspense } from 'react-loosely-lazy';
|
|
18
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
7
19
|
import { getExtensionKeyAndNodeKey, resolveImport } from './manifest-helpers';
|
|
8
20
|
import { messages } from './messages';
|
|
9
21
|
import { resolveImportSync } from './resolveImportSync';
|
|
@@ -29,24 +41,24 @@ export function getExtensionModuleNode(_x, _x2, _x3) {
|
|
|
29
41
|
|
|
30
42
|
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
31
43
|
function _getExtensionModuleNode() {
|
|
32
|
-
_getExtensionModuleNode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
44
|
+
_getExtensionModuleNode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(extensionProvider, extensionType, extensionKey
|
|
33
45
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Generic extension types; any required for provider compatibility
|
|
34
46
|
) {
|
|
35
47
|
var _getExtensionKeyAndNo3, _getExtensionKeyAndNo4, extKey, nodeKey, manifest;
|
|
36
|
-
return _regeneratorRuntime.wrap(function (
|
|
37
|
-
while (1) switch (
|
|
48
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
49
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
38
50
|
case 0:
|
|
39
51
|
_getExtensionKeyAndNo3 = getExtensionKeyAndNodeKey(extensionKey, extensionType), _getExtensionKeyAndNo4 = _slicedToArray(_getExtensionKeyAndNo3, 2), extKey = _getExtensionKeyAndNo4[0], nodeKey = _getExtensionKeyAndNo4[1];
|
|
40
|
-
|
|
52
|
+
_context2.next = 1;
|
|
41
53
|
return extensionProvider.getExtension(extensionType, extKey);
|
|
42
54
|
case 1:
|
|
43
|
-
manifest =
|
|
44
|
-
return
|
|
55
|
+
manifest = _context2.sent;
|
|
56
|
+
return _context2.abrupt("return", getNodeFromManifest(manifest, extKey, nodeKey, extensionType, extensionKey));
|
|
45
57
|
case 2:
|
|
46
58
|
case "end":
|
|
47
|
-
return
|
|
59
|
+
return _context2.stop();
|
|
48
60
|
}
|
|
49
|
-
},
|
|
61
|
+
}, _callee2);
|
|
50
62
|
}));
|
|
51
63
|
return _getExtensionModuleNode.apply(this, arguments);
|
|
52
64
|
}
|
|
@@ -76,16 +88,16 @@ export function getExtensionModuleNodePrivateProps(_x4, _x5, _x6) {
|
|
|
76
88
|
return _getExtensionModuleNodePrivateProps.apply(this, arguments);
|
|
77
89
|
}
|
|
78
90
|
function _getExtensionModuleNodePrivateProps() {
|
|
79
|
-
_getExtensionModuleNodePrivateProps = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
91
|
+
_getExtensionModuleNodePrivateProps = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(extensionProvider, extensionType, extensionKey) {
|
|
80
92
|
var moduleNode;
|
|
81
|
-
return _regeneratorRuntime.wrap(function (
|
|
82
|
-
while (1) switch (
|
|
93
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
94
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
83
95
|
case 0:
|
|
84
|
-
|
|
96
|
+
_context3.next = 1;
|
|
85
97
|
return getExtensionModuleNode(extensionProvider, extensionType, extensionKey);
|
|
86
98
|
case 1:
|
|
87
|
-
moduleNode =
|
|
88
|
-
return
|
|
99
|
+
moduleNode = _context3.sent;
|
|
100
|
+
return _context3.abrupt("return", Object.keys(moduleNode).filter(function (key) {
|
|
89
101
|
return key.startsWith('__');
|
|
90
102
|
}).reduce(function (acc, key) {
|
|
91
103
|
// Ignored via go/ees005
|
|
@@ -95,9 +107,9 @@ function _getExtensionModuleNodePrivateProps() {
|
|
|
95
107
|
}, {}));
|
|
96
108
|
case 2:
|
|
97
109
|
case "end":
|
|
98
|
-
return
|
|
110
|
+
return _context3.stop();
|
|
99
111
|
}
|
|
100
|
-
},
|
|
112
|
+
}, _callee3);
|
|
101
113
|
}));
|
|
102
114
|
return _getExtensionModuleNodePrivateProps.apply(this, arguments);
|
|
103
115
|
}
|
|
@@ -105,6 +117,52 @@ function isUnknownConfluenceMacroWithBody(extensionNode) {
|
|
|
105
117
|
var _extensionNode$parame;
|
|
106
118
|
return extensionNode !== null && extensionNode.type === 'extension' && extensionNode.extensionType === 'com.atlassian.confluence.macro.core' && !!((_extensionNode$parame = extensionNode.parameters) !== null && _extensionNode$parame !== void 0 && (_extensionNode$parame = _extensionNode$parame.macroParams) !== null && _extensionNode$parame !== void 0 && (_extensionNode$parame = _extensionNode$parame.__bodyContent) !== null && _extensionNode$parame !== void 0 && _extensionNode$parame.value);
|
|
107
119
|
}
|
|
120
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components -- error boundaries require a class component
|
|
121
|
+
var ExtensionRendererErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
|
122
|
+
function ExtensionRendererErrorBoundary() {
|
|
123
|
+
var _this;
|
|
124
|
+
_classCallCheck(this, ExtensionRendererErrorBoundary);
|
|
125
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
126
|
+
args[_key] = arguments[_key];
|
|
127
|
+
}
|
|
128
|
+
_this = _callSuper(this, ExtensionRendererErrorBoundary, [].concat(args));
|
|
129
|
+
_defineProperty(_this, "state", {});
|
|
130
|
+
return _this;
|
|
131
|
+
}
|
|
132
|
+
_inherits(ExtensionRendererErrorBoundary, _React$Component);
|
|
133
|
+
return _createClass(ExtensionRendererErrorBoundary, [{
|
|
134
|
+
key: "componentDidCatch",
|
|
135
|
+
value: function componentDidCatch(error) {
|
|
136
|
+
// eslint-disable-next-line no-console
|
|
137
|
+
console.error('Error rendering extension', error);
|
|
138
|
+
}
|
|
139
|
+
}, {
|
|
140
|
+
key: "render",
|
|
141
|
+
value: function render() {
|
|
142
|
+
return this.state.error ? renderExtensionLoadingError(this.state.error, this.props.fallbackProps) : this.props.children;
|
|
143
|
+
}
|
|
144
|
+
}], [{
|
|
145
|
+
key: "getDerivedStateFromError",
|
|
146
|
+
value: function getDerivedStateFromError(error) {
|
|
147
|
+
return {
|
|
148
|
+
error: error
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
}]);
|
|
152
|
+
}(React.Component);
|
|
153
|
+
var noop = function noop() {};
|
|
154
|
+
function renderExtensionLoadingError(error, props) {
|
|
155
|
+
// Needed because the old react-loadable (older code-splitting library) error handling behaviour might be relied on by extensions.
|
|
156
|
+
// https://unpkg.com/react-loadable@5.2.2/lib/index.js
|
|
157
|
+
return /*#__PURE__*/React.createElement(ExtensionLoading, _extends({
|
|
158
|
+
isLoading: false,
|
|
159
|
+
pastDelay: true,
|
|
160
|
+
timedOut: false,
|
|
161
|
+
error: error,
|
|
162
|
+
retry: noop
|
|
163
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
164
|
+
}, props));
|
|
165
|
+
}
|
|
108
166
|
function ExtensionLoading(props) {
|
|
109
167
|
var intl = useIntl();
|
|
110
168
|
var extensionNode = props.node;
|
|
@@ -127,29 +185,103 @@ function ExtensionLoading(props) {
|
|
|
127
185
|
|
|
128
186
|
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
129
187
|
export function getNodeRenderer(extensionProvider, extensionType, extensionKey) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
188
|
+
// Async is needed to wrap the getExtensionModuleNodeMaybePreloaded call in a promise so that we can use the lazy() API
|
|
189
|
+
var loadNodeRenderer = /*#__PURE__*/function () {
|
|
190
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
191
|
+
var _renderSync, _ref2;
|
|
192
|
+
var maybePromise, preloaded, _t, _t2, _t3;
|
|
193
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
194
|
+
while (1) switch (_context.prev = _context.next) {
|
|
195
|
+
case 0:
|
|
196
|
+
maybePromise = getExtensionModuleNodeMaybePreloaded(extensionProvider, extensionType, extensionKey);
|
|
197
|
+
if (!(maybePromise instanceof Promise)) {
|
|
198
|
+
_context.next = 2;
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
_t = resolveImport;
|
|
202
|
+
_context.next = 1;
|
|
203
|
+
return maybePromise;
|
|
204
|
+
case 1:
|
|
205
|
+
return _context.abrupt("return", _t(_context.sent.render()));
|
|
206
|
+
case 2:
|
|
207
|
+
preloaded = maybePromise === null || maybePromise === void 0 || (_renderSync = (_ref2 = maybePromise).renderSync) === null || _renderSync === void 0 ? void 0 : _renderSync.call(_ref2); // Only product implemented preloading will return sync result
|
|
208
|
+
// However the out-of-box won't handle this. Confluence uses a custom implementation
|
|
209
|
+
if (!preloaded) {
|
|
210
|
+
_context.next = 3;
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
_t2 =
|
|
214
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
215
|
+
resolveImportSync(preloaded);
|
|
216
|
+
_context.next = 5;
|
|
217
|
+
break;
|
|
218
|
+
case 3:
|
|
219
|
+
_t3 = resolveImport;
|
|
220
|
+
_context.next = 4;
|
|
221
|
+
return maybePromise;
|
|
222
|
+
case 4:
|
|
223
|
+
_t2 = _t3(_context.sent.render());
|
|
224
|
+
case 5:
|
|
225
|
+
return _context.abrupt("return", _t2);
|
|
226
|
+
case 6:
|
|
227
|
+
case "end":
|
|
228
|
+
return _context.stop();
|
|
229
|
+
}
|
|
230
|
+
}, _callee);
|
|
231
|
+
}));
|
|
232
|
+
return function loadNodeRenderer() {
|
|
233
|
+
return _ref.apply(this, arguments);
|
|
234
|
+
};
|
|
235
|
+
}();
|
|
236
|
+
var LazyNodeRenderer = lazy(function () {
|
|
237
|
+
return loadNodeRenderer();
|
|
238
|
+
});
|
|
239
|
+
LazyNodeRenderer.displayName = 'lazy(NodeRenderer)';
|
|
240
|
+
var loadNodeRendererNoWrappedPromise = function loadNodeRendererNoWrappedPromise() {
|
|
241
|
+
var _renderSync2, _ref3;
|
|
242
|
+
var maybePromise = getExtensionModuleNodeMaybePreloaded(extensionProvider, extensionType, extensionKey);
|
|
243
|
+
if (maybePromise instanceof Promise) {
|
|
244
|
+
return maybePromise.then(function (node) {
|
|
245
|
+
return resolveImport(node.render());
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
var preloaded = maybePromise === null || maybePromise === void 0 || (_renderSync2 = (_ref3 = maybePromise).renderSync) === null || _renderSync2 === void 0 ? void 0 : _renderSync2.call(_ref3);
|
|
249
|
+
// Only product implemented preloading will return sync result
|
|
250
|
+
// However the out-of-box won't handle this. Confluence uses a custom implementation
|
|
251
|
+
return preloaded ?
|
|
252
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
253
|
+
resolveImportSync(preloaded) : resolveImport(maybePromise.render());
|
|
254
|
+
};
|
|
255
|
+
// Ignored via go/ees005
|
|
256
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
257
|
+
var getNodeRenderer = Loadable({
|
|
258
|
+
loader: loadNodeRendererNoWrappedPromise,
|
|
147
259
|
// react-loadable passes all props from <NodeRenderer> to the loading component at runtime,
|
|
148
260
|
// but its TypeScript types only expect LoadingComponentProps. We cast here because
|
|
149
261
|
// ExtensionLoading accepts additional props (node, showUnknownMacroPlaceholder) that
|
|
150
262
|
// react-loadable will pass through but doesn't know about in its type definitions.
|
|
151
263
|
loading: ExtensionLoading
|
|
152
264
|
});
|
|
265
|
+
// We have to make sure the Loadable is assigned the name "getNodeRenderer" by Babel.
|
|
266
|
+
// This loadable name is used by Babel to inject _maybeSyncLoader: true.
|
|
267
|
+
// confluence/next/tools/config/loadableBabelPluginOptions.config.js (see HOT-307098)
|
|
268
|
+
var LoadableNodeRenderer = getNodeRenderer;
|
|
269
|
+
var NodeRenderer = function NodeRenderer(props) {
|
|
270
|
+
var _props$loadingFallbac;
|
|
271
|
+
if (!isExperimentEnabled('platform_editor_loosely_lazy_migration')) {
|
|
272
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
273
|
+
return /*#__PURE__*/React.createElement(LoadableNodeRenderer, props);
|
|
274
|
+
}
|
|
275
|
+
return /*#__PURE__*/React.createElement(ExtensionRendererErrorBoundary, {
|
|
276
|
+
fallbackProps: props
|
|
277
|
+
}, /*#__PURE__*/React.createElement(LazySuspense, {
|
|
278
|
+
fallback: (_props$loadingFallbac = props.loadingFallback) !== null && _props$loadingFallbac !== void 0 ? _props$loadingFallbac : null
|
|
279
|
+
}, /*#__PURE__*/React.createElement(LazyNodeRenderer, props)));
|
|
280
|
+
};
|
|
281
|
+
NodeRenderer.preload = function () {
|
|
282
|
+
return isExperimentEnabled('platform_editor_loosely_lazy_migration') ? LazyNodeRenderer.preload() : LoadableNodeRenderer.preload();
|
|
283
|
+
};
|
|
284
|
+
return NodeRenderer;
|
|
153
285
|
}
|
|
154
286
|
// eslint-disable-next-line @atlaskit/editor/no-re-export
|
|
155
287
|
export { getExtensionManifest } from './getExtensionManifest';
|
|
@@ -3,6 +3,9 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
4
|
import React, { useEffect, useRef, useState } from 'react';
|
|
5
5
|
import Loadable from 'react-loadable';
|
|
6
|
+
// oxlint-disable-next-line @atlassian/no-restricted-imports
|
|
7
|
+
import { lazy, LazySuspense } from 'react-loosely-lazy';
|
|
8
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
6
9
|
import { getContextualToolbarItemsFromModule } from '../extensions';
|
|
7
10
|
import { nodeToJSON } from '../utils';
|
|
8
11
|
import { DropdownMenuItem } from './DropdownMenuItem';
|
|
@@ -85,12 +88,29 @@ var DropdownMenuExtensionItem = function DropdownMenuExtensionItem(_ref3) {
|
|
|
85
88
|
// Use ref to keep icon component stable across renders
|
|
86
89
|
var iconRef = useRef(null);
|
|
87
90
|
if (!iconRef.current && item.icon) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
var loadIcon = function loadIcon() {
|
|
92
|
+
return resolveExtensionIcon(item.icon);
|
|
93
|
+
};
|
|
94
|
+
var IconLazy = lazy(function () {
|
|
95
|
+
return resolveExtensionIcon(item.icon);
|
|
96
|
+
});
|
|
97
|
+
IconLazy.displayName = 'lazy(ExtensionIcon)';
|
|
98
|
+
var IconLoadable = Loadable({
|
|
99
|
+
loader: loadIcon,
|
|
92
100
|
loading: noop
|
|
93
101
|
});
|
|
102
|
+
var Icon = function Icon(props) {
|
|
103
|
+
return isExperimentEnabled('platform_editor_loosely_lazy_migration') ? /*#__PURE__*/React.createElement(LazySuspense, {
|
|
104
|
+
fallback: null
|
|
105
|
+
}, /*#__PURE__*/React.createElement(IconLazy, props)) :
|
|
106
|
+
/*#__PURE__*/
|
|
107
|
+
// eslint-disable-next-line react/jsx-props-no-spreading -- pass icon props to the legacy component
|
|
108
|
+
React.createElement(IconLoadable, props);
|
|
109
|
+
};
|
|
110
|
+
Icon.preload = function () {
|
|
111
|
+
return isExperimentEnabled('platform_editor_loosely_lazy_migration') ? IconLazy.preload() : IconLoadable.preload();
|
|
112
|
+
};
|
|
113
|
+
iconRef.current = Icon;
|
|
94
114
|
}
|
|
95
115
|
var dropdownItem = convertExtensionToDropdownMenuItem({
|
|
96
116
|
item: item,
|