@atlaskit/editor-plugin-card 1.12.1 → 1.14.0
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 +22 -0
- package/dist/cjs/nodeviews/inlineCard.js +0 -124
- package/dist/cjs/pm-plugins/main.js +2 -3
- package/dist/cjs/toolbar.js +1 -1
- package/dist/cjs/ui/AwarenessWrapper/index.js +29 -11
- package/dist/cjs/ui/NewInlineCardOverlay/index.js +234 -0
- package/dist/es2019/nodeviews/inlineCard.js +1 -112
- package/dist/es2019/pm-plugins/main.js +2 -3
- package/dist/es2019/toolbar.js +1 -1
- package/dist/es2019/ui/AwarenessWrapper/index.js +23 -7
- package/dist/es2019/ui/NewInlineCardOverlay/index.js +213 -0
- package/dist/esm/nodeviews/inlineCard.js +1 -125
- package/dist/esm/pm-plugins/main.js +2 -3
- package/dist/esm/toolbar.js +1 -1
- package/dist/esm/ui/AwarenessWrapper/index.js +29 -11
- package/dist/esm/ui/NewInlineCardOverlay/index.js +224 -0
- package/dist/types/nodeviews/inlineCard.d.ts +1 -18
- package/dist/types/ui/NewInlineCardOverlay/index.d.ts +6 -0
- package/dist/types-ts4.5/nodeviews/inlineCard.d.ts +1 -18
- package/dist/types-ts4.5/ui/NewInlineCardOverlay/index.d.ts +6 -0
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-card
|
|
2
2
|
|
|
3
|
+
## 1.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#100627](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/100627)
|
|
8
|
+
[`619f85adfe8b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/619f85adfe8b) -
|
|
9
|
+
EDM-9852 Add initial inline link overlay for live pages support
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#101524](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/101524)
|
|
14
|
+
[`4821570088e6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4821570088e6) -
|
|
15
|
+
ED-23362 Bump ADF schema to version 36.8.1 and add support for adf validation and transformation
|
|
16
|
+
|
|
17
|
+
## 1.13.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- [#98528](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/98528)
|
|
22
|
+
[`12181f0bfaed`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/12181f0bfaed) -
|
|
23
|
+
EDM-9252 Removal of platform.linking-platform.smart-card.inline-switcher
|
|
24
|
+
|
|
3
25
|
## 1.12.1
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -4,126 +4,14 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.InlineCardComponent = void 0;
|
|
8
7
|
exports.InlineCardNodeView = InlineCardNodeView;
|
|
9
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
13
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
14
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
15
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
16
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
9
|
var _react = _interopRequireDefault(require("react"));
|
|
18
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
19
|
-
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
20
10
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
21
11
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
22
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
23
|
-
var _smartCard = require("@atlaskit/smart-card");
|
|
24
|
-
var _actions = require("../pm-plugins/actions");
|
|
25
12
|
var _utils = require("../utils");
|
|
26
13
|
var _genericCard = require("./genericCard");
|
|
27
14
|
var _inlineCardWithAwareness = require("./inlineCardWithAwareness");
|
|
28
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
29
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
30
|
-
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
31
|
-
var InlineCardComponent = exports.InlineCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
32
|
-
(0, _inherits2.default)(InlineCardComponent, _React$PureComponent);
|
|
33
|
-
var _super = _createSuper(InlineCardComponent);
|
|
34
|
-
function InlineCardComponent() {
|
|
35
|
-
var _this;
|
|
36
|
-
(0, _classCallCheck2.default)(this, InlineCardComponent);
|
|
37
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
38
|
-
args[_key] = arguments[_key];
|
|
39
|
-
}
|
|
40
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
41
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onResolve", function (data) {
|
|
42
|
-
var _this$props = _this.props,
|
|
43
|
-
getPos = _this$props.getPos,
|
|
44
|
-
view = _this$props.view;
|
|
45
|
-
if (!getPos || typeof getPos === 'boolean') {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
var title = data.title,
|
|
49
|
-
url = data.url;
|
|
50
|
-
// don't dispatch immediately since we might be in the middle of
|
|
51
|
-
// rendering a nodeview
|
|
52
|
-
(0, _rafSchd.default)(function () {
|
|
53
|
-
// prosemirror-bump-fix
|
|
54
|
-
var pos = getPos();
|
|
55
|
-
if (typeof pos !== 'number') {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
var tr = view.state.tr;
|
|
59
|
-
(0, _actions.registerCard)({
|
|
60
|
-
title: title,
|
|
61
|
-
url: url,
|
|
62
|
-
pos: pos
|
|
63
|
-
})(tr);
|
|
64
|
-
view.dispatch(tr);
|
|
65
|
-
})();
|
|
66
|
-
});
|
|
67
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onError", function (data) {
|
|
68
|
-
var url = data.url,
|
|
69
|
-
err = data.err;
|
|
70
|
-
if (err) {
|
|
71
|
-
throw err;
|
|
72
|
-
}
|
|
73
|
-
_this.onResolve({
|
|
74
|
-
url: url
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
return _this;
|
|
78
|
-
}
|
|
79
|
-
(0, _createClass2.default)(InlineCardComponent, [{
|
|
80
|
-
key: "UNSAFE_componentWillMount",
|
|
81
|
-
value: function UNSAFE_componentWillMount() {
|
|
82
|
-
var view = this.props.view;
|
|
83
|
-
var scrollContainer = (0, _ui.findOverflowScrollParent)(view.dom);
|
|
84
|
-
this.scrollContainer = scrollContainer || undefined;
|
|
85
|
-
}
|
|
86
|
-
}, {
|
|
87
|
-
key: "render",
|
|
88
|
-
value: function render() {
|
|
89
|
-
var _this$props2 = this.props,
|
|
90
|
-
node = _this$props2.node,
|
|
91
|
-
cardContext = _this$props2.cardContext,
|
|
92
|
-
actionOptions = _this$props2.actionOptions,
|
|
93
|
-
showServerActions = _this$props2.showServerActions,
|
|
94
|
-
useAlternativePreloader = _this$props2.useAlternativePreloader,
|
|
95
|
-
onClick = _this$props2.onClick;
|
|
96
|
-
var _node$attrs = node.attrs,
|
|
97
|
-
url = _node$attrs.url,
|
|
98
|
-
data = _node$attrs.data;
|
|
99
|
-
var card = /*#__PURE__*/_react.default.createElement("span", {
|
|
100
|
-
className: "card"
|
|
101
|
-
}, /*#__PURE__*/_react.default.createElement(_smartCard.Card, {
|
|
102
|
-
key: url,
|
|
103
|
-
url: url,
|
|
104
|
-
data: data,
|
|
105
|
-
appearance: "inline",
|
|
106
|
-
onClick: onClick,
|
|
107
|
-
container: this.scrollContainer,
|
|
108
|
-
onResolve: this.onResolve,
|
|
109
|
-
onError: this.onError,
|
|
110
|
-
inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
|
|
111
|
-
actionOptions: actionOptions,
|
|
112
|
-
showServerActions: showServerActions
|
|
113
|
-
}));
|
|
114
|
-
// [WS-2307]: we only render card wrapped into a Provider when the value is ready,
|
|
115
|
-
// otherwise if we got data, we can render the card directly since it doesn't need the Provider
|
|
116
|
-
return cardContext && cardContext.value ? /*#__PURE__*/_react.default.createElement(cardContext.Provider, {
|
|
117
|
-
value: cardContext.value
|
|
118
|
-
}, card) : data ? card : null;
|
|
119
|
-
}
|
|
120
|
-
}]);
|
|
121
|
-
return InlineCardComponent;
|
|
122
|
-
}(_react.default.PureComponent);
|
|
123
|
-
(0, _defineProperty2.default)(InlineCardComponent, "contextTypes", {
|
|
124
|
-
contextAdapter: _propTypes.default.object
|
|
125
|
-
});
|
|
126
|
-
var WrappedInlineCard = (0, _genericCard.Card)(InlineCardComponent, _ui.UnsupportedInline);
|
|
127
15
|
var WrappedInlineCardWithAwareness = (0, _genericCard.Card)(_inlineCardWithAwareness.InlineCardWithAwareness, _ui.UnsupportedInline);
|
|
128
16
|
function InlineCardNodeView(props) {
|
|
129
17
|
var useAlternativePreloader = props.useAlternativePreloader,
|
|
@@ -137,18 +25,6 @@ function InlineCardNodeView(props) {
|
|
|
137
25
|
enableInlineUpgradeFeatures = props.enableInlineUpgradeFeatures,
|
|
138
26
|
pluginInjectionApi = props.pluginInjectionApi,
|
|
139
27
|
onClickCallback = props.onClickCallback;
|
|
140
|
-
if (!(0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.inline-switcher')) {
|
|
141
|
-
return /*#__PURE__*/_react.default.createElement(WrappedInlineCard, {
|
|
142
|
-
node: node,
|
|
143
|
-
view: view,
|
|
144
|
-
getPos: getPos,
|
|
145
|
-
actionOptions: actionOptions,
|
|
146
|
-
showServerActions: showServerActions,
|
|
147
|
-
useAlternativePreloader: useAlternativePreloader,
|
|
148
|
-
pluginInjectionApi: pluginInjectionApi,
|
|
149
|
-
onClickCallback: onClickCallback
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
28
|
return /*#__PURE__*/_react.default.createElement(WrappedInlineCardWithAwareness, (0, _extends2.default)({
|
|
153
29
|
node: node,
|
|
154
30
|
view: view,
|
|
@@ -62,7 +62,6 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
|
|
|
62
62
|
allowBlockCards = options.allowBlockCards,
|
|
63
63
|
onClickCallback = options.onClickCallback;
|
|
64
64
|
var enableInlineUpgradeFeatures = !!showUpgradeDiscoverability && platform !== 'mobile';
|
|
65
|
-
var shouldUseUpgradeFeatures = (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.inline-switcher') && enableInlineUpgradeFeatures;
|
|
66
65
|
var inlineCardViewProducer = (0, _reactNodeView.getInlineNodeViewProducer)({
|
|
67
66
|
pmPluginFactoryParams: pmPluginFactoryParams,
|
|
68
67
|
Component: _inlineCard.InlineCardNodeView,
|
|
@@ -119,7 +118,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
|
|
|
119
118
|
if (!meta) {
|
|
120
119
|
return pluginStateWithUpdatedPos;
|
|
121
120
|
}
|
|
122
|
-
if (!
|
|
121
|
+
if (!enableInlineUpgradeFeatures) {
|
|
123
122
|
return (0, _reducers.default)(pluginStateWithUpdatedPos, meta);
|
|
124
123
|
}
|
|
125
124
|
var newState = (0, _reducers.default)(pluginStateWithUpdatedPos, meta);
|
|
@@ -283,7 +282,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
|
|
|
283
282
|
return new _embedCard.EmbedCard(node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, undefined, true, undefined, hasIntlContext).init();
|
|
284
283
|
}
|
|
285
284
|
}
|
|
286
|
-
},
|
|
285
|
+
}, enableInlineUpgradeFeatures && {
|
|
287
286
|
handleKeyDown: function handleKeyDown(view) {
|
|
288
287
|
handleAwarenessOverlay(view);
|
|
289
288
|
return false;
|
package/dist/cjs/toolbar.js
CHANGED
|
@@ -494,5 +494,5 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
|
|
|
494
494
|
return toolbarItems;
|
|
495
495
|
};
|
|
496
496
|
var shouldRenderToolbarPulse = exports.shouldRenderToolbarPulse = function shouldRenderToolbarPulse(embedEnabled, appearance, status, isDiscoverabilityEnabled) {
|
|
497
|
-
return embedEnabled && appearance === 'inline' && status === 'resolved' && isDiscoverabilityEnabled
|
|
497
|
+
return embedEnabled && appearance === 'inline' && status === 'resolved' && isDiscoverabilityEnabled;
|
|
498
498
|
};
|
|
@@ -9,10 +9,12 @@ 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");
|
|
12
13
|
var _useLinkUpgradeDiscoverability = _interopRequireDefault(require("../../common/hooks/useLinkUpgradeDiscoverability"));
|
|
13
14
|
var _localStorage = require("../../common/local-storage");
|
|
14
15
|
var _utils = require("../../utils");
|
|
15
16
|
var _InlineCardOverlay = _interopRequireDefault(require("../InlineCardOverlay"));
|
|
17
|
+
var _NewInlineCardOverlay = _interopRequireDefault(require("../NewInlineCardOverlay"));
|
|
16
18
|
var _Pulse = require("../Pulse");
|
|
17
19
|
/** @jsx jsx */
|
|
18
20
|
|
|
@@ -77,17 +79,33 @@ var AwarenessWrapper = exports.AwarenessWrapper = function AwarenessWrapper(_ref
|
|
|
77
79
|
setOverlayHoveredStyles(isHovered);
|
|
78
80
|
}, [setOverlayHoveredStyles]);
|
|
79
81
|
var cardWithOverlay = (0, _react.useMemo)(function () {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
82
|
+
if (shouldShowLinkOverlay) {
|
|
83
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-links-in-live-pages')) {
|
|
84
|
+
return (0, _react2.jsx)(_NewInlineCardOverlay.default, {
|
|
85
|
+
isSelected: isSelected,
|
|
86
|
+
isVisible: isResolvedViewRendered && (isInserted || isHovered || isSelected),
|
|
87
|
+
onMouseEnter: function onMouseEnter() {
|
|
88
|
+
return handleOverlayChange(true);
|
|
89
|
+
},
|
|
90
|
+
onMouseLeave: function onMouseLeave() {
|
|
91
|
+
return handleOverlayChange(false);
|
|
92
|
+
},
|
|
93
|
+
url: url
|
|
94
|
+
}, children);
|
|
95
|
+
}
|
|
96
|
+
return (0, _react2.jsx)(_InlineCardOverlay.default, {
|
|
97
|
+
isSelected: isSelected,
|
|
98
|
+
isVisible: isResolvedViewRendered && (isInserted || isHovered || isSelected),
|
|
99
|
+
onMouseEnter: function onMouseEnter() {
|
|
100
|
+
return handleOverlayChange(true);
|
|
101
|
+
},
|
|
102
|
+
onMouseLeave: function onMouseLeave() {
|
|
103
|
+
return handleOverlayChange(false);
|
|
104
|
+
},
|
|
105
|
+
url: url
|
|
106
|
+
}, children);
|
|
107
|
+
}
|
|
108
|
+
return children;
|
|
91
109
|
}, [shouldShowLinkOverlay, isSelected, isResolvedViewRendered, isInserted, isHovered, url, children, handleOverlayChange]);
|
|
92
110
|
return (0, _react.useMemo)(function () {
|
|
93
111
|
var _cardContext$value;
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
14
|
+
var _react2 = require("@emotion/react");
|
|
15
|
+
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
16
|
+
var _reactIntlNext = require("react-intl-next");
|
|
17
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
18
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
19
|
+
var _preferences = _interopRequireDefault(require("@atlaskit/icon/glyph/preferences"));
|
|
20
|
+
var _colors = require("@atlaskit/theme/colors");
|
|
21
|
+
var _utils2 = require("../InlineCardOverlay/utils");
|
|
22
|
+
var _excluded = ["children", "isSelected", "isVisible", "testId", "url"];
|
|
23
|
+
/* eslint-disable @atlaskit/design-system/no-nested-styles */
|
|
24
|
+
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
25
|
+
/** @jsx jsx */
|
|
26
|
+
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); }
|
|
27
|
+
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; }
|
|
28
|
+
var DEBOUNCE_IN_MS = 5;
|
|
29
|
+
var ESTIMATED_MIN_WIDTH_IN_PX = 16;
|
|
30
|
+
var PADDING_IN_PX = 4;
|
|
31
|
+
var ICON_WIDTH_IN_PX = 14;
|
|
32
|
+
var ICON_AND_LABEL_CLASSNAME = 'ak-editor-card-overlay-icon-and-label';
|
|
33
|
+
var OVERLAY_LABEL_CLASSNAME = 'ak-editor-card-overlay-label';
|
|
34
|
+
var OVERLAY_MARKER_CLASSNAME = 'ak-editor-card-overlay-marker';
|
|
35
|
+
var TEXT_NODE_SELECTOR = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].join(',');
|
|
36
|
+
var SMART_LINK_BACKGROUND_COLOR = "var(--ds-surface-raised, ".concat(_colors.N0, ")");
|
|
37
|
+
// TODO: This should be lighter to match the rest of the button
|
|
38
|
+
var SMART_LINK_ACTIVE_COLOR = "var(--ds-background-selected, ".concat(_colors.B100, ")");
|
|
39
|
+
var containerStyles = (0, _react2.css)({
|
|
40
|
+
position: 'relative',
|
|
41
|
+
lineHeight: 'normal',
|
|
42
|
+
':active': (0, _defineProperty2.default)({}, ".".concat(ICON_AND_LABEL_CLASSNAME), {
|
|
43
|
+
background: SMART_LINK_ACTIVE_COLOR
|
|
44
|
+
})
|
|
45
|
+
});
|
|
46
|
+
var overlayStyles = (0, _react2.css)({
|
|
47
|
+
// Set default styling to be invisible but available in dom for width calculation.
|
|
48
|
+
visibility: 'hidden',
|
|
49
|
+
marginTop: "var(--ds-space-050, 4px)",
|
|
50
|
+
position: 'absolute',
|
|
51
|
+
verticalAlign: 'text-top',
|
|
52
|
+
height: '1lh',
|
|
53
|
+
'@supports not (height: 1lh)': {
|
|
54
|
+
height: '1.2em'
|
|
55
|
+
},
|
|
56
|
+
overflow: 'hidden',
|
|
57
|
+
// EDM-1717: box-shadow Safari fix bring load wrapper zIndex to 1
|
|
58
|
+
zIndex: 2,
|
|
59
|
+
pointerEvents: 'none'
|
|
60
|
+
});
|
|
61
|
+
var showOverlayStyles = (0, _react2.css)({
|
|
62
|
+
visibility: 'visible'
|
|
63
|
+
});
|
|
64
|
+
var iconStyles = (0, _react2.css)({
|
|
65
|
+
// Position icon in the middle
|
|
66
|
+
span: {
|
|
67
|
+
display: 'flex'
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
var labelStyles = (0, _react2.css)({
|
|
71
|
+
fontSize: '0.875em',
|
|
72
|
+
fontWeight: '600',
|
|
73
|
+
width: 'max-content'
|
|
74
|
+
});
|
|
75
|
+
var iconAndLabelStyles = (0, _react2.css)({
|
|
76
|
+
display: 'flex',
|
|
77
|
+
alignItems: 'center',
|
|
78
|
+
height: '100%',
|
|
79
|
+
marginLeft: "var(--ds-space-050, 4px)",
|
|
80
|
+
marginRight: "var(--ds-space-025, 2px)",
|
|
81
|
+
background: SMART_LINK_BACKGROUND_COLOR,
|
|
82
|
+
color: "var(--ds-text-subtlest, ".concat(_colors.N700, ")")
|
|
83
|
+
});
|
|
84
|
+
var overflowingContainerStyles = (0, _react2.css)({
|
|
85
|
+
display: 'flex',
|
|
86
|
+
flexDirection: 'row-reverse',
|
|
87
|
+
alignItems: 'center',
|
|
88
|
+
width: 'max-content',
|
|
89
|
+
height: '100%'
|
|
90
|
+
});
|
|
91
|
+
var NarrowInlineCardOverlay = function NarrowInlineCardOverlay(_ref) {
|
|
92
|
+
var children = _ref.children,
|
|
93
|
+
_ref$isSelected = _ref.isSelected,
|
|
94
|
+
isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
|
|
95
|
+
_ref$isVisible = _ref.isVisible,
|
|
96
|
+
isVisible = _ref$isVisible === void 0 ? false : _ref$isVisible,
|
|
97
|
+
_ref$testId = _ref.testId,
|
|
98
|
+
testId = _ref$testId === void 0 ? 'inline-card-overlay' : _ref$testId,
|
|
99
|
+
url = _ref.url,
|
|
100
|
+
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
101
|
+
var _useState = (0, _react.useState)(false),
|
|
102
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
103
|
+
showOverlay = _useState2[0],
|
|
104
|
+
setShowOverlay = _useState2[1];
|
|
105
|
+
var _useState3 = (0, _react.useState)(undefined),
|
|
106
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
107
|
+
availableWidth = _useState4[0],
|
|
108
|
+
setAvailableWidth = _useState4[1];
|
|
109
|
+
var maxOverlayWidth = (0, _react.useRef)(0);
|
|
110
|
+
var minOverlayWidth = (0, _react.useRef)(ESTIMATED_MIN_WIDTH_IN_PX);
|
|
111
|
+
var parentWidth = (0, _react.useRef)(0);
|
|
112
|
+
var iconSize = (0, _react.useRef)('small');
|
|
113
|
+
var containerRef = (0, _react.useRef)(null);
|
|
114
|
+
|
|
115
|
+
// TODO EDM-9843: Use availableWidth for small link edge case
|
|
116
|
+
availableWidth;
|
|
117
|
+
var setVisibility = (0, _react.useCallback)(function () {
|
|
118
|
+
if (!containerRef.current || !maxOverlayWidth.current) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
var marker = (0, _utils2.getChildElement)(containerRef, ".".concat(OVERLAY_MARKER_CLASSNAME));
|
|
122
|
+
if (!marker) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
try {
|
|
126
|
+
var oneLine = (0, _utils2.isOneLine)(containerRef.current, marker);
|
|
127
|
+
|
|
128
|
+
// Get the width of the available space to display overlay.
|
|
129
|
+
// This is the width of the inline link itself. If the inline
|
|
130
|
+
// is wrapped to the next line, this is width of the last line.
|
|
131
|
+
var _availableWidth = (0, _utils2.getInlineCardAvailableWidth)(containerRef.current, marker) - PADDING_IN_PX - (
|
|
132
|
+
// Always leave at least the icon visible
|
|
133
|
+
oneLine ? ICON_WIDTH_IN_PX + PADDING_IN_PX : 0);
|
|
134
|
+
setAvailableWidth(_availableWidth);
|
|
135
|
+
var canShowOverlay = !isSelected;
|
|
136
|
+
setShowOverlay(canShowOverlay);
|
|
137
|
+
} catch (_unused) {
|
|
138
|
+
// If something goes wrong, hide the overlay all together.
|
|
139
|
+
setShowOverlay(false);
|
|
140
|
+
}
|
|
141
|
+
}, [isSelected]);
|
|
142
|
+
(0, _react.useLayoutEffect)(function () {
|
|
143
|
+
// Using useLayoutEffect here.
|
|
144
|
+
// 1) We want all to be able to determine whether to display label before
|
|
145
|
+
// the overlay becomes visible.
|
|
146
|
+
// 2) We need to wait for the refs to be assigned to be able to do determine
|
|
147
|
+
// the width of the overlay.
|
|
148
|
+
if (!containerRef.current) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// This should run only once
|
|
153
|
+
if (!maxOverlayWidth.current) {
|
|
154
|
+
var iconAndLabel = (0, _utils2.getChildElement)(containerRef, ".".concat(ICON_AND_LABEL_CLASSNAME));
|
|
155
|
+
var _label = (0, _utils2.getChildElement)(containerRef, ".".concat(OVERLAY_LABEL_CLASSNAME));
|
|
156
|
+
if (iconAndLabel && _label) {
|
|
157
|
+
// Set overlay max (label + icon) and min (icon only) width.
|
|
158
|
+
var _getOverlayWidths = (0, _utils2.getOverlayWidths)(iconAndLabel, _label),
|
|
159
|
+
max = _getOverlayWidths.max,
|
|
160
|
+
min = _getOverlayWidths.min;
|
|
161
|
+
maxOverlayWidth.current = max;
|
|
162
|
+
minOverlayWidth.current = min;
|
|
163
|
+
iconSize.current = (0, _utils2.getIconSize)(_label);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (isVisible) {
|
|
167
|
+
setVisibility();
|
|
168
|
+
}
|
|
169
|
+
}, [setVisibility, isVisible]);
|
|
170
|
+
(0, _react.useEffect)(function () {
|
|
171
|
+
var _containerRef$current;
|
|
172
|
+
// Find the closest block parent to observe size change
|
|
173
|
+
var parent = containerRef === null || containerRef === void 0 || (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.closest(TEXT_NODE_SELECTOR);
|
|
174
|
+
if (!parent) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
var updateOverlay = (0, _debounce.default)(function (entries) {
|
|
178
|
+
var _entries$;
|
|
179
|
+
if (!isVisible) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
var size = entries === null || entries === void 0 || (_entries$ = entries[0]) === null || _entries$ === void 0 || (_entries$ = _entries$.contentBoxSize) === null || _entries$ === void 0 || (_entries$ = _entries$[0]) === null || _entries$ === void 0 ? void 0 : _entries$.inlineSize;
|
|
183
|
+
if (!size) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
if (!parentWidth.current) {
|
|
187
|
+
parentWidth.current = size;
|
|
188
|
+
}
|
|
189
|
+
if (parentWidth.current === size) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
parentWidth.current = size;
|
|
193
|
+
setVisibility();
|
|
194
|
+
}, DEBOUNCE_IN_MS);
|
|
195
|
+
var observer = new ResizeObserver(updateOverlay);
|
|
196
|
+
observer.observe(parent);
|
|
197
|
+
return function () {
|
|
198
|
+
observer.disconnect();
|
|
199
|
+
};
|
|
200
|
+
}, [isVisible, setVisibility]);
|
|
201
|
+
var intl = (0, _reactIntlNext.useIntl)();
|
|
202
|
+
var label = intl.formatMessage(_messages.cardMessages.inlineOverlay);
|
|
203
|
+
return (0, _react2.jsx)("span", (0, _extends2.default)({}, props, {
|
|
204
|
+
css: containerStyles,
|
|
205
|
+
ref: containerRef
|
|
206
|
+
}), isVisible && (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)("span", {
|
|
207
|
+
"aria-hidden": "true",
|
|
208
|
+
className: OVERLAY_MARKER_CLASSNAME
|
|
209
|
+
}, _utils.ZERO_WIDTH_JOINER), (0, _react2.jsx)("a", {
|
|
210
|
+
css: [overlayStyles, showOverlay && showOverlayStyles],
|
|
211
|
+
"data-testid": testId,
|
|
212
|
+
href: url,
|
|
213
|
+
onClick: function onClick(e) {
|
|
214
|
+
return e.preventDefault();
|
|
215
|
+
},
|
|
216
|
+
tabIndex: -1
|
|
217
|
+
}, (0, _react2.jsx)("span", {
|
|
218
|
+
css: overflowingContainerStyles
|
|
219
|
+
}, (0, _react2.jsx)("span", {
|
|
220
|
+
css: iconAndLabelStyles,
|
|
221
|
+
className: ICON_AND_LABEL_CLASSNAME
|
|
222
|
+
}, (0, _react2.jsx)("span", {
|
|
223
|
+
css: iconStyles
|
|
224
|
+
}, (0, _react2.jsx)(_preferences.default, {
|
|
225
|
+
label: label,
|
|
226
|
+
size: iconSize.current,
|
|
227
|
+
testId: "".concat(testId, "-icon")
|
|
228
|
+
})), (0, _react2.jsx)("span", {
|
|
229
|
+
css: labelStyles,
|
|
230
|
+
className: OVERLAY_LABEL_CLASSNAME,
|
|
231
|
+
"data-testid": "".concat(testId, "-label")
|
|
232
|
+
}))))), children);
|
|
233
|
+
};
|
|
234
|
+
var _default = exports.default = NarrowInlineCardOverlay;
|
|
@@ -1,109 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
2
|
import React from 'react';
|
|
4
|
-
import
|
|
5
|
-
import rafSchedule from 'raf-schd';
|
|
6
|
-
import { findOverflowScrollParent, UnsupportedInline } from '@atlaskit/editor-common/ui';
|
|
3
|
+
import { UnsupportedInline } from '@atlaskit/editor-common/ui';
|
|
7
4
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
9
|
-
import { Card as SmartCard } from '@atlaskit/smart-card';
|
|
10
|
-
import { registerCard } from '../pm-plugins/actions';
|
|
11
5
|
import { isBlockSupportedAtPosition, isEmbedSupportedAtPosition } from '../utils';
|
|
12
6
|
import { Card } from './genericCard';
|
|
13
7
|
import { InlineCardWithAwareness } from './inlineCardWithAwareness';
|
|
14
|
-
|
|
15
|
-
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
16
|
-
export class InlineCardComponent extends React.PureComponent {
|
|
17
|
-
constructor(...args) {
|
|
18
|
-
super(...args);
|
|
19
|
-
_defineProperty(this, "onResolve", data => {
|
|
20
|
-
const {
|
|
21
|
-
getPos,
|
|
22
|
-
view
|
|
23
|
-
} = this.props;
|
|
24
|
-
if (!getPos || typeof getPos === 'boolean') {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const {
|
|
28
|
-
title,
|
|
29
|
-
url
|
|
30
|
-
} = data;
|
|
31
|
-
// don't dispatch immediately since we might be in the middle of
|
|
32
|
-
// rendering a nodeview
|
|
33
|
-
rafSchedule(() => {
|
|
34
|
-
// prosemirror-bump-fix
|
|
35
|
-
const pos = getPos();
|
|
36
|
-
if (typeof pos !== 'number') {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const tr = view.state.tr;
|
|
40
|
-
registerCard({
|
|
41
|
-
title,
|
|
42
|
-
url,
|
|
43
|
-
pos
|
|
44
|
-
})(tr);
|
|
45
|
-
view.dispatch(tr);
|
|
46
|
-
})();
|
|
47
|
-
});
|
|
48
|
-
_defineProperty(this, "onError", data => {
|
|
49
|
-
const {
|
|
50
|
-
url,
|
|
51
|
-
err
|
|
52
|
-
} = data;
|
|
53
|
-
if (err) {
|
|
54
|
-
throw err;
|
|
55
|
-
}
|
|
56
|
-
this.onResolve({
|
|
57
|
-
url
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
UNSAFE_componentWillMount() {
|
|
62
|
-
const {
|
|
63
|
-
view
|
|
64
|
-
} = this.props;
|
|
65
|
-
const scrollContainer = findOverflowScrollParent(view.dom);
|
|
66
|
-
this.scrollContainer = scrollContainer || undefined;
|
|
67
|
-
}
|
|
68
|
-
render() {
|
|
69
|
-
const {
|
|
70
|
-
node,
|
|
71
|
-
cardContext,
|
|
72
|
-
actionOptions,
|
|
73
|
-
showServerActions,
|
|
74
|
-
useAlternativePreloader,
|
|
75
|
-
onClick
|
|
76
|
-
} = this.props;
|
|
77
|
-
const {
|
|
78
|
-
url,
|
|
79
|
-
data
|
|
80
|
-
} = node.attrs;
|
|
81
|
-
const card = /*#__PURE__*/React.createElement("span", {
|
|
82
|
-
className: "card"
|
|
83
|
-
}, /*#__PURE__*/React.createElement(SmartCard, {
|
|
84
|
-
key: url,
|
|
85
|
-
url: url,
|
|
86
|
-
data: data,
|
|
87
|
-
appearance: "inline",
|
|
88
|
-
onClick: onClick,
|
|
89
|
-
container: this.scrollContainer,
|
|
90
|
-
onResolve: this.onResolve,
|
|
91
|
-
onError: this.onError,
|
|
92
|
-
inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
|
|
93
|
-
actionOptions: actionOptions,
|
|
94
|
-
showServerActions: showServerActions
|
|
95
|
-
}));
|
|
96
|
-
// [WS-2307]: we only render card wrapped into a Provider when the value is ready,
|
|
97
|
-
// otherwise if we got data, we can render the card directly since it doesn't need the Provider
|
|
98
|
-
return cardContext && cardContext.value ? /*#__PURE__*/React.createElement(cardContext.Provider, {
|
|
99
|
-
value: cardContext.value
|
|
100
|
-
}, card) : data ? card : null;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
_defineProperty(InlineCardComponent, "contextTypes", {
|
|
104
|
-
contextAdapter: PropTypes.object
|
|
105
|
-
});
|
|
106
|
-
const WrappedInlineCard = Card(InlineCardComponent, UnsupportedInline);
|
|
107
8
|
const WrappedInlineCardWithAwareness = Card(InlineCardWithAwareness, UnsupportedInline);
|
|
108
9
|
export function InlineCardNodeView(props) {
|
|
109
10
|
const {
|
|
@@ -119,18 +20,6 @@ export function InlineCardNodeView(props) {
|
|
|
119
20
|
pluginInjectionApi,
|
|
120
21
|
onClickCallback
|
|
121
22
|
} = props;
|
|
122
|
-
if (!getBooleanFF('platform.linking-platform.smart-card.inline-switcher')) {
|
|
123
|
-
return /*#__PURE__*/React.createElement(WrappedInlineCard, {
|
|
124
|
-
node: node,
|
|
125
|
-
view: view,
|
|
126
|
-
getPos: getPos,
|
|
127
|
-
actionOptions: actionOptions,
|
|
128
|
-
showServerActions: showServerActions,
|
|
129
|
-
useAlternativePreloader: useAlternativePreloader,
|
|
130
|
-
pluginInjectionApi: pluginInjectionApi,
|
|
131
|
-
onClickCallback: onClickCallback
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
23
|
return /*#__PURE__*/React.createElement(WrappedInlineCardWithAwareness, _extends({
|
|
135
24
|
node: node,
|
|
136
25
|
view: view,
|
|
@@ -47,7 +47,6 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
|
|
|
47
47
|
onClickCallback
|
|
48
48
|
} = options;
|
|
49
49
|
const enableInlineUpgradeFeatures = !!showUpgradeDiscoverability && platform !== 'mobile';
|
|
50
|
-
const shouldUseUpgradeFeatures = getBooleanFF('platform.linking-platform.smart-card.inline-switcher') && enableInlineUpgradeFeatures;
|
|
51
50
|
const inlineCardViewProducer = getInlineNodeViewProducer({
|
|
52
51
|
pmPluginFactoryParams,
|
|
53
52
|
Component: InlineCardNodeView,
|
|
@@ -105,7 +104,7 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
|
|
|
105
104
|
if (!meta) {
|
|
106
105
|
return pluginStateWithUpdatedPos;
|
|
107
106
|
}
|
|
108
|
-
if (!
|
|
107
|
+
if (!enableInlineUpgradeFeatures) {
|
|
109
108
|
return reducer(pluginStateWithUpdatedPos, meta);
|
|
110
109
|
}
|
|
111
110
|
const newState = reducer(pluginStateWithUpdatedPos, meta);
|
|
@@ -277,7 +276,7 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
|
|
|
277
276
|
return new EmbedCard(node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, undefined, true, undefined, hasIntlContext).init();
|
|
278
277
|
}
|
|
279
278
|
},
|
|
280
|
-
...(
|
|
279
|
+
...(enableInlineUpgradeFeatures && {
|
|
281
280
|
handleKeyDown: view => {
|
|
282
281
|
handleAwarenessOverlay(view);
|
|
283
282
|
return false;
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -487,5 +487,5 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
|
|
|
487
487
|
return toolbarItems;
|
|
488
488
|
};
|
|
489
489
|
export const shouldRenderToolbarPulse = (embedEnabled, appearance, status, isDiscoverabilityEnabled) => {
|
|
490
|
-
return embedEnabled && appearance === 'inline' && status === 'resolved' && isDiscoverabilityEnabled
|
|
490
|
+
return embedEnabled && appearance === 'inline' && status === 'resolved' && isDiscoverabilityEnabled;
|
|
491
491
|
};
|