@atlaskit/editor-plugin-card 18.1.5 → 18.1.6
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 +6 -0
- package/dist/cjs/nodeviews/inlineCard.js +4 -151
- package/dist/cjs/nodeviews/inlineCardBase.js +159 -0
- package/dist/cjs/nodeviews/inlineCardWithAwareness.js +5 -5
- package/dist/es2019/nodeviews/inlineCard.js +2 -155
- package/dist/es2019/nodeviews/inlineCardBase.js +157 -0
- package/dist/es2019/nodeviews/inlineCardWithAwareness.js +1 -1
- package/dist/esm/nodeviews/inlineCard.js +6 -151
- package/dist/esm/nodeviews/inlineCardBase.js +149 -0
- package/dist/esm/nodeviews/inlineCardWithAwareness.js +1 -1
- package/dist/types/nodeviews/inlineCard.d.ts +0 -1
- package/dist/types/nodeviews/inlineCardBase.d.ts +3 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,168 +5,21 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.InlineCard = void 0;
|
|
9
8
|
exports.InlineCardNodeView = InlineCardNodeView;
|
|
10
9
|
exports.inlineCardNodeView = void 0;
|
|
11
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
-
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
14
|
-
var _v = _interopRequireDefault(require("uuid/v4"));
|
|
15
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
16
12
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
17
13
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
18
14
|
var _editorSmartLinkDraggable = require("@atlaskit/editor-smart-link-draggable");
|
|
19
15
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
20
|
-
var _smartCard = require("@atlaskit/smart-card");
|
|
21
|
-
var _ssr = require("@atlaskit/smart-card/ssr");
|
|
22
16
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
23
|
-
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
24
17
|
var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
|
|
25
|
-
var _actions = require("../pm-plugins/actions");
|
|
26
18
|
var _utils = require("../pm-plugins/utils");
|
|
27
19
|
var _SmartCardSSRReactContextsProvider = require("../ui/SmartCardSSRReactContextsProvider");
|
|
28
|
-
var _toolbar = require("../ui/toolbar");
|
|
29
20
|
var _genericCard = require("./genericCard");
|
|
30
21
|
var _inlineCardWithAwareness = require("./inlineCardWithAwareness");
|
|
31
22
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
32
|
-
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
33
|
-
|
|
34
|
-
var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
35
|
-
var _cardContext$value;
|
|
36
|
-
var node = _ref.node,
|
|
37
|
-
cardContext = _ref.cardContext,
|
|
38
|
-
actionOptions = _ref.actionOptions,
|
|
39
|
-
useAlternativePreloader = _ref.useAlternativePreloader,
|
|
40
|
-
view = _ref.view,
|
|
41
|
-
getPos = _ref.getPos,
|
|
42
|
-
propsOnClick = _ref.onClick,
|
|
43
|
-
onRes = _ref.onResolve,
|
|
44
|
-
isHovered = _ref.isHovered,
|
|
45
|
-
showHoverPreview = _ref.showHoverPreview,
|
|
46
|
-
hoverPreviewOptions = _ref.hoverPreviewOptions,
|
|
47
|
-
isPageSSRed = _ref.isPageSSRed,
|
|
48
|
-
pluginInjectionApi = _ref.pluginInjectionApi,
|
|
49
|
-
disablePreviewPanel = _ref.disablePreviewPanel;
|
|
50
|
-
var _node$attrs = node.attrs,
|
|
51
|
-
url = _node$attrs.url,
|
|
52
|
-
data = _node$attrs.data;
|
|
53
|
-
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
54
|
-
var refId = (0, _react.useRef)((0, _v.default)());
|
|
55
|
-
var removeCardDispatched = (0, _react.useRef)(false);
|
|
56
|
-
var _ref2 = (cardContext === null || cardContext === void 0 || (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.store) || {},
|
|
57
|
-
getSmartlinkState = _ref2.getState;
|
|
58
|
-
var cardState = getSmartlinkState === null || getSmartlinkState === void 0 ? void 0 : getSmartlinkState()[url || ''];
|
|
59
|
-
(0, _react.useEffect)(function () {
|
|
60
|
-
var id = refId.current;
|
|
61
|
-
removeCardDispatched.current = false;
|
|
62
|
-
return function () {
|
|
63
|
-
if ((0, _expValEquals.expValEquals)('platform_editor_inline_card_dispatch_guard', 'isEnabled', true) && removeCardDispatched.current) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
removeCardDispatched.current = true;
|
|
67
|
-
var tr = view.state.tr;
|
|
68
|
-
(0, _actions.removeCard)({
|
|
69
|
-
id: id
|
|
70
|
-
})(tr);
|
|
71
|
-
view.dispatch(tr);
|
|
72
|
-
};
|
|
73
|
-
}, [getPos, view]);
|
|
74
|
-
var scrollContainer = (0, _react.useMemo)(
|
|
75
|
-
// Ignored via go/ees005
|
|
76
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
77
|
-
function () {
|
|
78
|
-
return (0, _ui.findOverflowScrollParent)(view.dom) || undefined;
|
|
79
|
-
}, [view.dom]);
|
|
80
|
-
var onResolve = (0, _react.useCallback)(function (data) {
|
|
81
|
-
if (!getPos || typeof getPos === 'boolean') {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
var title = data.title,
|
|
85
|
-
url = data.url;
|
|
86
|
-
// don't dispatch immediately since we might be in the middle of
|
|
87
|
-
// rendering a nodeview
|
|
88
|
-
(0, _rafSchd.default)(function () {
|
|
89
|
-
// prosemirror-bump-fix
|
|
90
|
-
var pos = getPos();
|
|
91
|
-
if (typeof pos !== 'number') {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
var tr = view.state.tr;
|
|
95
|
-
(0, _actions.registerCard)({
|
|
96
|
-
title: title,
|
|
97
|
-
url: url,
|
|
98
|
-
pos: pos,
|
|
99
|
-
id: refId.current
|
|
100
|
-
})(tr);
|
|
101
|
-
onRes === null || onRes === void 0 || onRes(tr, title);
|
|
102
|
-
view.dispatch(tr);
|
|
103
|
-
})();
|
|
104
|
-
}, [getPos, view, onRes]);
|
|
105
|
-
var onError = (0, _react.useCallback)(function (data) {
|
|
106
|
-
var url = data.url,
|
|
107
|
-
err = data.err;
|
|
108
|
-
if (err) {
|
|
109
|
-
throw err;
|
|
110
|
-
}
|
|
111
|
-
onResolve({
|
|
112
|
-
url: url
|
|
113
|
-
});
|
|
114
|
-
}, [onResolve]);
|
|
115
|
-
var handleOnClick = (0, _react.useCallback)(function (event, data) {
|
|
116
|
-
if (event.metaKey || event.ctrlKey) {
|
|
117
|
-
var _pluginInjectionApi$a, _data$destinationUrl;
|
|
118
|
-
var _ref3 = (_pluginInjectionApi$a = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.analytics) !== null && _pluginInjectionApi$a !== void 0 ? _pluginInjectionApi$a : {},
|
|
119
|
-
editorAnalyticsApi = _ref3.actions;
|
|
120
|
-
(0, _toolbar.visitCardLinkAnalytics)(editorAnalyticsApi, _analytics.INPUT_METHOD.META_CLICK)(view.state, view.dispatch);
|
|
121
|
-
window.open((0, _platformFeatureFlags.fg)('platform_smartlink_xpc_url_wrapping') ? (_data$destinationUrl = data === null || data === void 0 ? void 0 : data.destinationUrl) !== null && _data$destinationUrl !== void 0 ? _data$destinationUrl : url : url, '_blank');
|
|
122
|
-
} else {
|
|
123
|
-
// only trigger the provided onClick callback if the meta key or ctrl key is not pressed
|
|
124
|
-
propsOnClick === null || propsOnClick === void 0 || propsOnClick(event);
|
|
125
|
-
}
|
|
126
|
-
}, [propsOnClick, url, view, pluginInjectionApi]);
|
|
127
|
-
var onClick = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? handleOnClick : propsOnClick;
|
|
128
|
-
var card = (0, _react.useMemo)(function () {
|
|
129
|
-
if ((isPageSSRed || cardState && (0, _expValEquals.expValEquals)('platform_editor_smartlink_local_cache', 'isEnabled', true)) && url) {
|
|
130
|
-
return /*#__PURE__*/_react.default.createElement(_ssr.CardSSR, {
|
|
131
|
-
key: url,
|
|
132
|
-
url: url,
|
|
133
|
-
appearance: "inline",
|
|
134
|
-
onClick: onClick,
|
|
135
|
-
container: scrollContainer,
|
|
136
|
-
onResolve: onResolve,
|
|
137
|
-
onError: onError,
|
|
138
|
-
inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
|
|
139
|
-
actionOptions: actionOptions,
|
|
140
|
-
isHovered: isHovered,
|
|
141
|
-
showHoverPreview: showHoverPreview,
|
|
142
|
-
hoverPreviewOptions: hoverPreviewOptions,
|
|
143
|
-
disablePreviewPanel: disablePreviewPanel,
|
|
144
|
-
hideIconLoadingSkeleton: true
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
return /*#__PURE__*/_react.default.createElement(_smartCard.Card, {
|
|
148
|
-
key: url,
|
|
149
|
-
url: url !== null && url !== void 0 ? url : data.url,
|
|
150
|
-
appearance: "inline",
|
|
151
|
-
onClick: onClick,
|
|
152
|
-
container: scrollContainer,
|
|
153
|
-
onResolve: onResolve,
|
|
154
|
-
onError: onError,
|
|
155
|
-
inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
|
|
156
|
-
actionOptions: actionOptions,
|
|
157
|
-
isHovered: isHovered,
|
|
158
|
-
showHoverPreview: showHoverPreview,
|
|
159
|
-
hoverPreviewOptions: hoverPreviewOptions,
|
|
160
|
-
disablePreviewPanel: disablePreviewPanel
|
|
161
|
-
});
|
|
162
|
-
}, [url, data, onClick, scrollContainer, onResolve, onError, useAlternativePreloader, actionOptions, isHovered, showHoverPreview, hoverPreviewOptions, isPageSSRed, disablePreviewPanel, cardState]);
|
|
163
|
-
|
|
164
|
-
// [WS-2307]: we only render card wrapped into a Provider when the value is ready,
|
|
165
|
-
// otherwise if we got data, we can render the card directly since it doesn't need the Provider
|
|
166
|
-
return cardContext && cardContext.value ? /*#__PURE__*/_react.default.createElement(cardContext.Provider, {
|
|
167
|
-
value: cardContext.value
|
|
168
|
-
}, card) : data ? card : null;
|
|
169
|
-
});
|
|
170
23
|
var WrappedInlineCardWithAwareness = (0, _genericCard.Card)(_inlineCardWithAwareness.InlineCardWithAwareness, _ui.UnsupportedInline);
|
|
171
24
|
var selectorWithCard = function selectorWithCard(states) {
|
|
172
25
|
var _states$editorViewMod, _states$cardState;
|
|
@@ -218,8 +71,8 @@ function InlineCardNodeView(props) {
|
|
|
218
71
|
if ((0, _expValEquals.expValEquals)('platform_editor_smartlink_local_cache', 'isEnabled', true)) {
|
|
219
72
|
// Refresh cache in the background
|
|
220
73
|
provider === null || provider === void 0 || provider.then(function (providerInstance) {
|
|
221
|
-
var _refreshCache,
|
|
222
|
-
(_refreshCache = (
|
|
74
|
+
var _refreshCache, _ref;
|
|
75
|
+
(_refreshCache = (_ref = providerInstance).refreshCache) === null || _refreshCache === void 0 || _refreshCache.call(_ref, props.node);
|
|
223
76
|
});
|
|
224
77
|
}
|
|
225
78
|
}, [provider, props.node]);
|
|
@@ -255,8 +108,8 @@ function InlineCardNodeView(props) {
|
|
|
255
108
|
isChangeboardTarget: isChangeboardTarget
|
|
256
109
|
}, inlineCardContent));
|
|
257
110
|
}
|
|
258
|
-
var inlineCardNodeView = exports.inlineCardNodeView = function inlineCardNodeView(
|
|
259
|
-
var inlineCardViewProducer =
|
|
111
|
+
var inlineCardNodeView = exports.inlineCardNodeView = function inlineCardNodeView(_ref2) {
|
|
112
|
+
var inlineCardViewProducer = _ref2.inlineCardViewProducer;
|
|
260
113
|
return function (node, view, getPos, decorations) {
|
|
261
114
|
return inlineCardViewProducer(node, view, getPos, decorations);
|
|
262
115
|
};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.InlineCard = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
11
|
+
var _v = _interopRequireDefault(require("uuid/v4"));
|
|
12
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
|
+
var _ui = require("@atlaskit/editor-common/ui");
|
|
14
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
|
+
var _smartCard = require("@atlaskit/smart-card");
|
|
16
|
+
var _ssr = require("@atlaskit/smart-card/ssr");
|
|
17
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
18
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
19
|
+
var _actions = require("../pm-plugins/actions");
|
|
20
|
+
var _toolbar = require("../ui/toolbar");
|
|
21
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
22
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
23
|
+
|
|
24
|
+
var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
25
|
+
var _cardContext$value;
|
|
26
|
+
var node = _ref.node,
|
|
27
|
+
cardContext = _ref.cardContext,
|
|
28
|
+
actionOptions = _ref.actionOptions,
|
|
29
|
+
useAlternativePreloader = _ref.useAlternativePreloader,
|
|
30
|
+
view = _ref.view,
|
|
31
|
+
getPos = _ref.getPos,
|
|
32
|
+
propsOnClick = _ref.onClick,
|
|
33
|
+
onRes = _ref.onResolve,
|
|
34
|
+
isHovered = _ref.isHovered,
|
|
35
|
+
showHoverPreview = _ref.showHoverPreview,
|
|
36
|
+
hoverPreviewOptions = _ref.hoverPreviewOptions,
|
|
37
|
+
isPageSSRed = _ref.isPageSSRed,
|
|
38
|
+
pluginInjectionApi = _ref.pluginInjectionApi,
|
|
39
|
+
disablePreviewPanel = _ref.disablePreviewPanel;
|
|
40
|
+
var _node$attrs = node.attrs,
|
|
41
|
+
url = _node$attrs.url,
|
|
42
|
+
data = _node$attrs.data;
|
|
43
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
44
|
+
var refId = (0, _react.useRef)((0, _v.default)());
|
|
45
|
+
var removeCardDispatched = (0, _react.useRef)(false);
|
|
46
|
+
var _ref2 = (cardContext === null || cardContext === void 0 || (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.store) || {},
|
|
47
|
+
getSmartlinkState = _ref2.getState;
|
|
48
|
+
var cardState = getSmartlinkState === null || getSmartlinkState === void 0 ? void 0 : getSmartlinkState()[url || ''];
|
|
49
|
+
(0, _react.useEffect)(function () {
|
|
50
|
+
var id = refId.current;
|
|
51
|
+
removeCardDispatched.current = false;
|
|
52
|
+
return function () {
|
|
53
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_inline_card_dispatch_guard', 'isEnabled', true) && removeCardDispatched.current) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
removeCardDispatched.current = true;
|
|
57
|
+
var tr = view.state.tr;
|
|
58
|
+
(0, _actions.removeCard)({
|
|
59
|
+
id: id
|
|
60
|
+
})(tr);
|
|
61
|
+
view.dispatch(tr);
|
|
62
|
+
};
|
|
63
|
+
}, [getPos, view]);
|
|
64
|
+
var scrollContainer = (0, _react.useMemo)(
|
|
65
|
+
// Ignored via go/ees005
|
|
66
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
67
|
+
function () {
|
|
68
|
+
return (0, _ui.findOverflowScrollParent)(view.dom) || undefined;
|
|
69
|
+
}, [view.dom]);
|
|
70
|
+
var onResolve = (0, _react.useCallback)(function (data) {
|
|
71
|
+
if (!getPos || typeof getPos === 'boolean') {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
var title = data.title,
|
|
75
|
+
url = data.url;
|
|
76
|
+
// don't dispatch immediately since we might be in the middle of
|
|
77
|
+
// rendering a nodeview
|
|
78
|
+
(0, _rafSchd.default)(function () {
|
|
79
|
+
// prosemirror-bump-fix
|
|
80
|
+
var pos = getPos();
|
|
81
|
+
if (typeof pos !== 'number') {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
var tr = view.state.tr;
|
|
85
|
+
(0, _actions.registerCard)({
|
|
86
|
+
title: title,
|
|
87
|
+
url: url,
|
|
88
|
+
pos: pos,
|
|
89
|
+
id: refId.current
|
|
90
|
+
})(tr);
|
|
91
|
+
onRes === null || onRes === void 0 || onRes(tr, title);
|
|
92
|
+
view.dispatch(tr);
|
|
93
|
+
})();
|
|
94
|
+
}, [getPos, view, onRes]);
|
|
95
|
+
var onError = (0, _react.useCallback)(function (data) {
|
|
96
|
+
var url = data.url,
|
|
97
|
+
err = data.err;
|
|
98
|
+
if (err) {
|
|
99
|
+
throw err;
|
|
100
|
+
}
|
|
101
|
+
onResolve({
|
|
102
|
+
url: url
|
|
103
|
+
});
|
|
104
|
+
}, [onResolve]);
|
|
105
|
+
var handleOnClick = (0, _react.useCallback)(function (event, data) {
|
|
106
|
+
if (event.metaKey || event.ctrlKey) {
|
|
107
|
+
var _pluginInjectionApi$a, _data$destinationUrl;
|
|
108
|
+
var _ref3 = (_pluginInjectionApi$a = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.analytics) !== null && _pluginInjectionApi$a !== void 0 ? _pluginInjectionApi$a : {},
|
|
109
|
+
editorAnalyticsApi = _ref3.actions;
|
|
110
|
+
(0, _toolbar.visitCardLinkAnalytics)(editorAnalyticsApi, _analytics.INPUT_METHOD.META_CLICK)(view.state, view.dispatch);
|
|
111
|
+
window.open((0, _platformFeatureFlags.fg)('platform_smartlink_xpc_url_wrapping') ? (_data$destinationUrl = data === null || data === void 0 ? void 0 : data.destinationUrl) !== null && _data$destinationUrl !== void 0 ? _data$destinationUrl : url : url, '_blank');
|
|
112
|
+
} else {
|
|
113
|
+
// only trigger the provided onClick callback if the meta key or ctrl key is not pressed
|
|
114
|
+
propsOnClick === null || propsOnClick === void 0 || propsOnClick(event);
|
|
115
|
+
}
|
|
116
|
+
}, [propsOnClick, url, view, pluginInjectionApi]);
|
|
117
|
+
var onClick = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? handleOnClick : propsOnClick;
|
|
118
|
+
var card = (0, _react.useMemo)(function () {
|
|
119
|
+
if ((isPageSSRed || cardState && (0, _expValEquals.expValEquals)('platform_editor_smartlink_local_cache', 'isEnabled', true)) && url) {
|
|
120
|
+
return /*#__PURE__*/_react.default.createElement(_ssr.CardSSR, {
|
|
121
|
+
key: url,
|
|
122
|
+
url: url,
|
|
123
|
+
appearance: "inline",
|
|
124
|
+
onClick: onClick,
|
|
125
|
+
container: scrollContainer,
|
|
126
|
+
onResolve: onResolve,
|
|
127
|
+
onError: onError,
|
|
128
|
+
inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
|
|
129
|
+
actionOptions: actionOptions,
|
|
130
|
+
isHovered: isHovered,
|
|
131
|
+
showHoverPreview: showHoverPreview,
|
|
132
|
+
hoverPreviewOptions: hoverPreviewOptions,
|
|
133
|
+
disablePreviewPanel: disablePreviewPanel,
|
|
134
|
+
hideIconLoadingSkeleton: true
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return /*#__PURE__*/_react.default.createElement(_smartCard.Card, {
|
|
138
|
+
key: url,
|
|
139
|
+
url: url !== null && url !== void 0 ? url : data.url,
|
|
140
|
+
appearance: "inline",
|
|
141
|
+
onClick: onClick,
|
|
142
|
+
container: scrollContainer,
|
|
143
|
+
onResolve: onResolve,
|
|
144
|
+
onError: onError,
|
|
145
|
+
inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
|
|
146
|
+
actionOptions: actionOptions,
|
|
147
|
+
isHovered: isHovered,
|
|
148
|
+
showHoverPreview: showHoverPreview,
|
|
149
|
+
hoverPreviewOptions: hoverPreviewOptions,
|
|
150
|
+
disablePreviewPanel: disablePreviewPanel
|
|
151
|
+
});
|
|
152
|
+
}, [url, data, onClick, scrollContainer, onResolve, onError, useAlternativePreloader, actionOptions, isHovered, showHoverPreview, hoverPreviewOptions, isPageSSRed, disablePreviewPanel, cardState]);
|
|
153
|
+
|
|
154
|
+
// [WS-2307]: we only render card wrapped into a Provider when the value is ready,
|
|
155
|
+
// otherwise if we got data, we can render the card directly since it doesn't need the Provider
|
|
156
|
+
return cardContext && cardContext.value ? /*#__PURE__*/_react.default.createElement(cardContext.Provider, {
|
|
157
|
+
value: cardContext.value
|
|
158
|
+
}, card) : data ? card : null;
|
|
159
|
+
});
|
|
@@ -22,7 +22,7 @@ var _actions = require("../pm-plugins/actions");
|
|
|
22
22
|
var _pluginKey = require("../pm-plugins/plugin-key");
|
|
23
23
|
var _AwarenessWrapper = require("../ui/AwarenessWrapper");
|
|
24
24
|
var _PreviewInvoker = require("../ui/preview/PreviewInvoker");
|
|
25
|
-
var
|
|
25
|
+
var _inlineCardBase = require("./inlineCardBase");
|
|
26
26
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
27
27
|
var selector = function selector(states) {
|
|
28
28
|
var _states$editorViewMod, _states$selectionStat;
|
|
@@ -103,7 +103,7 @@ var InlineCardWithAwareness = exports.InlineCardWithAwareness = /*#__PURE__*/(0,
|
|
|
103
103
|
compactPadding: editorAppearance === 'comment' || editorAppearance === 'chromeless',
|
|
104
104
|
editorAnalyticsApi: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions,
|
|
105
105
|
view: view
|
|
106
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
106
|
+
}, /*#__PURE__*/_react.default.createElement(_inlineCardBase.InlineCard, {
|
|
107
107
|
node: node,
|
|
108
108
|
view: view,
|
|
109
109
|
getPos: getPos,
|
|
@@ -120,7 +120,7 @@ var InlineCardWithAwareness = exports.InlineCardWithAwareness = /*#__PURE__*/(0,
|
|
|
120
120
|
}));
|
|
121
121
|
}, [isResolvedViewRendered, node, editorAppearance, view, getPos, useAlternativePreloader, actionOptions, onResolve, onClick, cardContext, isHovered, isPageSSRed, provider, pluginInjectionApi, destinationUrl]);
|
|
122
122
|
var innerCardOriginal = (0, _react.useMemo)(function () {
|
|
123
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
123
|
+
return /*#__PURE__*/_react.default.createElement(_inlineCardBase.InlineCard, {
|
|
124
124
|
node: node,
|
|
125
125
|
view: view,
|
|
126
126
|
getPos: getPos,
|
|
@@ -229,7 +229,7 @@ var InlineCardWithAwareness = exports.InlineCardWithAwareness = /*#__PURE__*/(0,
|
|
|
229
229
|
});
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
232
|
+
}, /*#__PURE__*/_react.default.createElement(_inlineCardBase.InlineCard, {
|
|
233
233
|
node: node,
|
|
234
234
|
view: view,
|
|
235
235
|
getPos: getPos,
|
|
@@ -246,7 +246,7 @@ var InlineCardWithAwareness = exports.InlineCardWithAwareness = /*#__PURE__*/(0,
|
|
|
246
246
|
disablePreviewPanel: true
|
|
247
247
|
}));
|
|
248
248
|
} else {
|
|
249
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
249
|
+
return /*#__PURE__*/_react.default.createElement(_inlineCardBase.InlineCard, {
|
|
250
250
|
node: node,
|
|
251
251
|
view: view,
|
|
252
252
|
getPos: getPos,
|
|
@@ -1,168 +1,15 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React, {
|
|
3
|
-
import rafSchedule from 'raf-schd';
|
|
4
|
-
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
5
|
-
import uuid from 'uuid/v4';
|
|
6
|
-
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import React, { useEffect, useMemo } from 'react';
|
|
7
3
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
8
|
-
import { UnsupportedInline
|
|
4
|
+
import { UnsupportedInline } from '@atlaskit/editor-common/ui';
|
|
9
5
|
import { SmartLinkDraggable, SMART_LINK_DRAG_TYPES, SMART_LINK_APPEARANCE } from '@atlaskit/editor-smart-link-draggable';
|
|
10
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
|
-
import { Card as SmartCard } from '@atlaskit/smart-card';
|
|
12
|
-
import { CardSSR } from '@atlaskit/smart-card/ssr';
|
|
13
7
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
14
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
15
8
|
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
16
|
-
import { registerCard, removeCard } from '../pm-plugins/actions';
|
|
17
9
|
import { getAwarenessProps } from '../pm-plugins/utils';
|
|
18
10
|
import { SmartCardSSRReactContextsProvider } from '../ui/SmartCardSSRReactContextsProvider';
|
|
19
|
-
import { visitCardLinkAnalytics } from '../ui/toolbar';
|
|
20
11
|
import { Card } from './genericCard';
|
|
21
12
|
import { InlineCardWithAwareness } from './inlineCardWithAwareness';
|
|
22
|
-
export const InlineCard = /*#__PURE__*/memo(({
|
|
23
|
-
node,
|
|
24
|
-
cardContext,
|
|
25
|
-
actionOptions,
|
|
26
|
-
useAlternativePreloader,
|
|
27
|
-
view,
|
|
28
|
-
getPos,
|
|
29
|
-
onClick: propsOnClick,
|
|
30
|
-
onResolve: onRes,
|
|
31
|
-
isHovered,
|
|
32
|
-
showHoverPreview,
|
|
33
|
-
hoverPreviewOptions,
|
|
34
|
-
isPageSSRed,
|
|
35
|
-
pluginInjectionApi,
|
|
36
|
-
disablePreviewPanel
|
|
37
|
-
}) => {
|
|
38
|
-
var _cardContext$value;
|
|
39
|
-
const {
|
|
40
|
-
url,
|
|
41
|
-
data
|
|
42
|
-
} = node.attrs;
|
|
43
|
-
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
44
|
-
const refId = useRef(uuid());
|
|
45
|
-
const removeCardDispatched = useRef(false);
|
|
46
|
-
const {
|
|
47
|
-
getState: getSmartlinkState
|
|
48
|
-
} = (cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.store) || {};
|
|
49
|
-
const cardState = getSmartlinkState === null || getSmartlinkState === void 0 ? void 0 : getSmartlinkState()[url || ''];
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
const id = refId.current;
|
|
52
|
-
removeCardDispatched.current = false;
|
|
53
|
-
return () => {
|
|
54
|
-
if (expValEquals('platform_editor_inline_card_dispatch_guard', 'isEnabled', true) && removeCardDispatched.current) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
removeCardDispatched.current = true;
|
|
58
|
-
const {
|
|
59
|
-
tr
|
|
60
|
-
} = view.state;
|
|
61
|
-
removeCard({
|
|
62
|
-
id
|
|
63
|
-
})(tr);
|
|
64
|
-
view.dispatch(tr);
|
|
65
|
-
};
|
|
66
|
-
}, [getPos, view]);
|
|
67
|
-
const scrollContainer = useMemo(
|
|
68
|
-
// Ignored via go/ees005
|
|
69
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
70
|
-
() => findOverflowScrollParent(view.dom) || undefined, [view.dom]);
|
|
71
|
-
const onResolve = useCallback(data => {
|
|
72
|
-
if (!getPos || typeof getPos === 'boolean') {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const {
|
|
76
|
-
title,
|
|
77
|
-
url
|
|
78
|
-
} = data;
|
|
79
|
-
// don't dispatch immediately since we might be in the middle of
|
|
80
|
-
// rendering a nodeview
|
|
81
|
-
rafSchedule(() => {
|
|
82
|
-
// prosemirror-bump-fix
|
|
83
|
-
const pos = getPos();
|
|
84
|
-
if (typeof pos !== 'number') {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
const tr = view.state.tr;
|
|
88
|
-
registerCard({
|
|
89
|
-
title,
|
|
90
|
-
url,
|
|
91
|
-
pos,
|
|
92
|
-
id: refId.current
|
|
93
|
-
})(tr);
|
|
94
|
-
onRes === null || onRes === void 0 ? void 0 : onRes(tr, title);
|
|
95
|
-
view.dispatch(tr);
|
|
96
|
-
})();
|
|
97
|
-
}, [getPos, view, onRes]);
|
|
98
|
-
const onError = useCallback(data => {
|
|
99
|
-
const {
|
|
100
|
-
url,
|
|
101
|
-
err
|
|
102
|
-
} = data;
|
|
103
|
-
if (err) {
|
|
104
|
-
throw err;
|
|
105
|
-
}
|
|
106
|
-
onResolve({
|
|
107
|
-
url
|
|
108
|
-
});
|
|
109
|
-
}, [onResolve]);
|
|
110
|
-
const handleOnClick = useCallback((event, data) => {
|
|
111
|
-
if (event.metaKey || event.ctrlKey) {
|
|
112
|
-
var _pluginInjectionApi$a, _data$destinationUrl;
|
|
113
|
-
const {
|
|
114
|
-
actions: editorAnalyticsApi
|
|
115
|
-
} = (_pluginInjectionApi$a = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.analytics) !== null && _pluginInjectionApi$a !== void 0 ? _pluginInjectionApi$a : {};
|
|
116
|
-
visitCardLinkAnalytics(editorAnalyticsApi, INPUT_METHOD.META_CLICK)(view.state, view.dispatch);
|
|
117
|
-
window.open(fg('platform_smartlink_xpc_url_wrapping') ? (_data$destinationUrl = data === null || data === void 0 ? void 0 : data.destinationUrl) !== null && _data$destinationUrl !== void 0 ? _data$destinationUrl : url : url, '_blank');
|
|
118
|
-
} else {
|
|
119
|
-
// only trigger the provided onClick callback if the meta key or ctrl key is not pressed
|
|
120
|
-
propsOnClick === null || propsOnClick === void 0 ? void 0 : propsOnClick(event);
|
|
121
|
-
}
|
|
122
|
-
}, [propsOnClick, url, view, pluginInjectionApi]);
|
|
123
|
-
const onClick = editorExperiment('platform_editor_controls', 'variant1') ? handleOnClick : propsOnClick;
|
|
124
|
-
const card = useMemo(() => {
|
|
125
|
-
if ((isPageSSRed || cardState && expValEquals('platform_editor_smartlink_local_cache', 'isEnabled', true)) && url) {
|
|
126
|
-
return /*#__PURE__*/React.createElement(CardSSR, {
|
|
127
|
-
key: url,
|
|
128
|
-
url: url,
|
|
129
|
-
appearance: "inline",
|
|
130
|
-
onClick: onClick,
|
|
131
|
-
container: scrollContainer,
|
|
132
|
-
onResolve: onResolve,
|
|
133
|
-
onError: onError,
|
|
134
|
-
inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
|
|
135
|
-
actionOptions: actionOptions,
|
|
136
|
-
isHovered: isHovered,
|
|
137
|
-
showHoverPreview: showHoverPreview,
|
|
138
|
-
hoverPreviewOptions: hoverPreviewOptions,
|
|
139
|
-
disablePreviewPanel: disablePreviewPanel,
|
|
140
|
-
hideIconLoadingSkeleton: true
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
return /*#__PURE__*/React.createElement(SmartCard, {
|
|
144
|
-
key: url,
|
|
145
|
-
url: url !== null && url !== void 0 ? url : data.url,
|
|
146
|
-
appearance: "inline",
|
|
147
|
-
onClick: onClick,
|
|
148
|
-
container: scrollContainer,
|
|
149
|
-
onResolve: onResolve,
|
|
150
|
-
onError: onError,
|
|
151
|
-
inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
|
|
152
|
-
actionOptions: actionOptions,
|
|
153
|
-
isHovered: isHovered,
|
|
154
|
-
showHoverPreview: showHoverPreview,
|
|
155
|
-
hoverPreviewOptions: hoverPreviewOptions,
|
|
156
|
-
disablePreviewPanel: disablePreviewPanel
|
|
157
|
-
});
|
|
158
|
-
}, [url, data, onClick, scrollContainer, onResolve, onError, useAlternativePreloader, actionOptions, isHovered, showHoverPreview, hoverPreviewOptions, isPageSSRed, disablePreviewPanel, cardState]);
|
|
159
|
-
|
|
160
|
-
// [WS-2307]: we only render card wrapped into a Provider when the value is ready,
|
|
161
|
-
// otherwise if we got data, we can render the card directly since it doesn't need the Provider
|
|
162
|
-
return cardContext && cardContext.value ? /*#__PURE__*/React.createElement(cardContext.Provider, {
|
|
163
|
-
value: cardContext.value
|
|
164
|
-
}, card) : data ? card : null;
|
|
165
|
-
});
|
|
166
13
|
const WrappedInlineCardWithAwareness = Card(InlineCardWithAwareness, UnsupportedInline);
|
|
167
14
|
const selectorWithCard = states => {
|
|
168
15
|
var _states$editorViewMod, _states$cardState;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import React, { memo, useCallback, useEffect, useMemo, useRef } from 'react';
|
|
2
|
+
import rafSchedule from 'raf-schd';
|
|
3
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
4
|
+
import uuid from 'uuid/v4';
|
|
5
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
6
|
+
import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
|
+
import { Card as SmartCard } from '@atlaskit/smart-card';
|
|
9
|
+
import { CardSSR } from '@atlaskit/smart-card/ssr';
|
|
10
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
11
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
12
|
+
import { registerCard, removeCard } from '../pm-plugins/actions';
|
|
13
|
+
import { visitCardLinkAnalytics } from '../ui/toolbar';
|
|
14
|
+
export const InlineCard = /*#__PURE__*/memo(({
|
|
15
|
+
node,
|
|
16
|
+
cardContext,
|
|
17
|
+
actionOptions,
|
|
18
|
+
useAlternativePreloader,
|
|
19
|
+
view,
|
|
20
|
+
getPos,
|
|
21
|
+
onClick: propsOnClick,
|
|
22
|
+
onResolve: onRes,
|
|
23
|
+
isHovered,
|
|
24
|
+
showHoverPreview,
|
|
25
|
+
hoverPreviewOptions,
|
|
26
|
+
isPageSSRed,
|
|
27
|
+
pluginInjectionApi,
|
|
28
|
+
disablePreviewPanel
|
|
29
|
+
}) => {
|
|
30
|
+
var _cardContext$value;
|
|
31
|
+
const {
|
|
32
|
+
url,
|
|
33
|
+
data
|
|
34
|
+
} = node.attrs;
|
|
35
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
36
|
+
const refId = useRef(uuid());
|
|
37
|
+
const removeCardDispatched = useRef(false);
|
|
38
|
+
const {
|
|
39
|
+
getState: getSmartlinkState
|
|
40
|
+
} = (cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.store) || {};
|
|
41
|
+
const cardState = getSmartlinkState === null || getSmartlinkState === void 0 ? void 0 : getSmartlinkState()[url || ''];
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
const id = refId.current;
|
|
44
|
+
removeCardDispatched.current = false;
|
|
45
|
+
return () => {
|
|
46
|
+
if (expValEquals('platform_editor_inline_card_dispatch_guard', 'isEnabled', true) && removeCardDispatched.current) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
removeCardDispatched.current = true;
|
|
50
|
+
const {
|
|
51
|
+
tr
|
|
52
|
+
} = view.state;
|
|
53
|
+
removeCard({
|
|
54
|
+
id
|
|
55
|
+
})(tr);
|
|
56
|
+
view.dispatch(tr);
|
|
57
|
+
};
|
|
58
|
+
}, [getPos, view]);
|
|
59
|
+
const scrollContainer = useMemo(
|
|
60
|
+
// Ignored via go/ees005
|
|
61
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
62
|
+
() => findOverflowScrollParent(view.dom) || undefined, [view.dom]);
|
|
63
|
+
const onResolve = useCallback(data => {
|
|
64
|
+
if (!getPos || typeof getPos === 'boolean') {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const {
|
|
68
|
+
title,
|
|
69
|
+
url
|
|
70
|
+
} = data;
|
|
71
|
+
// don't dispatch immediately since we might be in the middle of
|
|
72
|
+
// rendering a nodeview
|
|
73
|
+
rafSchedule(() => {
|
|
74
|
+
// prosemirror-bump-fix
|
|
75
|
+
const pos = getPos();
|
|
76
|
+
if (typeof pos !== 'number') {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const tr = view.state.tr;
|
|
80
|
+
registerCard({
|
|
81
|
+
title,
|
|
82
|
+
url,
|
|
83
|
+
pos,
|
|
84
|
+
id: refId.current
|
|
85
|
+
})(tr);
|
|
86
|
+
onRes === null || onRes === void 0 ? void 0 : onRes(tr, title);
|
|
87
|
+
view.dispatch(tr);
|
|
88
|
+
})();
|
|
89
|
+
}, [getPos, view, onRes]);
|
|
90
|
+
const onError = useCallback(data => {
|
|
91
|
+
const {
|
|
92
|
+
url,
|
|
93
|
+
err
|
|
94
|
+
} = data;
|
|
95
|
+
if (err) {
|
|
96
|
+
throw err;
|
|
97
|
+
}
|
|
98
|
+
onResolve({
|
|
99
|
+
url
|
|
100
|
+
});
|
|
101
|
+
}, [onResolve]);
|
|
102
|
+
const handleOnClick = useCallback((event, data) => {
|
|
103
|
+
if (event.metaKey || event.ctrlKey) {
|
|
104
|
+
var _pluginInjectionApi$a, _data$destinationUrl;
|
|
105
|
+
const {
|
|
106
|
+
actions: editorAnalyticsApi
|
|
107
|
+
} = (_pluginInjectionApi$a = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.analytics) !== null && _pluginInjectionApi$a !== void 0 ? _pluginInjectionApi$a : {};
|
|
108
|
+
visitCardLinkAnalytics(editorAnalyticsApi, INPUT_METHOD.META_CLICK)(view.state, view.dispatch);
|
|
109
|
+
window.open(fg('platform_smartlink_xpc_url_wrapping') ? (_data$destinationUrl = data === null || data === void 0 ? void 0 : data.destinationUrl) !== null && _data$destinationUrl !== void 0 ? _data$destinationUrl : url : url, '_blank');
|
|
110
|
+
} else {
|
|
111
|
+
// only trigger the provided onClick callback if the meta key or ctrl key is not pressed
|
|
112
|
+
propsOnClick === null || propsOnClick === void 0 ? void 0 : propsOnClick(event);
|
|
113
|
+
}
|
|
114
|
+
}, [propsOnClick, url, view, pluginInjectionApi]);
|
|
115
|
+
const onClick = editorExperiment('platform_editor_controls', 'variant1') ? handleOnClick : propsOnClick;
|
|
116
|
+
const card = useMemo(() => {
|
|
117
|
+
if ((isPageSSRed || cardState && expValEquals('platform_editor_smartlink_local_cache', 'isEnabled', true)) && url) {
|
|
118
|
+
return /*#__PURE__*/React.createElement(CardSSR, {
|
|
119
|
+
key: url,
|
|
120
|
+
url: url,
|
|
121
|
+
appearance: "inline",
|
|
122
|
+
onClick: onClick,
|
|
123
|
+
container: scrollContainer,
|
|
124
|
+
onResolve: onResolve,
|
|
125
|
+
onError: onError,
|
|
126
|
+
inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
|
|
127
|
+
actionOptions: actionOptions,
|
|
128
|
+
isHovered: isHovered,
|
|
129
|
+
showHoverPreview: showHoverPreview,
|
|
130
|
+
hoverPreviewOptions: hoverPreviewOptions,
|
|
131
|
+
disablePreviewPanel: disablePreviewPanel,
|
|
132
|
+
hideIconLoadingSkeleton: true
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
return /*#__PURE__*/React.createElement(SmartCard, {
|
|
136
|
+
key: url,
|
|
137
|
+
url: url !== null && url !== void 0 ? url : data.url,
|
|
138
|
+
appearance: "inline",
|
|
139
|
+
onClick: onClick,
|
|
140
|
+
container: scrollContainer,
|
|
141
|
+
onResolve: onResolve,
|
|
142
|
+
onError: onError,
|
|
143
|
+
inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
|
|
144
|
+
actionOptions: actionOptions,
|
|
145
|
+
isHovered: isHovered,
|
|
146
|
+
showHoverPreview: showHoverPreview,
|
|
147
|
+
hoverPreviewOptions: hoverPreviewOptions,
|
|
148
|
+
disablePreviewPanel: disablePreviewPanel
|
|
149
|
+
});
|
|
150
|
+
}, [url, data, onClick, scrollContainer, onResolve, onError, useAlternativePreloader, actionOptions, isHovered, showHoverPreview, hoverPreviewOptions, isPageSSRed, disablePreviewPanel, cardState]);
|
|
151
|
+
|
|
152
|
+
// [WS-2307]: we only render card wrapped into a Provider when the value is ready,
|
|
153
|
+
// otherwise if we got data, we can render the card directly since it doesn't need the Provider
|
|
154
|
+
return cardContext && cardContext.value ? /*#__PURE__*/React.createElement(cardContext.Provider, {
|
|
155
|
+
value: cardContext.value
|
|
156
|
+
}, card) : data ? card : null;
|
|
157
|
+
});
|
|
@@ -13,7 +13,7 @@ import { registerRemoveOverlay } from '../pm-plugins/actions';
|
|
|
13
13
|
import { pluginKey } from '../pm-plugins/plugin-key';
|
|
14
14
|
import { AwarenessWrapper } from '../ui/AwarenessWrapper';
|
|
15
15
|
import { PreviewInvoker } from '../ui/preview/PreviewInvoker';
|
|
16
|
-
import { InlineCard } from './
|
|
16
|
+
import { InlineCard } from './inlineCardBase';
|
|
17
17
|
const selector = states => {
|
|
18
18
|
var _states$editorViewMod, _states$selectionStat;
|
|
19
19
|
return {
|
|
@@ -1,160 +1,15 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React, {
|
|
3
|
-
import rafSchedule from 'raf-schd';
|
|
4
|
-
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
5
|
-
import uuid from 'uuid/v4';
|
|
6
|
-
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import React, { useEffect, useMemo } from 'react';
|
|
7
3
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
8
|
-
import { UnsupportedInline
|
|
4
|
+
import { UnsupportedInline } from '@atlaskit/editor-common/ui';
|
|
9
5
|
import { SmartLinkDraggable, SMART_LINK_DRAG_TYPES, SMART_LINK_APPEARANCE } from '@atlaskit/editor-smart-link-draggable';
|
|
10
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
|
-
import { Card as SmartCard } from '@atlaskit/smart-card';
|
|
12
|
-
import { CardSSR } from '@atlaskit/smart-card/ssr';
|
|
13
7
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
14
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
15
8
|
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
16
|
-
import { registerCard, removeCard } from '../pm-plugins/actions';
|
|
17
9
|
import { getAwarenessProps } from '../pm-plugins/utils';
|
|
18
10
|
import { SmartCardSSRReactContextsProvider } from '../ui/SmartCardSSRReactContextsProvider';
|
|
19
|
-
import { visitCardLinkAnalytics } from '../ui/toolbar';
|
|
20
11
|
import { Card } from './genericCard';
|
|
21
12
|
import { InlineCardWithAwareness } from './inlineCardWithAwareness';
|
|
22
|
-
export var InlineCard = /*#__PURE__*/memo(function (_ref) {
|
|
23
|
-
var _cardContext$value;
|
|
24
|
-
var node = _ref.node,
|
|
25
|
-
cardContext = _ref.cardContext,
|
|
26
|
-
actionOptions = _ref.actionOptions,
|
|
27
|
-
useAlternativePreloader = _ref.useAlternativePreloader,
|
|
28
|
-
view = _ref.view,
|
|
29
|
-
getPos = _ref.getPos,
|
|
30
|
-
propsOnClick = _ref.onClick,
|
|
31
|
-
onRes = _ref.onResolve,
|
|
32
|
-
isHovered = _ref.isHovered,
|
|
33
|
-
showHoverPreview = _ref.showHoverPreview,
|
|
34
|
-
hoverPreviewOptions = _ref.hoverPreviewOptions,
|
|
35
|
-
isPageSSRed = _ref.isPageSSRed,
|
|
36
|
-
pluginInjectionApi = _ref.pluginInjectionApi,
|
|
37
|
-
disablePreviewPanel = _ref.disablePreviewPanel;
|
|
38
|
-
var _node$attrs = node.attrs,
|
|
39
|
-
url = _node$attrs.url,
|
|
40
|
-
data = _node$attrs.data;
|
|
41
|
-
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
42
|
-
var refId = useRef(uuid());
|
|
43
|
-
var removeCardDispatched = useRef(false);
|
|
44
|
-
var _ref2 = (cardContext === null || cardContext === void 0 || (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.store) || {},
|
|
45
|
-
getSmartlinkState = _ref2.getState;
|
|
46
|
-
var cardState = getSmartlinkState === null || getSmartlinkState === void 0 ? void 0 : getSmartlinkState()[url || ''];
|
|
47
|
-
useEffect(function () {
|
|
48
|
-
var id = refId.current;
|
|
49
|
-
removeCardDispatched.current = false;
|
|
50
|
-
return function () {
|
|
51
|
-
if (expValEquals('platform_editor_inline_card_dispatch_guard', 'isEnabled', true) && removeCardDispatched.current) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
removeCardDispatched.current = true;
|
|
55
|
-
var tr = view.state.tr;
|
|
56
|
-
removeCard({
|
|
57
|
-
id: id
|
|
58
|
-
})(tr);
|
|
59
|
-
view.dispatch(tr);
|
|
60
|
-
};
|
|
61
|
-
}, [getPos, view]);
|
|
62
|
-
var scrollContainer = useMemo(
|
|
63
|
-
// Ignored via go/ees005
|
|
64
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
65
|
-
function () {
|
|
66
|
-
return findOverflowScrollParent(view.dom) || undefined;
|
|
67
|
-
}, [view.dom]);
|
|
68
|
-
var onResolve = useCallback(function (data) {
|
|
69
|
-
if (!getPos || typeof getPos === 'boolean') {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
var title = data.title,
|
|
73
|
-
url = data.url;
|
|
74
|
-
// don't dispatch immediately since we might be in the middle of
|
|
75
|
-
// rendering a nodeview
|
|
76
|
-
rafSchedule(function () {
|
|
77
|
-
// prosemirror-bump-fix
|
|
78
|
-
var pos = getPos();
|
|
79
|
-
if (typeof pos !== 'number') {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
var tr = view.state.tr;
|
|
83
|
-
registerCard({
|
|
84
|
-
title: title,
|
|
85
|
-
url: url,
|
|
86
|
-
pos: pos,
|
|
87
|
-
id: refId.current
|
|
88
|
-
})(tr);
|
|
89
|
-
onRes === null || onRes === void 0 || onRes(tr, title);
|
|
90
|
-
view.dispatch(tr);
|
|
91
|
-
})();
|
|
92
|
-
}, [getPos, view, onRes]);
|
|
93
|
-
var onError = useCallback(function (data) {
|
|
94
|
-
var url = data.url,
|
|
95
|
-
err = data.err;
|
|
96
|
-
if (err) {
|
|
97
|
-
throw err;
|
|
98
|
-
}
|
|
99
|
-
onResolve({
|
|
100
|
-
url: url
|
|
101
|
-
});
|
|
102
|
-
}, [onResolve]);
|
|
103
|
-
var handleOnClick = useCallback(function (event, data) {
|
|
104
|
-
if (event.metaKey || event.ctrlKey) {
|
|
105
|
-
var _pluginInjectionApi$a, _data$destinationUrl;
|
|
106
|
-
var _ref3 = (_pluginInjectionApi$a = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.analytics) !== null && _pluginInjectionApi$a !== void 0 ? _pluginInjectionApi$a : {},
|
|
107
|
-
editorAnalyticsApi = _ref3.actions;
|
|
108
|
-
visitCardLinkAnalytics(editorAnalyticsApi, INPUT_METHOD.META_CLICK)(view.state, view.dispatch);
|
|
109
|
-
window.open(fg('platform_smartlink_xpc_url_wrapping') ? (_data$destinationUrl = data === null || data === void 0 ? void 0 : data.destinationUrl) !== null && _data$destinationUrl !== void 0 ? _data$destinationUrl : url : url, '_blank');
|
|
110
|
-
} else {
|
|
111
|
-
// only trigger the provided onClick callback if the meta key or ctrl key is not pressed
|
|
112
|
-
propsOnClick === null || propsOnClick === void 0 || propsOnClick(event);
|
|
113
|
-
}
|
|
114
|
-
}, [propsOnClick, url, view, pluginInjectionApi]);
|
|
115
|
-
var onClick = editorExperiment('platform_editor_controls', 'variant1') ? handleOnClick : propsOnClick;
|
|
116
|
-
var card = useMemo(function () {
|
|
117
|
-
if ((isPageSSRed || cardState && expValEquals('platform_editor_smartlink_local_cache', 'isEnabled', true)) && url) {
|
|
118
|
-
return /*#__PURE__*/React.createElement(CardSSR, {
|
|
119
|
-
key: url,
|
|
120
|
-
url: url,
|
|
121
|
-
appearance: "inline",
|
|
122
|
-
onClick: onClick,
|
|
123
|
-
container: scrollContainer,
|
|
124
|
-
onResolve: onResolve,
|
|
125
|
-
onError: onError,
|
|
126
|
-
inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
|
|
127
|
-
actionOptions: actionOptions,
|
|
128
|
-
isHovered: isHovered,
|
|
129
|
-
showHoverPreview: showHoverPreview,
|
|
130
|
-
hoverPreviewOptions: hoverPreviewOptions,
|
|
131
|
-
disablePreviewPanel: disablePreviewPanel,
|
|
132
|
-
hideIconLoadingSkeleton: true
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
return /*#__PURE__*/React.createElement(SmartCard, {
|
|
136
|
-
key: url,
|
|
137
|
-
url: url !== null && url !== void 0 ? url : data.url,
|
|
138
|
-
appearance: "inline",
|
|
139
|
-
onClick: onClick,
|
|
140
|
-
container: scrollContainer,
|
|
141
|
-
onResolve: onResolve,
|
|
142
|
-
onError: onError,
|
|
143
|
-
inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
|
|
144
|
-
actionOptions: actionOptions,
|
|
145
|
-
isHovered: isHovered,
|
|
146
|
-
showHoverPreview: showHoverPreview,
|
|
147
|
-
hoverPreviewOptions: hoverPreviewOptions,
|
|
148
|
-
disablePreviewPanel: disablePreviewPanel
|
|
149
|
-
});
|
|
150
|
-
}, [url, data, onClick, scrollContainer, onResolve, onError, useAlternativePreloader, actionOptions, isHovered, showHoverPreview, hoverPreviewOptions, isPageSSRed, disablePreviewPanel, cardState]);
|
|
151
|
-
|
|
152
|
-
// [WS-2307]: we only render card wrapped into a Provider when the value is ready,
|
|
153
|
-
// otherwise if we got data, we can render the card directly since it doesn't need the Provider
|
|
154
|
-
return cardContext && cardContext.value ? /*#__PURE__*/React.createElement(cardContext.Provider, {
|
|
155
|
-
value: cardContext.value
|
|
156
|
-
}, card) : data ? card : null;
|
|
157
|
-
});
|
|
158
13
|
var WrappedInlineCardWithAwareness = Card(InlineCardWithAwareness, UnsupportedInline);
|
|
159
14
|
var selectorWithCard = function selectorWithCard(states) {
|
|
160
15
|
var _states$editorViewMod, _states$cardState;
|
|
@@ -206,8 +61,8 @@ export function InlineCardNodeView(props) {
|
|
|
206
61
|
if (expValEquals('platform_editor_smartlink_local_cache', 'isEnabled', true)) {
|
|
207
62
|
// Refresh cache in the background
|
|
208
63
|
provider === null || provider === void 0 || provider.then(function (providerInstance) {
|
|
209
|
-
var _refreshCache,
|
|
210
|
-
(_refreshCache = (
|
|
64
|
+
var _refreshCache, _ref;
|
|
65
|
+
(_refreshCache = (_ref = providerInstance).refreshCache) === null || _refreshCache === void 0 || _refreshCache.call(_ref, props.node);
|
|
211
66
|
});
|
|
212
67
|
}
|
|
213
68
|
}, [provider, props.node]);
|
|
@@ -243,8 +98,8 @@ export function InlineCardNodeView(props) {
|
|
|
243
98
|
isChangeboardTarget: isChangeboardTarget
|
|
244
99
|
}, inlineCardContent));
|
|
245
100
|
}
|
|
246
|
-
export var inlineCardNodeView = function inlineCardNodeView(
|
|
247
|
-
var inlineCardViewProducer =
|
|
101
|
+
export var inlineCardNodeView = function inlineCardNodeView(_ref2) {
|
|
102
|
+
var inlineCardViewProducer = _ref2.inlineCardViewProducer;
|
|
248
103
|
return function (node, view, getPos, decorations) {
|
|
249
104
|
return inlineCardViewProducer(node, view, getPos, decorations);
|
|
250
105
|
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import React, { memo, useCallback, useEffect, useMemo, useRef } from 'react';
|
|
2
|
+
import rafSchedule from 'raf-schd';
|
|
3
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
4
|
+
import uuid from 'uuid/v4';
|
|
5
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
6
|
+
import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
|
+
import { Card as SmartCard } from '@atlaskit/smart-card';
|
|
9
|
+
import { CardSSR } from '@atlaskit/smart-card/ssr';
|
|
10
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
11
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
12
|
+
import { registerCard, removeCard } from '../pm-plugins/actions';
|
|
13
|
+
import { visitCardLinkAnalytics } from '../ui/toolbar';
|
|
14
|
+
export var InlineCard = /*#__PURE__*/memo(function (_ref) {
|
|
15
|
+
var _cardContext$value;
|
|
16
|
+
var node = _ref.node,
|
|
17
|
+
cardContext = _ref.cardContext,
|
|
18
|
+
actionOptions = _ref.actionOptions,
|
|
19
|
+
useAlternativePreloader = _ref.useAlternativePreloader,
|
|
20
|
+
view = _ref.view,
|
|
21
|
+
getPos = _ref.getPos,
|
|
22
|
+
propsOnClick = _ref.onClick,
|
|
23
|
+
onRes = _ref.onResolve,
|
|
24
|
+
isHovered = _ref.isHovered,
|
|
25
|
+
showHoverPreview = _ref.showHoverPreview,
|
|
26
|
+
hoverPreviewOptions = _ref.hoverPreviewOptions,
|
|
27
|
+
isPageSSRed = _ref.isPageSSRed,
|
|
28
|
+
pluginInjectionApi = _ref.pluginInjectionApi,
|
|
29
|
+
disablePreviewPanel = _ref.disablePreviewPanel;
|
|
30
|
+
var _node$attrs = node.attrs,
|
|
31
|
+
url = _node$attrs.url,
|
|
32
|
+
data = _node$attrs.data;
|
|
33
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
34
|
+
var refId = useRef(uuid());
|
|
35
|
+
var removeCardDispatched = useRef(false);
|
|
36
|
+
var _ref2 = (cardContext === null || cardContext === void 0 || (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.store) || {},
|
|
37
|
+
getSmartlinkState = _ref2.getState;
|
|
38
|
+
var cardState = getSmartlinkState === null || getSmartlinkState === void 0 ? void 0 : getSmartlinkState()[url || ''];
|
|
39
|
+
useEffect(function () {
|
|
40
|
+
var id = refId.current;
|
|
41
|
+
removeCardDispatched.current = false;
|
|
42
|
+
return function () {
|
|
43
|
+
if (expValEquals('platform_editor_inline_card_dispatch_guard', 'isEnabled', true) && removeCardDispatched.current) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
removeCardDispatched.current = true;
|
|
47
|
+
var tr = view.state.tr;
|
|
48
|
+
removeCard({
|
|
49
|
+
id: id
|
|
50
|
+
})(tr);
|
|
51
|
+
view.dispatch(tr);
|
|
52
|
+
};
|
|
53
|
+
}, [getPos, view]);
|
|
54
|
+
var scrollContainer = useMemo(
|
|
55
|
+
// Ignored via go/ees005
|
|
56
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
57
|
+
function () {
|
|
58
|
+
return findOverflowScrollParent(view.dom) || undefined;
|
|
59
|
+
}, [view.dom]);
|
|
60
|
+
var onResolve = useCallback(function (data) {
|
|
61
|
+
if (!getPos || typeof getPos === 'boolean') {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
var title = data.title,
|
|
65
|
+
url = data.url;
|
|
66
|
+
// don't dispatch immediately since we might be in the middle of
|
|
67
|
+
// rendering a nodeview
|
|
68
|
+
rafSchedule(function () {
|
|
69
|
+
// prosemirror-bump-fix
|
|
70
|
+
var pos = getPos();
|
|
71
|
+
if (typeof pos !== 'number') {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
var tr = view.state.tr;
|
|
75
|
+
registerCard({
|
|
76
|
+
title: title,
|
|
77
|
+
url: url,
|
|
78
|
+
pos: pos,
|
|
79
|
+
id: refId.current
|
|
80
|
+
})(tr);
|
|
81
|
+
onRes === null || onRes === void 0 || onRes(tr, title);
|
|
82
|
+
view.dispatch(tr);
|
|
83
|
+
})();
|
|
84
|
+
}, [getPos, view, onRes]);
|
|
85
|
+
var onError = useCallback(function (data) {
|
|
86
|
+
var url = data.url,
|
|
87
|
+
err = data.err;
|
|
88
|
+
if (err) {
|
|
89
|
+
throw err;
|
|
90
|
+
}
|
|
91
|
+
onResolve({
|
|
92
|
+
url: url
|
|
93
|
+
});
|
|
94
|
+
}, [onResolve]);
|
|
95
|
+
var handleOnClick = useCallback(function (event, data) {
|
|
96
|
+
if (event.metaKey || event.ctrlKey) {
|
|
97
|
+
var _pluginInjectionApi$a, _data$destinationUrl;
|
|
98
|
+
var _ref3 = (_pluginInjectionApi$a = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.analytics) !== null && _pluginInjectionApi$a !== void 0 ? _pluginInjectionApi$a : {},
|
|
99
|
+
editorAnalyticsApi = _ref3.actions;
|
|
100
|
+
visitCardLinkAnalytics(editorAnalyticsApi, INPUT_METHOD.META_CLICK)(view.state, view.dispatch);
|
|
101
|
+
window.open(fg('platform_smartlink_xpc_url_wrapping') ? (_data$destinationUrl = data === null || data === void 0 ? void 0 : data.destinationUrl) !== null && _data$destinationUrl !== void 0 ? _data$destinationUrl : url : url, '_blank');
|
|
102
|
+
} else {
|
|
103
|
+
// only trigger the provided onClick callback if the meta key or ctrl key is not pressed
|
|
104
|
+
propsOnClick === null || propsOnClick === void 0 || propsOnClick(event);
|
|
105
|
+
}
|
|
106
|
+
}, [propsOnClick, url, view, pluginInjectionApi]);
|
|
107
|
+
var onClick = editorExperiment('platform_editor_controls', 'variant1') ? handleOnClick : propsOnClick;
|
|
108
|
+
var card = useMemo(function () {
|
|
109
|
+
if ((isPageSSRed || cardState && expValEquals('platform_editor_smartlink_local_cache', 'isEnabled', true)) && url) {
|
|
110
|
+
return /*#__PURE__*/React.createElement(CardSSR, {
|
|
111
|
+
key: url,
|
|
112
|
+
url: url,
|
|
113
|
+
appearance: "inline",
|
|
114
|
+
onClick: onClick,
|
|
115
|
+
container: scrollContainer,
|
|
116
|
+
onResolve: onResolve,
|
|
117
|
+
onError: onError,
|
|
118
|
+
inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
|
|
119
|
+
actionOptions: actionOptions,
|
|
120
|
+
isHovered: isHovered,
|
|
121
|
+
showHoverPreview: showHoverPreview,
|
|
122
|
+
hoverPreviewOptions: hoverPreviewOptions,
|
|
123
|
+
disablePreviewPanel: disablePreviewPanel,
|
|
124
|
+
hideIconLoadingSkeleton: true
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
return /*#__PURE__*/React.createElement(SmartCard, {
|
|
128
|
+
key: url,
|
|
129
|
+
url: url !== null && url !== void 0 ? url : data.url,
|
|
130
|
+
appearance: "inline",
|
|
131
|
+
onClick: onClick,
|
|
132
|
+
container: scrollContainer,
|
|
133
|
+
onResolve: onResolve,
|
|
134
|
+
onError: onError,
|
|
135
|
+
inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
|
|
136
|
+
actionOptions: actionOptions,
|
|
137
|
+
isHovered: isHovered,
|
|
138
|
+
showHoverPreview: showHoverPreview,
|
|
139
|
+
hoverPreviewOptions: hoverPreviewOptions,
|
|
140
|
+
disablePreviewPanel: disablePreviewPanel
|
|
141
|
+
});
|
|
142
|
+
}, [url, data, onClick, scrollContainer, onResolve, onError, useAlternativePreloader, actionOptions, isHovered, showHoverPreview, hoverPreviewOptions, isPageSSRed, disablePreviewPanel, cardState]);
|
|
143
|
+
|
|
144
|
+
// [WS-2307]: we only render card wrapped into a Provider when the value is ready,
|
|
145
|
+
// otherwise if we got data, we can render the card directly since it doesn't need the Provider
|
|
146
|
+
return cardContext && cardContext.value ? /*#__PURE__*/React.createElement(cardContext.Provider, {
|
|
147
|
+
value: cardContext.value
|
|
148
|
+
}, card) : data ? card : null;
|
|
149
|
+
});
|
|
@@ -14,7 +14,7 @@ import { registerRemoveOverlay } from '../pm-plugins/actions';
|
|
|
14
14
|
import { pluginKey } from '../pm-plugins/plugin-key';
|
|
15
15
|
import { AwarenessWrapper } from '../ui/AwarenessWrapper';
|
|
16
16
|
import { PreviewInvoker } from '../ui/preview/PreviewInvoker';
|
|
17
|
-
import { InlineCard } from './
|
|
17
|
+
import { InlineCard } from './inlineCardBase';
|
|
18
18
|
var selector = function selector(states) {
|
|
19
19
|
var _states$editorViewMod, _states$selectionStat;
|
|
20
20
|
return {
|
|
@@ -4,7 +4,6 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
|
4
4
|
import type { Decoration, EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
import type { SmartCardProps } from './genericCard';
|
|
6
6
|
import type { InlineCardWithAwarenessProps } from './inlineCardWithAwareness';
|
|
7
|
-
export declare const InlineCard: React.MemoExoticComponent<({ node, cardContext, actionOptions, useAlternativePreloader, view, getPos, onClick, onResolve, isHovered, showHoverPreview, hoverPreviewOptions, isPageSSRed, pluginInjectionApi, disablePreviewPanel, }: SmartCardProps) => React.JSX.Element | null>;
|
|
8
7
|
export type InlineCardNodeViewProps = Pick<SmartCardProps, 'useAlternativePreloader' | 'actionOptions' | 'allowEmbeds' | 'allowBlockCards' | 'enableInlineUpgradeFeatures' | 'pluginInjectionApi' | 'onClickCallback' | 'isPageSSRed' | 'CompetitorPrompt' | 'provider' | 'intl' | 'smartCardContext'>;
|
|
9
8
|
/**
|
|
10
9
|
* Inline card node view component that renders a Smart Link inline card within the editor.
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { SmartCardProps } from './genericCard';
|
|
3
|
+
export declare const InlineCard: React.MemoExoticComponent<({ node, cardContext, actionOptions, useAlternativePreloader, view, getPos, onClick, onResolve, isHovered, showHoverPreview, hoverPreviewOptions, isPageSSRed, pluginInjectionApi, disablePreviewPanel, }: SmartCardProps) => React.JSX.Element | null>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-card",
|
|
3
|
-
"version": "18.1.
|
|
3
|
+
"version": "18.1.6",
|
|
4
4
|
"description": "Card plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -56,10 +56,10 @@
|
|
|
56
56
|
"@atlaskit/menu": "^9.2.0",
|
|
57
57
|
"@atlaskit/platform-feature-flags": "^2.0.0",
|
|
58
58
|
"@atlaskit/platform-feature-flags-react": "^1.1.0",
|
|
59
|
-
"@atlaskit/primitives": "^
|
|
59
|
+
"@atlaskit/primitives": "^21.0.0",
|
|
60
60
|
"@atlaskit/prosemirror-history": "^1.0.0",
|
|
61
61
|
"@atlaskit/smart-card": "^45.9.0",
|
|
62
|
-
"@atlaskit/tmp-editor-statsig": "^125.
|
|
62
|
+
"@atlaskit/tmp-editor-statsig": "^125.2.0",
|
|
63
63
|
"@atlaskit/tokens": "^15.8.0",
|
|
64
64
|
"@babel/runtime": "^7.0.0",
|
|
65
65
|
"@emotion/react": "^11.7.1",
|