@atlaskit/editor-plugin-card 2.6.0 → 2.6.2
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 +18 -0
- package/dist/cjs/nodeviews/blockCard.js +37 -13
- package/dist/cjs/nodeviews/embedCard.js +35 -10
- package/dist/es2019/nodeviews/blockCard.js +21 -4
- package/dist/es2019/nodeviews/embedCard.js +20 -1
- package/dist/esm/nodeviews/blockCard.js +38 -14
- package/dist/esm/nodeviews/embedCard.js +35 -10
- package/dist/types/nodeviews/blockCard.d.ts +3 -0
- package/dist/types/nodeviews/embedCard.d.ts +3 -0
- package/dist/types-ts4.5/nodeviews/blockCard.d.ts +3 -0
- package/dist/types-ts4.5/nodeviews/embedCard.d.ts +3 -0
- package/package.json +7 -7
- package/dist/cjs/ui/LeftIconOverlay/ConfigureLinkDropdown/index.js +0 -58
- package/dist/cjs/ui/LeftIconOverlay/index.js +0 -199
- package/dist/es2019/ui/LeftIconOverlay/ConfigureLinkDropdown/index.js +0 -47
- package/dist/es2019/ui/LeftIconOverlay/index.js +0 -177
- package/dist/esm/ui/LeftIconOverlay/ConfigureLinkDropdown/index.js +0 -48
- package/dist/esm/ui/LeftIconOverlay/index.js +0 -190
- package/dist/types/ui/LeftIconOverlay/ConfigureLinkDropdown/index.d.ts +0 -6
- package/dist/types/ui/LeftIconOverlay/index.d.ts +0 -10
- package/dist/types-ts4.5/ui/LeftIconOverlay/ConfigureLinkDropdown/index.d.ts +0 -6
- package/dist/types-ts4.5/ui/LeftIconOverlay/index.d.ts +0 -10
|
@@ -1,199 +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 _react = _interopRequireWildcard(require("react"));
|
|
13
|
-
var _react2 = require("@emotion/react");
|
|
14
|
-
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
15
|
-
var _reactIntlNext = require("react-intl-next");
|
|
16
|
-
var _messages = require("@atlaskit/editor-common/messages");
|
|
17
|
-
var _whitespace = require("@atlaskit/editor-common/whitespace");
|
|
18
|
-
var _preferences = _interopRequireDefault(require("@atlaskit/icon/glyph/preferences"));
|
|
19
|
-
var _colors = require("@atlaskit/theme/colors");
|
|
20
|
-
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
21
|
-
var _utils = require("../InlineCardOverlay/utils");
|
|
22
|
-
var _excluded = ["children", "isSelected", "isVisible", "testId"];
|
|
23
|
-
/* eslint-disable @atlaskit/design-system/no-nested-styles */
|
|
24
|
-
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
25
|
-
/** @jsx jsx */
|
|
26
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
27
|
-
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); }
|
|
28
|
-
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; }
|
|
29
|
-
var DEBOUNCE_IN_MS = 5;
|
|
30
|
-
var PADDING_IN_PX = 4;
|
|
31
|
-
var ICON_WIDTH_IN_PX = 16;
|
|
32
|
-
var ICON_AND_LABEL_CLASSNAME = 'ak-editor-card-overlay-icon-and-label';
|
|
33
|
-
var OVERLAY_MARKER_CLASSNAME = 'ak-editor-card-overlay-marker';
|
|
34
|
-
var TEXT_NODE_SELECTOR = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].join(',');
|
|
35
|
-
var SMART_LINK_BACKGROUND_COLOR = "var(--ds-surface-raised, ".concat(_colors.N0, ")");
|
|
36
|
-
var CONFIGURE_ICON_BACKGROUND_COLOR = "var(--ds-background-neutral, ".concat(_colors.N30A, ")");
|
|
37
|
-
var CONFIGURE_ICON_BACKGROUND_HOVERED_COLOR = "var(--ds-background-neutral-hovered, ".concat(_colors.N40A, ")");
|
|
38
|
-
var CONFIGURE_ICON_BACKGROUND_ACTIVE_COLOR = "var(--ds-background-neutral-pressed, ".concat(_colors.N60A, ")");
|
|
39
|
-
var containerStyles = (0, _react2.css)({
|
|
40
|
-
position: 'relative',
|
|
41
|
-
lineHeight: 'normal'
|
|
42
|
-
});
|
|
43
|
-
var overlayStyles = (0, _react2.css)({
|
|
44
|
-
position: 'absolute',
|
|
45
|
-
// Vertically align. Required for overlay to be centered inside the inline link (the inline lozenge is slightly larger than the designs)
|
|
46
|
-
transform: 'translate(0%, -50%)',
|
|
47
|
-
top: '50%',
|
|
48
|
-
// Set default styling to be invisible but available in dom for width calculation.
|
|
49
|
-
visibility: 'hidden',
|
|
50
|
-
overflow: 'hidden',
|
|
51
|
-
// EDM-1717: box-shadow Safari fix bring load wrapper zIndex to 1
|
|
52
|
-
zIndex: 2
|
|
53
|
-
});
|
|
54
|
-
var showOverlayStyles = (0, _react2.css)({
|
|
55
|
-
visibility: 'visible'
|
|
56
|
-
});
|
|
57
|
-
var iconStyles = (0, _react2.css)({
|
|
58
|
-
background: CONFIGURE_ICON_BACKGROUND_COLOR,
|
|
59
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
60
|
-
':hover': {
|
|
61
|
-
background: CONFIGURE_ICON_BACKGROUND_HOVERED_COLOR
|
|
62
|
-
},
|
|
63
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
64
|
-
':active': {
|
|
65
|
-
background: CONFIGURE_ICON_BACKGROUND_ACTIVE_COLOR
|
|
66
|
-
},
|
|
67
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
68
|
-
span: {
|
|
69
|
-
// If PreferencesIcon left as inline-block (default), height is incorrect and border radius is clipped when parent element
|
|
70
|
-
// uses 1lh height (rather than 100%)
|
|
71
|
-
display: 'block'
|
|
72
|
-
},
|
|
73
|
-
// Note: The spec recomends 3px, but the icon doesn't fit left of the lozenge text if this size
|
|
74
|
-
padding: "var(--ds-space-025, 2px)",
|
|
75
|
-
borderRadius: '3px'
|
|
76
|
-
});
|
|
77
|
-
var iconAndLabelStyles = (0, _react2.css)({
|
|
78
|
-
display: 'flex',
|
|
79
|
-
alignItems: 'center',
|
|
80
|
-
height: '100%',
|
|
81
|
-
// eslint-disable-next-line @atlaskit/design-system/use-tokens-space
|
|
82
|
-
marginLeft: '2.5px',
|
|
83
|
-
// Margin from very left of entire card (inclusive of blue)
|
|
84
|
-
|
|
85
|
-
// This exists so if we set a semi-transparent background above, the provider icon doesn't show
|
|
86
|
-
background: SMART_LINK_BACKGROUND_COLOR,
|
|
87
|
-
// Ensure we don't have a white gap when the inline-card is in an active state
|
|
88
|
-
borderRadius: '3px',
|
|
89
|
-
color: "var(--ds-text-subtlest, ".concat(_colors.N700, ")")
|
|
90
|
-
});
|
|
91
|
-
var LeftIconOverlay = function LeftIconOverlay(_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
|
-
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
100
|
-
var _useState = (0, _react.useState)(false),
|
|
101
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
102
|
-
showOverlay = _useState2[0],
|
|
103
|
-
setShowOverlay = _useState2[1];
|
|
104
|
-
var _useState3 = (0, _react.useState)(undefined),
|
|
105
|
-
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
106
|
-
availableWidth = _useState4[0],
|
|
107
|
-
setAvailableWidth = _useState4[1];
|
|
108
|
-
var containerRef = (0, _react.useRef)(null);
|
|
109
|
-
|
|
110
|
-
// TODO EDM-9853: Use availableWidth for small link edge case
|
|
111
|
-
// Calculation logic will need to updated.
|
|
112
|
-
availableWidth;
|
|
113
|
-
var setVisibility = (0, _react.useCallback)(function () {
|
|
114
|
-
if (!containerRef.current) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
var marker = (0, _utils.getChildElement)(containerRef, ".".concat(OVERLAY_MARKER_CLASSNAME));
|
|
118
|
-
if (!marker) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
try {
|
|
122
|
-
var oneLine = (0, _utils.isOneLine)(containerRef.current, marker);
|
|
123
|
-
|
|
124
|
-
// Get the width of the available space to display overlay.
|
|
125
|
-
// This is the width of the inline link itself. If the inline
|
|
126
|
-
// is wrapped to the next line, this is width of the last line.
|
|
127
|
-
var _availableWidth = (0, _utils.getInlineCardAvailableWidth)(containerRef.current, marker) - PADDING_IN_PX - (
|
|
128
|
-
// Always leave at least the icon visible
|
|
129
|
-
oneLine ? ICON_WIDTH_IN_PX + PADDING_IN_PX : 0);
|
|
130
|
-
setAvailableWidth(_availableWidth);
|
|
131
|
-
var canShowOverlay = !isSelected;
|
|
132
|
-
setShowOverlay(canShowOverlay);
|
|
133
|
-
} catch (_unused) {
|
|
134
|
-
// If something goes wrong, hide the overlay all together.
|
|
135
|
-
setShowOverlay(false);
|
|
136
|
-
}
|
|
137
|
-
}, [isSelected]);
|
|
138
|
-
(0, _react.useLayoutEffect)(function () {
|
|
139
|
-
if (!containerRef.current) {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
if (isVisible) {
|
|
143
|
-
setVisibility();
|
|
144
|
-
}
|
|
145
|
-
}, [setVisibility, isVisible]);
|
|
146
|
-
(0, _react.useEffect)(function () {
|
|
147
|
-
var _containerRef$current;
|
|
148
|
-
// Find the closest block parent to observe size change
|
|
149
|
-
var parent = containerRef === null || containerRef === void 0 || (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.closest(TEXT_NODE_SELECTOR);
|
|
150
|
-
if (!parent) {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
var updateOverlay = (0, _debounce.default)(function (entries) {
|
|
154
|
-
var _entries$;
|
|
155
|
-
if (!isVisible) {
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
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;
|
|
159
|
-
if (!size) {
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
setVisibility();
|
|
163
|
-
}, DEBOUNCE_IN_MS);
|
|
164
|
-
var observer = new ResizeObserver(updateOverlay);
|
|
165
|
-
observer.observe(parent);
|
|
166
|
-
return function () {
|
|
167
|
-
observer.disconnect();
|
|
168
|
-
};
|
|
169
|
-
}, [isVisible, setVisibility]);
|
|
170
|
-
var intl = (0, _reactIntlNext.useIntl)();
|
|
171
|
-
var configureLinkLabel = intl.formatMessage(_messages.cardMessages.inlineConfigureLink);
|
|
172
|
-
return (0, _react2.jsx)("span", (0, _extends2.default)({}, props, {
|
|
173
|
-
css: containerStyles,
|
|
174
|
-
ref: containerRef
|
|
175
|
-
}), isVisible && (0, _react2.jsx)(_tooltip.default, {
|
|
176
|
-
content: configureLinkLabel
|
|
177
|
-
}, function (tooltipProps) {
|
|
178
|
-
return (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)("span", {
|
|
179
|
-
"aria-hidden": "true",
|
|
180
|
-
className: OVERLAY_MARKER_CLASSNAME
|
|
181
|
-
}, _whitespace.ZERO_WIDTH_JOINER), (0, _react2.jsx)("span", {
|
|
182
|
-
css: [overlayStyles, showOverlay && showOverlayStyles],
|
|
183
|
-
tabIndex: -1,
|
|
184
|
-
"data-testid": testId
|
|
185
|
-
}, (0, _react2.jsx)("span", (0, _extends2.default)({}, tooltipProps, {
|
|
186
|
-
css: iconAndLabelStyles
|
|
187
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
188
|
-
,
|
|
189
|
-
className: ICON_AND_LABEL_CLASSNAME
|
|
190
|
-
}), (0, _react2.jsx)("span", {
|
|
191
|
-
css: iconStyles
|
|
192
|
-
}, (0, _react2.jsx)(_preferences.default, {
|
|
193
|
-
label: configureLinkLabel,
|
|
194
|
-
size: 'small',
|
|
195
|
-
testId: "".concat(testId, "-icon")
|
|
196
|
-
})))));
|
|
197
|
-
}), children);
|
|
198
|
-
};
|
|
199
|
-
var _default = exports.default = LeftIconOverlay;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { useIntl } from 'react-intl-next';
|
|
4
|
-
import Button from '@atlaskit/button/new';
|
|
5
|
-
import DropdownMenu, { DropdownItem, DropdownItemGroup } from '@atlaskit/dropdown-menu';
|
|
6
|
-
import { cardMessages as messages } from '@atlaskit/editor-common/messages';
|
|
7
|
-
import ChevronDownIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
8
|
-
import PreferencesIcon from '@atlaskit/icon/glyph/preferences';
|
|
9
|
-
import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
|
|
10
|
-
const ConfigureLinkDropdown = props => {
|
|
11
|
-
const {
|
|
12
|
-
testId
|
|
13
|
-
} = props;
|
|
14
|
-
const intl = useIntl();
|
|
15
|
-
const configureLinkLabel = intl.formatMessage(messages.inlineConfigureLink);
|
|
16
|
-
const goToLinkLabel = intl.formatMessage(messages.inlineConfigureLink);
|
|
17
|
-
return /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
18
|
-
trigger: ({
|
|
19
|
-
triggerRef,
|
|
20
|
-
...props
|
|
21
|
-
}) => /*#__PURE__*/React.createElement(Button, _extends({}, props, {
|
|
22
|
-
spacing: 'none',
|
|
23
|
-
ref: triggerRef
|
|
24
|
-
}), /*#__PURE__*/React.createElement("span", {
|
|
25
|
-
style: {
|
|
26
|
-
padding: `0 ${"var(--ds-space-025, 2px)"}`
|
|
27
|
-
}
|
|
28
|
-
}, /*#__PURE__*/React.createElement(ChevronDownIcon, {
|
|
29
|
-
label: configureLinkLabel,
|
|
30
|
-
size: 'small',
|
|
31
|
-
testId: `${testId}-icon`
|
|
32
|
-
}))),
|
|
33
|
-
spacing: 'compact',
|
|
34
|
-
placement: 'bottom-start'
|
|
35
|
-
}, /*#__PURE__*/React.createElement(DropdownItemGroup, null, /*#__PURE__*/React.createElement(DropdownItem, {
|
|
36
|
-
elemBefore: /*#__PURE__*/React.createElement(ShortcutIcon, {
|
|
37
|
-
label: goToLinkLabel,
|
|
38
|
-
size: 'small'
|
|
39
|
-
})
|
|
40
|
-
}, goToLinkLabel), /*#__PURE__*/React.createElement(DropdownItem, {
|
|
41
|
-
elemBefore: /*#__PURE__*/React.createElement(PreferencesIcon, {
|
|
42
|
-
label: configureLinkLabel,
|
|
43
|
-
size: 'small'
|
|
44
|
-
})
|
|
45
|
-
}, configureLinkLabel)));
|
|
46
|
-
};
|
|
47
|
-
export default ConfigureLinkDropdown;
|
|
@@ -1,177 +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
|
-
/** @jsx jsx */
|
|
5
|
-
import React, { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
|
-
import { css, jsx } from '@emotion/react';
|
|
9
|
-
import debounce from 'lodash/debounce';
|
|
10
|
-
import { useIntl } from 'react-intl-next';
|
|
11
|
-
import { cardMessages as messages } from '@atlaskit/editor-common/messages';
|
|
12
|
-
import { ZERO_WIDTH_JOINER } from '@atlaskit/editor-common/whitespace';
|
|
13
|
-
import PreferencesIcon from '@atlaskit/icon/glyph/preferences';
|
|
14
|
-
import { N0, N30A, N40A, N60A, N700 } from '@atlaskit/theme/colors';
|
|
15
|
-
import Tooltip from '@atlaskit/tooltip';
|
|
16
|
-
import { getChildElement, getInlineCardAvailableWidth, isOneLine } from '../InlineCardOverlay/utils';
|
|
17
|
-
const DEBOUNCE_IN_MS = 5;
|
|
18
|
-
const PADDING_IN_PX = 4;
|
|
19
|
-
const ICON_WIDTH_IN_PX = 16;
|
|
20
|
-
const ICON_AND_LABEL_CLASSNAME = 'ak-editor-card-overlay-icon-and-label';
|
|
21
|
-
const OVERLAY_MARKER_CLASSNAME = 'ak-editor-card-overlay-marker';
|
|
22
|
-
const TEXT_NODE_SELECTOR = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].join(',');
|
|
23
|
-
const SMART_LINK_BACKGROUND_COLOR = `var(--ds-surface-raised, ${N0})`;
|
|
24
|
-
const CONFIGURE_ICON_BACKGROUND_COLOR = `var(--ds-background-neutral, ${N30A})`;
|
|
25
|
-
const CONFIGURE_ICON_BACKGROUND_HOVERED_COLOR = `var(--ds-background-neutral-hovered, ${N40A})`;
|
|
26
|
-
const CONFIGURE_ICON_BACKGROUND_ACTIVE_COLOR = `var(--ds-background-neutral-pressed, ${N60A})`;
|
|
27
|
-
const containerStyles = css({
|
|
28
|
-
position: 'relative',
|
|
29
|
-
lineHeight: 'normal'
|
|
30
|
-
});
|
|
31
|
-
const overlayStyles = css({
|
|
32
|
-
position: 'absolute',
|
|
33
|
-
// Vertically align. Required for overlay to be centered inside the inline link (the inline lozenge is slightly larger than the designs)
|
|
34
|
-
transform: 'translate(0%, -50%)',
|
|
35
|
-
top: '50%',
|
|
36
|
-
// Set default styling to be invisible but available in dom for width calculation.
|
|
37
|
-
visibility: 'hidden',
|
|
38
|
-
overflow: 'hidden',
|
|
39
|
-
// EDM-1717: box-shadow Safari fix bring load wrapper zIndex to 1
|
|
40
|
-
zIndex: 2
|
|
41
|
-
});
|
|
42
|
-
const showOverlayStyles = css({
|
|
43
|
-
visibility: 'visible'
|
|
44
|
-
});
|
|
45
|
-
const iconStyles = css({
|
|
46
|
-
background: CONFIGURE_ICON_BACKGROUND_COLOR,
|
|
47
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
48
|
-
':hover': {
|
|
49
|
-
background: CONFIGURE_ICON_BACKGROUND_HOVERED_COLOR
|
|
50
|
-
},
|
|
51
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
52
|
-
':active': {
|
|
53
|
-
background: CONFIGURE_ICON_BACKGROUND_ACTIVE_COLOR
|
|
54
|
-
},
|
|
55
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
56
|
-
span: {
|
|
57
|
-
// If PreferencesIcon left as inline-block (default), height is incorrect and border radius is clipped when parent element
|
|
58
|
-
// uses 1lh height (rather than 100%)
|
|
59
|
-
display: 'block'
|
|
60
|
-
},
|
|
61
|
-
// Note: The spec recomends 3px, but the icon doesn't fit left of the lozenge text if this size
|
|
62
|
-
padding: "var(--ds-space-025, 2px)",
|
|
63
|
-
borderRadius: '3px'
|
|
64
|
-
});
|
|
65
|
-
const iconAndLabelStyles = css({
|
|
66
|
-
display: 'flex',
|
|
67
|
-
alignItems: 'center',
|
|
68
|
-
height: '100%',
|
|
69
|
-
// eslint-disable-next-line @atlaskit/design-system/use-tokens-space
|
|
70
|
-
marginLeft: '2.5px',
|
|
71
|
-
// Margin from very left of entire card (inclusive of blue)
|
|
72
|
-
|
|
73
|
-
// This exists so if we set a semi-transparent background above, the provider icon doesn't show
|
|
74
|
-
background: SMART_LINK_BACKGROUND_COLOR,
|
|
75
|
-
// Ensure we don't have a white gap when the inline-card is in an active state
|
|
76
|
-
borderRadius: '3px',
|
|
77
|
-
color: `var(--ds-text-subtlest, ${N700})`
|
|
78
|
-
});
|
|
79
|
-
const LeftIconOverlay = ({
|
|
80
|
-
children,
|
|
81
|
-
isSelected = false,
|
|
82
|
-
isVisible = false,
|
|
83
|
-
testId = 'inline-card-overlay',
|
|
84
|
-
...props
|
|
85
|
-
}) => {
|
|
86
|
-
const [showOverlay, setShowOverlay] = useState(false);
|
|
87
|
-
const [availableWidth, setAvailableWidth] = useState(undefined);
|
|
88
|
-
const containerRef = useRef(null);
|
|
89
|
-
|
|
90
|
-
// TODO EDM-9853: Use availableWidth for small link edge case
|
|
91
|
-
// Calculation logic will need to updated.
|
|
92
|
-
availableWidth;
|
|
93
|
-
const setVisibility = useCallback(() => {
|
|
94
|
-
if (!containerRef.current) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
const marker = getChildElement(containerRef, `.${OVERLAY_MARKER_CLASSNAME}`);
|
|
98
|
-
if (!marker) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
try {
|
|
102
|
-
const oneLine = isOneLine(containerRef.current, marker);
|
|
103
|
-
|
|
104
|
-
// Get the width of the available space to display overlay.
|
|
105
|
-
// This is the width of the inline link itself. If the inline
|
|
106
|
-
// is wrapped to the next line, this is width of the last line.
|
|
107
|
-
const availableWidth = getInlineCardAvailableWidth(containerRef.current, marker) - PADDING_IN_PX - (
|
|
108
|
-
// Always leave at least the icon visible
|
|
109
|
-
oneLine ? ICON_WIDTH_IN_PX + PADDING_IN_PX : 0);
|
|
110
|
-
setAvailableWidth(availableWidth);
|
|
111
|
-
const canShowOverlay = !isSelected;
|
|
112
|
-
setShowOverlay(canShowOverlay);
|
|
113
|
-
} catch {
|
|
114
|
-
// If something goes wrong, hide the overlay all together.
|
|
115
|
-
setShowOverlay(false);
|
|
116
|
-
}
|
|
117
|
-
}, [isSelected]);
|
|
118
|
-
useLayoutEffect(() => {
|
|
119
|
-
if (!containerRef.current) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
if (isVisible) {
|
|
123
|
-
setVisibility();
|
|
124
|
-
}
|
|
125
|
-
}, [setVisibility, isVisible]);
|
|
126
|
-
useEffect(() => {
|
|
127
|
-
var _containerRef$current;
|
|
128
|
-
// Find the closest block parent to observe size change
|
|
129
|
-
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);
|
|
130
|
-
if (!parent) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
const updateOverlay = debounce(entries => {
|
|
134
|
-
var _entries$, _entries$$contentBoxS, _entries$$contentBoxS2;
|
|
135
|
-
if (!isVisible) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
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;
|
|
139
|
-
if (!size) {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
setVisibility();
|
|
143
|
-
}, DEBOUNCE_IN_MS);
|
|
144
|
-
const observer = new ResizeObserver(updateOverlay);
|
|
145
|
-
observer.observe(parent);
|
|
146
|
-
return () => {
|
|
147
|
-
observer.disconnect();
|
|
148
|
-
};
|
|
149
|
-
}, [isVisible, setVisibility]);
|
|
150
|
-
const intl = useIntl();
|
|
151
|
-
const configureLinkLabel = intl.formatMessage(messages.inlineConfigureLink);
|
|
152
|
-
return jsx("span", _extends({}, props, {
|
|
153
|
-
css: containerStyles,
|
|
154
|
-
ref: containerRef
|
|
155
|
-
}), isVisible && jsx(Tooltip, {
|
|
156
|
-
content: configureLinkLabel
|
|
157
|
-
}, tooltipProps => jsx(React.Fragment, null, jsx("span", {
|
|
158
|
-
"aria-hidden": "true",
|
|
159
|
-
className: OVERLAY_MARKER_CLASSNAME
|
|
160
|
-
}, ZERO_WIDTH_JOINER), jsx("span", {
|
|
161
|
-
css: [overlayStyles, showOverlay && showOverlayStyles],
|
|
162
|
-
tabIndex: -1,
|
|
163
|
-
"data-testid": testId
|
|
164
|
-
}, jsx("span", _extends({}, tooltipProps, {
|
|
165
|
-
css: iconAndLabelStyles
|
|
166
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
167
|
-
,
|
|
168
|
-
className: ICON_AND_LABEL_CLASSNAME
|
|
169
|
-
}), jsx("span", {
|
|
170
|
-
css: iconStyles
|
|
171
|
-
}, jsx(PreferencesIcon, {
|
|
172
|
-
label: configureLinkLabel,
|
|
173
|
-
size: 'small',
|
|
174
|
-
testId: `${testId}-icon`
|
|
175
|
-
})))))), children);
|
|
176
|
-
};
|
|
177
|
-
export default LeftIconOverlay;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["triggerRef"];
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import { useIntl } from 'react-intl-next';
|
|
6
|
-
import Button from '@atlaskit/button/new';
|
|
7
|
-
import DropdownMenu, { DropdownItem, DropdownItemGroup } from '@atlaskit/dropdown-menu';
|
|
8
|
-
import { cardMessages as messages } from '@atlaskit/editor-common/messages';
|
|
9
|
-
import ChevronDownIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
10
|
-
import PreferencesIcon from '@atlaskit/icon/glyph/preferences';
|
|
11
|
-
import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
|
|
12
|
-
var ConfigureLinkDropdown = function ConfigureLinkDropdown(props) {
|
|
13
|
-
var testId = props.testId;
|
|
14
|
-
var intl = useIntl();
|
|
15
|
-
var configureLinkLabel = intl.formatMessage(messages.inlineConfigureLink);
|
|
16
|
-
var goToLinkLabel = intl.formatMessage(messages.inlineConfigureLink);
|
|
17
|
-
return /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
18
|
-
trigger: function trigger(_ref) {
|
|
19
|
-
var triggerRef = _ref.triggerRef,
|
|
20
|
-
props = _objectWithoutProperties(_ref, _excluded);
|
|
21
|
-
return /*#__PURE__*/React.createElement(Button, _extends({}, props, {
|
|
22
|
-
spacing: 'none',
|
|
23
|
-
ref: triggerRef
|
|
24
|
-
}), /*#__PURE__*/React.createElement("span", {
|
|
25
|
-
style: {
|
|
26
|
-
padding: "0 ".concat("var(--ds-space-025, 2px)")
|
|
27
|
-
}
|
|
28
|
-
}, /*#__PURE__*/React.createElement(ChevronDownIcon, {
|
|
29
|
-
label: configureLinkLabel,
|
|
30
|
-
size: 'small',
|
|
31
|
-
testId: "".concat(testId, "-icon")
|
|
32
|
-
})));
|
|
33
|
-
},
|
|
34
|
-
spacing: 'compact',
|
|
35
|
-
placement: 'bottom-start'
|
|
36
|
-
}, /*#__PURE__*/React.createElement(DropdownItemGroup, null, /*#__PURE__*/React.createElement(DropdownItem, {
|
|
37
|
-
elemBefore: /*#__PURE__*/React.createElement(ShortcutIcon, {
|
|
38
|
-
label: goToLinkLabel,
|
|
39
|
-
size: 'small'
|
|
40
|
-
})
|
|
41
|
-
}, goToLinkLabel), /*#__PURE__*/React.createElement(DropdownItem, {
|
|
42
|
-
elemBefore: /*#__PURE__*/React.createElement(PreferencesIcon, {
|
|
43
|
-
label: configureLinkLabel,
|
|
44
|
-
size: 'small'
|
|
45
|
-
})
|
|
46
|
-
}, configureLinkLabel)));
|
|
47
|
-
};
|
|
48
|
-
export default ConfigureLinkDropdown;
|
|
@@ -1,190 +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
|
-
var _excluded = ["children", "isSelected", "isVisible", "testId"];
|
|
5
|
-
/* eslint-disable @atlaskit/design-system/no-nested-styles */
|
|
6
|
-
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
7
|
-
/** @jsx jsx */
|
|
8
|
-
import React, { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
9
|
-
|
|
10
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
11
|
-
import { css, jsx } from '@emotion/react';
|
|
12
|
-
import debounce from 'lodash/debounce';
|
|
13
|
-
import { useIntl } from 'react-intl-next';
|
|
14
|
-
import { cardMessages as messages } from '@atlaskit/editor-common/messages';
|
|
15
|
-
import { ZERO_WIDTH_JOINER } from '@atlaskit/editor-common/whitespace';
|
|
16
|
-
import PreferencesIcon from '@atlaskit/icon/glyph/preferences';
|
|
17
|
-
import { N0, N30A, N40A, N60A, N700 } from '@atlaskit/theme/colors';
|
|
18
|
-
import Tooltip from '@atlaskit/tooltip';
|
|
19
|
-
import { getChildElement, getInlineCardAvailableWidth, isOneLine } from '../InlineCardOverlay/utils';
|
|
20
|
-
var DEBOUNCE_IN_MS = 5;
|
|
21
|
-
var PADDING_IN_PX = 4;
|
|
22
|
-
var ICON_WIDTH_IN_PX = 16;
|
|
23
|
-
var ICON_AND_LABEL_CLASSNAME = 'ak-editor-card-overlay-icon-and-label';
|
|
24
|
-
var OVERLAY_MARKER_CLASSNAME = 'ak-editor-card-overlay-marker';
|
|
25
|
-
var TEXT_NODE_SELECTOR = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].join(',');
|
|
26
|
-
var SMART_LINK_BACKGROUND_COLOR = "var(--ds-surface-raised, ".concat(N0, ")");
|
|
27
|
-
var CONFIGURE_ICON_BACKGROUND_COLOR = "var(--ds-background-neutral, ".concat(N30A, ")");
|
|
28
|
-
var CONFIGURE_ICON_BACKGROUND_HOVERED_COLOR = "var(--ds-background-neutral-hovered, ".concat(N40A, ")");
|
|
29
|
-
var CONFIGURE_ICON_BACKGROUND_ACTIVE_COLOR = "var(--ds-background-neutral-pressed, ".concat(N60A, ")");
|
|
30
|
-
var containerStyles = css({
|
|
31
|
-
position: 'relative',
|
|
32
|
-
lineHeight: 'normal'
|
|
33
|
-
});
|
|
34
|
-
var overlayStyles = css({
|
|
35
|
-
position: 'absolute',
|
|
36
|
-
// Vertically align. Required for overlay to be centered inside the inline link (the inline lozenge is slightly larger than the designs)
|
|
37
|
-
transform: 'translate(0%, -50%)',
|
|
38
|
-
top: '50%',
|
|
39
|
-
// Set default styling to be invisible but available in dom for width calculation.
|
|
40
|
-
visibility: 'hidden',
|
|
41
|
-
overflow: 'hidden',
|
|
42
|
-
// EDM-1717: box-shadow Safari fix bring load wrapper zIndex to 1
|
|
43
|
-
zIndex: 2
|
|
44
|
-
});
|
|
45
|
-
var showOverlayStyles = css({
|
|
46
|
-
visibility: 'visible'
|
|
47
|
-
});
|
|
48
|
-
var iconStyles = css({
|
|
49
|
-
background: CONFIGURE_ICON_BACKGROUND_COLOR,
|
|
50
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
51
|
-
':hover': {
|
|
52
|
-
background: CONFIGURE_ICON_BACKGROUND_HOVERED_COLOR
|
|
53
|
-
},
|
|
54
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
55
|
-
':active': {
|
|
56
|
-
background: CONFIGURE_ICON_BACKGROUND_ACTIVE_COLOR
|
|
57
|
-
},
|
|
58
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
59
|
-
span: {
|
|
60
|
-
// If PreferencesIcon left as inline-block (default), height is incorrect and border radius is clipped when parent element
|
|
61
|
-
// uses 1lh height (rather than 100%)
|
|
62
|
-
display: 'block'
|
|
63
|
-
},
|
|
64
|
-
// Note: The spec recomends 3px, but the icon doesn't fit left of the lozenge text if this size
|
|
65
|
-
padding: "var(--ds-space-025, 2px)",
|
|
66
|
-
borderRadius: '3px'
|
|
67
|
-
});
|
|
68
|
-
var iconAndLabelStyles = css({
|
|
69
|
-
display: 'flex',
|
|
70
|
-
alignItems: 'center',
|
|
71
|
-
height: '100%',
|
|
72
|
-
// eslint-disable-next-line @atlaskit/design-system/use-tokens-space
|
|
73
|
-
marginLeft: '2.5px',
|
|
74
|
-
// Margin from very left of entire card (inclusive of blue)
|
|
75
|
-
|
|
76
|
-
// This exists so if we set a semi-transparent background above, the provider icon doesn't show
|
|
77
|
-
background: SMART_LINK_BACKGROUND_COLOR,
|
|
78
|
-
// Ensure we don't have a white gap when the inline-card is in an active state
|
|
79
|
-
borderRadius: '3px',
|
|
80
|
-
color: "var(--ds-text-subtlest, ".concat(N700, ")")
|
|
81
|
-
});
|
|
82
|
-
var LeftIconOverlay = function LeftIconOverlay(_ref) {
|
|
83
|
-
var children = _ref.children,
|
|
84
|
-
_ref$isSelected = _ref.isSelected,
|
|
85
|
-
isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
|
|
86
|
-
_ref$isVisible = _ref.isVisible,
|
|
87
|
-
isVisible = _ref$isVisible === void 0 ? false : _ref$isVisible,
|
|
88
|
-
_ref$testId = _ref.testId,
|
|
89
|
-
testId = _ref$testId === void 0 ? 'inline-card-overlay' : _ref$testId,
|
|
90
|
-
props = _objectWithoutProperties(_ref, _excluded);
|
|
91
|
-
var _useState = useState(false),
|
|
92
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
93
|
-
showOverlay = _useState2[0],
|
|
94
|
-
setShowOverlay = _useState2[1];
|
|
95
|
-
var _useState3 = useState(undefined),
|
|
96
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
97
|
-
availableWidth = _useState4[0],
|
|
98
|
-
setAvailableWidth = _useState4[1];
|
|
99
|
-
var containerRef = useRef(null);
|
|
100
|
-
|
|
101
|
-
// TODO EDM-9853: Use availableWidth for small link edge case
|
|
102
|
-
// Calculation logic will need to updated.
|
|
103
|
-
availableWidth;
|
|
104
|
-
var setVisibility = useCallback(function () {
|
|
105
|
-
if (!containerRef.current) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
var marker = getChildElement(containerRef, ".".concat(OVERLAY_MARKER_CLASSNAME));
|
|
109
|
-
if (!marker) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
try {
|
|
113
|
-
var oneLine = isOneLine(containerRef.current, marker);
|
|
114
|
-
|
|
115
|
-
// Get the width of the available space to display overlay.
|
|
116
|
-
// This is the width of the inline link itself. If the inline
|
|
117
|
-
// is wrapped to the next line, this is width of the last line.
|
|
118
|
-
var _availableWidth = getInlineCardAvailableWidth(containerRef.current, marker) - PADDING_IN_PX - (
|
|
119
|
-
// Always leave at least the icon visible
|
|
120
|
-
oneLine ? ICON_WIDTH_IN_PX + PADDING_IN_PX : 0);
|
|
121
|
-
setAvailableWidth(_availableWidth);
|
|
122
|
-
var canShowOverlay = !isSelected;
|
|
123
|
-
setShowOverlay(canShowOverlay);
|
|
124
|
-
} catch (_unused) {
|
|
125
|
-
// If something goes wrong, hide the overlay all together.
|
|
126
|
-
setShowOverlay(false);
|
|
127
|
-
}
|
|
128
|
-
}, [isSelected]);
|
|
129
|
-
useLayoutEffect(function () {
|
|
130
|
-
if (!containerRef.current) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
if (isVisible) {
|
|
134
|
-
setVisibility();
|
|
135
|
-
}
|
|
136
|
-
}, [setVisibility, isVisible]);
|
|
137
|
-
useEffect(function () {
|
|
138
|
-
var _containerRef$current;
|
|
139
|
-
// Find the closest block parent to observe size change
|
|
140
|
-
var parent = containerRef === null || containerRef === void 0 || (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.closest(TEXT_NODE_SELECTOR);
|
|
141
|
-
if (!parent) {
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
var updateOverlay = debounce(function (entries) {
|
|
145
|
-
var _entries$;
|
|
146
|
-
if (!isVisible) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
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;
|
|
150
|
-
if (!size) {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
setVisibility();
|
|
154
|
-
}, DEBOUNCE_IN_MS);
|
|
155
|
-
var observer = new ResizeObserver(updateOverlay);
|
|
156
|
-
observer.observe(parent);
|
|
157
|
-
return function () {
|
|
158
|
-
observer.disconnect();
|
|
159
|
-
};
|
|
160
|
-
}, [isVisible, setVisibility]);
|
|
161
|
-
var intl = useIntl();
|
|
162
|
-
var configureLinkLabel = intl.formatMessage(messages.inlineConfigureLink);
|
|
163
|
-
return jsx("span", _extends({}, props, {
|
|
164
|
-
css: containerStyles,
|
|
165
|
-
ref: containerRef
|
|
166
|
-
}), isVisible && jsx(Tooltip, {
|
|
167
|
-
content: configureLinkLabel
|
|
168
|
-
}, function (tooltipProps) {
|
|
169
|
-
return jsx(React.Fragment, null, jsx("span", {
|
|
170
|
-
"aria-hidden": "true",
|
|
171
|
-
className: OVERLAY_MARKER_CLASSNAME
|
|
172
|
-
}, ZERO_WIDTH_JOINER), jsx("span", {
|
|
173
|
-
css: [overlayStyles, showOverlay && showOverlayStyles],
|
|
174
|
-
tabIndex: -1,
|
|
175
|
-
"data-testid": testId
|
|
176
|
-
}, jsx("span", _extends({}, tooltipProps, {
|
|
177
|
-
css: iconAndLabelStyles
|
|
178
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
179
|
-
,
|
|
180
|
-
className: ICON_AND_LABEL_CLASSNAME
|
|
181
|
-
}), jsx("span", {
|
|
182
|
-
css: iconStyles
|
|
183
|
-
}, jsx(PreferencesIcon, {
|
|
184
|
-
label: configureLinkLabel,
|
|
185
|
-
size: 'small',
|
|
186
|
-
testId: "".concat(testId, "-icon")
|
|
187
|
-
})))));
|
|
188
|
-
}), children);
|
|
189
|
-
};
|
|
190
|
-
export default LeftIconOverlay;
|