@atlaskit/editor-plugin-card 36.0.18 → 36.0.20
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 +14 -0
- package/package.json +4 -4
- package/dist/cjs/ui/ConfigureOverlay/index.js +0 -69
- package/dist/cjs/ui/InlineCardOverlay/index.js +0 -282
- package/dist/cjs/ui/InlineCardOverlay/types.js +0 -1
- package/dist/cjs/ui/InlineCardOverlay/utils.js +0 -48
- package/dist/es2019/ui/ConfigureOverlay/index.js +0 -55
- package/dist/es2019/ui/InlineCardOverlay/index.js +0 -264
- package/dist/es2019/ui/InlineCardOverlay/types.js +0 -0
- package/dist/es2019/ui/InlineCardOverlay/utils.js +0 -40
- package/dist/esm/ui/ConfigureOverlay/index.js +0 -61
- package/dist/esm/ui/InlineCardOverlay/index.js +0 -275
- package/dist/esm/ui/InlineCardOverlay/types.js +0 -0
- package/dist/esm/ui/InlineCardOverlay/utils.js +0 -42
- package/dist/types/ui/ConfigureOverlay/index.d.ts +0 -11
- package/dist/types/ui/InlineCardOverlay/index.d.ts +0 -9
- package/dist/types/ui/InlineCardOverlay/types.d.ts +0 -6
- package/dist/types/ui/InlineCardOverlay/utils.d.ts +0 -20
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-card
|
|
2
2
|
|
|
3
|
+
## 36.0.20
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`dd3768b8944a6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/dd3768b8944a6) -
|
|
8
|
+
Delete unreachable source files and unused dependencies
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 36.0.19
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 36.0.18
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-card",
|
|
3
|
-
"version": "36.0.
|
|
3
|
+
"version": "36.0.20",
|
|
4
4
|
"description": "Card plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"@atlaskit/editor-plugin-user-intent": "^28.0.0",
|
|
43
43
|
"@atlaskit/editor-plugin-width": "^31.0.0",
|
|
44
44
|
"@atlaskit/editor-prosemirror": "^9.0.0",
|
|
45
|
-
"@atlaskit/editor-shared-styles": "^5.
|
|
45
|
+
"@atlaskit/editor-shared-styles": "^5.1.0",
|
|
46
46
|
"@atlaskit/editor-smart-link-draggable": "^1.2.0",
|
|
47
|
-
"@atlaskit/editor-toolbar": "^2.
|
|
47
|
+
"@atlaskit/editor-toolbar": "^2.10.0",
|
|
48
48
|
"@atlaskit/editor-ui-control-model": "^3.0.0",
|
|
49
49
|
"@atlaskit/frontend-utilities": "^5.1.0",
|
|
50
50
|
"@atlaskit/icon": "^38.0.0",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"@atlaskit/primitives": "^22.6.0",
|
|
64
64
|
"@atlaskit/prosemirror-history": "^1.3.0",
|
|
65
65
|
"@atlaskit/smart-card": "^46.13.0",
|
|
66
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
66
|
+
"@atlaskit/tmp-editor-statsig": "^258.0.0",
|
|
67
67
|
"@atlaskit/tokens": "^20.9.0",
|
|
68
68
|
"@atlaskit/tooltip": "^24.4.0",
|
|
69
69
|
"@babel/runtime": "^7.0.0",
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
-
var _react = require("react");
|
|
10
|
-
var _react2 = require("@emotion/react");
|
|
11
|
-
var _ConfigureLinkOverlay = require("@atlaskit/editor-common/link/ConfigureLinkOverlay");
|
|
12
|
-
/**
|
|
13
|
-
* @jsxRuntime classic
|
|
14
|
-
* @jsx jsx
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
// not permitted to migrate atlaskit packages to compiled yet, see https://hello.atlassian.net/wiki/spaces/UAF/pages/3006969423/Migrating+AFM+platform+components+to+Compiled+a+guide
|
|
18
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports
|
|
19
|
-
|
|
20
|
-
var ConfigureOverlayWrapperStyles = (0, _react2.css)({
|
|
21
|
-
position: 'relative',
|
|
22
|
-
left: "var(--ds-space-025, 2px)"
|
|
23
|
-
});
|
|
24
|
-
var OverlayWrapper = function OverlayWrapper(_ref) {
|
|
25
|
-
var view = _ref.view,
|
|
26
|
-
targetElementPos = _ref.targetElementPos,
|
|
27
|
-
children = _ref.children,
|
|
28
|
-
hoverCallback = _ref.isHoveredCallback,
|
|
29
|
-
onOpenLinkClick = _ref.onOpenLinkClick;
|
|
30
|
-
var _useState = (0, _react.useState)(false),
|
|
31
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
32
|
-
showConfigureButton = _useState2[0],
|
|
33
|
-
setShowConfigureButton = _useState2[1];
|
|
34
|
-
var _useState3 = (0, _react.useState)(false),
|
|
35
|
-
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
36
|
-
dropdownOpen = _useState4[0],
|
|
37
|
-
setDropdownOpen = _useState4[1];
|
|
38
|
-
var onDropdownChange = (0, _react.useCallback)(function (isOpen) {
|
|
39
|
-
setDropdownOpen(isOpen);
|
|
40
|
-
if (!isOpen) {
|
|
41
|
-
setShowConfigureButton(false);
|
|
42
|
-
}
|
|
43
|
-
}, []);
|
|
44
|
-
var showOverlay = (0, _react.useCallback)(function () {
|
|
45
|
-
setShowConfigureButton(true);
|
|
46
|
-
hoverCallback(true);
|
|
47
|
-
}, [hoverCallback]);
|
|
48
|
-
var hideOverlay = (0, _react.useCallback)(function () {
|
|
49
|
-
if (!dropdownOpen) {
|
|
50
|
-
setShowConfigureButton(false);
|
|
51
|
-
hoverCallback(false);
|
|
52
|
-
}
|
|
53
|
-
}, [dropdownOpen, hoverCallback]);
|
|
54
|
-
return (0, _react2.jsx)("span", {
|
|
55
|
-
onMouseEnter: showOverlay,
|
|
56
|
-
onMouseLeave: hideOverlay,
|
|
57
|
-
onFocus: showOverlay,
|
|
58
|
-
onBlur: hideOverlay,
|
|
59
|
-
"data-testid": "inline-card-overlay-wrapper"
|
|
60
|
-
}, (0, _react2.jsx)("span", {
|
|
61
|
-
css: ConfigureOverlayWrapperStyles
|
|
62
|
-
}, showConfigureButton && (0, _react2.jsx)(_ConfigureLinkOverlay.OverlayButton, {
|
|
63
|
-
editorView: view,
|
|
64
|
-
targetElementPos: targetElementPos,
|
|
65
|
-
onDropdownChange: onDropdownChange,
|
|
66
|
-
onOpenLinkClick: onOpenLinkClick
|
|
67
|
-
})), children);
|
|
68
|
-
};
|
|
69
|
-
var _default = exports.default = OverlayWrapper;
|
|
@@ -1,282 +0,0 @@
|
|
|
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 _reactIntl = require("react-intl");
|
|
17
|
-
var _card = require("@atlaskit/editor-common/messages/card");
|
|
18
|
-
var _whitespace = require("@atlaskit/editor-common/whitespace/whitespace");
|
|
19
|
-
var _customize = _interopRequireDefault(require("@atlaskit/icon/core/customize"));
|
|
20
|
-
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
21
|
-
var _useSmartLinkDestinationUrl = require("@atlaskit/smart-card/hook/use-smart-link-destination-url");
|
|
22
|
-
var _utils = require("./utils");
|
|
23
|
-
var _excluded = ["children", "isSelected", "isVisible", "testId", "url"];
|
|
24
|
-
/* eslint-disable @atlaskit/design-system/no-nested-styles */
|
|
25
|
-
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
26
|
-
/**
|
|
27
|
-
* @jsxRuntime classic
|
|
28
|
-
* @jsx jsx
|
|
29
|
-
*/
|
|
30
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports
|
|
31
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
32
|
-
var DEBOUNCE_IN_MS = 5;
|
|
33
|
-
var ESTIMATED_MIN_WIDTH_IN_PX = 16;
|
|
34
|
-
var PADDING_IN_PX = 4;
|
|
35
|
-
var ICON_WIDTH_IN_PX = 14;
|
|
36
|
-
var ICON_AND_LABEL_CLASSNAME = 'ak-editor-card-overlay-icon-and-label';
|
|
37
|
-
var OVERLAY_LABEL_CLASSNAME = 'ak-editor-card-overlay-label';
|
|
38
|
-
var OVERLAY_GRADIENT_CLASSNAME = 'ak-editor-card-overlay-gradient';
|
|
39
|
-
var OVERLAY_MARKER_CLASSNAME = 'ak-editor-card-overlay-marker';
|
|
40
|
-
var TEXT_NODE_SELECTOR = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].join(',');
|
|
41
|
-
var SMART_LINK_BACKGROUND_COLOR = "var(--ds-surface-raised, #FFFFFF)";
|
|
42
|
-
var SMART_LINK_ACTIVE_COLOR = "var(--ds-background-selected, #E9F2FE)";
|
|
43
|
-
var getGradientWithColor = function getGradientWithColor(color) {
|
|
44
|
-
return "linear-gradient(270deg, ".concat(color, " 0%, rgba(255, 255, 255, 0.00) 100%)");
|
|
45
|
-
};
|
|
46
|
-
var containerStyles = (0, _react2.css)({
|
|
47
|
-
position: 'relative',
|
|
48
|
-
// eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
|
|
49
|
-
lineHeight: 'normal',
|
|
50
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
51
|
-
':active': (0, _defineProperty2.default)((0, _defineProperty2.default)({}, ".".concat(ICON_AND_LABEL_CLASSNAME), {
|
|
52
|
-
background: SMART_LINK_ACTIVE_COLOR
|
|
53
|
-
}), ".".concat(OVERLAY_GRADIENT_CLASSNAME), {
|
|
54
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
55
|
-
background: getGradientWithColor(SMART_LINK_ACTIVE_COLOR)
|
|
56
|
-
})
|
|
57
|
-
});
|
|
58
|
-
var overlayStyles = (0, _react2.css)({
|
|
59
|
-
// Set default styling to be invisible but available in dom for width calculation.
|
|
60
|
-
visibility: 'hidden',
|
|
61
|
-
position: 'absolute',
|
|
62
|
-
display: 'inline-flex',
|
|
63
|
-
justifyContent: 'flex-end',
|
|
64
|
-
alignItems: 'center',
|
|
65
|
-
verticalAlign: 'text-top',
|
|
66
|
-
height: '1lh',
|
|
67
|
-
'@supports not (height: 1lh)': {
|
|
68
|
-
height: '1.2em'
|
|
69
|
-
},
|
|
70
|
-
overflow: 'hidden',
|
|
71
|
-
// EDM-1717: box-shadow Safari fix bring load wrapper zIndex to 1
|
|
72
|
-
zIndex: 2,
|
|
73
|
-
pointerEvents: 'none'
|
|
74
|
-
});
|
|
75
|
-
var showOverlayStyles = (0, _react2.css)({
|
|
76
|
-
position: 'relative',
|
|
77
|
-
visibility: 'visible'
|
|
78
|
-
});
|
|
79
|
-
var iconStyles = (0, _react2.css)({
|
|
80
|
-
// Position icon in the middle
|
|
81
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
82
|
-
span: {
|
|
83
|
-
display: 'flex'
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
var labelStyles = (0, _react2.css)({
|
|
87
|
-
font: "var(--ds-font-body, normal 400 14px/20px \"Atlassian Sans\", ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
|
|
88
|
-
fontWeight: "var(--ds-font-weight-semibold, 600)",
|
|
89
|
-
width: 'max-content'
|
|
90
|
-
});
|
|
91
|
-
var iconAndLabelStyles = (0, _react2.css)({
|
|
92
|
-
display: 'flex',
|
|
93
|
-
alignItems: 'center',
|
|
94
|
-
height: '100%',
|
|
95
|
-
gap: "var(--ds-space-050, 4px)",
|
|
96
|
-
paddingRight: "var(--ds-space-050, 4px)",
|
|
97
|
-
// Margin to avoid the background covering the link border
|
|
98
|
-
marginRight: "var(--ds-space-025, 2px)",
|
|
99
|
-
background: SMART_LINK_BACKGROUND_COLOR,
|
|
100
|
-
color: "var(--ds-text-subtlest, #6B6E76)"
|
|
101
|
-
});
|
|
102
|
-
var overflowingContainerStyles = (0, _react2.css)({
|
|
103
|
-
display: 'flex',
|
|
104
|
-
flexDirection: 'row-reverse',
|
|
105
|
-
alignItems: 'center',
|
|
106
|
-
width: 'max-content',
|
|
107
|
-
height: '100%'
|
|
108
|
-
});
|
|
109
|
-
var gradientStyles = (0, _react2.css)({
|
|
110
|
-
width: '2.5rem',
|
|
111
|
-
height: '100%',
|
|
112
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
113
|
-
background: getGradientWithColor(SMART_LINK_BACKGROUND_COLOR)
|
|
114
|
-
});
|
|
115
|
-
var InlineCardOverlay = function InlineCardOverlay(_ref) {
|
|
116
|
-
var _useSmartLinkDestinat;
|
|
117
|
-
var children = _ref.children,
|
|
118
|
-
_ref$isSelected = _ref.isSelected,
|
|
119
|
-
isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
|
|
120
|
-
_ref$isVisible = _ref.isVisible,
|
|
121
|
-
isVisible = _ref$isVisible === void 0 ? false : _ref$isVisible,
|
|
122
|
-
_ref$testId = _ref.testId,
|
|
123
|
-
testId = _ref$testId === void 0 ? 'inline-card-overlay' : _ref$testId,
|
|
124
|
-
url = _ref.url,
|
|
125
|
-
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
126
|
-
var _useState = (0, _react.useState)(false),
|
|
127
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
128
|
-
showOverlay = _useState2[0],
|
|
129
|
-
setShowOverlay = _useState2[1];
|
|
130
|
-
var _useState3 = (0, _react.useState)(true),
|
|
131
|
-
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
132
|
-
showLabel = _useState4[0],
|
|
133
|
-
setShowLabel = _useState4[1];
|
|
134
|
-
var _useState5 = (0, _react.useState)(undefined),
|
|
135
|
-
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
136
|
-
availableWidth = _useState6[0],
|
|
137
|
-
setAvailableWidth = _useState6[1];
|
|
138
|
-
var maxOverlayWidth = (0, _react.useRef)(0);
|
|
139
|
-
var minOverlayWidth = (0, _react.useRef)(ESTIMATED_MIN_WIDTH_IN_PX);
|
|
140
|
-
var parentWidth = (0, _react.useRef)(0);
|
|
141
|
-
var containerRef = (0, _react.useRef)(null);
|
|
142
|
-
var setVisibility = (0, _react.useCallback)(function () {
|
|
143
|
-
if (!containerRef.current || !maxOverlayWidth.current) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
var marker = (0, _utils.getChildElement)(containerRef, ".".concat(OVERLAY_MARKER_CLASSNAME));
|
|
147
|
-
if (!marker) {
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
try {
|
|
151
|
-
var oneLine = (0, _utils.isOneLine)(containerRef.current, marker);
|
|
152
|
-
|
|
153
|
-
// Get the width of the available space to display overlay.
|
|
154
|
-
// This is the width of the inline link itself. If the inline
|
|
155
|
-
// is wrapped to the next line, this is width of the last line.
|
|
156
|
-
var _availableWidth = (0, _utils.getInlineCardAvailableWidth)(containerRef.current, marker) - PADDING_IN_PX - (
|
|
157
|
-
// Always leave at least the icon visible
|
|
158
|
-
oneLine ? ICON_WIDTH_IN_PX + PADDING_IN_PX : 0);
|
|
159
|
-
setAvailableWidth(_availableWidth);
|
|
160
|
-
var canShowLabel = _availableWidth > maxOverlayWidth.current;
|
|
161
|
-
setShowLabel(canShowLabel);
|
|
162
|
-
var canShowOverlay = _availableWidth > minOverlayWidth.current && !isSelected;
|
|
163
|
-
setShowOverlay(canShowOverlay);
|
|
164
|
-
} catch (_unused) {
|
|
165
|
-
// If something goes wrong, hide the overlay all together.
|
|
166
|
-
setShowOverlay(false);
|
|
167
|
-
}
|
|
168
|
-
}, [isSelected]);
|
|
169
|
-
(0, _react.useLayoutEffect)(function () {
|
|
170
|
-
// Using useLayoutEffect here.
|
|
171
|
-
// 1) We want all to be able to determine whether to display label before
|
|
172
|
-
// the overlay becomes visible.
|
|
173
|
-
// 2) We need to wait for the refs to be assigned to be able to do determine
|
|
174
|
-
// the width of the overlay.
|
|
175
|
-
if (!containerRef.current) {
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// This should run only once
|
|
180
|
-
if (!maxOverlayWidth.current) {
|
|
181
|
-
var iconAndLabel = (0, _utils.getChildElement)(containerRef, ".".concat(ICON_AND_LABEL_CLASSNAME));
|
|
182
|
-
var _label = (0, _utils.getChildElement)(containerRef, ".".concat(OVERLAY_LABEL_CLASSNAME));
|
|
183
|
-
if (iconAndLabel && _label) {
|
|
184
|
-
// Set overlay max (label + icon) and min (icon only) width.
|
|
185
|
-
var _getOverlayWidths = (0, _utils.getOverlayWidths)(iconAndLabel, _label),
|
|
186
|
-
max = _getOverlayWidths.max,
|
|
187
|
-
min = _getOverlayWidths.min;
|
|
188
|
-
maxOverlayWidth.current = max;
|
|
189
|
-
minOverlayWidth.current = min;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
if (isVisible) {
|
|
193
|
-
setVisibility();
|
|
194
|
-
}
|
|
195
|
-
}, [setVisibility, isVisible]);
|
|
196
|
-
(0, _react.useEffect)(function () {
|
|
197
|
-
var _containerRef$current;
|
|
198
|
-
// Find the closest block parent to observe size change
|
|
199
|
-
var parent = containerRef === null || containerRef === void 0 || (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.closest(TEXT_NODE_SELECTOR);
|
|
200
|
-
if (!parent) {
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
var updateOverlay = (0, _debounce.default)(function (entries) {
|
|
204
|
-
var _entries$;
|
|
205
|
-
if (!isVisible) {
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
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;
|
|
209
|
-
if (!size) {
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
if (!parentWidth.current) {
|
|
213
|
-
parentWidth.current = size;
|
|
214
|
-
}
|
|
215
|
-
if (parentWidth.current === size) {
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
parentWidth.current = size;
|
|
219
|
-
setVisibility();
|
|
220
|
-
}, DEBOUNCE_IN_MS);
|
|
221
|
-
var observer = new ResizeObserver(updateOverlay);
|
|
222
|
-
observer.observe(parent);
|
|
223
|
-
return function () {
|
|
224
|
-
observer.disconnect();
|
|
225
|
-
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_memory_leaks')) {
|
|
226
|
-
updateOverlay.cancel();
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
}, [isVisible, setVisibility]);
|
|
230
|
-
var destinationUrl = (_useSmartLinkDestinat = (0, _useSmartLinkDestinationUrl.useSmartLinkDestinationUrl)(url)) !== null && _useSmartLinkDestinat !== void 0 ? _useSmartLinkDestinat : url;
|
|
231
|
-
var intl = (0, _reactIntl.useIntl)();
|
|
232
|
-
var label = intl.formatMessage(_card.messages.inlineOverlay);
|
|
233
|
-
return (
|
|
234
|
-
// Ignored via go/ees005
|
|
235
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
236
|
-
(0, _react2.jsx)("span", (0, _extends2.default)({}, props, {
|
|
237
|
-
css: containerStyles,
|
|
238
|
-
ref: containerRef
|
|
239
|
-
}), children, isVisible && (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)("span", {
|
|
240
|
-
"aria-hidden": "true",
|
|
241
|
-
className: OVERLAY_MARKER_CLASSNAME
|
|
242
|
-
}, _whitespace.ZERO_WIDTH_JOINER), (0, _react2.jsx)("a", {
|
|
243
|
-
css: [overlayStyles, showOverlay && showOverlayStyles],
|
|
244
|
-
style: {
|
|
245
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
246
|
-
marginLeft: availableWidth && -availableWidth,
|
|
247
|
-
width: availableWidth
|
|
248
|
-
},
|
|
249
|
-
"data-testid": testId,
|
|
250
|
-
href: destinationUrl,
|
|
251
|
-
onClick: function onClick(e) {
|
|
252
|
-
return e.preventDefault();
|
|
253
|
-
},
|
|
254
|
-
tabIndex: -1
|
|
255
|
-
}, (0, _react2.jsx)("span", {
|
|
256
|
-
css: overflowingContainerStyles
|
|
257
|
-
}, (0, _react2.jsx)("span", {
|
|
258
|
-
css: iconAndLabelStyles
|
|
259
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
260
|
-
,
|
|
261
|
-
className: ICON_AND_LABEL_CLASSNAME
|
|
262
|
-
}, (0, _react2.jsx)("span", {
|
|
263
|
-
css: iconStyles
|
|
264
|
-
}, (0, _react2.jsx)(_customize.default, {
|
|
265
|
-
label: label,
|
|
266
|
-
testId: "".concat(testId, "-icon")
|
|
267
|
-
})), showLabel && (0, _react2.jsx)("span", {
|
|
268
|
-
css: labelStyles
|
|
269
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
270
|
-
,
|
|
271
|
-
className: OVERLAY_LABEL_CLASSNAME,
|
|
272
|
-
"data-testid": "".concat(testId, "-label")
|
|
273
|
-
}, label)), (0, _react2.jsx)("span", {
|
|
274
|
-
css: gradientStyles
|
|
275
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
276
|
-
,
|
|
277
|
-
className: OVERLAY_GRADIENT_CLASSNAME,
|
|
278
|
-
"data-testid": "".concat(testId, "-gradient")
|
|
279
|
-
})))))
|
|
280
|
-
);
|
|
281
|
-
};
|
|
282
|
-
var _default = exports.default = InlineCardOverlay;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isOneLine = exports.getOverlayWidths = exports.getInlineCardAvailableWidth = exports.getIconSize = exports.getChildElement = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Find a child element inside a ref.
|
|
9
|
-
*/
|
|
10
|
-
var getChildElement = exports.getChildElement = function getChildElement(ref, selector) {
|
|
11
|
-
return ref.current ? ref.current.querySelector(selector) : undefined;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Get the available width of the inline card.
|
|
16
|
-
* (Mainly here to make the component unit testable.)
|
|
17
|
-
*/
|
|
18
|
-
var getInlineCardAvailableWidth = exports.getInlineCardAvailableWidth = function getInlineCardAvailableWidth(startEl, endEl) {
|
|
19
|
-
var start = startEl.getBoundingClientRect().left;
|
|
20
|
-
var end = endEl.getBoundingClientRect().left;
|
|
21
|
-
return end - start;
|
|
22
|
-
};
|
|
23
|
-
var isOneLine = exports.isOneLine = function isOneLine(startEl, endEl) {
|
|
24
|
-
var start = startEl.getBoundingClientRect().top;
|
|
25
|
-
var end = endEl.getBoundingClientRect().top;
|
|
26
|
-
return start === end;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Get max and min width of an overlay.
|
|
31
|
-
* (Mainly here to make the component unit testable.)
|
|
32
|
-
*/
|
|
33
|
-
var getOverlayWidths = exports.getOverlayWidths = function getOverlayWidths(overlayEl, labelEl) {
|
|
34
|
-
var max = overlayEl.getBoundingClientRect().width;
|
|
35
|
-
var min = max - labelEl.getBoundingClientRect().width;
|
|
36
|
-
return {
|
|
37
|
-
max: max,
|
|
38
|
-
min: min
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
var getIconSize = exports.getIconSize = function getIconSize(labelEl) {
|
|
42
|
-
var h2FontSizePx = 20;
|
|
43
|
-
var fontSize = window && parseFloat(window.getComputedStyle(labelEl).fontSize);
|
|
44
|
-
if (!fontSize || fontSize < h2FontSizePx) {
|
|
45
|
-
return 'small';
|
|
46
|
-
}
|
|
47
|
-
return 'medium';
|
|
48
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jsxRuntime classic
|
|
3
|
-
* @jsx jsx
|
|
4
|
-
*/
|
|
5
|
-
import { useCallback, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
// not permitted to migrate atlaskit packages to compiled yet, see https://hello.atlassian.net/wiki/spaces/UAF/pages/3006969423/Migrating+AFM+platform+components+to+Compiled+a+guide
|
|
8
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports
|
|
9
|
-
import { css, jsx } from '@emotion/react';
|
|
10
|
-
import { OverlayButton } from '@atlaskit/editor-common/link/ConfigureLinkOverlay';
|
|
11
|
-
const ConfigureOverlayWrapperStyles = css({
|
|
12
|
-
position: 'relative',
|
|
13
|
-
left: "var(--ds-space-025, 2px)"
|
|
14
|
-
});
|
|
15
|
-
const OverlayWrapper = ({
|
|
16
|
-
view,
|
|
17
|
-
targetElementPos,
|
|
18
|
-
children,
|
|
19
|
-
isHoveredCallback: hoverCallback,
|
|
20
|
-
onOpenLinkClick
|
|
21
|
-
}) => {
|
|
22
|
-
const [showConfigureButton, setShowConfigureButton] = useState(false);
|
|
23
|
-
const [dropdownOpen, setDropdownOpen] = useState(false);
|
|
24
|
-
const onDropdownChange = useCallback(isOpen => {
|
|
25
|
-
setDropdownOpen(isOpen);
|
|
26
|
-
if (!isOpen) {
|
|
27
|
-
setShowConfigureButton(false);
|
|
28
|
-
}
|
|
29
|
-
}, []);
|
|
30
|
-
const showOverlay = useCallback(() => {
|
|
31
|
-
setShowConfigureButton(true);
|
|
32
|
-
hoverCallback(true);
|
|
33
|
-
}, [hoverCallback]);
|
|
34
|
-
const hideOverlay = useCallback(() => {
|
|
35
|
-
if (!dropdownOpen) {
|
|
36
|
-
setShowConfigureButton(false);
|
|
37
|
-
hoverCallback(false);
|
|
38
|
-
}
|
|
39
|
-
}, [dropdownOpen, hoverCallback]);
|
|
40
|
-
return jsx("span", {
|
|
41
|
-
onMouseEnter: showOverlay,
|
|
42
|
-
onMouseLeave: hideOverlay,
|
|
43
|
-
onFocus: showOverlay,
|
|
44
|
-
onBlur: hideOverlay,
|
|
45
|
-
"data-testid": "inline-card-overlay-wrapper"
|
|
46
|
-
}, jsx("span", {
|
|
47
|
-
css: ConfigureOverlayWrapperStyles
|
|
48
|
-
}, showConfigureButton && jsx(OverlayButton, {
|
|
49
|
-
editorView: view,
|
|
50
|
-
targetElementPos: targetElementPos,
|
|
51
|
-
onDropdownChange: onDropdownChange,
|
|
52
|
-
onOpenLinkClick: onOpenLinkClick
|
|
53
|
-
})), children);
|
|
54
|
-
};
|
|
55
|
-
export default OverlayWrapper;
|
|
@@ -1,264 +0,0 @@
|
|
|
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
|
-
/**
|
|
5
|
-
* @jsxRuntime classic
|
|
6
|
-
* @jsx jsx
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import React, { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
10
|
-
|
|
11
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports
|
|
12
|
-
import { css, jsx } from '@emotion/react';
|
|
13
|
-
import debounce from 'lodash/debounce';
|
|
14
|
-
import { useIntl } from 'react-intl';
|
|
15
|
-
import { messages } from '@atlaskit/editor-common/messages/card';
|
|
16
|
-
import { ZERO_WIDTH_JOINER } from '@atlaskit/editor-common/whitespace/whitespace';
|
|
17
|
-
import CustomizeIcon from '@atlaskit/icon/core/customize';
|
|
18
|
-
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
19
|
-
import { useSmartLinkDestinationUrl } from '@atlaskit/smart-card/hook/use-smart-link-destination-url';
|
|
20
|
-
import { getChildElement, getInlineCardAvailableWidth, getOverlayWidths, isOneLine } from './utils';
|
|
21
|
-
const DEBOUNCE_IN_MS = 5;
|
|
22
|
-
const ESTIMATED_MIN_WIDTH_IN_PX = 16;
|
|
23
|
-
const PADDING_IN_PX = 4;
|
|
24
|
-
const ICON_WIDTH_IN_PX = 14;
|
|
25
|
-
const ICON_AND_LABEL_CLASSNAME = 'ak-editor-card-overlay-icon-and-label';
|
|
26
|
-
const OVERLAY_LABEL_CLASSNAME = 'ak-editor-card-overlay-label';
|
|
27
|
-
const OVERLAY_GRADIENT_CLASSNAME = 'ak-editor-card-overlay-gradient';
|
|
28
|
-
const OVERLAY_MARKER_CLASSNAME = 'ak-editor-card-overlay-marker';
|
|
29
|
-
const TEXT_NODE_SELECTOR = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].join(',');
|
|
30
|
-
const SMART_LINK_BACKGROUND_COLOR = "var(--ds-surface-raised, #FFFFFF)";
|
|
31
|
-
const SMART_LINK_ACTIVE_COLOR = "var(--ds-background-selected, #E9F2FE)";
|
|
32
|
-
const getGradientWithColor = color => {
|
|
33
|
-
return `linear-gradient(270deg, ${color} 0%, rgba(255, 255, 255, 0.00) 100%)`;
|
|
34
|
-
};
|
|
35
|
-
const containerStyles = css({
|
|
36
|
-
position: 'relative',
|
|
37
|
-
// eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
|
|
38
|
-
lineHeight: 'normal',
|
|
39
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
40
|
-
':active': {
|
|
41
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
42
|
-
[`.${ICON_AND_LABEL_CLASSNAME}`]: {
|
|
43
|
-
background: SMART_LINK_ACTIVE_COLOR
|
|
44
|
-
},
|
|
45
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
46
|
-
[`.${OVERLAY_GRADIENT_CLASSNAME}`]: {
|
|
47
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
48
|
-
background: getGradientWithColor(SMART_LINK_ACTIVE_COLOR)
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
const overlayStyles = css({
|
|
53
|
-
// Set default styling to be invisible but available in dom for width calculation.
|
|
54
|
-
visibility: 'hidden',
|
|
55
|
-
position: 'absolute',
|
|
56
|
-
display: 'inline-flex',
|
|
57
|
-
justifyContent: 'flex-end',
|
|
58
|
-
alignItems: 'center',
|
|
59
|
-
verticalAlign: 'text-top',
|
|
60
|
-
height: '1lh',
|
|
61
|
-
'@supports not (height: 1lh)': {
|
|
62
|
-
height: '1.2em'
|
|
63
|
-
},
|
|
64
|
-
overflow: 'hidden',
|
|
65
|
-
// EDM-1717: box-shadow Safari fix bring load wrapper zIndex to 1
|
|
66
|
-
zIndex: 2,
|
|
67
|
-
pointerEvents: 'none'
|
|
68
|
-
});
|
|
69
|
-
const showOverlayStyles = css({
|
|
70
|
-
position: 'relative',
|
|
71
|
-
visibility: 'visible'
|
|
72
|
-
});
|
|
73
|
-
const iconStyles = css({
|
|
74
|
-
// Position icon in the middle
|
|
75
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
76
|
-
span: {
|
|
77
|
-
display: 'flex'
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
const labelStyles = css({
|
|
81
|
-
font: "var(--ds-font-body, normal 400 14px/20px \"Atlassian Sans\", ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
|
|
82
|
-
fontWeight: "var(--ds-font-weight-semibold, 600)",
|
|
83
|
-
width: 'max-content'
|
|
84
|
-
});
|
|
85
|
-
const iconAndLabelStyles = css({
|
|
86
|
-
display: 'flex',
|
|
87
|
-
alignItems: 'center',
|
|
88
|
-
height: '100%',
|
|
89
|
-
gap: "var(--ds-space-050, 4px)",
|
|
90
|
-
paddingRight: "var(--ds-space-050, 4px)",
|
|
91
|
-
// Margin to avoid the background covering the link border
|
|
92
|
-
marginRight: "var(--ds-space-025, 2px)",
|
|
93
|
-
background: SMART_LINK_BACKGROUND_COLOR,
|
|
94
|
-
color: "var(--ds-text-subtlest, #6B6E76)"
|
|
95
|
-
});
|
|
96
|
-
const overflowingContainerStyles = css({
|
|
97
|
-
display: 'flex',
|
|
98
|
-
flexDirection: 'row-reverse',
|
|
99
|
-
alignItems: 'center',
|
|
100
|
-
width: 'max-content',
|
|
101
|
-
height: '100%'
|
|
102
|
-
});
|
|
103
|
-
const gradientStyles = css({
|
|
104
|
-
width: '2.5rem',
|
|
105
|
-
height: '100%',
|
|
106
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
107
|
-
background: getGradientWithColor(SMART_LINK_BACKGROUND_COLOR)
|
|
108
|
-
});
|
|
109
|
-
const InlineCardOverlay = ({
|
|
110
|
-
children,
|
|
111
|
-
isSelected = false,
|
|
112
|
-
isVisible = false,
|
|
113
|
-
testId = 'inline-card-overlay',
|
|
114
|
-
url,
|
|
115
|
-
...props
|
|
116
|
-
}) => {
|
|
117
|
-
var _useSmartLinkDestinat;
|
|
118
|
-
const [showOverlay, setShowOverlay] = useState(false);
|
|
119
|
-
const [showLabel, setShowLabel] = useState(true);
|
|
120
|
-
const [availableWidth, setAvailableWidth] = useState(undefined);
|
|
121
|
-
const maxOverlayWidth = useRef(0);
|
|
122
|
-
const minOverlayWidth = useRef(ESTIMATED_MIN_WIDTH_IN_PX);
|
|
123
|
-
const parentWidth = useRef(0);
|
|
124
|
-
const containerRef = useRef(null);
|
|
125
|
-
const setVisibility = useCallback(() => {
|
|
126
|
-
if (!containerRef.current || !maxOverlayWidth.current) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
const marker = getChildElement(containerRef, `.${OVERLAY_MARKER_CLASSNAME}`);
|
|
130
|
-
if (!marker) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
try {
|
|
134
|
-
const oneLine = isOneLine(containerRef.current, marker);
|
|
135
|
-
|
|
136
|
-
// Get the width of the available space to display overlay.
|
|
137
|
-
// This is the width of the inline link itself. If the inline
|
|
138
|
-
// is wrapped to the next line, this is width of the last line.
|
|
139
|
-
const availableWidth = getInlineCardAvailableWidth(containerRef.current, marker) - PADDING_IN_PX - (
|
|
140
|
-
// Always leave at least the icon visible
|
|
141
|
-
oneLine ? ICON_WIDTH_IN_PX + PADDING_IN_PX : 0);
|
|
142
|
-
setAvailableWidth(availableWidth);
|
|
143
|
-
const canShowLabel = availableWidth > maxOverlayWidth.current;
|
|
144
|
-
setShowLabel(canShowLabel);
|
|
145
|
-
const canShowOverlay = availableWidth > minOverlayWidth.current && !isSelected;
|
|
146
|
-
setShowOverlay(canShowOverlay);
|
|
147
|
-
} catch {
|
|
148
|
-
// If something goes wrong, hide the overlay all together.
|
|
149
|
-
setShowOverlay(false);
|
|
150
|
-
}
|
|
151
|
-
}, [isSelected]);
|
|
152
|
-
useLayoutEffect(() => {
|
|
153
|
-
// Using useLayoutEffect here.
|
|
154
|
-
// 1) We want all to be able to determine whether to display label before
|
|
155
|
-
// the overlay becomes visible.
|
|
156
|
-
// 2) We need to wait for the refs to be assigned to be able to do determine
|
|
157
|
-
// the width of the overlay.
|
|
158
|
-
if (!containerRef.current) {
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// This should run only once
|
|
163
|
-
if (!maxOverlayWidth.current) {
|
|
164
|
-
const iconAndLabel = getChildElement(containerRef, `.${ICON_AND_LABEL_CLASSNAME}`);
|
|
165
|
-
const label = getChildElement(containerRef, `.${OVERLAY_LABEL_CLASSNAME}`);
|
|
166
|
-
if (iconAndLabel && label) {
|
|
167
|
-
// Set overlay max (label + icon) and min (icon only) width.
|
|
168
|
-
const {
|
|
169
|
-
max,
|
|
170
|
-
min
|
|
171
|
-
} = getOverlayWidths(iconAndLabel, label);
|
|
172
|
-
maxOverlayWidth.current = max;
|
|
173
|
-
minOverlayWidth.current = min;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
if (isVisible) {
|
|
177
|
-
setVisibility();
|
|
178
|
-
}
|
|
179
|
-
}, [setVisibility, isVisible]);
|
|
180
|
-
useEffect(() => {
|
|
181
|
-
var _containerRef$current;
|
|
182
|
-
// Find the closest block parent to observe size change
|
|
183
|
-
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);
|
|
184
|
-
if (!parent) {
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
const updateOverlay = debounce(entries => {
|
|
188
|
-
var _entries$, _entries$$contentBoxS, _entries$$contentBoxS2;
|
|
189
|
-
if (!isVisible) {
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
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;
|
|
193
|
-
if (!size) {
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
if (!parentWidth.current) {
|
|
197
|
-
parentWidth.current = size;
|
|
198
|
-
}
|
|
199
|
-
if (parentWidth.current === size) {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
parentWidth.current = size;
|
|
203
|
-
setVisibility();
|
|
204
|
-
}, DEBOUNCE_IN_MS);
|
|
205
|
-
const observer = new ResizeObserver(updateOverlay);
|
|
206
|
-
observer.observe(parent);
|
|
207
|
-
return () => {
|
|
208
|
-
observer.disconnect();
|
|
209
|
-
if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
|
|
210
|
-
updateOverlay.cancel();
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
}, [isVisible, setVisibility]);
|
|
214
|
-
const destinationUrl = (_useSmartLinkDestinat = useSmartLinkDestinationUrl(url)) !== null && _useSmartLinkDestinat !== void 0 ? _useSmartLinkDestinat : url;
|
|
215
|
-
const intl = useIntl();
|
|
216
|
-
const label = intl.formatMessage(messages.inlineOverlay);
|
|
217
|
-
return (
|
|
218
|
-
// Ignored via go/ees005
|
|
219
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
220
|
-
jsx("span", _extends({}, props, {
|
|
221
|
-
css: containerStyles,
|
|
222
|
-
ref: containerRef
|
|
223
|
-
}), children, isVisible && jsx(React.Fragment, null, jsx("span", {
|
|
224
|
-
"aria-hidden": "true",
|
|
225
|
-
className: OVERLAY_MARKER_CLASSNAME
|
|
226
|
-
}, ZERO_WIDTH_JOINER), jsx("a", {
|
|
227
|
-
css: [overlayStyles, showOverlay && showOverlayStyles],
|
|
228
|
-
style: {
|
|
229
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
230
|
-
marginLeft: availableWidth && -availableWidth,
|
|
231
|
-
width: availableWidth
|
|
232
|
-
},
|
|
233
|
-
"data-testid": testId,
|
|
234
|
-
href: destinationUrl,
|
|
235
|
-
onClick: e => e.preventDefault(),
|
|
236
|
-
tabIndex: -1
|
|
237
|
-
}, jsx("span", {
|
|
238
|
-
css: overflowingContainerStyles
|
|
239
|
-
}, jsx("span", {
|
|
240
|
-
css: iconAndLabelStyles
|
|
241
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
242
|
-
,
|
|
243
|
-
className: ICON_AND_LABEL_CLASSNAME
|
|
244
|
-
}, jsx("span", {
|
|
245
|
-
css: iconStyles
|
|
246
|
-
}, jsx(CustomizeIcon, {
|
|
247
|
-
label: label,
|
|
248
|
-
testId: `${testId}-icon`
|
|
249
|
-
})), showLabel && jsx("span", {
|
|
250
|
-
css: labelStyles
|
|
251
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
252
|
-
,
|
|
253
|
-
className: OVERLAY_LABEL_CLASSNAME,
|
|
254
|
-
"data-testid": `${testId}-label`
|
|
255
|
-
}, label)), jsx("span", {
|
|
256
|
-
css: gradientStyles
|
|
257
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
258
|
-
,
|
|
259
|
-
className: OVERLAY_GRADIENT_CLASSNAME,
|
|
260
|
-
"data-testid": `${testId}-gradient`
|
|
261
|
-
})))))
|
|
262
|
-
);
|
|
263
|
-
};
|
|
264
|
-
export default InlineCardOverlay;
|
|
File without changes
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Find a child element inside a ref.
|
|
3
|
-
*/
|
|
4
|
-
export const getChildElement = (ref, selector) => ref.current ? ref.current.querySelector(selector) : undefined;
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Get the available width of the inline card.
|
|
8
|
-
* (Mainly here to make the component unit testable.)
|
|
9
|
-
*/
|
|
10
|
-
export const getInlineCardAvailableWidth = (startEl, endEl) => {
|
|
11
|
-
const start = startEl.getBoundingClientRect().left;
|
|
12
|
-
const end = endEl.getBoundingClientRect().left;
|
|
13
|
-
return end - start;
|
|
14
|
-
};
|
|
15
|
-
export const isOneLine = (startEl, endEl) => {
|
|
16
|
-
const start = startEl.getBoundingClientRect().top;
|
|
17
|
-
const end = endEl.getBoundingClientRect().top;
|
|
18
|
-
return start === end;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Get max and min width of an overlay.
|
|
23
|
-
* (Mainly here to make the component unit testable.)
|
|
24
|
-
*/
|
|
25
|
-
export const getOverlayWidths = (overlayEl, labelEl) => {
|
|
26
|
-
const max = overlayEl.getBoundingClientRect().width;
|
|
27
|
-
const min = max - labelEl.getBoundingClientRect().width;
|
|
28
|
-
return {
|
|
29
|
-
max,
|
|
30
|
-
min
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
export const getIconSize = labelEl => {
|
|
34
|
-
const h2FontSizePx = 20;
|
|
35
|
-
const fontSize = window && parseFloat(window.getComputedStyle(labelEl).fontSize);
|
|
36
|
-
if (!fontSize || fontSize < h2FontSizePx) {
|
|
37
|
-
return 'small';
|
|
38
|
-
}
|
|
39
|
-
return 'medium';
|
|
40
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
/**
|
|
3
|
-
* @jsxRuntime classic
|
|
4
|
-
* @jsx jsx
|
|
5
|
-
*/
|
|
6
|
-
import { useCallback, useState } from 'react';
|
|
7
|
-
|
|
8
|
-
// not permitted to migrate atlaskit packages to compiled yet, see https://hello.atlassian.net/wiki/spaces/UAF/pages/3006969423/Migrating+AFM+platform+components+to+Compiled+a+guide
|
|
9
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports
|
|
10
|
-
import { css, jsx } from '@emotion/react';
|
|
11
|
-
import { OverlayButton } from '@atlaskit/editor-common/link/ConfigureLinkOverlay';
|
|
12
|
-
var ConfigureOverlayWrapperStyles = css({
|
|
13
|
-
position: 'relative',
|
|
14
|
-
left: "var(--ds-space-025, 2px)"
|
|
15
|
-
});
|
|
16
|
-
var OverlayWrapper = function OverlayWrapper(_ref) {
|
|
17
|
-
var view = _ref.view,
|
|
18
|
-
targetElementPos = _ref.targetElementPos,
|
|
19
|
-
children = _ref.children,
|
|
20
|
-
hoverCallback = _ref.isHoveredCallback,
|
|
21
|
-
onOpenLinkClick = _ref.onOpenLinkClick;
|
|
22
|
-
var _useState = useState(false),
|
|
23
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
24
|
-
showConfigureButton = _useState2[0],
|
|
25
|
-
setShowConfigureButton = _useState2[1];
|
|
26
|
-
var _useState3 = useState(false),
|
|
27
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
28
|
-
dropdownOpen = _useState4[0],
|
|
29
|
-
setDropdownOpen = _useState4[1];
|
|
30
|
-
var onDropdownChange = useCallback(function (isOpen) {
|
|
31
|
-
setDropdownOpen(isOpen);
|
|
32
|
-
if (!isOpen) {
|
|
33
|
-
setShowConfigureButton(false);
|
|
34
|
-
}
|
|
35
|
-
}, []);
|
|
36
|
-
var showOverlay = useCallback(function () {
|
|
37
|
-
setShowConfigureButton(true);
|
|
38
|
-
hoverCallback(true);
|
|
39
|
-
}, [hoverCallback]);
|
|
40
|
-
var hideOverlay = useCallback(function () {
|
|
41
|
-
if (!dropdownOpen) {
|
|
42
|
-
setShowConfigureButton(false);
|
|
43
|
-
hoverCallback(false);
|
|
44
|
-
}
|
|
45
|
-
}, [dropdownOpen, hoverCallback]);
|
|
46
|
-
return jsx("span", {
|
|
47
|
-
onMouseEnter: showOverlay,
|
|
48
|
-
onMouseLeave: hideOverlay,
|
|
49
|
-
onFocus: showOverlay,
|
|
50
|
-
onBlur: hideOverlay,
|
|
51
|
-
"data-testid": "inline-card-overlay-wrapper"
|
|
52
|
-
}, jsx("span", {
|
|
53
|
-
css: ConfigureOverlayWrapperStyles
|
|
54
|
-
}, showConfigureButton && jsx(OverlayButton, {
|
|
55
|
-
editorView: view,
|
|
56
|
-
targetElementPos: targetElementPos,
|
|
57
|
-
onDropdownChange: onDropdownChange,
|
|
58
|
-
onOpenLinkClick: onOpenLinkClick
|
|
59
|
-
})), children);
|
|
60
|
-
};
|
|
61
|
-
export default OverlayWrapper;
|
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
|
-
var _excluded = ["children", "isSelected", "isVisible", "testId", "url"];
|
|
6
|
-
/* eslint-disable @atlaskit/design-system/no-nested-styles */
|
|
7
|
-
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
8
|
-
/**
|
|
9
|
-
* @jsxRuntime classic
|
|
10
|
-
* @jsx jsx
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import React, { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
14
|
-
|
|
15
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports
|
|
16
|
-
import { css, jsx } from '@emotion/react';
|
|
17
|
-
import debounce from 'lodash/debounce';
|
|
18
|
-
import { useIntl } from 'react-intl';
|
|
19
|
-
import { messages } from '@atlaskit/editor-common/messages/card';
|
|
20
|
-
import { ZERO_WIDTH_JOINER } from '@atlaskit/editor-common/whitespace/whitespace';
|
|
21
|
-
import CustomizeIcon from '@atlaskit/icon/core/customize';
|
|
22
|
-
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
23
|
-
import { useSmartLinkDestinationUrl } from '@atlaskit/smart-card/hook/use-smart-link-destination-url';
|
|
24
|
-
import { getChildElement, getInlineCardAvailableWidth, getOverlayWidths, isOneLine } from './utils';
|
|
25
|
-
var DEBOUNCE_IN_MS = 5;
|
|
26
|
-
var ESTIMATED_MIN_WIDTH_IN_PX = 16;
|
|
27
|
-
var PADDING_IN_PX = 4;
|
|
28
|
-
var ICON_WIDTH_IN_PX = 14;
|
|
29
|
-
var ICON_AND_LABEL_CLASSNAME = 'ak-editor-card-overlay-icon-and-label';
|
|
30
|
-
var OVERLAY_LABEL_CLASSNAME = 'ak-editor-card-overlay-label';
|
|
31
|
-
var OVERLAY_GRADIENT_CLASSNAME = 'ak-editor-card-overlay-gradient';
|
|
32
|
-
var OVERLAY_MARKER_CLASSNAME = 'ak-editor-card-overlay-marker';
|
|
33
|
-
var TEXT_NODE_SELECTOR = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].join(',');
|
|
34
|
-
var SMART_LINK_BACKGROUND_COLOR = "var(--ds-surface-raised, #FFFFFF)";
|
|
35
|
-
var SMART_LINK_ACTIVE_COLOR = "var(--ds-background-selected, #E9F2FE)";
|
|
36
|
-
var getGradientWithColor = function getGradientWithColor(color) {
|
|
37
|
-
return "linear-gradient(270deg, ".concat(color, " 0%, rgba(255, 255, 255, 0.00) 100%)");
|
|
38
|
-
};
|
|
39
|
-
var containerStyles = css({
|
|
40
|
-
position: 'relative',
|
|
41
|
-
// eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
|
|
42
|
-
lineHeight: 'normal',
|
|
43
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
44
|
-
':active': _defineProperty(_defineProperty({}, ".".concat(ICON_AND_LABEL_CLASSNAME), {
|
|
45
|
-
background: SMART_LINK_ACTIVE_COLOR
|
|
46
|
-
}), ".".concat(OVERLAY_GRADIENT_CLASSNAME), {
|
|
47
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
48
|
-
background: getGradientWithColor(SMART_LINK_ACTIVE_COLOR)
|
|
49
|
-
})
|
|
50
|
-
});
|
|
51
|
-
var overlayStyles = css({
|
|
52
|
-
// Set default styling to be invisible but available in dom for width calculation.
|
|
53
|
-
visibility: 'hidden',
|
|
54
|
-
position: 'absolute',
|
|
55
|
-
display: 'inline-flex',
|
|
56
|
-
justifyContent: 'flex-end',
|
|
57
|
-
alignItems: 'center',
|
|
58
|
-
verticalAlign: 'text-top',
|
|
59
|
-
height: '1lh',
|
|
60
|
-
'@supports not (height: 1lh)': {
|
|
61
|
-
height: '1.2em'
|
|
62
|
-
},
|
|
63
|
-
overflow: 'hidden',
|
|
64
|
-
// EDM-1717: box-shadow Safari fix bring load wrapper zIndex to 1
|
|
65
|
-
zIndex: 2,
|
|
66
|
-
pointerEvents: 'none'
|
|
67
|
-
});
|
|
68
|
-
var showOverlayStyles = css({
|
|
69
|
-
position: 'relative',
|
|
70
|
-
visibility: 'visible'
|
|
71
|
-
});
|
|
72
|
-
var iconStyles = css({
|
|
73
|
-
// Position icon in the middle
|
|
74
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
75
|
-
span: {
|
|
76
|
-
display: 'flex'
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
var labelStyles = css({
|
|
80
|
-
font: "var(--ds-font-body, normal 400 14px/20px \"Atlassian Sans\", ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
|
|
81
|
-
fontWeight: "var(--ds-font-weight-semibold, 600)",
|
|
82
|
-
width: 'max-content'
|
|
83
|
-
});
|
|
84
|
-
var iconAndLabelStyles = css({
|
|
85
|
-
display: 'flex',
|
|
86
|
-
alignItems: 'center',
|
|
87
|
-
height: '100%',
|
|
88
|
-
gap: "var(--ds-space-050, 4px)",
|
|
89
|
-
paddingRight: "var(--ds-space-050, 4px)",
|
|
90
|
-
// Margin to avoid the background covering the link border
|
|
91
|
-
marginRight: "var(--ds-space-025, 2px)",
|
|
92
|
-
background: SMART_LINK_BACKGROUND_COLOR,
|
|
93
|
-
color: "var(--ds-text-subtlest, #6B6E76)"
|
|
94
|
-
});
|
|
95
|
-
var overflowingContainerStyles = css({
|
|
96
|
-
display: 'flex',
|
|
97
|
-
flexDirection: 'row-reverse',
|
|
98
|
-
alignItems: 'center',
|
|
99
|
-
width: 'max-content',
|
|
100
|
-
height: '100%'
|
|
101
|
-
});
|
|
102
|
-
var gradientStyles = css({
|
|
103
|
-
width: '2.5rem',
|
|
104
|
-
height: '100%',
|
|
105
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
106
|
-
background: getGradientWithColor(SMART_LINK_BACKGROUND_COLOR)
|
|
107
|
-
});
|
|
108
|
-
var InlineCardOverlay = function InlineCardOverlay(_ref) {
|
|
109
|
-
var _useSmartLinkDestinat;
|
|
110
|
-
var children = _ref.children,
|
|
111
|
-
_ref$isSelected = _ref.isSelected,
|
|
112
|
-
isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
|
|
113
|
-
_ref$isVisible = _ref.isVisible,
|
|
114
|
-
isVisible = _ref$isVisible === void 0 ? false : _ref$isVisible,
|
|
115
|
-
_ref$testId = _ref.testId,
|
|
116
|
-
testId = _ref$testId === void 0 ? 'inline-card-overlay' : _ref$testId,
|
|
117
|
-
url = _ref.url,
|
|
118
|
-
props = _objectWithoutProperties(_ref, _excluded);
|
|
119
|
-
var _useState = useState(false),
|
|
120
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
121
|
-
showOverlay = _useState2[0],
|
|
122
|
-
setShowOverlay = _useState2[1];
|
|
123
|
-
var _useState3 = useState(true),
|
|
124
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
125
|
-
showLabel = _useState4[0],
|
|
126
|
-
setShowLabel = _useState4[1];
|
|
127
|
-
var _useState5 = useState(undefined),
|
|
128
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
129
|
-
availableWidth = _useState6[0],
|
|
130
|
-
setAvailableWidth = _useState6[1];
|
|
131
|
-
var maxOverlayWidth = useRef(0);
|
|
132
|
-
var minOverlayWidth = useRef(ESTIMATED_MIN_WIDTH_IN_PX);
|
|
133
|
-
var parentWidth = useRef(0);
|
|
134
|
-
var containerRef = useRef(null);
|
|
135
|
-
var setVisibility = useCallback(function () {
|
|
136
|
-
if (!containerRef.current || !maxOverlayWidth.current) {
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
var marker = getChildElement(containerRef, ".".concat(OVERLAY_MARKER_CLASSNAME));
|
|
140
|
-
if (!marker) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
try {
|
|
144
|
-
var oneLine = isOneLine(containerRef.current, marker);
|
|
145
|
-
|
|
146
|
-
// Get the width of the available space to display overlay.
|
|
147
|
-
// This is the width of the inline link itself. If the inline
|
|
148
|
-
// is wrapped to the next line, this is width of the last line.
|
|
149
|
-
var _availableWidth = getInlineCardAvailableWidth(containerRef.current, marker) - PADDING_IN_PX - (
|
|
150
|
-
// Always leave at least the icon visible
|
|
151
|
-
oneLine ? ICON_WIDTH_IN_PX + PADDING_IN_PX : 0);
|
|
152
|
-
setAvailableWidth(_availableWidth);
|
|
153
|
-
var canShowLabel = _availableWidth > maxOverlayWidth.current;
|
|
154
|
-
setShowLabel(canShowLabel);
|
|
155
|
-
var canShowOverlay = _availableWidth > minOverlayWidth.current && !isSelected;
|
|
156
|
-
setShowOverlay(canShowOverlay);
|
|
157
|
-
} catch (_unused) {
|
|
158
|
-
// If something goes wrong, hide the overlay all together.
|
|
159
|
-
setShowOverlay(false);
|
|
160
|
-
}
|
|
161
|
-
}, [isSelected]);
|
|
162
|
-
useLayoutEffect(function () {
|
|
163
|
-
// Using useLayoutEffect here.
|
|
164
|
-
// 1) We want all to be able to determine whether to display label before
|
|
165
|
-
// the overlay becomes visible.
|
|
166
|
-
// 2) We need to wait for the refs to be assigned to be able to do determine
|
|
167
|
-
// the width of the overlay.
|
|
168
|
-
if (!containerRef.current) {
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// This should run only once
|
|
173
|
-
if (!maxOverlayWidth.current) {
|
|
174
|
-
var iconAndLabel = getChildElement(containerRef, ".".concat(ICON_AND_LABEL_CLASSNAME));
|
|
175
|
-
var _label = getChildElement(containerRef, ".".concat(OVERLAY_LABEL_CLASSNAME));
|
|
176
|
-
if (iconAndLabel && _label) {
|
|
177
|
-
// Set overlay max (label + icon) and min (icon only) width.
|
|
178
|
-
var _getOverlayWidths = getOverlayWidths(iconAndLabel, _label),
|
|
179
|
-
max = _getOverlayWidths.max,
|
|
180
|
-
min = _getOverlayWidths.min;
|
|
181
|
-
maxOverlayWidth.current = max;
|
|
182
|
-
minOverlayWidth.current = min;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
if (isVisible) {
|
|
186
|
-
setVisibility();
|
|
187
|
-
}
|
|
188
|
-
}, [setVisibility, isVisible]);
|
|
189
|
-
useEffect(function () {
|
|
190
|
-
var _containerRef$current;
|
|
191
|
-
// Find the closest block parent to observe size change
|
|
192
|
-
var parent = containerRef === null || containerRef === void 0 || (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.closest(TEXT_NODE_SELECTOR);
|
|
193
|
-
if (!parent) {
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
var updateOverlay = debounce(function (entries) {
|
|
197
|
-
var _entries$;
|
|
198
|
-
if (!isVisible) {
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
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;
|
|
202
|
-
if (!size) {
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
if (!parentWidth.current) {
|
|
206
|
-
parentWidth.current = size;
|
|
207
|
-
}
|
|
208
|
-
if (parentWidth.current === size) {
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
parentWidth.current = size;
|
|
212
|
-
setVisibility();
|
|
213
|
-
}, DEBOUNCE_IN_MS);
|
|
214
|
-
var observer = new ResizeObserver(updateOverlay);
|
|
215
|
-
observer.observe(parent);
|
|
216
|
-
return function () {
|
|
217
|
-
observer.disconnect();
|
|
218
|
-
if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
|
|
219
|
-
updateOverlay.cancel();
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
}, [isVisible, setVisibility]);
|
|
223
|
-
var destinationUrl = (_useSmartLinkDestinat = useSmartLinkDestinationUrl(url)) !== null && _useSmartLinkDestinat !== void 0 ? _useSmartLinkDestinat : url;
|
|
224
|
-
var intl = useIntl();
|
|
225
|
-
var label = intl.formatMessage(messages.inlineOverlay);
|
|
226
|
-
return (
|
|
227
|
-
// Ignored via go/ees005
|
|
228
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
229
|
-
jsx("span", _extends({}, props, {
|
|
230
|
-
css: containerStyles,
|
|
231
|
-
ref: containerRef
|
|
232
|
-
}), children, isVisible && jsx(React.Fragment, null, jsx("span", {
|
|
233
|
-
"aria-hidden": "true",
|
|
234
|
-
className: OVERLAY_MARKER_CLASSNAME
|
|
235
|
-
}, ZERO_WIDTH_JOINER), jsx("a", {
|
|
236
|
-
css: [overlayStyles, showOverlay && showOverlayStyles],
|
|
237
|
-
style: {
|
|
238
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
239
|
-
marginLeft: availableWidth && -availableWidth,
|
|
240
|
-
width: availableWidth
|
|
241
|
-
},
|
|
242
|
-
"data-testid": testId,
|
|
243
|
-
href: destinationUrl,
|
|
244
|
-
onClick: function onClick(e) {
|
|
245
|
-
return e.preventDefault();
|
|
246
|
-
},
|
|
247
|
-
tabIndex: -1
|
|
248
|
-
}, jsx("span", {
|
|
249
|
-
css: overflowingContainerStyles
|
|
250
|
-
}, jsx("span", {
|
|
251
|
-
css: iconAndLabelStyles
|
|
252
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
253
|
-
,
|
|
254
|
-
className: ICON_AND_LABEL_CLASSNAME
|
|
255
|
-
}, jsx("span", {
|
|
256
|
-
css: iconStyles
|
|
257
|
-
}, jsx(CustomizeIcon, {
|
|
258
|
-
label: label,
|
|
259
|
-
testId: "".concat(testId, "-icon")
|
|
260
|
-
})), showLabel && jsx("span", {
|
|
261
|
-
css: labelStyles
|
|
262
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
263
|
-
,
|
|
264
|
-
className: OVERLAY_LABEL_CLASSNAME,
|
|
265
|
-
"data-testid": "".concat(testId, "-label")
|
|
266
|
-
}, label)), jsx("span", {
|
|
267
|
-
css: gradientStyles
|
|
268
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
269
|
-
,
|
|
270
|
-
className: OVERLAY_GRADIENT_CLASSNAME,
|
|
271
|
-
"data-testid": "".concat(testId, "-gradient")
|
|
272
|
-
})))))
|
|
273
|
-
);
|
|
274
|
-
};
|
|
275
|
-
export default InlineCardOverlay;
|
|
File without changes
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Find a child element inside a ref.
|
|
3
|
-
*/
|
|
4
|
-
export var getChildElement = function getChildElement(ref, selector) {
|
|
5
|
-
return ref.current ? ref.current.querySelector(selector) : undefined;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Get the available width of the inline card.
|
|
10
|
-
* (Mainly here to make the component unit testable.)
|
|
11
|
-
*/
|
|
12
|
-
export var getInlineCardAvailableWidth = function getInlineCardAvailableWidth(startEl, endEl) {
|
|
13
|
-
var start = startEl.getBoundingClientRect().left;
|
|
14
|
-
var end = endEl.getBoundingClientRect().left;
|
|
15
|
-
return end - start;
|
|
16
|
-
};
|
|
17
|
-
export var isOneLine = function isOneLine(startEl, endEl) {
|
|
18
|
-
var start = startEl.getBoundingClientRect().top;
|
|
19
|
-
var end = endEl.getBoundingClientRect().top;
|
|
20
|
-
return start === end;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Get max and min width of an overlay.
|
|
25
|
-
* (Mainly here to make the component unit testable.)
|
|
26
|
-
*/
|
|
27
|
-
export var getOverlayWidths = function getOverlayWidths(overlayEl, labelEl) {
|
|
28
|
-
var max = overlayEl.getBoundingClientRect().width;
|
|
29
|
-
var min = max - labelEl.getBoundingClientRect().width;
|
|
30
|
-
return {
|
|
31
|
-
max: max,
|
|
32
|
-
min: min
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
export var getIconSize = function getIconSize(labelEl) {
|
|
36
|
-
var h2FontSizePx = 20;
|
|
37
|
-
var fontSize = window && parseFloat(window.getComputedStyle(labelEl).fontSize);
|
|
38
|
-
if (!fontSize || fontSize < h2FontSizePx) {
|
|
39
|
-
return 'small';
|
|
40
|
-
}
|
|
41
|
-
return 'medium';
|
|
42
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { jsx } from '@emotion/react';
|
|
2
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
declare const OverlayWrapper: ({ view, targetElementPos, children, isHoveredCallback: hoverCallback, onOpenLinkClick, }: {
|
|
4
|
-
children: JSX.Element;
|
|
5
|
-
/** Fired when the mouse enters or leaves the overlay button */
|
|
6
|
-
isHoveredCallback: (isHovered: boolean) => void;
|
|
7
|
-
onOpenLinkClick: (event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => void;
|
|
8
|
-
targetElementPos: number | undefined;
|
|
9
|
-
view: EditorView;
|
|
10
|
-
}) => jsx.JSX.Element;
|
|
11
|
-
export default OverlayWrapper;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jsxRuntime classic
|
|
3
|
-
* @jsx jsx
|
|
4
|
-
*/
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { jsx } from '@emotion/react';
|
|
7
|
-
import type { InlineCardOverlayProps } from './types';
|
|
8
|
-
declare const InlineCardOverlay: ({ children, isSelected, isVisible, testId, url, ...props }: React.PropsWithChildren<InlineCardOverlayProps>) => jsx.JSX.Element;
|
|
9
|
-
export default InlineCardOverlay;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { Size } from '@atlaskit/icon/types';
|
|
2
|
-
/**
|
|
3
|
-
* Find a child element inside a ref.
|
|
4
|
-
*/
|
|
5
|
-
export declare const getChildElement: (ref: React.RefObject<HTMLElement>, selector: string) => HTMLElement | null | undefined;
|
|
6
|
-
/**
|
|
7
|
-
* Get the available width of the inline card.
|
|
8
|
-
* (Mainly here to make the component unit testable.)
|
|
9
|
-
*/
|
|
10
|
-
export declare const getInlineCardAvailableWidth: (startEl: HTMLElement, endEl: HTMLElement) => number;
|
|
11
|
-
export declare const isOneLine: (startEl: HTMLElement, endEl: HTMLElement) => boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Get max and min width of an overlay.
|
|
14
|
-
* (Mainly here to make the component unit testable.)
|
|
15
|
-
*/
|
|
16
|
-
export declare const getOverlayWidths: (overlayEl: HTMLElement, labelEl: HTMLElement) => {
|
|
17
|
-
max: number;
|
|
18
|
-
min: number;
|
|
19
|
-
};
|
|
20
|
-
export declare const getIconSize: (labelEl: HTMLElement) => Size;
|