@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
@@ -0,0 +1,123 @@
1
+ /** @jsx jsx */
2
+ import { useCallback, useMemo, useRef, useState } from 'react';
3
+ import { css, jsx } from '@emotion/react';
4
+ import { FormattedMessage } from 'react-intl-next';
5
+ import { linkToolbarMessages, cardMessages as messages } from '@atlaskit/editor-common/messages';
6
+ import { FloatingToolbarButton as Button } from '@atlaskit/editor-common/ui';
7
+ import { ArrowKeyNavigationType, DropdownContainer as UiDropdown } from '@atlaskit/editor-common/ui-menu';
8
+ import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
9
+ import { ButtonItem } from '@atlaskit/menu';
10
+ import { Flex } from '@atlaskit/primitives';
11
+ import { editDatasource } from '../pm-plugins/doc';
12
+ import { isDatasourceConfigEditable } from '../utils';
13
+ import { CardContextProvider } from './CardContextProvider';
14
+ import { useFetchDatasourceInfo } from './useFetchDatasourceInfo';
15
+ const dropdownExpandContainer = css({
16
+ margin: `0px ${"var(--ds-space-negative-050, -4px)"}`
17
+ });
18
+ const EditButtonWithCardContext = ({
19
+ cardContext,
20
+ intl,
21
+ editorAnalyticsApi,
22
+ url,
23
+ editorView,
24
+ onLinkEditClick
25
+ }) => {
26
+ const {
27
+ datasourceId
28
+ } = useFetchDatasourceInfo({
29
+ isRegularCardNode: true,
30
+ url,
31
+ cardContext
32
+ });
33
+ const [isOpen, setIsOpen] = useState(false);
34
+ const containerRef = useRef();
35
+ const toggleOpen = () => setIsOpen(open => !open);
36
+ const onClose = () => setIsOpen(false);
37
+ const dispatchCommand = useCallback(fn => {
38
+ if (editorView) {
39
+ fn === null || fn === void 0 ? void 0 : fn(editorView.state, editorView.dispatch);
40
+ if (!editorView.hasFocus()) {
41
+ editorView.focus();
42
+ }
43
+ }
44
+ }, [editorView]);
45
+ const onEditLink = useCallback(() => {
46
+ dispatchCommand(onLinkEditClick);
47
+ }, [dispatchCommand, onLinkEditClick]);
48
+ const shouldFallbackToEditButton = useMemo(() => {
49
+ if (!datasourceId || !isDatasourceConfigEditable(datasourceId)) {
50
+ return true;
51
+ }
52
+ if (url) {
53
+ var _cardContext$store, _urlState$error;
54
+ const urlState = cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$store = cardContext.store) === null || _cardContext$store === void 0 ? void 0 : _cardContext$store.getState()[url];
55
+ if ((urlState === null || urlState === void 0 ? void 0 : (_urlState$error = urlState.error) === null || _urlState$error === void 0 ? void 0 : _urlState$error.kind) === 'fatal') {
56
+ return true;
57
+ }
58
+ }
59
+ return false;
60
+ }, [cardContext === null || cardContext === void 0 ? void 0 : cardContext.store, datasourceId, url]);
61
+ const onEditDatasource = useCallback(() => {
62
+ if (datasourceId) {
63
+ dispatchCommand(editDatasource(datasourceId, editorAnalyticsApi));
64
+ }
65
+ }, [dispatchCommand, datasourceId, editorAnalyticsApi]);
66
+ if (shouldFallbackToEditButton) {
67
+ return jsx(Button, {
68
+ testId: "edit-link",
69
+ onClick: onEditLink
70
+ }, jsx(FormattedMessage, linkToolbarMessages.editLink));
71
+ }
72
+ const trigger = jsx(Button, {
73
+ testId: "edit-dropdown-trigger",
74
+ iconAfter: jsx("span", {
75
+ css: dropdownExpandContainer
76
+ }, jsx(ExpandIcon, {
77
+ label: intl.formatMessage(messages.editDropdownTriggerTitle)
78
+ })),
79
+ onClick: toggleOpen,
80
+ selected: isOpen,
81
+ disabled: false,
82
+ ariaHasPopup: true
83
+ }, jsx(FormattedMessage, messages.editDropdownTriggerTitle));
84
+ return jsx(Flex, {
85
+ ref: containerRef
86
+ }, jsx(UiDropdown, {
87
+ mountTo: containerRef.current,
88
+ isOpen: isOpen,
89
+ handleClickOutside: onClose,
90
+ handleEscapeKeydown: onClose,
91
+ trigger: trigger,
92
+ scrollableElement: containerRef.current,
93
+ arrowKeyNavigationProviderOptions: {
94
+ type: ArrowKeyNavigationType.MENU
95
+ }
96
+ }, jsx(ButtonItem, {
97
+ key: "edit.link",
98
+ onClick: onEditLink,
99
+ testId: "edit-dropdown-edit-link-item"
100
+ }, jsx(FormattedMessage, messages.editDropdownEditLinkTitle)), jsx(ButtonItem, {
101
+ key: "edit.datasource",
102
+ onClick: onEditDatasource,
103
+ testId: "edit-dropdown-edit-datasource-item"
104
+ }, jsx(FormattedMessage, messages.editDropdownEditDatasourceTitle))));
105
+ };
106
+ export const EditToolbarButton = ({
107
+ intl,
108
+ editorAnalyticsApi,
109
+ url,
110
+ editorView,
111
+ onLinkEditClick
112
+ }) => {
113
+ return jsx(CardContextProvider, null, ({
114
+ cardContext
115
+ }) => jsx(EditButtonWithCardContext, {
116
+ url: url,
117
+ intl: intl,
118
+ editorAnalyticsApi: editorAnalyticsApi,
119
+ editorView: editorView,
120
+ cardContext: cardContext,
121
+ onLinkEditClick: onLinkEditClick
122
+ }));
123
+ };
@@ -217,7 +217,9 @@ const InlineCardOverlay = ({
217
217
  }, jsx("span", {
218
218
  css: overflowingContainerStyles
219
219
  }, jsx("span", {
220
- css: iconAndLabelStyles,
220
+ css: iconAndLabelStyles
221
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
222
+ ,
221
223
  className: ICON_AND_LABEL_CLASSNAME
222
224
  }, jsx("span", {
223
225
  css: iconStyles
@@ -226,11 +228,15 @@ const InlineCardOverlay = ({
226
228
  size: iconSize.current,
227
229
  testId: `${testId}-icon`
228
230
  })), showLabel && jsx("span", {
229
- css: labelStyles,
231
+ css: labelStyles
232
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
233
+ ,
230
234
  className: OVERLAY_LABEL_CLASSNAME,
231
235
  "data-testid": `${testId}-label`
232
236
  }, label)), jsx("span", {
233
- css: gradientStyles,
237
+ css: gradientStyles
238
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
239
+ ,
234
240
  className: OVERLAY_GRADIENT_CLASSNAME,
235
241
  "data-testid": `${testId}-gradient`
236
242
  })))));
@@ -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
  });
@@ -73,6 +73,9 @@ export const isDatasourceConfigEditable = datasourceId => {
73
73
  }
74
74
  return datasourcesWithConfigModal.includes(datasourceId);
75
75
  };
76
+ export const isEditDropdownEnabled = platform => {
77
+ return getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar') && platform !== 'mobile';
78
+ };
76
79
 
77
80
  /**
78
81
  * Typeguard that checks node attributes are datasource node attributes
@@ -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]);
@@ -6,12 +6,12 @@ import isEqual from 'lodash/isEqual';
6
6
  import { isSafeUrl } from '@atlaskit/adf-schema';
7
7
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, SMART_LINK_TYPE, unlinkPayload } from '@atlaskit/editor-common/analytics';
8
8
  import { addLinkMetadata } from '@atlaskit/editor-common/card';
9
- import { getLinkCreationAnalyticsEvent, isFromCurrentDomain, nodesBetweenChanged, processRawValue } from '@atlaskit/editor-common/utils';
9
+ import { getDatasourceType, getLinkCreationAnalyticsEvent, isFromCurrentDomain, nodesBetweenChanged, processRawValue } from '@atlaskit/editor-common/utils';
10
10
  import { closeHistory } from '@atlaskit/editor-prosemirror/history';
11
11
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
12
12
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
13
13
  import { appearanceForNodeType, isDatasourceConfigEditable, isDatasourceNode, selectedCardAppearance } from '../utils';
14
- import { hideDatasourceModal, queueCards, removeDatasourceStash, resolveCard, setDatasourceStash } from './actions';
14
+ import { hideDatasourceModal, queueCards, removeDatasourceStash, resolveCard, setDatasourceStash, showDatasourceModal } from './actions';
15
15
  import { pluginKey } from './plugin-key';
16
16
  import { shouldReplaceLink } from './shouldReplaceLink';
17
17
  /**
@@ -560,4 +560,24 @@ var updateDatasourceStash = function updateDatasourceStash(tr, selectedNode) {
560
560
  }
561
561
  }
562
562
  }
563
+ };
564
+ export var editDatasource = function editDatasource(datasourceId, _editorAnalyticsApi) {
565
+ return function (state, dispatch) {
566
+ var datasourceType = getDatasourceType(datasourceId);
567
+ if (dispatch && datasourceType) {
568
+ var tr = state.tr;
569
+ showDatasourceModal(datasourceType)(tr);
570
+ // editorAnalyticsApi?.attachAnalyticsEvent(
571
+ // buildEditLinkPayload(
572
+ // type as
573
+ // | ACTION_SUBJECT_ID.CARD_INLINE
574
+ // | ACTION_SUBJECT_ID.CARD_BLOCK
575
+ // | ACTION_SUBJECT_ID.EMBEDS,
576
+ // ),
577
+ // )(tr);
578
+ dispatch(tr);
579
+ return true;
580
+ }
581
+ return false;
582
+ };
563
583
  };
@@ -18,14 +18,15 @@ import CogIcon from '@atlaskit/icon/glyph/editor/settings';
18
18
  import UnlinkIcon from '@atlaskit/icon/glyph/editor/unlink';
19
19
  import OpenIcon from '@atlaskit/icon/glyph/shortcut';
20
20
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
21
- import { changeSelectedCardToText } from './pm-plugins/doc';
21
+ import { changeSelectedCardToText, editDatasource } from './pm-plugins/doc';
22
22
  import { pluginKey } from './pm-plugins/main';
23
23
  import { DatasourceAppearanceButton } from './ui/DatasourceAppearanceButton';
24
- import { editDatasource, EditDatasourceButton } from './ui/EditDatasourceButton';
24
+ import { EditDatasourceButton } from './ui/EditDatasourceButton';
25
25
  import { buildEditLinkToolbar, editLink, editLinkToolbarConfig } from './ui/EditLinkToolbar';
26
+ import { EditToolbarButton } from './ui/EditToolbarButton';
26
27
  import { LinkToolbarAppearance } from './ui/LinkToolbarAppearance';
27
28
  import { ToolbarViewedEvent } from './ui/ToolbarViewedEvent';
28
- import { appearanceForNodeType, displayInfoForCard, findCardInfo, isDatasourceConfigEditable, isDatasourceNode, titleUrlPairFromNode } from './utils';
29
+ import { appearanceForNodeType, displayInfoForCard, findCardInfo, isDatasourceConfigEditable, isDatasourceNode, isEditDropdownEnabled, titleUrlPairFromNode } from './utils';
29
30
  export var removeCard = function removeCard(editorAnalyticsApi) {
30
31
  return commandWithMetadata(function (state, dispatch) {
31
32
  if (!(state.selection instanceof NodeSelection)) {
@@ -215,7 +216,20 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
215
216
  return getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, node.attrs.datasource.id, state, cardOptions, currentAppearance, platform, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.card) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions);
216
217
  } else {
217
218
  var inlineCard = state.schema.nodes.inlineCard;
218
- var toolbarItems = [{
219
+ var toolbarItems = [isEditDropdownEnabled(platform) && cardOptions.allowDatasource ? {
220
+ type: 'custom',
221
+ fallback: [],
222
+ render: function render(editorView) {
223
+ return /*#__PURE__*/React.createElement(EditToolbarButton, {
224
+ key: "edit-toolbar-item",
225
+ url: url,
226
+ intl: intl,
227
+ editorAnalyticsApi: editorAnalyticsApi,
228
+ editorView: editorView,
229
+ onLinkEditClick: editLink(editorAnalyticsApi)
230
+ });
231
+ }
232
+ } : {
219
233
  id: 'editor.link.edit',
220
234
  type: 'button',
221
235
  selected: false,
@@ -314,7 +328,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
314
328
  type: 'separator'
315
329
  }]));
316
330
  }
317
- var shouldShowDatasourceEditButton = platform !== 'mobile' && allowDatasource;
331
+ var shouldShowDatasourceEditButton = platform !== 'mobile' && allowDatasource && !getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar');
318
332
  if (shouldShowDatasourceEditButton) {
319
333
  toolbarItems.unshift({
320
334
  type: 'custom',
@@ -374,7 +388,7 @@ export var getSettingsButtonGroup = function getSettingsButtonGroup(intl, editor
374
388
  var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state, cardOptions, currentAppearance, platform, cardActions) {
375
389
  var _node$attrs3;
376
390
  var toolbarItems = [];
377
- if (isDatasourceConfigEditable(datasourceId)) {
391
+ if (isDatasourceConfigEditable(datasourceId) && !getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar')) {
378
392
  toolbarItems.push({
379
393
  id: 'editor.edit.datasource',
380
394
  type: 'button',
@@ -388,6 +402,22 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
388
402
  type: 'separator'
389
403
  });
390
404
  }
405
+ var editDropdownWithSeparator = [{
406
+ type: 'custom',
407
+ fallback: [],
408
+ render: function render(editorView) {
409
+ return /*#__PURE__*/React.createElement(EditToolbarButton, {
410
+ key: "edit-toolbar-item",
411
+ url: metadata.url,
412
+ intl: intl,
413
+ editorAnalyticsApi: editorAnalyticsApi,
414
+ editorView: editorView,
415
+ onLinkEditClick: editLink(editorAnalyticsApi)
416
+ });
417
+ }
418
+ }, {
419
+ type: 'separator'
420
+ }];
391
421
  var canShowMainToolbar = function canShowMainToolbar() {
392
422
  // we do not show smart-link or the datasource icons when the node does not have a url to resolve
393
423
  if (!metadata.url) {
@@ -407,7 +437,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
407
437
  allowEmbeds = cardOptions.allowEmbeds,
408
438
  showUpgradeDiscoverability = cardOptions.showUpgradeDiscoverability;
409
439
  var url = metadata.url;
410
- toolbarItems.push({
440
+ toolbarItems.push.apply(toolbarItems, [{
411
441
  type: 'custom',
412
442
  fallback: [],
413
443
  render: function render(editorView) {
@@ -443,7 +473,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
443
473
  }
444
474
  }, {
445
475
  type: 'separator'
446
- });
476
+ }].concat(_toConsumableArray(getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar') ? [].concat(editDropdownWithSeparator) : [])));
447
477
  }
448
478
  if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
449
479
  toolbarItems.push({
@@ -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 {