@atlaskit/editor-plugin-card 2.0.2 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 2.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#108600](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/108600)
8
+ [`ab0ef9cd9d368`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ab0ef9cd9d368) -
9
+ [ux] Fixed the toolbar edit button in the new dropdown button for assets.
10
+ - Updated dependencies
11
+
12
+ ## 2.0.3
13
+
14
+ ### Patch Changes
15
+
16
+ - [#108480](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/108480)
17
+ [`8552b1dc7f80d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8552b1dc7f80d) -
18
+ Creating new dropdown component for configuring links
19
+
3
20
  ## 2.0.2
4
21
 
5
22
  ### Patch Changes
@@ -226,7 +226,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
226
226
  } else {
227
227
  var inlineCard = state.schema.nodes.inlineCard;
228
228
  var isEditDropdownEnabled = (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.enable-datasource-edit-dropdown-toolbar') && platform !== 'mobile' && cardOptions.allowDatasource;
229
- var toolbarItems = [isEditDropdownEnabled ? {
229
+ var editItems = isEditDropdownEnabled ? [{
230
230
  type: 'custom',
231
231
  fallback: [],
232
232
  render: function render(editorView) {
@@ -239,7 +239,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
239
239
  onLinkEditClick: (0, _EditLinkToolbar.editLink)(editorAnalyticsApi)
240
240
  });
241
241
  }
242
- } : {
242
+ }] : [{
243
243
  id: 'editor.link.edit',
244
244
  type: 'button',
245
245
  selected: false,
@@ -250,7 +250,8 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
250
250
  onClick: (0, _EditLinkToolbar.editLink)(editorAnalyticsApi)
251
251
  }, {
252
252
  type: 'separator'
253
- }, {
253
+ }];
254
+ var toolbarItems = [].concat(editItems, [{
254
255
  id: 'editor.link.openLink',
255
256
  type: 'button',
256
257
  icon: _shortcut.default,
@@ -260,7 +261,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
260
261
  onClick: visitCardLink(editorAnalyticsApi)
261
262
  }, {
262
263
  type: 'separator'
263
- }].concat((0, _toConsumableArray2.default)(getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi)), [{
264
+ }], (0, _toConsumableArray2.default)(getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi)), [{
264
265
  type: 'copy-button',
265
266
  supportsViewMode: true,
266
267
  items: [{
@@ -410,23 +411,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
410
411
  type: 'separator'
411
412
  });
412
413
  }
413
- var editDropdownWithSeparator = [{
414
- type: 'custom',
415
- fallback: [],
416
- render: function render(editorView) {
417
- return /*#__PURE__*/_react.default.createElement(_EditToolbarButton.EditToolbarButton, {
418
- key: "edit-toolbar-item",
419
- url: metadata.url,
420
- intl: intl,
421
- editorAnalyticsApi: editorAnalyticsApi,
422
- editorView: editorView,
423
- onLinkEditClick: (0, _EditLinkToolbar.editLink)(editorAnalyticsApi)
424
- });
425
- }
426
- }, {
427
- type: 'separator'
428
- }];
429
- var canShowMainToolbar = function canShowMainToolbar() {
414
+ var canShowAppearanceSwitch = function canShowAppearanceSwitch() {
430
415
  // we do not show smart-link or the datasource icons when the node does not have a url to resolve
431
416
  if (!metadata.url) {
432
417
  return false;
@@ -440,12 +425,12 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
440
425
  // FF to enable additional toolbar buttons based on if the datasource is configurable or not
441
426
  return (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.datasource-enable-toolbar-buttons-for-all-datasources') ? true : !(0, _utils3.isDatasourceConfigEditable)(datasourceId);
442
427
  };
443
- if (canShowMainToolbar()) {
428
+ if (canShowAppearanceSwitch()) {
444
429
  var allowBlockCards = cardOptions.allowBlockCards,
445
430
  allowEmbeds = cardOptions.allowEmbeds,
446
431
  showUpgradeDiscoverability = cardOptions.showUpgradeDiscoverability;
447
432
  var url = metadata.url;
448
- toolbarItems.push.apply(toolbarItems, [{
433
+ toolbarItems.push({
449
434
  type: 'custom',
450
435
  fallback: [],
451
436
  render: function render(editorView) {
@@ -480,7 +465,24 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
480
465
  }
481
466
  }, {
482
467
  type: 'separator'
483
- }].concat((0, _toConsumableArray2.default)((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.enable-datasource-edit-dropdown-toolbar') ? [].concat(editDropdownWithSeparator) : [])));
468
+ });
469
+ }
470
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.enable-datasource-edit-dropdown-toolbar')) {
471
+ toolbarItems.push({
472
+ type: 'custom',
473
+ fallback: [],
474
+ render: function render(editorView) {
475
+ return /*#__PURE__*/_react.default.createElement(_EditToolbarButton.EditToolbarButton, {
476
+ datasourceId: datasourceId,
477
+ key: "edit-toolbar-item",
478
+ url: metadata.url,
479
+ intl: intl,
480
+ editorAnalyticsApi: editorAnalyticsApi,
481
+ editorView: editorView,
482
+ onLinkEditClick: (0, _EditLinkToolbar.editLink)(editorAnalyticsApi)
483
+ });
484
+ }
485
+ });
484
486
  }
485
487
  if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
486
488
  toolbarItems.push({
@@ -24,19 +24,20 @@ var _useFetchDatasourceInfo = require("./useFetchDatasourceInfo");
24
24
  var dropdownExpandContainer = (0, _react2.css)({
25
25
  margin: "0px ".concat("var(--ds-space-negative-050, -4px)")
26
26
  });
27
- var EditButtonWithCardContext = function EditButtonWithCardContext(_ref) {
28
- var cardContext = _ref.cardContext,
29
- intl = _ref.intl,
30
- editorAnalyticsApi = _ref.editorAnalyticsApi,
31
- url = _ref.url,
32
- editorView = _ref.editorView,
33
- onLinkEditClick = _ref.onLinkEditClick;
34
- var _useFetchDatasourceIn = (0, _useFetchDatasourceInfo.useFetchDatasourceInfo)({
35
- isRegularCardNode: true,
36
- url: url,
37
- cardContext: cardContext
38
- }),
39
- datasourceId = _useFetchDatasourceIn.datasourceId;
27
+ var EditToolbarButtonWithCardContext = function EditToolbarButtonWithCardContext(props) {
28
+ var _response$datasourceI;
29
+ var url = props.url,
30
+ cardContext = props.cardContext,
31
+ intl = props.intl,
32
+ editorAnalyticsApi = props.editorAnalyticsApi,
33
+ editorView = props.editorView,
34
+ onLinkEditClick = props.onLinkEditClick;
35
+ var response = (0, _useFetchDatasourceInfo.useFetchDatasourceInfo)({
36
+ isRegularCardNode: true,
37
+ url: url,
38
+ cardContext: cardContext
39
+ });
40
+ var datasourceId = (_response$datasourceI = response.datasourceId) !== null && _response$datasourceI !== void 0 ? _response$datasourceI : props.datasourceId;
40
41
  var _useState = (0, _react.useState)(false),
41
42
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
42
43
  isOpen = _useState2[0],
@@ -61,73 +62,104 @@ var EditButtonWithCardContext = function EditButtonWithCardContext(_ref) {
61
62
  var onEditLink = (0, _react.useCallback)(function () {
62
63
  dispatchCommand(onLinkEditClick);
63
64
  }, [dispatchCommand, onLinkEditClick]);
64
- var shouldFallbackToEditButton = (0, _react.useMemo)(function () {
65
+ var editVariant = (0, _react.useMemo)(function () {
66
+ var hasUrl = url !== null && url !== undefined;
65
67
  if (!datasourceId || !(0, _utils.isDatasourceConfigEditable)(datasourceId)) {
66
- return true;
68
+ if (hasUrl) {
69
+ return 'edit-link';
70
+ }
71
+ return 'none';
67
72
  }
68
- if (url) {
73
+ if (hasUrl) {
69
74
  var _cardContext$store, _urlState$error;
70
75
  var urlState = cardContext === null || cardContext === void 0 || (_cardContext$store = cardContext.store) === null || _cardContext$store === void 0 ? void 0 : _cardContext$store.getState()[url];
71
76
  if ((urlState === null || urlState === void 0 || (_urlState$error = urlState.error) === null || _urlState$error === void 0 ? void 0 : _urlState$error.kind) === 'fatal') {
72
- return true;
77
+ return 'edit-link';
73
78
  }
79
+ return 'edit-dropdown';
80
+ } else {
81
+ return 'edit-datasource';
74
82
  }
75
- return false;
76
83
  }, [cardContext === null || cardContext === void 0 ? void 0 : cardContext.store, datasourceId, url]);
77
84
  var onEditDatasource = (0, _react.useCallback)(function () {
78
85
  if (datasourceId) {
79
86
  dispatchCommand((0, _doc.editDatasource)(datasourceId, editorAnalyticsApi));
80
87
  }
81
88
  }, [dispatchCommand, datasourceId, editorAnalyticsApi]);
82
- if (shouldFallbackToEditButton) {
83
- return (0, _react2.jsx)(_ui.FloatingToolbarButton, {
84
- testId: "edit-link",
85
- onClick: onEditLink
86
- }, (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.linkToolbarMessages.editLink));
89
+ switch (editVariant) {
90
+ case 'edit-link':
91
+ {
92
+ return (0, _react2.jsx)(_primitives.Flex, {
93
+ gap: "space.050"
94
+ }, (0, _react2.jsx)(_ui.FloatingToolbarButton, {
95
+ testId: "edit-link",
96
+ onClick: onEditLink
97
+ }, (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.linkToolbarMessages.editLink)), (0, _react2.jsx)(_ui.FloatingToolbarSeparator, null));
98
+ }
99
+ case 'edit-datasource':
100
+ {
101
+ return (0, _react2.jsx)(_primitives.Flex, {
102
+ gap: "space.050"
103
+ }, (0, _react2.jsx)(_ui.FloatingToolbarButton, {
104
+ testId: "edit-datasource",
105
+ tooltipContent: intl.formatMessage(_messages.linkToolbarMessages.editDatasourceStandaloneTooltip),
106
+ onClick: onEditDatasource
107
+ }, (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.linkToolbarMessages.editDatasourceStandalone)), (0, _react2.jsx)(_ui.FloatingToolbarSeparator, null));
108
+ }
109
+ case 'edit-dropdown':
110
+ {
111
+ var trigger = (0, _react2.jsx)(_primitives.Flex, {
112
+ gap: "space.050"
113
+ }, (0, _react2.jsx)(_ui.FloatingToolbarButton, {
114
+ testId: "edit-dropdown-trigger",
115
+ iconAfter: (0, _react2.jsx)("span", {
116
+ css: dropdownExpandContainer
117
+ }, (0, _react2.jsx)(_chevronDown.default, {
118
+ label: intl.formatMessage(_messages.cardMessages.editDropdownTriggerTitle)
119
+ })),
120
+ onClick: toggleOpen,
121
+ selected: isOpen,
122
+ disabled: false,
123
+ ariaHasPopup: true
124
+ }, (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.cardMessages.editDropdownTriggerTitle)), (0, _react2.jsx)(_ui.FloatingToolbarSeparator, null));
125
+ return (0, _react2.jsx)(_primitives.Flex, {
126
+ ref: containerRef
127
+ }, (0, _react2.jsx)(_uiMenu.DropdownContainer, {
128
+ mountTo: containerRef.current,
129
+ isOpen: isOpen,
130
+ handleClickOutside: onClose,
131
+ handleEscapeKeydown: onClose,
132
+ trigger: trigger,
133
+ scrollableElement: containerRef.current,
134
+ arrowKeyNavigationProviderOptions: {
135
+ type: _uiMenu.ArrowKeyNavigationType.MENU
136
+ }
137
+ }, (0, _react2.jsx)(_menu.ButtonItem, {
138
+ key: "edit.link",
139
+ onClick: onEditLink,
140
+ testId: "edit-dropdown-edit-link-item"
141
+ }, (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.cardMessages.editDropdownEditLinkTitle)), (0, _react2.jsx)(_menu.ButtonItem, {
142
+ key: "edit.datasource",
143
+ onClick: onEditDatasource,
144
+ testId: "edit-dropdown-edit-datasource-item"
145
+ }, (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.cardMessages.editDropdownEditDatasourceTitle))));
146
+ }
147
+ case 'none':
148
+ default:
149
+ return null;
87
150
  }
88
- var trigger = (0, _react2.jsx)(_ui.FloatingToolbarButton, {
89
- testId: "edit-dropdown-trigger",
90
- iconAfter: (0, _react2.jsx)("span", {
91
- css: dropdownExpandContainer
92
- }, (0, _react2.jsx)(_chevronDown.default, {
93
- label: intl.formatMessage(_messages.cardMessages.editDropdownTriggerTitle)
94
- })),
95
- onClick: toggleOpen,
96
- selected: isOpen,
97
- disabled: false,
98
- ariaHasPopup: true
99
- }, (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.cardMessages.editDropdownTriggerTitle));
100
- return (0, _react2.jsx)(_primitives.Flex, {
101
- ref: containerRef
102
- }, (0, _react2.jsx)(_uiMenu.DropdownContainer, {
103
- mountTo: containerRef.current,
104
- isOpen: isOpen,
105
- handleClickOutside: onClose,
106
- handleEscapeKeydown: onClose,
107
- trigger: trigger,
108
- scrollableElement: containerRef.current,
109
- arrowKeyNavigationProviderOptions: {
110
- type: _uiMenu.ArrowKeyNavigationType.MENU
111
- }
112
- }, (0, _react2.jsx)(_menu.ButtonItem, {
113
- key: "edit.link",
114
- onClick: onEditLink,
115
- testId: "edit-dropdown-edit-link-item"
116
- }, (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.cardMessages.editDropdownEditLinkTitle)), (0, _react2.jsx)(_menu.ButtonItem, {
117
- key: "edit.datasource",
118
- onClick: onEditDatasource,
119
- testId: "edit-dropdown-edit-datasource-item"
120
- }, (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.cardMessages.editDropdownEditDatasourceTitle))));
121
151
  };
122
- var EditToolbarButton = exports.EditToolbarButton = function EditToolbarButton(_ref2) {
123
- var intl = _ref2.intl,
124
- editorAnalyticsApi = _ref2.editorAnalyticsApi,
125
- url = _ref2.url,
126
- editorView = _ref2.editorView,
127
- onLinkEditClick = _ref2.onLinkEditClick;
128
- return (0, _react2.jsx)(_CardContextProvider.CardContextProvider, null, function (_ref3) {
129
- var cardContext = _ref3.cardContext;
130
- return (0, _react2.jsx)(EditButtonWithCardContext, {
152
+ var EditToolbarButton = exports.EditToolbarButton = function EditToolbarButton(props) {
153
+ var datasourceId = props.datasourceId,
154
+ intl = props.intl,
155
+ editorAnalyticsApi = props.editorAnalyticsApi,
156
+ url = props.url,
157
+ editorView = props.editorView,
158
+ onLinkEditClick = props.onLinkEditClick;
159
+ return (0, _react2.jsx)(_CardContextProvider.CardContextProvider, null, function (_ref) {
160
+ var cardContext = _ref.cardContext;
161
+ return (0, _react2.jsx)(EditToolbarButtonWithCardContext, {
162
+ datasourceId: datasourceId,
131
163
  url: url,
132
164
  intl: intl,
133
165
  editorAnalyticsApi: editorAnalyticsApi,
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
+ var _react = _interopRequireDefault(require("react"));
12
+ var _reactIntlNext = require("react-intl-next");
13
+ var _new = _interopRequireDefault(require("@atlaskit/button/new"));
14
+ var _dropdownMenu = _interopRequireWildcard(require("@atlaskit/dropdown-menu"));
15
+ var _messages = require("@atlaskit/editor-common/messages");
16
+ var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/glyph/chevron-down"));
17
+ var _preferences = _interopRequireDefault(require("@atlaskit/icon/glyph/preferences"));
18
+ var _shortcut = _interopRequireDefault(require("@atlaskit/icon/glyph/shortcut"));
19
+ var _excluded = ["triggerRef"];
20
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
21
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
22
+ var ConfigureLinkDropdown = function ConfigureLinkDropdown(props) {
23
+ var testId = props.testId;
24
+ var intl = (0, _reactIntlNext.useIntl)();
25
+ var configureLinkLabel = intl.formatMessage(_messages.cardMessages.inlineConfigureLink);
26
+ var goToLinkLabel = intl.formatMessage(_messages.cardMessages.inlineConfigureLink);
27
+ return /*#__PURE__*/_react.default.createElement(_dropdownMenu.default, {
28
+ trigger: function trigger(_ref) {
29
+ var triggerRef = _ref.triggerRef,
30
+ props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
31
+ return /*#__PURE__*/_react.default.createElement(_new.default, (0, _extends2.default)({}, props, {
32
+ spacing: "none",
33
+ ref: triggerRef
34
+ }), /*#__PURE__*/_react.default.createElement("span", {
35
+ style: {
36
+ padding: "0 ".concat("var(--ds-space-025, 2px)")
37
+ }
38
+ }, /*#__PURE__*/_react.default.createElement(_chevronDown.default, {
39
+ label: configureLinkLabel,
40
+ size: 'small',
41
+ testId: "".concat(testId, "-icon")
42
+ })));
43
+ },
44
+ spacing: "compact",
45
+ placement: "bottom-start"
46
+ }, /*#__PURE__*/_react.default.createElement(_dropdownMenu.DropdownItemGroup, null, /*#__PURE__*/_react.default.createElement(_dropdownMenu.DropdownItem, {
47
+ elemBefore: /*#__PURE__*/_react.default.createElement(_shortcut.default, {
48
+ label: goToLinkLabel,
49
+ size: "small"
50
+ })
51
+ }, goToLinkLabel), /*#__PURE__*/_react.default.createElement(_dropdownMenu.DropdownItem, {
52
+ elemBefore: /*#__PURE__*/_react.default.createElement(_preferences.default, {
53
+ label: configureLinkLabel,
54
+ size: "small"
55
+ })
56
+ }, configureLinkLabel)));
57
+ };
58
+ var _default = exports.default = ConfigureLinkDropdown;
@@ -220,7 +220,7 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
220
220
  inlineCard
221
221
  } = state.schema.nodes;
222
222
  const isEditDropdownEnabled = getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar') && platform !== 'mobile' && cardOptions.allowDatasource;
223
- const toolbarItems = [isEditDropdownEnabled ? {
223
+ const editItems = isEditDropdownEnabled ? [{
224
224
  type: 'custom',
225
225
  fallback: [],
226
226
  render: editorView => /*#__PURE__*/React.createElement(EditToolbarButton, {
@@ -231,7 +231,7 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
231
231
  editorView: editorView,
232
232
  onLinkEditClick: editLink(editorAnalyticsApi)
233
233
  })
234
- } : {
234
+ }] : [{
235
235
  id: 'editor.link.edit',
236
236
  type: 'button',
237
237
  selected: false,
@@ -242,7 +242,8 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
242
242
  onClick: editLink(editorAnalyticsApi)
243
243
  }, {
244
244
  type: 'separator'
245
- }, {
245
+ }];
246
+ const toolbarItems = [...editItems, {
246
247
  id: 'editor.link.openLink',
247
248
  type: 'button',
248
249
  icon: OpenIcon,
@@ -397,21 +398,7 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
397
398
  type: 'separator'
398
399
  });
399
400
  }
400
- const editDropdownWithSeparator = [{
401
- type: 'custom',
402
- fallback: [],
403
- render: editorView => /*#__PURE__*/React.createElement(EditToolbarButton, {
404
- key: "edit-toolbar-item",
405
- url: metadata.url,
406
- intl: intl,
407
- editorAnalyticsApi: editorAnalyticsApi,
408
- editorView: editorView,
409
- onLinkEditClick: editLink(editorAnalyticsApi)
410
- })
411
- }, {
412
- type: 'separator'
413
- }];
414
- const canShowMainToolbar = () => {
401
+ const canShowAppearanceSwitch = () => {
415
402
  // we do not show smart-link or the datasource icons when the node does not have a url to resolve
416
403
  if (!metadata.url) {
417
404
  return false;
@@ -425,7 +412,7 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
425
412
  // FF to enable additional toolbar buttons based on if the datasource is configurable or not
426
413
  return getBooleanFF('platform.linking-platform.datasource-enable-toolbar-buttons-for-all-datasources') ? true : !isDatasourceConfigEditable(datasourceId);
427
414
  };
428
- if (canShowMainToolbar()) {
415
+ if (canShowAppearanceSwitch()) {
429
416
  const {
430
417
  allowBlockCards,
431
418
  allowEmbeds,
@@ -467,7 +454,22 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
467
454
  })
468
455
  }, {
469
456
  type: 'separator'
470
- }, ...(getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar') ? [...editDropdownWithSeparator] : []));
457
+ });
458
+ }
459
+ if (getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar')) {
460
+ toolbarItems.push({
461
+ type: 'custom',
462
+ fallback: [],
463
+ render: editorView => /*#__PURE__*/React.createElement(EditToolbarButton, {
464
+ datasourceId: datasourceId,
465
+ key: "edit-toolbar-item",
466
+ url: metadata.url,
467
+ intl: intl,
468
+ editorAnalyticsApi: editorAnalyticsApi,
469
+ editorView: editorView,
470
+ onLinkEditClick: editLink(editorAnalyticsApi)
471
+ })
472
+ });
471
473
  }
472
474
  if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
473
475
  toolbarItems.push({
@@ -3,7 +3,7 @@ import { useCallback, useMemo, useRef, useState } from 'react';
3
3
  import { css, jsx } from '@emotion/react';
4
4
  import { FormattedMessage } from 'react-intl-next';
5
5
  import { linkToolbarMessages, cardMessages as messages } from '@atlaskit/editor-common/messages';
6
- import { FloatingToolbarButton as Button } from '@atlaskit/editor-common/ui';
6
+ import { FloatingToolbarButton as Button, FloatingToolbarSeparator as Separator } from '@atlaskit/editor-common/ui';
7
7
  import { ArrowKeyNavigationType, DropdownContainer as UiDropdown } from '@atlaskit/editor-common/ui-menu';
8
8
  import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
9
9
  import { ButtonItem } from '@atlaskit/menu';
@@ -15,21 +15,22 @@ import { useFetchDatasourceInfo } from './useFetchDatasourceInfo';
15
15
  const dropdownExpandContainer = css({
16
16
  margin: `0px ${"var(--ds-space-negative-050, -4px)"}`
17
17
  });
18
- const EditButtonWithCardContext = ({
19
- cardContext,
20
- intl,
21
- editorAnalyticsApi,
22
- url,
23
- editorView,
24
- onLinkEditClick
25
- }) => {
18
+ const EditToolbarButtonWithCardContext = props => {
19
+ var _response$datasourceI;
26
20
  const {
27
- datasourceId
28
- } = useFetchDatasourceInfo({
21
+ url,
22
+ cardContext,
23
+ intl,
24
+ editorAnalyticsApi,
25
+ editorView,
26
+ onLinkEditClick
27
+ } = props;
28
+ const response = useFetchDatasourceInfo({
29
29
  isRegularCardNode: true,
30
30
  url,
31
31
  cardContext
32
32
  });
33
+ const datasourceId = (_response$datasourceI = response.datasourceId) !== null && _response$datasourceI !== void 0 ? _response$datasourceI : props.datasourceId;
33
34
  const [isOpen, setIsOpen] = useState(false);
34
35
  const containerRef = useRef();
35
36
  const toggleOpen = () => setIsOpen(open => !open);
@@ -45,74 +46,106 @@ const EditButtonWithCardContext = ({
45
46
  const onEditLink = useCallback(() => {
46
47
  dispatchCommand(onLinkEditClick);
47
48
  }, [dispatchCommand, onLinkEditClick]);
48
- const shouldFallbackToEditButton = useMemo(() => {
49
+ const editVariant = useMemo(() => {
50
+ const hasUrl = url !== null && url !== undefined;
49
51
  if (!datasourceId || !isDatasourceConfigEditable(datasourceId)) {
50
- return true;
52
+ if (hasUrl) {
53
+ return 'edit-link';
54
+ }
55
+ return 'none';
51
56
  }
52
- if (url) {
57
+ if (hasUrl) {
53
58
  var _cardContext$store, _urlState$error;
54
59
  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
60
  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;
61
+ return 'edit-link';
57
62
  }
63
+ return 'edit-dropdown';
64
+ } else {
65
+ return 'edit-datasource';
58
66
  }
59
- return false;
60
67
  }, [cardContext === null || cardContext === void 0 ? void 0 : cardContext.store, datasourceId, url]);
61
68
  const onEditDatasource = useCallback(() => {
62
69
  if (datasourceId) {
63
70
  dispatchCommand(editDatasource(datasourceId, editorAnalyticsApi));
64
71
  }
65
72
  }, [dispatchCommand, datasourceId, editorAnalyticsApi]);
66
- if (shouldFallbackToEditButton) {
67
- return jsx(Button, {
68
- testId: "edit-link",
69
- onClick: onEditLink
70
- }, jsx(FormattedMessage, linkToolbarMessages.editLink));
73
+ switch (editVariant) {
74
+ case 'edit-link':
75
+ {
76
+ return jsx(Flex, {
77
+ gap: "space.050"
78
+ }, jsx(Button, {
79
+ testId: "edit-link",
80
+ onClick: onEditLink
81
+ }, jsx(FormattedMessage, linkToolbarMessages.editLink)), jsx(Separator, null));
82
+ }
83
+ case 'edit-datasource':
84
+ {
85
+ return jsx(Flex, {
86
+ gap: "space.050"
87
+ }, jsx(Button, {
88
+ testId: "edit-datasource",
89
+ tooltipContent: intl.formatMessage(linkToolbarMessages.editDatasourceStandaloneTooltip),
90
+ onClick: onEditDatasource
91
+ }, jsx(FormattedMessage, linkToolbarMessages.editDatasourceStandalone)), jsx(Separator, null));
92
+ }
93
+ case 'edit-dropdown':
94
+ {
95
+ const trigger = jsx(Flex, {
96
+ gap: "space.050"
97
+ }, jsx(Button, {
98
+ testId: "edit-dropdown-trigger",
99
+ iconAfter: jsx("span", {
100
+ css: dropdownExpandContainer
101
+ }, jsx(ExpandIcon, {
102
+ label: intl.formatMessage(messages.editDropdownTriggerTitle)
103
+ })),
104
+ onClick: toggleOpen,
105
+ selected: isOpen,
106
+ disabled: false,
107
+ ariaHasPopup: true
108
+ }, jsx(FormattedMessage, messages.editDropdownTriggerTitle)), jsx(Separator, null));
109
+ return jsx(Flex, {
110
+ ref: containerRef
111
+ }, jsx(UiDropdown, {
112
+ mountTo: containerRef.current,
113
+ isOpen: isOpen,
114
+ handleClickOutside: onClose,
115
+ handleEscapeKeydown: onClose,
116
+ trigger: trigger,
117
+ scrollableElement: containerRef.current,
118
+ arrowKeyNavigationProviderOptions: {
119
+ type: ArrowKeyNavigationType.MENU
120
+ }
121
+ }, jsx(ButtonItem, {
122
+ key: "edit.link",
123
+ onClick: onEditLink,
124
+ testId: "edit-dropdown-edit-link-item"
125
+ }, jsx(FormattedMessage, messages.editDropdownEditLinkTitle)), jsx(ButtonItem, {
126
+ key: "edit.datasource",
127
+ onClick: onEditDatasource,
128
+ testId: "edit-dropdown-edit-datasource-item"
129
+ }, jsx(FormattedMessage, messages.editDropdownEditDatasourceTitle))));
130
+ }
131
+ case 'none':
132
+ default:
133
+ return null;
71
134
  }
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
135
  };
106
- export const EditToolbarButton = ({
107
- intl,
108
- editorAnalyticsApi,
109
- url,
110
- editorView,
111
- onLinkEditClick
112
- }) => {
136
+ export const EditToolbarButton = props => {
137
+ const {
138
+ datasourceId,
139
+ intl,
140
+ editorAnalyticsApi,
141
+ url,
142
+ editorView,
143
+ onLinkEditClick
144
+ } = props;
113
145
  return jsx(CardContextProvider, null, ({
114
146
  cardContext
115
- }) => jsx(EditButtonWithCardContext, {
147
+ }) => jsx(EditToolbarButtonWithCardContext, {
148
+ datasourceId: datasourceId,
116
149
  url: url,
117
150
  intl: intl,
118
151
  editorAnalyticsApi: editorAnalyticsApi,
@@ -0,0 +1,47 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import { useIntl } from "react-intl-next";
4
+ import Button from "@atlaskit/button/new";
5
+ import DropdownMenu, { DropdownItem, DropdownItemGroup } from "@atlaskit/dropdown-menu";
6
+ import { cardMessages as messages } from "@atlaskit/editor-common/messages";
7
+ import ChevronDownIcon from "@atlaskit/icon/glyph/chevron-down";
8
+ import PreferencesIcon from "@atlaskit/icon/glyph/preferences";
9
+ import ShortcutIcon from "@atlaskit/icon/glyph/shortcut";
10
+ const ConfigureLinkDropdown = props => {
11
+ const {
12
+ testId
13
+ } = props;
14
+ const intl = useIntl();
15
+ const configureLinkLabel = intl.formatMessage(messages.inlineConfigureLink);
16
+ const goToLinkLabel = intl.formatMessage(messages.inlineConfigureLink);
17
+ return /*#__PURE__*/React.createElement(DropdownMenu, {
18
+ trigger: ({
19
+ triggerRef,
20
+ ...props
21
+ }) => /*#__PURE__*/React.createElement(Button, _extends({}, props, {
22
+ spacing: "none",
23
+ ref: triggerRef
24
+ }), /*#__PURE__*/React.createElement("span", {
25
+ style: {
26
+ padding: `0 ${"var(--ds-space-025, 2px)"}`
27
+ }
28
+ }, /*#__PURE__*/React.createElement(ChevronDownIcon, {
29
+ label: configureLinkLabel,
30
+ size: 'small',
31
+ testId: `${testId}-icon`
32
+ }))),
33
+ spacing: "compact",
34
+ placement: "bottom-start"
35
+ }, /*#__PURE__*/React.createElement(DropdownItemGroup, null, /*#__PURE__*/React.createElement(DropdownItem, {
36
+ elemBefore: /*#__PURE__*/React.createElement(ShortcutIcon, {
37
+ label: goToLinkLabel,
38
+ size: "small"
39
+ })
40
+ }, goToLinkLabel), /*#__PURE__*/React.createElement(DropdownItem, {
41
+ elemBefore: /*#__PURE__*/React.createElement(PreferencesIcon, {
42
+ label: configureLinkLabel,
43
+ size: "small"
44
+ })
45
+ }, configureLinkLabel)));
46
+ };
47
+ export default ConfigureLinkDropdown;
@@ -216,7 +216,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
216
216
  } else {
217
217
  var inlineCard = state.schema.nodes.inlineCard;
218
218
  var isEditDropdownEnabled = getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar') && platform !== 'mobile' && cardOptions.allowDatasource;
219
- var toolbarItems = [isEditDropdownEnabled ? {
219
+ var editItems = isEditDropdownEnabled ? [{
220
220
  type: 'custom',
221
221
  fallback: [],
222
222
  render: function render(editorView) {
@@ -229,7 +229,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
229
229
  onLinkEditClick: editLink(editorAnalyticsApi)
230
230
  });
231
231
  }
232
- } : {
232
+ }] : [{
233
233
  id: 'editor.link.edit',
234
234
  type: 'button',
235
235
  selected: false,
@@ -240,7 +240,8 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
240
240
  onClick: editLink(editorAnalyticsApi)
241
241
  }, {
242
242
  type: 'separator'
243
- }, {
243
+ }];
244
+ var toolbarItems = [].concat(editItems, [{
244
245
  id: 'editor.link.openLink',
245
246
  type: 'button',
246
247
  icon: OpenIcon,
@@ -250,7 +251,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
250
251
  onClick: visitCardLink(editorAnalyticsApi)
251
252
  }, {
252
253
  type: 'separator'
253
- }].concat(_toConsumableArray(getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi)), [{
254
+ }], _toConsumableArray(getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi)), [{
254
255
  type: 'copy-button',
255
256
  supportsViewMode: true,
256
257
  items: [{
@@ -400,23 +401,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
400
401
  type: 'separator'
401
402
  });
402
403
  }
403
- var editDropdownWithSeparator = [{
404
- type: 'custom',
405
- fallback: [],
406
- render: function render(editorView) {
407
- return /*#__PURE__*/React.createElement(EditToolbarButton, {
408
- key: "edit-toolbar-item",
409
- url: metadata.url,
410
- intl: intl,
411
- editorAnalyticsApi: editorAnalyticsApi,
412
- editorView: editorView,
413
- onLinkEditClick: editLink(editorAnalyticsApi)
414
- });
415
- }
416
- }, {
417
- type: 'separator'
418
- }];
419
- var canShowMainToolbar = function canShowMainToolbar() {
404
+ var canShowAppearanceSwitch = function canShowAppearanceSwitch() {
420
405
  // we do not show smart-link or the datasource icons when the node does not have a url to resolve
421
406
  if (!metadata.url) {
422
407
  return false;
@@ -430,12 +415,12 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
430
415
  // FF to enable additional toolbar buttons based on if the datasource is configurable or not
431
416
  return getBooleanFF('platform.linking-platform.datasource-enable-toolbar-buttons-for-all-datasources') ? true : !isDatasourceConfigEditable(datasourceId);
432
417
  };
433
- if (canShowMainToolbar()) {
418
+ if (canShowAppearanceSwitch()) {
434
419
  var allowBlockCards = cardOptions.allowBlockCards,
435
420
  allowEmbeds = cardOptions.allowEmbeds,
436
421
  showUpgradeDiscoverability = cardOptions.showUpgradeDiscoverability;
437
422
  var url = metadata.url;
438
- toolbarItems.push.apply(toolbarItems, [{
423
+ toolbarItems.push({
439
424
  type: 'custom',
440
425
  fallback: [],
441
426
  render: function render(editorView) {
@@ -470,7 +455,24 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
470
455
  }
471
456
  }, {
472
457
  type: 'separator'
473
- }].concat(_toConsumableArray(getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar') ? [].concat(editDropdownWithSeparator) : [])));
458
+ });
459
+ }
460
+ if (getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar')) {
461
+ toolbarItems.push({
462
+ type: 'custom',
463
+ fallback: [],
464
+ render: function render(editorView) {
465
+ return /*#__PURE__*/React.createElement(EditToolbarButton, {
466
+ datasourceId: datasourceId,
467
+ key: "edit-toolbar-item",
468
+ url: metadata.url,
469
+ intl: intl,
470
+ editorAnalyticsApi: editorAnalyticsApi,
471
+ editorView: editorView,
472
+ onLinkEditClick: editLink(editorAnalyticsApi)
473
+ });
474
+ }
475
+ });
474
476
  }
475
477
  if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
476
478
  toolbarItems.push({
@@ -4,7 +4,7 @@ import { useCallback, useMemo, useRef, useState } from 'react';
4
4
  import { css, jsx } from '@emotion/react';
5
5
  import { FormattedMessage } from 'react-intl-next';
6
6
  import { linkToolbarMessages, cardMessages as messages } from '@atlaskit/editor-common/messages';
7
- import { FloatingToolbarButton as Button } from '@atlaskit/editor-common/ui';
7
+ import { FloatingToolbarButton as Button, FloatingToolbarSeparator as Separator } from '@atlaskit/editor-common/ui';
8
8
  import { ArrowKeyNavigationType, DropdownContainer as UiDropdown } from '@atlaskit/editor-common/ui-menu';
9
9
  import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
10
10
  import { ButtonItem } from '@atlaskit/menu';
@@ -16,19 +16,20 @@ import { useFetchDatasourceInfo } from './useFetchDatasourceInfo';
16
16
  var dropdownExpandContainer = css({
17
17
  margin: "0px ".concat("var(--ds-space-negative-050, -4px)")
18
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;
19
+ var EditToolbarButtonWithCardContext = function EditToolbarButtonWithCardContext(props) {
20
+ var _response$datasourceI;
21
+ var url = props.url,
22
+ cardContext = props.cardContext,
23
+ intl = props.intl,
24
+ editorAnalyticsApi = props.editorAnalyticsApi,
25
+ editorView = props.editorView,
26
+ onLinkEditClick = props.onLinkEditClick;
27
+ var response = useFetchDatasourceInfo({
28
+ isRegularCardNode: true,
29
+ url: url,
30
+ cardContext: cardContext
31
+ });
32
+ var datasourceId = (_response$datasourceI = response.datasourceId) !== null && _response$datasourceI !== void 0 ? _response$datasourceI : props.datasourceId;
32
33
  var _useState = useState(false),
33
34
  _useState2 = _slicedToArray(_useState, 2),
34
35
  isOpen = _useState2[0],
@@ -53,73 +54,104 @@ var EditButtonWithCardContext = function EditButtonWithCardContext(_ref) {
53
54
  var onEditLink = useCallback(function () {
54
55
  dispatchCommand(onLinkEditClick);
55
56
  }, [dispatchCommand, onLinkEditClick]);
56
- var shouldFallbackToEditButton = useMemo(function () {
57
+ var editVariant = useMemo(function () {
58
+ var hasUrl = url !== null && url !== undefined;
57
59
  if (!datasourceId || !isDatasourceConfigEditable(datasourceId)) {
58
- return true;
60
+ if (hasUrl) {
61
+ return 'edit-link';
62
+ }
63
+ return 'none';
59
64
  }
60
- if (url) {
65
+ if (hasUrl) {
61
66
  var _cardContext$store, _urlState$error;
62
67
  var urlState = cardContext === null || cardContext === void 0 || (_cardContext$store = cardContext.store) === null || _cardContext$store === void 0 ? void 0 : _cardContext$store.getState()[url];
63
68
  if ((urlState === null || urlState === void 0 || (_urlState$error = urlState.error) === null || _urlState$error === void 0 ? void 0 : _urlState$error.kind) === 'fatal') {
64
- return true;
69
+ return 'edit-link';
65
70
  }
71
+ return 'edit-dropdown';
72
+ } else {
73
+ return 'edit-datasource';
66
74
  }
67
- return false;
68
75
  }, [cardContext === null || cardContext === void 0 ? void 0 : cardContext.store, datasourceId, url]);
69
76
  var onEditDatasource = useCallback(function () {
70
77
  if (datasourceId) {
71
78
  dispatchCommand(editDatasource(datasourceId, editorAnalyticsApi));
72
79
  }
73
80
  }, [dispatchCommand, datasourceId, editorAnalyticsApi]);
74
- if (shouldFallbackToEditButton) {
75
- return jsx(Button, {
76
- testId: "edit-link",
77
- onClick: onEditLink
78
- }, jsx(FormattedMessage, linkToolbarMessages.editLink));
81
+ switch (editVariant) {
82
+ case 'edit-link':
83
+ {
84
+ return jsx(Flex, {
85
+ gap: "space.050"
86
+ }, jsx(Button, {
87
+ testId: "edit-link",
88
+ onClick: onEditLink
89
+ }, jsx(FormattedMessage, linkToolbarMessages.editLink)), jsx(Separator, null));
90
+ }
91
+ case 'edit-datasource':
92
+ {
93
+ return jsx(Flex, {
94
+ gap: "space.050"
95
+ }, jsx(Button, {
96
+ testId: "edit-datasource",
97
+ tooltipContent: intl.formatMessage(linkToolbarMessages.editDatasourceStandaloneTooltip),
98
+ onClick: onEditDatasource
99
+ }, jsx(FormattedMessage, linkToolbarMessages.editDatasourceStandalone)), jsx(Separator, null));
100
+ }
101
+ case 'edit-dropdown':
102
+ {
103
+ var trigger = jsx(Flex, {
104
+ gap: "space.050"
105
+ }, jsx(Button, {
106
+ testId: "edit-dropdown-trigger",
107
+ iconAfter: jsx("span", {
108
+ css: dropdownExpandContainer
109
+ }, jsx(ExpandIcon, {
110
+ label: intl.formatMessage(messages.editDropdownTriggerTitle)
111
+ })),
112
+ onClick: toggleOpen,
113
+ selected: isOpen,
114
+ disabled: false,
115
+ ariaHasPopup: true
116
+ }, jsx(FormattedMessage, messages.editDropdownTriggerTitle)), jsx(Separator, null));
117
+ return jsx(Flex, {
118
+ ref: containerRef
119
+ }, jsx(UiDropdown, {
120
+ mountTo: containerRef.current,
121
+ isOpen: isOpen,
122
+ handleClickOutside: onClose,
123
+ handleEscapeKeydown: onClose,
124
+ trigger: trigger,
125
+ scrollableElement: containerRef.current,
126
+ arrowKeyNavigationProviderOptions: {
127
+ type: ArrowKeyNavigationType.MENU
128
+ }
129
+ }, jsx(ButtonItem, {
130
+ key: "edit.link",
131
+ onClick: onEditLink,
132
+ testId: "edit-dropdown-edit-link-item"
133
+ }, jsx(FormattedMessage, messages.editDropdownEditLinkTitle)), jsx(ButtonItem, {
134
+ key: "edit.datasource",
135
+ onClick: onEditDatasource,
136
+ testId: "edit-dropdown-edit-datasource-item"
137
+ }, jsx(FormattedMessage, messages.editDropdownEditDatasourceTitle))));
138
+ }
139
+ case 'none':
140
+ default:
141
+ return null;
79
142
  }
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
143
  };
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, {
144
+ export var EditToolbarButton = function EditToolbarButton(props) {
145
+ var datasourceId = props.datasourceId,
146
+ intl = props.intl,
147
+ editorAnalyticsApi = props.editorAnalyticsApi,
148
+ url = props.url,
149
+ editorView = props.editorView,
150
+ onLinkEditClick = props.onLinkEditClick;
151
+ return jsx(CardContextProvider, null, function (_ref) {
152
+ var cardContext = _ref.cardContext;
153
+ return jsx(EditToolbarButtonWithCardContext, {
154
+ datasourceId: datasourceId,
123
155
  url: url,
124
156
  intl: intl,
125
157
  editorAnalyticsApi: editorAnalyticsApi,
@@ -0,0 +1,48 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["triggerRef"];
4
+ import React from 'react';
5
+ import { useIntl } from "react-intl-next";
6
+ import Button from "@atlaskit/button/new";
7
+ import DropdownMenu, { DropdownItem, DropdownItemGroup } from "@atlaskit/dropdown-menu";
8
+ import { cardMessages as messages } from "@atlaskit/editor-common/messages";
9
+ import ChevronDownIcon from "@atlaskit/icon/glyph/chevron-down";
10
+ import PreferencesIcon from "@atlaskit/icon/glyph/preferences";
11
+ import ShortcutIcon from "@atlaskit/icon/glyph/shortcut";
12
+ var ConfigureLinkDropdown = function ConfigureLinkDropdown(props) {
13
+ var testId = props.testId;
14
+ var intl = useIntl();
15
+ var configureLinkLabel = intl.formatMessage(messages.inlineConfigureLink);
16
+ var goToLinkLabel = intl.formatMessage(messages.inlineConfigureLink);
17
+ return /*#__PURE__*/React.createElement(DropdownMenu, {
18
+ trigger: function trigger(_ref) {
19
+ var triggerRef = _ref.triggerRef,
20
+ props = _objectWithoutProperties(_ref, _excluded);
21
+ return /*#__PURE__*/React.createElement(Button, _extends({}, props, {
22
+ spacing: "none",
23
+ ref: triggerRef
24
+ }), /*#__PURE__*/React.createElement("span", {
25
+ style: {
26
+ padding: "0 ".concat("var(--ds-space-025, 2px)")
27
+ }
28
+ }, /*#__PURE__*/React.createElement(ChevronDownIcon, {
29
+ label: configureLinkLabel,
30
+ size: 'small',
31
+ testId: "".concat(testId, "-icon")
32
+ })));
33
+ },
34
+ spacing: "compact",
35
+ placement: "bottom-start"
36
+ }, /*#__PURE__*/React.createElement(DropdownItemGroup, null, /*#__PURE__*/React.createElement(DropdownItem, {
37
+ elemBefore: /*#__PURE__*/React.createElement(ShortcutIcon, {
38
+ label: goToLinkLabel,
39
+ size: "small"
40
+ })
41
+ }, goToLinkLabel), /*#__PURE__*/React.createElement(DropdownItem, {
42
+ elemBefore: /*#__PURE__*/React.createElement(PreferencesIcon, {
43
+ label: configureLinkLabel,
44
+ size: "small"
45
+ })
46
+ }, configureLinkLabel)));
47
+ };
48
+ export default ConfigureLinkDropdown;
@@ -4,7 +4,8 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
4
4
  import type { Command } from '@atlaskit/editor-common/types';
5
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
6
  import type { CardContext } from '@atlaskit/link-provider';
7
- export interface EditToolbarButtonProps {
7
+ export interface EditDatasourceToolbarButtonProps {
8
+ datasourceId?: string;
8
9
  intl: IntlShape;
9
10
  editorAnalyticsApi?: EditorAnalyticsAPI;
10
11
  url?: string;
@@ -12,4 +13,4 @@ export interface EditToolbarButtonProps {
12
13
  cardContext?: CardContext;
13
14
  onLinkEditClick: Command;
14
15
  }
15
- export declare const EditToolbarButton: ({ intl, editorAnalyticsApi, url, editorView, onLinkEditClick, }: EditToolbarButtonProps) => jsx.JSX.Element;
16
+ export declare const EditToolbarButton: (props: EditDatasourceToolbarButtonProps) => jsx.JSX.Element;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export type SmallLinkDropdownProps = {
3
+ testId: string;
4
+ };
5
+ declare const ConfigureLinkDropdown: (props: SmallLinkDropdownProps) => JSX.Element;
6
+ export default ConfigureLinkDropdown;
@@ -4,7 +4,8 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
4
4
  import type { Command } from '@atlaskit/editor-common/types';
5
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
6
  import type { CardContext } from '@atlaskit/link-provider';
7
- export interface EditToolbarButtonProps {
7
+ export interface EditDatasourceToolbarButtonProps {
8
+ datasourceId?: string;
8
9
  intl: IntlShape;
9
10
  editorAnalyticsApi?: EditorAnalyticsAPI;
10
11
  url?: string;
@@ -12,4 +13,4 @@ export interface EditToolbarButtonProps {
12
13
  cardContext?: CardContext;
13
14
  onLinkEditClick: Command;
14
15
  }
15
- export declare const EditToolbarButton: ({ intl, editorAnalyticsApi, url, editorView, onLinkEditClick, }: EditToolbarButtonProps) => jsx.JSX.Element;
16
+ export declare const EditToolbarButton: (props: EditDatasourceToolbarButtonProps) => jsx.JSX.Element;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export type SmallLinkDropdownProps = {
3
+ testId: string;
4
+ };
5
+ declare const ConfigureLinkDropdown: (props: SmallLinkDropdownProps) => JSX.Element;
6
+ export default ConfigureLinkDropdown;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,8 +34,10 @@
34
34
  "dependencies": {
35
35
  "@atlaskit/adf-schema": "^36.10.7",
36
36
  "@atlaskit/analytics-next": "^9.3.0",
37
+ "@atlaskit/button": "^17.17.1",
37
38
  "@atlaskit/custom-steps": "^0.2.0",
38
- "@atlaskit/editor-common": "^82.1.0",
39
+ "@atlaskit/dropdown-menu": "^12.10.2",
40
+ "@atlaskit/editor-common": "^82.2.0",
39
41
  "@atlaskit/editor-plugin-analytics": "^1.2.0",
40
42
  "@atlaskit/editor-plugin-decorations": "^1.1.0",
41
43
  "@atlaskit/editor-plugin-editor-viewmode": "^1.1.0",
@@ -48,7 +50,7 @@
48
50
  "@atlaskit/frontend-utilities": "^2.7.0",
49
51
  "@atlaskit/icon": "^22.3.0",
50
52
  "@atlaskit/link-analytics": "^8.3.0",
51
- "@atlaskit/link-client-extension": "^1.8.0",
53
+ "@atlaskit/link-client-extension": "^1.9.0",
52
54
  "@atlaskit/link-datasource": "^2.3.0",
53
55
  "@atlaskit/linking-common": "^5.7.0",
54
56
  "@atlaskit/linking-types": "^8.9.0",