@atlaskit/editor-plugin-card 7.1.0 → 7.2.1
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 +27 -0
- package/dist/cjs/nodeviews/embedCard.js +51 -4
- package/dist/cjs/nodeviews/genericCard.js +2 -19
- package/dist/cjs/nodeviews/inlineCard.js +1 -45
- package/dist/cjs/nodeviews/inlineCardWithAwareness.js +34 -18
- package/dist/cjs/pm-plugins/main.js +4 -24
- package/dist/cjs/ui/{OpenButtonOverlay → HoverLinkOverlay}/index.js +26 -14
- package/dist/cjs/ui/toolbar.js +8 -1
- package/dist/es2019/nodeviews/embedCard.js +49 -4
- package/dist/es2019/nodeviews/genericCard.js +2 -19
- package/dist/es2019/nodeviews/inlineCard.js +2 -42
- package/dist/es2019/nodeviews/inlineCardWithAwareness.js +34 -18
- package/dist/es2019/pm-plugins/main.js +1 -23
- package/dist/es2019/ui/{OpenButtonOverlay → HoverLinkOverlay}/index.js +25 -14
- package/dist/es2019/ui/toolbar.js +8 -1
- package/dist/esm/nodeviews/embedCard.js +51 -4
- package/dist/esm/nodeviews/genericCard.js +2 -19
- package/dist/esm/nodeviews/inlineCard.js +2 -46
- package/dist/esm/nodeviews/inlineCardWithAwareness.js +34 -18
- package/dist/esm/pm-plugins/main.js +3 -23
- package/dist/esm/ui/{OpenButtonOverlay → HoverLinkOverlay}/index.js +26 -14
- package/dist/esm/ui/toolbar.js +8 -1
- package/dist/types/nodeviews/embedCard.d.ts +2 -1
- package/dist/types/nodeviews/inlineCard.d.ts +1 -1
- package/dist/types/pm-plugins/main.d.ts +0 -2
- package/dist/types/ui/HoverLinkOverlay/index.d.ts +9 -0
- package/dist/types/ui/{OpenButtonOverlay → HoverLinkOverlay}/types.d.ts +3 -1
- package/dist/types/ui/datasourceErrorBoundary.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/embedCard.d.ts +2 -1
- package/dist/types-ts4.5/nodeviews/inlineCard.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +0 -2
- package/dist/types-ts4.5/ui/HoverLinkOverlay/index.d.ts +9 -0
- package/dist/types-ts4.5/ui/{OpenButtonOverlay → HoverLinkOverlay}/types.d.ts +3 -1
- package/dist/types-ts4.5/ui/datasourceErrorBoundary.d.ts +1 -1
- package/package.json +6 -8
- package/dist/cjs/ui/PanelButtonOverlay/index.js +0 -171
- package/dist/cjs/ui/PanelButtonOverlay/types.js +0 -5
- package/dist/es2019/ui/PanelButtonOverlay/index.js +0 -148
- package/dist/esm/ui/OpenButtonOverlay/types.js +0 -1
- package/dist/esm/ui/PanelButtonOverlay/index.js +0 -158
- package/dist/esm/ui/PanelButtonOverlay/types.js +0 -1
- package/dist/types/ui/OpenButtonOverlay/index.d.ts +0 -9
- package/dist/types/ui/PanelButtonOverlay/index.d.ts +0 -9
- package/dist/types/ui/PanelButtonOverlay/types.d.ts +0 -7
- package/dist/types-ts4.5/ui/OpenButtonOverlay/index.d.ts +0 -9
- package/dist/types-ts4.5/ui/PanelButtonOverlay/index.d.ts +0 -9
- package/dist/types-ts4.5/ui/PanelButtonOverlay/types.d.ts +0 -7
- /package/dist/cjs/ui/{OpenButtonOverlay → HoverLinkOverlay}/types.js +0 -0
- /package/dist/es2019/ui/{OpenButtonOverlay → HoverLinkOverlay}/types.js +0 -0
- /package/dist/{es2019/ui/PanelButtonOverlay → esm/ui/HoverLinkOverlay}/types.js +0 -0
|
@@ -1,171 +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 _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
var _react2 = require("@emotion/react");
|
|
12
|
-
var _reactIntlNext = require("react-intl-next");
|
|
13
|
-
var _messages = require("@atlaskit/editor-common/messages");
|
|
14
|
-
var _panelRight = _interopRequireDefault(require("@atlaskit/icon/core/panel-right"));
|
|
15
|
-
var _primitives = require("@atlaskit/primitives");
|
|
16
|
-
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); }
|
|
17
|
-
/* eslint-disable @atlaskit/design-system/no-nested-styles */
|
|
18
|
-
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
19
|
-
/**
|
|
20
|
-
* @jsxRuntime classic
|
|
21
|
-
* @jsx jsx
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
// eslint-disable-line @atlaskit/ui-styling-standard/use-compiled
|
|
25
|
-
|
|
26
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
27
|
-
|
|
28
|
-
// eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
|
|
29
|
-
|
|
30
|
-
var containerStyles = (0, _react2.css)({
|
|
31
|
-
position: 'relative'
|
|
32
|
-
});
|
|
33
|
-
var iconWrapperStyles = (0, _primitives.xcss)({
|
|
34
|
-
display: 'inline-flex',
|
|
35
|
-
justifyContent: 'center',
|
|
36
|
-
alignItems: 'center',
|
|
37
|
-
height: '17px',
|
|
38
|
-
width: '17px'
|
|
39
|
-
});
|
|
40
|
-
var hiddenTextStyle = (0, _react2.css)({
|
|
41
|
-
overflow: 'hidden',
|
|
42
|
-
whiteSpace: 'nowrap',
|
|
43
|
-
position: 'absolute',
|
|
44
|
-
visibility: 'hidden'
|
|
45
|
-
});
|
|
46
|
-
var iconAndLabelWrapperStyles = (0, _primitives.xcss)({
|
|
47
|
-
position: 'absolute',
|
|
48
|
-
left: 'space.025',
|
|
49
|
-
top: '-1px',
|
|
50
|
-
cursor: 'pointer',
|
|
51
|
-
display: 'inline-flex',
|
|
52
|
-
alignItems: 'center',
|
|
53
|
-
verticalAlign: 'middle',
|
|
54
|
-
paddingInline: 'space.050',
|
|
55
|
-
gap: 'space.025',
|
|
56
|
-
overflow: 'hidden',
|
|
57
|
-
zIndex: 'card',
|
|
58
|
-
backgroundColor: 'color.background.accent.gray.subtlest',
|
|
59
|
-
borderRadius: "var(--ds-border-radius, 3px)",
|
|
60
|
-
color: 'color.text.subtle',
|
|
61
|
-
textDecoration: 'none',
|
|
62
|
-
whiteSpace: 'nowrap',
|
|
63
|
-
':hover': {
|
|
64
|
-
backgroundColor: 'elevation.surface.hovered',
|
|
65
|
-
color: 'color.text.subtle',
|
|
66
|
-
textDecoration: 'none'
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
var MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY = 45;
|
|
70
|
-
var ICON_WIDTH = 16;
|
|
71
|
-
var DEFAULT_PANEL_TEXT_WIDTH = 28; // Default panel text width in English
|
|
72
|
-
|
|
73
|
-
var PanelButtonOverlay = function PanelButtonOverlay(_ref) {
|
|
74
|
-
var children = _ref.children,
|
|
75
|
-
_ref$isVisible = _ref.isVisible,
|
|
76
|
-
isVisible = _ref$isVisible === void 0 ? false : _ref$isVisible,
|
|
77
|
-
editorAppearance = _ref.editorAppearance,
|
|
78
|
-
onClick = _ref.onClick;
|
|
79
|
-
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
80
|
-
formatMessage = _useIntl.formatMessage;
|
|
81
|
-
var label = formatMessage(_messages.cardMessages.panelButtonTitle);
|
|
82
|
-
var containerRef = (0, _react.useRef)(null);
|
|
83
|
-
var panelButtonRef = (0, _react.useRef)(null);
|
|
84
|
-
var hiddenTextRef = (0, _react.useRef)(null);
|
|
85
|
-
var _useState = (0, _react.useState)(true),
|
|
86
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
87
|
-
showLabel = _useState2[0],
|
|
88
|
-
setShowLabel = _useState2[1];
|
|
89
|
-
var _useState3 = (0, _react.useState)(false),
|
|
90
|
-
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
91
|
-
isHovered = _useState4[0],
|
|
92
|
-
setHovered = _useState4[1];
|
|
93
|
-
var panelTextWidthRef = (0, _react.useRef)(null);
|
|
94
|
-
(0, _react.useLayoutEffect)(function () {
|
|
95
|
-
var _containerRef$current, _panelButtonRef$curre;
|
|
96
|
-
if (!isVisible || !isHovered) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
var cardWidth = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.offsetWidth;
|
|
100
|
-
var panelButtonWidth = (_panelButtonRef$curre = panelButtonRef.current) === null || _panelButtonRef$curre === void 0 ? void 0 : _panelButtonRef$curre.offsetWidth;
|
|
101
|
-
|
|
102
|
-
// Get the hidden text width
|
|
103
|
-
if (!panelTextWidthRef.current) {
|
|
104
|
-
var hiddenText = hiddenTextRef.current;
|
|
105
|
-
if (hiddenText) {
|
|
106
|
-
// Measure the width of the hidden text
|
|
107
|
-
// Temporarily make the element visible to measure its width
|
|
108
|
-
hiddenText.style.visibility = 'hidden';
|
|
109
|
-
hiddenText.style.display = 'inline';
|
|
110
|
-
panelTextWidthRef.current = hiddenText.offsetWidth;
|
|
111
|
-
|
|
112
|
-
// Reset the hiddenText's display property
|
|
113
|
-
hiddenText.style.display = 'none';
|
|
114
|
-
hiddenText.style.visibility = 'inherit';
|
|
115
|
-
} else {
|
|
116
|
-
panelTextWidthRef.current = DEFAULT_PANEL_TEXT_WIDTH;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
if (!cardWidth || !panelButtonWidth) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
var panelTextWidth = panelTextWidthRef.current || DEFAULT_PANEL_TEXT_WIDTH;
|
|
123
|
-
var canShowLabel = cardWidth - panelTextWidth > MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY + ICON_WIDTH;
|
|
124
|
-
setShowLabel(canShowLabel);
|
|
125
|
-
}, [isVisible, isHovered]);
|
|
126
|
-
var handleOverlayChange = function handleOverlayChange(isHovered) {
|
|
127
|
-
setHovered(isHovered);
|
|
128
|
-
};
|
|
129
|
-
var handleClick = function handleClick() {
|
|
130
|
-
if (onClick) {
|
|
131
|
-
onClick();
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
return (
|
|
135
|
-
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
136
|
-
(0, _react2.jsx)("span", {
|
|
137
|
-
ref: containerRef,
|
|
138
|
-
css: containerStyles,
|
|
139
|
-
onMouseEnter: function onMouseEnter() {
|
|
140
|
-
return handleOverlayChange(true);
|
|
141
|
-
},
|
|
142
|
-
onMouseLeave: function onMouseLeave() {
|
|
143
|
-
return handleOverlayChange(false);
|
|
144
|
-
}
|
|
145
|
-
}, children, (0, _react2.jsx)("span", {
|
|
146
|
-
css: hiddenTextStyle,
|
|
147
|
-
"aria-hidden": "true"
|
|
148
|
-
}, (0, _react2.jsx)(_primitives.Text, {
|
|
149
|
-
ref: hiddenTextRef,
|
|
150
|
-
size: "small",
|
|
151
|
-
maxLines: 1
|
|
152
|
-
}, label)), isHovered && (0, _react2.jsx)(_primitives.Pressable, {
|
|
153
|
-
ref: panelButtonRef,
|
|
154
|
-
xcss: iconAndLabelWrapperStyles,
|
|
155
|
-
style: {
|
|
156
|
-
paddingBlock: editorAppearance === 'comment' || editorAppearance === 'chromeless' ? '1px' : "var(--ds-space-025, 2px)"
|
|
157
|
-
},
|
|
158
|
-
onClick: handleClick
|
|
159
|
-
}, (0, _react2.jsx)(_primitives.Box, {
|
|
160
|
-
xcss: iconWrapperStyles,
|
|
161
|
-
"data-inlinecard-button-overlay": "icon-wrapper-line-height"
|
|
162
|
-
}, (0, _react2.jsx)(_panelRight.default, {
|
|
163
|
-
label: ""
|
|
164
|
-
})), showLabel && (0, _react2.jsx)(_primitives.Text, {
|
|
165
|
-
size: "small",
|
|
166
|
-
color: "color.text.subtle",
|
|
167
|
-
maxLines: 1
|
|
168
|
-
}, label)))
|
|
169
|
-
);
|
|
170
|
-
};
|
|
171
|
-
var _default = exports.default = PanelButtonOverlay;
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @atlaskit/design-system/no-nested-styles */
|
|
2
|
-
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
3
|
-
/**
|
|
4
|
-
* @jsxRuntime classic
|
|
5
|
-
* @jsx jsx
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import React, { useLayoutEffect, useRef, useState } from 'react';
|
|
9
|
-
import { css, jsx } from '@emotion/react'; // eslint-disable-line @atlaskit/ui-styling-standard/use-compiled
|
|
10
|
-
import { useIntl } from 'react-intl-next';
|
|
11
|
-
import { cardMessages } from '@atlaskit/editor-common/messages';
|
|
12
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
13
|
-
import PanelRightIcon from '@atlaskit/icon/core/panel-right';
|
|
14
|
-
// eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
|
|
15
|
-
import { Box, Pressable, Text, xcss } from '@atlaskit/primitives';
|
|
16
|
-
const containerStyles = css({
|
|
17
|
-
position: 'relative'
|
|
18
|
-
});
|
|
19
|
-
const iconWrapperStyles = xcss({
|
|
20
|
-
display: 'inline-flex',
|
|
21
|
-
justifyContent: 'center',
|
|
22
|
-
alignItems: 'center',
|
|
23
|
-
height: '17px',
|
|
24
|
-
width: '17px'
|
|
25
|
-
});
|
|
26
|
-
const hiddenTextStyle = css({
|
|
27
|
-
overflow: 'hidden',
|
|
28
|
-
whiteSpace: 'nowrap',
|
|
29
|
-
position: 'absolute',
|
|
30
|
-
visibility: 'hidden'
|
|
31
|
-
});
|
|
32
|
-
const iconAndLabelWrapperStyles = xcss({
|
|
33
|
-
position: 'absolute',
|
|
34
|
-
left: 'space.025',
|
|
35
|
-
top: '-1px',
|
|
36
|
-
cursor: 'pointer',
|
|
37
|
-
display: 'inline-flex',
|
|
38
|
-
alignItems: 'center',
|
|
39
|
-
verticalAlign: 'middle',
|
|
40
|
-
paddingInline: 'space.050',
|
|
41
|
-
gap: 'space.025',
|
|
42
|
-
overflow: 'hidden',
|
|
43
|
-
zIndex: 'card',
|
|
44
|
-
backgroundColor: 'color.background.accent.gray.subtlest',
|
|
45
|
-
borderRadius: "var(--ds-border-radius, 3px)",
|
|
46
|
-
color: 'color.text.subtle',
|
|
47
|
-
textDecoration: 'none',
|
|
48
|
-
whiteSpace: 'nowrap',
|
|
49
|
-
':hover': {
|
|
50
|
-
backgroundColor: 'elevation.surface.hovered',
|
|
51
|
-
color: 'color.text.subtle',
|
|
52
|
-
textDecoration: 'none'
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
const MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY = 45;
|
|
56
|
-
const ICON_WIDTH = 16;
|
|
57
|
-
const DEFAULT_PANEL_TEXT_WIDTH = 28; // Default panel text width in English
|
|
58
|
-
|
|
59
|
-
const PanelButtonOverlay = ({
|
|
60
|
-
children,
|
|
61
|
-
isVisible = false,
|
|
62
|
-
editorAppearance,
|
|
63
|
-
onClick
|
|
64
|
-
}) => {
|
|
65
|
-
const {
|
|
66
|
-
formatMessage
|
|
67
|
-
} = useIntl();
|
|
68
|
-
const label = formatMessage(cardMessages.panelButtonTitle);
|
|
69
|
-
const containerRef = useRef(null);
|
|
70
|
-
const panelButtonRef = useRef(null);
|
|
71
|
-
const hiddenTextRef = useRef(null);
|
|
72
|
-
const [showLabel, setShowLabel] = useState(true);
|
|
73
|
-
const [isHovered, setHovered] = useState(false);
|
|
74
|
-
const panelTextWidthRef = useRef(null);
|
|
75
|
-
useLayoutEffect(() => {
|
|
76
|
-
var _containerRef$current, _panelButtonRef$curre;
|
|
77
|
-
if (!isVisible || !isHovered) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
const cardWidth = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.offsetWidth;
|
|
81
|
-
const panelButtonWidth = (_panelButtonRef$curre = panelButtonRef.current) === null || _panelButtonRef$curre === void 0 ? void 0 : _panelButtonRef$curre.offsetWidth;
|
|
82
|
-
|
|
83
|
-
// Get the hidden text width
|
|
84
|
-
if (!panelTextWidthRef.current) {
|
|
85
|
-
const hiddenText = hiddenTextRef.current;
|
|
86
|
-
if (hiddenText) {
|
|
87
|
-
// Measure the width of the hidden text
|
|
88
|
-
// Temporarily make the element visible to measure its width
|
|
89
|
-
hiddenText.style.visibility = 'hidden';
|
|
90
|
-
hiddenText.style.display = 'inline';
|
|
91
|
-
panelTextWidthRef.current = hiddenText.offsetWidth;
|
|
92
|
-
|
|
93
|
-
// Reset the hiddenText's display property
|
|
94
|
-
hiddenText.style.display = 'none';
|
|
95
|
-
hiddenText.style.visibility = 'inherit';
|
|
96
|
-
} else {
|
|
97
|
-
panelTextWidthRef.current = DEFAULT_PANEL_TEXT_WIDTH;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
if (!cardWidth || !panelButtonWidth) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
const panelTextWidth = panelTextWidthRef.current || DEFAULT_PANEL_TEXT_WIDTH;
|
|
104
|
-
const canShowLabel = cardWidth - panelTextWidth > MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY + ICON_WIDTH;
|
|
105
|
-
setShowLabel(canShowLabel);
|
|
106
|
-
}, [isVisible, isHovered]);
|
|
107
|
-
const handleOverlayChange = isHovered => {
|
|
108
|
-
setHovered(isHovered);
|
|
109
|
-
};
|
|
110
|
-
const handleClick = () => {
|
|
111
|
-
if (onClick) {
|
|
112
|
-
onClick();
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
return (
|
|
116
|
-
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
117
|
-
jsx("span", {
|
|
118
|
-
ref: containerRef,
|
|
119
|
-
css: containerStyles,
|
|
120
|
-
onMouseEnter: () => handleOverlayChange(true),
|
|
121
|
-
onMouseLeave: () => handleOverlayChange(false)
|
|
122
|
-
}, children, jsx("span", {
|
|
123
|
-
css: hiddenTextStyle,
|
|
124
|
-
"aria-hidden": "true"
|
|
125
|
-
}, jsx(Text, {
|
|
126
|
-
ref: hiddenTextRef,
|
|
127
|
-
size: "small",
|
|
128
|
-
maxLines: 1
|
|
129
|
-
}, label)), isHovered && jsx(Pressable, {
|
|
130
|
-
ref: panelButtonRef,
|
|
131
|
-
xcss: iconAndLabelWrapperStyles,
|
|
132
|
-
style: {
|
|
133
|
-
paddingBlock: editorAppearance === 'comment' || editorAppearance === 'chromeless' ? '1px' : "var(--ds-space-025, 2px)"
|
|
134
|
-
},
|
|
135
|
-
onClick: handleClick
|
|
136
|
-
}, jsx(Box, {
|
|
137
|
-
xcss: iconWrapperStyles,
|
|
138
|
-
"data-inlinecard-button-overlay": "icon-wrapper-line-height"
|
|
139
|
-
}, jsx(PanelRightIcon, {
|
|
140
|
-
label: ""
|
|
141
|
-
})), showLabel && jsx(Text, {
|
|
142
|
-
size: "small",
|
|
143
|
-
color: "color.text.subtle",
|
|
144
|
-
maxLines: 1
|
|
145
|
-
}, label)))
|
|
146
|
-
);
|
|
147
|
-
};
|
|
148
|
-
export default PanelButtonOverlay;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
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, { useLayoutEffect, useRef, useState } from 'react';
|
|
10
|
-
import { css, jsx } from '@emotion/react'; // eslint-disable-line @atlaskit/ui-styling-standard/use-compiled
|
|
11
|
-
import { useIntl } from 'react-intl-next';
|
|
12
|
-
import { cardMessages } from '@atlaskit/editor-common/messages';
|
|
13
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
14
|
-
import PanelRightIcon from '@atlaskit/icon/core/panel-right';
|
|
15
|
-
// eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
|
|
16
|
-
import { Box, Pressable, Text, xcss } from '@atlaskit/primitives';
|
|
17
|
-
var containerStyles = css({
|
|
18
|
-
position: 'relative'
|
|
19
|
-
});
|
|
20
|
-
var iconWrapperStyles = xcss({
|
|
21
|
-
display: 'inline-flex',
|
|
22
|
-
justifyContent: 'center',
|
|
23
|
-
alignItems: 'center',
|
|
24
|
-
height: '17px',
|
|
25
|
-
width: '17px'
|
|
26
|
-
});
|
|
27
|
-
var hiddenTextStyle = css({
|
|
28
|
-
overflow: 'hidden',
|
|
29
|
-
whiteSpace: 'nowrap',
|
|
30
|
-
position: 'absolute',
|
|
31
|
-
visibility: 'hidden'
|
|
32
|
-
});
|
|
33
|
-
var iconAndLabelWrapperStyles = xcss({
|
|
34
|
-
position: 'absolute',
|
|
35
|
-
left: 'space.025',
|
|
36
|
-
top: '-1px',
|
|
37
|
-
cursor: 'pointer',
|
|
38
|
-
display: 'inline-flex',
|
|
39
|
-
alignItems: 'center',
|
|
40
|
-
verticalAlign: 'middle',
|
|
41
|
-
paddingInline: 'space.050',
|
|
42
|
-
gap: 'space.025',
|
|
43
|
-
overflow: 'hidden',
|
|
44
|
-
zIndex: 'card',
|
|
45
|
-
backgroundColor: 'color.background.accent.gray.subtlest',
|
|
46
|
-
borderRadius: "var(--ds-border-radius, 3px)",
|
|
47
|
-
color: 'color.text.subtle',
|
|
48
|
-
textDecoration: 'none',
|
|
49
|
-
whiteSpace: 'nowrap',
|
|
50
|
-
':hover': {
|
|
51
|
-
backgroundColor: 'elevation.surface.hovered',
|
|
52
|
-
color: 'color.text.subtle',
|
|
53
|
-
textDecoration: 'none'
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
var MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY = 45;
|
|
57
|
-
var ICON_WIDTH = 16;
|
|
58
|
-
var DEFAULT_PANEL_TEXT_WIDTH = 28; // Default panel text width in English
|
|
59
|
-
|
|
60
|
-
var PanelButtonOverlay = function PanelButtonOverlay(_ref) {
|
|
61
|
-
var children = _ref.children,
|
|
62
|
-
_ref$isVisible = _ref.isVisible,
|
|
63
|
-
isVisible = _ref$isVisible === void 0 ? false : _ref$isVisible,
|
|
64
|
-
editorAppearance = _ref.editorAppearance,
|
|
65
|
-
onClick = _ref.onClick;
|
|
66
|
-
var _useIntl = useIntl(),
|
|
67
|
-
formatMessage = _useIntl.formatMessage;
|
|
68
|
-
var label = formatMessage(cardMessages.panelButtonTitle);
|
|
69
|
-
var containerRef = useRef(null);
|
|
70
|
-
var panelButtonRef = useRef(null);
|
|
71
|
-
var hiddenTextRef = useRef(null);
|
|
72
|
-
var _useState = useState(true),
|
|
73
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
74
|
-
showLabel = _useState2[0],
|
|
75
|
-
setShowLabel = _useState2[1];
|
|
76
|
-
var _useState3 = useState(false),
|
|
77
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
78
|
-
isHovered = _useState4[0],
|
|
79
|
-
setHovered = _useState4[1];
|
|
80
|
-
var panelTextWidthRef = useRef(null);
|
|
81
|
-
useLayoutEffect(function () {
|
|
82
|
-
var _containerRef$current, _panelButtonRef$curre;
|
|
83
|
-
if (!isVisible || !isHovered) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
var cardWidth = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.offsetWidth;
|
|
87
|
-
var panelButtonWidth = (_panelButtonRef$curre = panelButtonRef.current) === null || _panelButtonRef$curre === void 0 ? void 0 : _panelButtonRef$curre.offsetWidth;
|
|
88
|
-
|
|
89
|
-
// Get the hidden text width
|
|
90
|
-
if (!panelTextWidthRef.current) {
|
|
91
|
-
var hiddenText = hiddenTextRef.current;
|
|
92
|
-
if (hiddenText) {
|
|
93
|
-
// Measure the width of the hidden text
|
|
94
|
-
// Temporarily make the element visible to measure its width
|
|
95
|
-
hiddenText.style.visibility = 'hidden';
|
|
96
|
-
hiddenText.style.display = 'inline';
|
|
97
|
-
panelTextWidthRef.current = hiddenText.offsetWidth;
|
|
98
|
-
|
|
99
|
-
// Reset the hiddenText's display property
|
|
100
|
-
hiddenText.style.display = 'none';
|
|
101
|
-
hiddenText.style.visibility = 'inherit';
|
|
102
|
-
} else {
|
|
103
|
-
panelTextWidthRef.current = DEFAULT_PANEL_TEXT_WIDTH;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
if (!cardWidth || !panelButtonWidth) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
var panelTextWidth = panelTextWidthRef.current || DEFAULT_PANEL_TEXT_WIDTH;
|
|
110
|
-
var canShowLabel = cardWidth - panelTextWidth > MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY + ICON_WIDTH;
|
|
111
|
-
setShowLabel(canShowLabel);
|
|
112
|
-
}, [isVisible, isHovered]);
|
|
113
|
-
var handleOverlayChange = function handleOverlayChange(isHovered) {
|
|
114
|
-
setHovered(isHovered);
|
|
115
|
-
};
|
|
116
|
-
var handleClick = function handleClick() {
|
|
117
|
-
if (onClick) {
|
|
118
|
-
onClick();
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
return (
|
|
122
|
-
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
123
|
-
jsx("span", {
|
|
124
|
-
ref: containerRef,
|
|
125
|
-
css: containerStyles,
|
|
126
|
-
onMouseEnter: function onMouseEnter() {
|
|
127
|
-
return handleOverlayChange(true);
|
|
128
|
-
},
|
|
129
|
-
onMouseLeave: function onMouseLeave() {
|
|
130
|
-
return handleOverlayChange(false);
|
|
131
|
-
}
|
|
132
|
-
}, children, jsx("span", {
|
|
133
|
-
css: hiddenTextStyle,
|
|
134
|
-
"aria-hidden": "true"
|
|
135
|
-
}, jsx(Text, {
|
|
136
|
-
ref: hiddenTextRef,
|
|
137
|
-
size: "small",
|
|
138
|
-
maxLines: 1
|
|
139
|
-
}, label)), isHovered && jsx(Pressable, {
|
|
140
|
-
ref: panelButtonRef,
|
|
141
|
-
xcss: iconAndLabelWrapperStyles,
|
|
142
|
-
style: {
|
|
143
|
-
paddingBlock: editorAppearance === 'comment' || editorAppearance === 'chromeless' ? '1px' : "var(--ds-space-025, 2px)"
|
|
144
|
-
},
|
|
145
|
-
onClick: handleClick
|
|
146
|
-
}, jsx(Box, {
|
|
147
|
-
xcss: iconWrapperStyles,
|
|
148
|
-
"data-inlinecard-button-overlay": "icon-wrapper-line-height"
|
|
149
|
-
}, jsx(PanelRightIcon, {
|
|
150
|
-
label: ""
|
|
151
|
-
})), showLabel && jsx(Text, {
|
|
152
|
-
size: "small",
|
|
153
|
-
color: "color.text.subtle",
|
|
154
|
-
maxLines: 1
|
|
155
|
-
}, label)))
|
|
156
|
-
);
|
|
157
|
-
};
|
|
158
|
-
export default PanelButtonOverlay;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -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 { OpenButtonOverlayProps } from './types';
|
|
8
|
-
declare const OpenButtonOverlay: ({ children, isVisible, url, editorAppearance, editorAnalyticsApi, view, }: React.PropsWithChildren<OpenButtonOverlayProps>) => jsx.JSX.Element;
|
|
9
|
-
export default OpenButtonOverlay;
|
|
@@ -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 { PanelButtonOverlayProps } from '../PanelButtonOverlay/types';
|
|
8
|
-
declare const PanelButtonOverlay: ({ children, isVisible, editorAppearance, onClick, }: React.PropsWithChildren<PanelButtonOverlayProps>) => jsx.JSX.Element;
|
|
9
|
-
export default PanelButtonOverlay;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { EditorAppearance } from '@atlaskit/editor-common/types';
|
|
3
|
-
export type PanelButtonOverlayProps = React.HTMLAttributes<HTMLSpanElement> & {
|
|
4
|
-
isVisible?: boolean;
|
|
5
|
-
editorAppearance?: EditorAppearance;
|
|
6
|
-
onClick?: () => void;
|
|
7
|
-
};
|
|
@@ -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 { OpenButtonOverlayProps } from './types';
|
|
8
|
-
declare const OpenButtonOverlay: ({ children, isVisible, url, editorAppearance, editorAnalyticsApi, view, }: React.PropsWithChildren<OpenButtonOverlayProps>) => jsx.JSX.Element;
|
|
9
|
-
export default OpenButtonOverlay;
|
|
@@ -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 { PanelButtonOverlayProps } from '../PanelButtonOverlay/types';
|
|
8
|
-
declare const PanelButtonOverlay: ({ children, isVisible, editorAppearance, onClick, }: React.PropsWithChildren<PanelButtonOverlayProps>) => jsx.JSX.Element;
|
|
9
|
-
export default PanelButtonOverlay;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { EditorAppearance } from '@atlaskit/editor-common/types';
|
|
3
|
-
export type PanelButtonOverlayProps = React.HTMLAttributes<HTMLSpanElement> & {
|
|
4
|
-
isVisible?: boolean;
|
|
5
|
-
editorAppearance?: EditorAppearance;
|
|
6
|
-
onClick?: () => void;
|
|
7
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|