@atlaskit/editor-plugin-card 7.0.6 → 7.0.8

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,20 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 7.0.8
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 7.0.7
10
+
11
+ ### Patch Changes
12
+
13
+ - [#183772](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/183772)
14
+ [`8b2280a6cd32a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8b2280a6cd32a) -
15
+ [ux] ED-28391: Added panel hover button for jira in edit mode"
16
+ - Updated dependencies
17
+
3
18
  ## 7.0.6
4
19
 
5
20
  ### Patch Changes
@@ -9,11 +9,14 @@ exports.InlineCardWithAwareness = void 0;
9
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
10
  var _react = _interopRequireWildcard(require("react"));
11
11
  var _hooks = require("@atlaskit/editor-common/hooks");
12
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
+ var _smartCard = require("@atlaskit/smart-card");
12
14
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
13
15
  var _actions = require("../pm-plugins/actions");
14
16
  var _pluginKey = require("../pm-plugins/plugin-key");
15
17
  var _AwarenessWrapper = require("../ui/AwarenessWrapper");
16
18
  var _OpenButtonOverlay = _interopRequireDefault(require("../ui/OpenButtonOverlay"));
19
+ var _PanelButtonOverlay = _interopRequireDefault(require("../ui/PanelButtonOverlay"));
17
20
  var _inlineCard = require("./inlineCard");
18
21
  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); }
19
22
  var selector = function selector(states) {
@@ -128,6 +131,48 @@ var InlineCardWithAwareness = exports.InlineCardWithAwareness = /*#__PURE__*/(0,
128
131
  return (mode === 'edit' || editorAppearance === 'comment' || shouldShowOpenButtonOverlayInChomeless) && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1');
129
132
  }, [mode, editorAppearance]);
130
133
  var innerCard = shouldShowOpenButtonOverlay ? innerCardWithOpenButtonOverlay : innerCardOriginal;
134
+ if ((0, _platformFeatureFlags.fg)('platform_editor_preview_panel_linking')) {
135
+ var _cardContext$value;
136
+ var cardState = cardContext === null || cardContext === void 0 || (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 || (_cardContext$value = _cardContext$value.store) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.getState()[node.attrs.url];
137
+ if (cardState) {
138
+ var _cardContext$value2, _cardContext$value2$i, _cardContext$value3;
139
+ var ari = (0, _smartCard.getObjectAri)(cardState.details);
140
+ var name = (0, _smartCard.getObjectName)(cardState.details);
141
+ var iconUrl = (0, _smartCard.getObjectIconUrl)(cardState.details);
142
+ var isPanelAvailable = ari && (cardContext === null || cardContext === void 0 || (_cardContext$value2 = cardContext.value) === null || _cardContext$value2 === void 0 || (_cardContext$value2$i = _cardContext$value2.isPreviewPanelAvailable) === null || _cardContext$value2$i === void 0 ? void 0 : _cardContext$value2$i.call(_cardContext$value2, {
143
+ ari: ari
144
+ }));
145
+ var openPreviewPanel = cardContext === null || cardContext === void 0 || (_cardContext$value3 = cardContext.value) === null || _cardContext$value3 === void 0 ? void 0 : _cardContext$value3.openPreviewPanel;
146
+ var handleOpenGlancePanelClick = function handleOpenGlancePanelClick() {
147
+ if (openPreviewPanel && isPanelAvailable) {
148
+ openPreviewPanel({
149
+ url: node.attrs.url,
150
+ ari: ari,
151
+ name: name || '',
152
+ iconUrl: iconUrl
153
+ });
154
+ }
155
+ };
156
+ var innerCardWithPanelButtonOverlay = /*#__PURE__*/_react.default.createElement(_PanelButtonOverlay.default, {
157
+ isVisible: isResolvedViewRendered,
158
+ editorAppearance: editorAppearance,
159
+ onClick: handleOpenGlancePanelClick
160
+ }, /*#__PURE__*/_react.default.createElement(_inlineCard.InlineCard, {
161
+ node: node,
162
+ view: view,
163
+ getPos: getPos,
164
+ useAlternativePreloader: useAlternativePreloader,
165
+ actionOptions: actionOptions,
166
+ onResolve: onResolve,
167
+ onClick: onClick,
168
+ cardContext: cardContext,
169
+ isHovered: isHovered,
170
+ isPageSSRed: isPageSSRed,
171
+ pluginInjectionApi: pluginInjectionApi
172
+ }));
173
+ innerCard = isPanelAvailable && openPreviewPanel ? innerCardWithPanelButtonOverlay : innerCard;
174
+ }
175
+ }
131
176
  var getPosFunction = typeof getPos === 'function' ? getPos : undefined;
132
177
  var placeholderUniqId = (getPosFunction === null || getPosFunction === void 0 ? void 0 : getPosFunction()) || 0;
133
178
  return isOverlayEnabled || isPulseEnabled ? /*#__PURE__*/_react.default.createElement(_AwarenessWrapper.AwarenessWrapper, {
@@ -9,6 +9,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
9
9
  var _react = require("react");
10
10
  var _react2 = require("@emotion/react");
11
11
  var _analyticsNext = require("@atlaskit/analytics-next");
12
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
13
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
13
14
  var _utils = require("../../pm-plugins/utils");
14
15
  var _useLinkUpgradeDiscoverability = _interopRequireDefault(require("../hooks/useLinkUpgradeDiscoverability"));
@@ -32,7 +33,7 @@ var loaderWrapperStyles = (0, _react2.css)({
32
33
  }
33
34
  });
34
35
  var AwarenessWrapper = exports.AwarenessWrapper = function AwarenessWrapper(_ref) {
35
- var _cardContext$value2;
36
+ var _cardContext$value, _cardContext$value3;
36
37
  var cardContext = _ref.cardContext,
37
38
  children = _ref.children,
38
39
  getPos = _ref.getPos,
@@ -84,8 +85,10 @@ var AwarenessWrapper = exports.AwarenessWrapper = function AwarenessWrapper(_ref
84
85
  setIsHovered(isHovered);
85
86
  setOverlayHoveredStyles(isHovered);
86
87
  }, [setOverlayHoveredStyles]);
88
+ var isPreviewPanelAvailable = cardContext === null || cardContext === void 0 || (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.isPreviewPanelAvailable;
89
+ var shouldShowGlancePanel = (isPreviewPanelAvailable || false) && (0, _platformFeatureFlags.fg)('platform_editor_preview_panel_linking');
87
90
  var cardWithOverlay = (0, _react.useMemo)(function () {
88
- if (shouldShowLinkOverlay && !(0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
91
+ if (shouldShowLinkOverlay && !shouldShowGlancePanel && !(0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
89
92
  return (0, _react2.jsx)(_InlineCardOverlay.default, {
90
93
  isSelected: isSelected,
91
94
  isVisible: isResolvedViewRendered && (isInserted || isHovered || isSelected),
@@ -99,11 +102,11 @@ var AwarenessWrapper = exports.AwarenessWrapper = function AwarenessWrapper(_ref
99
102
  }, children);
100
103
  }
101
104
  return children;
102
- }, [shouldShowLinkOverlay, children, isSelected, isResolvedViewRendered, isInserted, isHovered, url, handleOverlayChange]);
105
+ }, [shouldShowLinkOverlay, children, isSelected, isResolvedViewRendered, isInserted, isHovered, url, handleOverlayChange, shouldShowGlancePanel]);
103
106
  var isInline = appearance === 'inline';
104
107
  var placeholderUniqId = linkPosition || 0;
105
108
  return (0, _react.useMemo)(function () {
106
- var _cardContext$value;
109
+ var _cardContext$value2;
107
110
  return (0, _react2.jsx)("span", {
108
111
  css: shouldShowLinkPulse && loaderWrapperStyles
109
112
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
@@ -114,7 +117,7 @@ var AwarenessWrapper = exports.AwarenessWrapper = function AwarenessWrapper(_ref
114
117
  "data-ssr-placeholder-replace": "awareness-wrapper-".concat(placeholderUniqId)
115
118
  }, (0, _react2.jsx)(_analyticsNext.AnalyticsContext, {
116
119
  data: {
117
- attributes: (0, _utils.getResolvedAttributesFromStore)(url, 'inline', cardContext === null || cardContext === void 0 || (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.store)
120
+ attributes: (0, _utils.getResolvedAttributesFromStore)(url, 'inline', cardContext === null || cardContext === void 0 || (_cardContext$value2 = cardContext.value) === null || _cardContext$value2 === void 0 ? void 0 : _cardContext$value2.store)
118
121
  }
119
122
  }, (0, _react2.jsx)(_Pulse.DiscoveryPulse, {
120
123
  localStorageKey: _localStorage.LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK,
@@ -124,5 +127,5 @@ var AwarenessWrapper = exports.AwarenessWrapper = function AwarenessWrapper(_ref
124
127
  testId: "link-discovery-pulse",
125
128
  isInline: isInline
126
129
  }, cardWithOverlay)));
127
- }, [shouldShowLinkPulse, url, cardContext === null || cardContext === void 0 || (_cardContext$value2 = cardContext.value) === null || _cardContext$value2 === void 0 ? void 0 : _cardContext$value2.store, isResolvedViewRendered, cardWithOverlay, isInline, placeholderUniqId]);
130
+ }, [shouldShowLinkPulse, url, cardContext === null || cardContext === void 0 || (_cardContext$value3 = cardContext.value) === null || _cardContext$value3 === void 0 ? void 0 : _cardContext$value3.store, isResolvedViewRendered, cardWithOverlay, isInline, placeholderUniqId]);
128
131
  };
@@ -0,0 +1,169 @@
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
+ var containerStyles = (0, _react2.css)({
29
+ position: 'relative'
30
+ });
31
+ var iconWrapperStyles = (0, _primitives.xcss)({
32
+ display: 'inline-flex',
33
+ justifyContent: 'center',
34
+ alignItems: 'center',
35
+ height: '17px',
36
+ width: '17px'
37
+ });
38
+ var hiddenTextStyle = (0, _react2.css)({
39
+ overflow: 'hidden',
40
+ whiteSpace: 'nowrap',
41
+ position: 'absolute',
42
+ visibility: 'hidden'
43
+ });
44
+ var iconAndLabelWrapperStyles = (0, _primitives.xcss)({
45
+ position: 'absolute',
46
+ left: 'space.025',
47
+ top: '-1px',
48
+ cursor: 'pointer',
49
+ display: 'inline-flex',
50
+ alignItems: 'center',
51
+ verticalAlign: 'middle',
52
+ paddingInline: 'space.050',
53
+ gap: 'space.025',
54
+ overflow: 'hidden',
55
+ zIndex: 'card',
56
+ backgroundColor: 'color.background.accent.gray.subtlest',
57
+ borderRadius: "var(--ds-border-radius, 3px)",
58
+ color: 'color.text.subtle',
59
+ textDecoration: 'none',
60
+ whiteSpace: 'nowrap',
61
+ ':hover': {
62
+ backgroundColor: 'elevation.surface.hovered',
63
+ color: 'color.text.subtle',
64
+ textDecoration: 'none'
65
+ }
66
+ });
67
+ var MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY = 45;
68
+ var ICON_WIDTH = 16;
69
+ var DEFAULT_PANEL_TEXT_WIDTH = 28; // Default panel text width in English
70
+
71
+ var PanelButtonOverlay = function PanelButtonOverlay(_ref) {
72
+ var children = _ref.children,
73
+ _ref$isVisible = _ref.isVisible,
74
+ isVisible = _ref$isVisible === void 0 ? false : _ref$isVisible,
75
+ editorAppearance = _ref.editorAppearance,
76
+ onClick = _ref.onClick;
77
+ var _useIntl = (0, _reactIntlNext.useIntl)(),
78
+ formatMessage = _useIntl.formatMessage;
79
+ var label = formatMessage(_messages.cardMessages.panelButtonTitle);
80
+ var containerRef = (0, _react.useRef)(null);
81
+ var panelButtonRef = (0, _react.useRef)(null);
82
+ var hiddenTextRef = (0, _react.useRef)(null);
83
+ var _useState = (0, _react.useState)(true),
84
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
85
+ showLabel = _useState2[0],
86
+ setShowLabel = _useState2[1];
87
+ var _useState3 = (0, _react.useState)(false),
88
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
89
+ isHovered = _useState4[0],
90
+ setHovered = _useState4[1];
91
+ var panelTextWidthRef = (0, _react.useRef)(null);
92
+ (0, _react.useLayoutEffect)(function () {
93
+ var _containerRef$current, _panelButtonRef$curre;
94
+ if (!isVisible || !isHovered) {
95
+ return;
96
+ }
97
+ var cardWidth = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.offsetWidth;
98
+ var panelButtonWidth = (_panelButtonRef$curre = panelButtonRef.current) === null || _panelButtonRef$curre === void 0 ? void 0 : _panelButtonRef$curre.offsetWidth;
99
+
100
+ // Get the hidden text width
101
+ if (!panelTextWidthRef.current) {
102
+ var hiddenText = hiddenTextRef.current;
103
+ if (hiddenText) {
104
+ // Measure the width of the hidden text
105
+ // Temporarily make the element visible to measure its width
106
+ hiddenText.style.visibility = 'hidden';
107
+ hiddenText.style.display = 'inline';
108
+ panelTextWidthRef.current = hiddenText.offsetWidth;
109
+
110
+ // Reset the hiddenText's display property
111
+ hiddenText.style.display = 'none';
112
+ hiddenText.style.visibility = 'inherit';
113
+ } else {
114
+ panelTextWidthRef.current = DEFAULT_PANEL_TEXT_WIDTH;
115
+ }
116
+ }
117
+ if (!cardWidth || !panelButtonWidth) {
118
+ return;
119
+ }
120
+ var panelTextWidth = panelTextWidthRef.current || DEFAULT_PANEL_TEXT_WIDTH;
121
+ var canShowLabel = cardWidth - panelTextWidth > MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY + ICON_WIDTH;
122
+ setShowLabel(canShowLabel);
123
+ }, [isVisible, isHovered]);
124
+ var handleOverlayChange = function handleOverlayChange(isHovered) {
125
+ setHovered(isHovered);
126
+ };
127
+ var handleClick = function handleClick() {
128
+ if (onClick) {
129
+ onClick();
130
+ }
131
+ };
132
+ return (
133
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
134
+ (0, _react2.jsx)("span", {
135
+ ref: containerRef,
136
+ css: containerStyles,
137
+ onMouseEnter: function onMouseEnter() {
138
+ return handleOverlayChange(true);
139
+ },
140
+ onMouseLeave: function onMouseLeave() {
141
+ return handleOverlayChange(false);
142
+ }
143
+ }, children, (0, _react2.jsx)("span", {
144
+ css: hiddenTextStyle,
145
+ "aria-hidden": "true"
146
+ }, (0, _react2.jsx)(_primitives.Text, {
147
+ ref: hiddenTextRef,
148
+ size: "small",
149
+ maxLines: 1
150
+ }, label)), isHovered && (0, _react2.jsx)(_primitives.Pressable, {
151
+ ref: panelButtonRef,
152
+ xcss: iconAndLabelWrapperStyles,
153
+ style: {
154
+ paddingBlock: editorAppearance === 'comment' || editorAppearance === 'chromeless' ? '1px' : "var(--ds-space-025, 2px)"
155
+ },
156
+ onClick: handleClick
157
+ }, (0, _react2.jsx)(_primitives.Box, {
158
+ xcss: iconWrapperStyles,
159
+ "data-inlinecard-button-overlay": "icon-wrapper-line-height"
160
+ }, (0, _react2.jsx)(_panelRight.default, {
161
+ label: ""
162
+ })), showLabel && (0, _react2.jsx)(_primitives.Text, {
163
+ size: "small",
164
+ color: "color.text.subtle",
165
+ maxLines: 1
166
+ }, label)))
167
+ );
168
+ };
169
+ var _default = exports.default = PanelButtonOverlay;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -1,10 +1,13 @@
1
1
  import React, { memo, useCallback, useMemo, useState } from 'react';
2
2
  import { sharedPluginStateHookMigratorFactory, useSharedPluginState, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
4
+ import { getObjectAri, getObjectName, getObjectIconUrl } from '@atlaskit/smart-card';
3
5
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
6
  import { registerRemoveOverlay } from '../pm-plugins/actions';
5
7
  import { pluginKey } from '../pm-plugins/plugin-key';
6
8
  import { AwarenessWrapper } from '../ui/AwarenessWrapper';
7
9
  import OpenButtonOverlay from '../ui/OpenButtonOverlay';
10
+ import PanelButtonOverlay from '../ui/PanelButtonOverlay';
8
11
  import { InlineCard } from './inlineCard';
9
12
  const selector = states => {
10
13
  var _states$editorViewMod;
@@ -105,7 +108,49 @@ export const InlineCardWithAwareness = /*#__PURE__*/memo(({
105
108
  const shouldShowOpenButtonOverlayInChomeless = editorAppearance === 'chromeless';
106
109
  return (mode === 'edit' || editorAppearance === 'comment' || shouldShowOpenButtonOverlayInChomeless) && editorExperiment('platform_editor_controls', 'variant1');
107
110
  }, [mode, editorAppearance]);
108
- const innerCard = shouldShowOpenButtonOverlay ? innerCardWithOpenButtonOverlay : innerCardOriginal;
111
+ let innerCard = shouldShowOpenButtonOverlay ? innerCardWithOpenButtonOverlay : innerCardOriginal;
112
+ if (fg('platform_editor_preview_panel_linking')) {
113
+ var _cardContext$value, _cardContext$value$st;
114
+ const cardState = cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : (_cardContext$value$st = _cardContext$value.store) === null || _cardContext$value$st === void 0 ? void 0 : _cardContext$value$st.getState()[node.attrs.url];
115
+ if (cardState) {
116
+ var _cardContext$value2, _cardContext$value2$i, _cardContext$value3;
117
+ const ari = getObjectAri(cardState.details);
118
+ const name = getObjectName(cardState.details);
119
+ const iconUrl = getObjectIconUrl(cardState.details);
120
+ const isPanelAvailable = ari && (cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$value2 = cardContext.value) === null || _cardContext$value2 === void 0 ? void 0 : (_cardContext$value2$i = _cardContext$value2.isPreviewPanelAvailable) === null || _cardContext$value2$i === void 0 ? void 0 : _cardContext$value2$i.call(_cardContext$value2, {
121
+ ari
122
+ }));
123
+ const openPreviewPanel = cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$value3 = cardContext.value) === null || _cardContext$value3 === void 0 ? void 0 : _cardContext$value3.openPreviewPanel;
124
+ const handleOpenGlancePanelClick = () => {
125
+ if (openPreviewPanel && isPanelAvailable) {
126
+ openPreviewPanel({
127
+ url: node.attrs.url,
128
+ ari,
129
+ name: name || '',
130
+ iconUrl
131
+ });
132
+ }
133
+ };
134
+ const innerCardWithPanelButtonOverlay = /*#__PURE__*/React.createElement(PanelButtonOverlay, {
135
+ isVisible: isResolvedViewRendered,
136
+ editorAppearance: editorAppearance,
137
+ onClick: handleOpenGlancePanelClick
138
+ }, /*#__PURE__*/React.createElement(InlineCard, {
139
+ node: node,
140
+ view: view,
141
+ getPos: getPos,
142
+ useAlternativePreloader: useAlternativePreloader,
143
+ actionOptions: actionOptions,
144
+ onResolve: onResolve,
145
+ onClick: onClick,
146
+ cardContext: cardContext,
147
+ isHovered: isHovered,
148
+ isPageSSRed: isPageSSRed,
149
+ pluginInjectionApi: pluginInjectionApi
150
+ }));
151
+ innerCard = isPanelAvailable && openPreviewPanel ? innerCardWithPanelButtonOverlay : innerCard;
152
+ }
153
+ }
109
154
  const getPosFunction = typeof getPos === 'function' ? getPos : undefined;
110
155
  const placeholderUniqId = (getPosFunction === null || getPosFunction === void 0 ? void 0 : getPosFunction()) || 0;
111
156
  return isOverlayEnabled || isPulseEnabled ? /*#__PURE__*/React.createElement(AwarenessWrapper, {
@@ -7,6 +7,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
7
7
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
8
8
  import { css, jsx } from '@emotion/react';
9
9
  import { AnalyticsContext } from '@atlaskit/analytics-next';
10
+ import { fg } from '@atlaskit/platform-feature-flags';
10
11
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
11
12
  import { getResolvedAttributesFromStore } from '../../pm-plugins/utils';
12
13
  import useLinkUpgradeDiscoverability from '../hooks/useLinkUpgradeDiscoverability';
@@ -37,7 +38,7 @@ export const AwarenessWrapper = ({
37
38
  url,
38
39
  appearance
39
40
  }) => {
40
- var _cardContext$value2;
41
+ var _cardContext$value, _cardContext$value3;
41
42
  const [isHovered, setIsHovered] = useState(false);
42
43
  const linkPosition = useMemo(() => {
43
44
  if (!getPos || typeof getPos === 'boolean') {
@@ -74,8 +75,10 @@ export const AwarenessWrapper = ({
74
75
  setIsHovered(isHovered);
75
76
  setOverlayHoveredStyles(isHovered);
76
77
  }, [setOverlayHoveredStyles]);
78
+ const isPreviewPanelAvailable = cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.isPreviewPanelAvailable;
79
+ const shouldShowGlancePanel = (isPreviewPanelAvailable || false) && fg('platform_editor_preview_panel_linking');
77
80
  const cardWithOverlay = useMemo(() => {
78
- if (shouldShowLinkOverlay && !editorExperiment('platform_editor_controls', 'variant1')) {
81
+ if (shouldShowLinkOverlay && !shouldShowGlancePanel && !editorExperiment('platform_editor_controls', 'variant1')) {
79
82
  return jsx(InlineCardOverlay, {
80
83
  isSelected: isSelected,
81
84
  isVisible: isResolvedViewRendered && (isInserted || isHovered || isSelected),
@@ -85,11 +88,11 @@ export const AwarenessWrapper = ({
85
88
  }, children);
86
89
  }
87
90
  return children;
88
- }, [shouldShowLinkOverlay, children, isSelected, isResolvedViewRendered, isInserted, isHovered, url, handleOverlayChange]);
91
+ }, [shouldShowLinkOverlay, children, isSelected, isResolvedViewRendered, isInserted, isHovered, url, handleOverlayChange, shouldShowGlancePanel]);
89
92
  const isInline = appearance === 'inline';
90
93
  const placeholderUniqId = linkPosition || 0;
91
94
  return useMemo(() => {
92
- var _cardContext$value;
95
+ var _cardContext$value2;
93
96
  return jsx("span", {
94
97
  css: shouldShowLinkPulse && loaderWrapperStyles
95
98
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
@@ -100,7 +103,7 @@ export const AwarenessWrapper = ({
100
103
  "data-ssr-placeholder-replace": `awareness-wrapper-${placeholderUniqId}`
101
104
  }, jsx(AnalyticsContext, {
102
105
  data: {
103
- attributes: getResolvedAttributesFromStore(url, 'inline', cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.store)
106
+ attributes: getResolvedAttributesFromStore(url, 'inline', cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$value2 = cardContext.value) === null || _cardContext$value2 === void 0 ? void 0 : _cardContext$value2.store)
104
107
  }
105
108
  }, jsx(DiscoveryPulse, {
106
109
  localStorageKey: LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK,
@@ -110,5 +113,5 @@ export const AwarenessWrapper = ({
110
113
  testId: "link-discovery-pulse",
111
114
  isInline: isInline
112
115
  }, cardWithOverlay)));
113
- }, [shouldShowLinkPulse, url, cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$value2 = cardContext.value) === null || _cardContext$value2 === void 0 ? void 0 : _cardContext$value2.store, isResolvedViewRendered, cardWithOverlay, isInline, placeholderUniqId]);
116
+ }, [shouldShowLinkPulse, url, cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$value3 = cardContext.value) === null || _cardContext$value3 === void 0 ? void 0 : _cardContext$value3.store, isResolvedViewRendered, cardWithOverlay, isInline, placeholderUniqId]);
114
117
  };
@@ -0,0 +1,147 @@
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
+ import { Box, Pressable, Text, xcss } from '@atlaskit/primitives';
15
+ const containerStyles = css({
16
+ position: 'relative'
17
+ });
18
+ const iconWrapperStyles = xcss({
19
+ display: 'inline-flex',
20
+ justifyContent: 'center',
21
+ alignItems: 'center',
22
+ height: '17px',
23
+ width: '17px'
24
+ });
25
+ const hiddenTextStyle = css({
26
+ overflow: 'hidden',
27
+ whiteSpace: 'nowrap',
28
+ position: 'absolute',
29
+ visibility: 'hidden'
30
+ });
31
+ const iconAndLabelWrapperStyles = xcss({
32
+ position: 'absolute',
33
+ left: 'space.025',
34
+ top: '-1px',
35
+ cursor: 'pointer',
36
+ display: 'inline-flex',
37
+ alignItems: 'center',
38
+ verticalAlign: 'middle',
39
+ paddingInline: 'space.050',
40
+ gap: 'space.025',
41
+ overflow: 'hidden',
42
+ zIndex: 'card',
43
+ backgroundColor: 'color.background.accent.gray.subtlest',
44
+ borderRadius: "var(--ds-border-radius, 3px)",
45
+ color: 'color.text.subtle',
46
+ textDecoration: 'none',
47
+ whiteSpace: 'nowrap',
48
+ ':hover': {
49
+ backgroundColor: 'elevation.surface.hovered',
50
+ color: 'color.text.subtle',
51
+ textDecoration: 'none'
52
+ }
53
+ });
54
+ const MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY = 45;
55
+ const ICON_WIDTH = 16;
56
+ const DEFAULT_PANEL_TEXT_WIDTH = 28; // Default panel text width in English
57
+
58
+ const PanelButtonOverlay = ({
59
+ children,
60
+ isVisible = false,
61
+ editorAppearance,
62
+ onClick
63
+ }) => {
64
+ const {
65
+ formatMessage
66
+ } = useIntl();
67
+ const label = formatMessage(cardMessages.panelButtonTitle);
68
+ const containerRef = useRef(null);
69
+ const panelButtonRef = useRef(null);
70
+ const hiddenTextRef = useRef(null);
71
+ const [showLabel, setShowLabel] = useState(true);
72
+ const [isHovered, setHovered] = useState(false);
73
+ const panelTextWidthRef = useRef(null);
74
+ useLayoutEffect(() => {
75
+ var _containerRef$current, _panelButtonRef$curre;
76
+ if (!isVisible || !isHovered) {
77
+ return;
78
+ }
79
+ const cardWidth = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.offsetWidth;
80
+ const panelButtonWidth = (_panelButtonRef$curre = panelButtonRef.current) === null || _panelButtonRef$curre === void 0 ? void 0 : _panelButtonRef$curre.offsetWidth;
81
+
82
+ // Get the hidden text width
83
+ if (!panelTextWidthRef.current) {
84
+ const hiddenText = hiddenTextRef.current;
85
+ if (hiddenText) {
86
+ // Measure the width of the hidden text
87
+ // Temporarily make the element visible to measure its width
88
+ hiddenText.style.visibility = 'hidden';
89
+ hiddenText.style.display = 'inline';
90
+ panelTextWidthRef.current = hiddenText.offsetWidth;
91
+
92
+ // Reset the hiddenText's display property
93
+ hiddenText.style.display = 'none';
94
+ hiddenText.style.visibility = 'inherit';
95
+ } else {
96
+ panelTextWidthRef.current = DEFAULT_PANEL_TEXT_WIDTH;
97
+ }
98
+ }
99
+ if (!cardWidth || !panelButtonWidth) {
100
+ return;
101
+ }
102
+ const panelTextWidth = panelTextWidthRef.current || DEFAULT_PANEL_TEXT_WIDTH;
103
+ const canShowLabel = cardWidth - panelTextWidth > MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY + ICON_WIDTH;
104
+ setShowLabel(canShowLabel);
105
+ }, [isVisible, isHovered]);
106
+ const handleOverlayChange = isHovered => {
107
+ setHovered(isHovered);
108
+ };
109
+ const handleClick = () => {
110
+ if (onClick) {
111
+ onClick();
112
+ }
113
+ };
114
+ return (
115
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
116
+ jsx("span", {
117
+ ref: containerRef,
118
+ css: containerStyles,
119
+ onMouseEnter: () => handleOverlayChange(true),
120
+ onMouseLeave: () => handleOverlayChange(false)
121
+ }, children, jsx("span", {
122
+ css: hiddenTextStyle,
123
+ "aria-hidden": "true"
124
+ }, jsx(Text, {
125
+ ref: hiddenTextRef,
126
+ size: "small",
127
+ maxLines: 1
128
+ }, label)), isHovered && jsx(Pressable, {
129
+ ref: panelButtonRef,
130
+ xcss: iconAndLabelWrapperStyles,
131
+ style: {
132
+ paddingBlock: editorAppearance === 'comment' || editorAppearance === 'chromeless' ? '1px' : "var(--ds-space-025, 2px)"
133
+ },
134
+ onClick: handleClick
135
+ }, jsx(Box, {
136
+ xcss: iconWrapperStyles,
137
+ "data-inlinecard-button-overlay": "icon-wrapper-line-height"
138
+ }, jsx(PanelRightIcon, {
139
+ label: ""
140
+ })), showLabel && jsx(Text, {
141
+ size: "small",
142
+ color: "color.text.subtle",
143
+ maxLines: 1
144
+ }, label)))
145
+ );
146
+ };
147
+ export default PanelButtonOverlay;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,11 +1,14 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import React, { memo, useCallback, useMemo, useState } from 'react';
3
3
  import { sharedPluginStateHookMigratorFactory, useSharedPluginState, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
5
+ import { getObjectAri, getObjectName, getObjectIconUrl } from '@atlaskit/smart-card';
4
6
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
7
  import { registerRemoveOverlay } from '../pm-plugins/actions';
6
8
  import { pluginKey } from '../pm-plugins/plugin-key';
7
9
  import { AwarenessWrapper } from '../ui/AwarenessWrapper';
8
10
  import OpenButtonOverlay from '../ui/OpenButtonOverlay';
11
+ import PanelButtonOverlay from '../ui/PanelButtonOverlay';
9
12
  import { InlineCard } from './inlineCard';
10
13
  var selector = function selector(states) {
11
14
  var _states$editorViewMod;
@@ -119,6 +122,48 @@ export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
119
122
  return (mode === 'edit' || editorAppearance === 'comment' || shouldShowOpenButtonOverlayInChomeless) && editorExperiment('platform_editor_controls', 'variant1');
120
123
  }, [mode, editorAppearance]);
121
124
  var innerCard = shouldShowOpenButtonOverlay ? innerCardWithOpenButtonOverlay : innerCardOriginal;
125
+ if (fg('platform_editor_preview_panel_linking')) {
126
+ var _cardContext$value;
127
+ var cardState = cardContext === null || cardContext === void 0 || (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 || (_cardContext$value = _cardContext$value.store) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.getState()[node.attrs.url];
128
+ if (cardState) {
129
+ var _cardContext$value2, _cardContext$value2$i, _cardContext$value3;
130
+ var ari = getObjectAri(cardState.details);
131
+ var name = getObjectName(cardState.details);
132
+ var iconUrl = getObjectIconUrl(cardState.details);
133
+ var isPanelAvailable = ari && (cardContext === null || cardContext === void 0 || (_cardContext$value2 = cardContext.value) === null || _cardContext$value2 === void 0 || (_cardContext$value2$i = _cardContext$value2.isPreviewPanelAvailable) === null || _cardContext$value2$i === void 0 ? void 0 : _cardContext$value2$i.call(_cardContext$value2, {
134
+ ari: ari
135
+ }));
136
+ var openPreviewPanel = cardContext === null || cardContext === void 0 || (_cardContext$value3 = cardContext.value) === null || _cardContext$value3 === void 0 ? void 0 : _cardContext$value3.openPreviewPanel;
137
+ var handleOpenGlancePanelClick = function handleOpenGlancePanelClick() {
138
+ if (openPreviewPanel && isPanelAvailable) {
139
+ openPreviewPanel({
140
+ url: node.attrs.url,
141
+ ari: ari,
142
+ name: name || '',
143
+ iconUrl: iconUrl
144
+ });
145
+ }
146
+ };
147
+ var innerCardWithPanelButtonOverlay = /*#__PURE__*/React.createElement(PanelButtonOverlay, {
148
+ isVisible: isResolvedViewRendered,
149
+ editorAppearance: editorAppearance,
150
+ onClick: handleOpenGlancePanelClick
151
+ }, /*#__PURE__*/React.createElement(InlineCard, {
152
+ node: node,
153
+ view: view,
154
+ getPos: getPos,
155
+ useAlternativePreloader: useAlternativePreloader,
156
+ actionOptions: actionOptions,
157
+ onResolve: onResolve,
158
+ onClick: onClick,
159
+ cardContext: cardContext,
160
+ isHovered: isHovered,
161
+ isPageSSRed: isPageSSRed,
162
+ pluginInjectionApi: pluginInjectionApi
163
+ }));
164
+ innerCard = isPanelAvailable && openPreviewPanel ? innerCardWithPanelButtonOverlay : innerCard;
165
+ }
166
+ }
122
167
  var getPosFunction = typeof getPos === 'function' ? getPos : undefined;
123
168
  var placeholderUniqId = (getPosFunction === null || getPosFunction === void 0 ? void 0 : getPosFunction()) || 0;
124
169
  return isOverlayEnabled || isPulseEnabled ? /*#__PURE__*/React.createElement(AwarenessWrapper, {
@@ -8,6 +8,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
8
8
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
9
9
  import { css, jsx } from '@emotion/react';
10
10
  import { AnalyticsContext } from '@atlaskit/analytics-next';
11
+ import { fg } from '@atlaskit/platform-feature-flags';
11
12
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
12
13
  import { getResolvedAttributesFromStore } from '../../pm-plugins/utils';
13
14
  import useLinkUpgradeDiscoverability from '../hooks/useLinkUpgradeDiscoverability';
@@ -24,7 +25,7 @@ var loaderWrapperStyles = css({
24
25
  }
25
26
  });
26
27
  export var AwarenessWrapper = function AwarenessWrapper(_ref) {
27
- var _cardContext$value2;
28
+ var _cardContext$value, _cardContext$value3;
28
29
  var cardContext = _ref.cardContext,
29
30
  children = _ref.children,
30
31
  getPos = _ref.getPos,
@@ -76,8 +77,10 @@ export var AwarenessWrapper = function AwarenessWrapper(_ref) {
76
77
  setIsHovered(isHovered);
77
78
  setOverlayHoveredStyles(isHovered);
78
79
  }, [setOverlayHoveredStyles]);
80
+ var isPreviewPanelAvailable = cardContext === null || cardContext === void 0 || (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.isPreviewPanelAvailable;
81
+ var shouldShowGlancePanel = (isPreviewPanelAvailable || false) && fg('platform_editor_preview_panel_linking');
79
82
  var cardWithOverlay = useMemo(function () {
80
- if (shouldShowLinkOverlay && !editorExperiment('platform_editor_controls', 'variant1')) {
83
+ if (shouldShowLinkOverlay && !shouldShowGlancePanel && !editorExperiment('platform_editor_controls', 'variant1')) {
81
84
  return jsx(InlineCardOverlay, {
82
85
  isSelected: isSelected,
83
86
  isVisible: isResolvedViewRendered && (isInserted || isHovered || isSelected),
@@ -91,11 +94,11 @@ export var AwarenessWrapper = function AwarenessWrapper(_ref) {
91
94
  }, children);
92
95
  }
93
96
  return children;
94
- }, [shouldShowLinkOverlay, children, isSelected, isResolvedViewRendered, isInserted, isHovered, url, handleOverlayChange]);
97
+ }, [shouldShowLinkOverlay, children, isSelected, isResolvedViewRendered, isInserted, isHovered, url, handleOverlayChange, shouldShowGlancePanel]);
95
98
  var isInline = appearance === 'inline';
96
99
  var placeholderUniqId = linkPosition || 0;
97
100
  return useMemo(function () {
98
- var _cardContext$value;
101
+ var _cardContext$value2;
99
102
  return jsx("span", {
100
103
  css: shouldShowLinkPulse && loaderWrapperStyles
101
104
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
@@ -106,7 +109,7 @@ export var AwarenessWrapper = function AwarenessWrapper(_ref) {
106
109
  "data-ssr-placeholder-replace": "awareness-wrapper-".concat(placeholderUniqId)
107
110
  }, jsx(AnalyticsContext, {
108
111
  data: {
109
- attributes: getResolvedAttributesFromStore(url, 'inline', cardContext === null || cardContext === void 0 || (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.store)
112
+ attributes: getResolvedAttributesFromStore(url, 'inline', cardContext === null || cardContext === void 0 || (_cardContext$value2 = cardContext.value) === null || _cardContext$value2 === void 0 ? void 0 : _cardContext$value2.store)
110
113
  }
111
114
  }, jsx(DiscoveryPulse, {
112
115
  localStorageKey: LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK,
@@ -116,5 +119,5 @@ export var AwarenessWrapper = function AwarenessWrapper(_ref) {
116
119
  testId: "link-discovery-pulse",
117
120
  isInline: isInline
118
121
  }, cardWithOverlay)));
119
- }, [shouldShowLinkPulse, url, cardContext === null || cardContext === void 0 || (_cardContext$value2 = cardContext.value) === null || _cardContext$value2 === void 0 ? void 0 : _cardContext$value2.store, isResolvedViewRendered, cardWithOverlay, isInline, placeholderUniqId]);
122
+ }, [shouldShowLinkPulse, url, cardContext === null || cardContext === void 0 || (_cardContext$value3 = cardContext.value) === null || _cardContext$value3 === void 0 ? void 0 : _cardContext$value3.store, isResolvedViewRendered, cardWithOverlay, isInline, placeholderUniqId]);
120
123
  };
@@ -0,0 +1,157 @@
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
+ import { Box, Pressable, Text, xcss } from '@atlaskit/primitives';
16
+ var containerStyles = css({
17
+ position: 'relative'
18
+ });
19
+ var iconWrapperStyles = xcss({
20
+ display: 'inline-flex',
21
+ justifyContent: 'center',
22
+ alignItems: 'center',
23
+ height: '17px',
24
+ width: '17px'
25
+ });
26
+ var hiddenTextStyle = css({
27
+ overflow: 'hidden',
28
+ whiteSpace: 'nowrap',
29
+ position: 'absolute',
30
+ visibility: 'hidden'
31
+ });
32
+ var 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
+ var MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY = 45;
56
+ var ICON_WIDTH = 16;
57
+ var DEFAULT_PANEL_TEXT_WIDTH = 28; // Default panel text width in English
58
+
59
+ var PanelButtonOverlay = function PanelButtonOverlay(_ref) {
60
+ var children = _ref.children,
61
+ _ref$isVisible = _ref.isVisible,
62
+ isVisible = _ref$isVisible === void 0 ? false : _ref$isVisible,
63
+ editorAppearance = _ref.editorAppearance,
64
+ onClick = _ref.onClick;
65
+ var _useIntl = useIntl(),
66
+ formatMessage = _useIntl.formatMessage;
67
+ var label = formatMessage(cardMessages.panelButtonTitle);
68
+ var containerRef = useRef(null);
69
+ var panelButtonRef = useRef(null);
70
+ var hiddenTextRef = useRef(null);
71
+ var _useState = useState(true),
72
+ _useState2 = _slicedToArray(_useState, 2),
73
+ showLabel = _useState2[0],
74
+ setShowLabel = _useState2[1];
75
+ var _useState3 = useState(false),
76
+ _useState4 = _slicedToArray(_useState3, 2),
77
+ isHovered = _useState4[0],
78
+ setHovered = _useState4[1];
79
+ var panelTextWidthRef = useRef(null);
80
+ useLayoutEffect(function () {
81
+ var _containerRef$current, _panelButtonRef$curre;
82
+ if (!isVisible || !isHovered) {
83
+ return;
84
+ }
85
+ var cardWidth = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.offsetWidth;
86
+ var panelButtonWidth = (_panelButtonRef$curre = panelButtonRef.current) === null || _panelButtonRef$curre === void 0 ? void 0 : _panelButtonRef$curre.offsetWidth;
87
+
88
+ // Get the hidden text width
89
+ if (!panelTextWidthRef.current) {
90
+ var hiddenText = hiddenTextRef.current;
91
+ if (hiddenText) {
92
+ // Measure the width of the hidden text
93
+ // Temporarily make the element visible to measure its width
94
+ hiddenText.style.visibility = 'hidden';
95
+ hiddenText.style.display = 'inline';
96
+ panelTextWidthRef.current = hiddenText.offsetWidth;
97
+
98
+ // Reset the hiddenText's display property
99
+ hiddenText.style.display = 'none';
100
+ hiddenText.style.visibility = 'inherit';
101
+ } else {
102
+ panelTextWidthRef.current = DEFAULT_PANEL_TEXT_WIDTH;
103
+ }
104
+ }
105
+ if (!cardWidth || !panelButtonWidth) {
106
+ return;
107
+ }
108
+ var panelTextWidth = panelTextWidthRef.current || DEFAULT_PANEL_TEXT_WIDTH;
109
+ var canShowLabel = cardWidth - panelTextWidth > MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY + ICON_WIDTH;
110
+ setShowLabel(canShowLabel);
111
+ }, [isVisible, isHovered]);
112
+ var handleOverlayChange = function handleOverlayChange(isHovered) {
113
+ setHovered(isHovered);
114
+ };
115
+ var handleClick = function handleClick() {
116
+ if (onClick) {
117
+ onClick();
118
+ }
119
+ };
120
+ return (
121
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
122
+ jsx("span", {
123
+ ref: containerRef,
124
+ css: containerStyles,
125
+ onMouseEnter: function onMouseEnter() {
126
+ return handleOverlayChange(true);
127
+ },
128
+ onMouseLeave: function onMouseLeave() {
129
+ return handleOverlayChange(false);
130
+ }
131
+ }, children, jsx("span", {
132
+ css: hiddenTextStyle,
133
+ "aria-hidden": "true"
134
+ }, jsx(Text, {
135
+ ref: hiddenTextRef,
136
+ size: "small",
137
+ maxLines: 1
138
+ }, label)), isHovered && jsx(Pressable, {
139
+ ref: panelButtonRef,
140
+ xcss: iconAndLabelWrapperStyles,
141
+ style: {
142
+ paddingBlock: editorAppearance === 'comment' || editorAppearance === 'chromeless' ? '1px' : "var(--ds-space-025, 2px)"
143
+ },
144
+ onClick: handleClick
145
+ }, jsx(Box, {
146
+ xcss: iconWrapperStyles,
147
+ "data-inlinecard-button-overlay": "icon-wrapper-line-height"
148
+ }, jsx(PanelRightIcon, {
149
+ label: ""
150
+ })), showLabel && jsx(Text, {
151
+ size: "small",
152
+ color: "color.text.subtle",
153
+ maxLines: 1
154
+ }, label)))
155
+ );
156
+ };
157
+ export default PanelButtonOverlay;
@@ -0,0 +1 @@
1
+ export {};
@@ -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 { PanelButtonOverlayProps } from '../PanelButtonOverlay/types';
8
+ declare const PanelButtonOverlay: ({ children, isVisible, editorAppearance, onClick, }: React.PropsWithChildren<PanelButtonOverlayProps>) => jsx.JSX.Element;
9
+ export default PanelButtonOverlay;
@@ -0,0 +1,7 @@
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
+ };
@@ -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 { PanelButtonOverlayProps } from '../PanelButtonOverlay/types';
8
+ declare const PanelButtonOverlay: ({ children, isVisible, editorAppearance, onClick, }: React.PropsWithChildren<PanelButtonOverlayProps>) => jsx.JSX.Element;
9
+ export default PanelButtonOverlay;
@@ -0,0 +1,7 @@
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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "7.0.6",
3
+ "version": "7.0.8",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -47,7 +47,7 @@
47
47
  "@atlaskit/editor-plugin-grid": "^3.0.0",
48
48
  "@atlaskit/editor-plugin-width": "^4.0.0",
49
49
  "@atlaskit/editor-prosemirror": "7.0.0",
50
- "@atlaskit/editor-shared-styles": "^3.4.0",
50
+ "@atlaskit/editor-shared-styles": "^3.5.0",
51
51
  "@atlaskit/frontend-utilities": "^3.1.0",
52
52
  "@atlaskit/icon": "^27.3.0",
53
53
  "@atlaskit/link": "^3.2.0",
@@ -55,13 +55,13 @@
55
55
  "@atlaskit/link-client-extension": "^5.0.0",
56
56
  "@atlaskit/link-datasource": "^4.13.0",
57
57
  "@atlaskit/linking-common": "^9.1.0",
58
- "@atlaskit/linking-types": "^13.0.0",
58
+ "@atlaskit/linking-types": "^14.0.0",
59
59
  "@atlaskit/menu": "^8.0.0",
60
60
  "@atlaskit/platform-feature-flags": "^1.1.0",
61
61
  "@atlaskit/primitives": "^14.10.0",
62
- "@atlaskit/smart-card": "^40.2.0",
62
+ "@atlaskit/smart-card": "^40.3.0",
63
63
  "@atlaskit/theme": "^19.0.0",
64
- "@atlaskit/tmp-editor-statsig": "^9.7.0",
64
+ "@atlaskit/tmp-editor-statsig": "^9.8.0",
65
65
  "@atlaskit/tokens": "^5.5.0",
66
66
  "@babel/runtime": "^7.0.0",
67
67
  "@emotion/react": "^11.7.1",
@@ -134,6 +134,9 @@
134
134
  "platform_editor_cards_maxcallstackfix": {
135
135
  "type": "boolean"
136
136
  },
137
+ "platform_editor_preview_panel_linking": {
138
+ "type": "boolean"
139
+ },
137
140
  "platform_editor_controls_patch_13": {
138
141
  "type": "boolean"
139
142
  },