@atlaskit/editor-plugin-card 5.3.1 → 5.3.3

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,23 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 5.3.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#127355](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/127355)
8
+ [`f4e608fc7d405`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f4e608fc7d405) -
9
+ Clean up feature gate platform_fix_embedded_card_re-rendering
10
+ - Updated dependencies
11
+
12
+ ## 5.3.2
13
+
14
+ ### Patch Changes
15
+
16
+ - [#127208](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/127208)
17
+ [`c2951b65d3aac`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c2951b65d3aac) -
18
+ [ux] ED-26896 Move list option to link dropdown
19
+ - Updated dependencies
20
+
3
21
  ## 5.3.1
4
22
 
5
23
  ### Patch Changes
@@ -58,8 +58,7 @@ var CardInner = function CardInner(_ref) {
58
58
  }
59
59
  var lineLength = getLineLength(view, pos, widthStateLineLength);
60
60
  var containerWidth = (0, _utils.isRichMediaInsideOfBlockNode)(view, pos) ? lineLength : widthStateWidth;
61
- var editorDisabledWhenGateDisabled = (editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled) && !(0, _platformFeatureFlags.fg)('platform_fix_embedded_card_re-rendering');
62
- if (!allowResizing || !hasPreview || editorDisabledWhenGateDisabled) {
61
+ if (!allowResizing || !hasPreview) {
63
62
  // There are two ways `width` and `height` can be defined here:
64
63
  // 1) Either as `heightAlone` as height value and no width
65
64
  // 2) or as `1` for height and aspectRation (defined or a default one) as a width
@@ -104,10 +103,7 @@ var CardInner = function CardInner(_ref) {
104
103
  containerWidth: containerWidth,
105
104
  displayGrid: displayGrid,
106
105
  updateSize: updateSize,
107
- dispatchAnalyticsEvent: dispatchAnalyticsEvent
108
- // Ignored via go/ees005
109
- // eslint-disable-next-line react/jsx-props-no-spreading
110
- }, (0, _platformFeatureFlags.fg)('platform_fix_embedded_card_re-rendering') && {
106
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
111
107
  isResizeDisabled: editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled
112
108
  }), smartCard);
113
109
  };
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.datasourceDisplayInformation = exports.DatasourceDropdownOption = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _messages = require("@atlaskit/editor-common/messages");
10
+ var _state = require("@atlaskit/editor-prosemirror/state");
11
+ var _smartLinkList = _interopRequireDefault(require("@atlaskit/icon/core/smart-link-list"));
12
+ var _linkDatasource = require("@atlaskit/link-datasource");
13
+ var _linkProvider = require("@atlaskit/link-provider");
14
+ var _menu = require("@atlaskit/menu");
15
+ var _doc = require("../pm-plugins/doc");
16
+ var _pluginKey = require("../pm-plugins/plugin-key");
17
+ var _useFetchDatasourceInfo = require("./useFetchDatasourceInfo");
18
+ var datasourceDisplayInformation = exports.datasourceDisplayInformation = {
19
+ title: _messages.cardMessages.datasourceAppearanceTitle,
20
+ icon: _smartLinkList.default,
21
+ // eslint-disable-next-line @atlaskit/editor/no-re-export
22
+ iconFallback: _smartLinkList.default
23
+ };
24
+ var DatasourceDropdownOption = exports.DatasourceDropdownOption = function DatasourceDropdownOption(_ref) {
25
+ var allowDatasource = _ref.allowDatasource,
26
+ intl = _ref.intl,
27
+ url = _ref.url,
28
+ selected = _ref.selected,
29
+ inputMethod = _ref.inputMethod,
30
+ dispatchCommand = _ref.dispatchCommand;
31
+ var cardContext = (0, _linkProvider.useSmartLinkContext)();
32
+ var _useFetchDatasourceIn = (0, _useFetchDatasourceInfo.useFetchDatasourceInfo)({
33
+ isRegularCardNode: true,
34
+ url: url,
35
+ cardContext: cardContext
36
+ }),
37
+ datasourceId = _useFetchDatasourceIn.datasourceId,
38
+ parameters = _useFetchDatasourceIn.parameters;
39
+ if (!allowDatasource || !datasourceId || !parameters) {
40
+ return null;
41
+ }
42
+ var onChangeAppearance = function onChangeAppearance(editorState, _dispatch, view) {
43
+ var _state$datasourceStas, _state$datasourceStas2;
44
+ if (!view || !datasourceId || !parameters) {
45
+ return false;
46
+ }
47
+ var state = _pluginKey.pluginKey.getState(editorState);
48
+ var newAdf = (0, _linkDatasource.buildDatasourceAdf)({
49
+ id: datasourceId,
50
+ parameters: parameters,
51
+ views: (_state$datasourceStas = state === null || state === void 0 || (_state$datasourceStas2 = state.datasourceStash[url]) === null || _state$datasourceStas2 === void 0 ? void 0 : _state$datasourceStas2.views) !== null && _state$datasourceStas !== void 0 ? _state$datasourceStas : [{
52
+ type: 'table'
53
+ }]
54
+ }, url);
55
+ var selection = editorState.selection;
56
+ var existingNode;
57
+ // Check if the selection contains a link mark
58
+ var $pos = editorState.doc.resolve(selection.from);
59
+ var isLinkMark = $pos.marks().some(function (mark) {
60
+ return mark.type === editorState.schema.marks.link;
61
+ });
62
+
63
+ // When selection is a TextNode and a link Mark is present return that node
64
+ if (selection instanceof _state.NodeSelection) {
65
+ existingNode = selection.node;
66
+ } else if (isLinkMark) {
67
+ var _editorState$doc$node;
68
+ existingNode = (_editorState$doc$node = editorState.doc.nodeAt(selection.from)) !== null && _editorState$doc$node !== void 0 ? _editorState$doc$node : undefined;
69
+ }
70
+ if (existingNode) {
71
+ (0, _doc.updateCardViaDatasource)({
72
+ state: editorState,
73
+ node: existingNode,
74
+ newAdf: newAdf,
75
+ view: view,
76
+ sourceEvent: undefined,
77
+ isDeletingConfig: true,
78
+ inputMethod: inputMethod
79
+ });
80
+ return true;
81
+ }
82
+ return false;
83
+ };
84
+ if (url) {
85
+ var _cardContext$store, _urlState$error;
86
+ var urlState = cardContext === null || cardContext === void 0 || (_cardContext$store = cardContext.store) === null || _cardContext$store === void 0 ? void 0 : _cardContext$store.getState()[url];
87
+ if ((urlState === null || urlState === void 0 || (_urlState$error = urlState.error) === null || _urlState$error === void 0 ? void 0 : _urlState$error.kind) === 'fatal') {
88
+ return null;
89
+ }
90
+ }
91
+ return /*#__PURE__*/_react.default.createElement(_menu.ButtonItem, {
92
+ key: intl.formatMessage(_messages.cardMessages.datasourceAppearanceTitle),
93
+ iconBefore: (0, _smartLinkList.default)({
94
+ label: intl.formatMessage(_messages.cardMessages.datasourceAppearanceTitle)
95
+ }),
96
+ onClick: function onClick() {
97
+ return dispatchCommand(onChangeAppearance);
98
+ },
99
+ isSelected: selected
100
+ }, intl.formatMessage(_messages.cardMessages.datasourceAppearanceTitle));
101
+ };
@@ -25,8 +25,9 @@ var HyperlinkDropdown = function HyperlinkDropdown(props) {
25
25
  intl = props.intl,
26
26
  editorState = props.editorState,
27
27
  cardOptions = props.cardOptions,
28
- editorAnalyticsApi = props.editorAnalyticsApi;
29
-
28
+ editorAnalyticsApi = props.editorAnalyticsApi,
29
+ allowDatasource = props.allowDatasource,
30
+ isDatasourceView = props.isDatasourceView;
30
31
  // Ignored via go/ees005
31
32
  // eslint-disable-next-line require-await
32
33
  var getProvider = /*#__PURE__*/function () {
@@ -139,9 +140,11 @@ var HyperlinkDropdown = function HyperlinkDropdown(props) {
139
140
  editorState: editorState,
140
141
  allowEmbeds: cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowEmbeds,
141
142
  allowBlockCards: cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowBlockCards,
143
+ allowDatasource: allowDatasource,
142
144
  editorAnalyticsApi: editorAnalyticsApi,
143
145
  dispatchCommand: props.dispatchCommand,
144
- settingsConfig: props.settingsConfig
146
+ settingsConfig: props.settingsConfig,
147
+ isDatasourceView: isDatasourceView
145
148
  });
146
149
  };
147
150
  var getHyperlinkAppearanceDropdown = exports.getHyperlinkAppearanceDropdown = function getHyperlinkAppearanceDropdown(_ref3) {
@@ -151,7 +154,9 @@ var getHyperlinkAppearanceDropdown = exports.getHyperlinkAppearanceDropdown = fu
151
154
  editorAnalyticsApi = _ref3.editorAnalyticsApi,
152
155
  editorPluginApi = _ref3.editorPluginApi,
153
156
  settingsConfig = _ref3.settingsConfig,
154
- cardOptions = _ref3.cardOptions;
157
+ cardOptions = _ref3.cardOptions,
158
+ allowDatasource = _ref3.allowDatasource,
159
+ isDatasourceView = _ref3.isDatasourceView;
155
160
  var alignmentItemOptions = {
156
161
  render: function render(props) {
157
162
  if (!editorState) {
@@ -165,7 +170,9 @@ var getHyperlinkAppearanceDropdown = exports.getHyperlinkAppearanceDropdown = fu
165
170
  editorPluginApi: editorPluginApi,
166
171
  dispatchCommand: props.dispatchCommand,
167
172
  settingsConfig: settingsConfig,
168
- cardOptions: cardOptions
173
+ cardOptions: cardOptions,
174
+ allowDatasource: allowDatasource,
175
+ isDatasourceView: isDatasourceView
169
176
  });
170
177
  },
171
178
  width: 200,
@@ -15,6 +15,7 @@ var _model = require("@atlaskit/editor-prosemirror/model");
15
15
  var _linkProvider = require("@atlaskit/link-provider");
16
16
  var _menu = require("@atlaskit/menu");
17
17
  var _doc = require("../pm-plugins/doc");
18
+ var _DatasourceDropdownOption = require("./DatasourceDropdownOption");
18
19
  var _LinkToolbarAppearance = require("./LinkToolbarAppearance");
19
20
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
20
21
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -27,6 +28,7 @@ var LinkAppearanceMenu = exports.LinkAppearanceMenu = function LinkAppearanceMen
27
28
  allowEmbeds = _ref.allowEmbeds,
28
29
  _ref$allowBlockCards = _ref.allowBlockCards,
29
30
  allowBlockCards = _ref$allowBlockCards === void 0 ? true : _ref$allowBlockCards,
31
+ allowDatasource = _ref.allowDatasource,
30
32
  editorAnalyticsApi = _ref.editorAnalyticsApi,
31
33
  _ref$showUpgradeDisco = _ref.showUpgradeDiscoverability,
32
34
  showUpgradeDiscoverability = _ref$showUpgradeDisco === void 0 ? true : _ref$showUpgradeDisco,
@@ -109,6 +111,13 @@ var LinkAppearanceMenu = exports.LinkAppearanceMenu = function LinkAppearanceMen
109
111
  },
110
112
  isSelected: option.selected
111
113
  }, option.title);
114
+ }), /*#__PURE__*/_react.default.createElement(_DatasourceDropdownOption.DatasourceDropdownOption, {
115
+ allowDatasource: allowDatasource,
116
+ intl: intl,
117
+ url: url !== null && url !== void 0 ? url : '',
118
+ selected: Boolean(isDatasourceView),
119
+ inputMethod: _analytics.INPUT_METHOD.FLOATING_TB,
120
+ dispatchCommand: dispatchCommand
112
121
  })), /*#__PURE__*/_react.default.createElement(_menu.Section, {
113
122
  hasSeparator: true
114
123
  }, /*#__PURE__*/_react.default.createElement(_menu.LinkItem, {
@@ -127,6 +136,7 @@ var getLinkAppearanceDropdown = exports.getLinkAppearanceDropdown = function get
127
136
  allowEmbeds = _ref2.allowEmbeds,
128
137
  _ref2$allowBlockCards = _ref2.allowBlockCards,
129
138
  allowBlockCards = _ref2$allowBlockCards === void 0 ? true : _ref2$allowBlockCards,
139
+ allowDatasource = _ref2.allowDatasource,
130
140
  editorAnalyticsApi = _ref2.editorAnalyticsApi,
131
141
  _ref2$showUpgradeDisc = _ref2.showUpgradeDiscoverability,
132
142
  showUpgradeDiscoverability = _ref2$showUpgradeDisc === void 0 ? true : _ref2$showUpgradeDisc,
@@ -144,6 +154,7 @@ var getLinkAppearanceDropdown = exports.getLinkAppearanceDropdown = function get
144
154
  editorAnalyticsApi: editorAnalyticsApi,
145
155
  showUpgradeDiscoverability: showUpgradeDiscoverability,
146
156
  isDatasourceView: isDatasourceView,
157
+ allowDatasource: allowDatasource,
147
158
  dispatchCommand: props.dispatchCommand,
148
159
  settingsConfig: settingsConfig
149
160
  });
@@ -151,7 +162,7 @@ var getLinkAppearanceDropdown = exports.getLinkAppearanceDropdown = function get
151
162
  width: 200,
152
163
  height: 400
153
164
  };
154
- var currentAppearanceDisplayInformation = _card.appearancePropsMap[currentAppearance !== null && currentAppearance !== void 0 ? currentAppearance : 'url'];
165
+ var currentAppearanceDisplayInformation = isDatasourceView ? _DatasourceDropdownOption.datasourceDisplayInformation : _card.appearancePropsMap[currentAppearance !== null && currentAppearance !== void 0 ? currentAppearance : 'url'];
155
166
  var alignmentToolbarItem = {
156
167
  id: 'card-appearance',
157
168
  testId: 'card-appearance-dropdown',
@@ -17,7 +17,6 @@ var _react2 = require("@emotion/react");
17
17
  var _ui = require("@atlaskit/editor-common/ui");
18
18
  var _utils = require("@atlaskit/editor-prosemirror/utils");
19
19
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
20
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
21
20
  var _smartCard = require("@atlaskit/smart-card");
22
21
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
23
22
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -339,7 +338,7 @@ var ResizableEmbedCard = exports.default = /*#__PURE__*/function (_React$Compone
339
338
  };
340
339
  var enable = {};
341
340
  _ui.handleSides.forEach(function (side) {
342
- if (isResizeDisabled && (0, _platformFeatureFlags.fg)('platform_fix_embedded_card_re-rendering')) {
341
+ if (isResizeDisabled) {
343
342
  enable[side] = false;
344
343
  return;
345
344
  }
@@ -401,9 +401,11 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
401
401
  allowEmbeds: allowEmbeds,
402
402
  allowBlockCards: allowBlockCards,
403
403
  editorAnalyticsApi: editorAnalyticsApi,
404
+ allowDatasource: cardOptions.allowDatasource,
404
405
  showUpgradeDiscoverability: showUpgradeDiscoverability,
405
- settingsConfig: getSettingsButton(intl, editorAnalyticsApi, cardOptions.userPreferencesLink)
406
- })], (0, _toConsumableArray2.default)(showDatasourceAppearance ? [{
406
+ settingsConfig: getSettingsButton(intl, editorAnalyticsApi, cardOptions.userPreferencesLink),
407
+ isDatasourceView: isDatasource
408
+ })], (0, _toConsumableArray2.default)(showDatasourceAppearance && (0, _experiments.editorExperiment)('platform_editor_controls', 'control') ? [{
407
409
  type: 'custom',
408
410
  fallback: [],
409
411
  render: function render(editorView) {
@@ -491,51 +493,59 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
491
493
  allowEmbeds = cardOptions.allowEmbeds,
492
494
  showUpgradeDiscoverability = cardOptions.showUpgradeDiscoverability;
493
495
  var url = metadata.url;
494
- toolbarItems.push((0, _experiments.editorExperiment)('platform_editor_controls', 'control') ? {
495
- type: 'custom',
496
- fallback: [],
497
- render: function render(editorView) {
498
- return /*#__PURE__*/_react.default.createElement(_LinkToolbarAppearance.LinkToolbarAppearance, {
499
- key: "link-appearance",
500
- url: url,
501
- intl: intl,
502
- currentAppearance: currentAppearance,
503
- editorView: editorView,
504
- editorState: state,
505
- allowEmbeds: allowEmbeds,
506
- allowBlockCards: allowBlockCards,
507
- editorAnalyticsApi: editorAnalyticsApi,
508
- showUpgradeDiscoverability: showUpgradeDiscoverability,
509
- isDatasourceView: true
510
- });
511
- }
512
- } : (0, _LinkToolbarAppearanceDropdown.getLinkAppearanceDropdown)({
513
- url: url,
514
- intl: intl,
515
- currentAppearance: currentAppearance,
516
- editorState: state,
517
- allowEmbeds: allowEmbeds,
518
- allowBlockCards: allowBlockCards,
519
- editorAnalyticsApi: editorAnalyticsApi,
520
- showUpgradeDiscoverability: showUpgradeDiscoverability,
521
- settingsConfig: getSettingsButton(intl, editorAnalyticsApi, cardOptions.userPreferencesLink)
522
- }), {
523
- type: 'custom',
524
- fallback: [],
525
- render: function render(editorView) {
526
- return /*#__PURE__*/_react.default.createElement(_DatasourceAppearanceButton.DatasourceAppearanceButton, {
527
- intl: intl,
528
- editorAnalyticsApi: editorAnalyticsApi,
529
- url: url,
530
- editorView: editorView,
531
- editorState: state,
532
- selected: true,
533
- inputMethod: _analytics.INPUT_METHOD.FLOATING_TB
534
- });
535
- }
536
- }, {
537
- type: 'separator'
538
- });
496
+ if ((0, _experiments.editorExperiment)('platform_editor_controls', 'control')) {
497
+ toolbarItems.push({
498
+ type: 'custom',
499
+ fallback: [],
500
+ render: function render(editorView) {
501
+ return /*#__PURE__*/_react.default.createElement(_LinkToolbarAppearance.LinkToolbarAppearance, {
502
+ key: "link-appearance",
503
+ url: url,
504
+ intl: intl,
505
+ currentAppearance: currentAppearance,
506
+ editorView: editorView,
507
+ editorState: state,
508
+ allowEmbeds: allowEmbeds,
509
+ allowBlockCards: allowBlockCards,
510
+ editorAnalyticsApi: editorAnalyticsApi,
511
+ showUpgradeDiscoverability: showUpgradeDiscoverability,
512
+ isDatasourceView: true
513
+ });
514
+ }
515
+ }, {
516
+ type: 'custom',
517
+ fallback: [],
518
+ render: function render(editorView) {
519
+ return /*#__PURE__*/_react.default.createElement(_DatasourceAppearanceButton.DatasourceAppearanceButton, {
520
+ intl: intl,
521
+ editorAnalyticsApi: editorAnalyticsApi,
522
+ url: url,
523
+ editorView: editorView,
524
+ editorState: state,
525
+ selected: true,
526
+ inputMethod: _analytics.INPUT_METHOD.FLOATING_TB
527
+ });
528
+ }
529
+ }, {
530
+ type: 'separator'
531
+ });
532
+ } else {
533
+ toolbarItems.push((0, _LinkToolbarAppearanceDropdown.getLinkAppearanceDropdown)({
534
+ url: url,
535
+ intl: intl,
536
+ currentAppearance: currentAppearance,
537
+ editorState: state,
538
+ allowEmbeds: allowEmbeds,
539
+ allowBlockCards: allowBlockCards,
540
+ editorAnalyticsApi: editorAnalyticsApi,
541
+ allowDatasource: cardOptions.allowDatasource,
542
+ showUpgradeDiscoverability: showUpgradeDiscoverability,
543
+ settingsConfig: getSettingsButton(intl, editorAnalyticsApi, cardOptions.userPreferencesLink),
544
+ isDatasourceView: true
545
+ }), {
546
+ type: 'separator'
547
+ });
548
+ }
539
549
  }
540
550
  toolbarItems.push({
541
551
  type: 'custom',
@@ -648,29 +658,14 @@ var getStartingToolbarItems = exports.getStartingToolbarItems = function getStar
648
658
  intl: intl,
649
659
  editorState: state,
650
660
  editorAnalyticsApi: api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions,
661
+ allowDatasource: options.allowDatasource,
651
662
  editorPluginApi: api,
652
663
  cardOptions: options,
653
- settingsConfig: getSettingsButton(intl, api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, options.userPreferencesLink)
654
- })].concat((0, _toConsumableArray2.default)(options !== null && options !== void 0 && options.allowDatasource ? [{
655
- type: 'custom',
656
- fallback: [],
657
- render: function render(editorView) {
658
- var _api$analytics4;
659
- if (!editorView) {
660
- return null;
661
- }
662
- return /*#__PURE__*/_react.default.createElement(_DatasourceAppearanceButton.DatasourceAppearanceButton, {
663
- intl: intl,
664
- editorAnalyticsApi: api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions,
665
- url: link,
666
- editorView: editorView,
667
- editorState: editorView.state,
668
- inputMethod: _analytics.INPUT_METHOD.FLOATING_TB
669
- });
670
- }
671
- }] : []), [{
664
+ settingsConfig: getSettingsButton(intl, api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, options.userPreferencesLink),
665
+ isDatasourceView: false
666
+ }), {
672
667
  type: 'separator'
673
- }], editLinkItem);
668
+ }].concat(editLinkItem);
674
669
  }
675
670
  return [{
676
671
  type: 'custom',
@@ -687,7 +682,7 @@ var getStartingToolbarItems = exports.getStartingToolbarItems = function getStar
687
682
  type: 'custom',
688
683
  fallback: [],
689
684
  render: function render(editorView) {
690
- var _api$analytics5;
685
+ var _api$analytics4;
691
686
  if (!editorView) {
692
687
  return null;
693
688
  }
@@ -698,7 +693,7 @@ var getStartingToolbarItems = exports.getStartingToolbarItems = function getStar
698
693
  editorView: editorView,
699
694
  editorState: editorView.state,
700
695
  cardOptions: options,
701
- editorAnalyticsApi: api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions,
696
+ editorAnalyticsApi: api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions,
702
697
  editorPluginApi: api
703
698
  });
704
699
  }
@@ -712,10 +707,10 @@ var getEndingToolbarItems = exports.getEndingToolbarItems = function getEndingTo
712
707
  * Or explicit user preferences config in order to enable button
713
708
  */
714
709
  if ((options.provider || options.userPreferencesLink) && (0, _experiments.editorExperiment)('platform_editor_controls', 'control')) {
715
- var _api$analytics6;
710
+ var _api$analytics5;
716
711
  return [{
717
712
  type: 'separator'
718
- }, getSettingsButton(intl, api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions, options.userPreferencesLink)];
713
+ }, getSettingsButton(intl, api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions, options.userPreferencesLink)];
719
714
  }
720
715
  return [];
721
716
  };
@@ -42,8 +42,7 @@ const CardInner = ({
42
42
  }
43
43
  const lineLength = getLineLength(view, pos, widthStateLineLength);
44
44
  const containerWidth = isRichMediaInsideOfBlockNode(view, pos) ? lineLength : widthStateWidth;
45
- const editorDisabledWhenGateDisabled = (editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled) && !fg('platform_fix_embedded_card_re-rendering');
46
- if (!allowResizing || !hasPreview || editorDisabledWhenGateDisabled) {
45
+ if (!allowResizing || !hasPreview) {
47
46
  // There are two ways `width` and `height` can be defined here:
48
47
  // 1) Either as `heightAlone` as height value and no width
49
48
  // 2) or as `1` for height and aspectRation (defined or a default one) as a width
@@ -88,10 +87,7 @@ const CardInner = ({
88
87
  containerWidth: containerWidth,
89
88
  displayGrid: displayGrid,
90
89
  updateSize: updateSize,
91
- dispatchAnalyticsEvent: dispatchAnalyticsEvent
92
- // Ignored via go/ees005
93
- // eslint-disable-next-line react/jsx-props-no-spreading
94
- }, fg('platform_fix_embedded_card_re-rendering') && {
90
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
95
91
  isResizeDisabled: editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled
96
92
  }), smartCard);
97
93
  };
@@ -0,0 +1,94 @@
1
+ import React from 'react';
2
+ import { cardMessages as messages } from '@atlaskit/editor-common/messages';
3
+ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
4
+ import SmartLinkListIcon from '@atlaskit/icon/core/smart-link-list';
5
+ import { buildDatasourceAdf } from '@atlaskit/link-datasource';
6
+ import { useSmartLinkContext } from '@atlaskit/link-provider';
7
+ import { ButtonItem } from '@atlaskit/menu';
8
+ import { updateCardViaDatasource } from '../pm-plugins/doc';
9
+ import { pluginKey } from '../pm-plugins/plugin-key';
10
+ import { useFetchDatasourceInfo } from './useFetchDatasourceInfo';
11
+ export const datasourceDisplayInformation = {
12
+ title: messages.datasourceAppearanceTitle,
13
+ icon: SmartLinkListIcon,
14
+ // eslint-disable-next-line @atlaskit/editor/no-re-export
15
+ iconFallback: SmartLinkListIcon
16
+ };
17
+ export const DatasourceDropdownOption = ({
18
+ allowDatasource,
19
+ intl,
20
+ url,
21
+ selected,
22
+ inputMethod,
23
+ dispatchCommand
24
+ }) => {
25
+ const cardContext = useSmartLinkContext();
26
+ const {
27
+ datasourceId,
28
+ parameters
29
+ } = useFetchDatasourceInfo({
30
+ isRegularCardNode: true,
31
+ url,
32
+ cardContext
33
+ });
34
+ if (!allowDatasource || !datasourceId || !parameters) {
35
+ return null;
36
+ }
37
+ const onChangeAppearance = (editorState, _dispatch, view) => {
38
+ var _state$datasourceStas, _state$datasourceStas2;
39
+ if (!view || !datasourceId || !parameters) {
40
+ return false;
41
+ }
42
+ const state = pluginKey.getState(editorState);
43
+ const newAdf = buildDatasourceAdf({
44
+ id: datasourceId,
45
+ parameters,
46
+ views: (_state$datasourceStas = state === null || state === void 0 ? void 0 : (_state$datasourceStas2 = state.datasourceStash[url]) === null || _state$datasourceStas2 === void 0 ? void 0 : _state$datasourceStas2.views) !== null && _state$datasourceStas !== void 0 ? _state$datasourceStas : [{
47
+ type: 'table'
48
+ }]
49
+ }, url);
50
+ const {
51
+ selection
52
+ } = editorState;
53
+ let existingNode;
54
+ // Check if the selection contains a link mark
55
+ const $pos = editorState.doc.resolve(selection.from);
56
+ const isLinkMark = $pos.marks().some(mark => mark.type === editorState.schema.marks.link);
57
+
58
+ // When selection is a TextNode and a link Mark is present return that node
59
+ if (selection instanceof NodeSelection) {
60
+ existingNode = selection.node;
61
+ } else if (isLinkMark) {
62
+ var _editorState$doc$node;
63
+ existingNode = (_editorState$doc$node = editorState.doc.nodeAt(selection.from)) !== null && _editorState$doc$node !== void 0 ? _editorState$doc$node : undefined;
64
+ }
65
+ if (existingNode) {
66
+ updateCardViaDatasource({
67
+ state: editorState,
68
+ node: existingNode,
69
+ newAdf,
70
+ view,
71
+ sourceEvent: undefined,
72
+ isDeletingConfig: true,
73
+ inputMethod
74
+ });
75
+ return true;
76
+ }
77
+ return false;
78
+ };
79
+ if (url) {
80
+ var _cardContext$store, _urlState$error;
81
+ const urlState = cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$store = cardContext.store) === null || _cardContext$store === void 0 ? void 0 : _cardContext$store.getState()[url];
82
+ if ((urlState === null || urlState === void 0 ? void 0 : (_urlState$error = urlState.error) === null || _urlState$error === void 0 ? void 0 : _urlState$error.kind) === 'fatal') {
83
+ return null;
84
+ }
85
+ }
86
+ return /*#__PURE__*/React.createElement(ButtonItem, {
87
+ key: intl.formatMessage(messages.datasourceAppearanceTitle),
88
+ iconBefore: SmartLinkListIcon({
89
+ label: intl.formatMessage(messages.datasourceAppearanceTitle)
90
+ }),
91
+ onClick: () => dispatchCommand(onChangeAppearance),
92
+ isSelected: selected
93
+ }, intl.formatMessage(messages.datasourceAppearanceTitle));
94
+ };
@@ -10,9 +10,10 @@ const HyperlinkDropdown = props => {
10
10
  intl,
11
11
  editorState,
12
12
  cardOptions,
13
- editorAnalyticsApi
13
+ editorAnalyticsApi,
14
+ allowDatasource,
15
+ isDatasourceView
14
16
  } = props;
15
-
16
17
  // Ignored via go/ees005
17
18
  // eslint-disable-next-line require-await
18
19
  const getProvider = async () => {
@@ -62,9 +63,11 @@ const HyperlinkDropdown = props => {
62
63
  editorState: editorState,
63
64
  allowEmbeds: cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowEmbeds,
64
65
  allowBlockCards: cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowBlockCards,
66
+ allowDatasource: allowDatasource,
65
67
  editorAnalyticsApi: editorAnalyticsApi,
66
68
  dispatchCommand: props.dispatchCommand,
67
- settingsConfig: props.settingsConfig
69
+ settingsConfig: props.settingsConfig,
70
+ isDatasourceView: isDatasourceView
68
71
  });
69
72
  };
70
73
  export const getHyperlinkAppearanceDropdown = ({
@@ -74,7 +77,9 @@ export const getHyperlinkAppearanceDropdown = ({
74
77
  editorAnalyticsApi,
75
78
  editorPluginApi,
76
79
  settingsConfig,
77
- cardOptions
80
+ cardOptions,
81
+ allowDatasource,
82
+ isDatasourceView
78
83
  }) => {
79
84
  const alignmentItemOptions = {
80
85
  render: props => {
@@ -89,7 +94,9 @@ export const getHyperlinkAppearanceDropdown = ({
89
94
  editorPluginApi: editorPluginApi,
90
95
  dispatchCommand: props.dispatchCommand,
91
96
  settingsConfig: settingsConfig,
92
- cardOptions: cardOptions
97
+ cardOptions: cardOptions,
98
+ allowDatasource: allowDatasource,
99
+ isDatasourceView: isDatasourceView
93
100
  });
94
101
  },
95
102
  width: 200,