@atlaskit/editor-plugin-card 1.7.0 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/nodeviews/blockCard.js +9 -5
  3. package/dist/cjs/nodeviews/embedCard.js +7 -5
  4. package/dist/cjs/nodeviews/genericCard.js +58 -9
  5. package/dist/cjs/nodeviews/inlineCard.js +10 -6
  6. package/dist/cjs/nodeviews/inlineCardWithAwareness.js +4 -3
  7. package/dist/cjs/pm-plugins/main.js +9 -4
  8. package/dist/cjs/toolbar.js +4 -0
  9. package/dist/es2019/nodeviews/blockCard.js +9 -5
  10. package/dist/es2019/nodeviews/embedCard.js +7 -5
  11. package/dist/es2019/nodeviews/genericCard.js +50 -3
  12. package/dist/es2019/nodeviews/inlineCard.js +10 -6
  13. package/dist/es2019/nodeviews/inlineCardWithAwareness.js +4 -3
  14. package/dist/es2019/pm-plugins/main.js +9 -4
  15. package/dist/es2019/toolbar.js +4 -0
  16. package/dist/esm/nodeviews/blockCard.js +9 -5
  17. package/dist/esm/nodeviews/embedCard.js +7 -5
  18. package/dist/esm/nodeviews/genericCard.js +55 -9
  19. package/dist/esm/nodeviews/inlineCard.js +10 -6
  20. package/dist/esm/nodeviews/inlineCardWithAwareness.js +4 -3
  21. package/dist/esm/pm-plugins/main.js +9 -4
  22. package/dist/esm/toolbar.js +4 -0
  23. package/dist/types/nodeviews/blockCard.d.ts +1 -2
  24. package/dist/types/nodeviews/embedCard.d.ts +1 -2
  25. package/dist/types/nodeviews/genericCard.d.ts +6 -1
  26. package/dist/types/nodeviews/inlineCard.d.ts +1 -2
  27. package/dist/types/nodeviews/inlineCardWithAwareness.d.ts +1 -1
  28. package/dist/types/plugin.d.ts +2 -0
  29. package/dist/types/types.d.ts +2 -1
  30. package/dist/types-ts4.5/nodeviews/blockCard.d.ts +1 -2
  31. package/dist/types-ts4.5/nodeviews/embedCard.d.ts +1 -2
  32. package/dist/types-ts4.5/nodeviews/genericCard.d.ts +6 -1
  33. package/dist/types-ts4.5/nodeviews/inlineCard.d.ts +1 -2
  34. package/dist/types-ts4.5/nodeviews/inlineCardWithAwareness.d.ts +1 -1
  35. package/dist/types-ts4.5/plugin.d.ts +2 -0
  36. package/dist/types-ts4.5/types.d.ts +2 -1
  37. package/package.json +10 -6
@@ -43,7 +43,8 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
43
43
  cardPluginEvents,
44
44
  showUpgradeDiscoverability,
45
45
  allowEmbeds,
46
- allowBlockCards
46
+ allowBlockCards,
47
+ onClickCallback
47
48
  } = options;
48
49
  const enableInlineUpgradeFeatures = !!showUpgradeDiscoverability && platform !== 'mobile';
49
50
  const shouldUseUpgradeFeatures = getBooleanFF('platform.linking-platform.smart-card.inline-switcher') && enableInlineUpgradeFeatures;
@@ -57,7 +58,8 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
57
58
  enableInlineUpgradeFeatures,
58
59
  allowEmbeds,
59
60
  allowBlockCards,
60
- pluginInjectionApi
61
+ pluginInjectionApi,
62
+ onClickCallback
61
63
  }
62
64
  });
63
65
  return new SafePlugin({
@@ -226,7 +228,9 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
226
228
  const reactComponentProps = {
227
229
  platform,
228
230
  actionOptions,
229
- showServerActions
231
+ showServerActions,
232
+ pluginInjectionApi,
233
+ onClickCallback: options.onClickCallback
230
234
  };
231
235
  const hasIntlContext = true;
232
236
  const isDatasource = !!(node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.datasource);
@@ -266,7 +270,8 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
266
270
  dispatchAnalyticsEvent,
267
271
  pluginInjectionApi,
268
272
  actionOptions,
269
- showServerActions
273
+ showServerActions,
274
+ onClickCallback: options.onClickCallback
270
275
  };
271
276
  const hasIntlContext = true;
272
277
  return new EmbedCard(node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, undefined, true, undefined, hasIntlContext).init();
@@ -389,6 +389,10 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
389
389
  });
390
390
  }
391
391
  const canShowMainToolbar = () => {
392
+ // we do not show smart-link or the datasource icons when the node does not have a url to resolve
393
+ if (!metadata.url) {
394
+ return false;
395
+ }
392
396
  if (
393
397
  // FF that controls visibily of the additional toolbar buttons
394
398
  !getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar')) {
@@ -29,7 +29,6 @@ export var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
29
29
  args[_key] = arguments[_key];
30
30
  }
31
31
  _this = _super.call.apply(_super, [this].concat(args));
32
- _defineProperty(_assertThisInitialized(_this), "onClick", function () {});
33
32
  _defineProperty(_assertThisInitialized(_this), "onResolve", function (data) {
34
33
  var _this$props = _this.props,
35
34
  getPos = _this$props.getPos,
@@ -90,7 +89,8 @@ export var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
90
89
  cardContext = _this$props2.cardContext,
91
90
  platform = _this$props2.platform,
92
91
  actionOptions = _this$props2.actionOptions,
93
- showServerActions = _this$props2.showServerActions;
92
+ showServerActions = _this$props2.showServerActions,
93
+ onClick = _this$props2.onClick;
94
94
  var _node$attrs = node.attrs,
95
95
  url = _node$attrs.url,
96
96
  data = _node$attrs.data;
@@ -100,7 +100,7 @@ export var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
100
100
  data: data,
101
101
  container: this.scrollContainer,
102
102
  appearance: "block",
103
- onClick: this.onClick,
103
+ onClick: onClick,
104
104
  onResolve: this.onResolve,
105
105
  onError: this.onError,
106
106
  platform: platform,
@@ -164,14 +164,18 @@ export var BlockCard = /*#__PURE__*/function (_ReactNodeView) {
164
164
  var _this$reactComponentP = this.reactComponentProps,
165
165
  platform = _this$reactComponentP.platform,
166
166
  actionOptions = _this$reactComponentP.actionOptions,
167
- showServerActions = _this$reactComponentP.showServerActions;
167
+ showServerActions = _this$reactComponentP.showServerActions,
168
+ pluginInjectionApi = _this$reactComponentP.pluginInjectionApi,
169
+ onClickCallback = _this$reactComponentP.onClickCallback;
168
170
  return /*#__PURE__*/React.createElement(WrappedBlockCard, {
169
171
  node: this.node,
170
172
  view: this.view,
171
173
  getPos: this.getPos,
172
174
  platform: platform,
173
175
  actionOptions: actionOptions,
174
- showServerActions: showServerActions
176
+ showServerActions: showServerActions,
177
+ pluginInjectionApi: pluginInjectionApi,
178
+ onClickCallback: onClickCallback
175
179
  });
176
180
  }
177
181
  }]);
@@ -104,7 +104,6 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
104
104
  }
105
105
  _this = _super.call.apply(_super, [this].concat(args));
106
106
  _defineProperty(_assertThisInitialized(_this), "embedIframeRef", /*#__PURE__*/React.createRef());
107
- _defineProperty(_assertThisInitialized(_this), "onClick", function () {});
108
107
  _defineProperty(_assertThisInitialized(_this), "state", {
109
108
  hasPreview: true
110
109
  });
@@ -265,7 +264,8 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
265
264
  getPos = _this$props.getPos,
266
265
  pluginInjectionApi = _this$props.pluginInjectionApi,
267
266
  actionOptions = _this$props.actionOptions,
268
- showServerActions = _this$props.showServerActions;
267
+ showServerActions = _this$props.showServerActions,
268
+ onClick = _this$props.onClick;
269
269
  var _node$attrs = node.attrs,
270
270
  url = _node$attrs.url,
271
271
  pctWidth = _node$attrs.width,
@@ -296,7 +296,7 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
296
296
  key: url,
297
297
  url: url,
298
298
  appearance: "embed",
299
- onClick: this.onClick,
299
+ onClick: onClick,
300
300
  onResolve: this.onResolve,
301
301
  onError: this.onError,
302
302
  frameStyle: "show",
@@ -382,7 +382,8 @@ export var EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
382
382
  platform = _this$reactComponentP.platform,
383
383
  fullWidthMode = _this$reactComponentP.fullWidthMode,
384
384
  dispatchAnalyticsEvent = _this$reactComponentP.dispatchAnalyticsEvent,
385
- pluginInjectionApi = _this$reactComponentP.pluginInjectionApi;
385
+ pluginInjectionApi = _this$reactComponentP.pluginInjectionApi,
386
+ onClickCallback = _this$reactComponentP.onClickCallback;
386
387
  return /*#__PURE__*/React.createElement(WrappedBlockCard, {
387
388
  node: this.node,
388
389
  view: this.view,
@@ -392,7 +393,8 @@ export var EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
392
393
  platform: platform,
393
394
  fullWidthMode: fullWidthMode,
394
395
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
395
- pluginInjectionApi: pluginInjectionApi
396
+ pluginInjectionApi: pluginInjectionApi,
397
+ onClickCallback: onClickCallback
396
398
  });
397
399
  }
398
400
  }]);
@@ -8,14 +8,41 @@ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
8
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
9
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10
10
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
11
- import React from 'react';
11
+ import React, { useCallback } from 'react';
12
12
  import PropTypes from 'prop-types';
13
13
  import { isSafeUrl } from '@atlaskit/adf-schema';
14
14
  import { AnalyticsContext } from '@atlaskit/analytics-next';
15
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
15
16
  import { getAnalyticsEditorAppearance } from '@atlaskit/editor-common/utils';
17
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
16
18
  import { changeSelectedCardToLinkFallback } from '../pm-plugins/doc';
17
19
  import { getPluginState } from '../pm-plugins/util/state';
18
20
  import { titleUrlPairFromNode } from '../utils';
21
+ var WithClickHandler = function WithClickHandler(_ref) {
22
+ var pluginInjectionApi = _ref.pluginInjectionApi,
23
+ url = _ref.url,
24
+ onClickCallback = _ref.onClickCallback,
25
+ children = _ref.children;
26
+ var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['editorViewMode']),
27
+ editorViewModeState = _useSharedPluginState.editorViewModeState;
28
+ var onClick = useCallback(function (event) {
29
+ if (typeof onClickCallback === 'function') {
30
+ try {
31
+ onClickCallback({
32
+ event: event,
33
+ url: url
34
+ });
35
+ } catch (_unused) {}
36
+ }
37
+ }, [url, onClickCallback]);
38
+
39
+ // Setting `onClick` to `undefined` ensures clicks on smartcards navigate to the URL.
40
+ // If in view mode and not overriding with onClickCallback option, then allow smartlinks to navigate on click.
41
+ var allowNavigation = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' && !onClickCallback;
42
+ return /*#__PURE__*/React.createElement(React.Fragment, null, children({
43
+ onClick: allowNavigation ? undefined : onClick
44
+ }));
45
+ };
19
46
  export function Card(SmartCardComponent, UnsupportedComponent) {
20
47
  var _class;
21
48
  return _class = /*#__PURE__*/function (_React$Component) {
@@ -31,12 +58,17 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
31
58
  _defineProperty(_assertThisInitialized(_this), "state", {
32
59
  isError: false
33
60
  });
61
+ _defineProperty(_assertThisInitialized(_this), "onClick", function () {});
34
62
  return _this;
35
63
  }
36
64
  _createClass(_class, [{
37
65
  key: "render",
38
66
  value: function render() {
39
- var _getPluginState;
67
+ var _getPluginState,
68
+ _this2 = this;
69
+ var _this$props = this.props,
70
+ pluginInjectionApi = _this$props.pluginInjectionApi,
71
+ onClickCallback = _this$props.onClickCallback;
40
72
  var _titleUrlPairFromNode = titleUrlPairFromNode(this.props.node),
41
73
  url = _titleUrlPairFromNode.url;
42
74
  if (url && !isSafeUrl(url)) {
@@ -65,10 +97,24 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
65
97
  // Below is added for the future implementation of Linking Platform namespaced analytics context
66
98
  location: analyticsEditorAppearance
67
99
  }
68
- }, /*#__PURE__*/React.createElement(SmartCardComponent, _extends({
100
+ }, getBooleanFF('platform.linking-platform.smart-card.on-click-callback') ? /*#__PURE__*/React.createElement(WithClickHandler, {
101
+ pluginInjectionApi: pluginInjectionApi,
102
+ onClickCallback: onClickCallback,
103
+ url: url
104
+ }, function (_ref2) {
105
+ var onClick = _ref2.onClick;
106
+ return /*#__PURE__*/React.createElement(SmartCardComponent, _extends({
107
+ key: url,
108
+ cardContext: cardContext
109
+ }, _this2.props, {
110
+ onClick: onClick
111
+ }));
112
+ }) : /*#__PURE__*/React.createElement(SmartCardComponent, _extends({
69
113
  key: url,
70
114
  cardContext: cardContext
71
- }, this.props)));
115
+ }, this.props, {
116
+ onClick: this.onClick
117
+ })));
72
118
  }
73
119
  }, {
74
120
  key: "componentDidCatch",
@@ -84,11 +130,11 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
84
130
  this.setState({
85
131
  isError: true
86
132
  });
87
- var _this$props = this.props,
88
- view = _this$props.view,
89
- node = _this$props.node,
90
- getPos = _this$props.getPos,
91
- pluginInjectionApi = _this$props.pluginInjectionApi;
133
+ var _this$props2 = this.props,
134
+ view = _this$props2.view,
135
+ node = _this$props2.node,
136
+ getPos = _this$props2.getPos,
137
+ pluginInjectionApi = _this$props2.pluginInjectionApi;
92
138
  var _titleUrlPairFromNode2 = titleUrlPairFromNode(node),
93
139
  url = _titleUrlPairFromNode2.url;
94
140
  if (!getPos || typeof getPos === 'boolean') {
@@ -31,7 +31,6 @@ export var InlineCardComponent = /*#__PURE__*/function (_React$PureComponent) {
31
31
  args[_key] = arguments[_key];
32
32
  }
33
33
  _this = _super.call.apply(_super, [this].concat(args));
34
- _defineProperty(_assertThisInitialized(_this), "onClick", function () {});
35
34
  _defineProperty(_assertThisInitialized(_this), "onResolve", function (data) {
36
35
  var _this$props = _this.props,
37
36
  getPos = _this$props.getPos,
@@ -85,7 +84,8 @@ export var InlineCardComponent = /*#__PURE__*/function (_React$PureComponent) {
85
84
  cardContext = _this$props2.cardContext,
86
85
  actionOptions = _this$props2.actionOptions,
87
86
  showServerActions = _this$props2.showServerActions,
88
- useAlternativePreloader = _this$props2.useAlternativePreloader;
87
+ useAlternativePreloader = _this$props2.useAlternativePreloader,
88
+ onClick = _this$props2.onClick;
89
89
  var _node$attrs = node.attrs,
90
90
  url = _node$attrs.url,
91
91
  data = _node$attrs.data;
@@ -96,7 +96,7 @@ export var InlineCardComponent = /*#__PURE__*/function (_React$PureComponent) {
96
96
  url: url,
97
97
  data: data,
98
98
  appearance: "inline",
99
- onClick: this.onClick,
99
+ onClick: onClick,
100
100
  container: this.scrollContainer,
101
101
  onResolve: this.onResolve,
102
102
  onError: this.onError,
@@ -128,7 +128,8 @@ export function InlineCardNodeView(props) {
128
128
  allowEmbeds = props.allowEmbeds,
129
129
  allowBlockCards = props.allowBlockCards,
130
130
  enableInlineUpgradeFeatures = props.enableInlineUpgradeFeatures,
131
- pluginInjectionApi = props.pluginInjectionApi;
131
+ pluginInjectionApi = props.pluginInjectionApi,
132
+ onClickCallback = props.onClickCallback;
132
133
  if (!getBooleanFF('platform.linking-platform.smart-card.inline-switcher')) {
133
134
  return /*#__PURE__*/React.createElement(WrappedInlineCard, {
134
135
  node: node,
@@ -136,7 +137,9 @@ export function InlineCardNodeView(props) {
136
137
  getPos: getPos,
137
138
  actionOptions: actionOptions,
138
139
  showServerActions: showServerActions,
139
- useAlternativePreloader: useAlternativePreloader
140
+ useAlternativePreloader: useAlternativePreloader,
141
+ pluginInjectionApi: pluginInjectionApi,
142
+ onClickCallback: onClickCallback
140
143
  });
141
144
  }
142
145
  return /*#__PURE__*/React.createElement(WrappedInlineCardWithAwareness, _extends({
@@ -146,7 +149,8 @@ export function InlineCardNodeView(props) {
146
149
  actionOptions: actionOptions,
147
150
  showServerActions: showServerActions,
148
151
  useAlternativePreloader: useAlternativePreloader,
149
- pluginInjectionApi: pluginInjectionApi
152
+ pluginInjectionApi: pluginInjectionApi,
153
+ onClickCallback: onClickCallback
150
154
  }, enableInlineUpgradeFeatures && getAwarenessProps(view.state, getPos, allowEmbeds, allowBlockCards)));
151
155
  }
152
156
  var getAwarenessProps = function getAwarenessProps(editorState, getPos, allowEmbeds, allowBlockCards) {
@@ -17,7 +17,8 @@ var InlineCard = function InlineCard(_ref) {
17
17
  isPulseEnabled = _ref.isPulseEnabled,
18
18
  pluginInjectionApi = _ref.pluginInjectionApi,
19
19
  _ref$isSelected = _ref.isSelected,
20
- isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected;
20
+ isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
21
+ onClick = _ref.onClick;
21
22
  var _node$attrs = node.attrs,
22
23
  url = _node$attrs.url,
23
24
  data = _node$attrs.data;
@@ -95,7 +96,7 @@ var InlineCard = function InlineCard(_ref) {
95
96
  url: url,
96
97
  data: data,
97
98
  appearance: "inline",
98
- onClick: function onClick() {},
99
+ onClick: onClick,
99
100
  container: scrollContainer,
100
101
  onResolve: onResolve,
101
102
  onError: onError,
@@ -104,7 +105,7 @@ var InlineCard = function InlineCard(_ref) {
104
105
  showServerActions: showServerActions,
105
106
  isHovered: isHovered
106
107
  });
107
- }, [data, isHovered, onError, onResolve, scrollContainer, url, useAlternativePreloader, actionOptions, showServerActions]);
108
+ }, [data, isHovered, onError, onResolve, scrollContainer, url, useAlternativePreloader, actionOptions, showServerActions, onClick]);
108
109
  var card = useMemo(function () {
109
110
  return isOverlayEnabled || isPulseEnabled ? /*#__PURE__*/React.createElement(AwarenessWrapper, {
110
111
  isOverlayEnabled: isOverlayEnabled,
@@ -47,7 +47,8 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
47
47
  cardPluginEvents = options.cardPluginEvents,
48
48
  showUpgradeDiscoverability = options.showUpgradeDiscoverability,
49
49
  allowEmbeds = options.allowEmbeds,
50
- allowBlockCards = options.allowBlockCards;
50
+ allowBlockCards = options.allowBlockCards,
51
+ onClickCallback = options.onClickCallback;
51
52
  var enableInlineUpgradeFeatures = !!showUpgradeDiscoverability && platform !== 'mobile';
52
53
  var shouldUseUpgradeFeatures = getBooleanFF('platform.linking-platform.smart-card.inline-switcher') && enableInlineUpgradeFeatures;
53
54
  var inlineCardViewProducer = getInlineNodeViewProducer({
@@ -60,7 +61,8 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
60
61
  enableInlineUpgradeFeatures: enableInlineUpgradeFeatures,
61
62
  allowEmbeds: allowEmbeds,
62
63
  allowBlockCards: allowBlockCards,
63
- pluginInjectionApi: pluginInjectionApi
64
+ pluginInjectionApi: pluginInjectionApi,
65
+ onClickCallback: onClickCallback
64
66
  }
65
67
  });
66
68
  return new SafePlugin({
@@ -222,7 +224,9 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
222
224
  var reactComponentProps = {
223
225
  platform: platform,
224
226
  actionOptions: actionOptions,
225
- showServerActions: showServerActions
227
+ showServerActions: showServerActions,
228
+ pluginInjectionApi: pluginInjectionApi,
229
+ onClickCallback: options.onClickCallback
226
230
  };
227
231
  var hasIntlContext = true;
228
232
  var isDatasource = !!(node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.datasource);
@@ -260,7 +264,8 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
260
264
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
261
265
  pluginInjectionApi: pluginInjectionApi,
262
266
  actionOptions: actionOptions,
263
- showServerActions: showServerActions
267
+ showServerActions: showServerActions,
268
+ onClickCallback: options.onClickCallback
264
269
  };
265
270
  var hasIntlContext = true;
266
271
  return new EmbedCard(node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, undefined, true, undefined, hasIntlContext).init();
@@ -388,6 +388,10 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
388
388
  });
389
389
  }
390
390
  var canShowMainToolbar = function canShowMainToolbar() {
391
+ // we do not show smart-link or the datasource icons when the node does not have a url to resolve
392
+ if (!metadata.url) {
393
+ return false;
394
+ }
391
395
  if (
392
396
  // FF that controls visibily of the additional toolbar buttons
393
397
  !getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar')) {
@@ -6,7 +6,6 @@ import type { Decoration, DecorationSource } from '@atlaskit/editor-prosemirror/
6
6
  import type { SmartCardProps } from './genericCard';
7
7
  export declare class BlockCardComponent extends React.PureComponent<SmartCardProps> {
8
8
  private scrollContainer?;
9
- onClick: () => void;
10
9
  static contextTypes: {
11
10
  contextAdapter: PropTypes.Requireable<object>;
12
11
  };
@@ -21,7 +20,7 @@ export declare class BlockCardComponent extends React.PureComponent<SmartCardPro
21
20
  }) => void;
22
21
  render(): JSX.Element;
23
22
  }
24
- export type BlockCardNodeViewProps = Pick<SmartCardProps, 'platform' | 'actionOptions' | 'showServerActions'>;
23
+ export type BlockCardNodeViewProps = Pick<SmartCardProps, 'platform' | 'actionOptions' | 'showServerActions' | 'pluginInjectionApi' | 'onClickCallback'>;
25
24
  export declare class BlockCard extends ReactNodeView<BlockCardNodeViewProps> {
26
25
  createDomRef(): HTMLElement;
27
26
  validUpdate(currentNode: Node, newNode: Node): boolean;
@@ -13,7 +13,6 @@ export declare class EmbedCardComponent extends React.PureComponent<SmartCardPro
13
13
  private scrollContainer?;
14
14
  private embedIframeRef;
15
15
  context: any;
16
- onClick: () => void;
17
16
  static contextTypes: {
18
17
  contextAdapter: PropTypes.Requireable<object>;
19
18
  };
@@ -39,7 +38,7 @@ export declare class EmbedCardComponent extends React.PureComponent<SmartCardPro
39
38
  }) => void;
40
39
  render(): JSX.Element;
41
40
  }
42
- export type EmbedCardNodeViewProps = Pick<SmartCardProps, 'eventDispatcher' | 'allowResizing' | 'platform' | 'fullWidthMode' | 'dispatchAnalyticsEvent' | 'pluginInjectionApi' | 'actionOptions' | 'showServerActions'>;
41
+ export type EmbedCardNodeViewProps = Pick<SmartCardProps, 'eventDispatcher' | 'allowResizing' | 'platform' | 'fullWidthMode' | 'dispatchAnalyticsEvent' | 'pluginInjectionApi' | 'actionOptions' | 'showServerActions' | 'onClickCallback'>;
43
42
  export declare class EmbedCard extends ReactNodeView<EmbedCardNodeViewProps> {
44
43
  viewShouldUpdate(nextNode: PMNode): boolean;
45
44
  createDomRef(): HTMLElement;
@@ -1,12 +1,14 @@
1
1
  import React from 'react';
2
+ import type { EventHandler, KeyboardEvent, MouseEvent } from 'react';
2
3
  import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
4
+ import type { OnClickCallback } from '@atlaskit/editor-common/card';
3
5
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
4
6
  import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
5
7
  import type { getPosHandler, ReactComponentProps } from '@atlaskit/editor-common/react-node-view';
6
8
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
7
9
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
8
10
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
9
- import type { CardContext } from '@atlaskit/link-provider';
11
+ import { type CardContext } from '@atlaskit/link-provider';
10
12
  import type { CardProps as BaseCardProps, CardPlatform } from '@atlaskit/smart-card';
11
13
  import type { cardPlugin } from '../index';
12
14
  export type EditorContext<T> = React.Context<T> & {
@@ -40,8 +42,11 @@ export interface CardProps extends CardNodeViewProps {
40
42
  isPulseEnabled?: boolean;
41
43
  linkPosition?: number;
42
44
  isSelected?: boolean;
45
+ onClickCallback?: OnClickCallback;
43
46
  }
44
47
  export interface SmartCardProps extends CardProps {
48
+ pluginInjectionApi?: ExtractInjectionAPI<typeof cardPlugin>;
45
49
  cardContext?: EditorContext<CardContext | undefined>;
50
+ onClick?: EventHandler<MouseEvent | KeyboardEvent> | undefined;
46
51
  }
47
52
  export declare function Card(SmartCardComponent: React.ComponentType<React.PropsWithChildren<SmartCardProps>>, UnsupportedComponent: React.ComponentType<React.PropsWithChildren<unknown>>): React.ComponentType<React.PropsWithChildren<CardProps>>;
@@ -4,7 +4,6 @@ import type { InlineNodeViewComponentProps } from '@atlaskit/editor-common/react
4
4
  import type { SmartCardProps } from './genericCard';
5
5
  export declare class InlineCardComponent extends React.PureComponent<SmartCardProps> {
6
6
  private scrollContainer?;
7
- private onClick;
8
7
  static contextTypes: {
9
8
  contextAdapter: PropTypes.Requireable<object>;
10
9
  };
@@ -19,7 +18,7 @@ export declare class InlineCardComponent extends React.PureComponent<SmartCardPr
19
18
  }) => void;
20
19
  render(): JSX.Element | null;
21
20
  }
22
- export type InlineCardNodeViewProps = Pick<SmartCardProps, 'useAlternativePreloader' | 'actionOptions' | 'showServerActions' | 'allowEmbeds' | 'allowBlockCards' | 'enableInlineUpgradeFeatures' | 'pluginInjectionApi'>;
21
+ export type InlineCardNodeViewProps = Pick<SmartCardProps, 'useAlternativePreloader' | 'actionOptions' | 'showServerActions' | 'allowEmbeds' | 'allowBlockCards' | 'enableInlineUpgradeFeatures' | 'pluginInjectionApi' | 'onClickCallback'>;
23
22
  type InlineCardWithAwarenessProps = {
24
23
  allowEmbeds?: boolean;
25
24
  allowBlockCards?: boolean;
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import type { SmartCardProps } from './genericCard';
3
- export declare const InlineCardWithAwareness: React.MemoExoticComponent<({ node, cardContext, actionOptions, showServerActions, useAlternativePreloader, view, getPos, isOverlayEnabled, isPulseEnabled, pluginInjectionApi, isSelected, }: SmartCardProps) => JSX.Element | null>;
3
+ export declare const InlineCardWithAwareness: React.MemoExoticComponent<({ node, cardContext, actionOptions, showServerActions, useAlternativePreloader, view, getPos, isOverlayEnabled, isPulseEnabled, pluginInjectionApi, isSelected, onClick, }: SmartCardProps) => JSX.Element | null>;
@@ -2,6 +2,7 @@ import type { CardPluginActions } from '@atlaskit/editor-common/card';
2
2
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
3
3
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
4
  import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
5
+ import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
5
6
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
6
7
  import type { FloatingToolbarPlugin } from '@atlaskit/editor-plugin-floating-toolbar';
7
8
  import type { GridPlugin } from '@atlaskit/editor-plugin-grid';
@@ -13,6 +14,7 @@ export type CardPlugin = NextEditorPlugin<'card', {
13
14
  dependencies: [
14
15
  OptionalPlugin<FeatureFlagsPlugin>,
15
16
  OptionalPlugin<AnalyticsPlugin>,
17
+ OptionalPlugin<EditorViewModePlugin>,
16
18
  WidthPlugin,
17
19
  DecorationsPlugin,
18
20
  GridPlugin,
@@ -1,6 +1,6 @@
1
1
  import type { UIAnalyticsEvent } from '@atlaskit/analytics-next';
2
2
  import type { ACTION } from '@atlaskit/editor-common/analytics';
3
- import type { CardOptions, CardReplacementInputMethod } from '@atlaskit/editor-common/card';
3
+ import type { CardOptions, CardReplacementInputMethod, OnClickCallback } from '@atlaskit/editor-common/card';
4
4
  import type { CardAppearance, CardProvider } from '@atlaskit/editor-common/provider-factory';
5
5
  import type { DatasourceModalType, EditorAppearance, LinkPickerOptions } from '@atlaskit/editor-common/types';
6
6
  import type { DatasourceAdfView } from '@atlaskit/linking-common';
@@ -100,6 +100,7 @@ export type CardPluginOptions = CardOptions & {
100
100
  cardPluginEvents?: EditorCardPluginEvents<CardPluginEvent>;
101
101
  lpLinkPicker?: boolean;
102
102
  disableFloatingToolbar?: boolean;
103
+ onClickCallback?: OnClickCallback;
103
104
  };
104
105
  export type SetProvider = {
105
106
  type: 'SET_PROVIDER';
@@ -6,7 +6,6 @@ import type { Decoration, DecorationSource } from '@atlaskit/editor-prosemirror/
6
6
  import type { SmartCardProps } from './genericCard';
7
7
  export declare class BlockCardComponent extends React.PureComponent<SmartCardProps> {
8
8
  private scrollContainer?;
9
- onClick: () => void;
10
9
  static contextTypes: {
11
10
  contextAdapter: PropTypes.Requireable<object>;
12
11
  };
@@ -21,7 +20,7 @@ export declare class BlockCardComponent extends React.PureComponent<SmartCardPro
21
20
  }) => void;
22
21
  render(): JSX.Element;
23
22
  }
24
- export type BlockCardNodeViewProps = Pick<SmartCardProps, 'platform' | 'actionOptions' | 'showServerActions'>;
23
+ export type BlockCardNodeViewProps = Pick<SmartCardProps, 'platform' | 'actionOptions' | 'showServerActions' | 'pluginInjectionApi' | 'onClickCallback'>;
25
24
  export declare class BlockCard extends ReactNodeView<BlockCardNodeViewProps> {
26
25
  createDomRef(): HTMLElement;
27
26
  validUpdate(currentNode: Node, newNode: Node): boolean;
@@ -13,7 +13,6 @@ export declare class EmbedCardComponent extends React.PureComponent<SmartCardPro
13
13
  private scrollContainer?;
14
14
  private embedIframeRef;
15
15
  context: any;
16
- onClick: () => void;
17
16
  static contextTypes: {
18
17
  contextAdapter: PropTypes.Requireable<object>;
19
18
  };
@@ -39,7 +38,7 @@ export declare class EmbedCardComponent extends React.PureComponent<SmartCardPro
39
38
  }) => void;
40
39
  render(): JSX.Element;
41
40
  }
42
- export type EmbedCardNodeViewProps = Pick<SmartCardProps, 'eventDispatcher' | 'allowResizing' | 'platform' | 'fullWidthMode' | 'dispatchAnalyticsEvent' | 'pluginInjectionApi' | 'actionOptions' | 'showServerActions'>;
41
+ export type EmbedCardNodeViewProps = Pick<SmartCardProps, 'eventDispatcher' | 'allowResizing' | 'platform' | 'fullWidthMode' | 'dispatchAnalyticsEvent' | 'pluginInjectionApi' | 'actionOptions' | 'showServerActions' | 'onClickCallback'>;
43
42
  export declare class EmbedCard extends ReactNodeView<EmbedCardNodeViewProps> {
44
43
  viewShouldUpdate(nextNode: PMNode): boolean;
45
44
  createDomRef(): HTMLElement;
@@ -1,12 +1,14 @@
1
1
  import React from 'react';
2
+ import type { EventHandler, KeyboardEvent, MouseEvent } from 'react';
2
3
  import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
4
+ import type { OnClickCallback } from '@atlaskit/editor-common/card';
3
5
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
4
6
  import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
5
7
  import type { getPosHandler, ReactComponentProps } from '@atlaskit/editor-common/react-node-view';
6
8
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
7
9
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
8
10
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
9
- import type { CardContext } from '@atlaskit/link-provider';
11
+ import { type CardContext } from '@atlaskit/link-provider';
10
12
  import type { CardProps as BaseCardProps, CardPlatform } from '@atlaskit/smart-card';
11
13
  import type { cardPlugin } from '../index';
12
14
  export type EditorContext<T> = React.Context<T> & {
@@ -40,8 +42,11 @@ export interface CardProps extends CardNodeViewProps {
40
42
  isPulseEnabled?: boolean;
41
43
  linkPosition?: number;
42
44
  isSelected?: boolean;
45
+ onClickCallback?: OnClickCallback;
43
46
  }
44
47
  export interface SmartCardProps extends CardProps {
48
+ pluginInjectionApi?: ExtractInjectionAPI<typeof cardPlugin>;
45
49
  cardContext?: EditorContext<CardContext | undefined>;
50
+ onClick?: EventHandler<MouseEvent | KeyboardEvent> | undefined;
46
51
  }
47
52
  export declare function Card(SmartCardComponent: React.ComponentType<React.PropsWithChildren<SmartCardProps>>, UnsupportedComponent: React.ComponentType<React.PropsWithChildren<unknown>>): React.ComponentType<React.PropsWithChildren<CardProps>>;
@@ -4,7 +4,6 @@ import type { InlineNodeViewComponentProps } from '@atlaskit/editor-common/react
4
4
  import type { SmartCardProps } from './genericCard';
5
5
  export declare class InlineCardComponent extends React.PureComponent<SmartCardProps> {
6
6
  private scrollContainer?;
7
- private onClick;
8
7
  static contextTypes: {
9
8
  contextAdapter: PropTypes.Requireable<object>;
10
9
  };
@@ -19,7 +18,7 @@ export declare class InlineCardComponent extends React.PureComponent<SmartCardPr
19
18
  }) => void;
20
19
  render(): JSX.Element | null;
21
20
  }
22
- export type InlineCardNodeViewProps = Pick<SmartCardProps, 'useAlternativePreloader' | 'actionOptions' | 'showServerActions' | 'allowEmbeds' | 'allowBlockCards' | 'enableInlineUpgradeFeatures' | 'pluginInjectionApi'>;
21
+ export type InlineCardNodeViewProps = Pick<SmartCardProps, 'useAlternativePreloader' | 'actionOptions' | 'showServerActions' | 'allowEmbeds' | 'allowBlockCards' | 'enableInlineUpgradeFeatures' | 'pluginInjectionApi' | 'onClickCallback'>;
23
22
  type InlineCardWithAwarenessProps = {
24
23
  allowEmbeds?: boolean;
25
24
  allowBlockCards?: boolean;
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import type { SmartCardProps } from './genericCard';
3
- export declare const InlineCardWithAwareness: React.MemoExoticComponent<({ node, cardContext, actionOptions, showServerActions, useAlternativePreloader, view, getPos, isOverlayEnabled, isPulseEnabled, pluginInjectionApi, isSelected, }: SmartCardProps) => JSX.Element | null>;
3
+ export declare const InlineCardWithAwareness: React.MemoExoticComponent<({ node, cardContext, actionOptions, showServerActions, useAlternativePreloader, view, getPos, isOverlayEnabled, isPulseEnabled, pluginInjectionApi, isSelected, onClick, }: SmartCardProps) => JSX.Element | null>;
@@ -2,6 +2,7 @@ import type { CardPluginActions } from '@atlaskit/editor-common/card';
2
2
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
3
3
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
4
  import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
5
+ import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
5
6
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
6
7
  import type { FloatingToolbarPlugin } from '@atlaskit/editor-plugin-floating-toolbar';
7
8
  import type { GridPlugin } from '@atlaskit/editor-plugin-grid';
@@ -13,6 +14,7 @@ export type CardPlugin = NextEditorPlugin<'card', {
13
14
  dependencies: [
14
15
  OptionalPlugin<FeatureFlagsPlugin>,
15
16
  OptionalPlugin<AnalyticsPlugin>,
17
+ OptionalPlugin<EditorViewModePlugin>,
16
18
  WidthPlugin,
17
19
  DecorationsPlugin,
18
20
  GridPlugin,
@@ -1,6 +1,6 @@
1
1
  import type { UIAnalyticsEvent } from '@atlaskit/analytics-next';
2
2
  import type { ACTION } from '@atlaskit/editor-common/analytics';
3
- import type { CardOptions, CardReplacementInputMethod } from '@atlaskit/editor-common/card';
3
+ import type { CardOptions, CardReplacementInputMethod, OnClickCallback } from '@atlaskit/editor-common/card';
4
4
  import type { CardAppearance, CardProvider } from '@atlaskit/editor-common/provider-factory';
5
5
  import type { DatasourceModalType, EditorAppearance, LinkPickerOptions } from '@atlaskit/editor-common/types';
6
6
  import type { DatasourceAdfView } from '@atlaskit/linking-common';
@@ -100,6 +100,7 @@ export type CardPluginOptions = CardOptions & {
100
100
  cardPluginEvents?: EditorCardPluginEvents<CardPluginEvent>;
101
101
  lpLinkPicker?: boolean;
102
102
  disableFloatingToolbar?: boolean;
103
+ onClickCallback?: OnClickCallback;
103
104
  };
104
105
  export type SetProvider = {
105
106
  type: 'SET_PROVIDER';