@atlaskit/editor-plugin-card 1.14.4 → 1.15.0

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 (61) hide show
  1. package/.eslintrc.js +12 -12
  2. package/CHANGELOG.md +692 -681
  3. package/LICENSE.md +6 -8
  4. package/dist/cjs/nodeviews/datasource.js +1 -0
  5. package/dist/cjs/nodeviews/inlineCardWithAwareness.js +4 -1
  6. package/dist/cjs/pm-plugins/doc.js +21 -1
  7. package/dist/cjs/toolbar.js +36 -6
  8. package/dist/cjs/ui/AwarenessWrapper/index.js +20 -18
  9. package/dist/cjs/ui/DatasourceModal/index.js +4 -5
  10. package/dist/cjs/ui/EditDatasourceButton.js +5 -26
  11. package/dist/cjs/ui/EditToolbarButton.js +139 -0
  12. package/dist/cjs/ui/InlineCardOverlay/index.js +9 -3
  13. package/dist/cjs/ui/{NewInlineCardOverlay → LeftIconOverlay}/index.js +60 -101
  14. package/dist/cjs/ui/ResizableEmbedCard.js +3 -0
  15. package/dist/cjs/utils.js +4 -1
  16. package/dist/es2019/nodeviews/datasource.js +1 -0
  17. package/dist/es2019/nodeviews/inlineCardWithAwareness.js +4 -1
  18. package/dist/es2019/pm-plugins/doc.js +22 -2
  19. package/dist/es2019/toolbar.js +33 -7
  20. package/dist/es2019/ui/AwarenessWrapper/index.js +20 -18
  21. package/dist/es2019/ui/DatasourceModal/index.js +4 -5
  22. package/dist/es2019/ui/EditDatasourceButton.js +1 -22
  23. package/dist/es2019/ui/EditToolbarButton.js +123 -0
  24. package/dist/es2019/ui/InlineCardOverlay/index.js +9 -3
  25. package/dist/es2019/ui/{NewInlineCardOverlay → LeftIconOverlay}/index.js +51 -94
  26. package/dist/es2019/ui/ResizableEmbedCard.js +4 -0
  27. package/dist/es2019/utils.js +3 -0
  28. package/dist/esm/nodeviews/datasource.js +1 -0
  29. package/dist/esm/nodeviews/inlineCardWithAwareness.js +4 -1
  30. package/dist/esm/pm-plugins/doc.js +22 -2
  31. package/dist/esm/toolbar.js +38 -8
  32. package/dist/esm/ui/AwarenessWrapper/index.js +20 -18
  33. package/dist/esm/ui/DatasourceModal/index.js +4 -5
  34. package/dist/esm/ui/EditDatasourceButton.js +1 -22
  35. package/dist/esm/ui/EditToolbarButton.js +131 -0
  36. package/dist/esm/ui/InlineCardOverlay/index.js +9 -3
  37. package/dist/esm/ui/{NewInlineCardOverlay → LeftIconOverlay}/index.js +62 -103
  38. package/dist/esm/ui/ResizableEmbedCard.js +3 -0
  39. package/dist/esm/utils.js +3 -0
  40. package/dist/types/pm-plugins/doc.d.ts +1 -0
  41. package/dist/types/ui/EditDatasourceButton.d.ts +0 -2
  42. package/dist/types/ui/EditToolbarButton.d.ts +15 -0
  43. package/dist/types/ui/EditorAnalyticsContext.d.ts +1 -1
  44. package/dist/types/ui/EditorLinkingPlatformAnalytics/DatasourceEvents.d.ts +1 -1
  45. package/dist/types/ui/EditorLinkingPlatformAnalytics/LinkEvents.d.ts +1 -1
  46. package/dist/types/ui/EditorSmartCardEvents.d.ts +1 -1
  47. package/dist/types/ui/LeftIconOverlay/index.d.ts +10 -0
  48. package/dist/types/utils.d.ts +2 -0
  49. package/dist/types-ts4.5/pm-plugins/doc.d.ts +1 -0
  50. package/dist/types-ts4.5/ui/EditDatasourceButton.d.ts +0 -2
  51. package/dist/types-ts4.5/ui/EditToolbarButton.d.ts +15 -0
  52. package/dist/types-ts4.5/ui/EditorAnalyticsContext.d.ts +1 -1
  53. package/dist/types-ts4.5/ui/EditorLinkingPlatformAnalytics/DatasourceEvents.d.ts +1 -1
  54. package/dist/types-ts4.5/ui/EditorLinkingPlatformAnalytics/LinkEvents.d.ts +1 -1
  55. package/dist/types-ts4.5/ui/EditorSmartCardEvents.d.ts +1 -1
  56. package/dist/types-ts4.5/ui/LeftIconOverlay/index.d.ts +10 -0
  57. package/dist/types-ts4.5/utils.d.ts +2 -0
  58. package/package.json +9 -6
  59. package/report.api.md +94 -96
  60. package/dist/types/ui/NewInlineCardOverlay/index.d.ts +0 -6
  61. package/dist/types-ts4.5/ui/NewInlineCardOverlay/index.d.ts +0 -6
@@ -2,9 +2,8 @@
2
2
  import { css, jsx } from '@emotion/react';
3
3
  import { cardMessages as messages } from '@atlaskit/editor-common/messages';
4
4
  import { FloatingToolbarButton as Button, FloatingToolbarSeparator as Separator, SmallerEditIcon } from '@atlaskit/editor-common/ui';
5
- import { getDatasourceType } from '@atlaskit/editor-common/utils';
6
5
  import { Flex } from '@atlaskit/primitives';
7
- import { showDatasourceModal } from '../pm-plugins/actions';
6
+ import { editDatasource } from '../pm-plugins/doc';
8
7
  import { isDatasourceConfigEditable } from '../utils';
9
8
  import { CardContextProvider } from './CardContextProvider';
10
9
  import { useFetchDatasourceInfo } from './useFetchDatasourceInfo';
@@ -71,24 +70,4 @@ export var EditDatasourceButton = function EditDatasourceButton(_ref2) {
71
70
  cardContext: cardContext
72
71
  });
73
72
  });
74
- };
75
- export var editDatasource = function editDatasource(datasourceId, editorAnalyticsApi) {
76
- return function (state, dispatch) {
77
- var datasourceType = getDatasourceType(datasourceId);
78
- if (dispatch && datasourceType) {
79
- var tr = state.tr;
80
- showDatasourceModal(datasourceType)(tr);
81
- // editorAnalyticsApi?.attachAnalyticsEvent(
82
- // buildEditLinkPayload(
83
- // type as
84
- // | ACTION_SUBJECT_ID.CARD_INLINE
85
- // | ACTION_SUBJECT_ID.CARD_BLOCK
86
- // | ACTION_SUBJECT_ID.EMBEDS,
87
- // ),
88
- // )(tr);
89
- dispatch(tr);
90
- return true;
91
- }
92
- return false;
93
- };
94
73
  };
@@ -0,0 +1,131 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ /** @jsx jsx */
3
+ import { useCallback, useMemo, useRef, useState } from 'react';
4
+ import { css, jsx } from '@emotion/react';
5
+ import { FormattedMessage } from 'react-intl-next';
6
+ import { linkToolbarMessages, cardMessages as messages } from '@atlaskit/editor-common/messages';
7
+ import { FloatingToolbarButton as Button } from '@atlaskit/editor-common/ui';
8
+ import { ArrowKeyNavigationType, DropdownContainer as UiDropdown } from '@atlaskit/editor-common/ui-menu';
9
+ import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
10
+ import { ButtonItem } from '@atlaskit/menu';
11
+ import { Flex } from '@atlaskit/primitives';
12
+ import { editDatasource } from '../pm-plugins/doc';
13
+ import { isDatasourceConfigEditable } from '../utils';
14
+ import { CardContextProvider } from './CardContextProvider';
15
+ import { useFetchDatasourceInfo } from './useFetchDatasourceInfo';
16
+ var dropdownExpandContainer = css({
17
+ margin: "0px ".concat("var(--ds-space-negative-050, -4px)")
18
+ });
19
+ var EditButtonWithCardContext = function EditButtonWithCardContext(_ref) {
20
+ var cardContext = _ref.cardContext,
21
+ intl = _ref.intl,
22
+ editorAnalyticsApi = _ref.editorAnalyticsApi,
23
+ url = _ref.url,
24
+ editorView = _ref.editorView,
25
+ onLinkEditClick = _ref.onLinkEditClick;
26
+ var _useFetchDatasourceIn = useFetchDatasourceInfo({
27
+ isRegularCardNode: true,
28
+ url: url,
29
+ cardContext: cardContext
30
+ }),
31
+ datasourceId = _useFetchDatasourceIn.datasourceId;
32
+ var _useState = useState(false),
33
+ _useState2 = _slicedToArray(_useState, 2),
34
+ isOpen = _useState2[0],
35
+ setIsOpen = _useState2[1];
36
+ var containerRef = useRef();
37
+ var toggleOpen = function toggleOpen() {
38
+ return setIsOpen(function (open) {
39
+ return !open;
40
+ });
41
+ };
42
+ var onClose = function onClose() {
43
+ return setIsOpen(false);
44
+ };
45
+ var dispatchCommand = useCallback(function (fn) {
46
+ if (editorView) {
47
+ fn === null || fn === void 0 || fn(editorView.state, editorView.dispatch);
48
+ if (!editorView.hasFocus()) {
49
+ editorView.focus();
50
+ }
51
+ }
52
+ }, [editorView]);
53
+ var onEditLink = useCallback(function () {
54
+ dispatchCommand(onLinkEditClick);
55
+ }, [dispatchCommand, onLinkEditClick]);
56
+ var shouldFallbackToEditButton = useMemo(function () {
57
+ if (!datasourceId || !isDatasourceConfigEditable(datasourceId)) {
58
+ return true;
59
+ }
60
+ if (url) {
61
+ var _cardContext$store, _urlState$error;
62
+ var urlState = cardContext === null || cardContext === void 0 || (_cardContext$store = cardContext.store) === null || _cardContext$store === void 0 ? void 0 : _cardContext$store.getState()[url];
63
+ if ((urlState === null || urlState === void 0 || (_urlState$error = urlState.error) === null || _urlState$error === void 0 ? void 0 : _urlState$error.kind) === 'fatal') {
64
+ return true;
65
+ }
66
+ }
67
+ return false;
68
+ }, [cardContext === null || cardContext === void 0 ? void 0 : cardContext.store, datasourceId, url]);
69
+ var onEditDatasource = useCallback(function () {
70
+ if (datasourceId) {
71
+ dispatchCommand(editDatasource(datasourceId, editorAnalyticsApi));
72
+ }
73
+ }, [dispatchCommand, datasourceId, editorAnalyticsApi]);
74
+ if (shouldFallbackToEditButton) {
75
+ return jsx(Button, {
76
+ testId: "edit-link",
77
+ onClick: onEditLink
78
+ }, jsx(FormattedMessage, linkToolbarMessages.editLink));
79
+ }
80
+ var trigger = jsx(Button, {
81
+ testId: "edit-dropdown-trigger",
82
+ iconAfter: jsx("span", {
83
+ css: dropdownExpandContainer
84
+ }, jsx(ExpandIcon, {
85
+ label: intl.formatMessage(messages.editDropdownTriggerTitle)
86
+ })),
87
+ onClick: toggleOpen,
88
+ selected: isOpen,
89
+ disabled: false,
90
+ ariaHasPopup: true
91
+ }, jsx(FormattedMessage, messages.editDropdownTriggerTitle));
92
+ return jsx(Flex, {
93
+ ref: containerRef
94
+ }, jsx(UiDropdown, {
95
+ mountTo: containerRef.current,
96
+ isOpen: isOpen,
97
+ handleClickOutside: onClose,
98
+ handleEscapeKeydown: onClose,
99
+ trigger: trigger,
100
+ scrollableElement: containerRef.current,
101
+ arrowKeyNavigationProviderOptions: {
102
+ type: ArrowKeyNavigationType.MENU
103
+ }
104
+ }, jsx(ButtonItem, {
105
+ key: "edit.link",
106
+ onClick: onEditLink,
107
+ testId: "edit-dropdown-edit-link-item"
108
+ }, jsx(FormattedMessage, messages.editDropdownEditLinkTitle)), jsx(ButtonItem, {
109
+ key: "edit.datasource",
110
+ onClick: onEditDatasource,
111
+ testId: "edit-dropdown-edit-datasource-item"
112
+ }, jsx(FormattedMessage, messages.editDropdownEditDatasourceTitle))));
113
+ };
114
+ export var EditToolbarButton = function EditToolbarButton(_ref2) {
115
+ var intl = _ref2.intl,
116
+ editorAnalyticsApi = _ref2.editorAnalyticsApi,
117
+ url = _ref2.url,
118
+ editorView = _ref2.editorView,
119
+ onLinkEditClick = _ref2.onLinkEditClick;
120
+ return jsx(CardContextProvider, null, function (_ref3) {
121
+ var cardContext = _ref3.cardContext;
122
+ return jsx(EditButtonWithCardContext, {
123
+ url: url,
124
+ intl: intl,
125
+ editorAnalyticsApi: editorAnalyticsApi,
126
+ editorView: editorView,
127
+ cardContext: cardContext,
128
+ onLinkEditClick: onLinkEditClick
129
+ });
130
+ });
131
+ };
@@ -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
  });
package/dist/esm/utils.js CHANGED
@@ -80,6 +80,9 @@ export var isDatasourceConfigEditable = function isDatasourceConfigEditable(data
80
80
  }
81
81
  return datasourcesWithConfigModal.includes(datasourceId);
82
82
  };
83
+ export var isEditDropdownEnabled = function isEditDropdownEnabled(platform) {
84
+ return getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar') && platform !== 'mobile';
85
+ };
83
86
 
84
87
  /**
85
88
  * Typeguard that checks node attributes are datasource node attributes
@@ -38,4 +38,5 @@ export declare const insertDatasource: (state: EditorState, adf: DatasourceAdf |
38
38
  * Get attributes for new Card Appearance
39
39
  */
40
40
  export declare const getAttrsForAppearance: (appearance: CardAppearance, selectedNode: Node) => import("prosemirror-model").Attrs;
41
+ export declare const editDatasource: (datasourceId: string, _editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
41
42
  export {};
@@ -2,7 +2,6 @@
2
2
  import { jsx } from '@emotion/react';
3
3
  import type { IntlShape } from 'react-intl-next';
4
4
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
5
- import type { Command } from '@atlaskit/editor-common/types';
6
5
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
7
6
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
8
7
  import type { CardContext } from '@atlaskit/link-provider';
@@ -15,4 +14,3 @@ export interface EditDatasourceButtonProps {
15
14
  cardContext?: CardContext;
16
15
  }
17
16
  export declare const EditDatasourceButton: ({ intl, editorAnalyticsApi, url, editorView, editorState, }: EditDatasourceButtonProps) => jsx.JSX.Element;
18
- export declare const editDatasource: (datasourceId: string, editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
@@ -0,0 +1,15 @@
1
+ import { jsx } from '@emotion/react';
2
+ import { type IntlShape } from 'react-intl-next';
3
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
4
+ import type { Command } from '@atlaskit/editor-common/types';
5
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { CardContext } from '@atlaskit/link-provider';
7
+ export interface EditToolbarButtonProps {
8
+ intl: IntlShape;
9
+ editorAnalyticsApi?: EditorAnalyticsAPI;
10
+ url?: string;
11
+ editorView?: EditorView;
12
+ cardContext?: CardContext;
13
+ onLinkEditClick: Command;
14
+ }
15
+ export declare const EditToolbarButton: ({ intl, editorAnalyticsApi, url, editorView, onLinkEditClick, }: EditToolbarButtonProps) => jsx.JSX.Element;
@@ -7,4 +7,4 @@ export type EditorAnalyticsContextProps = {
7
7
  /**
8
8
  * Provides location attribute to child events
9
9
  */
10
- export declare const EditorAnalyticsContext: ({ editorView, children, }: EditorAnalyticsContextProps) => JSX.Element;
10
+ export declare const EditorAnalyticsContext: ({ editorView, children }: EditorAnalyticsContextProps) => JSX.Element;
@@ -3,4 +3,4 @@ import type { AnalyticsBindingsProps } from './common';
3
3
  * Subscribes to the events occuring in the card
4
4
  * plugin and fires analytics events accordingly
5
5
  */
6
- export declare const DatasourceEventsBinding: ({ cardPluginEvents, }: AnalyticsBindingsProps) => null;
6
+ export declare const DatasourceEventsBinding: ({ cardPluginEvents }: AnalyticsBindingsProps) => null;
@@ -3,4 +3,4 @@ import type { AnalyticsBindingsProps } from './common';
3
3
  * Subscribes to the events occuring in the card
4
4
  * plugin and fires analytics events accordingly
5
5
  */
6
- export declare const LinkEventsBinding: ({ cardPluginEvents, }: AnalyticsBindingsProps) => null;
6
+ export declare const LinkEventsBinding: ({ cardPluginEvents }: AnalyticsBindingsProps) => null;
@@ -1,4 +1,4 @@
1
1
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
- export declare const EditorSmartCardEvents: ({ editorView, }: {
2
+ export declare const EditorSmartCardEvents: ({ editorView }: {
3
3
  editorView: EditorView;
4
4
  }) => null;
@@ -0,0 +1,10 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ import { jsx } from '@emotion/react';
4
+ export type LeftIconOverlayProps = React.HTMLAttributes<HTMLSpanElement> & {
5
+ isSelected?: boolean;
6
+ isVisible?: boolean;
7
+ testId?: string;
8
+ };
9
+ declare const LeftIconOverlay: ({ children, isSelected, isVisible, testId, ...props }: React.PropsWithChildren<LeftIconOverlayProps>) => jsx.JSX.Element;
10
+ export default LeftIconOverlay;
@@ -2,6 +2,7 @@ import type { CardAppearance } from '@atlaskit/editor-common/provider-factory';
2
2
  import type { Node, NodeType } from '@atlaskit/editor-prosemirror/model';
3
3
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { CardContext } from '@atlaskit/link-provider';
5
+ import type { CardPlatform } from '@atlaskit/smart-card';
5
6
  import type { CardInfo, DatasourceNode } from './types';
6
7
  export declare const appearanceForNodeType: (spec: NodeType) => CardAppearance | undefined;
7
8
  export declare const selectedCardAppearance: (state: EditorState) => CardAppearance | undefined;
@@ -22,6 +23,7 @@ export declare const isEmbedSupportedAtPosition: (currentNodePosition: number, e
22
23
  export declare const isBlockSupportedAtPosition: (currentNodePosition: number, editorState: EditorState, currentAppearance?: CardAppearance) => boolean;
23
24
  export declare const getResolvedAttributesFromStore: (url: string, display: string | null, store?: CardContext['store']) => {};
24
25
  export declare const isDatasourceConfigEditable: (datasourceId: string) => boolean;
26
+ export declare const isEditDropdownEnabled: (platform?: CardPlatform) => boolean;
25
27
  /**
26
28
  * Typeguard that checks node attributes are datasource node attributes
27
29
  * ** WARNING ** Typeguards are not a guarantee, if the asserted type changes
@@ -38,4 +38,5 @@ export declare const insertDatasource: (state: EditorState, adf: DatasourceAdf |
38
38
  * Get attributes for new Card Appearance
39
39
  */
40
40
  export declare const getAttrsForAppearance: (appearance: CardAppearance, selectedNode: Node) => import("prosemirror-model").Attrs;
41
+ export declare const editDatasource: (datasourceId: string, _editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
41
42
  export {};
@@ -2,7 +2,6 @@
2
2
  import { jsx } from '@emotion/react';
3
3
  import type { IntlShape } from 'react-intl-next';
4
4
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
5
- import type { Command } from '@atlaskit/editor-common/types';
6
5
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
7
6
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
8
7
  import type { CardContext } from '@atlaskit/link-provider';
@@ -15,4 +14,3 @@ export interface EditDatasourceButtonProps {
15
14
  cardContext?: CardContext;
16
15
  }
17
16
  export declare const EditDatasourceButton: ({ intl, editorAnalyticsApi, url, editorView, editorState, }: EditDatasourceButtonProps) => jsx.JSX.Element;
18
- export declare const editDatasource: (datasourceId: string, editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
@@ -0,0 +1,15 @@
1
+ import { jsx } from '@emotion/react';
2
+ import { type IntlShape } from 'react-intl-next';
3
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
4
+ import type { Command } from '@atlaskit/editor-common/types';
5
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { CardContext } from '@atlaskit/link-provider';
7
+ export interface EditToolbarButtonProps {
8
+ intl: IntlShape;
9
+ editorAnalyticsApi?: EditorAnalyticsAPI;
10
+ url?: string;
11
+ editorView?: EditorView;
12
+ cardContext?: CardContext;
13
+ onLinkEditClick: Command;
14
+ }
15
+ export declare const EditToolbarButton: ({ intl, editorAnalyticsApi, url, editorView, onLinkEditClick, }: EditToolbarButtonProps) => jsx.JSX.Element;
@@ -7,4 +7,4 @@ export type EditorAnalyticsContextProps = {
7
7
  /**
8
8
  * Provides location attribute to child events
9
9
  */
10
- export declare const EditorAnalyticsContext: ({ editorView, children, }: EditorAnalyticsContextProps) => JSX.Element;
10
+ export declare const EditorAnalyticsContext: ({ editorView, children }: EditorAnalyticsContextProps) => JSX.Element;
@@ -3,4 +3,4 @@ import type { AnalyticsBindingsProps } from './common';
3
3
  * Subscribes to the events occuring in the card
4
4
  * plugin and fires analytics events accordingly
5
5
  */
6
- export declare const DatasourceEventsBinding: ({ cardPluginEvents, }: AnalyticsBindingsProps) => null;
6
+ export declare const DatasourceEventsBinding: ({ cardPluginEvents }: AnalyticsBindingsProps) => null;
@@ -3,4 +3,4 @@ import type { AnalyticsBindingsProps } from './common';
3
3
  * Subscribes to the events occuring in the card
4
4
  * plugin and fires analytics events accordingly
5
5
  */
6
- export declare const LinkEventsBinding: ({ cardPluginEvents, }: AnalyticsBindingsProps) => null;
6
+ export declare const LinkEventsBinding: ({ cardPluginEvents }: AnalyticsBindingsProps) => null;
@@ -1,4 +1,4 @@
1
1
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
- export declare const EditorSmartCardEvents: ({ editorView, }: {
2
+ export declare const EditorSmartCardEvents: ({ editorView }: {
3
3
  editorView: EditorView;
4
4
  }) => null;
@@ -0,0 +1,10 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ import { jsx } from '@emotion/react';
4
+ export type LeftIconOverlayProps = React.HTMLAttributes<HTMLSpanElement> & {
5
+ isSelected?: boolean;
6
+ isVisible?: boolean;
7
+ testId?: string;
8
+ };
9
+ declare const LeftIconOverlay: ({ children, isSelected, isVisible, testId, ...props }: React.PropsWithChildren<LeftIconOverlayProps>) => jsx.JSX.Element;
10
+ export default LeftIconOverlay;