@atlaskit/editor-plugin-card 1.14.3 → 1.14.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/nodeviews/datasource.js +1 -0
  3. package/dist/cjs/nodeviews/inlineCardWithAwareness.js +4 -1
  4. package/dist/cjs/ui/AwarenessWrapper/index.js +20 -18
  5. package/dist/cjs/ui/DatasourceModal/index.js +4 -5
  6. package/dist/cjs/ui/InlineCardOverlay/index.js +9 -3
  7. package/dist/cjs/ui/{NewInlineCardOverlay → LeftIconOverlay}/index.js +60 -101
  8. package/dist/cjs/ui/ResizableEmbedCard.js +3 -0
  9. package/dist/es2019/nodeviews/datasource.js +1 -0
  10. package/dist/es2019/nodeviews/inlineCardWithAwareness.js +4 -1
  11. package/dist/es2019/ui/AwarenessWrapper/index.js +20 -18
  12. package/dist/es2019/ui/DatasourceModal/index.js +4 -5
  13. package/dist/es2019/ui/InlineCardOverlay/index.js +9 -3
  14. package/dist/es2019/ui/{NewInlineCardOverlay → LeftIconOverlay}/index.js +51 -94
  15. package/dist/es2019/ui/ResizableEmbedCard.js +4 -0
  16. package/dist/esm/nodeviews/datasource.js +1 -0
  17. package/dist/esm/nodeviews/inlineCardWithAwareness.js +4 -1
  18. package/dist/esm/ui/AwarenessWrapper/index.js +20 -18
  19. package/dist/esm/ui/DatasourceModal/index.js +4 -5
  20. package/dist/esm/ui/InlineCardOverlay/index.js +9 -3
  21. package/dist/esm/ui/{NewInlineCardOverlay → LeftIconOverlay}/index.js +62 -103
  22. package/dist/esm/ui/ResizableEmbedCard.js +3 -0
  23. package/dist/types/analytics/utils.d.ts +3 -3
  24. package/dist/types/pm-plugins/plugin-key.d.ts +1 -1
  25. package/dist/types/pm-plugins/util/state.d.ts +2 -2
  26. package/dist/types/ui/EditorAnalyticsContext.d.ts +1 -1
  27. package/dist/types/ui/LeftIconOverlay/index.d.ts +10 -0
  28. package/dist/types-ts4.5/analytics/utils.d.ts +3 -3
  29. package/dist/types-ts4.5/pm-plugins/plugin-key.d.ts +1 -1
  30. package/dist/types-ts4.5/pm-plugins/util/state.d.ts +2 -2
  31. package/dist/types-ts4.5/ui/EditorAnalyticsContext.d.ts +1 -1
  32. package/dist/types-ts4.5/ui/LeftIconOverlay/index.d.ts +10 -0
  33. package/package.json +5 -4
  34. package/dist/types/ui/NewInlineCardOverlay/index.d.ts +0 -6
  35. package/dist/types-ts4.5/ui/NewInlineCardOverlay/index.d.ts +0 -6
@@ -9,93 +9,84 @@ import { useIntl } from 'react-intl-next';
9
9
  import { cardMessages as messages } from '@atlaskit/editor-common/messages';
10
10
  import { ZERO_WIDTH_JOINER } from '@atlaskit/editor-common/utils';
11
11
  import PreferencesIcon from '@atlaskit/icon/glyph/preferences';
12
- import { B100, N0, N700 } from '@atlaskit/theme/colors';
13
- import { getChildElement, getIconSize, getInlineCardAvailableWidth, getOverlayWidths, isOneLine } from '../InlineCardOverlay/utils';
12
+ import { N0, N30A, N40A, N60A, N700 } from '@atlaskit/theme/colors';
13
+ import Tooltip from '@atlaskit/tooltip';
14
+ import { getChildElement, getInlineCardAvailableWidth, isOneLine } from '../InlineCardOverlay/utils';
14
15
  const DEBOUNCE_IN_MS = 5;
15
- const ESTIMATED_MIN_WIDTH_IN_PX = 16;
16
16
  const PADDING_IN_PX = 4;
17
- const ICON_WIDTH_IN_PX = 14;
17
+ const ICON_WIDTH_IN_PX = 16;
18
18
  const ICON_AND_LABEL_CLASSNAME = 'ak-editor-card-overlay-icon-and-label';
19
- const OVERLAY_LABEL_CLASSNAME = 'ak-editor-card-overlay-label';
20
19
  const OVERLAY_MARKER_CLASSNAME = 'ak-editor-card-overlay-marker';
21
20
  const TEXT_NODE_SELECTOR = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].join(',');
22
21
  const SMART_LINK_BACKGROUND_COLOR = `var(--ds-surface-raised, ${N0})`;
23
- // TODO: This should be lighter to match the rest of the button
24
- const SMART_LINK_ACTIVE_COLOR = `var(--ds-background-selected, ${B100})`;
22
+ const CONFIGURE_ICON_BACKGROUND_COLOR = `var(--ds-background-neutral, ${N30A})`;
23
+ const CONFIGURE_ICON_BACKGROUND_HOVERED_COLOR = `var(--ds-background-neutral-hovered, ${N40A})`;
24
+ const CONFIGURE_ICON_BACKGROUND_ACTIVE_COLOR = `var(--ds-background-neutral-pressed, ${N60A})`;
25
25
  const containerStyles = css({
26
26
  position: 'relative',
27
- lineHeight: 'normal',
28
- ':active': {
29
- [`.${ICON_AND_LABEL_CLASSNAME}`]: {
30
- background: SMART_LINK_ACTIVE_COLOR
31
- }
32
- }
27
+ lineHeight: 'normal'
33
28
  });
34
29
  const overlayStyles = css({
30
+ position: 'absolute',
31
+ // Vertically align. Required for overlay to be centered inside the inline link (the inline lozenge is slightly larger than the designs)
32
+ transform: 'translate(0%, -50%)',
33
+ top: '50%',
35
34
  // Set default styling to be invisible but available in dom for width calculation.
36
35
  visibility: 'hidden',
37
- marginTop: "var(--ds-space-050, 4px)",
38
- position: 'absolute',
39
- verticalAlign: 'text-top',
40
- height: '1lh',
41
- '@supports not (height: 1lh)': {
42
- height: '1.2em'
43
- },
44
36
  overflow: 'hidden',
45
37
  // EDM-1717: box-shadow Safari fix bring load wrapper zIndex to 1
46
- zIndex: 2,
47
- pointerEvents: 'none'
38
+ zIndex: 2
48
39
  });
49
40
  const showOverlayStyles = css({
50
41
  visibility: 'visible'
51
42
  });
52
43
  const iconStyles = css({
53
- // Position icon in the middle
44
+ background: CONFIGURE_ICON_BACKGROUND_COLOR,
45
+ ':hover': {
46
+ background: CONFIGURE_ICON_BACKGROUND_HOVERED_COLOR
47
+ },
48
+ ':active': {
49
+ background: CONFIGURE_ICON_BACKGROUND_ACTIVE_COLOR
50
+ },
54
51
  span: {
55
- display: 'flex'
56
- }
57
- });
58
- const labelStyles = css({
59
- fontSize: '0.875em',
60
- fontWeight: '600',
61
- width: 'max-content'
52
+ // If PreferencesIcon left as inline-block (default), height is incorrect and border radius is clipped when parent element
53
+ // uses 1lh height (rather than 100%)
54
+ display: 'block'
55
+ },
56
+ // Note: The spec recomends 3px, but the icon doesn't fit left of the lozenge text if this size
57
+ padding: "var(--ds-space-025, 2px)",
58
+ borderRadius: '3px'
62
59
  });
63
60
  const iconAndLabelStyles = css({
64
61
  display: 'flex',
65
62
  alignItems: 'center',
66
63
  height: '100%',
67
- marginLeft: "var(--ds-space-050, 4px)",
68
- marginRight: "var(--ds-space-025, 2px)",
64
+ // eslint-disable-next-line @atlaskit/design-system/use-tokens-space
65
+ marginLeft: '2.5px',
66
+ // Margin from very left of entire card (inclusive of blue)
67
+
68
+ // This exists so if we set a semi-transparent background above, the provider icon doesn't show
69
69
  background: SMART_LINK_BACKGROUND_COLOR,
70
+ // Ensure we don't have a white gap when the inline-card is in an active state
71
+ borderRadius: '3px',
70
72
  color: `var(--ds-text-subtlest, ${N700})`
71
73
  });
72
- const overflowingContainerStyles = css({
73
- display: 'flex',
74
- flexDirection: 'row-reverse',
75
- alignItems: 'center',
76
- width: 'max-content',
77
- height: '100%'
78
- });
79
- const NarrowInlineCardOverlay = ({
74
+ const LeftIconOverlay = ({
80
75
  children,
81
76
  isSelected = false,
82
77
  isVisible = false,
83
78
  testId = 'inline-card-overlay',
84
- url,
85
79
  ...props
86
80
  }) => {
87
81
  const [showOverlay, setShowOverlay] = useState(false);
88
82
  const [availableWidth, setAvailableWidth] = useState(undefined);
89
- const maxOverlayWidth = useRef(0);
90
- const minOverlayWidth = useRef(ESTIMATED_MIN_WIDTH_IN_PX);
91
- const parentWidth = useRef(0);
92
- const iconSize = useRef('small');
93
83
  const containerRef = useRef(null);
94
84
 
95
- // TODO EDM-9843: Use availableWidth for small link edge case
85
+ // TODO EDM-9853: Use availableWidth for small link edge case
86
+ // Calculation logic will need to updated.
96
87
  availableWidth;
97
88
  const setVisibility = useCallback(() => {
98
- if (!containerRef.current || !maxOverlayWidth.current) {
89
+ if (!containerRef.current) {
99
90
  return;
100
91
  }
101
92
  const marker = getChildElement(containerRef, `.${OVERLAY_MARKER_CLASSNAME}`);
@@ -120,30 +111,9 @@ const NarrowInlineCardOverlay = ({
120
111
  }
121
112
  }, [isSelected]);
122
113
  useLayoutEffect(() => {
123
- // Using useLayoutEffect here.
124
- // 1) We want all to be able to determine whether to display label before
125
- // the overlay becomes visible.
126
- // 2) We need to wait for the refs to be assigned to be able to do determine
127
- // the width of the overlay.
128
114
  if (!containerRef.current) {
129
115
  return;
130
116
  }
131
-
132
- // This should run only once
133
- if (!maxOverlayWidth.current) {
134
- const iconAndLabel = getChildElement(containerRef, `.${ICON_AND_LABEL_CLASSNAME}`);
135
- const label = getChildElement(containerRef, `.${OVERLAY_LABEL_CLASSNAME}`);
136
- if (iconAndLabel && label) {
137
- // Set overlay max (label + icon) and min (icon only) width.
138
- const {
139
- max,
140
- min
141
- } = getOverlayWidths(iconAndLabel, label);
142
- maxOverlayWidth.current = max;
143
- minOverlayWidth.current = min;
144
- iconSize.current = getIconSize(label);
145
- }
146
- }
147
117
  if (isVisible) {
148
118
  setVisibility();
149
119
  }
@@ -164,13 +134,6 @@ const NarrowInlineCardOverlay = ({
164
134
  if (!size) {
165
135
  return;
166
136
  }
167
- if (!parentWidth.current) {
168
- parentWidth.current = size;
169
- }
170
- if (parentWidth.current === size) {
171
- return;
172
- }
173
- parentWidth.current = size;
174
137
  setVisibility();
175
138
  }, DEBOUNCE_IN_MS);
176
139
  const observer = new ResizeObserver(updateOverlay);
@@ -180,34 +143,28 @@ const NarrowInlineCardOverlay = ({
180
143
  };
181
144
  }, [isVisible, setVisibility]);
182
145
  const intl = useIntl();
183
- const label = intl.formatMessage(messages.inlineOverlay);
146
+ const configureLinkLabel = intl.formatMessage(messages.inlineConfigureLink);
184
147
  return jsx("span", _extends({}, props, {
185
148
  css: containerStyles,
186
149
  ref: containerRef
187
- }), isVisible && jsx(React.Fragment, null, jsx("span", {
150
+ }), isVisible && jsx(Tooltip, {
151
+ content: configureLinkLabel
152
+ }, tooltipProps => jsx(React.Fragment, null, jsx("span", {
188
153
  "aria-hidden": "true",
189
154
  className: OVERLAY_MARKER_CLASSNAME
190
- }, ZERO_WIDTH_JOINER), jsx("a", {
155
+ }, ZERO_WIDTH_JOINER), jsx("span", {
191
156
  css: [overlayStyles, showOverlay && showOverlayStyles],
192
- "data-testid": testId,
193
- href: url,
194
- onClick: e => e.preventDefault(),
195
- tabIndex: -1
196
- }, jsx("span", {
197
- css: overflowingContainerStyles
198
- }, jsx("span", {
157
+ tabIndex: -1,
158
+ "data-testid": testId
159
+ }, jsx("span", _extends({}, tooltipProps, {
199
160
  css: iconAndLabelStyles,
200
161
  className: ICON_AND_LABEL_CLASSNAME
201
- }, jsx("span", {
162
+ }), jsx("span", {
202
163
  css: iconStyles
203
164
  }, jsx(PreferencesIcon, {
204
- label: label,
205
- size: iconSize.current,
165
+ label: configureLinkLabel,
166
+ size: 'small',
206
167
  testId: `${testId}-icon`
207
- })), jsx("span", {
208
- css: labelStyles,
209
- className: OVERLAY_LABEL_CLASSNAME,
210
- "data-testid": `${testId}-label`
211
- }))))), children);
168
+ })))))), children);
212
169
  };
213
- export default NarrowInlineCardOverlay;
170
+ export default LeftIconOverlay;
@@ -289,10 +289,14 @@ export default class ResizableEmbedCard extends React.Component {
289
289
  return jsx("span", {
290
290
  "data-testid": 'resizable-embed-card-height-definer',
291
291
  style: {
292
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
292
293
  display: 'block',
293
294
  /* Fixes extra padding problem in Firefox */
295
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
294
296
  fontSize: 0,
297
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
295
298
  lineHeight: 0,
299
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
296
300
  ...heightDefiningStyles
297
301
  }
298
302
  });
@@ -275,6 +275,7 @@ export var Datasource = /*#__PURE__*/function (_ReactNodeView) {
275
275
  url: attrs.url,
276
276
  datasourceId: attrs === null || attrs === void 0 || (_attrs$datasource = attrs.datasource) === null || _attrs$datasource === void 0 ? void 0 : _attrs$datasource.id
277
277
  }, jsx("div", {
278
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
278
279
  className: DATASOURCE_INNER_CONTAINER_CLASSNAME,
279
280
  style: {
280
281
  minWidth: this.isNodeNested ? '100%' : calcBreakoutWidth(attrs.layout || DATASOURCE_DEFAULT_LAYOUT, this.tableWidth)
@@ -120,7 +120,10 @@ var InlineCard = function InlineCard(_ref) {
120
120
  markMostRecentlyInsertedLink: markMostRecentlyInsertedLink,
121
121
  pluginInjectionApi: pluginInjectionApi,
122
122
  setOverlayHoveredStyles: setOverlayHoveredStyles
123
- }, innerCard) : /*#__PURE__*/React.createElement("span", {
123
+ }, innerCard) :
124
+ /*#__PURE__*/
125
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
126
+ React.createElement("span", {
124
127
  className: "card"
125
128
  }, innerCard);
126
129
  }, [cardContext, getPos, innerCard, isHovered, isInserted, isOverlayEnabled, isPulseEnabled, isResolvedViewRendered, isSelected, markMostRecentlyInsertedLink, pluginInjectionApi, setOverlayHoveredStyles, url]);
@@ -8,7 +8,7 @@ import useLinkUpgradeDiscoverability from '../../common/hooks/useLinkUpgradeDisc
8
8
  import { isLocalStorageKeyDiscovered, LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK, LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR, markLocalStorageKeyDiscovered, ONE_DAY_IN_MILLISECONDS } from '../../common/local-storage';
9
9
  import { getResolvedAttributesFromStore } from '../../utils';
10
10
  import InlineCardOverlay from '../InlineCardOverlay';
11
- import NewInlineCardOverlay from '../NewInlineCardOverlay';
11
+ import LeftIconOverlay from '../LeftIconOverlay';
12
12
  import { DiscoveryPulse } from '../Pulse';
13
13
  // editor adds a standard line-height that is bigger than an inline smart link
14
14
  // due to that the link has a bit of white space around it, which doesn't look right when there is pulse around it
@@ -73,7 +73,7 @@ export var AwarenessWrapper = function AwarenessWrapper(_ref) {
73
73
  var cardWithOverlay = useMemo(function () {
74
74
  if (shouldShowLinkOverlay) {
75
75
  if (getBooleanFF('platform.linking-platform.smart-links-in-live-pages')) {
76
- return jsx(NewInlineCardOverlay, {
76
+ return jsx(LeftIconOverlay, {
77
77
  isSelected: isSelected,
78
78
  isVisible: isResolvedViewRendered && (isInserted || isHovered || isSelected),
79
79
  onMouseEnter: function onMouseEnter() {
@@ -81,8 +81,7 @@ export var AwarenessWrapper = function AwarenessWrapper(_ref) {
81
81
  },
82
82
  onMouseLeave: function onMouseLeave() {
83
83
  return handleOverlayChange(false);
84
- },
85
- url: url
84
+ }
86
85
  }, children);
87
86
  }
88
87
  return jsx(InlineCardOverlay, {
@@ -101,19 +100,22 @@ export var AwarenessWrapper = function AwarenessWrapper(_ref) {
101
100
  }, [shouldShowLinkOverlay, isSelected, isResolvedViewRendered, isInserted, isHovered, url, children, handleOverlayChange]);
102
101
  return useMemo(function () {
103
102
  var _cardContext$value;
104
- return jsx("span", {
105
- css: shouldShowLinkPulse && loaderWrapperStyles,
106
- className: "card"
107
- }, jsx(AnalyticsContext, {
108
- 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)
110
- }
111
- }, jsx(DiscoveryPulse, {
112
- localStorageKey: LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK,
113
- localStorageKeyExpirationInMs: ONE_DAY_IN_MILLISECONDS,
114
- discoveryMode: "start",
115
- shouldShowPulse: isResolvedViewRendered && shouldShowLinkPulse,
116
- testId: "link-discovery-pulse"
117
- }, cardWithOverlay)));
103
+ return (
104
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
105
+ jsx("span", {
106
+ css: shouldShowLinkPulse && loaderWrapperStyles,
107
+ className: "card"
108
+ }, jsx(AnalyticsContext, {
109
+ data: {
110
+ attributes: getResolvedAttributesFromStore(url, 'inline', cardContext === null || cardContext === void 0 || (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.store)
111
+ }
112
+ }, jsx(DiscoveryPulse, {
113
+ localStorageKey: LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK,
114
+ localStorageKeyExpirationInMs: ONE_DAY_IN_MILLISECONDS,
115
+ discoveryMode: "start",
116
+ shouldShowPulse: isResolvedViewRendered && shouldShowLinkPulse,
117
+ testId: "link-discovery-pulse"
118
+ }, cardWithOverlay)))
119
+ );
118
120
  }, [shouldShowLinkPulse, url, cardContext === null || cardContext === void 0 || (_cardContext$value2 = cardContext.value) === null || _cardContext$value2 === void 0 ? void 0 : _cardContext$value2.store, isResolvedViewRendered, cardWithOverlay]);
119
121
  };
@@ -24,7 +24,7 @@ export var DatasourceModal = function DatasourceModal(_ref) {
24
24
  var onClose = useCallback(function () {
25
25
  dispatch(hideDatasourceModal(transaction));
26
26
  }, [dispatch, transaction]);
27
- var onInsert = useOnInsert(view, existingNode);
27
+ var updateAdf = useUpdateAdf(view, existingNode);
28
28
  var isRegularCardNode = !!(existingNode && !(existingNode !== null && existingNode !== void 0 && (_existingNode$attrs = existingNode.attrs) !== null && _existingNode$attrs !== void 0 && _existingNode$attrs.datasource));
29
29
  var _ref2 = (existingNode === null || existingNode === void 0 || (_existingNode$attrs2 = existingNode.attrs) === null || _existingNode$attrs2 === void 0 ? void 0 : _existingNode$attrs2.datasource) || {},
30
30
  _ref2$id = _ref2.id,
@@ -57,10 +57,10 @@ export var DatasourceModal = function DatasourceModal(_ref) {
57
57
  columnCustomSizes: columnCustomSizes,
58
58
  wrappedColumnKeys: wrappedColumnKeys,
59
59
  onCancel: onClose,
60
- onInsert: onInsert
60
+ onInsert: updateAdf
61
61
  });
62
62
  };
63
- var useOnInsert = function useOnInsert(view, existingNode) {
63
+ var useUpdateAdf = function useUpdateAdf(view, existingNode) {
64
64
  return useCallback(function (newAdf, analyticEvent) {
65
65
  if (analyticEvent) {
66
66
  analyticEvent.update(function (payload) {
@@ -111,10 +111,9 @@ var resolveColumnsConfig = function resolveColumnsConfig(views) {
111
111
  tableView = _views[0];
112
112
  var visibleColumnKeys = [];
113
113
  var wrappedColumnKeys = [];
114
- var columnCustomSizes;
114
+ var columnCustomSizes = {};
115
115
  var columns = tableView === null || tableView === void 0 || (_tableView$properties = tableView.properties) === null || _tableView$properties === void 0 ? void 0 : _tableView$properties.columns;
116
116
  if (columns) {
117
- columnCustomSizes = {};
118
117
  var _iterator = _createForOfIteratorHelper(columns),
119
118
  _step;
120
119
  try {
@@ -231,7 +231,9 @@ var InlineCardOverlay = function InlineCardOverlay(_ref) {
231
231
  }, jsx("span", {
232
232
  css: overflowingContainerStyles
233
233
  }, jsx("span", {
234
- css: iconAndLabelStyles,
234
+ css: iconAndLabelStyles
235
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
236
+ ,
235
237
  className: ICON_AND_LABEL_CLASSNAME
236
238
  }, jsx("span", {
237
239
  css: iconStyles
@@ -240,11 +242,15 @@ var InlineCardOverlay = function InlineCardOverlay(_ref) {
240
242
  size: iconSize.current,
241
243
  testId: "".concat(testId, "-icon")
242
244
  })), showLabel && jsx("span", {
243
- css: labelStyles,
245
+ css: labelStyles
246
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
247
+ ,
244
248
  className: OVERLAY_LABEL_CLASSNAME,
245
249
  "data-testid": "".concat(testId, "-label")
246
250
  }, label)), jsx("span", {
247
- css: gradientStyles,
251
+ css: gradientStyles
252
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
253
+ ,
248
254
  className: OVERLAY_GRADIENT_CLASSNAME,
249
255
  "data-testid": "".concat(testId, "-gradient")
250
256
  })))));
@@ -1,8 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
- var _excluded = ["children", "isSelected", "isVisible", "testId", "url"];
4
+ var _excluded = ["children", "isSelected", "isVisible", "testId"];
6
5
  /* eslint-disable @atlaskit/design-system/no-nested-styles */
7
6
  /* eslint-disable @atlaskit/design-system/prefer-primitives */
8
7
  /** @jsx jsx */
@@ -13,72 +12,69 @@ import { useIntl } from 'react-intl-next';
13
12
  import { cardMessages as messages } from '@atlaskit/editor-common/messages';
14
13
  import { ZERO_WIDTH_JOINER } from '@atlaskit/editor-common/utils';
15
14
  import PreferencesIcon from '@atlaskit/icon/glyph/preferences';
16
- import { B100, N0, N700 } from '@atlaskit/theme/colors';
17
- import { getChildElement, getIconSize, getInlineCardAvailableWidth, getOverlayWidths, isOneLine } from '../InlineCardOverlay/utils';
15
+ import { N0, N30A, N40A, N60A, N700 } from '@atlaskit/theme/colors';
16
+ import Tooltip from '@atlaskit/tooltip';
17
+ import { getChildElement, getInlineCardAvailableWidth, isOneLine } from '../InlineCardOverlay/utils';
18
18
  var DEBOUNCE_IN_MS = 5;
19
- var ESTIMATED_MIN_WIDTH_IN_PX = 16;
20
19
  var PADDING_IN_PX = 4;
21
- var ICON_WIDTH_IN_PX = 14;
20
+ var ICON_WIDTH_IN_PX = 16;
22
21
  var ICON_AND_LABEL_CLASSNAME = 'ak-editor-card-overlay-icon-and-label';
23
- var OVERLAY_LABEL_CLASSNAME = 'ak-editor-card-overlay-label';
24
22
  var OVERLAY_MARKER_CLASSNAME = 'ak-editor-card-overlay-marker';
25
23
  var TEXT_NODE_SELECTOR = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].join(',');
26
24
  var SMART_LINK_BACKGROUND_COLOR = "var(--ds-surface-raised, ".concat(N0, ")");
27
- // TODO: This should be lighter to match the rest of the button
28
- var SMART_LINK_ACTIVE_COLOR = "var(--ds-background-selected, ".concat(B100, ")");
25
+ var CONFIGURE_ICON_BACKGROUND_COLOR = "var(--ds-background-neutral, ".concat(N30A, ")");
26
+ var CONFIGURE_ICON_BACKGROUND_HOVERED_COLOR = "var(--ds-background-neutral-hovered, ".concat(N40A, ")");
27
+ var CONFIGURE_ICON_BACKGROUND_ACTIVE_COLOR = "var(--ds-background-neutral-pressed, ".concat(N60A, ")");
29
28
  var containerStyles = css({
30
29
  position: 'relative',
31
- lineHeight: 'normal',
32
- ':active': _defineProperty({}, ".".concat(ICON_AND_LABEL_CLASSNAME), {
33
- background: SMART_LINK_ACTIVE_COLOR
34
- })
30
+ lineHeight: 'normal'
35
31
  });
36
32
  var overlayStyles = css({
33
+ position: 'absolute',
34
+ // Vertically align. Required for overlay to be centered inside the inline link (the inline lozenge is slightly larger than the designs)
35
+ transform: 'translate(0%, -50%)',
36
+ top: '50%',
37
37
  // Set default styling to be invisible but available in dom for width calculation.
38
38
  visibility: 'hidden',
39
- marginTop: "var(--ds-space-050, 4px)",
40
- position: 'absolute',
41
- verticalAlign: 'text-top',
42
- height: '1lh',
43
- '@supports not (height: 1lh)': {
44
- height: '1.2em'
45
- },
46
39
  overflow: 'hidden',
47
40
  // EDM-1717: box-shadow Safari fix bring load wrapper zIndex to 1
48
- zIndex: 2,
49
- pointerEvents: 'none'
41
+ zIndex: 2
50
42
  });
51
43
  var showOverlayStyles = css({
52
44
  visibility: 'visible'
53
45
  });
54
46
  var iconStyles = css({
55
- // Position icon in the middle
47
+ background: CONFIGURE_ICON_BACKGROUND_COLOR,
48
+ ':hover': {
49
+ background: CONFIGURE_ICON_BACKGROUND_HOVERED_COLOR
50
+ },
51
+ ':active': {
52
+ background: CONFIGURE_ICON_BACKGROUND_ACTIVE_COLOR
53
+ },
56
54
  span: {
57
- display: 'flex'
58
- }
59
- });
60
- var labelStyles = css({
61
- fontSize: '0.875em',
62
- fontWeight: '600',
63
- width: 'max-content'
55
+ // If PreferencesIcon left as inline-block (default), height is incorrect and border radius is clipped when parent element
56
+ // uses 1lh height (rather than 100%)
57
+ display: 'block'
58
+ },
59
+ // Note: The spec recomends 3px, but the icon doesn't fit left of the lozenge text if this size
60
+ padding: "var(--ds-space-025, 2px)",
61
+ borderRadius: '3px'
64
62
  });
65
63
  var iconAndLabelStyles = css({
66
64
  display: 'flex',
67
65
  alignItems: 'center',
68
66
  height: '100%',
69
- marginLeft: "var(--ds-space-050, 4px)",
70
- marginRight: "var(--ds-space-025, 2px)",
67
+ // eslint-disable-next-line @atlaskit/design-system/use-tokens-space
68
+ marginLeft: '2.5px',
69
+ // Margin from very left of entire card (inclusive of blue)
70
+
71
+ // This exists so if we set a semi-transparent background above, the provider icon doesn't show
71
72
  background: SMART_LINK_BACKGROUND_COLOR,
73
+ // Ensure we don't have a white gap when the inline-card is in an active state
74
+ borderRadius: '3px',
72
75
  color: "var(--ds-text-subtlest, ".concat(N700, ")")
73
76
  });
74
- var overflowingContainerStyles = css({
75
- display: 'flex',
76
- flexDirection: 'row-reverse',
77
- alignItems: 'center',
78
- width: 'max-content',
79
- height: '100%'
80
- });
81
- var NarrowInlineCardOverlay = function NarrowInlineCardOverlay(_ref) {
77
+ var LeftIconOverlay = function LeftIconOverlay(_ref) {
82
78
  var children = _ref.children,
83
79
  _ref$isSelected = _ref.isSelected,
84
80
  isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
@@ -86,7 +82,6 @@ var NarrowInlineCardOverlay = function NarrowInlineCardOverlay(_ref) {
86
82
  isVisible = _ref$isVisible === void 0 ? false : _ref$isVisible,
87
83
  _ref$testId = _ref.testId,
88
84
  testId = _ref$testId === void 0 ? 'inline-card-overlay' : _ref$testId,
89
- url = _ref.url,
90
85
  props = _objectWithoutProperties(_ref, _excluded);
91
86
  var _useState = useState(false),
92
87
  _useState2 = _slicedToArray(_useState, 2),
@@ -96,16 +91,13 @@ var NarrowInlineCardOverlay = function NarrowInlineCardOverlay(_ref) {
96
91
  _useState4 = _slicedToArray(_useState3, 2),
97
92
  availableWidth = _useState4[0],
98
93
  setAvailableWidth = _useState4[1];
99
- var maxOverlayWidth = useRef(0);
100
- var minOverlayWidth = useRef(ESTIMATED_MIN_WIDTH_IN_PX);
101
- var parentWidth = useRef(0);
102
- var iconSize = useRef('small');
103
94
  var containerRef = useRef(null);
104
95
 
105
- // TODO EDM-9843: Use availableWidth for small link edge case
96
+ // TODO EDM-9853: Use availableWidth for small link edge case
97
+ // Calculation logic will need to updated.
106
98
  availableWidth;
107
99
  var setVisibility = useCallback(function () {
108
- if (!containerRef.current || !maxOverlayWidth.current) {
100
+ if (!containerRef.current) {
109
101
  return;
110
102
  }
111
103
  var marker = getChildElement(containerRef, ".".concat(OVERLAY_MARKER_CLASSNAME));
@@ -130,29 +122,9 @@ var NarrowInlineCardOverlay = function NarrowInlineCardOverlay(_ref) {
130
122
  }
131
123
  }, [isSelected]);
132
124
  useLayoutEffect(function () {
133
- // Using useLayoutEffect here.
134
- // 1) We want all to be able to determine whether to display label before
135
- // the overlay becomes visible.
136
- // 2) We need to wait for the refs to be assigned to be able to do determine
137
- // the width of the overlay.
138
125
  if (!containerRef.current) {
139
126
  return;
140
127
  }
141
-
142
- // This should run only once
143
- if (!maxOverlayWidth.current) {
144
- var iconAndLabel = getChildElement(containerRef, ".".concat(ICON_AND_LABEL_CLASSNAME));
145
- var _label = getChildElement(containerRef, ".".concat(OVERLAY_LABEL_CLASSNAME));
146
- if (iconAndLabel && _label) {
147
- // Set overlay max (label + icon) and min (icon only) width.
148
- var _getOverlayWidths = getOverlayWidths(iconAndLabel, _label),
149
- max = _getOverlayWidths.max,
150
- min = _getOverlayWidths.min;
151
- maxOverlayWidth.current = max;
152
- minOverlayWidth.current = min;
153
- iconSize.current = getIconSize(_label);
154
- }
155
- }
156
128
  if (isVisible) {
157
129
  setVisibility();
158
130
  }
@@ -173,13 +145,6 @@ var NarrowInlineCardOverlay = function NarrowInlineCardOverlay(_ref) {
173
145
  if (!size) {
174
146
  return;
175
147
  }
176
- if (!parentWidth.current) {
177
- parentWidth.current = size;
178
- }
179
- if (parentWidth.current === size) {
180
- return;
181
- }
182
- parentWidth.current = size;
183
148
  setVisibility();
184
149
  }, DEBOUNCE_IN_MS);
185
150
  var observer = new ResizeObserver(updateOverlay);
@@ -189,36 +154,30 @@ var NarrowInlineCardOverlay = function NarrowInlineCardOverlay(_ref) {
189
154
  };
190
155
  }, [isVisible, setVisibility]);
191
156
  var intl = useIntl();
192
- var label = intl.formatMessage(messages.inlineOverlay);
157
+ var configureLinkLabel = intl.formatMessage(messages.inlineConfigureLink);
193
158
  return jsx("span", _extends({}, props, {
194
159
  css: containerStyles,
195
160
  ref: containerRef
196
- }), isVisible && jsx(React.Fragment, null, jsx("span", {
197
- "aria-hidden": "true",
198
- className: OVERLAY_MARKER_CLASSNAME
199
- }, ZERO_WIDTH_JOINER), jsx("a", {
200
- css: [overlayStyles, showOverlay && showOverlayStyles],
201
- "data-testid": testId,
202
- href: url,
203
- onClick: function onClick(e) {
204
- return e.preventDefault();
205
- },
206
- tabIndex: -1
207
- }, jsx("span", {
208
- css: overflowingContainerStyles
209
- }, jsx("span", {
210
- css: iconAndLabelStyles,
211
- className: ICON_AND_LABEL_CLASSNAME
212
- }, jsx("span", {
213
- css: iconStyles
214
- }, jsx(PreferencesIcon, {
215
- label: label,
216
- size: iconSize.current,
217
- testId: "".concat(testId, "-icon")
218
- })), jsx("span", {
219
- css: labelStyles,
220
- className: OVERLAY_LABEL_CLASSNAME,
221
- "data-testid": "".concat(testId, "-label")
222
- }))))), children);
161
+ }), isVisible && jsx(Tooltip, {
162
+ content: configureLinkLabel
163
+ }, function (tooltipProps) {
164
+ return jsx(React.Fragment, null, jsx("span", {
165
+ "aria-hidden": "true",
166
+ className: OVERLAY_MARKER_CLASSNAME
167
+ }, ZERO_WIDTH_JOINER), jsx("span", {
168
+ css: [overlayStyles, showOverlay && showOverlayStyles],
169
+ tabIndex: -1,
170
+ "data-testid": testId
171
+ }, jsx("span", _extends({}, tooltipProps, {
172
+ css: iconAndLabelStyles,
173
+ className: ICON_AND_LABEL_CLASSNAME
174
+ }), jsx("span", {
175
+ css: iconStyles
176
+ }, jsx(PreferencesIcon, {
177
+ label: configureLinkLabel,
178
+ size: 'small',
179
+ testId: "".concat(testId, "-icon")
180
+ })))));
181
+ }), children);
223
182
  };
224
- export default NarrowInlineCardOverlay;
183
+ export default LeftIconOverlay;
@@ -308,9 +308,12 @@ var ResizableEmbedCard = /*#__PURE__*/function (_React$Component) {
308
308
  return jsx("span", {
309
309
  "data-testid": 'resizable-embed-card-height-definer',
310
310
  style: _objectSpread({
311
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
311
312
  display: 'block',
312
313
  /* Fixes extra padding problem in Firefox */
314
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
313
315
  fontSize: 0,
316
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
314
317
  lineHeight: 0
315
318
  }, heightDefiningStyles)
316
319
  });