@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
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
3
3
|
import { css, jsx } from '@emotion/react';
|
|
4
4
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
5
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import useLinkUpgradeDiscoverability from '../../common/hooks/useLinkUpgradeDiscoverability';
|
|
6
7
|
import { isLocalStorageKeyDiscovered, LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK, LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR, markLocalStorageKeyDiscovered, ONE_DAY_IN_MILLISECONDS } from '../../common/local-storage';
|
|
7
8
|
import { getResolvedAttributesFromStore } from '../../utils';
|
|
8
9
|
import InlineCardOverlay from '../InlineCardOverlay';
|
|
10
|
+
import NewInlineCardOverlay from '../NewInlineCardOverlay';
|
|
9
11
|
import { DiscoveryPulse } from '../Pulse';
|
|
10
12
|
// editor adds a standard line-height that is bigger than an inline smart link
|
|
11
13
|
// due to that the link has a bit of white space around it, which doesn't look right when there is pulse around it
|
|
@@ -66,13 +68,27 @@ export const AwarenessWrapper = ({
|
|
|
66
68
|
setIsHovered(isHovered);
|
|
67
69
|
setOverlayHoveredStyles(isHovered);
|
|
68
70
|
}, [setOverlayHoveredStyles]);
|
|
69
|
-
const cardWithOverlay = useMemo(() =>
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
const cardWithOverlay = useMemo(() => {
|
|
72
|
+
if (shouldShowLinkOverlay) {
|
|
73
|
+
if (getBooleanFF('platform.linking-platform.smart-links-in-live-pages')) {
|
|
74
|
+
return jsx(NewInlineCardOverlay, {
|
|
75
|
+
isSelected: isSelected,
|
|
76
|
+
isVisible: isResolvedViewRendered && (isInserted || isHovered || isSelected),
|
|
77
|
+
onMouseEnter: () => handleOverlayChange(true),
|
|
78
|
+
onMouseLeave: () => handleOverlayChange(false),
|
|
79
|
+
url: url
|
|
80
|
+
}, children);
|
|
81
|
+
}
|
|
82
|
+
return jsx(InlineCardOverlay, {
|
|
83
|
+
isSelected: isSelected,
|
|
84
|
+
isVisible: isResolvedViewRendered && (isInserted || isHovered || isSelected),
|
|
85
|
+
onMouseEnter: () => handleOverlayChange(true),
|
|
86
|
+
onMouseLeave: () => handleOverlayChange(false),
|
|
87
|
+
url: url
|
|
88
|
+
}, children);
|
|
89
|
+
}
|
|
90
|
+
return children;
|
|
91
|
+
}, [shouldShowLinkOverlay, isSelected, isResolvedViewRendered, isInserted, isHovered, url, children, handleOverlayChange]);
|
|
76
92
|
return useMemo(() => {
|
|
77
93
|
var _cardContext$value;
|
|
78
94
|
return jsx("span", {
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/* eslint-disable @atlaskit/design-system/no-nested-styles */
|
|
3
|
+
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
4
|
+
/** @jsx jsx */
|
|
5
|
+
import React, { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
6
|
+
import { css, jsx } from '@emotion/react';
|
|
7
|
+
import debounce from 'lodash/debounce';
|
|
8
|
+
import { useIntl } from 'react-intl-next';
|
|
9
|
+
import { cardMessages as messages } from '@atlaskit/editor-common/messages';
|
|
10
|
+
import { ZERO_WIDTH_JOINER } from '@atlaskit/editor-common/utils';
|
|
11
|
+
import PreferencesIcon from '@atlaskit/icon/glyph/preferences';
|
|
12
|
+
import { B100, N0, N700 } from '@atlaskit/theme/colors';
|
|
13
|
+
import { getChildElement, getIconSize, getInlineCardAvailableWidth, getOverlayWidths, isOneLine } from '../InlineCardOverlay/utils';
|
|
14
|
+
const DEBOUNCE_IN_MS = 5;
|
|
15
|
+
const ESTIMATED_MIN_WIDTH_IN_PX = 16;
|
|
16
|
+
const PADDING_IN_PX = 4;
|
|
17
|
+
const ICON_WIDTH_IN_PX = 14;
|
|
18
|
+
const ICON_AND_LABEL_CLASSNAME = 'ak-editor-card-overlay-icon-and-label';
|
|
19
|
+
const OVERLAY_LABEL_CLASSNAME = 'ak-editor-card-overlay-label';
|
|
20
|
+
const OVERLAY_MARKER_CLASSNAME = 'ak-editor-card-overlay-marker';
|
|
21
|
+
const TEXT_NODE_SELECTOR = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].join(',');
|
|
22
|
+
const SMART_LINK_BACKGROUND_COLOR = `var(--ds-surface-raised, ${N0})`;
|
|
23
|
+
// TODO: This should be lighter to match the rest of the button
|
|
24
|
+
const SMART_LINK_ACTIVE_COLOR = `var(--ds-background-selected, ${B100})`;
|
|
25
|
+
const containerStyles = css({
|
|
26
|
+
position: 'relative',
|
|
27
|
+
lineHeight: 'normal',
|
|
28
|
+
':active': {
|
|
29
|
+
[`.${ICON_AND_LABEL_CLASSNAME}`]: {
|
|
30
|
+
background: SMART_LINK_ACTIVE_COLOR
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const overlayStyles = css({
|
|
35
|
+
// Set default styling to be invisible but available in dom for width calculation.
|
|
36
|
+
visibility: 'hidden',
|
|
37
|
+
marginTop: "var(--ds-space-050, 4px)",
|
|
38
|
+
position: 'absolute',
|
|
39
|
+
verticalAlign: 'text-top',
|
|
40
|
+
height: '1lh',
|
|
41
|
+
'@supports not (height: 1lh)': {
|
|
42
|
+
height: '1.2em'
|
|
43
|
+
},
|
|
44
|
+
overflow: 'hidden',
|
|
45
|
+
// EDM-1717: box-shadow Safari fix bring load wrapper zIndex to 1
|
|
46
|
+
zIndex: 2,
|
|
47
|
+
pointerEvents: 'none'
|
|
48
|
+
});
|
|
49
|
+
const showOverlayStyles = css({
|
|
50
|
+
visibility: 'visible'
|
|
51
|
+
});
|
|
52
|
+
const iconStyles = css({
|
|
53
|
+
// Position icon in the middle
|
|
54
|
+
span: {
|
|
55
|
+
display: 'flex'
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const labelStyles = css({
|
|
59
|
+
fontSize: '0.875em',
|
|
60
|
+
fontWeight: '600',
|
|
61
|
+
width: 'max-content'
|
|
62
|
+
});
|
|
63
|
+
const iconAndLabelStyles = css({
|
|
64
|
+
display: 'flex',
|
|
65
|
+
alignItems: 'center',
|
|
66
|
+
height: '100%',
|
|
67
|
+
marginLeft: "var(--ds-space-050, 4px)",
|
|
68
|
+
marginRight: "var(--ds-space-025, 2px)",
|
|
69
|
+
background: SMART_LINK_BACKGROUND_COLOR,
|
|
70
|
+
color: `var(--ds-text-subtlest, ${N700})`
|
|
71
|
+
});
|
|
72
|
+
const overflowingContainerStyles = css({
|
|
73
|
+
display: 'flex',
|
|
74
|
+
flexDirection: 'row-reverse',
|
|
75
|
+
alignItems: 'center',
|
|
76
|
+
width: 'max-content',
|
|
77
|
+
height: '100%'
|
|
78
|
+
});
|
|
79
|
+
const NarrowInlineCardOverlay = ({
|
|
80
|
+
children,
|
|
81
|
+
isSelected = false,
|
|
82
|
+
isVisible = false,
|
|
83
|
+
testId = 'inline-card-overlay',
|
|
84
|
+
url,
|
|
85
|
+
...props
|
|
86
|
+
}) => {
|
|
87
|
+
const [showOverlay, setShowOverlay] = useState(false);
|
|
88
|
+
const [availableWidth, setAvailableWidth] = useState(undefined);
|
|
89
|
+
const maxOverlayWidth = useRef(0);
|
|
90
|
+
const minOverlayWidth = useRef(ESTIMATED_MIN_WIDTH_IN_PX);
|
|
91
|
+
const parentWidth = useRef(0);
|
|
92
|
+
const iconSize = useRef('small');
|
|
93
|
+
const containerRef = useRef(null);
|
|
94
|
+
|
|
95
|
+
// TODO EDM-9843: Use availableWidth for small link edge case
|
|
96
|
+
availableWidth;
|
|
97
|
+
const setVisibility = useCallback(() => {
|
|
98
|
+
if (!containerRef.current || !maxOverlayWidth.current) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const marker = getChildElement(containerRef, `.${OVERLAY_MARKER_CLASSNAME}`);
|
|
102
|
+
if (!marker) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
const oneLine = isOneLine(containerRef.current, marker);
|
|
107
|
+
|
|
108
|
+
// Get the width of the available space to display overlay.
|
|
109
|
+
// This is the width of the inline link itself. If the inline
|
|
110
|
+
// is wrapped to the next line, this is width of the last line.
|
|
111
|
+
const availableWidth = getInlineCardAvailableWidth(containerRef.current, marker) - PADDING_IN_PX - (
|
|
112
|
+
// Always leave at least the icon visible
|
|
113
|
+
oneLine ? ICON_WIDTH_IN_PX + PADDING_IN_PX : 0);
|
|
114
|
+
setAvailableWidth(availableWidth);
|
|
115
|
+
const canShowOverlay = !isSelected;
|
|
116
|
+
setShowOverlay(canShowOverlay);
|
|
117
|
+
} catch {
|
|
118
|
+
// If something goes wrong, hide the overlay all together.
|
|
119
|
+
setShowOverlay(false);
|
|
120
|
+
}
|
|
121
|
+
}, [isSelected]);
|
|
122
|
+
useLayoutEffect(() => {
|
|
123
|
+
// Using useLayoutEffect here.
|
|
124
|
+
// 1) We want all to be able to determine whether to display label before
|
|
125
|
+
// the overlay becomes visible.
|
|
126
|
+
// 2) We need to wait for the refs to be assigned to be able to do determine
|
|
127
|
+
// the width of the overlay.
|
|
128
|
+
if (!containerRef.current) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// This should run only once
|
|
133
|
+
if (!maxOverlayWidth.current) {
|
|
134
|
+
const iconAndLabel = getChildElement(containerRef, `.${ICON_AND_LABEL_CLASSNAME}`);
|
|
135
|
+
const label = getChildElement(containerRef, `.${OVERLAY_LABEL_CLASSNAME}`);
|
|
136
|
+
if (iconAndLabel && label) {
|
|
137
|
+
// Set overlay max (label + icon) and min (icon only) width.
|
|
138
|
+
const {
|
|
139
|
+
max,
|
|
140
|
+
min
|
|
141
|
+
} = getOverlayWidths(iconAndLabel, label);
|
|
142
|
+
maxOverlayWidth.current = max;
|
|
143
|
+
minOverlayWidth.current = min;
|
|
144
|
+
iconSize.current = getIconSize(label);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (isVisible) {
|
|
148
|
+
setVisibility();
|
|
149
|
+
}
|
|
150
|
+
}, [setVisibility, isVisible]);
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
var _containerRef$current;
|
|
153
|
+
// Find the closest block parent to observe size change
|
|
154
|
+
const parent = containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.closest(TEXT_NODE_SELECTOR);
|
|
155
|
+
if (!parent) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const updateOverlay = debounce(entries => {
|
|
159
|
+
var _entries$, _entries$$contentBoxS, _entries$$contentBoxS2;
|
|
160
|
+
if (!isVisible) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const size = entries === null || entries === void 0 ? void 0 : (_entries$ = entries[0]) === null || _entries$ === void 0 ? void 0 : (_entries$$contentBoxS = _entries$.contentBoxSize) === null || _entries$$contentBoxS === void 0 ? void 0 : (_entries$$contentBoxS2 = _entries$$contentBoxS[0]) === null || _entries$$contentBoxS2 === void 0 ? void 0 : _entries$$contentBoxS2.inlineSize;
|
|
164
|
+
if (!size) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (!parentWidth.current) {
|
|
168
|
+
parentWidth.current = size;
|
|
169
|
+
}
|
|
170
|
+
if (parentWidth.current === size) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
parentWidth.current = size;
|
|
174
|
+
setVisibility();
|
|
175
|
+
}, DEBOUNCE_IN_MS);
|
|
176
|
+
const observer = new ResizeObserver(updateOverlay);
|
|
177
|
+
observer.observe(parent);
|
|
178
|
+
return () => {
|
|
179
|
+
observer.disconnect();
|
|
180
|
+
};
|
|
181
|
+
}, [isVisible, setVisibility]);
|
|
182
|
+
const intl = useIntl();
|
|
183
|
+
const label = intl.formatMessage(messages.inlineOverlay);
|
|
184
|
+
return jsx("span", _extends({}, props, {
|
|
185
|
+
css: containerStyles,
|
|
186
|
+
ref: containerRef
|
|
187
|
+
}), isVisible && jsx(React.Fragment, null, jsx("span", {
|
|
188
|
+
"aria-hidden": "true",
|
|
189
|
+
className: OVERLAY_MARKER_CLASSNAME
|
|
190
|
+
}, ZERO_WIDTH_JOINER), jsx("a", {
|
|
191
|
+
css: [overlayStyles, showOverlay && showOverlayStyles],
|
|
192
|
+
"data-testid": testId,
|
|
193
|
+
href: url,
|
|
194
|
+
onClick: e => e.preventDefault(),
|
|
195
|
+
tabIndex: -1
|
|
196
|
+
}, jsx("span", {
|
|
197
|
+
css: overflowingContainerStyles
|
|
198
|
+
}, jsx("span", {
|
|
199
|
+
css: iconAndLabelStyles,
|
|
200
|
+
className: ICON_AND_LABEL_CLASSNAME
|
|
201
|
+
}, jsx("span", {
|
|
202
|
+
css: iconStyles
|
|
203
|
+
}, jsx(PreferencesIcon, {
|
|
204
|
+
label: label,
|
|
205
|
+
size: iconSize.current,
|
|
206
|
+
testId: `${testId}-icon`
|
|
207
|
+
})), jsx("span", {
|
|
208
|
+
css: labelStyles,
|
|
209
|
+
className: OVERLAY_LABEL_CLASSNAME,
|
|
210
|
+
"data-testid": `${testId}-label`
|
|
211
|
+
}))))), children);
|
|
212
|
+
};
|
|
213
|
+
export default NarrowInlineCardOverlay;
|
|
@@ -1,122 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
11
2
|
import React from 'react';
|
|
12
|
-
import
|
|
13
|
-
import rafSchedule from 'raf-schd';
|
|
14
|
-
import { findOverflowScrollParent, UnsupportedInline } from '@atlaskit/editor-common/ui';
|
|
3
|
+
import { UnsupportedInline } from '@atlaskit/editor-common/ui';
|
|
15
4
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
16
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
17
|
-
import { Card as SmartCard } from '@atlaskit/smart-card';
|
|
18
|
-
import { registerCard } from '../pm-plugins/actions';
|
|
19
5
|
import { isBlockSupportedAtPosition, isEmbedSupportedAtPosition } from '../utils';
|
|
20
6
|
import { Card } from './genericCard';
|
|
21
7
|
import { InlineCardWithAwareness } from './inlineCardWithAwareness';
|
|
22
|
-
|
|
23
|
-
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
24
|
-
export var InlineCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
25
|
-
_inherits(InlineCardComponent, _React$PureComponent);
|
|
26
|
-
var _super = _createSuper(InlineCardComponent);
|
|
27
|
-
function InlineCardComponent() {
|
|
28
|
-
var _this;
|
|
29
|
-
_classCallCheck(this, InlineCardComponent);
|
|
30
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
31
|
-
args[_key] = arguments[_key];
|
|
32
|
-
}
|
|
33
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
34
|
-
_defineProperty(_assertThisInitialized(_this), "onResolve", function (data) {
|
|
35
|
-
var _this$props = _this.props,
|
|
36
|
-
getPos = _this$props.getPos,
|
|
37
|
-
view = _this$props.view;
|
|
38
|
-
if (!getPos || typeof getPos === 'boolean') {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
var title = data.title,
|
|
42
|
-
url = data.url;
|
|
43
|
-
// don't dispatch immediately since we might be in the middle of
|
|
44
|
-
// rendering a nodeview
|
|
45
|
-
rafSchedule(function () {
|
|
46
|
-
// prosemirror-bump-fix
|
|
47
|
-
var pos = getPos();
|
|
48
|
-
if (typeof pos !== 'number') {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
var tr = view.state.tr;
|
|
52
|
-
registerCard({
|
|
53
|
-
title: title,
|
|
54
|
-
url: url,
|
|
55
|
-
pos: pos
|
|
56
|
-
})(tr);
|
|
57
|
-
view.dispatch(tr);
|
|
58
|
-
})();
|
|
59
|
-
});
|
|
60
|
-
_defineProperty(_assertThisInitialized(_this), "onError", function (data) {
|
|
61
|
-
var url = data.url,
|
|
62
|
-
err = data.err;
|
|
63
|
-
if (err) {
|
|
64
|
-
throw err;
|
|
65
|
-
}
|
|
66
|
-
_this.onResolve({
|
|
67
|
-
url: url
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
return _this;
|
|
71
|
-
}
|
|
72
|
-
_createClass(InlineCardComponent, [{
|
|
73
|
-
key: "UNSAFE_componentWillMount",
|
|
74
|
-
value: function UNSAFE_componentWillMount() {
|
|
75
|
-
var view = this.props.view;
|
|
76
|
-
var scrollContainer = findOverflowScrollParent(view.dom);
|
|
77
|
-
this.scrollContainer = scrollContainer || undefined;
|
|
78
|
-
}
|
|
79
|
-
}, {
|
|
80
|
-
key: "render",
|
|
81
|
-
value: function render() {
|
|
82
|
-
var _this$props2 = this.props,
|
|
83
|
-
node = _this$props2.node,
|
|
84
|
-
cardContext = _this$props2.cardContext,
|
|
85
|
-
actionOptions = _this$props2.actionOptions,
|
|
86
|
-
showServerActions = _this$props2.showServerActions,
|
|
87
|
-
useAlternativePreloader = _this$props2.useAlternativePreloader,
|
|
88
|
-
onClick = _this$props2.onClick;
|
|
89
|
-
var _node$attrs = node.attrs,
|
|
90
|
-
url = _node$attrs.url,
|
|
91
|
-
data = _node$attrs.data;
|
|
92
|
-
var card = /*#__PURE__*/React.createElement("span", {
|
|
93
|
-
className: "card"
|
|
94
|
-
}, /*#__PURE__*/React.createElement(SmartCard, {
|
|
95
|
-
key: url,
|
|
96
|
-
url: url,
|
|
97
|
-
data: data,
|
|
98
|
-
appearance: "inline",
|
|
99
|
-
onClick: onClick,
|
|
100
|
-
container: this.scrollContainer,
|
|
101
|
-
onResolve: this.onResolve,
|
|
102
|
-
onError: this.onError,
|
|
103
|
-
inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
|
|
104
|
-
actionOptions: actionOptions,
|
|
105
|
-
showServerActions: showServerActions
|
|
106
|
-
}));
|
|
107
|
-
// [WS-2307]: we only render card wrapped into a Provider when the value is ready,
|
|
108
|
-
// otherwise if we got data, we can render the card directly since it doesn't need the Provider
|
|
109
|
-
return cardContext && cardContext.value ? /*#__PURE__*/React.createElement(cardContext.Provider, {
|
|
110
|
-
value: cardContext.value
|
|
111
|
-
}, card) : data ? card : null;
|
|
112
|
-
}
|
|
113
|
-
}]);
|
|
114
|
-
return InlineCardComponent;
|
|
115
|
-
}(React.PureComponent);
|
|
116
|
-
_defineProperty(InlineCardComponent, "contextTypes", {
|
|
117
|
-
contextAdapter: PropTypes.object
|
|
118
|
-
});
|
|
119
|
-
var WrappedInlineCard = Card(InlineCardComponent, UnsupportedInline);
|
|
120
8
|
var WrappedInlineCardWithAwareness = Card(InlineCardWithAwareness, UnsupportedInline);
|
|
121
9
|
export function InlineCardNodeView(props) {
|
|
122
10
|
var useAlternativePreloader = props.useAlternativePreloader,
|
|
@@ -130,18 +18,6 @@ export function InlineCardNodeView(props) {
|
|
|
130
18
|
enableInlineUpgradeFeatures = props.enableInlineUpgradeFeatures,
|
|
131
19
|
pluginInjectionApi = props.pluginInjectionApi,
|
|
132
20
|
onClickCallback = props.onClickCallback;
|
|
133
|
-
if (!getBooleanFF('platform.linking-platform.smart-card.inline-switcher')) {
|
|
134
|
-
return /*#__PURE__*/React.createElement(WrappedInlineCard, {
|
|
135
|
-
node: node,
|
|
136
|
-
view: view,
|
|
137
|
-
getPos: getPos,
|
|
138
|
-
actionOptions: actionOptions,
|
|
139
|
-
showServerActions: showServerActions,
|
|
140
|
-
useAlternativePreloader: useAlternativePreloader,
|
|
141
|
-
pluginInjectionApi: pluginInjectionApi,
|
|
142
|
-
onClickCallback: onClickCallback
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
21
|
return /*#__PURE__*/React.createElement(WrappedInlineCardWithAwareness, _extends({
|
|
146
22
|
node: node,
|
|
147
23
|
view: view,
|
|
@@ -50,7 +50,6 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
|
|
|
50
50
|
allowBlockCards = options.allowBlockCards,
|
|
51
51
|
onClickCallback = options.onClickCallback;
|
|
52
52
|
var enableInlineUpgradeFeatures = !!showUpgradeDiscoverability && platform !== 'mobile';
|
|
53
|
-
var shouldUseUpgradeFeatures = getBooleanFF('platform.linking-platform.smart-card.inline-switcher') && enableInlineUpgradeFeatures;
|
|
54
53
|
var inlineCardViewProducer = getInlineNodeViewProducer({
|
|
55
54
|
pmPluginFactoryParams: pmPluginFactoryParams,
|
|
56
55
|
Component: InlineCardNodeView,
|
|
@@ -107,7 +106,7 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
|
|
|
107
106
|
if (!meta) {
|
|
108
107
|
return pluginStateWithUpdatedPos;
|
|
109
108
|
}
|
|
110
|
-
if (!
|
|
109
|
+
if (!enableInlineUpgradeFeatures) {
|
|
111
110
|
return reducer(pluginStateWithUpdatedPos, meta);
|
|
112
111
|
}
|
|
113
112
|
var newState = reducer(pluginStateWithUpdatedPos, meta);
|
|
@@ -271,7 +270,7 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
|
|
|
271
270
|
return new EmbedCard(node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, undefined, true, undefined, hasIntlContext).init();
|
|
272
271
|
}
|
|
273
272
|
}
|
|
274
|
-
},
|
|
273
|
+
}, enableInlineUpgradeFeatures && {
|
|
275
274
|
handleKeyDown: function handleKeyDown(view) {
|
|
276
275
|
handleAwarenessOverlay(view);
|
|
277
276
|
return false;
|
package/dist/esm/toolbar.js
CHANGED
|
@@ -484,5 +484,5 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
|
|
|
484
484
|
return toolbarItems;
|
|
485
485
|
};
|
|
486
486
|
export var shouldRenderToolbarPulse = function shouldRenderToolbarPulse(embedEnabled, appearance, status, isDiscoverabilityEnabled) {
|
|
487
|
-
return embedEnabled && appearance === 'inline' && status === 'resolved' && isDiscoverabilityEnabled
|
|
487
|
+
return embedEnabled && appearance === 'inline' && status === 'resolved' && isDiscoverabilityEnabled;
|
|
488
488
|
};
|
|
@@ -3,10 +3,12 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
3
3
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
4
4
|
import { css, jsx } from '@emotion/react';
|
|
5
5
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
6
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import useLinkUpgradeDiscoverability from '../../common/hooks/useLinkUpgradeDiscoverability';
|
|
7
8
|
import { isLocalStorageKeyDiscovered, LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK, LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR, markLocalStorageKeyDiscovered, ONE_DAY_IN_MILLISECONDS } from '../../common/local-storage';
|
|
8
9
|
import { getResolvedAttributesFromStore } from '../../utils';
|
|
9
10
|
import InlineCardOverlay from '../InlineCardOverlay';
|
|
11
|
+
import NewInlineCardOverlay from '../NewInlineCardOverlay';
|
|
10
12
|
import { DiscoveryPulse } from '../Pulse';
|
|
11
13
|
// editor adds a standard line-height that is bigger than an inline smart link
|
|
12
14
|
// due to that the link has a bit of white space around it, which doesn't look right when there is pulse around it
|
|
@@ -69,17 +71,33 @@ export var AwarenessWrapper = function AwarenessWrapper(_ref) {
|
|
|
69
71
|
setOverlayHoveredStyles(isHovered);
|
|
70
72
|
}, [setOverlayHoveredStyles]);
|
|
71
73
|
var cardWithOverlay = useMemo(function () {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
74
|
+
if (shouldShowLinkOverlay) {
|
|
75
|
+
if (getBooleanFF('platform.linking-platform.smart-links-in-live-pages')) {
|
|
76
|
+
return jsx(NewInlineCardOverlay, {
|
|
77
|
+
isSelected: isSelected,
|
|
78
|
+
isVisible: isResolvedViewRendered && (isInserted || isHovered || isSelected),
|
|
79
|
+
onMouseEnter: function onMouseEnter() {
|
|
80
|
+
return handleOverlayChange(true);
|
|
81
|
+
},
|
|
82
|
+
onMouseLeave: function onMouseLeave() {
|
|
83
|
+
return handleOverlayChange(false);
|
|
84
|
+
},
|
|
85
|
+
url: url
|
|
86
|
+
}, children);
|
|
87
|
+
}
|
|
88
|
+
return jsx(InlineCardOverlay, {
|
|
89
|
+
isSelected: isSelected,
|
|
90
|
+
isVisible: isResolvedViewRendered && (isInserted || isHovered || isSelected),
|
|
91
|
+
onMouseEnter: function onMouseEnter() {
|
|
92
|
+
return handleOverlayChange(true);
|
|
93
|
+
},
|
|
94
|
+
onMouseLeave: function onMouseLeave() {
|
|
95
|
+
return handleOverlayChange(false);
|
|
96
|
+
},
|
|
97
|
+
url: url
|
|
98
|
+
}, children);
|
|
99
|
+
}
|
|
100
|
+
return children;
|
|
83
101
|
}, [shouldShowLinkOverlay, isSelected, isResolvedViewRendered, isInserted, isHovered, url, children, handleOverlayChange]);
|
|
84
102
|
return useMemo(function () {
|
|
85
103
|
var _cardContext$value;
|