@atlaskit/editor-plugin-card 2.3.3 → 2.3.5
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 +17 -0
- package/dist/cjs/nodeviews/genericCard.js +1 -1
- package/dist/cjs/nodeviews/inlineCard.js +101 -16
- package/dist/cjs/nodeviews/inlineCardWithAwareness.js +40 -96
- package/dist/cjs/plugin.js +2 -2
- package/dist/cjs/ui/AwarenessWrapper/index.js +2 -11
- package/dist/cjs/utils.js +15 -2
- package/dist/es2019/nodeviews/genericCard.js +2 -2
- package/dist/es2019/nodeviews/inlineCard.js +100 -17
- package/dist/es2019/nodeviews/inlineCardWithAwareness.js +39 -97
- package/dist/es2019/plugin.js +3 -3
- package/dist/es2019/ui/AwarenessWrapper/index.js +2 -11
- package/dist/es2019/utils.js +15 -2
- package/dist/esm/nodeviews/genericCard.js +2 -2
- package/dist/esm/nodeviews/inlineCard.js +98 -17
- package/dist/esm/nodeviews/inlineCardWithAwareness.js +41 -97
- package/dist/esm/plugin.js +3 -3
- package/dist/esm/ui/AwarenessWrapper/index.js +2 -11
- package/dist/esm/utils.js +15 -2
- package/dist/types/nodeviews/genericCard.d.ts +6 -4
- package/dist/types/nodeviews/inlineCard.d.ts +3 -7
- package/dist/types/nodeviews/inlineCardWithAwareness.d.ts +6 -1
- package/dist/types/ui/AwarenessWrapper/index.d.ts +4 -3
- package/dist/types/utils.d.ts +6 -0
- package/dist/types-ts4.5/nodeviews/genericCard.d.ts +6 -4
- package/dist/types-ts4.5/nodeviews/inlineCard.d.ts +3 -7
- package/dist/types-ts4.5/nodeviews/inlineCardWithAwareness.d.ts +6 -1
- package/dist/types-ts4.5/ui/AwarenessWrapper/index.d.ts +4 -3
- package/dist/types-ts4.5/utils.d.ts +6 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-card
|
|
2
2
|
|
|
3
|
+
## 2.3.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#117005](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/117005)
|
|
8
|
+
[`74f438b3abcff`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/74f438b3abcff) -
|
|
9
|
+
[ux] Fix for import statement in plugins.tsx
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 2.3.4
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#116819](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/116819)
|
|
17
|
+
[`d80c008d6a32e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d80c008d6a32e) -
|
|
18
|
+
[ux] Seperate live page overlay logic from discoverability overlay and assosciated code refactor
|
|
19
|
+
|
|
3
20
|
## 2.3.3
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -107,7 +107,7 @@ function Card(SmartCardComponent, UnsupportedComponent) {
|
|
|
107
107
|
// Below is added for the future implementation of Linking Platform namespaced analytics context
|
|
108
108
|
location: analyticsEditorAppearance
|
|
109
109
|
}
|
|
110
|
-
}, (0, _platformFeatureFlags.
|
|
110
|
+
}, (0, _platformFeatureFlags.fg)('platform.linking-platform.smart-card.on-click-callback') ? /*#__PURE__*/_react.default.createElement(WithClickHandler, {
|
|
111
111
|
pluginInjectionApi: pluginInjectionApi,
|
|
112
112
|
onClickCallback: onClickCallback,
|
|
113
113
|
url: url
|
|
@@ -1,18 +1,101 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
8
|
+
exports.InlineCard = void 0;
|
|
7
9
|
exports.InlineCardNodeView = InlineCardNodeView;
|
|
8
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
-
var _react =
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
10
13
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
11
|
-
var
|
|
14
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
|
+
var _smartCard = require("@atlaskit/smart-card");
|
|
16
|
+
var _actions = require("../pm-plugins/actions");
|
|
17
|
+
var _ConfigureOverlay = _interopRequireDefault(require("../ui/ConfigureOverlay"));
|
|
12
18
|
var _utils = require("../utils");
|
|
13
19
|
var _genericCard = require("./genericCard");
|
|
14
20
|
var _inlineCardWithAwareness = require("./inlineCardWithAwareness");
|
|
21
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
22
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
23
|
+
var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
24
|
+
var node = _ref.node,
|
|
25
|
+
cardContext = _ref.cardContext,
|
|
26
|
+
actionOptions = _ref.actionOptions,
|
|
27
|
+
showServerActions = _ref.showServerActions,
|
|
28
|
+
useAlternativePreloader = _ref.useAlternativePreloader,
|
|
29
|
+
view = _ref.view,
|
|
30
|
+
getPos = _ref.getPos,
|
|
31
|
+
onClick = _ref.onClick,
|
|
32
|
+
onRes = _ref.onResolve,
|
|
33
|
+
isHovered = _ref.isHovered;
|
|
34
|
+
var _node$attrs = node.attrs,
|
|
35
|
+
url = _node$attrs.url,
|
|
36
|
+
data = _node$attrs.data;
|
|
37
|
+
var scrollContainer = (0, _react.useMemo)(function () {
|
|
38
|
+
return (0, _ui.findOverflowScrollParent)(view.dom) || undefined;
|
|
39
|
+
}, [view.dom]);
|
|
40
|
+
var onResolve = (0, _react.useCallback)(function (data) {
|
|
41
|
+
if (!getPos || typeof getPos === 'boolean') {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
var title = data.title,
|
|
45
|
+
url = data.url;
|
|
46
|
+
// don't dispatch immediately since we might be in the middle of
|
|
47
|
+
// rendering a nodeview
|
|
48
|
+
(0, _rafSchd.default)(function () {
|
|
49
|
+
// prosemirror-bump-fix
|
|
50
|
+
var pos = getPos();
|
|
51
|
+
if (typeof pos !== 'number') {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
var tr = view.state.tr;
|
|
55
|
+
(0, _actions.registerCard)({
|
|
56
|
+
title: title,
|
|
57
|
+
url: url,
|
|
58
|
+
pos: pos
|
|
59
|
+
})(tr);
|
|
60
|
+
onRes === null || onRes === void 0 || onRes(tr, title);
|
|
61
|
+
view.dispatch(tr);
|
|
62
|
+
})();
|
|
63
|
+
}, [getPos, view, onRes]);
|
|
64
|
+
var onError = (0, _react.useCallback)(function (data) {
|
|
65
|
+
var url = data.url,
|
|
66
|
+
err = data.err;
|
|
67
|
+
if (err) {
|
|
68
|
+
throw err;
|
|
69
|
+
}
|
|
70
|
+
onResolve({
|
|
71
|
+
url: url
|
|
72
|
+
});
|
|
73
|
+
}, [onResolve]);
|
|
74
|
+
var card = (0, _react.useMemo)(function () {
|
|
75
|
+
return /*#__PURE__*/_react.default.createElement(_smartCard.Card, {
|
|
76
|
+
key: url,
|
|
77
|
+
url: url,
|
|
78
|
+
data: data,
|
|
79
|
+
appearance: "inline",
|
|
80
|
+
onClick: onClick,
|
|
81
|
+
container: scrollContainer,
|
|
82
|
+
onResolve: onResolve,
|
|
83
|
+
onError: onError,
|
|
84
|
+
inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
|
|
85
|
+
actionOptions: actionOptions,
|
|
86
|
+
showServerActions: showServerActions,
|
|
87
|
+
isHovered: isHovered
|
|
88
|
+
});
|
|
89
|
+
}, [data, isHovered, onError, onResolve, scrollContainer, url, useAlternativePreloader, actionOptions, showServerActions, onClick]);
|
|
90
|
+
|
|
91
|
+
// [WS-2307]: we only render card wrapped into a Provider when the value is ready,
|
|
92
|
+
// otherwise if we got data, we can render the card directly since it doesn't need the Provider
|
|
93
|
+
return cardContext && cardContext.value ? /*#__PURE__*/_react.default.createElement(cardContext.Provider, {
|
|
94
|
+
value: cardContext.value
|
|
95
|
+
}, card) : data ? card : null;
|
|
96
|
+
});
|
|
15
97
|
var WrappedInlineCardWithAwareness = (0, _genericCard.Card)(_inlineCardWithAwareness.InlineCardWithAwareness, _ui.UnsupportedInline);
|
|
98
|
+
var WrappedInlineCard = (0, _genericCard.Card)(InlineCard, _ui.UnsupportedInline);
|
|
16
99
|
function InlineCardNodeView(props) {
|
|
17
100
|
var useAlternativePreloader = props.useAlternativePreloader,
|
|
18
101
|
node = props.node,
|
|
@@ -25,6 +108,20 @@ function InlineCardNodeView(props) {
|
|
|
25
108
|
enableInlineUpgradeFeatures = props.enableInlineUpgradeFeatures,
|
|
26
109
|
pluginInjectionApi = props.pluginInjectionApi,
|
|
27
110
|
onClickCallback = props.onClickCallback;
|
|
111
|
+
if ((0, _platformFeatureFlags.fg)('platform.linking-platform.smart-links-in-live-pages')) {
|
|
112
|
+
return /*#__PURE__*/_react.default.createElement(_ConfigureOverlay.default, {
|
|
113
|
+
targetElementPos: getPos(),
|
|
114
|
+
view: view
|
|
115
|
+
}, /*#__PURE__*/_react.default.createElement(WrappedInlineCard, {
|
|
116
|
+
node: node,
|
|
117
|
+
view: view,
|
|
118
|
+
getPos: getPos,
|
|
119
|
+
actionOptions: actionOptions,
|
|
120
|
+
showServerActions: showServerActions,
|
|
121
|
+
useAlternativePreloader: useAlternativePreloader,
|
|
122
|
+
onClickCallback: onClickCallback
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
28
125
|
return /*#__PURE__*/_react.default.createElement(WrappedInlineCardWithAwareness, (0, _extends2.default)({
|
|
29
126
|
node: node,
|
|
30
127
|
view: view,
|
|
@@ -34,17 +131,5 @@ function InlineCardNodeView(props) {
|
|
|
34
131
|
useAlternativePreloader: useAlternativePreloader,
|
|
35
132
|
pluginInjectionApi: pluginInjectionApi,
|
|
36
133
|
onClickCallback: onClickCallback
|
|
37
|
-
}, enableInlineUpgradeFeatures && getAwarenessProps(view.state, getPos, allowEmbeds, allowBlockCards)));
|
|
38
|
-
}
|
|
39
|
-
var getAwarenessProps = function getAwarenessProps(editorState, getPos, allowEmbeds, allowBlockCards) {
|
|
40
|
-
var _editorState$selectio, _editorState$selectio2;
|
|
41
|
-
var linkPosition = getPos && typeof getPos() === 'number' ? getPos() : undefined;
|
|
42
|
-
var canBeUpgradedToEmbed = !!linkPosition && allowEmbeds ? (0, _utils.isEmbedSupportedAtPosition)(linkPosition, editorState, 'inline') : false;
|
|
43
|
-
var canBeUpgradedToBlock = !!linkPosition && allowBlockCards ? (0, _utils.isBlockSupportedAtPosition)(linkPosition, editorState, 'inline') : false;
|
|
44
|
-
var isSelected = editorState.selection instanceof _state.NodeSelection && ((_editorState$selectio = editorState.selection) === null || _editorState$selectio === void 0 || (_editorState$selectio = _editorState$selectio.node) === null || _editorState$selectio === void 0 ? void 0 : _editorState$selectio.type) === editorState.schema.nodes.inlineCard && ((_editorState$selectio2 = editorState.selection) === null || _editorState$selectio2 === void 0 ? void 0 : _editorState$selectio2.from) === getPos();
|
|
45
|
-
return {
|
|
46
|
-
isPulseEnabled: canBeUpgradedToEmbed,
|
|
47
|
-
isOverlayEnabled: canBeUpgradedToEmbed || canBeUpgradedToBlock,
|
|
48
|
-
isSelected: isSelected
|
|
49
|
-
};
|
|
50
|
-
};
|
|
134
|
+
}, enableInlineUpgradeFeatures && (0, _utils.getAwarenessProps)(view.state, getPos, allowEmbeds, allowBlockCards)));
|
|
135
|
+
}
|
|
@@ -8,14 +8,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.InlineCardWithAwareness = void 0;
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
12
|
-
var _ui = require("@atlaskit/editor-common/ui");
|
|
13
|
-
var _smartCard = require("@atlaskit/smart-card");
|
|
14
11
|
var _actions = require("../pm-plugins/actions");
|
|
15
12
|
var _AwarenessWrapper = require("../ui/AwarenessWrapper");
|
|
13
|
+
var _inlineCard = require("./inlineCard");
|
|
16
14
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
17
15
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
|
-
var
|
|
16
|
+
var InlineCardWithAwareness = exports.InlineCardWithAwareness = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
19
17
|
var node = _ref.node,
|
|
20
18
|
cardContext = _ref.cardContext,
|
|
21
19
|
actionOptions = _ref.actionOptions,
|
|
@@ -23,15 +21,11 @@ var InlineCard = function InlineCard(_ref) {
|
|
|
23
21
|
useAlternativePreloader = _ref.useAlternativePreloader,
|
|
24
22
|
view = _ref.view,
|
|
25
23
|
getPos = _ref.getPos,
|
|
26
|
-
isOverlayEnabled = _ref.isOverlayEnabled,
|
|
27
|
-
isPulseEnabled = _ref.isPulseEnabled,
|
|
28
24
|
pluginInjectionApi = _ref.pluginInjectionApi,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
url = _node$attrs.url,
|
|
34
|
-
data = _node$attrs.data;
|
|
25
|
+
onClick = _ref.onClick,
|
|
26
|
+
isPulseEnabled = _ref.isPulseEnabled,
|
|
27
|
+
isOverlayEnabled = _ref.isOverlayEnabled,
|
|
28
|
+
isSelected = _ref.isSelected;
|
|
35
29
|
var _useState = (0, _react.useState)(false),
|
|
36
30
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
37
31
|
isHovered = _useState2[0],
|
|
@@ -44,50 +38,14 @@ var InlineCard = function InlineCard(_ref) {
|
|
|
44
38
|
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
45
39
|
isResolvedViewRendered = _useState6[0],
|
|
46
40
|
setIsResolvedViewRendered = _useState6[1];
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (!getPos || typeof getPos === 'boolean') {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
var title = data.title,
|
|
55
|
-
url = data.url;
|
|
56
|
-
// don't dispatch immediately since we might be in the middle of
|
|
57
|
-
// rendering a nodeview
|
|
58
|
-
(0, _rafSchd.default)(function () {
|
|
59
|
-
// prosemirror-bump-fix
|
|
60
|
-
var pos = getPos();
|
|
61
|
-
if (typeof pos !== 'number') {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
var tr = view.state.tr;
|
|
65
|
-
(0, _actions.registerCard)({
|
|
66
|
-
title: title,
|
|
67
|
-
url: url,
|
|
68
|
-
pos: pos
|
|
69
|
-
})(tr);
|
|
70
|
-
(0, _actions.registerRemoveOverlay)(function () {
|
|
71
|
-
return setIsInserted(false);
|
|
72
|
-
})(tr);
|
|
73
|
-
view.dispatch(tr);
|
|
74
|
-
})();
|
|
41
|
+
var onResolve = (0, _react.useCallback)(function (tr, title) {
|
|
42
|
+
(0, _actions.registerRemoveOverlay)(function () {
|
|
43
|
+
return setIsInserted(false);
|
|
44
|
+
})(tr);
|
|
75
45
|
if (title) {
|
|
76
46
|
setIsResolvedViewRendered(true);
|
|
77
47
|
}
|
|
78
|
-
}, [
|
|
79
|
-
var onError = (0, _react.useCallback)(function (data) {
|
|
80
|
-
var url = data.url,
|
|
81
|
-
err = data.err;
|
|
82
|
-
if (err) {
|
|
83
|
-
throw err;
|
|
84
|
-
}
|
|
85
|
-
onResolve({
|
|
86
|
-
url: url
|
|
87
|
-
});
|
|
88
|
-
}, [onResolve]);
|
|
89
|
-
|
|
90
|
-
// Begin Upgrade Awareness related code
|
|
48
|
+
}, []);
|
|
91
49
|
var markMostRecentlyInsertedLink = (0, _react.useCallback)(function (isLinkMostRecentlyInserted) {
|
|
92
50
|
if (isOverlayEnabled) {
|
|
93
51
|
setIsInserted(isLinkMostRecentlyInserted);
|
|
@@ -98,51 +56,37 @@ var InlineCard = function InlineCard(_ref) {
|
|
|
98
56
|
setIsHovered(isHovered);
|
|
99
57
|
}
|
|
100
58
|
}, [isOverlayEnabled]);
|
|
101
|
-
// End Upgrade Awareness related code
|
|
102
|
-
|
|
103
59
|
var innerCard = (0, _react.useMemo)(function () {
|
|
104
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
onClick: onClick,
|
|
110
|
-
container: scrollContainer,
|
|
111
|
-
onResolve: onResolve,
|
|
112
|
-
onError: onError,
|
|
113
|
-
inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
|
|
60
|
+
return /*#__PURE__*/_react.default.createElement(_inlineCard.InlineCard, {
|
|
61
|
+
node: node,
|
|
62
|
+
view: view,
|
|
63
|
+
getPos: getPos,
|
|
64
|
+
useAlternativePreloader: useAlternativePreloader,
|
|
114
65
|
actionOptions: actionOptions,
|
|
115
66
|
showServerActions: showServerActions,
|
|
67
|
+
onResolve: onResolve,
|
|
68
|
+
onClick: onClick,
|
|
69
|
+
cardContext: cardContext,
|
|
116
70
|
isHovered: isHovered
|
|
117
71
|
});
|
|
118
|
-
}, [
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}, innerCard);
|
|
140
|
-
}, [cardContext, getPos, innerCard, isHovered, isInserted, isOverlayEnabled, isPulseEnabled, isResolvedViewRendered, isSelected, markMostRecentlyInsertedLink, pluginInjectionApi, setOverlayHoveredStyles, url, view]);
|
|
141
|
-
|
|
142
|
-
// [WS-2307]: we only render card wrapped into a Provider when the value is ready,
|
|
143
|
-
// otherwise if we got data, we can render the card directly since it doesn't need the Provider
|
|
144
|
-
return cardContext && cardContext.value ? /*#__PURE__*/_react.default.createElement(cardContext.Provider, {
|
|
145
|
-
value: cardContext.value
|
|
146
|
-
}, card) : data ? card : null;
|
|
147
|
-
};
|
|
148
|
-
var InlineCardWithAwareness = exports.InlineCardWithAwareness = /*#__PURE__*/(0, _react.memo)(InlineCard);
|
|
72
|
+
}, [actionOptions, cardContext, getPos, isHovered, node, onClick, onResolve, showServerActions, useAlternativePreloader, view]);
|
|
73
|
+
return isOverlayEnabled || isPulseEnabled ? /*#__PURE__*/_react.default.createElement(_AwarenessWrapper.AwarenessWrapper, {
|
|
74
|
+
isOverlayEnabled: isOverlayEnabled,
|
|
75
|
+
isPulseEnabled: isPulseEnabled,
|
|
76
|
+
cardContext: cardContext,
|
|
77
|
+
getPos: getPos,
|
|
78
|
+
isHovered: isHovered,
|
|
79
|
+
isInserted: isInserted,
|
|
80
|
+
url: node.attrs.url,
|
|
81
|
+
isSelected: isSelected,
|
|
82
|
+
isResolvedViewRendered: isResolvedViewRendered,
|
|
83
|
+
markMostRecentlyInsertedLink: markMostRecentlyInsertedLink,
|
|
84
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
85
|
+
setOverlayHoveredStyles: setOverlayHoveredStyles
|
|
86
|
+
}, innerCard) :
|
|
87
|
+
/*#__PURE__*/
|
|
88
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
89
|
+
_react.default.createElement("span", {
|
|
90
|
+
className: "card"
|
|
91
|
+
}, innerCard);
|
|
92
|
+
});
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -13,9 +13,9 @@ var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
|
13
13
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
14
14
|
var _linkDatasource = require("@atlaskit/link-datasource");
|
|
15
15
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
|
-
var _doc = require("../src/pm-plugins/doc");
|
|
17
16
|
var _createEventsQueue = require("./analytics/create-events-queue");
|
|
18
17
|
var _actions = require("./pm-plugins/actions");
|
|
18
|
+
var _doc = require("./pm-plugins/doc");
|
|
19
19
|
var _keymap = require("./pm-plugins/keymap");
|
|
20
20
|
var _main = require("./pm-plugins/main");
|
|
21
21
|
var _pluginKey = require("./pm-plugins/plugin-key");
|
|
@@ -142,7 +142,7 @@ var cardPlugin = exports.cardPlugin = function cardPlugin(_ref) {
|
|
|
142
142
|
if ((0, _utils.canRenderDatasource)(_linkDatasource.ASSETS_LIST_OF_LINKS_DATASOURCE_ID)) {
|
|
143
143
|
quickInsertArray.push({
|
|
144
144
|
id: 'datasource',
|
|
145
|
-
title: (0, _platformFeatureFlags.
|
|
145
|
+
title: (0, _platformFeatureFlags.fg)('platform.linking-platform.datasource-assets_objects_remove_beta') ? formatMessage(_messages.cardMessages.datasourceAssetsObjectsGeneralAvailability) : formatMessage(_messages.cardMessages.datasourceAssetsObjects),
|
|
146
146
|
description: formatMessage(_messages.cardMessages.datasourceAssetsObjectsDescription),
|
|
147
147
|
categories: ['external-content', 'development'],
|
|
148
148
|
keywords: ['assets'],
|
|
@@ -9,11 +9,9 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
9
9
|
var _react = require("react");
|
|
10
10
|
var _react2 = require("@emotion/react");
|
|
11
11
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
12
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
12
|
var _useLinkUpgradeDiscoverability = _interopRequireDefault(require("../../common/hooks/useLinkUpgradeDiscoverability"));
|
|
14
13
|
var _localStorage = require("../../common/local-storage");
|
|
15
14
|
var _utils = require("../../utils");
|
|
16
|
-
var _ConfigureOverlay = _interopRequireDefault(require("../ConfigureOverlay"));
|
|
17
15
|
var _InlineCardOverlay = _interopRequireDefault(require("../InlineCardOverlay"));
|
|
18
16
|
var _Pulse = require("../Pulse");
|
|
19
17
|
/** @jsx jsx */
|
|
@@ -41,8 +39,7 @@ var AwarenessWrapper = exports.AwarenessWrapper = function AwarenessWrapper(_ref
|
|
|
41
39
|
markMostRecentlyInsertedLink = _ref.markMostRecentlyInsertedLink,
|
|
42
40
|
pluginInjectionApi = _ref.pluginInjectionApi,
|
|
43
41
|
setOverlayHoveredStyles = _ref.setOverlayHoveredStyles,
|
|
44
|
-
url = _ref.url
|
|
45
|
-
view = _ref.view;
|
|
42
|
+
url = _ref.url;
|
|
46
43
|
var _useState = (0, _react.useState)(false),
|
|
47
44
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
48
45
|
isHovered = _useState2[0],
|
|
@@ -82,12 +79,6 @@ var AwarenessWrapper = exports.AwarenessWrapper = function AwarenessWrapper(_ref
|
|
|
82
79
|
setOverlayHoveredStyles(isHovered);
|
|
83
80
|
}, [setOverlayHoveredStyles]);
|
|
84
81
|
var cardWithOverlay = (0, _react.useMemo)(function () {
|
|
85
|
-
if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-links-in-live-pages')) {
|
|
86
|
-
return (0, _react2.jsx)(_ConfigureOverlay.default, {
|
|
87
|
-
targetElementPos: linkPosition,
|
|
88
|
-
view: view
|
|
89
|
-
}, children);
|
|
90
|
-
}
|
|
91
82
|
if (shouldShowLinkOverlay) {
|
|
92
83
|
return (0, _react2.jsx)(_InlineCardOverlay.default, {
|
|
93
84
|
isSelected: isSelected,
|
|
@@ -102,7 +93,7 @@ var AwarenessWrapper = exports.AwarenessWrapper = function AwarenessWrapper(_ref
|
|
|
102
93
|
}, children);
|
|
103
94
|
}
|
|
104
95
|
return children;
|
|
105
|
-
}, [shouldShowLinkOverlay, children, isSelected, isResolvedViewRendered, isInserted, isHovered, url,
|
|
96
|
+
}, [shouldShowLinkOverlay, children, isSelected, isResolvedViewRendered, isInserted, isHovered, url, handleOverlayChange]);
|
|
106
97
|
return (0, _react.useMemo)(function () {
|
|
107
98
|
var _cardContext$value;
|
|
108
99
|
return (
|
package/dist/cjs/utils.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.titleUrlPairFromNode = exports.selectedCardAppearance = exports.mergeCardInfo = exports.isEmbedSupportedAtPosition = exports.isDatasourceNode = exports.isDatasourceConfigEditable = exports.isDatasourceAdfAttributes = exports.isBlockSupportedAtPosition = exports.getResolvedAttributesFromStore = exports.focusEditorView = exports.findCardInfo = exports.displayInfoForCard = exports.appearanceForNodeType = void 0;
|
|
7
|
+
exports.titleUrlPairFromNode = exports.selectedCardAppearance = exports.mergeCardInfo = exports.isEmbedSupportedAtPosition = exports.isDatasourceNode = exports.isDatasourceConfigEditable = exports.isDatasourceAdfAttributes = exports.isBlockSupportedAtPosition = exports.getResolvedAttributesFromStore = exports.getAwarenessProps = exports.focusEditorView = exports.findCardInfo = exports.displayInfoForCard = exports.appearanceForNodeType = void 0;
|
|
8
8
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
9
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
10
10
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
@@ -82,7 +82,7 @@ var getResolvedAttributesFromStore = exports.getResolvedAttributesFromStore = fu
|
|
|
82
82
|
};
|
|
83
83
|
var isDatasourceConfigEditable = exports.isDatasourceConfigEditable = function isDatasourceConfigEditable(datasourceId) {
|
|
84
84
|
var datasourcesWithConfigModal = [_linkDatasource.JIRA_LIST_OF_LINKS_DATASOURCE_ID, _linkDatasource.ASSETS_LIST_OF_LINKS_DATASOURCE_ID];
|
|
85
|
-
if ((0, _platformFeatureFlags.
|
|
85
|
+
if ((0, _platformFeatureFlags.fg)('platform.linking-platform.datasource.enable-confluence-search-modal')) {
|
|
86
86
|
datasourcesWithConfigModal.push(_linkDatasource.CONFLUENCE_SEARCH_DATASOURCE_ID);
|
|
87
87
|
}
|
|
88
88
|
return datasourcesWithConfigModal.includes(datasourceId);
|
|
@@ -132,4 +132,17 @@ var focusEditorView = exports.focusEditorView = function focusEditorView(editorV
|
|
|
132
132
|
if (!editorView.hasFocus()) {
|
|
133
133
|
editorView.focus();
|
|
134
134
|
}
|
|
135
|
+
};
|
|
136
|
+
var getAwarenessProps = exports.getAwarenessProps = function getAwarenessProps(editorState, getPos, allowEmbeds, allowBlockCards) {
|
|
137
|
+
var _editorState$selectio, _editorState$selectio2;
|
|
138
|
+
var getPosFunction = typeof getPos !== 'boolean' ? getPos : undefined;
|
|
139
|
+
var linkPosition = getPosFunction === null || getPosFunction === void 0 ? void 0 : getPosFunction();
|
|
140
|
+
var canBeUpgradedToEmbed = !!linkPosition && allowEmbeds ? isEmbedSupportedAtPosition(linkPosition, editorState, 'inline') : false;
|
|
141
|
+
var canBeUpgradedToBlock = !!linkPosition && allowBlockCards ? isBlockSupportedAtPosition(linkPosition, editorState, 'inline') : false;
|
|
142
|
+
var isSelected = editorState.selection instanceof _state.NodeSelection && ((_editorState$selectio = editorState.selection) === null || _editorState$selectio === void 0 || (_editorState$selectio = _editorState$selectio.node) === null || _editorState$selectio === void 0 ? void 0 : _editorState$selectio.type) === editorState.schema.nodes.inlineCard && ((_editorState$selectio2 = editorState.selection) === null || _editorState$selectio2 === void 0 ? void 0 : _editorState$selectio2.from) === (getPosFunction === null || getPosFunction === void 0 ? void 0 : getPosFunction());
|
|
143
|
+
return {
|
|
144
|
+
isPulseEnabled: canBeUpgradedToEmbed,
|
|
145
|
+
isOverlayEnabled: canBeUpgradedToEmbed || canBeUpgradedToBlock,
|
|
146
|
+
isSelected: isSelected
|
|
147
|
+
};
|
|
135
148
|
};
|
|
@@ -6,7 +6,7 @@ import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
|
6
6
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
7
7
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
8
8
|
import { getAnalyticsEditorAppearance } from '@atlaskit/editor-common/utils';
|
|
9
|
-
import {
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
10
|
import { changeSelectedCardToLinkFallback } from '../pm-plugins/doc';
|
|
11
11
|
import { getPluginState } from '../pm-plugins/util/state';
|
|
12
12
|
import { titleUrlPairFromNode } from '../utils';
|
|
@@ -82,7 +82,7 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
|
|
|
82
82
|
// Below is added for the future implementation of Linking Platform namespaced analytics context
|
|
83
83
|
location: analyticsEditorAppearance
|
|
84
84
|
}
|
|
85
|
-
},
|
|
85
|
+
}, fg('platform.linking-platform.smart-card.on-click-callback') ? /*#__PURE__*/React.createElement(WithClickHandler, {
|
|
86
86
|
pluginInjectionApi: pluginInjectionApi,
|
|
87
87
|
onClickCallback: onClickCallback,
|
|
88
88
|
url: url
|
|
@@ -1,11 +1,92 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import React, { memo, useCallback, useMemo } from 'react';
|
|
3
|
+
import rafSchedule from 'raf-schd';
|
|
4
|
+
import { findOverflowScrollParent, UnsupportedInline } from '@atlaskit/editor-common/ui';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
|
+
import { Card as SmartCard } from '@atlaskit/smart-card';
|
|
7
|
+
import { registerCard } from '../pm-plugins/actions';
|
|
8
|
+
import OverlayWrapper from '../ui/ConfigureOverlay';
|
|
9
|
+
import { getAwarenessProps } from '../utils';
|
|
6
10
|
import { Card } from './genericCard';
|
|
7
11
|
import { InlineCardWithAwareness } from './inlineCardWithAwareness';
|
|
12
|
+
export const InlineCard = /*#__PURE__*/memo(({
|
|
13
|
+
node,
|
|
14
|
+
cardContext,
|
|
15
|
+
actionOptions,
|
|
16
|
+
showServerActions,
|
|
17
|
+
useAlternativePreloader,
|
|
18
|
+
view,
|
|
19
|
+
getPos,
|
|
20
|
+
onClick,
|
|
21
|
+
onResolve: onRes,
|
|
22
|
+
isHovered
|
|
23
|
+
}) => {
|
|
24
|
+
const {
|
|
25
|
+
url,
|
|
26
|
+
data
|
|
27
|
+
} = node.attrs;
|
|
28
|
+
const scrollContainer = useMemo(() => findOverflowScrollParent(view.dom) || undefined, [view.dom]);
|
|
29
|
+
const onResolve = useCallback(data => {
|
|
30
|
+
if (!getPos || typeof getPos === 'boolean') {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const {
|
|
34
|
+
title,
|
|
35
|
+
url
|
|
36
|
+
} = data;
|
|
37
|
+
// don't dispatch immediately since we might be in the middle of
|
|
38
|
+
// rendering a nodeview
|
|
39
|
+
rafSchedule(() => {
|
|
40
|
+
// prosemirror-bump-fix
|
|
41
|
+
const pos = getPos();
|
|
42
|
+
if (typeof pos !== 'number') {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const tr = view.state.tr;
|
|
46
|
+
registerCard({
|
|
47
|
+
title,
|
|
48
|
+
url,
|
|
49
|
+
pos
|
|
50
|
+
})(tr);
|
|
51
|
+
onRes === null || onRes === void 0 ? void 0 : onRes(tr, title);
|
|
52
|
+
view.dispatch(tr);
|
|
53
|
+
})();
|
|
54
|
+
}, [getPos, view, onRes]);
|
|
55
|
+
const onError = useCallback(data => {
|
|
56
|
+
const {
|
|
57
|
+
url,
|
|
58
|
+
err
|
|
59
|
+
} = data;
|
|
60
|
+
if (err) {
|
|
61
|
+
throw err;
|
|
62
|
+
}
|
|
63
|
+
onResolve({
|
|
64
|
+
url
|
|
65
|
+
});
|
|
66
|
+
}, [onResolve]);
|
|
67
|
+
const card = useMemo(() => /*#__PURE__*/React.createElement(SmartCard, {
|
|
68
|
+
key: url,
|
|
69
|
+
url: url,
|
|
70
|
+
data: data,
|
|
71
|
+
appearance: "inline",
|
|
72
|
+
onClick: onClick,
|
|
73
|
+
container: scrollContainer,
|
|
74
|
+
onResolve: onResolve,
|
|
75
|
+
onError: onError,
|
|
76
|
+
inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
|
|
77
|
+
actionOptions: actionOptions,
|
|
78
|
+
showServerActions: showServerActions,
|
|
79
|
+
isHovered: isHovered
|
|
80
|
+
}), [data, isHovered, onError, onResolve, scrollContainer, url, useAlternativePreloader, actionOptions, showServerActions, onClick]);
|
|
81
|
+
|
|
82
|
+
// [WS-2307]: we only render card wrapped into a Provider when the value is ready,
|
|
83
|
+
// otherwise if we got data, we can render the card directly since it doesn't need the Provider
|
|
84
|
+
return cardContext && cardContext.value ? /*#__PURE__*/React.createElement(cardContext.Provider, {
|
|
85
|
+
value: cardContext.value
|
|
86
|
+
}, card) : data ? card : null;
|
|
87
|
+
});
|
|
8
88
|
const WrappedInlineCardWithAwareness = Card(InlineCardWithAwareness, UnsupportedInline);
|
|
89
|
+
const WrappedInlineCard = Card(InlineCard, UnsupportedInline);
|
|
9
90
|
export function InlineCardNodeView(props) {
|
|
10
91
|
const {
|
|
11
92
|
useAlternativePreloader,
|
|
@@ -20,6 +101,20 @@ export function InlineCardNodeView(props) {
|
|
|
20
101
|
pluginInjectionApi,
|
|
21
102
|
onClickCallback
|
|
22
103
|
} = props;
|
|
104
|
+
if (fg('platform.linking-platform.smart-links-in-live-pages')) {
|
|
105
|
+
return /*#__PURE__*/React.createElement(OverlayWrapper, {
|
|
106
|
+
targetElementPos: getPos(),
|
|
107
|
+
view: view
|
|
108
|
+
}, /*#__PURE__*/React.createElement(WrappedInlineCard, {
|
|
109
|
+
node: node,
|
|
110
|
+
view: view,
|
|
111
|
+
getPos: getPos,
|
|
112
|
+
actionOptions: actionOptions,
|
|
113
|
+
showServerActions: showServerActions,
|
|
114
|
+
useAlternativePreloader: useAlternativePreloader,
|
|
115
|
+
onClickCallback: onClickCallback
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
23
118
|
return /*#__PURE__*/React.createElement(WrappedInlineCardWithAwareness, _extends({
|
|
24
119
|
node: node,
|
|
25
120
|
view: view,
|
|
@@ -30,16 +125,4 @@ export function InlineCardNodeView(props) {
|
|
|
30
125
|
pluginInjectionApi: pluginInjectionApi,
|
|
31
126
|
onClickCallback: onClickCallback
|
|
32
127
|
}, enableInlineUpgradeFeatures && getAwarenessProps(view.state, getPos, allowEmbeds, allowBlockCards)));
|
|
33
|
-
}
|
|
34
|
-
const getAwarenessProps = (editorState, getPos, allowEmbeds, allowBlockCards) => {
|
|
35
|
-
var _editorState$selectio, _editorState$selectio2, _editorState$selectio3;
|
|
36
|
-
const linkPosition = getPos && typeof getPos() === 'number' ? getPos() : undefined;
|
|
37
|
-
const canBeUpgradedToEmbed = !!linkPosition && allowEmbeds ? isEmbedSupportedAtPosition(linkPosition, editorState, 'inline') : false;
|
|
38
|
-
const canBeUpgradedToBlock = !!linkPosition && allowBlockCards ? isBlockSupportedAtPosition(linkPosition, editorState, 'inline') : false;
|
|
39
|
-
const isSelected = editorState.selection instanceof NodeSelection && ((_editorState$selectio = editorState.selection) === null || _editorState$selectio === void 0 ? void 0 : (_editorState$selectio2 = _editorState$selectio.node) === null || _editorState$selectio2 === void 0 ? void 0 : _editorState$selectio2.type) === editorState.schema.nodes.inlineCard && ((_editorState$selectio3 = editorState.selection) === null || _editorState$selectio3 === void 0 ? void 0 : _editorState$selectio3.from) === getPos();
|
|
40
|
-
return {
|
|
41
|
-
isPulseEnabled: canBeUpgradedToEmbed,
|
|
42
|
-
isOverlayEnabled: canBeUpgradedToEmbed || canBeUpgradedToBlock,
|
|
43
|
-
isSelected
|
|
44
|
-
};
|
|
45
|
-
};
|
|
128
|
+
}
|