@atlaskit/editor-plugin-card 7.3.1 → 7.4.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 +20 -0
- package/dist/cjs/nodeviews/blockCard.js +24 -6
- package/dist/cjs/nodeviews/embedCard.js +30 -8
- package/dist/cjs/nodeviews/inlineCard.js +1 -3
- package/dist/cjs/nodeviews/inlineCardWithAwareness.js +75 -42
- package/dist/cjs/ui/AwarenessWrapper/index.js +6 -8
- package/dist/cjs/ui/preview/PreviewInvoker.js +33 -0
- package/dist/es2019/nodeviews/blockCard.js +24 -6
- package/dist/es2019/nodeviews/embedCard.js +30 -8
- package/dist/es2019/nodeviews/inlineCard.js +1 -3
- package/dist/es2019/nodeviews/inlineCardWithAwareness.js +76 -42
- package/dist/es2019/ui/AwarenessWrapper/index.js +6 -8
- package/dist/es2019/ui/preview/PreviewInvoker.js +22 -0
- package/dist/esm/nodeviews/blockCard.js +24 -6
- package/dist/esm/nodeviews/embedCard.js +30 -8
- package/dist/esm/nodeviews/inlineCard.js +1 -3
- package/dist/esm/nodeviews/inlineCardWithAwareness.js +75 -42
- package/dist/esm/ui/AwarenessWrapper/index.js +6 -8
- package/dist/esm/ui/preview/PreviewInvoker.js +25 -0
- package/dist/types/nodeviews/blockCard.d.ts +1 -1
- package/dist/types/nodeviews/embedCard.d.ts +1 -1
- package/dist/types/ui/preview/PreviewInvoker.d.ts +12 -0
- package/dist/types-ts4.5/nodeviews/blockCard.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/embedCard.d.ts +1 -1
- package/dist/types-ts4.5/ui/preview/PreviewInvoker.d.ts +12 -0
- package/package.json +6 -6
|
@@ -8,7 +8,6 @@ import { UnsupportedInline, findOverflowScrollParent } from '@atlaskit/editor-co
|
|
|
8
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
9
|
import { Card as SmartCard } from '@atlaskit/smart-card';
|
|
10
10
|
import { CardSSR } from '@atlaskit/smart-card/ssr';
|
|
11
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
12
11
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
13
12
|
import { registerCard, removeCard } from '../pm-plugins/actions';
|
|
14
13
|
import { getAwarenessProps } from '../pm-plugins/utils';
|
|
@@ -107,8 +106,7 @@ export const InlineCard = /*#__PURE__*/memo(({
|
|
|
107
106
|
exposure: true
|
|
108
107
|
}) ? handleOnClick : propsOnClick;
|
|
109
108
|
const card = useMemo(() => {
|
|
110
|
-
|
|
111
|
-
if (isPageSSRed && url && !expValEquals('platform_editor_smart_card_otp', 'isEnabled', true)) {
|
|
109
|
+
if (isPageSSRed && url) {
|
|
112
110
|
return /*#__PURE__*/React.createElement(CardSSR, {
|
|
113
111
|
key: url,
|
|
114
112
|
url: url,
|
|
@@ -8,6 +8,7 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
|
8
8
|
import { registerRemoveOverlay } from '../pm-plugins/actions';
|
|
9
9
|
import { pluginKey } from '../pm-plugins/plugin-key';
|
|
10
10
|
import { AwarenessWrapper } from '../ui/AwarenessWrapper';
|
|
11
|
+
import { PreviewInvoker } from '../ui/preview/PreviewInvoker';
|
|
11
12
|
import { InlineCard } from './inlineCard';
|
|
12
13
|
const selector = states => {
|
|
13
14
|
var _states$editorViewMod, _states$selectionStat;
|
|
@@ -74,6 +75,7 @@ export const InlineCardWithAwareness = /*#__PURE__*/memo(({
|
|
|
74
75
|
selection
|
|
75
76
|
} = useSharedState(pluginInjectionApi);
|
|
76
77
|
const floatingToolbarNode = selection instanceof NodeSelection && selection.node;
|
|
78
|
+
// This is a prop to show Hover card, Hover card should be shown only in Live View and Classic Renderer (note when only Editor controls enabled we don't show in Live view)
|
|
77
79
|
const showHoverPreview = floatingToolbarNode !== node && fg('platform_editor_preview_panel_linking');
|
|
78
80
|
const innerCardWithOpenButtonOverlay = useMemo(() => {
|
|
79
81
|
var _pluginInjectionApi$a;
|
|
@@ -94,10 +96,9 @@ export const InlineCardWithAwareness = /*#__PURE__*/memo(({
|
|
|
94
96
|
cardContext: cardContext,
|
|
95
97
|
isHovered: isHovered,
|
|
96
98
|
isPageSSRed: isPageSSRed,
|
|
97
|
-
pluginInjectionApi: pluginInjectionApi
|
|
98
|
-
showHoverPreview: showHoverPreview
|
|
99
|
+
pluginInjectionApi: pluginInjectionApi
|
|
99
100
|
}));
|
|
100
|
-
}, [isResolvedViewRendered, node, editorAppearance, view, getPos, useAlternativePreloader, actionOptions, onResolve, onClick, cardContext, isHovered, isPageSSRed, pluginInjectionApi
|
|
101
|
+
}, [isResolvedViewRendered, node, editorAppearance, view, getPos, useAlternativePreloader, actionOptions, onResolve, onClick, cardContext, isHovered, isPageSSRed, pluginInjectionApi]);
|
|
101
102
|
const innerCardOriginal = useMemo(() => /*#__PURE__*/React.createElement(InlineCard, {
|
|
102
103
|
node: node,
|
|
103
104
|
view: view,
|
|
@@ -110,18 +111,19 @@ export const InlineCardWithAwareness = /*#__PURE__*/memo(({
|
|
|
110
111
|
isHovered: isHovered,
|
|
111
112
|
isPageSSRed: isPageSSRed,
|
|
112
113
|
pluginInjectionApi: pluginInjectionApi,
|
|
113
|
-
showHoverPreview:
|
|
114
|
-
}), [actionOptions, cardContext, getPos, isHovered, node, onClick, onResolve, useAlternativePreloader, view, isPageSSRed, pluginInjectionApi
|
|
114
|
+
showHoverPreview: false
|
|
115
|
+
}), [actionOptions, cardContext, getPos, isHovered, node, onClick, onResolve, useAlternativePreloader, view, isPageSSRed, pluginInjectionApi]);
|
|
115
116
|
const shouldShowOpenButtonOverlay = useMemo(() => {
|
|
116
117
|
const shouldShowOpenButtonOverlayInChomeless = editorAppearance === 'chromeless';
|
|
117
118
|
return (mode === 'edit' || editorAppearance === 'comment' || shouldShowOpenButtonOverlayInChomeless) && (editorExperiment('platform_editor_controls', 'variant1') || fg('platform_editor_preview_panel_linking'));
|
|
118
119
|
}, [mode, editorAppearance]);
|
|
119
120
|
let innerCard = shouldShowOpenButtonOverlay ? innerCardWithOpenButtonOverlay : innerCardOriginal;
|
|
120
|
-
if (fg('platform_editor_preview_panel_linking')) {
|
|
121
|
+
if (mode === 'view' && fg('platform_editor_preview_panel_linking')) {
|
|
121
122
|
var _cardContext$value, _cardContext$value$st;
|
|
122
|
-
const
|
|
123
|
+
const url = node.attrs.url;
|
|
124
|
+
const cardState = cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : (_cardContext$value$st = _cardContext$value.store) === null || _cardContext$value$st === void 0 ? void 0 : _cardContext$value$st.getState()[url];
|
|
123
125
|
if (cardState) {
|
|
124
|
-
var _cardContext$value2, _cardContext$value2$i, _cardContext$value3
|
|
126
|
+
var _cardContext$value2, _cardContext$value2$i, _cardContext$value3;
|
|
125
127
|
const ari = getObjectAri(cardState.details);
|
|
126
128
|
const name = getObjectName(cardState.details);
|
|
127
129
|
const iconUrl = getObjectIconUrl(cardState.details);
|
|
@@ -129,42 +131,74 @@ export const InlineCardWithAwareness = /*#__PURE__*/memo(({
|
|
|
129
131
|
ari
|
|
130
132
|
}));
|
|
131
133
|
const openPreviewPanel = cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$value3 = cardContext.value) === null || _cardContext$value3 === void 0 ? void 0 : _cardContext$value3.openPreviewPanel;
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
134
|
+
const isPreviewPanelAvailable = Boolean(openPreviewPanel && isPanelAvailable);
|
|
135
|
+
const innerCardWithPanelButtonOverlay = /*#__PURE__*/React.createElement(PreviewInvoker, {
|
|
136
|
+
url: url,
|
|
137
|
+
appearance: "inline"
|
|
138
|
+
}, ({
|
|
139
|
+
canPreview,
|
|
140
|
+
invokePreview
|
|
141
|
+
}) => {
|
|
142
|
+
const isPreviewModalAvailable = Boolean(canPreview && invokePreview);
|
|
143
|
+
// In view mode we show HoverLinkOverlay only with if preview mode or panel is available
|
|
144
|
+
// otherwise a use can click on smartlink itself to open the link in a new tab.
|
|
145
|
+
const isPreviewAvailable = isPreviewPanelAvailable || isPreviewModalAvailable;
|
|
146
|
+
if (isPreviewAvailable) {
|
|
147
|
+
var _pluginInjectionApi$a2;
|
|
148
|
+
return /*#__PURE__*/React.createElement(HoverLinkOverlay, {
|
|
149
|
+
isVisible: isResolvedViewRendered,
|
|
150
|
+
url: url,
|
|
151
|
+
compactPadding: editorAppearance === 'comment' || editorAppearance === 'chromeless',
|
|
152
|
+
editorAnalyticsApi: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions,
|
|
153
|
+
view: view,
|
|
154
|
+
showPanelButton: isPreviewAvailable,
|
|
155
|
+
showPanelButtonIcon: isPreviewAvailable && isPreviewPanelAvailable ? 'panel' : 'modal',
|
|
156
|
+
onClick: event => {
|
|
157
|
+
if (isPreviewPanelAvailable) {
|
|
158
|
+
event.preventDefault();
|
|
159
|
+
openPreviewPanel === null || openPreviewPanel === void 0 ? void 0 : openPreviewPanel({
|
|
160
|
+
url,
|
|
161
|
+
ari: ari || '',
|
|
162
|
+
name: name || '',
|
|
163
|
+
iconUrl
|
|
164
|
+
});
|
|
165
|
+
} else if (isPreviewModalAvailable) {
|
|
166
|
+
event.preventDefault();
|
|
167
|
+
invokePreview === null || invokePreview === void 0 ? void 0 : invokePreview();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}, /*#__PURE__*/React.createElement(InlineCard, {
|
|
171
|
+
node: node,
|
|
172
|
+
view: view,
|
|
173
|
+
getPos: getPos,
|
|
174
|
+
useAlternativePreloader: useAlternativePreloader,
|
|
175
|
+
actionOptions: actionOptions,
|
|
176
|
+
onResolve: onResolve,
|
|
177
|
+
onClick: onClick,
|
|
178
|
+
cardContext: cardContext,
|
|
179
|
+
isHovered: isHovered,
|
|
180
|
+
isPageSSRed: isPageSSRed,
|
|
181
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
182
|
+
showHoverPreview: mode === 'view' && showHoverPreview
|
|
183
|
+
}));
|
|
184
|
+
} else {
|
|
185
|
+
return /*#__PURE__*/React.createElement(InlineCard, {
|
|
186
|
+
node: node,
|
|
187
|
+
view: view,
|
|
188
|
+
getPos: getPos,
|
|
189
|
+
useAlternativePreloader: useAlternativePreloader,
|
|
190
|
+
actionOptions: actionOptions,
|
|
191
|
+
onResolve: onResolve,
|
|
192
|
+
onClick: onClick,
|
|
193
|
+
cardContext: cardContext,
|
|
194
|
+
isHovered: isHovered,
|
|
195
|
+
isPageSSRed: isPageSSRed,
|
|
196
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
197
|
+
showHoverPreview: mode === 'view' && showHoverPreview
|
|
142
198
|
});
|
|
143
199
|
}
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
isVisible: isResolvedViewRendered,
|
|
147
|
-
url: node.attrs.url,
|
|
148
|
-
compactPadding: editorAppearance === 'comment' || editorAppearance === 'chromeless',
|
|
149
|
-
editorAnalyticsApi: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions,
|
|
150
|
-
view: view,
|
|
151
|
-
showPanelButton: !!isPanelAvailable,
|
|
152
|
-
onClick: handleOpenGlancePanelClick
|
|
153
|
-
}, /*#__PURE__*/React.createElement(InlineCard, {
|
|
154
|
-
node: node,
|
|
155
|
-
view: view,
|
|
156
|
-
getPos: getPos,
|
|
157
|
-
useAlternativePreloader: useAlternativePreloader,
|
|
158
|
-
actionOptions: actionOptions,
|
|
159
|
-
onResolve: onResolve,
|
|
160
|
-
onClick: onClick,
|
|
161
|
-
cardContext: cardContext,
|
|
162
|
-
isHovered: isHovered,
|
|
163
|
-
isPageSSRed: isPageSSRed,
|
|
164
|
-
pluginInjectionApi: pluginInjectionApi,
|
|
165
|
-
showHoverPreview: showHoverPreview
|
|
166
|
-
}));
|
|
167
|
-
innerCard = isPanelAvailable && openPreviewPanel ? innerCardWithPanelButtonOverlay : innerCard;
|
|
200
|
+
});
|
|
201
|
+
innerCard = innerCardWithPanelButtonOverlay;
|
|
168
202
|
}
|
|
169
203
|
}
|
|
170
204
|
const getPosFunction = typeof getPos === 'function' ? getPos : undefined;
|
|
@@ -38,7 +38,7 @@ export const AwarenessWrapper = ({
|
|
|
38
38
|
url,
|
|
39
39
|
appearance
|
|
40
40
|
}) => {
|
|
41
|
-
var _cardContext$
|
|
41
|
+
var _cardContext$value2;
|
|
42
42
|
const [isHovered, setIsHovered] = useState(false);
|
|
43
43
|
const linkPosition = useMemo(() => {
|
|
44
44
|
if (!getPos || typeof getPos === 'boolean') {
|
|
@@ -75,10 +75,8 @@ export const AwarenessWrapper = ({
|
|
|
75
75
|
setIsHovered(isHovered);
|
|
76
76
|
setOverlayHoveredStyles(isHovered);
|
|
77
77
|
}, [setOverlayHoveredStyles]);
|
|
78
|
-
const isPreviewPanelAvailable = cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.isPreviewPanelAvailable;
|
|
79
|
-
const shouldShowGlancePanel = (isPreviewPanelAvailable || false) && fg('platform_editor_preview_panel_linking');
|
|
80
78
|
const cardWithOverlay = useMemo(() => {
|
|
81
|
-
if (shouldShowLinkOverlay && !
|
|
79
|
+
if (shouldShowLinkOverlay && !editorExperiment('platform_editor_controls', 'variant1') && !fg('platform_editor_preview_panel_linking')) {
|
|
82
80
|
return jsx(InlineCardOverlay, {
|
|
83
81
|
isSelected: isSelected,
|
|
84
82
|
isVisible: isResolvedViewRendered && (isInserted || isHovered || isSelected),
|
|
@@ -88,11 +86,11 @@ export const AwarenessWrapper = ({
|
|
|
88
86
|
}, children);
|
|
89
87
|
}
|
|
90
88
|
return children;
|
|
91
|
-
}, [shouldShowLinkOverlay, children, isSelected, isResolvedViewRendered, isInserted, isHovered, url, handleOverlayChange
|
|
89
|
+
}, [shouldShowLinkOverlay, children, isSelected, isResolvedViewRendered, isInserted, isHovered, url, handleOverlayChange]);
|
|
92
90
|
const isInline = appearance === 'inline';
|
|
93
91
|
const placeholderUniqId = linkPosition || 0;
|
|
94
92
|
return useMemo(() => {
|
|
95
|
-
var _cardContext$
|
|
93
|
+
var _cardContext$value;
|
|
96
94
|
return jsx("span", {
|
|
97
95
|
css: shouldShowLinkPulse && loaderWrapperStyles
|
|
98
96
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
@@ -103,7 +101,7 @@ export const AwarenessWrapper = ({
|
|
|
103
101
|
"data-ssr-placeholder-replace": `awareness-wrapper-${placeholderUniqId}`
|
|
104
102
|
}, jsx(AnalyticsContext, {
|
|
105
103
|
data: {
|
|
106
|
-
attributes: getResolvedAttributesFromStore(url, 'inline', cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$
|
|
104
|
+
attributes: getResolvedAttributesFromStore(url, 'inline', cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.store)
|
|
107
105
|
}
|
|
108
106
|
}, jsx(DiscoveryPulse, {
|
|
109
107
|
localStorageKey: LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK,
|
|
@@ -113,5 +111,5 @@ export const AwarenessWrapper = ({
|
|
|
113
111
|
testId: "link-discovery-pulse",
|
|
114
112
|
isInline: isInline
|
|
115
113
|
}, cardWithOverlay)));
|
|
116
|
-
}, [shouldShowLinkPulse, url, cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$
|
|
114
|
+
}, [shouldShowLinkPulse, url, cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$value2 = cardContext.value) === null || _cardContext$value2 === void 0 ? void 0 : _cardContext$value2.store, isResolvedViewRendered, cardWithOverlay, isInline, placeholderUniqId]);
|
|
117
115
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { useCallback, useMemo } from 'react';
|
|
2
|
+
import { useSmartLinkActions } from '@atlaskit/smart-card/hooks';
|
|
3
|
+
export const PreviewInvoker = ({
|
|
4
|
+
url,
|
|
5
|
+
appearance,
|
|
6
|
+
children
|
|
7
|
+
}) => {
|
|
8
|
+
const actions = useSmartLinkActions({
|
|
9
|
+
url,
|
|
10
|
+
appearance
|
|
11
|
+
});
|
|
12
|
+
const preview = useMemo(() => actions.find(action => action.id === 'preview-content'), [actions]);
|
|
13
|
+
const invokePreview = useCallback(() => {
|
|
14
|
+
try {
|
|
15
|
+
preview === null || preview === void 0 ? void 0 : preview.invoke();
|
|
16
|
+
} catch {}
|
|
17
|
+
}, [preview]);
|
|
18
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children({
|
|
19
|
+
canPreview: !!preview,
|
|
20
|
+
invokePreview
|
|
21
|
+
}));
|
|
22
|
+
};
|
|
@@ -15,6 +15,8 @@ import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
|
15
15
|
import { findOverflowScrollParent, UnsupportedBlock } from '@atlaskit/editor-common/ui';
|
|
16
16
|
import { browser, canRenderDatasource } from '@atlaskit/editor-common/utils';
|
|
17
17
|
import { Card as SmartCard } from '@atlaskit/smart-card';
|
|
18
|
+
import { CardSSR } from '@atlaskit/smart-card/ssr';
|
|
19
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
18
20
|
import { Datasource } from '../nodeviews/datasource';
|
|
19
21
|
import { registerCard, removeCard as _removeCard } from '../pm-plugins/actions';
|
|
20
22
|
import { isDatasourceNode } from '../pm-plugins/utils';
|
|
@@ -103,11 +105,23 @@ export var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
103
105
|
cardContext = _this$props2.cardContext,
|
|
104
106
|
actionOptions = _this$props2.actionOptions,
|
|
105
107
|
onClick = _this$props2.onClick,
|
|
106
|
-
CompetitorPrompt = _this$props2.CompetitorPrompt
|
|
108
|
+
CompetitorPrompt = _this$props2.CompetitorPrompt,
|
|
109
|
+
isPageSSRed = _this$props2.isPageSSRed;
|
|
107
110
|
var _node$attrs = node.attrs,
|
|
108
111
|
url = _node$attrs.url,
|
|
109
112
|
data = _node$attrs.data;
|
|
110
|
-
var cardInner = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(
|
|
113
|
+
var cardInner = isPageSSRed && expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CardSSR, {
|
|
114
|
+
key: url,
|
|
115
|
+
url: url !== null && url !== void 0 ? url : data.url,
|
|
116
|
+
container: this.scrollContainer,
|
|
117
|
+
appearance: "block",
|
|
118
|
+
onClick: onClick,
|
|
119
|
+
onResolve: this.onResolve,
|
|
120
|
+
onError: this.onError,
|
|
121
|
+
platform: 'web',
|
|
122
|
+
actionOptions: actionOptions,
|
|
123
|
+
CompetitorPrompt: CompetitorPrompt
|
|
124
|
+
}), this.gapCursorSpan()) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SmartCard, {
|
|
111
125
|
key: url,
|
|
112
126
|
url: url !== null && url !== void 0 ? url : data.url,
|
|
113
127
|
container: this.scrollContainer,
|
|
@@ -185,7 +199,8 @@ export var BlockCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
185
199
|
actionOptions = _this$reactComponentP3.actionOptions,
|
|
186
200
|
pluginInjectionApi = _this$reactComponentP3.pluginInjectionApi,
|
|
187
201
|
onClickCallback = _this$reactComponentP3.onClickCallback,
|
|
188
|
-
CompetitorPrompt = _this$reactComponentP3.CompetitorPrompt
|
|
202
|
+
CompetitorPrompt = _this$reactComponentP3.CompetitorPrompt,
|
|
203
|
+
isPageSSRed = _this$reactComponentP3.isPageSSRed;
|
|
189
204
|
return /*#__PURE__*/React.createElement(WrappedBlockCard, {
|
|
190
205
|
node: this.node,
|
|
191
206
|
view: this.view,
|
|
@@ -194,7 +209,8 @@ export var BlockCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
194
209
|
pluginInjectionApi: pluginInjectionApi,
|
|
195
210
|
onClickCallback: onClickCallback,
|
|
196
211
|
id: this.id,
|
|
197
|
-
CompetitorPrompt: CompetitorPrompt
|
|
212
|
+
CompetitorPrompt: CompetitorPrompt,
|
|
213
|
+
isPageSSRed: isPageSSRed
|
|
198
214
|
});
|
|
199
215
|
}
|
|
200
216
|
}, {
|
|
@@ -213,7 +229,8 @@ export var blockCardNodeView = function blockCardNodeView(_ref3) {
|
|
|
213
229
|
onClickCallback = _ref3.onClickCallback,
|
|
214
230
|
allowDatasource = _ref3.allowDatasource,
|
|
215
231
|
inlineCardViewProducer = _ref3.inlineCardViewProducer,
|
|
216
|
-
CompetitorPrompt = _ref3.CompetitorPrompt
|
|
232
|
+
CompetitorPrompt = _ref3.CompetitorPrompt,
|
|
233
|
+
isPageSSRed = _ref3.isPageSSRed;
|
|
217
234
|
return function (node, view, getPos, decorations) {
|
|
218
235
|
var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI,
|
|
219
236
|
eventDispatcher = pmPluginFactoryParams.eventDispatcher;
|
|
@@ -221,7 +238,8 @@ export var blockCardNodeView = function blockCardNodeView(_ref3) {
|
|
|
221
238
|
actionOptions: actionOptions,
|
|
222
239
|
pluginInjectionApi: pluginInjectionApi,
|
|
223
240
|
onClickCallback: onClickCallback,
|
|
224
|
-
CompetitorPrompt: CompetitorPrompt
|
|
241
|
+
CompetitorPrompt: CompetitorPrompt,
|
|
242
|
+
isPageSSRed: isPageSSRed
|
|
225
243
|
};
|
|
226
244
|
var isDatasource = isDatasourceNode(node);
|
|
227
245
|
if (isDatasource) {
|
|
@@ -23,6 +23,7 @@ import { floatingLayouts, isRichMediaInsideOfBlockNode } from '@atlaskit/editor-
|
|
|
23
23
|
import { akEditorFullPageNarrowBreakout, DEFAULT_EMBED_CARD_HEIGHT, DEFAULT_EMBED_CARD_WIDTH } from '@atlaskit/editor-shared-styles';
|
|
24
24
|
import { componentWithCondition } from '@atlaskit/platform-feature-flags-react';
|
|
25
25
|
import { EmbedResizeMessageListener, Card as SmartCard } from '@atlaskit/smart-card';
|
|
26
|
+
import { CardSSR } from '@atlaskit/smart-card/ssr';
|
|
26
27
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
27
28
|
import { registerCard, removeCard as _removeCard } from '../pm-plugins/actions';
|
|
28
29
|
import ResizableEmbedCard from '../ui/ResizableEmbedCard';
|
|
@@ -304,7 +305,8 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
304
305
|
pluginInjectionApi = _this$props.pluginInjectionApi,
|
|
305
306
|
actionOptions = _this$props.actionOptions,
|
|
306
307
|
onClick = _this$props.onClick,
|
|
307
|
-
CompetitorPrompt = _this$props.CompetitorPrompt
|
|
308
|
+
CompetitorPrompt = _this$props.CompetitorPrompt,
|
|
309
|
+
isPageSSRed = _this$props.isPageSSRed;
|
|
308
310
|
var _node$attrs = node.attrs,
|
|
309
311
|
url = _node$attrs.url,
|
|
310
312
|
pctWidth = _node$attrs.width,
|
|
@@ -331,7 +333,21 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
331
333
|
pctWidth: pctWidth,
|
|
332
334
|
fullWidthMode: fullWidthMode
|
|
333
335
|
};
|
|
334
|
-
var smartCard = /*#__PURE__*/React.createElement(
|
|
336
|
+
var smartCard = isPageSSRed && expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) ? /*#__PURE__*/React.createElement(CardSSR, {
|
|
337
|
+
key: url,
|
|
338
|
+
url: url,
|
|
339
|
+
appearance: "embed",
|
|
340
|
+
onClick: onClick,
|
|
341
|
+
onResolve: this.onResolve,
|
|
342
|
+
onError: this.onError,
|
|
343
|
+
frameStyle: "show",
|
|
344
|
+
inheritDimensions: true,
|
|
345
|
+
platform: 'web',
|
|
346
|
+
container: this.scrollContainer,
|
|
347
|
+
embedIframeRef: this.embedIframeRef,
|
|
348
|
+
actionOptions: actionOptions,
|
|
349
|
+
CompetitorPrompt: CompetitorPrompt
|
|
350
|
+
}) : /*#__PURE__*/React.createElement(SmartCard, {
|
|
335
351
|
key: url,
|
|
336
352
|
url: url,
|
|
337
353
|
appearance: "embed",
|
|
@@ -388,7 +404,8 @@ export var EmbedOrBlockCardComponent = function EmbedOrBlockCardComponent(props)
|
|
|
388
404
|
smartCard: props.smartCard,
|
|
389
405
|
hasPreview: props.hasPreview,
|
|
390
406
|
liveHeight: props.liveHeight,
|
|
391
|
-
initialAspectRatio: props.initialAspectRatio
|
|
407
|
+
initialAspectRatio: props.initialAspectRatio,
|
|
408
|
+
isPageSSRed: props.isPageSSRed
|
|
392
409
|
}) : /*#__PURE__*/React.createElement(EmbedCardComponent, {
|
|
393
410
|
id: props.id,
|
|
394
411
|
node: props.node,
|
|
@@ -406,7 +423,8 @@ export var EmbedOrBlockCardComponent = function EmbedOrBlockCardComponent(props)
|
|
|
406
423
|
smartCard: props.smartCard,
|
|
407
424
|
hasPreview: props.hasPreview,
|
|
408
425
|
liveHeight: props.liveHeight,
|
|
409
|
-
initialAspectRatio: props.initialAspectRatio
|
|
426
|
+
initialAspectRatio: props.initialAspectRatio,
|
|
427
|
+
isPageSSRed: props.isPageSSRed
|
|
410
428
|
});
|
|
411
429
|
};
|
|
412
430
|
var WrappedEmbedCardWithCondition = componentWithCondition(function () {
|
|
@@ -462,7 +480,8 @@ export var EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
462
480
|
dispatchAnalyticsEvent = _this$reactComponentP3.dispatchAnalyticsEvent,
|
|
463
481
|
pluginInjectionApi = _this$reactComponentP3.pluginInjectionApi,
|
|
464
482
|
onClickCallback = _this$reactComponentP3.onClickCallback,
|
|
465
|
-
CompetitorPrompt = _this$reactComponentP3.CompetitorPrompt
|
|
483
|
+
CompetitorPrompt = _this$reactComponentP3.CompetitorPrompt,
|
|
484
|
+
isPageSSRed = _this$reactComponentP3.isPageSSRed;
|
|
466
485
|
return /*#__PURE__*/React.createElement(WrappedEmbedCard, {
|
|
467
486
|
node: this.node,
|
|
468
487
|
view: this.view,
|
|
@@ -474,7 +493,8 @@ export var EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
474
493
|
pluginInjectionApi: pluginInjectionApi,
|
|
475
494
|
onClickCallback: onClickCallback,
|
|
476
495
|
id: this.id,
|
|
477
|
-
CompetitorPrompt: CompetitorPrompt
|
|
496
|
+
CompetitorPrompt: CompetitorPrompt,
|
|
497
|
+
isPageSSRed: isPageSSRed
|
|
478
498
|
});
|
|
479
499
|
}
|
|
480
500
|
}, {
|
|
@@ -493,7 +513,8 @@ export var embedCardNodeView = function embedCardNodeView(_ref4) {
|
|
|
493
513
|
pluginInjectionApi = _ref4.pluginInjectionApi,
|
|
494
514
|
actionOptions = _ref4.actionOptions,
|
|
495
515
|
onClickCallback = _ref4.onClickCallback,
|
|
496
|
-
CompetitorPrompt = _ref4.CompetitorPrompt
|
|
516
|
+
CompetitorPrompt = _ref4.CompetitorPrompt,
|
|
517
|
+
isPageSSRed = _ref4.isPageSSRed;
|
|
497
518
|
return function (node, view, getPos) {
|
|
498
519
|
var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI,
|
|
499
520
|
eventDispatcher = pmPluginFactoryParams.eventDispatcher,
|
|
@@ -506,7 +527,8 @@ export var embedCardNodeView = function embedCardNodeView(_ref4) {
|
|
|
506
527
|
pluginInjectionApi: pluginInjectionApi,
|
|
507
528
|
actionOptions: actionOptions,
|
|
508
529
|
onClickCallback: onClickCallback,
|
|
509
|
-
CompetitorPrompt: CompetitorPrompt
|
|
530
|
+
CompetitorPrompt: CompetitorPrompt,
|
|
531
|
+
isPageSSRed: isPageSSRed
|
|
510
532
|
};
|
|
511
533
|
return new EmbedCard(node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, undefined).init();
|
|
512
534
|
};
|
|
@@ -8,7 +8,6 @@ import { UnsupportedInline, findOverflowScrollParent } from '@atlaskit/editor-co
|
|
|
8
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
9
|
import { Card as SmartCard } from '@atlaskit/smart-card';
|
|
10
10
|
import { CardSSR } from '@atlaskit/smart-card/ssr';
|
|
11
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
12
11
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
13
12
|
import { registerCard, removeCard } from '../pm-plugins/actions';
|
|
14
13
|
import { getAwarenessProps } from '../pm-plugins/utils';
|
|
@@ -100,8 +99,7 @@ export var InlineCard = /*#__PURE__*/memo(function (_ref) {
|
|
|
100
99
|
exposure: true
|
|
101
100
|
}) ? handleOnClick : propsOnClick;
|
|
102
101
|
var card = useMemo(function () {
|
|
103
|
-
|
|
104
|
-
if (isPageSSRed && url && !expValEquals('platform_editor_smart_card_otp', 'isEnabled', true)) {
|
|
102
|
+
if (isPageSSRed && url) {
|
|
105
103
|
return /*#__PURE__*/React.createElement(CardSSR, {
|
|
106
104
|
key: url,
|
|
107
105
|
url: url,
|
|
@@ -9,6 +9,7 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
|
9
9
|
import { registerRemoveOverlay } from '../pm-plugins/actions';
|
|
10
10
|
import { pluginKey } from '../pm-plugins/plugin-key';
|
|
11
11
|
import { AwarenessWrapper } from '../ui/AwarenessWrapper';
|
|
12
|
+
import { PreviewInvoker } from '../ui/preview/PreviewInvoker';
|
|
12
13
|
import { InlineCard } from './inlineCard';
|
|
13
14
|
var selector = function selector(states) {
|
|
14
15
|
var _states$editorViewMod, _states$selectionStat;
|
|
@@ -85,6 +86,7 @@ export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
|
|
|
85
86
|
mode = _useSharedState.mode,
|
|
86
87
|
selection = _useSharedState.selection;
|
|
87
88
|
var floatingToolbarNode = selection instanceof NodeSelection && selection.node;
|
|
89
|
+
// This is a prop to show Hover card, Hover card should be shown only in Live View and Classic Renderer (note when only Editor controls enabled we don't show in Live view)
|
|
88
90
|
var showHoverPreview = floatingToolbarNode !== node && fg('platform_editor_preview_panel_linking');
|
|
89
91
|
var innerCardWithOpenButtonOverlay = useMemo(function () {
|
|
90
92
|
var _pluginInjectionApi$a;
|
|
@@ -105,10 +107,9 @@ export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
|
|
|
105
107
|
cardContext: cardContext,
|
|
106
108
|
isHovered: isHovered,
|
|
107
109
|
isPageSSRed: isPageSSRed,
|
|
108
|
-
pluginInjectionApi: pluginInjectionApi
|
|
109
|
-
showHoverPreview: showHoverPreview
|
|
110
|
+
pluginInjectionApi: pluginInjectionApi
|
|
110
111
|
}));
|
|
111
|
-
}, [isResolvedViewRendered, node, editorAppearance, view, getPos, useAlternativePreloader, actionOptions, onResolve, onClick, cardContext, isHovered, isPageSSRed, pluginInjectionApi
|
|
112
|
+
}, [isResolvedViewRendered, node, editorAppearance, view, getPos, useAlternativePreloader, actionOptions, onResolve, onClick, cardContext, isHovered, isPageSSRed, pluginInjectionApi]);
|
|
112
113
|
var innerCardOriginal = useMemo(function () {
|
|
113
114
|
return /*#__PURE__*/React.createElement(InlineCard, {
|
|
114
115
|
node: node,
|
|
@@ -122,19 +123,20 @@ export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
|
|
|
122
123
|
isHovered: isHovered,
|
|
123
124
|
isPageSSRed: isPageSSRed,
|
|
124
125
|
pluginInjectionApi: pluginInjectionApi,
|
|
125
|
-
showHoverPreview:
|
|
126
|
+
showHoverPreview: false
|
|
126
127
|
});
|
|
127
|
-
}, [actionOptions, cardContext, getPos, isHovered, node, onClick, onResolve, useAlternativePreloader, view, isPageSSRed, pluginInjectionApi
|
|
128
|
+
}, [actionOptions, cardContext, getPos, isHovered, node, onClick, onResolve, useAlternativePreloader, view, isPageSSRed, pluginInjectionApi]);
|
|
128
129
|
var shouldShowOpenButtonOverlay = useMemo(function () {
|
|
129
130
|
var shouldShowOpenButtonOverlayInChomeless = editorAppearance === 'chromeless';
|
|
130
131
|
return (mode === 'edit' || editorAppearance === 'comment' || shouldShowOpenButtonOverlayInChomeless) && (editorExperiment('platform_editor_controls', 'variant1') || fg('platform_editor_preview_panel_linking'));
|
|
131
132
|
}, [mode, editorAppearance]);
|
|
132
133
|
var innerCard = shouldShowOpenButtonOverlay ? innerCardWithOpenButtonOverlay : innerCardOriginal;
|
|
133
|
-
if (fg('platform_editor_preview_panel_linking')) {
|
|
134
|
+
if (mode === 'view' && fg('platform_editor_preview_panel_linking')) {
|
|
134
135
|
var _cardContext$value;
|
|
135
|
-
var
|
|
136
|
+
var url = node.attrs.url;
|
|
137
|
+
var cardState = cardContext === null || cardContext === void 0 || (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 || (_cardContext$value = _cardContext$value.store) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.getState()[url];
|
|
136
138
|
if (cardState) {
|
|
137
|
-
var _cardContext$value2, _cardContext$value2$i, _cardContext$value3
|
|
139
|
+
var _cardContext$value2, _cardContext$value2$i, _cardContext$value3;
|
|
138
140
|
var ari = getObjectAri(cardState.details);
|
|
139
141
|
var name = getObjectName(cardState.details);
|
|
140
142
|
var iconUrl = getObjectIconUrl(cardState.details);
|
|
@@ -142,42 +144,73 @@ export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
|
|
|
142
144
|
ari: ari
|
|
143
145
|
}));
|
|
144
146
|
var openPreviewPanel = cardContext === null || cardContext === void 0 || (_cardContext$value3 = cardContext.value) === null || _cardContext$value3 === void 0 ? void 0 : _cardContext$value3.openPreviewPanel;
|
|
145
|
-
var
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
147
|
+
var isPreviewPanelAvailable = Boolean(openPreviewPanel && isPanelAvailable);
|
|
148
|
+
var innerCardWithPanelButtonOverlay = /*#__PURE__*/React.createElement(PreviewInvoker, {
|
|
149
|
+
url: url,
|
|
150
|
+
appearance: "inline"
|
|
151
|
+
}, function (_ref2) {
|
|
152
|
+
var canPreview = _ref2.canPreview,
|
|
153
|
+
invokePreview = _ref2.invokePreview;
|
|
154
|
+
var isPreviewModalAvailable = Boolean(canPreview && invokePreview);
|
|
155
|
+
// In view mode we show HoverLinkOverlay only with if preview mode or panel is available
|
|
156
|
+
// otherwise a use can click on smartlink itself to open the link in a new tab.
|
|
157
|
+
var isPreviewAvailable = isPreviewPanelAvailable || isPreviewModalAvailable;
|
|
158
|
+
if (isPreviewAvailable) {
|
|
159
|
+
var _pluginInjectionApi$a2;
|
|
160
|
+
return /*#__PURE__*/React.createElement(HoverLinkOverlay, {
|
|
161
|
+
isVisible: isResolvedViewRendered,
|
|
162
|
+
url: url,
|
|
163
|
+
compactPadding: editorAppearance === 'comment' || editorAppearance === 'chromeless',
|
|
164
|
+
editorAnalyticsApi: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions,
|
|
165
|
+
view: view,
|
|
166
|
+
showPanelButton: isPreviewAvailable,
|
|
167
|
+
showPanelButtonIcon: isPreviewAvailable && isPreviewPanelAvailable ? 'panel' : 'modal',
|
|
168
|
+
onClick: function onClick(event) {
|
|
169
|
+
if (isPreviewPanelAvailable) {
|
|
170
|
+
event.preventDefault();
|
|
171
|
+
openPreviewPanel === null || openPreviewPanel === void 0 || openPreviewPanel({
|
|
172
|
+
url: url,
|
|
173
|
+
ari: ari || '',
|
|
174
|
+
name: name || '',
|
|
175
|
+
iconUrl: iconUrl
|
|
176
|
+
});
|
|
177
|
+
} else if (isPreviewModalAvailable) {
|
|
178
|
+
event.preventDefault();
|
|
179
|
+
invokePreview === null || invokePreview === void 0 || invokePreview();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}, /*#__PURE__*/React.createElement(InlineCard, {
|
|
183
|
+
node: node,
|
|
184
|
+
view: view,
|
|
185
|
+
getPos: getPos,
|
|
186
|
+
useAlternativePreloader: useAlternativePreloader,
|
|
187
|
+
actionOptions: actionOptions,
|
|
188
|
+
onResolve: onResolve,
|
|
189
|
+
onClick: onClick,
|
|
190
|
+
cardContext: cardContext,
|
|
191
|
+
isHovered: isHovered,
|
|
192
|
+
isPageSSRed: isPageSSRed,
|
|
193
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
194
|
+
showHoverPreview: mode === 'view' && showHoverPreview
|
|
195
|
+
}));
|
|
196
|
+
} else {
|
|
197
|
+
return /*#__PURE__*/React.createElement(InlineCard, {
|
|
198
|
+
node: node,
|
|
199
|
+
view: view,
|
|
200
|
+
getPos: getPos,
|
|
201
|
+
useAlternativePreloader: useAlternativePreloader,
|
|
202
|
+
actionOptions: actionOptions,
|
|
203
|
+
onResolve: onResolve,
|
|
204
|
+
onClick: onClick,
|
|
205
|
+
cardContext: cardContext,
|
|
206
|
+
isHovered: isHovered,
|
|
207
|
+
isPageSSRed: isPageSSRed,
|
|
208
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
209
|
+
showHoverPreview: mode === 'view' && showHoverPreview
|
|
155
210
|
});
|
|
156
211
|
}
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
isVisible: isResolvedViewRendered,
|
|
160
|
-
url: node.attrs.url,
|
|
161
|
-
compactPadding: editorAppearance === 'comment' || editorAppearance === 'chromeless',
|
|
162
|
-
editorAnalyticsApi: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions,
|
|
163
|
-
view: view,
|
|
164
|
-
showPanelButton: !!isPanelAvailable,
|
|
165
|
-
onClick: handleOpenGlancePanelClick
|
|
166
|
-
}, /*#__PURE__*/React.createElement(InlineCard, {
|
|
167
|
-
node: node,
|
|
168
|
-
view: view,
|
|
169
|
-
getPos: getPos,
|
|
170
|
-
useAlternativePreloader: useAlternativePreloader,
|
|
171
|
-
actionOptions: actionOptions,
|
|
172
|
-
onResolve: onResolve,
|
|
173
|
-
onClick: onClick,
|
|
174
|
-
cardContext: cardContext,
|
|
175
|
-
isHovered: isHovered,
|
|
176
|
-
isPageSSRed: isPageSSRed,
|
|
177
|
-
pluginInjectionApi: pluginInjectionApi,
|
|
178
|
-
showHoverPreview: showHoverPreview
|
|
179
|
-
}));
|
|
180
|
-
innerCard = isPanelAvailable && openPreviewPanel ? innerCardWithPanelButtonOverlay : innerCard;
|
|
212
|
+
});
|
|
213
|
+
innerCard = innerCardWithPanelButtonOverlay;
|
|
181
214
|
}
|
|
182
215
|
}
|
|
183
216
|
var getPosFunction = typeof getPos === 'function' ? getPos : undefined;
|