@atlaskit/editor-plugin-card 1.0.0 → 1.0.2

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,18 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 1.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 1.0.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [#71504](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/71504) [`8beedb8b48db`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8beedb8b48db) - [ux] Enable switch view from Datasource to back smart links behind ff platform.linking-platform.enable-datasource-appearance-toolbar
14
+ - Updated dependencies
15
+
3
16
  ## 1.0.0
4
17
 
5
18
  ### Major Changes
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.DatasourceComponent = exports.Datasource = void 0;
8
+ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
8
9
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
10
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
11
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
@@ -20,6 +21,7 @@ var _styles = require("@atlaskit/editor-common/styles");
20
21
  var _ui = require("@atlaskit/editor-common/ui");
21
22
  var _utils = require("@atlaskit/editor-common/utils");
22
23
  var _linkDatasource = require("@atlaskit/link-datasource");
24
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
23
25
  var _datasourceErrorBoundary = require("../datasourceErrorBoundary");
24
26
  var _EditorAnalyticsContext = require("../ui/EditorAnalyticsContext");
25
27
  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; }
@@ -193,7 +195,31 @@ var Datasource = exports.Datasource = /*#__PURE__*/function (_ReactNodeView) {
193
195
  });
194
196
  return _this2;
195
197
  }
198
+
199
+ // Need this function to check if the datasource attribute was added or not to a blockCard.
200
+ // If not, we return false so we can get the node to re-render properly as a block node instead.
201
+ // Otherwise, the node view will still consider the node as a Datasource and render a such.
196
202
  (0, _createClass2.default)(Datasource, [{
203
+ key: "validUpdate",
204
+ value: function validUpdate(currentNode, newNode) {
205
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.enable-datasource-appearance-toolbar')) {
206
+ var _newNode$attrs;
207
+ return !!((_newNode$attrs = newNode.attrs) !== null && _newNode$attrs !== void 0 && _newNode$attrs.datasource);
208
+ }
209
+ return true;
210
+ }
211
+ }, {
212
+ key: "update",
213
+ value: function update(node, decorations, _innerDecorations) {
214
+ var validUpdate = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function () {
215
+ return true;
216
+ };
217
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.enable-datasource-appearance-toolbar')) {
218
+ return (0, _get2.default)((0, _getPrototypeOf2.default)(Datasource.prototype), "update", this).call(this, node, decorations, _innerDecorations, this.validUpdate);
219
+ }
220
+ return (0, _get2.default)((0, _getPrototypeOf2.default)(Datasource.prototype), "update", this).call(this, node, decorations, _innerDecorations, validUpdate);
221
+ }
222
+ }, {
197
223
  key: "createDomRef",
198
224
  value: function createDomRef() {
199
225
  var domRef = document.createElement('div');
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.updateCardViaDatasource = exports.updateCard = exports.setSelectedCardAppearance = exports.replaceQueuedUrlWithCard = exports.queueCardsFromChangedTr = exports.queueCardFromChangedTr = exports.insertDatasource = exports.handleFallbackWithAnalytics = exports.getLinkNodeType = exports.convertHyperlinkToSmartCard = exports.changeSelectedCardToText = exports.changeSelectedCardToLinkFallback = exports.changeSelectedCardToLink = void 0;
7
+ exports.updateCardViaDatasource = exports.updateCard = exports.setSelectedCardAppearance = exports.replaceQueuedUrlWithCard = exports.queueCardsFromChangedTr = exports.queueCardFromChangedTr = exports.insertDatasource = exports.handleFallbackWithAnalytics = exports.getLinkNodeType = exports.getAttrsForAppearance = exports.convertHyperlinkToSmartCard = exports.changeSelectedCardToText = exports.changeSelectedCardToLinkFallback = exports.changeSelectedCardToLink = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
10
  var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
@@ -14,6 +14,7 @@ var _card = require("@atlaskit/editor-common/card");
14
14
  var _utils = require("@atlaskit/editor-common/utils");
15
15
  var _history = require("@atlaskit/editor-prosemirror/history");
16
16
  var _state = require("@atlaskit/editor-prosemirror/state");
17
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
18
  var _utils2 = require("../utils");
18
19
  var _actions = require("./actions");
19
20
  var _pluginKey = require("./plugin-key");
@@ -368,13 +369,21 @@ var setSelectedCardAppearance = exports.setSelectedCardAppearance = function set
368
369
  }
369
370
  return false;
370
371
  }
371
- if ((0, _utils2.appearanceForNodeType)(selectedNode.type) === appearance) {
372
- return false;
372
+ var attrs;
373
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.enable-datasource-appearance-toolbar')) {
374
+ if ((0, _utils2.appearanceForNodeType)(selectedNode.type) === appearance && !selectedNode.attrs.datasource) {
375
+ return false;
376
+ }
377
+ attrs = getAttrsForAppearance(appearance, selectedNode);
378
+ } else {
379
+ if ((0, _utils2.appearanceForNodeType)(selectedNode.type) === appearance) {
380
+ return false;
381
+ }
382
+ var isEmbed = appearance === 'embed';
383
+ attrs = isEmbed ? _objectSpread(_objectSpread({}, selectedNode.attrs), {}, {
384
+ layout: 'center'
385
+ }) : selectedNode.attrs;
373
386
  }
374
- var isEmbed = appearance === 'embed';
375
- var attrs = isEmbed ? _objectSpread(_objectSpread({}, selectedNode.attrs), {}, {
376
- layout: 'center'
377
- }) : selectedNode.attrs;
378
387
  var _state$selection = state.selection,
379
388
  from = _state$selection.from,
380
389
  to = _state$selection.to;
@@ -479,4 +488,21 @@ var insertDatasource = exports.insertDatasource = function insertDatasource(stat
479
488
  sourceEvent: sourceEvent
480
489
  });
481
490
  view.dispatch(tr.scrollIntoView());
491
+ };
492
+
493
+ /**
494
+ * Get attributes for new Card Appearance
495
+ */
496
+ var getAttrsForAppearance = exports.getAttrsForAppearance = function getAttrsForAppearance(appearance, selectedNode) {
497
+ if (appearance === 'embed') {
498
+ return _objectSpread(_objectSpread({}, selectedNode.attrs), {}, {
499
+ layout: 'center'
500
+ });
501
+ }
502
+ if (selectedNode.attrs.datasource) {
503
+ return {
504
+ url: selectedNode.attrs.url
505
+ };
506
+ }
507
+ return selectedNode.attrs;
482
508
  };
@@ -103,6 +103,16 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
103
103
  var events = (0, _eventsFromTr.eventsFromTransaction)(tr, prevEditorState);
104
104
  cardPluginEvents.push.apply(cardPluginEvents, (0, _toConsumableArray2.default)(events));
105
105
  }
106
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.enable-datasource-appearance-toolbar') && !meta) {
107
+ if (pluginState.datasourceTableRef) {
108
+ if (!(tr.selection instanceof _state.NodeSelection) || !tr.selection.node.attrs.datasource) {
109
+ // disable resize button when switching from datasource to block card
110
+ return _objectSpread(_objectSpread({}, pluginStateWithUpdatedPos), {}, {
111
+ datasourceTableRef: undefined
112
+ });
113
+ }
114
+ }
115
+ }
106
116
  if (!meta) {
107
117
  return pluginStateWithUpdatedPos;
108
118
  }
@@ -217,7 +217,8 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
217
217
  lpLinkPicker: lpLinkPicker
218
218
  })];
219
219
  } else if (shouldRenderDatasourceToolbar) {
220
- return getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, node.attrs.datasource.id, state);
220
+ var _pluginInjectionApi$c;
221
+ 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);
221
222
  } else {
222
223
  var inlineCard = state.schema.nodes.inlineCard;
223
224
  var toolbarItems = [{
@@ -285,7 +286,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
285
286
  type: 'custom',
286
287
  fallback: [],
287
288
  render: function render(editorView) {
288
- var _pluginInjectionApi$c;
289
+ var _pluginInjectionApi$c2;
289
290
  return /*#__PURE__*/_react.default.createElement(_LinkToolbarAppearance.LinkToolbarAppearance, {
290
291
  key: "link-appearance",
291
292
  url: url,
@@ -297,7 +298,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
297
298
  allowBlockCards: allowBlockCards,
298
299
  platform: platform,
299
300
  editorAnalyticsApi: editorAnalyticsApi,
300
- cardActions: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.card) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions,
301
+ cardActions: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.card) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.actions,
301
302
  showUpgradeDiscoverability: showUpgradeDiscoverability
302
303
  });
303
304
  }
@@ -360,7 +361,7 @@ var getSettingsButtonGroup = function getSettingsButtonGroup(intl, editorAnalyti
360
361
  type: 'separator'
361
362
  }];
362
363
  };
363
- var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state) {
364
+ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state, cardOptions, currentAppearance, platform, cardActions) {
364
365
  var _node$attrs3;
365
366
  var toolbarItems = [];
366
367
  if ((0, _utils3.isDatasourceConfigEditable)(datasourceId)) {
@@ -377,6 +378,50 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
377
378
  type: 'separator'
378
379
  });
379
380
  }
381
+
382
+ // Smart card view buttons only allowed for non-config datasources
383
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.enable-datasource-appearance-toolbar') && !(0, _utils3.isDatasourceConfigEditable)(datasourceId) && cardOptions) {
384
+ var allowBlockCards = cardOptions.allowBlockCards,
385
+ allowEmbeds = cardOptions.allowEmbeds,
386
+ showUpgradeDiscoverability = cardOptions.showUpgradeDiscoverability;
387
+ var url = metadata.url;
388
+ toolbarItems.push({
389
+ type: 'custom',
390
+ fallback: [],
391
+ render: function render(editorView) {
392
+ return /*#__PURE__*/_react.default.createElement(_LinkToolbarAppearance.LinkToolbarAppearance, {
393
+ key: "link-appearance",
394
+ url: url,
395
+ intl: intl,
396
+ currentAppearance: currentAppearance,
397
+ editorView: editorView,
398
+ editorState: state,
399
+ allowEmbeds: allowEmbeds,
400
+ allowBlockCards: allowBlockCards,
401
+ platform: platform,
402
+ editorAnalyticsApi: editorAnalyticsApi,
403
+ cardActions: cardActions,
404
+ showUpgradeDiscoverability: showUpgradeDiscoverability,
405
+ isDatasourceView: true
406
+ });
407
+ }
408
+ }, {
409
+ type: 'custom',
410
+ fallback: [],
411
+ render: function render(editorView) {
412
+ return /*#__PURE__*/_react.default.createElement(_DatasourceAppearanceButton.DatasourceAppearanceButton, {
413
+ intl: intl,
414
+ editorAnalyticsApi: editorAnalyticsApi,
415
+ url: url,
416
+ editorView: editorView,
417
+ editorState: state,
418
+ selected: true
419
+ });
420
+ }
421
+ }, {
422
+ type: 'separator'
423
+ });
424
+ }
380
425
  if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
381
426
  toolbarItems.push({
382
427
  id: 'editor.link.openLink',
@@ -27,7 +27,8 @@ var DatasourceAppearanceButtonWithCardContext = function DatasourceAppearanceBut
27
27
  intl = _ref.intl,
28
28
  url = _ref.url,
29
29
  editorView = _ref.editorView,
30
- editorState = _ref.editorState;
30
+ editorState = _ref.editorState,
31
+ selected = _ref.selected;
31
32
  var _useFetchDatasourceIn = (0, _useFetchDatasourceInfo.useFetchDatasourceInfo)({
32
33
  isRegularCardNode: true,
33
34
  url: url,
@@ -69,7 +70,7 @@ var DatasourceAppearanceButtonWithCardContext = function DatasourceAppearanceBut
69
70
  icon: (0, _react2.jsx)(_table.default, {
70
71
  label: buttonLabel
71
72
  }),
72
- selected: false,
73
+ selected: selected,
73
74
  onClick: onChangeAppearance,
74
75
  testId: 'card-datasource-appearance-button'
75
76
  }));
@@ -79,7 +80,8 @@ var DatasourceAppearanceButton = exports.DatasourceAppearanceButton = function D
79
80
  editorAnalyticsApi = _ref2.editorAnalyticsApi,
80
81
  url = _ref2.url,
81
82
  editorView = _ref2.editorView,
82
- editorState = _ref2.editorState;
83
+ editorState = _ref2.editorState,
84
+ selected = _ref2.selected;
83
85
  return (0, _react2.jsx)(_CardContextProvider.CardContextProvider, null, function (_ref3) {
84
86
  var cardContext = _ref3.cardContext;
85
87
  return (0, _react2.jsx)(DatasourceAppearanceButtonWithCardContext, {
@@ -88,7 +90,8 @@ var DatasourceAppearanceButton = exports.DatasourceAppearanceButton = function D
88
90
  editorAnalyticsApi: editorAnalyticsApi,
89
91
  editorView: editorView,
90
92
  editorState: editorState,
91
- cardContext: cardContext
93
+ cardContext: cardContext,
94
+ selected: selected
92
95
  });
93
96
  });
94
97
  };
@@ -56,7 +56,8 @@ var LinkToolbarAppearance = exports.LinkToolbarAppearance = /*#__PURE__*/functio
56
56
  editorAnalyticsApi = _this$props.editorAnalyticsApi,
57
57
  cardActions = _this$props.cardActions,
58
58
  _this$props$showUpgra = _this$props.showUpgradeDiscoverability,
59
- showUpgradeDiscoverability = _this$props$showUpgra === void 0 ? true : _this$props$showUpgra;
59
+ showUpgradeDiscoverability = _this$props$showUpgra === void 0 ? true : _this$props$showUpgra,
60
+ isDatasourceView = _this$props.isDatasourceView;
60
61
  var preview = allowEmbeds && cardContext && url && cardContext.extractors.getPreview(url, platform);
61
62
  var defaultCommand = function defaultCommand() {
62
63
  return false;
@@ -84,7 +85,7 @@ var LinkToolbarAppearance = exports.LinkToolbarAppearance = /*#__PURE__*/functio
84
85
  appearance: 'block',
85
86
  title: intl.formatMessage(_messages.cardMessages.block),
86
87
  onClick: (_cardActions$setSelec2 = cardActions === null || cardActions === void 0 ? void 0 : cardActions.setSelectedCardAppearance('block', editorAnalyticsApi)) !== null && _cardActions$setSelec2 !== void 0 ? _cardActions$setSelec2 : defaultCommand,
87
- selected: currentAppearance === 'block',
88
+ selected: currentAppearance === 'block' && !isDatasourceView,
88
89
  testId: 'block-appearance',
89
90
  disabled: !isBlockCardLinkSupportedInParent,
90
91
  tooltip: isBlockCardLinkSupportedInParent ? undefined : getUnavailableMessage(editorState, intl)
@@ -94,7 +95,7 @@ var LinkToolbarAppearance = exports.LinkToolbarAppearance = /*#__PURE__*/functio
94
95
  onClick: (0, _card.commandWithMetadata)((_cardActions$changeSe = cardActions === null || cardActions === void 0 ? void 0 : cardActions.changeSelectedCardToLink(url, url, true, undefined, undefined, editorAnalyticsApi)) !== null && _cardActions$changeSe !== void 0 ? _cardActions$changeSe : defaultCommand, {
95
96
  action: _analytics.ACTION.CHANGED_TYPE
96
97
  }),
97
- selected: !currentAppearance,
98
+ selected: !currentAppearance && !isDatasourceView,
98
99
  testId: 'url-appearance'
99
100
  }, {
100
101
  appearance: 'inline',
@@ -8,6 +8,7 @@ import { DATASOURCE_INNER_CONTAINER_CLASSNAME, SmartCardSharedCssClassName } fro
8
8
  import { UnsupportedInline } from '@atlaskit/editor-common/ui';
9
9
  import { calcBreakoutWidth } from '@atlaskit/editor-common/utils';
10
10
  import { DatasourceTableView } from '@atlaskit/link-datasource';
11
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
11
12
  import { DatasourceErrorBoundary } from '../datasourceErrorBoundary';
12
13
  import { EditorAnalyticsContext } from '../ui/EditorAnalyticsContext';
13
14
  const getPosSafely = pos => {
@@ -161,6 +162,22 @@ export class Datasource extends ReactNodeView {
161
162
  });
162
163
  }
163
164
 
165
+ // Need this function to check if the datasource attribute was added or not to a blockCard.
166
+ // If not, we return false so we can get the node to re-render properly as a block node instead.
167
+ // Otherwise, the node view will still consider the node as a Datasource and render a such.
168
+ validUpdate(currentNode, newNode) {
169
+ if (getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar')) {
170
+ var _newNode$attrs;
171
+ return !!((_newNode$attrs = newNode.attrs) !== null && _newNode$attrs !== void 0 && _newNode$attrs.datasource);
172
+ }
173
+ return true;
174
+ }
175
+ update(node, decorations, _innerDecorations, validUpdate = () => true) {
176
+ if (getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar')) {
177
+ return super.update(node, decorations, _innerDecorations, this.validUpdate);
178
+ }
179
+ return super.update(node, decorations, _innerDecorations, validUpdate);
180
+ }
164
181
  createDomRef() {
165
182
  const domRef = document.createElement('div');
166
183
  domRef.setAttribute('contenteditable', 'true');
@@ -5,6 +5,7 @@ import { addLinkMetadata } from '@atlaskit/editor-common/card';
5
5
  import { getLinkCreationAnalyticsEvent, isFromCurrentDomain, nodesBetweenChanged, processRawValue } from '@atlaskit/editor-common/utils';
6
6
  import { closeHistory } from '@atlaskit/editor-prosemirror/history';
7
7
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
8
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
9
  import { appearanceForNodeType, selectedCardAppearance } from '../utils';
9
10
  import { hideDatasourceModal, queueCards, resolveCard } from './actions';
10
11
  import { pluginKey } from './plugin-key';
@@ -341,14 +342,22 @@ export const setSelectedCardAppearance = (appearance, editorAnalyticsApi) => (st
341
342
  }
342
343
  return false;
343
344
  }
344
- if (appearanceForNodeType(selectedNode.type) === appearance) {
345
- return false;
345
+ let attrs;
346
+ if (getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar')) {
347
+ if (appearanceForNodeType(selectedNode.type) === appearance && !selectedNode.attrs.datasource) {
348
+ return false;
349
+ }
350
+ attrs = getAttrsForAppearance(appearance, selectedNode);
351
+ } else {
352
+ if (appearanceForNodeType(selectedNode.type) === appearance) {
353
+ return false;
354
+ }
355
+ const isEmbed = appearance === 'embed';
356
+ attrs = isEmbed ? {
357
+ ...selectedNode.attrs,
358
+ layout: 'center'
359
+ } : selectedNode.attrs;
346
360
  }
347
- const isEmbed = appearance === 'embed';
348
- const attrs = isEmbed ? {
349
- ...selectedNode.attrs,
350
- layout: 'center'
351
- } : selectedNode.attrs;
352
361
  const {
353
362
  from,
354
363
  to
@@ -462,4 +471,22 @@ export const insertDatasource = (state, adf, view, sourceEvent) => {
462
471
  sourceEvent
463
472
  });
464
473
  view.dispatch(tr.scrollIntoView());
474
+ };
475
+
476
+ /**
477
+ * Get attributes for new Card Appearance
478
+ */
479
+ export const getAttrsForAppearance = (appearance, selectedNode) => {
480
+ if (appearance === 'embed') {
481
+ return {
482
+ ...selectedNode.attrs,
483
+ layout: 'center'
484
+ };
485
+ }
486
+ if (selectedNode.attrs.datasource) {
487
+ return {
488
+ url: selectedNode.attrs.url
489
+ };
490
+ }
491
+ return selectedNode.attrs;
465
492
  };
@@ -88,6 +88,17 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
88
88
  const events = eventsFromTransaction(tr, prevEditorState);
89
89
  cardPluginEvents.push(...events);
90
90
  }
91
+ if (getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar') && !meta) {
92
+ if (pluginState.datasourceTableRef) {
93
+ if (!(tr.selection instanceof NodeSelection) || !tr.selection.node.attrs.datasource) {
94
+ // disable resize button when switching from datasource to block card
95
+ return {
96
+ ...pluginStateWithUpdatedPos,
97
+ datasourceTableRef: undefined
98
+ };
99
+ }
100
+ }
101
+ }
91
102
  if (!meta) {
92
103
  return pluginStateWithUpdatedPos;
93
104
  }
@@ -209,7 +209,8 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
209
209
  lpLinkPicker
210
210
  })];
211
211
  } else if (shouldRenderDatasourceToolbar) {
212
- return getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, node.attrs.datasource.id, state);
212
+ var _pluginInjectionApi$c;
213
+ return getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, node.attrs.datasource.id, state, cardOptions, currentAppearance, platform, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c = pluginInjectionApi.card) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions);
213
214
  } else {
214
215
  const {
215
216
  inlineCard
@@ -281,7 +282,7 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
281
282
  type: 'custom',
282
283
  fallback: [],
283
284
  render: editorView => {
284
- var _pluginInjectionApi$c;
285
+ var _pluginInjectionApi$c2;
285
286
  return /*#__PURE__*/React.createElement(LinkToolbarAppearance, {
286
287
  key: "link-appearance",
287
288
  url: url,
@@ -293,7 +294,7 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
293
294
  allowBlockCards: allowBlockCards,
294
295
  platform: platform,
295
296
  editorAnalyticsApi: editorAnalyticsApi,
296
- cardActions: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c = pluginInjectionApi.card) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions,
297
+ cardActions: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c2 = pluginInjectionApi.card) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.actions,
297
298
  showUpgradeDiscoverability: showUpgradeDiscoverability
298
299
  });
299
300
  }
@@ -351,7 +352,7 @@ const getSettingsButtonGroup = (intl, editorAnalyticsApi) => {
351
352
  type: 'separator'
352
353
  }];
353
354
  };
354
- const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state) => {
355
+ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state, cardOptions, currentAppearance, platform, cardActions) => {
355
356
  var _node$attrs3;
356
357
  const toolbarItems = [];
357
358
  if (isDatasourceConfigEditable(datasourceId)) {
@@ -368,6 +369,52 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
368
369
  type: 'separator'
369
370
  });
370
371
  }
372
+
373
+ // Smart card view buttons only allowed for non-config datasources
374
+ if (getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar') && !isDatasourceConfigEditable(datasourceId) && cardOptions) {
375
+ const {
376
+ allowBlockCards,
377
+ allowEmbeds,
378
+ showUpgradeDiscoverability
379
+ } = cardOptions;
380
+ const {
381
+ url
382
+ } = metadata;
383
+ toolbarItems.push({
384
+ type: 'custom',
385
+ fallback: [],
386
+ render: editorView => {
387
+ return /*#__PURE__*/React.createElement(LinkToolbarAppearance, {
388
+ key: "link-appearance",
389
+ url: url,
390
+ intl: intl,
391
+ currentAppearance: currentAppearance,
392
+ editorView: editorView,
393
+ editorState: state,
394
+ allowEmbeds: allowEmbeds,
395
+ allowBlockCards: allowBlockCards,
396
+ platform: platform,
397
+ editorAnalyticsApi: editorAnalyticsApi,
398
+ cardActions: cardActions,
399
+ showUpgradeDiscoverability: showUpgradeDiscoverability,
400
+ isDatasourceView: true
401
+ });
402
+ }
403
+ }, {
404
+ type: 'custom',
405
+ fallback: [],
406
+ render: editorView => /*#__PURE__*/React.createElement(DatasourceAppearanceButton, {
407
+ intl: intl,
408
+ editorAnalyticsApi: editorAnalyticsApi,
409
+ url: url,
410
+ editorView: editorView,
411
+ editorState: state,
412
+ selected: true
413
+ })
414
+ }, {
415
+ type: 'separator'
416
+ });
417
+ }
371
418
  if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
372
419
  toolbarItems.push({
373
420
  id: 'editor.link.openLink',
@@ -19,7 +19,8 @@ const DatasourceAppearanceButtonWithCardContext = ({
19
19
  intl,
20
20
  url,
21
21
  editorView,
22
- editorState
22
+ editorState,
23
+ selected
23
24
  }) => {
24
25
  const {
25
26
  datasourceId,
@@ -65,7 +66,7 @@ const DatasourceAppearanceButtonWithCardContext = ({
65
66
  icon: jsx(TableIcon, {
66
67
  label: buttonLabel
67
68
  }),
68
- selected: false,
69
+ selected: selected,
69
70
  onClick: onChangeAppearance,
70
71
  testId: 'card-datasource-appearance-button'
71
72
  }));
@@ -75,7 +76,8 @@ export const DatasourceAppearanceButton = ({
75
76
  editorAnalyticsApi,
76
77
  url,
77
78
  editorView,
78
- editorState
79
+ editorState,
80
+ selected
79
81
  }) => {
80
82
  return jsx(CardContextProvider, null, ({
81
83
  cardContext
@@ -85,6 +87,7 @@ export const DatasourceAppearanceButton = ({
85
87
  editorAnalyticsApi: editorAnalyticsApi,
86
88
  editorView: editorView,
87
89
  editorState: editorState,
88
- cardContext: cardContext
90
+ cardContext: cardContext,
91
+ selected: selected
89
92
  }));
90
93
  };
@@ -27,7 +27,8 @@ export class LinkToolbarAppearance extends React.Component {
27
27
  platform,
28
28
  editorAnalyticsApi,
29
29
  cardActions,
30
- showUpgradeDiscoverability = true
30
+ showUpgradeDiscoverability = true,
31
+ isDatasourceView
31
32
  } = this.props;
32
33
  const preview = allowEmbeds && cardContext && url && cardContext.extractors.getPreview(url, platform);
33
34
  const defaultCommand = () => false;
@@ -54,7 +55,7 @@ export class LinkToolbarAppearance extends React.Component {
54
55
  appearance: 'block',
55
56
  title: intl.formatMessage(messages.block),
56
57
  onClick: (_cardActions$setSelec2 = cardActions === null || cardActions === void 0 ? void 0 : cardActions.setSelectedCardAppearance('block', editorAnalyticsApi)) !== null && _cardActions$setSelec2 !== void 0 ? _cardActions$setSelec2 : defaultCommand,
57
- selected: currentAppearance === 'block',
58
+ selected: currentAppearance === 'block' && !isDatasourceView,
58
59
  testId: 'block-appearance',
59
60
  disabled: !isBlockCardLinkSupportedInParent,
60
61
  tooltip: isBlockCardLinkSupportedInParent ? undefined : getUnavailableMessage(editorState, intl)
@@ -64,7 +65,7 @@ export class LinkToolbarAppearance extends React.Component {
64
65
  onClick: commandWithMetadata((_cardActions$changeSe = cardActions === null || cardActions === void 0 ? void 0 : cardActions.changeSelectedCardToLink(url, url, true, undefined, undefined, editorAnalyticsApi)) !== null && _cardActions$changeSe !== void 0 ? _cardActions$changeSe : defaultCommand, {
65
66
  action: ACTION.CHANGED_TYPE
66
67
  }),
67
- selected: !currentAppearance,
68
+ selected: !currentAppearance && !isDatasourceView,
68
69
  testId: 'url-appearance'
69
70
  }, {
70
71
  appearance: 'inline',
@@ -1,3 +1,4 @@
1
+ import _get from "@babel/runtime/helpers/get";
1
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
3
  import _createClass from "@babel/runtime/helpers/createClass";
3
4
  import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
@@ -18,6 +19,7 @@ import { DATASOURCE_INNER_CONTAINER_CLASSNAME, SmartCardSharedCssClassName } fro
18
19
  import { UnsupportedInline } from '@atlaskit/editor-common/ui';
19
20
  import { calcBreakoutWidth } from '@atlaskit/editor-common/utils';
20
21
  import { DatasourceTableView } from '@atlaskit/link-datasource';
22
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
21
23
  import { DatasourceErrorBoundary } from '../datasourceErrorBoundary';
22
24
  import { EditorAnalyticsContext } from '../ui/EditorAnalyticsContext';
23
25
  var getPosSafely = function getPosSafely(pos) {
@@ -187,7 +189,31 @@ export var Datasource = /*#__PURE__*/function (_ReactNodeView) {
187
189
  });
188
190
  return _this2;
189
191
  }
192
+
193
+ // Need this function to check if the datasource attribute was added or not to a blockCard.
194
+ // If not, we return false so we can get the node to re-render properly as a block node instead.
195
+ // Otherwise, the node view will still consider the node as a Datasource and render a such.
190
196
  _createClass(Datasource, [{
197
+ key: "validUpdate",
198
+ value: function validUpdate(currentNode, newNode) {
199
+ if (getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar')) {
200
+ var _newNode$attrs;
201
+ return !!((_newNode$attrs = newNode.attrs) !== null && _newNode$attrs !== void 0 && _newNode$attrs.datasource);
202
+ }
203
+ return true;
204
+ }
205
+ }, {
206
+ key: "update",
207
+ value: function update(node, decorations, _innerDecorations) {
208
+ var validUpdate = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function () {
209
+ return true;
210
+ };
211
+ if (getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar')) {
212
+ return _get(_getPrototypeOf(Datasource.prototype), "update", this).call(this, node, decorations, _innerDecorations, this.validUpdate);
213
+ }
214
+ return _get(_getPrototypeOf(Datasource.prototype), "update", this).call(this, node, decorations, _innerDecorations, validUpdate);
215
+ }
216
+ }, {
191
217
  key: "createDomRef",
192
218
  value: function createDomRef() {
193
219
  var domRef = document.createElement('div');
@@ -9,6 +9,7 @@ import { addLinkMetadata } from '@atlaskit/editor-common/card';
9
9
  import { 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
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
12
13
  import { appearanceForNodeType, selectedCardAppearance } from '../utils';
13
14
  import { hideDatasourceModal, queueCards, resolveCard } from './actions';
14
15
  import { pluginKey } from './plugin-key';
@@ -361,13 +362,21 @@ export var setSelectedCardAppearance = function setSelectedCardAppearance(appear
361
362
  }
362
363
  return false;
363
364
  }
364
- if (appearanceForNodeType(selectedNode.type) === appearance) {
365
- return false;
365
+ var attrs;
366
+ if (getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar')) {
367
+ if (appearanceForNodeType(selectedNode.type) === appearance && !selectedNode.attrs.datasource) {
368
+ return false;
369
+ }
370
+ attrs = getAttrsForAppearance(appearance, selectedNode);
371
+ } else {
372
+ if (appearanceForNodeType(selectedNode.type) === appearance) {
373
+ return false;
374
+ }
375
+ var isEmbed = appearance === 'embed';
376
+ attrs = isEmbed ? _objectSpread(_objectSpread({}, selectedNode.attrs), {}, {
377
+ layout: 'center'
378
+ }) : selectedNode.attrs;
366
379
  }
367
- var isEmbed = appearance === 'embed';
368
- var attrs = isEmbed ? _objectSpread(_objectSpread({}, selectedNode.attrs), {}, {
369
- layout: 'center'
370
- }) : selectedNode.attrs;
371
380
  var _state$selection = state.selection,
372
381
  from = _state$selection.from,
373
382
  to = _state$selection.to;
@@ -472,4 +481,21 @@ export var insertDatasource = function insertDatasource(state, adf, view, source
472
481
  sourceEvent: sourceEvent
473
482
  });
474
483
  view.dispatch(tr.scrollIntoView());
484
+ };
485
+
486
+ /**
487
+ * Get attributes for new Card Appearance
488
+ */
489
+ export var getAttrsForAppearance = function getAttrsForAppearance(appearance, selectedNode) {
490
+ if (appearance === 'embed') {
491
+ return _objectSpread(_objectSpread({}, selectedNode.attrs), {}, {
492
+ layout: 'center'
493
+ });
494
+ }
495
+ if (selectedNode.attrs.datasource) {
496
+ return {
497
+ url: selectedNode.attrs.url
498
+ };
499
+ }
500
+ return selectedNode.attrs;
475
501
  };
@@ -91,6 +91,16 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
91
91
  var events = eventsFromTransaction(tr, prevEditorState);
92
92
  cardPluginEvents.push.apply(cardPluginEvents, _toConsumableArray(events));
93
93
  }
94
+ if (getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar') && !meta) {
95
+ if (pluginState.datasourceTableRef) {
96
+ if (!(tr.selection instanceof NodeSelection) || !tr.selection.node.attrs.datasource) {
97
+ // disable resize button when switching from datasource to block card
98
+ return _objectSpread(_objectSpread({}, pluginStateWithUpdatedPos), {}, {
99
+ datasourceTableRef: undefined
100
+ });
101
+ }
102
+ }
103
+ }
94
104
  if (!meta) {
95
105
  return pluginStateWithUpdatedPos;
96
106
  }
@@ -207,7 +207,8 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
207
207
  lpLinkPicker: lpLinkPicker
208
208
  })];
209
209
  } else if (shouldRenderDatasourceToolbar) {
210
- return getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, node.attrs.datasource.id, state);
210
+ var _pluginInjectionApi$c;
211
+ 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);
211
212
  } else {
212
213
  var inlineCard = state.schema.nodes.inlineCard;
213
214
  var toolbarItems = [{
@@ -275,7 +276,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
275
276
  type: 'custom',
276
277
  fallback: [],
277
278
  render: function render(editorView) {
278
- var _pluginInjectionApi$c;
279
+ var _pluginInjectionApi$c2;
279
280
  return /*#__PURE__*/React.createElement(LinkToolbarAppearance, {
280
281
  key: "link-appearance",
281
282
  url: url,
@@ -287,7 +288,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
287
288
  allowBlockCards: allowBlockCards,
288
289
  platform: platform,
289
290
  editorAnalyticsApi: editorAnalyticsApi,
290
- cardActions: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.card) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions,
291
+ cardActions: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.card) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.actions,
291
292
  showUpgradeDiscoverability: showUpgradeDiscoverability
292
293
  });
293
294
  }
@@ -350,7 +351,7 @@ var getSettingsButtonGroup = function getSettingsButtonGroup(intl, editorAnalyti
350
351
  type: 'separator'
351
352
  }];
352
353
  };
353
- var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state) {
354
+ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state, cardOptions, currentAppearance, platform, cardActions) {
354
355
  var _node$attrs3;
355
356
  var toolbarItems = [];
356
357
  if (isDatasourceConfigEditable(datasourceId)) {
@@ -367,6 +368,50 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
367
368
  type: 'separator'
368
369
  });
369
370
  }
371
+
372
+ // Smart card view buttons only allowed for non-config datasources
373
+ if (getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar') && !isDatasourceConfigEditable(datasourceId) && cardOptions) {
374
+ var allowBlockCards = cardOptions.allowBlockCards,
375
+ allowEmbeds = cardOptions.allowEmbeds,
376
+ showUpgradeDiscoverability = cardOptions.showUpgradeDiscoverability;
377
+ var url = metadata.url;
378
+ toolbarItems.push({
379
+ type: 'custom',
380
+ fallback: [],
381
+ render: function render(editorView) {
382
+ return /*#__PURE__*/React.createElement(LinkToolbarAppearance, {
383
+ key: "link-appearance",
384
+ url: url,
385
+ intl: intl,
386
+ currentAppearance: currentAppearance,
387
+ editorView: editorView,
388
+ editorState: state,
389
+ allowEmbeds: allowEmbeds,
390
+ allowBlockCards: allowBlockCards,
391
+ platform: platform,
392
+ editorAnalyticsApi: editorAnalyticsApi,
393
+ cardActions: cardActions,
394
+ showUpgradeDiscoverability: showUpgradeDiscoverability,
395
+ isDatasourceView: true
396
+ });
397
+ }
398
+ }, {
399
+ type: 'custom',
400
+ fallback: [],
401
+ render: function render(editorView) {
402
+ return /*#__PURE__*/React.createElement(DatasourceAppearanceButton, {
403
+ intl: intl,
404
+ editorAnalyticsApi: editorAnalyticsApi,
405
+ url: url,
406
+ editorView: editorView,
407
+ editorState: state,
408
+ selected: true
409
+ });
410
+ }
411
+ }, {
412
+ type: 'separator'
413
+ });
414
+ }
370
415
  if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
371
416
  toolbarItems.push({
372
417
  id: 'editor.link.openLink',
@@ -19,7 +19,8 @@ var DatasourceAppearanceButtonWithCardContext = function DatasourceAppearanceBut
19
19
  intl = _ref.intl,
20
20
  url = _ref.url,
21
21
  editorView = _ref.editorView,
22
- editorState = _ref.editorState;
22
+ editorState = _ref.editorState,
23
+ selected = _ref.selected;
23
24
  var _useFetchDatasourceIn = useFetchDatasourceInfo({
24
25
  isRegularCardNode: true,
25
26
  url: url,
@@ -61,7 +62,7 @@ var DatasourceAppearanceButtonWithCardContext = function DatasourceAppearanceBut
61
62
  icon: jsx(TableIcon, {
62
63
  label: buttonLabel
63
64
  }),
64
- selected: false,
65
+ selected: selected,
65
66
  onClick: onChangeAppearance,
66
67
  testId: 'card-datasource-appearance-button'
67
68
  }));
@@ -71,7 +72,8 @@ export var DatasourceAppearanceButton = function DatasourceAppearanceButton(_ref
71
72
  editorAnalyticsApi = _ref2.editorAnalyticsApi,
72
73
  url = _ref2.url,
73
74
  editorView = _ref2.editorView,
74
- editorState = _ref2.editorState;
75
+ editorState = _ref2.editorState,
76
+ selected = _ref2.selected;
75
77
  return jsx(CardContextProvider, null, function (_ref3) {
76
78
  var cardContext = _ref3.cardContext;
77
79
  return jsx(DatasourceAppearanceButtonWithCardContext, {
@@ -80,7 +82,8 @@ export var DatasourceAppearanceButton = function DatasourceAppearanceButton(_ref
80
82
  editorAnalyticsApi: editorAnalyticsApi,
81
83
  editorView: editorView,
82
84
  editorState: editorState,
83
- cardContext: cardContext
85
+ cardContext: cardContext,
86
+ selected: selected
84
87
  });
85
88
  });
86
89
  };
@@ -46,7 +46,8 @@ export var LinkToolbarAppearance = /*#__PURE__*/function (_React$Component) {
46
46
  editorAnalyticsApi = _this$props.editorAnalyticsApi,
47
47
  cardActions = _this$props.cardActions,
48
48
  _this$props$showUpgra = _this$props.showUpgradeDiscoverability,
49
- showUpgradeDiscoverability = _this$props$showUpgra === void 0 ? true : _this$props$showUpgra;
49
+ showUpgradeDiscoverability = _this$props$showUpgra === void 0 ? true : _this$props$showUpgra,
50
+ isDatasourceView = _this$props.isDatasourceView;
50
51
  var preview = allowEmbeds && cardContext && url && cardContext.extractors.getPreview(url, platform);
51
52
  var defaultCommand = function defaultCommand() {
52
53
  return false;
@@ -74,7 +75,7 @@ export var LinkToolbarAppearance = /*#__PURE__*/function (_React$Component) {
74
75
  appearance: 'block',
75
76
  title: intl.formatMessage(messages.block),
76
77
  onClick: (_cardActions$setSelec2 = cardActions === null || cardActions === void 0 ? void 0 : cardActions.setSelectedCardAppearance('block', editorAnalyticsApi)) !== null && _cardActions$setSelec2 !== void 0 ? _cardActions$setSelec2 : defaultCommand,
77
- selected: currentAppearance === 'block',
78
+ selected: currentAppearance === 'block' && !isDatasourceView,
78
79
  testId: 'block-appearance',
79
80
  disabled: !isBlockCardLinkSupportedInParent,
80
81
  tooltip: isBlockCardLinkSupportedInParent ? undefined : getUnavailableMessage(editorState, intl)
@@ -84,7 +85,7 @@ export var LinkToolbarAppearance = /*#__PURE__*/function (_React$Component) {
84
85
  onClick: commandWithMetadata((_cardActions$changeSe = cardActions === null || cardActions === void 0 ? void 0 : cardActions.changeSelectedCardToLink(url, url, true, undefined, undefined, editorAnalyticsApi)) !== null && _cardActions$changeSe !== void 0 ? _cardActions$changeSe : defaultCommand, {
85
86
  action: ACTION.CHANGED_TYPE
86
87
  }),
87
- selected: !currentAppearance,
88
+ selected: !currentAppearance && !isDatasourceView,
88
89
  testId: 'url-appearance'
89
90
  }, {
90
91
  appearance: 'inline',
@@ -8,7 +8,7 @@ import type { getPosHandler, ReactComponentProps } from '@atlaskit/editor-common
8
8
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
9
9
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
10
10
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
11
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
11
+ import type { Decoration, DecorationSource, EditorView } from '@atlaskit/editor-prosemirror/view';
12
12
  import type { cardPlugin } from '../index';
13
13
  export interface DatasourceProps extends ReactComponentProps {
14
14
  node: PMNode;
@@ -42,6 +42,8 @@ export declare class Datasource extends ReactNodeView<DatasourceProps> {
42
42
  private tableWidth;
43
43
  private isNodeNested;
44
44
  constructor(props: DatasourceProps);
45
+ validUpdate(currentNode: PMNode, newNode: PMNode): boolean;
46
+ update(node: PMNode, decorations: ReadonlyArray<Decoration>, _innerDecorations?: DecorationSource, validUpdate?: (currentNode: PMNode, newNode: PMNode) => boolean): boolean;
45
47
  createDomRef(): HTMLElement;
46
48
  render(): jsx.JSX.Element;
47
49
  }
@@ -25,3 +25,7 @@ export type LinkNodes = {
25
25
  export declare const getLinkNodeType: (appearance: CardAppearance, linkNodes: LinkNodes) => NodeType;
26
26
  export declare const updateCardViaDatasource: (state: EditorState, node: Node, newAdf: DatasourceAdf | InlineCardAdf, view: EditorView, sourceEvent?: UIAnalyticsEvent) => void;
27
27
  export declare const insertDatasource: (state: EditorState, adf: DatasourceAdf | InlineCardAdf, view: EditorView, sourceEvent?: UIAnalyticsEvent) => void;
28
+ /**
29
+ * Get attributes for new Card Appearance
30
+ */
31
+ export declare const getAttrsForAppearance: (appearance: CardAppearance, selectedNode: Node) => import("prosemirror-model").Attrs;
@@ -11,5 +11,6 @@ export interface DatasourceAppearanceButtonProps {
11
11
  editorView?: EditorView;
12
12
  editorState: EditorState;
13
13
  cardContext?: CardContext;
14
+ selected?: boolean;
14
15
  }
15
- export declare const DatasourceAppearanceButton: ({ intl, editorAnalyticsApi, url, editorView, editorState, }: DatasourceAppearanceButtonProps) => jsx.JSX.Element;
16
+ export declare const DatasourceAppearanceButton: ({ intl, editorAnalyticsApi, url, editorView, editorState, selected, }: DatasourceAppearanceButtonProps) => jsx.JSX.Element;
@@ -20,6 +20,7 @@ export interface LinkToolbarAppearanceProps {
20
20
  platform?: CardPlatform;
21
21
  cardActions: CardPluginActions | undefined;
22
22
  showUpgradeDiscoverability?: boolean;
23
+ isDatasourceView?: boolean;
23
24
  }
24
25
  export declare class LinkToolbarAppearance extends React.Component<LinkToolbarAppearanceProps, {}> {
25
26
  static contextTypes: {
@@ -8,7 +8,7 @@ import type { getPosHandler, ReactComponentProps } from '@atlaskit/editor-common
8
8
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
9
9
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
10
10
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
11
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
11
+ import type { Decoration, DecorationSource, EditorView } from '@atlaskit/editor-prosemirror/view';
12
12
  import type { cardPlugin } from '../index';
13
13
  export interface DatasourceProps extends ReactComponentProps {
14
14
  node: PMNode;
@@ -42,6 +42,8 @@ export declare class Datasource extends ReactNodeView<DatasourceProps> {
42
42
  private tableWidth;
43
43
  private isNodeNested;
44
44
  constructor(props: DatasourceProps);
45
+ validUpdate(currentNode: PMNode, newNode: PMNode): boolean;
46
+ update(node: PMNode, decorations: ReadonlyArray<Decoration>, _innerDecorations?: DecorationSource, validUpdate?: (currentNode: PMNode, newNode: PMNode) => boolean): boolean;
45
47
  createDomRef(): HTMLElement;
46
48
  render(): jsx.JSX.Element;
47
49
  }
@@ -25,3 +25,7 @@ export type LinkNodes = {
25
25
  export declare const getLinkNodeType: (appearance: CardAppearance, linkNodes: LinkNodes) => NodeType;
26
26
  export declare const updateCardViaDatasource: (state: EditorState, node: Node, newAdf: DatasourceAdf | InlineCardAdf, view: EditorView, sourceEvent?: UIAnalyticsEvent) => void;
27
27
  export declare const insertDatasource: (state: EditorState, adf: DatasourceAdf | InlineCardAdf, view: EditorView, sourceEvent?: UIAnalyticsEvent) => void;
28
+ /**
29
+ * Get attributes for new Card Appearance
30
+ */
31
+ export declare const getAttrsForAppearance: (appearance: CardAppearance, selectedNode: Node) => import("prosemirror-model").Attrs;
@@ -11,5 +11,6 @@ export interface DatasourceAppearanceButtonProps {
11
11
  editorView?: EditorView;
12
12
  editorState: EditorState;
13
13
  cardContext?: CardContext;
14
+ selected?: boolean;
14
15
  }
15
- export declare const DatasourceAppearanceButton: ({ intl, editorAnalyticsApi, url, editorView, editorState, }: DatasourceAppearanceButtonProps) => jsx.JSX.Element;
16
+ export declare const DatasourceAppearanceButton: ({ intl, editorAnalyticsApi, url, editorView, editorState, selected, }: DatasourceAppearanceButtonProps) => jsx.JSX.Element;
@@ -20,6 +20,7 @@ export interface LinkToolbarAppearanceProps {
20
20
  platform?: CardPlatform;
21
21
  cardActions: CardPluginActions | undefined;
22
22
  showUpgradeDiscoverability?: boolean;
23
+ isDatasourceView?: boolean;
23
24
  }
24
25
  export declare class LinkToolbarAppearance extends React.Component<LinkToolbarAppearanceProps, {}> {
25
26
  static contextTypes: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -35,11 +35,11 @@
35
35
  "@atlaskit/adf-schema": "^35.5.1",
36
36
  "@atlaskit/analytics-next": "^9.2.0",
37
37
  "@atlaskit/custom-steps": "^0.0.13",
38
- "@atlaskit/editor-common": "^77.4.0",
38
+ "@atlaskit/editor-common": "^78.0.0",
39
39
  "@atlaskit/editor-plugin-analytics": "^1.0.0",
40
40
  "@atlaskit/editor-plugin-decorations": "^1.0.0",
41
41
  "@atlaskit/editor-plugin-feature-flags": "^1.0.0",
42
- "@atlaskit/editor-plugin-floating-toolbar": "^1.0.0",
42
+ "@atlaskit/editor-plugin-floating-toolbar": "^1.1.0",
43
43
  "@atlaskit/editor-plugin-grid": "^1.0.0",
44
44
  "@atlaskit/editor-plugin-hyperlink": "^1.0.0",
45
45
  "@atlaskit/editor-plugin-width": "^1.0.0",
@@ -56,7 +56,7 @@
56
56
  "@atlaskit/primitives": "^2.0.0",
57
57
  "@atlaskit/smart-card": "^26.47.0",
58
58
  "@atlaskit/theme": "^12.6.0",
59
- "@atlaskit/tokens": "^1.36.0",
59
+ "@atlaskit/tokens": "^1.37.0",
60
60
  "@babel/runtime": "^7.0.0",
61
61
  "@emotion/react": "^11.7.1",
62
62
  "lodash": "^4.17.21",