@atlaskit/editor-plugin-card 2.3.7 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 2.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#117451](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/117451)
8
+ [`0ecc0082a92e6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0ecc0082a92e6) -
9
+ [ux] Enable hover cards for inline links in live pages behind ff
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
15
+ ## 2.3.8
16
+
17
+ ### Patch Changes
18
+
19
+ - [#117409](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/117409)
20
+ [`bf7f33f08064a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/bf7f33f08064a) -
21
+ Use the card provider passed directly to the card plugin to decouple it from editor-core.
22
+
3
23
  ## 2.3.7
4
24
 
5
25
  ### Patch Changes
@@ -10,6 +10,7 @@ exports.InlineCardNodeView = InlineCardNodeView;
10
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
11
  var _react = _interopRequireWildcard(require("react"));
12
12
  var _rafSchd = _interopRequireDefault(require("raf-schd"));
13
+ var _hooks = require("@atlaskit/editor-common/hooks");
13
14
  var _ui = require("@atlaskit/editor-common/ui");
14
15
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
15
16
  var _smartCard = require("@atlaskit/smart-card");
@@ -30,7 +31,9 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
30
31
  getPos = _ref.getPos,
31
32
  onClick = _ref.onClick,
32
33
  onRes = _ref.onResolve,
33
- isHovered = _ref.isHovered;
34
+ isHovered = _ref.isHovered,
35
+ showHoverPreview = _ref.showHoverPreview,
36
+ hoverPreviewOptions = _ref.hoverPreviewOptions;
34
37
  var _node$attrs = node.attrs,
35
38
  url = _node$attrs.url,
36
39
  data = _node$attrs.data;
@@ -84,9 +87,11 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
84
87
  inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
85
88
  actionOptions: actionOptions,
86
89
  showServerActions: showServerActions,
87
- isHovered: isHovered
90
+ isHovered: isHovered,
91
+ showHoverPreview: showHoverPreview,
92
+ hoverPreviewOptions: hoverPreviewOptions
88
93
  });
89
- }, [data, isHovered, onError, onResolve, scrollContainer, url, useAlternativePreloader, actionOptions, showServerActions, onClick]);
94
+ }, [url, data, onClick, scrollContainer, onResolve, onError, useAlternativePreloader, actionOptions, showServerActions, isHovered, showHoverPreview, hoverPreviewOptions]);
90
95
 
91
96
  // [WS-2307]: we only render card wrapped into a Provider when the value is ready,
92
97
  // otherwise if we got data, we can render the card directly since it doesn't need the Provider
@@ -97,6 +102,7 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
97
102
  var WrappedInlineCardWithAwareness = (0, _genericCard.Card)(_inlineCardWithAwareness.InlineCardWithAwareness, _ui.UnsupportedInline);
98
103
  var WrappedInlineCard = (0, _genericCard.Card)(InlineCard, _ui.UnsupportedInline);
99
104
  function InlineCardNodeView(props) {
105
+ var _useSharedPluginState;
100
106
  var useAlternativePreloader = props.useAlternativePreloader,
101
107
  node = props.node,
102
108
  view = props.view,
@@ -108,7 +114,10 @@ function InlineCardNodeView(props) {
108
114
  enableInlineUpgradeFeatures = props.enableInlineUpgradeFeatures,
109
115
  pluginInjectionApi = props.pluginInjectionApi,
110
116
  onClickCallback = props.onClickCallback;
117
+ var floatingToolbarNode = (_useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['floatingToolbar']).floatingToolbarState) === null || _useSharedPluginState === void 0 || (_useSharedPluginState = _useSharedPluginState.configWithNodeInfo) === null || _useSharedPluginState === void 0 ? void 0 : _useSharedPluginState.node;
111
118
  if ((0, _platformFeatureFlags.fg)('platform.linking-platform.smart-links-in-live-pages')) {
119
+ var showHoverPreview = floatingToolbarNode !== node;
120
+ var livePagesHoverCardFadeInDelay = 800;
112
121
  return /*#__PURE__*/_react.default.createElement(_ConfigureOverlay.default, {
113
122
  targetElementPos: getPos(),
114
123
  view: view
@@ -119,7 +128,11 @@ function InlineCardNodeView(props) {
119
128
  actionOptions: actionOptions,
120
129
  showServerActions: showServerActions,
121
130
  useAlternativePreloader: useAlternativePreloader,
122
- onClickCallback: onClickCallback
131
+ onClickCallback: onClickCallback,
132
+ showHoverPreview: showHoverPreview,
133
+ hoverPreviewOptions: {
134
+ fadeInDelay: livePagesHoverCardFadeInDelay
135
+ }
123
136
  }));
124
137
  }
125
138
  return /*#__PURE__*/_react.default.createElement(WrappedInlineCardWithAwareness, (0, _extends2.default)({
@@ -166,7 +166,11 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
166
166
  };
167
167
  var domAtPos = _view.domAtPos.bind(_view);
168
168
  var rafCancellationCallbacks = [];
169
- pmPluginFactoryParams.providerFactory.subscribe('cardProvider', subscriptionHandler);
169
+ if (options.provider && (0, _platformFeatureFlags.fg)('platform_editor_get_card_provider_from_config')) {
170
+ (0, _resolve.handleProvider)('cardProvider', options.provider, _view);
171
+ } else {
172
+ pmPluginFactoryParams.providerFactory.subscribe('cardProvider', subscriptionHandler);
173
+ }
170
174
  return {
171
175
  update: function update(view, prevState) {
172
176
  var _selection$node;
@@ -244,7 +248,9 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
244
248
  rafCancellationCallbacks.forEach(function (cancellationCallback) {
245
249
  return cancellationCallback();
246
250
  });
247
- pmPluginFactoryParams.providerFactory.unsubscribe('cardProvider', subscriptionHandler);
251
+ if (!(0, _platformFeatureFlags.fg)('platform_editor_get_card_provider_from_config')) {
252
+ pmPluginFactoryParams.providerFactory.unsubscribe('cardProvider', subscriptionHandler);
253
+ }
248
254
  }
249
255
  };
250
256
  },
@@ -42,15 +42,23 @@ var HyperlinkToolbarAppearance = exports.HyperlinkToolbarAppearance = /*#__PURE_
42
42
  supportedUrlsMap: new Map()
43
43
  });
44
44
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getProvider", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
45
+ var _this$props$cardOptio;
46
+ var _this$props$cardOptio2;
45
47
  return _regenerator.default.wrap(function _callee2$(_context2) {
46
48
  while (1) switch (_context2.prev = _context2.next) {
47
49
  case 0:
48
- if (!_this.cardProvider) {
50
+ if (!((_this$props$cardOptio = _this.props.cardOptions) !== null && _this$props$cardOptio !== void 0 && _this$props$cardOptio.provider && (0, _platformFeatureFlags.fg)('platform_editor_get_card_provider_from_config'))) {
49
51
  _context2.next = 2;
50
52
  break;
51
53
  }
52
- return _context2.abrupt("return", _this.cardProvider);
54
+ return _context2.abrupt("return", (_this$props$cardOptio2 = _this.props.cardOptions) === null || _this$props$cardOptio2 === void 0 ? void 0 : _this$props$cardOptio2.provider);
53
55
  case 2:
56
+ if (!_this.cardProvider) {
57
+ _context2.next = 4;
58
+ break;
59
+ }
60
+ return _context2.abrupt("return", _this.cardProvider);
61
+ case 4:
54
62
  return _context2.abrupt("return", new Promise(function (resolve) {
55
63
  var providerFactory = _this.props.providerFactory;
56
64
  providerFactory.subscribe('cardProvider', /*#__PURE__*/function () {
@@ -80,7 +88,7 @@ var HyperlinkToolbarAppearance = exports.HyperlinkToolbarAppearance = /*#__PURE_
80
88
  };
81
89
  }());
82
90
  }));
83
- case 3:
91
+ case 5:
84
92
  case "end":
85
93
  return _context2.stop();
86
94
  }
@@ -88,7 +96,7 @@ var HyperlinkToolbarAppearance = exports.HyperlinkToolbarAppearance = /*#__PURE_
88
96
  })));
89
97
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "resolveUrl", /*#__PURE__*/function () {
90
98
  var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(url) {
91
- var supportedUrlsMap, isUrlSupported, provider, newMap;
99
+ var supportedUrlsMap, isUrlSupported, _yield$provider$findP, provider, newMap;
92
100
  return _regenerator.default.wrap(function _callee3$(_context3) {
93
101
  while (1) switch (_context3.prev = _context3.next) {
94
102
  case 0:
@@ -106,26 +114,44 @@ var HyperlinkToolbarAppearance = exports.HyperlinkToolbarAppearance = /*#__PURE_
106
114
  case 7:
107
115
  provider = _context3.sent;
108
116
  _context3.next = 10;
109
- return provider.findPattern(url);
117
+ return provider === null || provider === void 0 ? void 0 : provider.findPattern(url);
110
118
  case 10:
111
- isUrlSupported = _context3.sent;
112
- _context3.next = 16;
119
+ _context3.t1 = _yield$provider$findP = _context3.sent;
120
+ _context3.t0 = _context3.t1 !== null;
121
+ if (!_context3.t0) {
122
+ _context3.next = 14;
123
+ break;
124
+ }
125
+ _context3.t0 = _yield$provider$findP !== void 0;
126
+ case 14:
127
+ if (!_context3.t0) {
128
+ _context3.next = 18;
129
+ break;
130
+ }
131
+ _context3.t2 = _yield$provider$findP;
132
+ _context3.next = 19;
113
133
  break;
114
- case 13:
115
- _context3.prev = 13;
116
- _context3.t0 = _context3["catch"](4);
134
+ case 18:
135
+ _context3.t2 = false;
136
+ case 19:
137
+ isUrlSupported = _context3.t2;
138
+ _context3.next = 25;
139
+ break;
140
+ case 22:
141
+ _context3.prev = 22;
142
+ _context3.t3 = _context3["catch"](4);
117
143
  isUrlSupported = false;
118
- case 16:
144
+ case 25:
119
145
  newMap = new Map(supportedUrlsMap);
120
146
  newMap.set(url, isUrlSupported);
121
147
  _this.setState({
122
148
  supportedUrlsMap: newMap
123
149
  });
124
- case 19:
150
+ case 28:
125
151
  case "end":
126
152
  return _context3.stop();
127
153
  }
128
- }, _callee3, null, [[4, 13]]);
154
+ }, _callee3, null, [[4, 22]]);
129
155
  }));
130
156
  return function (_x3) {
131
157
  return _ref3.apply(this, arguments);
@@ -1,6 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { memo, useCallback, useMemo } from 'react';
3
3
  import rafSchedule from 'raf-schd';
4
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
5
  import { findOverflowScrollParent, UnsupportedInline } from '@atlaskit/editor-common/ui';
5
6
  import { fg } from '@atlaskit/platform-feature-flags';
6
7
  import { Card as SmartCard } from '@atlaskit/smart-card';
@@ -19,7 +20,9 @@ export const InlineCard = /*#__PURE__*/memo(({
19
20
  getPos,
20
21
  onClick,
21
22
  onResolve: onRes,
22
- isHovered
23
+ isHovered,
24
+ showHoverPreview,
25
+ hoverPreviewOptions
23
26
  }) => {
24
27
  const {
25
28
  url,
@@ -76,8 +79,10 @@ export const InlineCard = /*#__PURE__*/memo(({
76
79
  inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
77
80
  actionOptions: actionOptions,
78
81
  showServerActions: showServerActions,
79
- isHovered: isHovered
80
- }), [data, isHovered, onError, onResolve, scrollContainer, url, useAlternativePreloader, actionOptions, showServerActions, onClick]);
82
+ isHovered: isHovered,
83
+ showHoverPreview: showHoverPreview,
84
+ hoverPreviewOptions: hoverPreviewOptions
85
+ }), [url, data, onClick, scrollContainer, onResolve, onError, useAlternativePreloader, actionOptions, showServerActions, isHovered, showHoverPreview, hoverPreviewOptions]);
81
86
 
82
87
  // [WS-2307]: we only render card wrapped into a Provider when the value is ready,
83
88
  // otherwise if we got data, we can render the card directly since it doesn't need the Provider
@@ -88,6 +93,7 @@ export const InlineCard = /*#__PURE__*/memo(({
88
93
  const WrappedInlineCardWithAwareness = Card(InlineCardWithAwareness, UnsupportedInline);
89
94
  const WrappedInlineCard = Card(InlineCard, UnsupportedInline);
90
95
  export function InlineCardNodeView(props) {
96
+ var _useSharedPluginState, _useSharedPluginState2;
91
97
  const {
92
98
  useAlternativePreloader,
93
99
  node,
@@ -101,7 +107,10 @@ export function InlineCardNodeView(props) {
101
107
  pluginInjectionApi,
102
108
  onClickCallback
103
109
  } = props;
110
+ const floatingToolbarNode = (_useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['floatingToolbar']).floatingToolbarState) === null || _useSharedPluginState === void 0 ? void 0 : (_useSharedPluginState2 = _useSharedPluginState.configWithNodeInfo) === null || _useSharedPluginState2 === void 0 ? void 0 : _useSharedPluginState2.node;
104
111
  if (fg('platform.linking-platform.smart-links-in-live-pages')) {
112
+ const showHoverPreview = floatingToolbarNode !== node;
113
+ const livePagesHoverCardFadeInDelay = 800;
105
114
  return /*#__PURE__*/React.createElement(OverlayWrapper, {
106
115
  targetElementPos: getPos(),
107
116
  view: view
@@ -112,7 +121,11 @@ export function InlineCardNodeView(props) {
112
121
  actionOptions: actionOptions,
113
122
  showServerActions: showServerActions,
114
123
  useAlternativePreloader: useAlternativePreloader,
115
- onClickCallback: onClickCallback
124
+ onClickCallback: onClickCallback,
125
+ showHoverPreview: showHoverPreview,
126
+ hoverPreviewOptions: {
127
+ fadeInDelay: livePagesHoverCardFadeInDelay
128
+ }
116
129
  }));
117
130
  }
118
131
  return /*#__PURE__*/React.createElement(WrappedInlineCardWithAwareness, _extends({
@@ -6,7 +6,7 @@ import { canRenderDatasource } from '@atlaskit/editor-common/utils';
6
6
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
7
7
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
8
8
  import { DATASOURCE_DEFAULT_LAYOUT } from '@atlaskit/linking-common';
9
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
9
+ import { fg, getBooleanFF } from '@atlaskit/platform-feature-flags';
10
10
  import { eventsFromTransaction } from '../analytics/events-from-tr';
11
11
  import { isLocalStorageKeyDiscovered } from '../common/local-storage';
12
12
  import { BlockCard } from '../nodeviews/blockCard';
@@ -149,7 +149,11 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
149
149
  const subscriptionHandler = (name, provider) => handleProvider(name, provider, view);
150
150
  const domAtPos = view.domAtPos.bind(view);
151
151
  const rafCancellationCallbacks = [];
152
- pmPluginFactoryParams.providerFactory.subscribe('cardProvider', subscriptionHandler);
152
+ if (options.provider && fg('platform_editor_get_card_provider_from_config')) {
153
+ handleProvider('cardProvider', options.provider, view);
154
+ } else {
155
+ pmPluginFactoryParams.providerFactory.subscribe('cardProvider', subscriptionHandler);
156
+ }
153
157
  return {
154
158
  update(view, prevState) {
155
159
  var _selection$node;
@@ -233,7 +237,9 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
233
237
  destroy() {
234
238
  // Cancel any outstanding raf callbacks.
235
239
  rafCancellationCallbacks.forEach(cancellationCallback => cancellationCallback());
236
- pmPluginFactoryParams.providerFactory.unsubscribe('cardProvider', subscriptionHandler);
240
+ if (!fg('platform_editor_get_card_provider_from_config')) {
241
+ pmPluginFactoryParams.providerFactory.unsubscribe('cardProvider', subscriptionHandler);
242
+ }
237
243
  }
238
244
  };
239
245
  },
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React, { Component } from 'react';
3
3
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { FloatingToolbarSeparator as Separator } from '@atlaskit/editor-common/ui';
5
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
5
+ import { fg, getBooleanFF } from '@atlaskit/platform-feature-flags';
6
6
  import { Flex } from '@atlaskit/primitives';
7
7
  import { DatasourceAppearanceButton } from './DatasourceAppearanceButton';
8
8
  import { EditDatasourceButton } from './EditDatasourceButton';
@@ -15,6 +15,11 @@ export class HyperlinkToolbarAppearance extends Component {
15
15
  supportedUrlsMap: new Map()
16
16
  });
17
17
  _defineProperty(this, "getProvider", async () => {
18
+ var _this$props$cardOptio;
19
+ if ((_this$props$cardOptio = this.props.cardOptions) !== null && _this$props$cardOptio !== void 0 && _this$props$cardOptio.provider && fg('platform_editor_get_card_provider_from_config')) {
20
+ var _this$props$cardOptio2;
21
+ return (_this$props$cardOptio2 = this.props.cardOptions) === null || _this$props$cardOptio2 === void 0 ? void 0 : _this$props$cardOptio2.provider;
22
+ }
18
23
  if (this.cardProvider) {
19
24
  return this.cardProvider;
20
25
  }
@@ -40,8 +45,9 @@ export class HyperlinkToolbarAppearance extends Component {
40
45
  }
41
46
  let isUrlSupported = false;
42
47
  try {
48
+ var _await$provider$findP;
43
49
  const provider = await this.getProvider();
44
- isUrlSupported = await provider.findPattern(url);
50
+ isUrlSupported = (_await$provider$findP = await (provider === null || provider === void 0 ? void 0 : provider.findPattern(url))) !== null && _await$provider$findP !== void 0 ? _await$provider$findP : false;
45
51
  } catch (error) {
46
52
  isUrlSupported = false;
47
53
  }
@@ -1,6 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { memo, useCallback, useMemo } from 'react';
3
3
  import rafSchedule from 'raf-schd';
4
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
5
  import { findOverflowScrollParent, UnsupportedInline } from '@atlaskit/editor-common/ui';
5
6
  import { fg } from '@atlaskit/platform-feature-flags';
6
7
  import { Card as SmartCard } from '@atlaskit/smart-card';
@@ -19,7 +20,9 @@ export var InlineCard = /*#__PURE__*/memo(function (_ref) {
19
20
  getPos = _ref.getPos,
20
21
  onClick = _ref.onClick,
21
22
  onRes = _ref.onResolve,
22
- isHovered = _ref.isHovered;
23
+ isHovered = _ref.isHovered,
24
+ showHoverPreview = _ref.showHoverPreview,
25
+ hoverPreviewOptions = _ref.hoverPreviewOptions;
23
26
  var _node$attrs = node.attrs,
24
27
  url = _node$attrs.url,
25
28
  data = _node$attrs.data;
@@ -73,9 +76,11 @@ export var InlineCard = /*#__PURE__*/memo(function (_ref) {
73
76
  inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
74
77
  actionOptions: actionOptions,
75
78
  showServerActions: showServerActions,
76
- isHovered: isHovered
79
+ isHovered: isHovered,
80
+ showHoverPreview: showHoverPreview,
81
+ hoverPreviewOptions: hoverPreviewOptions
77
82
  });
78
- }, [data, isHovered, onError, onResolve, scrollContainer, url, useAlternativePreloader, actionOptions, showServerActions, onClick]);
83
+ }, [url, data, onClick, scrollContainer, onResolve, onError, useAlternativePreloader, actionOptions, showServerActions, isHovered, showHoverPreview, hoverPreviewOptions]);
79
84
 
80
85
  // [WS-2307]: we only render card wrapped into a Provider when the value is ready,
81
86
  // otherwise if we got data, we can render the card directly since it doesn't need the Provider
@@ -86,6 +91,7 @@ export var InlineCard = /*#__PURE__*/memo(function (_ref) {
86
91
  var WrappedInlineCardWithAwareness = Card(InlineCardWithAwareness, UnsupportedInline);
87
92
  var WrappedInlineCard = Card(InlineCard, UnsupportedInline);
88
93
  export function InlineCardNodeView(props) {
94
+ var _useSharedPluginState;
89
95
  var useAlternativePreloader = props.useAlternativePreloader,
90
96
  node = props.node,
91
97
  view = props.view,
@@ -97,7 +103,10 @@ export function InlineCardNodeView(props) {
97
103
  enableInlineUpgradeFeatures = props.enableInlineUpgradeFeatures,
98
104
  pluginInjectionApi = props.pluginInjectionApi,
99
105
  onClickCallback = props.onClickCallback;
106
+ var floatingToolbarNode = (_useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['floatingToolbar']).floatingToolbarState) === null || _useSharedPluginState === void 0 || (_useSharedPluginState = _useSharedPluginState.configWithNodeInfo) === null || _useSharedPluginState === void 0 ? void 0 : _useSharedPluginState.node;
100
107
  if (fg('platform.linking-platform.smart-links-in-live-pages')) {
108
+ var showHoverPreview = floatingToolbarNode !== node;
109
+ var livePagesHoverCardFadeInDelay = 800;
101
110
  return /*#__PURE__*/React.createElement(OverlayWrapper, {
102
111
  targetElementPos: getPos(),
103
112
  view: view
@@ -108,7 +117,11 @@ export function InlineCardNodeView(props) {
108
117
  actionOptions: actionOptions,
109
118
  showServerActions: showServerActions,
110
119
  useAlternativePreloader: useAlternativePreloader,
111
- onClickCallback: onClickCallback
120
+ onClickCallback: onClickCallback,
121
+ showHoverPreview: showHoverPreview,
122
+ hoverPreviewOptions: {
123
+ fadeInDelay: livePagesHoverCardFadeInDelay
124
+ }
112
125
  }));
113
126
  }
114
127
  return /*#__PURE__*/React.createElement(WrappedInlineCardWithAwareness, _extends({
@@ -10,7 +10,7 @@ import { canRenderDatasource } from '@atlaskit/editor-common/utils';
10
10
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
11
11
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
12
12
  import { DATASOURCE_DEFAULT_LAYOUT } from '@atlaskit/linking-common';
13
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
13
+ import { fg, getBooleanFF } from '@atlaskit/platform-feature-flags';
14
14
  import { eventsFromTransaction } from '../analytics/events-from-tr';
15
15
  import { isLocalStorageKeyDiscovered } from '../common/local-storage';
16
16
  import { BlockCard } from '../nodeviews/blockCard';
@@ -153,7 +153,11 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
153
153
  };
154
154
  var domAtPos = _view.domAtPos.bind(_view);
155
155
  var rafCancellationCallbacks = [];
156
- pmPluginFactoryParams.providerFactory.subscribe('cardProvider', subscriptionHandler);
156
+ if (options.provider && fg('platform_editor_get_card_provider_from_config')) {
157
+ handleProvider('cardProvider', options.provider, _view);
158
+ } else {
159
+ pmPluginFactoryParams.providerFactory.subscribe('cardProvider', subscriptionHandler);
160
+ }
157
161
  return {
158
162
  update: function update(view, prevState) {
159
163
  var _selection$node;
@@ -231,7 +235,9 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
231
235
  rafCancellationCallbacks.forEach(function (cancellationCallback) {
232
236
  return cancellationCallback();
233
237
  });
234
- pmPluginFactoryParams.providerFactory.unsubscribe('cardProvider', subscriptionHandler);
238
+ if (!fg('platform_editor_get_card_provider_from_config')) {
239
+ pmPluginFactoryParams.providerFactory.unsubscribe('cardProvider', subscriptionHandler);
240
+ }
235
241
  }
236
242
  };
237
243
  },
@@ -12,7 +12,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
12
12
  import React, { Component } from 'react';
13
13
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
14
14
  import { FloatingToolbarSeparator as Separator } from '@atlaskit/editor-common/ui';
15
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
15
+ import { fg, getBooleanFF } from '@atlaskit/platform-feature-flags';
16
16
  import { Flex } from '@atlaskit/primitives';
17
17
  import { DatasourceAppearanceButton } from './DatasourceAppearanceButton';
18
18
  import { EditDatasourceButton } from './EditDatasourceButton';
@@ -32,15 +32,23 @@ export var HyperlinkToolbarAppearance = /*#__PURE__*/function (_Component) {
32
32
  supportedUrlsMap: new Map()
33
33
  });
34
34
  _defineProperty(_assertThisInitialized(_this), "getProvider", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
35
+ var _this$props$cardOptio;
36
+ var _this$props$cardOptio2;
35
37
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
36
38
  while (1) switch (_context2.prev = _context2.next) {
37
39
  case 0:
38
- if (!_this.cardProvider) {
40
+ if (!((_this$props$cardOptio = _this.props.cardOptions) !== null && _this$props$cardOptio !== void 0 && _this$props$cardOptio.provider && fg('platform_editor_get_card_provider_from_config'))) {
39
41
  _context2.next = 2;
40
42
  break;
41
43
  }
42
- return _context2.abrupt("return", _this.cardProvider);
44
+ return _context2.abrupt("return", (_this$props$cardOptio2 = _this.props.cardOptions) === null || _this$props$cardOptio2 === void 0 ? void 0 : _this$props$cardOptio2.provider);
43
45
  case 2:
46
+ if (!_this.cardProvider) {
47
+ _context2.next = 4;
48
+ break;
49
+ }
50
+ return _context2.abrupt("return", _this.cardProvider);
51
+ case 4:
44
52
  return _context2.abrupt("return", new Promise(function (resolve) {
45
53
  var providerFactory = _this.props.providerFactory;
46
54
  providerFactory.subscribe('cardProvider', /*#__PURE__*/function () {
@@ -70,7 +78,7 @@ export var HyperlinkToolbarAppearance = /*#__PURE__*/function (_Component) {
70
78
  };
71
79
  }());
72
80
  }));
73
- case 3:
81
+ case 5:
74
82
  case "end":
75
83
  return _context2.stop();
76
84
  }
@@ -78,7 +86,7 @@ export var HyperlinkToolbarAppearance = /*#__PURE__*/function (_Component) {
78
86
  })));
79
87
  _defineProperty(_assertThisInitialized(_this), "resolveUrl", /*#__PURE__*/function () {
80
88
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(url) {
81
- var supportedUrlsMap, isUrlSupported, provider, newMap;
89
+ var supportedUrlsMap, isUrlSupported, _yield$provider$findP, provider, newMap;
82
90
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
83
91
  while (1) switch (_context3.prev = _context3.next) {
84
92
  case 0:
@@ -96,26 +104,44 @@ export var HyperlinkToolbarAppearance = /*#__PURE__*/function (_Component) {
96
104
  case 7:
97
105
  provider = _context3.sent;
98
106
  _context3.next = 10;
99
- return provider.findPattern(url);
107
+ return provider === null || provider === void 0 ? void 0 : provider.findPattern(url);
100
108
  case 10:
101
- isUrlSupported = _context3.sent;
102
- _context3.next = 16;
109
+ _context3.t1 = _yield$provider$findP = _context3.sent;
110
+ _context3.t0 = _context3.t1 !== null;
111
+ if (!_context3.t0) {
112
+ _context3.next = 14;
113
+ break;
114
+ }
115
+ _context3.t0 = _yield$provider$findP !== void 0;
116
+ case 14:
117
+ if (!_context3.t0) {
118
+ _context3.next = 18;
119
+ break;
120
+ }
121
+ _context3.t2 = _yield$provider$findP;
122
+ _context3.next = 19;
103
123
  break;
104
- case 13:
105
- _context3.prev = 13;
106
- _context3.t0 = _context3["catch"](4);
124
+ case 18:
125
+ _context3.t2 = false;
126
+ case 19:
127
+ isUrlSupported = _context3.t2;
128
+ _context3.next = 25;
129
+ break;
130
+ case 22:
131
+ _context3.prev = 22;
132
+ _context3.t3 = _context3["catch"](4);
107
133
  isUrlSupported = false;
108
- case 16:
134
+ case 25:
109
135
  newMap = new Map(supportedUrlsMap);
110
136
  newMap.set(url, isUrlSupported);
111
137
  _this.setState({
112
138
  supportedUrlsMap: newMap
113
139
  });
114
- case 19:
140
+ case 28:
115
141
  case "end":
116
142
  return _context3.stop();
117
143
  }
118
- }, _callee3, null, [[4, 13]]);
144
+ }, _callee3, null, [[4, 22]]);
119
145
  }));
120
146
  return function (_x3) {
121
147
  return _ref3.apply(this, arguments);
@@ -40,6 +40,8 @@ export interface CardProps extends CardNodeViewProps {
40
40
  actionOptions?: BaseCardProps['actionOptions'];
41
41
  pluginInjectionApi?: ExtractInjectionAPI<typeof cardPlugin>;
42
42
  onClickCallback?: OnClickCallback;
43
+ showHoverPreview?: BaseCardProps['showHoverPreview'];
44
+ hoverPreviewOptions?: BaseCardProps['hoverPreviewOptions'];
43
45
  }
44
46
  export interface SmartCardProps extends CardProps {
45
47
  pluginInjectionApi?: ExtractInjectionAPI<typeof cardPlugin>;
@@ -2,6 +2,6 @@ import React from 'react';
2
2
  import type { InlineNodeViewComponentProps } from '@atlaskit/editor-common/react-node-view';
3
3
  import type { SmartCardProps } from './genericCard';
4
4
  import { type InlineCardWithAwarenessProps } from './inlineCardWithAwareness';
5
- export declare const InlineCard: React.MemoExoticComponent<({ node, cardContext, actionOptions, showServerActions, useAlternativePreloader, view, getPos, onClick, onResolve: onRes, isHovered, }: SmartCardProps) => JSX.Element | null>;
5
+ export declare const InlineCard: React.MemoExoticComponent<({ node, cardContext, actionOptions, showServerActions, useAlternativePreloader, view, getPos, onClick, onResolve: onRes, isHovered, showHoverPreview, hoverPreviewOptions, }: SmartCardProps) => JSX.Element | null>;
6
6
  export type InlineCardNodeViewProps = Pick<SmartCardProps, 'useAlternativePreloader' | 'actionOptions' | 'showServerActions' | 'allowEmbeds' | 'allowBlockCards' | 'enableInlineUpgradeFeatures' | 'pluginInjectionApi' | 'onClickCallback'>;
7
7
  export declare function InlineCardNodeView(props: InlineNodeViewComponentProps & InlineCardNodeViewProps & InlineCardWithAwarenessProps): JSX.Element;
@@ -40,6 +40,8 @@ export interface CardProps extends CardNodeViewProps {
40
40
  actionOptions?: BaseCardProps['actionOptions'];
41
41
  pluginInjectionApi?: ExtractInjectionAPI<typeof cardPlugin>;
42
42
  onClickCallback?: OnClickCallback;
43
+ showHoverPreview?: BaseCardProps['showHoverPreview'];
44
+ hoverPreviewOptions?: BaseCardProps['hoverPreviewOptions'];
43
45
  }
44
46
  export interface SmartCardProps extends CardProps {
45
47
  pluginInjectionApi?: ExtractInjectionAPI<typeof cardPlugin>;
@@ -2,6 +2,6 @@ import React from 'react';
2
2
  import type { InlineNodeViewComponentProps } from '@atlaskit/editor-common/react-node-view';
3
3
  import type { SmartCardProps } from './genericCard';
4
4
  import { type InlineCardWithAwarenessProps } from './inlineCardWithAwareness';
5
- export declare const InlineCard: React.MemoExoticComponent<({ node, cardContext, actionOptions, showServerActions, useAlternativePreloader, view, getPos, onClick, onResolve: onRes, isHovered, }: SmartCardProps) => JSX.Element | null>;
5
+ export declare const InlineCard: React.MemoExoticComponent<({ node, cardContext, actionOptions, showServerActions, useAlternativePreloader, view, getPos, onClick, onResolve: onRes, isHovered, showHoverPreview, hoverPreviewOptions, }: SmartCardProps) => JSX.Element | null>;
6
6
  export type InlineCardNodeViewProps = Pick<SmartCardProps, 'useAlternativePreloader' | 'actionOptions' | 'showServerActions' | 'allowEmbeds' | 'allowBlockCards' | 'enableInlineUpgradeFeatures' | 'pluginInjectionApi' | 'onClickCallback'>;
7
7
  export declare function InlineCardNodeView(props: InlineNodeViewComponentProps & InlineCardNodeViewProps & InlineCardWithAwarenessProps): JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "2.3.7",
3
+ "version": "2.4.0",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -36,7 +36,7 @@
36
36
  "@atlaskit/analytics-next": "^9.3.0",
37
37
  "@atlaskit/button": "^18.1.0",
38
38
  "@atlaskit/custom-steps": "^0.4.0",
39
- "@atlaskit/dropdown-menu": "^12.13.0",
39
+ "@atlaskit/dropdown-menu": "^12.14.0",
40
40
  "@atlaskit/editor-common": "^84.0.0",
41
41
  "@atlaskit/editor-plugin-analytics": "^1.4.0",
42
42
  "@atlaskit/editor-plugin-decorations": "^1.1.0",
@@ -58,7 +58,7 @@
58
58
  "@atlaskit/menu": "2.7.0",
59
59
  "@atlaskit/platform-feature-flags": "^0.3.0",
60
60
  "@atlaskit/primitives": "^10.0.0",
61
- "@atlaskit/smart-card": "^27.8.0",
61
+ "@atlaskit/smart-card": "^27.9.0",
62
62
  "@atlaskit/theme": "^12.11.0",
63
63
  "@atlaskit/tokens": "^1.53.0",
64
64
  "@atlaskit/tooltip": "^18.5.0",
@@ -136,6 +136,9 @@
136
136
  },
137
137
  "platform.linking-platform.editor-datasource-typeguards": {
138
138
  "type": "boolean"
139
+ },
140
+ "platform_editor_get_card_provider_from_config": {
141
+ "type": "boolean"
139
142
  }
140
143
  },
141
144
  "stricter": {