@atlaskit/editor-plugin-card 2.3.2 → 2.3.4
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 +16 -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/toolbar.js +14 -14
- 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/toolbar.js +15 -15
- 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/toolbar.js +15 -15
- 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 +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-card
|
|
2
2
|
|
|
3
|
+
## 2.3.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#116819](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/116819)
|
|
8
|
+
[`d80c008d6a32e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d80c008d6a32e) -
|
|
9
|
+
[ux] Seperate live page overlay logic from discoverability overlay and assosciated code refactor
|
|
10
|
+
|
|
11
|
+
## 2.3.3
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#116712](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/116712)
|
|
16
|
+
[`1e3e81166600e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1e3e81166600e) -
|
|
17
|
+
[ux] Bump for the previous fix of the import statement
|
|
18
|
+
|
|
3
19
|
## 2.3.2
|
|
4
20
|
|
|
5
21
|
### 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/toolbar.js
CHANGED
|
@@ -24,7 +24,7 @@ var _settings = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/sett
|
|
|
24
24
|
var _unlink = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/unlink"));
|
|
25
25
|
var _shortcut = _interopRequireDefault(require("@atlaskit/icon/glyph/shortcut"));
|
|
26
26
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
27
|
-
var _doc = require("
|
|
27
|
+
var _doc = require("./pm-plugins/doc");
|
|
28
28
|
var _main = require("./pm-plugins/main");
|
|
29
29
|
var _DatasourceAppearanceButton = require("./ui/DatasourceAppearanceButton");
|
|
30
30
|
var _EditDatasourceButton = require("./ui/EditDatasourceButton");
|
|
@@ -208,7 +208,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
208
208
|
var currentAppearance = (0, _utils3.appearanceForNodeType)(node.type);
|
|
209
209
|
var _ref2 = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$d2 = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {},
|
|
210
210
|
hoverDecoration = _ref2.hoverDecoration;
|
|
211
|
-
var isDatasource = (0, _platformFeatureFlags.
|
|
211
|
+
var isDatasource = (0, _platformFeatureFlags.fg)('platform.linking-platform.editor-datasource-typeguards') ? (0, _utils3.isDatasourceNode)(node) : currentAppearance === 'block' && (node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.datasource);
|
|
212
212
|
var shouldRenderDatasourceToolbar = isDatasource &&
|
|
213
213
|
// not showing toolbar in mobile for now since not sure what our plans are for it
|
|
214
214
|
platform !== 'mobile' && cardOptions.allowDatasource && (0, _utils.canRenderDatasource)(node === null || node === void 0 || (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 || (_node$attrs2 = _node$attrs2.datasource) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.id);
|
|
@@ -226,7 +226,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
226
226
|
return getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, node.attrs.datasource.id, state, cardOptions, currentAppearance, platform);
|
|
227
227
|
} else {
|
|
228
228
|
var inlineCard = state.schema.nodes.inlineCard;
|
|
229
|
-
var isEditDropdownEnabled = (0, _platformFeatureFlags.
|
|
229
|
+
var isEditDropdownEnabled = platform !== 'mobile' && cardOptions.allowDatasource && (0, _platformFeatureFlags.fg)('platform.linking-platform.enable-datasource-edit-dropdown-toolbar');
|
|
230
230
|
var editItems = isEditDropdownEnabled ? [{
|
|
231
231
|
type: 'custom',
|
|
232
232
|
fallback: [],
|
|
@@ -303,7 +303,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
303
303
|
// This code will be executed only for appearances such as "inline", "block" & "embed"
|
|
304
304
|
// For url appearance, please see HyperlinkToolbarAppearanceProps
|
|
305
305
|
if (currentAppearance) {
|
|
306
|
-
var showDatasourceAppearance = (0, _platformFeatureFlags.
|
|
306
|
+
var showDatasourceAppearance = allowDatasource && url && (0, _platformFeatureFlags.fg)('platform.linking-platform.enable-datasource-appearance-toolbar');
|
|
307
307
|
toolbarItems.unshift.apply(toolbarItems, (0, _toConsumableArray2.default)(getToolbarViewedItem(url, currentAppearance)).concat([{
|
|
308
308
|
type: 'custom',
|
|
309
309
|
fallback: [],
|
|
@@ -339,7 +339,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
339
339
|
type: 'separator'
|
|
340
340
|
}]));
|
|
341
341
|
}
|
|
342
|
-
var shouldShowDatasourceEditButton = platform !== 'mobile' && allowDatasource && !(0, _platformFeatureFlags.
|
|
342
|
+
var shouldShowDatasourceEditButton = platform !== 'mobile' && allowDatasource && !(0, _platformFeatureFlags.fg)('platform.linking-platform.enable-datasource-edit-dropdown-toolbar');
|
|
343
343
|
if (shouldShowDatasourceEditButton) {
|
|
344
344
|
toolbarItems.unshift({
|
|
345
345
|
type: 'custom',
|
|
@@ -377,8 +377,8 @@ var getHyperlinkToolbarSettingsButton = exports.getHyperlinkToolbarSettingsButto
|
|
|
377
377
|
type: 'button',
|
|
378
378
|
icon: _settings.default,
|
|
379
379
|
title: intl.formatMessage(_messages.linkToolbarMessages.settingsLink),
|
|
380
|
-
onClick: (0, _platformFeatureFlags.
|
|
381
|
-
href: (0, _platformFeatureFlags.
|
|
380
|
+
onClick: (0, _platformFeatureFlags.fg)('platform.editor.card.inject-settings-button') ? openLinkSettings(editorAnalyticsApi, userPreferencesLink) : openLinkSettings(editorAnalyticsApi, undefined),
|
|
381
|
+
href: (0, _platformFeatureFlags.fg)('platform.editor.card.inject-settings-button') ? userPreferencesLink || (0, _link.getLinkPreferencesURLFromENV)() : (0, _link.getLinkPreferencesURLFromENV)(),
|
|
382
382
|
target: '_blank'
|
|
383
383
|
};
|
|
384
384
|
};
|
|
@@ -388,7 +388,7 @@ var getSettingsButton = exports.getSettingsButton = function getSettingsButton(i
|
|
|
388
388
|
type: 'button',
|
|
389
389
|
icon: _settings.default,
|
|
390
390
|
title: intl.formatMessage(_messages.linkToolbarMessages.settingsLink),
|
|
391
|
-
onClick: (0, _platformFeatureFlags.
|
|
391
|
+
onClick: (0, _platformFeatureFlags.fg)('platform.editor.card.inject-settings-button') ? openLinkSettings(editorAnalyticsApi, userPreferencesLink) : openLinkSettings(editorAnalyticsApi, undefined)
|
|
392
392
|
};
|
|
393
393
|
};
|
|
394
394
|
var getSettingsButtonGroup = exports.getSettingsButtonGroup = function getSettingsButtonGroup(intl, editorAnalyticsApi, userPreferencesLink) {
|
|
@@ -399,7 +399,7 @@ var getSettingsButtonGroup = exports.getSettingsButtonGroup = function getSettin
|
|
|
399
399
|
var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state, cardOptions, currentAppearance, platform) {
|
|
400
400
|
var _node$attrs3;
|
|
401
401
|
var toolbarItems = [];
|
|
402
|
-
if ((0, _utils3.isDatasourceConfigEditable)(datasourceId) && !(0, _platformFeatureFlags.
|
|
402
|
+
if ((0, _utils3.isDatasourceConfigEditable)(datasourceId) && !(0, _platformFeatureFlags.fg)('platform.linking-platform.enable-datasource-edit-dropdown-toolbar')) {
|
|
403
403
|
toolbarItems.push({
|
|
404
404
|
id: 'editor.edit.datasource',
|
|
405
405
|
type: 'button',
|
|
@@ -420,12 +420,12 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
|
|
|
420
420
|
}
|
|
421
421
|
if (
|
|
422
422
|
// FF that controls visibily of the additional toolbar buttons
|
|
423
|
-
!(0, _platformFeatureFlags.
|
|
423
|
+
!(0, _platformFeatureFlags.fg)('platform.linking-platform.enable-datasource-appearance-toolbar')) {
|
|
424
424
|
return false;
|
|
425
425
|
}
|
|
426
426
|
|
|
427
427
|
// FF to enable additional toolbar buttons based on if the datasource is configurable or not
|
|
428
|
-
return (0, _platformFeatureFlags.
|
|
428
|
+
return (0, _platformFeatureFlags.fg)('platform.linking-platform.datasource-enable-toolbar-buttons-for-all-datasources') ? true : !(0, _utils3.isDatasourceConfigEditable)(datasourceId);
|
|
429
429
|
};
|
|
430
430
|
if (canShowAppearanceSwitch()) {
|
|
431
431
|
var allowBlockCards = cardOptions.allowBlockCards,
|
|
@@ -469,7 +469,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
|
|
|
469
469
|
type: 'separator'
|
|
470
470
|
});
|
|
471
471
|
}
|
|
472
|
-
if ((0, _platformFeatureFlags.
|
|
472
|
+
if ((0, _platformFeatureFlags.fg)('platform.linking-platform.enable-datasource-edit-dropdown-toolbar')) {
|
|
473
473
|
toolbarItems.push({
|
|
474
474
|
type: 'custom',
|
|
475
475
|
fallback: [],
|
|
@@ -530,7 +530,7 @@ var shouldRenderToolbarPulse = exports.shouldRenderToolbarPulse = function shoul
|
|
|
530
530
|
};
|
|
531
531
|
var getStartingToolbarItems = exports.getStartingToolbarItems = function getStartingToolbarItems(options, api) {
|
|
532
532
|
return function (intl, link, providerFactory, onEditLink, metadata) {
|
|
533
|
-
var isEditDropdownEnabled = (0, _platformFeatureFlags.
|
|
533
|
+
var isEditDropdownEnabled = options.platform !== 'mobile' && options.allowDatasource && (0, _platformFeatureFlags.fg)('platform.linking-platform.enable-datasource-edit-dropdown-toolbar');
|
|
534
534
|
var editLinkItem = isEditDropdownEnabled ? [{
|
|
535
535
|
type: 'custom',
|
|
536
536
|
fallback: [],
|
|
@@ -596,7 +596,7 @@ var getStartingToolbarItems = exports.getStartingToolbarItems = function getStar
|
|
|
596
596
|
};
|
|
597
597
|
var getEndingToolbarItems = exports.getEndingToolbarItems = function getEndingToolbarItems(options, api) {
|
|
598
598
|
return function (intl, link) {
|
|
599
|
-
if ((0, _platformFeatureFlags.
|
|
599
|
+
if ((0, _platformFeatureFlags.fg)('platform.editor.card.inject-settings-button')) {
|
|
600
600
|
/**
|
|
601
601
|
* Require either provider to be supplied (controls link preferences)
|
|
602
602
|
* Or explicit user preferences config in order to enable button
|
|
@@ -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
|