@atlaskit/editor-common 107.12.4 → 107.12.5

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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 107.12.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#188416](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/188416)
8
+ [`3d0ab988998ae`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3d0ab988998ae) -
9
+ [EDITOR-1067] Adding new actions to plus button in editor new command palette
10
+ - Updated dependencies
11
+
3
12
  ## 107.12.4
4
13
 
5
14
  ### Patch Changes
@@ -16,7 +16,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
16
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
17
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
18
18
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
19
- var packageVersion = "107.12.3";
19
+ var packageVersion = "107.12.4";
20
20
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
21
21
  // Remove URL as it has UGC
22
22
  // Ignored via go/ees007
@@ -23,7 +23,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
23
23
  * @jsx jsx
24
24
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
25
25
  var packageName = "@atlaskit/editor-common";
26
- var packageVersion = "107.12.3";
26
+ var packageVersion = "107.12.4";
27
27
  var halfFocusRing = 1;
28
28
  var dropOffset = '0, 8';
29
29
  // Ignored via go/ees005
@@ -0,0 +1,214 @@
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 _state = require("@atlaskit/editor-prosemirror/state");
14
+ var _linkExternal = _interopRequireDefault(require("@atlaskit/icon/core/link-external"));
15
+ var _panelRight = _interopRequireDefault(require("@atlaskit/icon/core/panel-right"));
16
+ var _primitives = require("@atlaskit/primitives");
17
+ var _analytics = require("../../analytics");
18
+ var _messages = require("../../messages");
19
+ 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); }
20
+ /* eslint-disable @atlaskit/design-system/no-nested-styles */
21
+ /* eslint-disable @atlaskit/design-system/prefer-primitives */
22
+ /**
23
+ * @jsxRuntime classic
24
+ * @jsx jsx
25
+ */
26
+
27
+ // eslint-disable-line @atlaskit/ui-styling-standard/use-compiled
28
+
29
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
30
+
31
+ // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
32
+
33
+ var containerStyles = (0, _react2.css)({
34
+ position: 'relative'
35
+ });
36
+ var iconWrapperStyles = (0, _primitives.xcss)({
37
+ display: 'inline-flex',
38
+ justifyContent: 'center',
39
+ alignItems: 'center',
40
+ height: '17px',
41
+ width: '17px'
42
+ });
43
+ var hiddenTextStyle = (0, _react2.css)({
44
+ overflow: 'hidden',
45
+ whiteSpace: 'nowrap',
46
+ position: 'absolute',
47
+ visibility: 'hidden'
48
+ });
49
+ var linkStyles = (0, _primitives.xcss)({
50
+ position: 'absolute',
51
+ left: 'space.025',
52
+ top: '-1px',
53
+ display: 'inline-flex',
54
+ alignItems: 'center',
55
+ verticalAlign: 'middle',
56
+ paddingBlock: 'space.025',
57
+ paddingInline: 'space.050',
58
+ gap: 'space.025',
59
+ overflow: 'hidden',
60
+ zIndex: 'card',
61
+ backgroundColor: 'color.background.accent.gray.subtlest',
62
+ borderRadius: "var(--ds-border-radius, 3px)",
63
+ color: 'color.text.subtle',
64
+ textDecoration: 'none',
65
+ whiteSpace: 'nowrap',
66
+ ':hover': {
67
+ backgroundColor: 'elevation.surface.hovered',
68
+ color: 'color.text.subtle',
69
+ textDecoration: 'none'
70
+ }
71
+ });
72
+ var MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY = 45;
73
+ var ICON_WIDTH = 16;
74
+ var DEFAULT_OPEN_TEXT_WIDTH = 28; // Default open text width in English
75
+
76
+ var visitCardLinkAnalytics = function visitCardLinkAnalytics(editorAnalyticsApi, inputMethod) {
77
+ return function (state, dispatch) {
78
+ if (!(state.selection instanceof _state.NodeSelection)) {
79
+ return false;
80
+ }
81
+ var type = state.selection.node.type;
82
+ if (dispatch) {
83
+ var tr = state.tr;
84
+ editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent((0, _analytics.buildVisitedNonHyperLinkPayload)(type.name, inputMethod))(tr);
85
+ dispatch(tr);
86
+ }
87
+ return true;
88
+ };
89
+ };
90
+ var HoverLinkOverlay = function HoverLinkOverlay(_ref) {
91
+ var children = _ref.children,
92
+ _ref$isVisible = _ref.isVisible,
93
+ isVisible = _ref$isVisible === void 0 ? false : _ref$isVisible,
94
+ url = _ref.url,
95
+ _ref$compactPadding = _ref.compactPadding,
96
+ compactPadding = _ref$compactPadding === void 0 ? false : _ref$compactPadding,
97
+ editorAnalyticsApi = _ref.editorAnalyticsApi,
98
+ view = _ref.view,
99
+ onClick = _ref.onClick,
100
+ _ref$showPanelButton = _ref.showPanelButton,
101
+ showPanelButton = _ref$showPanelButton === void 0 ? false : _ref$showPanelButton;
102
+ var _useIntl = (0, _reactIntlNext.useIntl)(),
103
+ formatMessage = _useIntl.formatMessage;
104
+ var label = showPanelButton ? formatMessage(_messages.cardMessages.panelButtonTitle) : formatMessage(_messages.cardMessages.openButtonTitle);
105
+ var containerRef = (0, _react.useRef)(null);
106
+ var hoverLinkButtonRef = (0, _react.useRef)(null);
107
+ var hiddenTextRef = (0, _react.useRef)(null);
108
+ var _useState = (0, _react.useState)(true),
109
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
110
+ showLabel = _useState2[0],
111
+ setShowLabel = _useState2[1];
112
+ var _useState3 = (0, _react.useState)(false),
113
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
114
+ isHovered = _useState4[0],
115
+ setHovered = _useState4[1];
116
+ var openTextWidthRef = (0, _react.useRef)(null);
117
+ (0, _react.useLayoutEffect)(function () {
118
+ var _containerRef$current, _hoverLinkButtonRef$c;
119
+ if (!isVisible || !isHovered) {
120
+ return;
121
+ }
122
+ var cardWidth = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.offsetWidth;
123
+ var openButtonWidth = (_hoverLinkButtonRef$c = hoverLinkButtonRef.current) === null || _hoverLinkButtonRef$c === void 0 ? void 0 : _hoverLinkButtonRef$c.offsetWidth;
124
+
125
+ // Get the hidden text width
126
+ if (!openTextWidthRef.current) {
127
+ var hiddenText = hiddenTextRef.current;
128
+ if (hiddenText) {
129
+ // Measure the width of the hidden text
130
+ // Temporarily make the element visible to measure its width
131
+ hiddenText.style.visibility = 'hidden';
132
+ hiddenText.style.display = 'inline';
133
+ openTextWidthRef.current = hiddenText.offsetWidth;
134
+
135
+ // Reset the hiddenText's display property
136
+ hiddenText.style.display = 'none';
137
+ hiddenText.style.visibility = 'inherit';
138
+ } else {
139
+ openTextWidthRef.current = DEFAULT_OPEN_TEXT_WIDTH;
140
+ }
141
+ }
142
+ if (!cardWidth || !openButtonWidth) {
143
+ return;
144
+ }
145
+ var openTextWidth = openTextWidthRef.current || DEFAULT_OPEN_TEXT_WIDTH;
146
+ var canShowLabel = cardWidth - openTextWidth > MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY + ICON_WIDTH;
147
+ setShowLabel(canShowLabel);
148
+ }, [isVisible, isHovered]);
149
+ var handleOverlayChange = function handleOverlayChange(isHovered) {
150
+ setHovered(isHovered);
151
+ };
152
+ var sendVisitLinkAnalytics = function sendVisitLinkAnalytics(inputMethod) {
153
+ if (editorAnalyticsApi && view) {
154
+ visitCardLinkAnalytics(editorAnalyticsApi, inputMethod)(view.state, view.dispatch);
155
+ }
156
+ };
157
+ var handleDoubleClick = function handleDoubleClick() {
158
+ if (!showPanelButton) {
159
+ sendVisitLinkAnalytics(_analytics.INPUT_METHOD.DOUBLE_CLICK);
160
+
161
+ // Double click opens the link in a new tab
162
+ window.open(url, '_blank');
163
+ }
164
+ };
165
+ var handleClick = function handleClick(event) {
166
+ if (showPanelButton && onClick) {
167
+ onClick(event);
168
+ } else {
169
+ sendVisitLinkAnalytics(_analytics.INPUT_METHOD.BUTTON);
170
+ }
171
+ };
172
+ return (
173
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
174
+ (0, _react2.jsx)("span", {
175
+ ref: containerRef,
176
+ css: containerStyles,
177
+ onDoubleClick: handleDoubleClick,
178
+ onMouseEnter: function onMouseEnter() {
179
+ return handleOverlayChange(true);
180
+ },
181
+ onMouseLeave: function onMouseLeave() {
182
+ return handleOverlayChange(false);
183
+ }
184
+ }, children, (0, _react2.jsx)("span", {
185
+ css: hiddenTextStyle,
186
+ "aria-hidden": "true"
187
+ }, (0, _react2.jsx)(_primitives.Text, {
188
+ ref: hiddenTextRef,
189
+ size: "small",
190
+ maxLines: 1
191
+ }, label)), isHovered && (0, _react2.jsx)(_primitives.Anchor, {
192
+ ref: hoverLinkButtonRef,
193
+ xcss: linkStyles,
194
+ href: url,
195
+ target: "_blank",
196
+ style: {
197
+ paddingBlock: compactPadding ? '1px' : "var(--ds-space-025, 2px)"
198
+ },
199
+ onClick: handleClick
200
+ }, (0, _react2.jsx)(_primitives.Box, {
201
+ xcss: iconWrapperStyles,
202
+ "data-inlinecard-button-overlay": "icon-wrapper-line-height"
203
+ }, showPanelButton ? (0, _react2.jsx)(_panelRight.default, {
204
+ label: ""
205
+ }) : (0, _react2.jsx)(_linkExternal.default, {
206
+ label: ""
207
+ })), showLabel && (0, _react2.jsx)(_primitives.Text, {
208
+ size: "small",
209
+ color: "color.text.subtle",
210
+ maxLines: 1
211
+ }, label)))
212
+ );
213
+ };
214
+ var _default = exports.default = HoverLinkOverlay;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -101,6 +101,12 @@ Object.defineProperty(exports, "HelperMessage", {
101
101
  return _Messages.HelperMessage;
102
102
  }
103
103
  });
104
+ Object.defineProperty(exports, "HoverLinkOverlay", {
105
+ enumerable: true,
106
+ get: function get() {
107
+ return _HoverLinkOverlay.default;
108
+ }
109
+ });
104
110
  Object.defineProperty(exports, "IntlErrorBoundary", {
105
111
  enumerable: true,
106
112
  get: function get() {
@@ -492,4 +498,5 @@ var _Separator2 = require("./Toolbar/Separator");
492
498
  var _DropList = _interopRequireDefault(require("./DropList"));
493
499
  var _MultiBodiedExtension = require("./MultiBodiedExtension");
494
500
  var _TableSelector = _interopRequireDefault(require("./TableSelector"));
501
+ var _HoverLinkOverlay = _interopRequireDefault(require("./HoverLinkOverlay"));
495
502
  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); }
@@ -1,7 +1,7 @@
1
1
  import { isFedRamp } from './environment';
2
2
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
3
3
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
4
- const packageVersion = "107.12.3";
4
+ const packageVersion = "107.12.4";
5
5
  const sanitiseSentryEvents = (data, _hint) => {
6
6
  // Remove URL as it has UGC
7
7
  // Ignored via go/ees007
@@ -13,7 +13,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
13
13
  import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
14
14
  import Layer from '../Layer';
15
15
  const packageName = "@atlaskit/editor-common";
16
- const packageVersion = "107.12.3";
16
+ const packageVersion = "107.12.4";
17
17
  const halfFocusRing = 1;
18
18
  const dropOffset = '0, 8';
19
19
  // Ignored via go/ees005
@@ -0,0 +1,190 @@
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
+ import React, { useLayoutEffect, useRef, useState } from 'react';
8
+ import { css, jsx } from '@emotion/react'; // eslint-disable-line @atlaskit/ui-styling-standard/use-compiled
9
+ import { useIntl } from 'react-intl-next';
10
+ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
11
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
12
+ import LinkExternalIcon from '@atlaskit/icon/core/link-external';
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 { Anchor, Box, Text, xcss } from '@atlaskit/primitives';
16
+ import { buildVisitedNonHyperLinkPayload, INPUT_METHOD } from '../../analytics';
17
+ import { cardMessages } from '../../messages';
18
+ const containerStyles = css({
19
+ position: 'relative'
20
+ });
21
+ const iconWrapperStyles = xcss({
22
+ display: 'inline-flex',
23
+ justifyContent: 'center',
24
+ alignItems: 'center',
25
+ height: '17px',
26
+ width: '17px'
27
+ });
28
+ const hiddenTextStyle = css({
29
+ overflow: 'hidden',
30
+ whiteSpace: 'nowrap',
31
+ position: 'absolute',
32
+ visibility: 'hidden'
33
+ });
34
+ const linkStyles = xcss({
35
+ position: 'absolute',
36
+ left: 'space.025',
37
+ top: '-1px',
38
+ display: 'inline-flex',
39
+ alignItems: 'center',
40
+ verticalAlign: 'middle',
41
+ paddingBlock: 'space.025',
42
+ paddingInline: 'space.050',
43
+ gap: 'space.025',
44
+ overflow: 'hidden',
45
+ zIndex: 'card',
46
+ backgroundColor: 'color.background.accent.gray.subtlest',
47
+ borderRadius: "var(--ds-border-radius, 3px)",
48
+ color: 'color.text.subtle',
49
+ textDecoration: 'none',
50
+ whiteSpace: 'nowrap',
51
+ ':hover': {
52
+ backgroundColor: 'elevation.surface.hovered',
53
+ color: 'color.text.subtle',
54
+ textDecoration: 'none'
55
+ }
56
+ });
57
+ const MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY = 45;
58
+ const ICON_WIDTH = 16;
59
+ const DEFAULT_OPEN_TEXT_WIDTH = 28; // Default open text width in English
60
+
61
+ const visitCardLinkAnalytics = (editorAnalyticsApi, inputMethod) => (state, dispatch) => {
62
+ if (!(state.selection instanceof NodeSelection)) {
63
+ return false;
64
+ }
65
+ const {
66
+ type
67
+ } = state.selection.node;
68
+ if (dispatch) {
69
+ const {
70
+ tr
71
+ } = state;
72
+ editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent(buildVisitedNonHyperLinkPayload(type.name, inputMethod))(tr);
73
+ dispatch(tr);
74
+ }
75
+ return true;
76
+ };
77
+ const HoverLinkOverlay = ({
78
+ children,
79
+ isVisible = false,
80
+ url,
81
+ compactPadding = false,
82
+ editorAnalyticsApi,
83
+ view,
84
+ onClick,
85
+ showPanelButton = false
86
+ }) => {
87
+ const {
88
+ formatMessage
89
+ } = useIntl();
90
+ const label = showPanelButton ? formatMessage(cardMessages.panelButtonTitle) : formatMessage(cardMessages.openButtonTitle);
91
+ const containerRef = useRef(null);
92
+ const hoverLinkButtonRef = useRef(null);
93
+ const hiddenTextRef = useRef(null);
94
+ const [showLabel, setShowLabel] = useState(true);
95
+ const [isHovered, setHovered] = useState(false);
96
+ const openTextWidthRef = useRef(null);
97
+ useLayoutEffect(() => {
98
+ var _containerRef$current, _hoverLinkButtonRef$c;
99
+ if (!isVisible || !isHovered) {
100
+ return;
101
+ }
102
+ const cardWidth = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.offsetWidth;
103
+ const openButtonWidth = (_hoverLinkButtonRef$c = hoverLinkButtonRef.current) === null || _hoverLinkButtonRef$c === void 0 ? void 0 : _hoverLinkButtonRef$c.offsetWidth;
104
+
105
+ // Get the hidden text width
106
+ if (!openTextWidthRef.current) {
107
+ const hiddenText = hiddenTextRef.current;
108
+ if (hiddenText) {
109
+ // Measure the width of the hidden text
110
+ // Temporarily make the element visible to measure its width
111
+ hiddenText.style.visibility = 'hidden';
112
+ hiddenText.style.display = 'inline';
113
+ openTextWidthRef.current = hiddenText.offsetWidth;
114
+
115
+ // Reset the hiddenText's display property
116
+ hiddenText.style.display = 'none';
117
+ hiddenText.style.visibility = 'inherit';
118
+ } else {
119
+ openTextWidthRef.current = DEFAULT_OPEN_TEXT_WIDTH;
120
+ }
121
+ }
122
+ if (!cardWidth || !openButtonWidth) {
123
+ return;
124
+ }
125
+ const openTextWidth = openTextWidthRef.current || DEFAULT_OPEN_TEXT_WIDTH;
126
+ const canShowLabel = cardWidth - openTextWidth > MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY + ICON_WIDTH;
127
+ setShowLabel(canShowLabel);
128
+ }, [isVisible, isHovered]);
129
+ const handleOverlayChange = isHovered => {
130
+ setHovered(isHovered);
131
+ };
132
+ const sendVisitLinkAnalytics = inputMethod => {
133
+ if (editorAnalyticsApi && view) {
134
+ visitCardLinkAnalytics(editorAnalyticsApi, inputMethod)(view.state, view.dispatch);
135
+ }
136
+ };
137
+ const handleDoubleClick = () => {
138
+ if (!showPanelButton) {
139
+ sendVisitLinkAnalytics(INPUT_METHOD.DOUBLE_CLICK);
140
+
141
+ // Double click opens the link in a new tab
142
+ window.open(url, '_blank');
143
+ }
144
+ };
145
+ const handleClick = event => {
146
+ if (showPanelButton && onClick) {
147
+ onClick(event);
148
+ } else {
149
+ sendVisitLinkAnalytics(INPUT_METHOD.BUTTON);
150
+ }
151
+ };
152
+ return (
153
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
154
+ jsx("span", {
155
+ ref: containerRef,
156
+ css: containerStyles,
157
+ onDoubleClick: handleDoubleClick,
158
+ onMouseEnter: () => handleOverlayChange(true),
159
+ onMouseLeave: () => handleOverlayChange(false)
160
+ }, children, jsx("span", {
161
+ css: hiddenTextStyle,
162
+ "aria-hidden": "true"
163
+ }, jsx(Text, {
164
+ ref: hiddenTextRef,
165
+ size: "small",
166
+ maxLines: 1
167
+ }, label)), isHovered && jsx(Anchor, {
168
+ ref: hoverLinkButtonRef,
169
+ xcss: linkStyles,
170
+ href: url,
171
+ target: "_blank",
172
+ style: {
173
+ paddingBlock: compactPadding ? '1px' : "var(--ds-space-025, 2px)"
174
+ },
175
+ onClick: handleClick
176
+ }, jsx(Box, {
177
+ xcss: iconWrapperStyles,
178
+ "data-inlinecard-button-overlay": "icon-wrapper-line-height"
179
+ }, showPanelButton ? jsx(PanelRightIcon, {
180
+ label: ""
181
+ }) : jsx(LinkExternalIcon, {
182
+ label: ""
183
+ })), showLabel && jsx(Text, {
184
+ size: "small",
185
+ color: "color.text.subtle",
186
+ maxLines: 1
187
+ }, label)))
188
+ );
189
+ };
190
+ export default HoverLinkOverlay;
@@ -0,0 +1 @@
1
+ export {};
@@ -43,4 +43,5 @@ export { ToolbarExpandIcon } from './Toolbar/ExpandIcon';
43
43
  export { ToolbarSeparator } from './Toolbar/Separator';
44
44
  export { default as DropList } from './DropList';
45
45
  export { sharedMultiBodiedExtensionStyles } from './MultiBodiedExtension';
46
- export { default as TableSelectorPopup } from './TableSelector';
46
+ export { default as TableSelectorPopup } from './TableSelector';
47
+ export { default as HoverLinkOverlay } from './HoverLinkOverlay';
@@ -7,7 +7,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
7
7
  import { isFedRamp } from './environment';
8
8
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
9
9
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
10
- var packageVersion = "107.12.3";
10
+ var packageVersion = "107.12.4";
11
11
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
12
12
  // Remove URL as it has UGC
13
13
  // Ignored via go/ees007
@@ -20,7 +20,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
20
20
  import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
21
21
  import Layer from '../Layer';
22
22
  var packageName = "@atlaskit/editor-common";
23
- var packageVersion = "107.12.3";
23
+ var packageVersion = "107.12.4";
24
24
  var halfFocusRing = 1;
25
25
  var dropOffset = '0, 8';
26
26
  // Ignored via go/ees005
@@ -0,0 +1,200 @@
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
+ 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 { NodeSelection } from '@atlaskit/editor-prosemirror/state';
12
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
13
+ import LinkExternalIcon from '@atlaskit/icon/core/link-external';
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 { Anchor, Box, Text, xcss } from '@atlaskit/primitives';
17
+ import { buildVisitedNonHyperLinkPayload, INPUT_METHOD } from '../../analytics';
18
+ import { cardMessages } from '../../messages';
19
+ var containerStyles = css({
20
+ position: 'relative'
21
+ });
22
+ var iconWrapperStyles = xcss({
23
+ display: 'inline-flex',
24
+ justifyContent: 'center',
25
+ alignItems: 'center',
26
+ height: '17px',
27
+ width: '17px'
28
+ });
29
+ var hiddenTextStyle = css({
30
+ overflow: 'hidden',
31
+ whiteSpace: 'nowrap',
32
+ position: 'absolute',
33
+ visibility: 'hidden'
34
+ });
35
+ var linkStyles = xcss({
36
+ position: 'absolute',
37
+ left: 'space.025',
38
+ top: '-1px',
39
+ display: 'inline-flex',
40
+ alignItems: 'center',
41
+ verticalAlign: 'middle',
42
+ paddingBlock: 'space.025',
43
+ paddingInline: 'space.050',
44
+ gap: 'space.025',
45
+ overflow: 'hidden',
46
+ zIndex: 'card',
47
+ backgroundColor: 'color.background.accent.gray.subtlest',
48
+ borderRadius: "var(--ds-border-radius, 3px)",
49
+ color: 'color.text.subtle',
50
+ textDecoration: 'none',
51
+ whiteSpace: 'nowrap',
52
+ ':hover': {
53
+ backgroundColor: 'elevation.surface.hovered',
54
+ color: 'color.text.subtle',
55
+ textDecoration: 'none'
56
+ }
57
+ });
58
+ var MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY = 45;
59
+ var ICON_WIDTH = 16;
60
+ var DEFAULT_OPEN_TEXT_WIDTH = 28; // Default open text width in English
61
+
62
+ var visitCardLinkAnalytics = function visitCardLinkAnalytics(editorAnalyticsApi, inputMethod) {
63
+ return function (state, dispatch) {
64
+ if (!(state.selection instanceof NodeSelection)) {
65
+ return false;
66
+ }
67
+ var type = state.selection.node.type;
68
+ if (dispatch) {
69
+ var tr = state.tr;
70
+ editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent(buildVisitedNonHyperLinkPayload(type.name, inputMethod))(tr);
71
+ dispatch(tr);
72
+ }
73
+ return true;
74
+ };
75
+ };
76
+ var HoverLinkOverlay = function HoverLinkOverlay(_ref) {
77
+ var children = _ref.children,
78
+ _ref$isVisible = _ref.isVisible,
79
+ isVisible = _ref$isVisible === void 0 ? false : _ref$isVisible,
80
+ url = _ref.url,
81
+ _ref$compactPadding = _ref.compactPadding,
82
+ compactPadding = _ref$compactPadding === void 0 ? false : _ref$compactPadding,
83
+ editorAnalyticsApi = _ref.editorAnalyticsApi,
84
+ view = _ref.view,
85
+ onClick = _ref.onClick,
86
+ _ref$showPanelButton = _ref.showPanelButton,
87
+ showPanelButton = _ref$showPanelButton === void 0 ? false : _ref$showPanelButton;
88
+ var _useIntl = useIntl(),
89
+ formatMessage = _useIntl.formatMessage;
90
+ var label = showPanelButton ? formatMessage(cardMessages.panelButtonTitle) : formatMessage(cardMessages.openButtonTitle);
91
+ var containerRef = useRef(null);
92
+ var hoverLinkButtonRef = useRef(null);
93
+ var hiddenTextRef = useRef(null);
94
+ var _useState = useState(true),
95
+ _useState2 = _slicedToArray(_useState, 2),
96
+ showLabel = _useState2[0],
97
+ setShowLabel = _useState2[1];
98
+ var _useState3 = useState(false),
99
+ _useState4 = _slicedToArray(_useState3, 2),
100
+ isHovered = _useState4[0],
101
+ setHovered = _useState4[1];
102
+ var openTextWidthRef = useRef(null);
103
+ useLayoutEffect(function () {
104
+ var _containerRef$current, _hoverLinkButtonRef$c;
105
+ if (!isVisible || !isHovered) {
106
+ return;
107
+ }
108
+ var cardWidth = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.offsetWidth;
109
+ var openButtonWidth = (_hoverLinkButtonRef$c = hoverLinkButtonRef.current) === null || _hoverLinkButtonRef$c === void 0 ? void 0 : _hoverLinkButtonRef$c.offsetWidth;
110
+
111
+ // Get the hidden text width
112
+ if (!openTextWidthRef.current) {
113
+ var hiddenText = hiddenTextRef.current;
114
+ if (hiddenText) {
115
+ // Measure the width of the hidden text
116
+ // Temporarily make the element visible to measure its width
117
+ hiddenText.style.visibility = 'hidden';
118
+ hiddenText.style.display = 'inline';
119
+ openTextWidthRef.current = hiddenText.offsetWidth;
120
+
121
+ // Reset the hiddenText's display property
122
+ hiddenText.style.display = 'none';
123
+ hiddenText.style.visibility = 'inherit';
124
+ } else {
125
+ openTextWidthRef.current = DEFAULT_OPEN_TEXT_WIDTH;
126
+ }
127
+ }
128
+ if (!cardWidth || !openButtonWidth) {
129
+ return;
130
+ }
131
+ var openTextWidth = openTextWidthRef.current || DEFAULT_OPEN_TEXT_WIDTH;
132
+ var canShowLabel = cardWidth - openTextWidth > MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY + ICON_WIDTH;
133
+ setShowLabel(canShowLabel);
134
+ }, [isVisible, isHovered]);
135
+ var handleOverlayChange = function handleOverlayChange(isHovered) {
136
+ setHovered(isHovered);
137
+ };
138
+ var sendVisitLinkAnalytics = function sendVisitLinkAnalytics(inputMethod) {
139
+ if (editorAnalyticsApi && view) {
140
+ visitCardLinkAnalytics(editorAnalyticsApi, inputMethod)(view.state, view.dispatch);
141
+ }
142
+ };
143
+ var handleDoubleClick = function handleDoubleClick() {
144
+ if (!showPanelButton) {
145
+ sendVisitLinkAnalytics(INPUT_METHOD.DOUBLE_CLICK);
146
+
147
+ // Double click opens the link in a new tab
148
+ window.open(url, '_blank');
149
+ }
150
+ };
151
+ var handleClick = function handleClick(event) {
152
+ if (showPanelButton && onClick) {
153
+ onClick(event);
154
+ } else {
155
+ sendVisitLinkAnalytics(INPUT_METHOD.BUTTON);
156
+ }
157
+ };
158
+ return (
159
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
160
+ jsx("span", {
161
+ ref: containerRef,
162
+ css: containerStyles,
163
+ onDoubleClick: handleDoubleClick,
164
+ onMouseEnter: function onMouseEnter() {
165
+ return handleOverlayChange(true);
166
+ },
167
+ onMouseLeave: function onMouseLeave() {
168
+ return handleOverlayChange(false);
169
+ }
170
+ }, children, jsx("span", {
171
+ css: hiddenTextStyle,
172
+ "aria-hidden": "true"
173
+ }, jsx(Text, {
174
+ ref: hiddenTextRef,
175
+ size: "small",
176
+ maxLines: 1
177
+ }, label)), isHovered && jsx(Anchor, {
178
+ ref: hoverLinkButtonRef,
179
+ xcss: linkStyles,
180
+ href: url,
181
+ target: "_blank",
182
+ style: {
183
+ paddingBlock: compactPadding ? '1px' : "var(--ds-space-025, 2px)"
184
+ },
185
+ onClick: handleClick
186
+ }, jsx(Box, {
187
+ xcss: iconWrapperStyles,
188
+ "data-inlinecard-button-overlay": "icon-wrapper-line-height"
189
+ }, showPanelButton ? jsx(PanelRightIcon, {
190
+ label: ""
191
+ }) : jsx(LinkExternalIcon, {
192
+ label: ""
193
+ })), showLabel && jsx(Text, {
194
+ size: "small",
195
+ color: "color.text.subtle",
196
+ maxLines: 1
197
+ }, label)))
198
+ );
199
+ };
200
+ export default HoverLinkOverlay;
@@ -0,0 +1 @@
1
+ export {};
@@ -43,4 +43,5 @@ export { ToolbarExpandIcon } from './Toolbar/ExpandIcon';
43
43
  export { ToolbarSeparator } from './Toolbar/Separator';
44
44
  export { default as DropList } from './DropList';
45
45
  export { sharedMultiBodiedExtensionStyles } from './MultiBodiedExtension';
46
- export { default as TableSelectorPopup } from './TableSelector';
46
+ export { default as TableSelectorPopup } from './TableSelector';
47
+ export { default as HoverLinkOverlay } from './HoverLinkOverlay';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+ import React from 'react';
6
+ import { jsx } from '@emotion/react';
7
+ import type { HoverLinkOverlayProps } from './types';
8
+ declare const HoverLinkOverlay: ({ children, isVisible, url, compactPadding, editorAnalyticsApi, view, onClick, showPanelButton, }: React.PropsWithChildren<HoverLinkOverlayProps>) => jsx.JSX.Element;
9
+ export default HoverLinkOverlay;
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
+ import type { EditorAnalyticsAPI } from '../../analytics';
4
+ export type HoverLinkOverlayProps = React.HTMLAttributes<HTMLSpanElement> & {
5
+ isVisible?: boolean;
6
+ url: string;
7
+ editorAnalyticsApi?: EditorAnalyticsAPI;
8
+ view?: EditorView;
9
+ onClick?: (event: React.MouseEvent<HTMLAnchorElement>) => void;
10
+ showPanelButton?: boolean;
11
+ compactPadding?: boolean;
12
+ };
@@ -55,3 +55,4 @@ export type { UseStickyToolbarType } from './Toolbar';
55
55
  export type { OpenChangedEvent } from './DropList';
56
56
  export { sharedMultiBodiedExtensionStyles } from './MultiBodiedExtension';
57
57
  export { default as TableSelectorPopup, type TableSelectorPopupProps } from './TableSelector';
58
+ export { default as HoverLinkOverlay } from './HoverLinkOverlay';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+ import React from 'react';
6
+ import { jsx } from '@emotion/react';
7
+ import type { HoverLinkOverlayProps } from './types';
8
+ declare const HoverLinkOverlay: ({ children, isVisible, url, compactPadding, editorAnalyticsApi, view, onClick, showPanelButton, }: React.PropsWithChildren<HoverLinkOverlayProps>) => jsx.JSX.Element;
9
+ export default HoverLinkOverlay;
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
+ import type { EditorAnalyticsAPI } from '../../analytics';
4
+ export type HoverLinkOverlayProps = React.HTMLAttributes<HTMLSpanElement> & {
5
+ isVisible?: boolean;
6
+ url: string;
7
+ editorAnalyticsApi?: EditorAnalyticsAPI;
8
+ view?: EditorView;
9
+ onClick?: (event: React.MouseEvent<HTMLAnchorElement>) => void;
10
+ showPanelButton?: boolean;
11
+ compactPadding?: boolean;
12
+ };
@@ -55,3 +55,4 @@ export type { UseStickyToolbarType } from './Toolbar';
55
55
  export type { OpenChangedEvent } from './DropList';
56
56
  export { sharedMultiBodiedExtensionStyles } from './MultiBodiedExtension';
57
57
  export { default as TableSelectorPopup, type TableSelectorPopupProps } from './TableSelector';
58
+ export { default as HoverLinkOverlay } from './HoverLinkOverlay';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "107.12.4",
3
+ "version": "107.12.5",
4
4
  "description": "A package that contains common classes and components for editor and renderer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -144,7 +144,7 @@
144
144
  "@atlaskit/icon": "^27.7.0",
145
145
  "@atlaskit/icon-object": "^7.1.0",
146
146
  "@atlaskit/link": "^3.2.0",
147
- "@atlaskit/link-datasource": "^4.14.0",
147
+ "@atlaskit/link-datasource": "^4.15.0",
148
148
  "@atlaskit/link-picker": "^3.8.0",
149
149
  "@atlaskit/media-card": "^79.4.0",
150
150
  "@atlaskit/media-client": "^35.2.0",