@atlaskit/editor-plugin-card 0.14.17 → 0.14.19
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 +12 -0
- package/dist/cjs/nodeviews/inlineCard.js +16 -18
- package/dist/cjs/nodeviews/inlineCardWithAwareness.js +38 -81
- package/dist/cjs/pm-plugins/main.js +4 -3
- package/dist/cjs/ui/AwarenessWrapper/index.js +107 -0
- package/dist/cjs/ui/EditorLinkingPlatformAnalytics/common.js +6 -1
- package/dist/cjs/ui/LinkToolbarAppearance.js +2 -2
- package/dist/cjs/{common/pulse → ui/Pulse}/index.js +1 -1
- package/dist/es2019/nodeviews/inlineCard.js +17 -19
- package/dist/es2019/nodeviews/inlineCardWithAwareness.js +35 -75
- package/dist/es2019/pm-plugins/main.js +4 -3
- package/dist/es2019/ui/AwarenessWrapper/index.js +91 -0
- package/dist/es2019/ui/EditorLinkingPlatformAnalytics/common.js +6 -1
- package/dist/es2019/ui/LinkToolbarAppearance.js +1 -1
- package/dist/es2019/{common/pulse → ui/Pulse}/index.js +1 -1
- package/dist/esm/nodeviews/inlineCard.js +16 -18
- package/dist/esm/nodeviews/inlineCardWithAwareness.js +35 -80
- package/dist/esm/pm-plugins/main.js +4 -3
- package/dist/esm/ui/AwarenessWrapper/index.js +99 -0
- package/dist/esm/ui/EditorLinkingPlatformAnalytics/common.js +6 -1
- package/dist/esm/ui/LinkToolbarAppearance.js +1 -1
- package/dist/esm/{common/pulse → ui/Pulse}/index.js +1 -1
- package/dist/types/nodeviews/inlineCardWithAwareness.d.ts +2 -3
- package/dist/types/ui/AwarenessWrapper/index.d.ts +13 -0
- package/dist/types/ui/EditorLinkingPlatformAnalytics/LinkEvents.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/inlineCardWithAwareness.d.ts +2 -3
- package/dist/types-ts4.5/ui/AwarenessWrapper/index.d.ts +13 -0
- package/dist/types-ts4.5/ui/EditorLinkingPlatformAnalytics/LinkEvents.d.ts +1 -1
- package/package.json +3 -3
- /package/dist/types/{common/pulse → ui/Pulse}/index.d.ts +0 -0
- /package/dist/types-ts4.5/{common/pulse → ui/Pulse}/index.d.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-card
|
|
2
2
|
|
|
3
|
+
## 0.14.19
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#60660](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/60660) [`102ad9375609`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/102ad9375609) - Fixed an issue where link creationMethod attribute was set as unknown when inserting via datasource config modal.
|
|
8
|
+
|
|
9
|
+
## 0.14.18
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#60441](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/60441) [`13892b95e918`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/13892b95e918) - [ux] Refactoring of the inline card with awareness solution (behind a FF)
|
|
14
|
+
|
|
3
15
|
## 0.14.17
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.InlineCardComponent = void 0;
|
|
8
8
|
exports.InlineCardNodeView = InlineCardNodeView;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
12
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
@@ -123,7 +124,6 @@ var InlineCardComponent = exports.InlineCardComponent = /*#__PURE__*/function (_
|
|
|
123
124
|
var WrappedInlineCard = (0, _genericCard.Card)(InlineCardComponent, _ui.UnsupportedInline);
|
|
124
125
|
var WrappedInlineCardWithAwareness = (0, _genericCard.Card)(_inlineCardWithAwareness.InlineCardWithAwareness, _ui.UnsupportedInline);
|
|
125
126
|
function InlineCardNodeView(props) {
|
|
126
|
-
var _view$state$selection, _view$state$selection2;
|
|
127
127
|
var useAlternativePreloader = props.useAlternativePreloader,
|
|
128
128
|
node = props.node,
|
|
129
129
|
view = props.view,
|
|
@@ -142,26 +142,24 @@ function InlineCardNodeView(props) {
|
|
|
142
142
|
useAlternativePreloader: useAlternativePreloader
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
|
-
|
|
146
|
-
// BEGIN: Awareness (To be revisited in EDM-8508)
|
|
147
|
-
var editorState = view.state;
|
|
148
|
-
var linkPosition = getPos && typeof getPos() === 'number' ? getPos() : undefined;
|
|
149
|
-
var canBeUpgradedToEmbed = !!linkPosition && allowEmbeds ? (0, _utils.isEmbedSupportedAtPosition)(linkPosition, editorState, 'inline') : false;
|
|
150
|
-
var canBeUpgradedToBlock = !!linkPosition && allowBlockCards ? (0, _utils.isBlockSupportedAtPosition)(linkPosition, editorState, 'inline') : false;
|
|
151
|
-
var isPulseEnabled = enableInlineUpgradeFeatures && canBeUpgradedToEmbed;
|
|
152
|
-
var isOverlayEnabled = enableInlineUpgradeFeatures && (canBeUpgradedToEmbed || canBeUpgradedToBlock);
|
|
153
|
-
var isSelected = view.state.selection instanceof _state.NodeSelection && ((_view$state$selection = view.state.selection) === null || _view$state$selection === void 0 || (_view$state$selection = _view$state$selection.node) === null || _view$state$selection === void 0 ? void 0 : _view$state$selection.type) === view.state.schema.nodes.inlineCard && ((_view$state$selection2 = view.state.selection) === null || _view$state$selection2 === void 0 ? void 0 : _view$state$selection2.from) === getPos();
|
|
154
|
-
// END: Awareness
|
|
155
|
-
|
|
156
|
-
return /*#__PURE__*/_react.default.createElement(WrappedInlineCardWithAwareness, {
|
|
145
|
+
return /*#__PURE__*/_react.default.createElement(WrappedInlineCardWithAwareness, (0, _extends2.default)({
|
|
157
146
|
node: node,
|
|
158
147
|
view: view,
|
|
159
148
|
getPos: getPos,
|
|
160
149
|
showServerActions: showServerActions,
|
|
161
150
|
useAlternativePreloader: useAlternativePreloader,
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
151
|
+
pluginInjectionApi: pluginInjectionApi
|
|
152
|
+
}, enableInlineUpgradeFeatures && getAwarenessProps(view.state, getPos, allowEmbeds, allowBlockCards)));
|
|
153
|
+
}
|
|
154
|
+
var getAwarenessProps = function getAwarenessProps(editorState, getPos, allowEmbeds, allowBlockCards) {
|
|
155
|
+
var _editorState$selectio, _editorState$selectio2;
|
|
156
|
+
var linkPosition = getPos && typeof getPos() === 'number' ? getPos() : undefined;
|
|
157
|
+
var canBeUpgradedToEmbed = !!linkPosition && allowEmbeds ? (0, _utils.isEmbedSupportedAtPosition)(linkPosition, editorState, 'inline') : false;
|
|
158
|
+
var canBeUpgradedToBlock = !!linkPosition && allowBlockCards ? (0, _utils.isBlockSupportedAtPosition)(linkPosition, editorState, 'inline') : false;
|
|
159
|
+
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();
|
|
160
|
+
return {
|
|
161
|
+
isPulseEnabled: canBeUpgradedToEmbed,
|
|
162
|
+
isOverlayEnabled: canBeUpgradedToEmbed || canBeUpgradedToBlock,
|
|
165
163
|
isSelected: isSelected
|
|
166
|
-
}
|
|
167
|
-
}
|
|
164
|
+
};
|
|
165
|
+
};
|
|
@@ -1,35 +1,21 @@
|
|
|
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
|
});
|
|
7
8
|
exports.InlineCardWithAwareness = void 0;
|
|
8
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
-
var _react = require("react");
|
|
10
|
-
var _react2 = require("@emotion/react");
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
12
|
-
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
13
12
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
14
13
|
var _smartCard = require("@atlaskit/smart-card");
|
|
15
|
-
var _useLinkUpgradeDiscoverability = _interopRequireDefault(require("../common/hooks/useLinkUpgradeDiscoverability"));
|
|
16
|
-
var _localStorage = require("../common/local-storage");
|
|
17
|
-
var _pulse = require("../common/pulse");
|
|
18
14
|
var _actions = require("../pm-plugins/actions");
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// editor adds a standard line-height that is bigger than an inline smart link
|
|
24
|
-
// due to that the link has a bit of white space around it, which doesn't look right when there is pulse around it
|
|
25
|
-
var loaderWrapperStyles = (0, _react2.css)({
|
|
26
|
-
// eslint-disable-next-line @atlaskit/design-system/no-nested-styles
|
|
27
|
-
'.loader-wrapper': {
|
|
28
|
-
lineHeight: 'normal'
|
|
29
|
-
}
|
|
30
|
-
});
|
|
15
|
+
var _AwarenessWrapper = require("../ui/AwarenessWrapper");
|
|
16
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
31
18
|
var InlineCard = function InlineCard(_ref) {
|
|
32
|
-
var _cardContext$value2;
|
|
33
19
|
var node = _ref.node,
|
|
34
20
|
cardContext = _ref.cardContext,
|
|
35
21
|
showServerActions = _ref.showServerActions,
|
|
@@ -44,8 +30,6 @@ var InlineCard = function InlineCard(_ref) {
|
|
|
44
30
|
var _node$attrs = node.attrs,
|
|
45
31
|
url = _node$attrs.url,
|
|
46
32
|
data = _node$attrs.data;
|
|
47
|
-
|
|
48
|
-
// BEGIN: Awareness (To be revisited in EDM-8508)
|
|
49
33
|
var _useState = (0, _react.useState)(false),
|
|
50
34
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
51
35
|
isHovered = _useState2[0],
|
|
@@ -58,33 +42,6 @@ var InlineCard = function InlineCard(_ref) {
|
|
|
58
42
|
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
59
43
|
isResolvedViewRendered = _useState6[0],
|
|
60
44
|
setIsResolvedViewRendered = _useState6[1];
|
|
61
|
-
var linkPosition = (0, _react.useMemo)(function () {
|
|
62
|
-
if (!getPos || typeof getPos === 'boolean') {
|
|
63
|
-
return undefined;
|
|
64
|
-
}
|
|
65
|
-
var pos = getPos();
|
|
66
|
-
return typeof pos === 'number' ? pos : undefined;
|
|
67
|
-
}, [getPos]);
|
|
68
|
-
var _useLinkUpgradeDiscov = (0, _useLinkUpgradeDiscoverability.default)({
|
|
69
|
-
url: url,
|
|
70
|
-
linkPosition: linkPosition || -1,
|
|
71
|
-
cardContext: cardContext === null || cardContext === void 0 ? void 0 : cardContext.value,
|
|
72
|
-
pluginInjectionApi: pluginInjectionApi,
|
|
73
|
-
isOverlayEnabled: isOverlayEnabled,
|
|
74
|
-
isPulseEnabled: isPulseEnabled
|
|
75
|
-
}),
|
|
76
|
-
shouldShowLinkPulse = _useLinkUpgradeDiscov.shouldShowLinkPulse,
|
|
77
|
-
shouldShowToolbarPulse = _useLinkUpgradeDiscov.shouldShowToolbarPulse,
|
|
78
|
-
shouldShowLinkOverlay = _useLinkUpgradeDiscov.shouldShowLinkOverlay,
|
|
79
|
-
isLinkMostRecentlyInserted = _useLinkUpgradeDiscov.isLinkMostRecentlyInserted;
|
|
80
|
-
|
|
81
|
-
// If the toolbar pulse has not yet been invalidated and this is a case where we will be showing it,
|
|
82
|
-
// we need to invalidate the link pulse too. Toolbar pulse will be invalidated in the corresponding component.
|
|
83
|
-
if (isSelected && shouldShowToolbarPulse && !(0, _localStorage.isLocalStorageKeyDiscovered)(_localStorage.LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR)) {
|
|
84
|
-
(0, _localStorage.markLocalStorageKeyDiscovered)(_localStorage.LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK);
|
|
85
|
-
}
|
|
86
|
-
// END: Awareness
|
|
87
|
-
|
|
88
45
|
var scrollContainer = (0, _react.useMemo)(function () {
|
|
89
46
|
return (0, _ui.findOverflowScrollParent)(view.dom) || undefined;
|
|
90
47
|
}, [view.dom]);
|
|
@@ -116,8 +73,7 @@ var InlineCard = function InlineCard(_ref) {
|
|
|
116
73
|
if (title) {
|
|
117
74
|
setIsResolvedViewRendered(true);
|
|
118
75
|
}
|
|
119
|
-
|
|
120
|
-
}, [view, getPos, isLinkMostRecentlyInserted]);
|
|
76
|
+
}, [view, getPos]);
|
|
121
77
|
var onError = (0, _react.useCallback)(function (data) {
|
|
122
78
|
var url = data.url,
|
|
123
79
|
err = data.err;
|
|
@@ -128,8 +84,22 @@ var InlineCard = function InlineCard(_ref) {
|
|
|
128
84
|
url: url
|
|
129
85
|
});
|
|
130
86
|
}, [onResolve]);
|
|
87
|
+
|
|
88
|
+
// Begin Upgrade Awareness related code
|
|
89
|
+
var markMostRecentlyInsertedLink = (0, _react.useCallback)(function (isLinkMostRecentlyInserted) {
|
|
90
|
+
if (isOverlayEnabled) {
|
|
91
|
+
setIsInserted(isLinkMostRecentlyInserted);
|
|
92
|
+
}
|
|
93
|
+
}, [isOverlayEnabled]);
|
|
94
|
+
var setOverlayHoveredStyles = (0, _react.useCallback)(function (isHovered) {
|
|
95
|
+
if (isOverlayEnabled) {
|
|
96
|
+
setIsHovered(isHovered);
|
|
97
|
+
}
|
|
98
|
+
}, [isOverlayEnabled]);
|
|
99
|
+
// End Upgrade Awareness related code
|
|
100
|
+
|
|
131
101
|
var innerCard = (0, _react.useMemo)(function () {
|
|
132
|
-
return
|
|
102
|
+
return /*#__PURE__*/_react.default.createElement(_smartCard.Card, {
|
|
133
103
|
key: url,
|
|
134
104
|
url: url,
|
|
135
105
|
data: data,
|
|
@@ -143,41 +113,28 @@ var InlineCard = function InlineCard(_ref) {
|
|
|
143
113
|
isHovered: isHovered
|
|
144
114
|
});
|
|
145
115
|
}, [data, isHovered, onError, onResolve, scrollContainer, showServerActions, url, useAlternativePreloader]);
|
|
146
|
-
|
|
147
|
-
// BEGIN: Awareness (To be revisited in EDM-8508)
|
|
148
|
-
var cardWithOverlay = (0, _react.useMemo)(function () {
|
|
149
|
-
return shouldShowLinkOverlay ? (0, _react2.jsx)(_InlineCardOverlay.default, {
|
|
150
|
-
isSelected: isSelected,
|
|
151
|
-
isVisible: isResolvedViewRendered && (isInserted || isHovered || isSelected),
|
|
152
|
-
onMouseEnter: function onMouseEnter() {
|
|
153
|
-
return setIsHovered(true);
|
|
154
|
-
},
|
|
155
|
-
onMouseLeave: function onMouseLeave() {
|
|
156
|
-
return setIsHovered(false);
|
|
157
|
-
},
|
|
158
|
-
url: url
|
|
159
|
-
}, innerCard) : innerCard;
|
|
160
|
-
}, [innerCard, isHovered, isResolvedViewRendered, isSelected, isInserted, shouldShowLinkOverlay, url]);
|
|
161
116
|
var card = (0, _react.useMemo)(function () {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
117
|
+
return isOverlayEnabled || isPulseEnabled ? /*#__PURE__*/_react.default.createElement(_AwarenessWrapper.AwarenessWrapper, {
|
|
118
|
+
isOverlayEnabled: isOverlayEnabled,
|
|
119
|
+
isPulseEnabled: isPulseEnabled,
|
|
120
|
+
cardContext: cardContext,
|
|
121
|
+
getPos: getPos,
|
|
122
|
+
isHovered: isHovered,
|
|
123
|
+
isInserted: isInserted,
|
|
124
|
+
url: url,
|
|
125
|
+
isSelected: isSelected,
|
|
126
|
+
isResolvedViewRendered: isResolvedViewRendered,
|
|
127
|
+
markMostRecentlyInsertedLink: markMostRecentlyInsertedLink,
|
|
128
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
129
|
+
setOverlayHoveredStyles: setOverlayHoveredStyles
|
|
130
|
+
}, innerCard) : /*#__PURE__*/_react.default.createElement("span", {
|
|
165
131
|
className: "card"
|
|
166
|
-
},
|
|
167
|
-
|
|
168
|
-
attributes: (0, _utils.getResolvedAttributesFromStore)(url, 'inline', cardContext === null || cardContext === void 0 || (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.store)
|
|
169
|
-
}
|
|
170
|
-
}, (0, _react2.jsx)(_pulse.DiscoveryPulse, {
|
|
171
|
-
localStorageKey: _localStorage.LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK,
|
|
172
|
-
localStorageKeyExpirationInMs: _localStorage.ONE_DAY_IN_MILLISECONDS,
|
|
173
|
-
discoveryMode: "start"
|
|
174
|
-
}, cardWithOverlay)) : cardWithOverlay);
|
|
175
|
-
}, [shouldShowLinkPulse, cardWithOverlay, url, cardContext === null || cardContext === void 0 || (_cardContext$value2 = cardContext.value) === null || _cardContext$value2 === void 0 ? void 0 : _cardContext$value2.store]);
|
|
176
|
-
// END: Awareness
|
|
132
|
+
}, innerCard);
|
|
133
|
+
}, [cardContext, getPos, innerCard, isHovered, isInserted, isOverlayEnabled, isPulseEnabled, isResolvedViewRendered, isSelected, markMostRecentlyInsertedLink, pluginInjectionApi, setOverlayHoveredStyles, url]);
|
|
177
134
|
|
|
178
135
|
// [WS-2307]: we only render card wrapped into a Provider when the value is ready,
|
|
179
136
|
// otherwise if we got data, we can render the card directly since it doesn't need the Provider
|
|
180
|
-
return cardContext && cardContext.value ?
|
|
137
|
+
return cardContext && cardContext.value ? /*#__PURE__*/_react.default.createElement(cardContext.Provider, {
|
|
181
138
|
value: cardContext.value
|
|
182
139
|
}, card) : data ? card : null;
|
|
183
140
|
};
|
|
@@ -60,6 +60,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
|
|
|
60
60
|
allowEmbeds = options.allowEmbeds,
|
|
61
61
|
allowBlockCards = options.allowBlockCards;
|
|
62
62
|
var enableInlineUpgradeFeatures = !!showUpgradeDiscoverability && platform !== 'mobile';
|
|
63
|
+
var shouldUseUpgradeFeatures = (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.inline-switcher') && enableInlineUpgradeFeatures;
|
|
63
64
|
var inlineCardViewProducer = (0, _reactNodeView.getInlineNodeViewProducer)({
|
|
64
65
|
pmPluginFactoryParams: pmPluginFactoryParams,
|
|
65
66
|
Component: _inlineCard.InlineCardNodeView,
|
|
@@ -103,7 +104,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
|
|
|
103
104
|
if (!meta) {
|
|
104
105
|
return pluginStateWithUpdatedPos;
|
|
105
106
|
}
|
|
106
|
-
if (!
|
|
107
|
+
if (!shouldUseUpgradeFeatures) {
|
|
107
108
|
return (0, _reducers.default)(pluginStateWithUpdatedPos, meta);
|
|
108
109
|
}
|
|
109
110
|
var newState = (0, _reducers.default)(pluginStateWithUpdatedPos, meta);
|
|
@@ -111,7 +112,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
|
|
|
111
112
|
// the code below is related to the "Inline Switcher" project, for more information pls see EDM-7984
|
|
112
113
|
var isSingleInlineLink = (pluginState === null || pluginState === void 0 || (_pluginState$requests = pluginState.requests) === null || _pluginState$requests === void 0 ? void 0 : _pluginState$requests.length) === 1 && pluginState.requests[0].appearance === 'inline';
|
|
113
114
|
var isSmartLinkPulseDiscovered = (0, _localStorage.isLocalStorageKeyDiscovered)(LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK);
|
|
114
|
-
if (meta.type !== 'RESOLVE' || !
|
|
115
|
+
if (meta.type !== 'RESOLVE' || !isSingleInlineLink) {
|
|
115
116
|
return newState;
|
|
116
117
|
}
|
|
117
118
|
var linkPosition = pluginState.requests[0].pos;
|
|
@@ -253,7 +254,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
|
|
|
253
254
|
return new _embedCard.EmbedCard(node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, undefined, true, undefined, hasIntlContext).init();
|
|
254
255
|
}
|
|
255
256
|
}
|
|
256
|
-
},
|
|
257
|
+
}, shouldUseUpgradeFeatures && {
|
|
257
258
|
handleKeyDown: function handleKeyDown(view) {
|
|
258
259
|
handleAwarenessOverlay(view);
|
|
259
260
|
return false;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.AwarenessWrapper = void 0;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var _react2 = require("@emotion/react");
|
|
11
|
+
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
12
|
+
var _useLinkUpgradeDiscoverability = _interopRequireDefault(require("../../common/hooks/useLinkUpgradeDiscoverability"));
|
|
13
|
+
var _localStorage = require("../../common/local-storage");
|
|
14
|
+
var _utils = require("../../utils");
|
|
15
|
+
var _InlineCardOverlay = _interopRequireDefault(require("../InlineCardOverlay"));
|
|
16
|
+
var _Pulse = require("../Pulse");
|
|
17
|
+
/** @jsx jsx */
|
|
18
|
+
|
|
19
|
+
// editor adds a standard line-height that is bigger than an inline smart link
|
|
20
|
+
// due to that the link has a bit of white space around it, which doesn't look right when there is pulse around it
|
|
21
|
+
var loaderWrapperStyles = (0, _react2.css)({
|
|
22
|
+
// eslint-disable-next-line @atlaskit/design-system/no-nested-styles
|
|
23
|
+
'.loader-wrapper': {
|
|
24
|
+
lineHeight: 'normal'
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
var AwarenessWrapper = exports.AwarenessWrapper = function AwarenessWrapper(_ref) {
|
|
28
|
+
var _cardContext$value2;
|
|
29
|
+
var cardContext = _ref.cardContext,
|
|
30
|
+
children = _ref.children,
|
|
31
|
+
getPos = _ref.getPos,
|
|
32
|
+
isInserted = _ref.isInserted,
|
|
33
|
+
isOverlayEnabled = _ref.isOverlayEnabled,
|
|
34
|
+
isSelected = _ref.isSelected,
|
|
35
|
+
isResolvedViewRendered = _ref.isResolvedViewRendered,
|
|
36
|
+
isPulseEnabled = _ref.isPulseEnabled,
|
|
37
|
+
markMostRecentlyInsertedLink = _ref.markMostRecentlyInsertedLink,
|
|
38
|
+
pluginInjectionApi = _ref.pluginInjectionApi,
|
|
39
|
+
setOverlayHoveredStyles = _ref.setOverlayHoveredStyles,
|
|
40
|
+
url = _ref.url;
|
|
41
|
+
var _useState = (0, _react.useState)(false),
|
|
42
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
43
|
+
isHovered = _useState2[0],
|
|
44
|
+
setIsHovered = _useState2[1];
|
|
45
|
+
var linkPosition = (0, _react.useMemo)(function () {
|
|
46
|
+
if (!getPos || typeof getPos === 'boolean') {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
var pos = getPos();
|
|
50
|
+
return typeof pos === 'number' ? pos : undefined;
|
|
51
|
+
}, [getPos]);
|
|
52
|
+
var _useLinkUpgradeDiscov = (0, _useLinkUpgradeDiscoverability.default)({
|
|
53
|
+
url: url,
|
|
54
|
+
linkPosition: linkPosition || -1,
|
|
55
|
+
cardContext: cardContext === null || cardContext === void 0 ? void 0 : cardContext.value,
|
|
56
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
57
|
+
isOverlayEnabled: isOverlayEnabled,
|
|
58
|
+
isPulseEnabled: isPulseEnabled
|
|
59
|
+
}),
|
|
60
|
+
shouldShowLinkPulse = _useLinkUpgradeDiscov.shouldShowLinkPulse,
|
|
61
|
+
shouldShowToolbarPulse = _useLinkUpgradeDiscov.shouldShowToolbarPulse,
|
|
62
|
+
shouldShowLinkOverlay = _useLinkUpgradeDiscov.shouldShowLinkOverlay,
|
|
63
|
+
isLinkMostRecentlyInserted = _useLinkUpgradeDiscov.isLinkMostRecentlyInserted;
|
|
64
|
+
|
|
65
|
+
// If the toolbar pulse has not yet been invalidated and this is a case where we will be showing it,
|
|
66
|
+
// we need to invalidate the link pulse too. Toolbar pulse will be invalidated in the corresponding component.
|
|
67
|
+
if (isSelected && shouldShowToolbarPulse && !(0, _localStorage.isLocalStorageKeyDiscovered)(_localStorage.LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR)) {
|
|
68
|
+
(0, _localStorage.markLocalStorageKeyDiscovered)(_localStorage.LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK);
|
|
69
|
+
}
|
|
70
|
+
(0, _react.useEffect)(function () {
|
|
71
|
+
if (shouldShowLinkOverlay && isLinkMostRecentlyInserted) {
|
|
72
|
+
markMostRecentlyInsertedLink(true);
|
|
73
|
+
}
|
|
74
|
+
}, [isLinkMostRecentlyInserted, markMostRecentlyInsertedLink, shouldShowLinkOverlay]);
|
|
75
|
+
var handleOverlayChange = (0, _react.useCallback)(function (isHovered) {
|
|
76
|
+
setIsHovered(isHovered);
|
|
77
|
+
setOverlayHoveredStyles(isHovered);
|
|
78
|
+
}, [setOverlayHoveredStyles]);
|
|
79
|
+
var cardWithOverlay = (0, _react.useMemo)(function () {
|
|
80
|
+
return shouldShowLinkOverlay ? (0, _react2.jsx)(_InlineCardOverlay.default, {
|
|
81
|
+
isSelected: isSelected,
|
|
82
|
+
isVisible: isResolvedViewRendered && (isInserted || isHovered || isSelected),
|
|
83
|
+
onMouseEnter: function onMouseEnter() {
|
|
84
|
+
return handleOverlayChange(true);
|
|
85
|
+
},
|
|
86
|
+
onMouseLeave: function onMouseLeave() {
|
|
87
|
+
return handleOverlayChange(false);
|
|
88
|
+
},
|
|
89
|
+
url: url
|
|
90
|
+
}, children) : children;
|
|
91
|
+
}, [shouldShowLinkOverlay, isSelected, isResolvedViewRendered, isInserted, isHovered, url, children, handleOverlayChange]);
|
|
92
|
+
return (0, _react.useMemo)(function () {
|
|
93
|
+
var _cardContext$value;
|
|
94
|
+
return (0, _react2.jsx)("span", {
|
|
95
|
+
css: shouldShowLinkPulse && loaderWrapperStyles,
|
|
96
|
+
className: "card"
|
|
97
|
+
}, shouldShowLinkPulse ? (0, _react2.jsx)(_analyticsNext.AnalyticsContext, {
|
|
98
|
+
data: {
|
|
99
|
+
attributes: (0, _utils.getResolvedAttributesFromStore)(url, 'inline', cardContext === null || cardContext === void 0 || (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.store)
|
|
100
|
+
}
|
|
101
|
+
}, (0, _react2.jsx)(_Pulse.DiscoveryPulse, {
|
|
102
|
+
localStorageKey: _localStorage.LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK,
|
|
103
|
+
localStorageKeyExpirationInMs: _localStorage.ONE_DAY_IN_MILLISECONDS,
|
|
104
|
+
discoveryMode: "start"
|
|
105
|
+
}, cardWithOverlay)) : cardWithOverlay);
|
|
106
|
+
}, [shouldShowLinkPulse, url, cardContext === null || cardContext === void 0 || (_cardContext$value2 = cardContext.value) === null || _cardContext$value2 === void 0 ? void 0 : _cardContext$value2.store, cardWithOverlay]);
|
|
107
|
+
};
|
|
@@ -25,7 +25,10 @@ var withHistoryMethod = function withHistoryMethod(fn) {
|
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
27
|
var getMethod = exports.getMethod = withHistoryMethod(function (_ref) {
|
|
28
|
-
var
|
|
28
|
+
var _inputMethod, _payload;
|
|
29
|
+
var inputMethod = _ref.inputMethod,
|
|
30
|
+
sourceEvent = _ref.sourceEvent;
|
|
31
|
+
inputMethod = (_inputMethod = inputMethod) !== null && _inputMethod !== void 0 ? _inputMethod : sourceEvent === null || sourceEvent === void 0 || (_payload = sourceEvent.payload) === null || _payload === void 0 || (_payload = _payload.attributes) === null || _payload === void 0 ? void 0 : _payload.inputMethod;
|
|
29
32
|
switch (inputMethod) {
|
|
30
33
|
case _analytics.INPUT_METHOD.CLIPBOARD:
|
|
31
34
|
return 'editor_paste';
|
|
@@ -38,6 +41,8 @@ var getMethod = exports.getMethod = withHistoryMethod(function (_ref) {
|
|
|
38
41
|
return 'linkpicker_searchResult';
|
|
39
42
|
case _analytics.INPUT_METHOD.MANUAL:
|
|
40
43
|
return 'linkpicker_manual';
|
|
44
|
+
case _analytics.INPUT_METHOD.DATASOURCE:
|
|
45
|
+
return 'datasource_config';
|
|
41
46
|
default:
|
|
42
47
|
return 'unknown';
|
|
43
48
|
}
|
|
@@ -22,9 +22,9 @@ var _messages = _interopRequireWildcard(require("@atlaskit/editor-common/message
|
|
|
22
22
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
23
23
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
24
24
|
var _localStorage = require("../common/local-storage");
|
|
25
|
-
var _pulse = require("../common/pulse");
|
|
26
25
|
var _toolbar = require("../toolbar");
|
|
27
26
|
var _utils2 = require("../utils");
|
|
27
|
+
var _Pulse = require("./Pulse");
|
|
28
28
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
29
29
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
30
30
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -134,7 +134,7 @@ var LinkToolbarAppearance = exports.LinkToolbarAppearance = /*#__PURE__*/functio
|
|
|
134
134
|
data: {
|
|
135
135
|
attributes: _objectSpread({}, resolvedAnalyticsAttributes)
|
|
136
136
|
}
|
|
137
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
137
|
+
}, /*#__PURE__*/_react.default.createElement(_Pulse.DiscoveryPulse, {
|
|
138
138
|
localStorageKey: _localStorage.LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR
|
|
139
139
|
}, LinkToolbarButtons));
|
|
140
140
|
}
|
|
@@ -8,7 +8,7 @@ exports.DiscoveryPulse = void 0;
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
10
10
|
var _linkingCommon = require("@atlaskit/linking-common");
|
|
11
|
-
var _localStorage = require("
|
|
11
|
+
var _localStorage = require("../../common/local-storage");
|
|
12
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
13
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
14
|
var DiscoveryPulse = exports.DiscoveryPulse = function DiscoveryPulse(_ref) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import PropTypes from 'prop-types';
|
|
@@ -103,7 +104,6 @@ _defineProperty(InlineCardComponent, "contextTypes", {
|
|
|
103
104
|
const WrappedInlineCard = Card(InlineCardComponent, UnsupportedInline);
|
|
104
105
|
const WrappedInlineCardWithAwareness = Card(InlineCardWithAwareness, UnsupportedInline);
|
|
105
106
|
export function InlineCardNodeView(props) {
|
|
106
|
-
var _view$state$selection, _view$state$selection2, _view$state$selection3;
|
|
107
107
|
const {
|
|
108
108
|
useAlternativePreloader,
|
|
109
109
|
node,
|
|
@@ -124,26 +124,24 @@ export function InlineCardNodeView(props) {
|
|
|
124
124
|
useAlternativePreloader: useAlternativePreloader
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
|
-
|
|
128
|
-
// BEGIN: Awareness (To be revisited in EDM-8508)
|
|
129
|
-
const editorState = view.state;
|
|
130
|
-
const linkPosition = getPos && typeof getPos() === 'number' ? getPos() : undefined;
|
|
131
|
-
const canBeUpgradedToEmbed = !!linkPosition && allowEmbeds ? isEmbedSupportedAtPosition(linkPosition, editorState, 'inline') : false;
|
|
132
|
-
const canBeUpgradedToBlock = !!linkPosition && allowBlockCards ? isBlockSupportedAtPosition(linkPosition, editorState, 'inline') : false;
|
|
133
|
-
const isPulseEnabled = enableInlineUpgradeFeatures && canBeUpgradedToEmbed;
|
|
134
|
-
const isOverlayEnabled = enableInlineUpgradeFeatures && (canBeUpgradedToEmbed || canBeUpgradedToBlock);
|
|
135
|
-
const isSelected = view.state.selection instanceof NodeSelection && ((_view$state$selection = view.state.selection) === null || _view$state$selection === void 0 ? void 0 : (_view$state$selection2 = _view$state$selection.node) === null || _view$state$selection2 === void 0 ? void 0 : _view$state$selection2.type) === view.state.schema.nodes.inlineCard && ((_view$state$selection3 = view.state.selection) === null || _view$state$selection3 === void 0 ? void 0 : _view$state$selection3.from) === getPos();
|
|
136
|
-
// END: Awareness
|
|
137
|
-
|
|
138
|
-
return /*#__PURE__*/React.createElement(WrappedInlineCardWithAwareness, {
|
|
127
|
+
return /*#__PURE__*/React.createElement(WrappedInlineCardWithAwareness, _extends({
|
|
139
128
|
node: node,
|
|
140
129
|
view: view,
|
|
141
130
|
getPos: getPos,
|
|
142
131
|
showServerActions: showServerActions,
|
|
143
132
|
useAlternativePreloader: useAlternativePreloader,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
133
|
+
pluginInjectionApi: pluginInjectionApi
|
|
134
|
+
}, enableInlineUpgradeFeatures && getAwarenessProps(view.state, getPos, allowEmbeds, allowBlockCards)));
|
|
135
|
+
}
|
|
136
|
+
const getAwarenessProps = (editorState, getPos, allowEmbeds, allowBlockCards) => {
|
|
137
|
+
var _editorState$selectio, _editorState$selectio2, _editorState$selectio3;
|
|
138
|
+
const linkPosition = getPos && typeof getPos() === 'number' ? getPos() : undefined;
|
|
139
|
+
const canBeUpgradedToEmbed = !!linkPosition && allowEmbeds ? isEmbedSupportedAtPosition(linkPosition, editorState, 'inline') : false;
|
|
140
|
+
const canBeUpgradedToBlock = !!linkPosition && allowBlockCards ? isBlockSupportedAtPosition(linkPosition, editorState, 'inline') : false;
|
|
141
|
+
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();
|
|
142
|
+
return {
|
|
143
|
+
isPulseEnabled: canBeUpgradedToEmbed,
|
|
144
|
+
isOverlayEnabled: canBeUpgradedToEmbed || canBeUpgradedToBlock,
|
|
145
|
+
isSelected
|
|
146
|
+
};
|
|
147
|
+
};
|