@atlaskit/editor-plugin-card 7.1.0 → 7.2.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 (50) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/cjs/nodeviews/embedCard.js +51 -4
  3. package/dist/cjs/nodeviews/genericCard.js +2 -19
  4. package/dist/cjs/nodeviews/inlineCard.js +1 -45
  5. package/dist/cjs/nodeviews/inlineCardWithAwareness.js +34 -18
  6. package/dist/cjs/pm-plugins/main.js +4 -24
  7. package/dist/cjs/ui/{OpenButtonOverlay → HoverLinkOverlay}/index.js +26 -14
  8. package/dist/cjs/ui/toolbar.js +8 -1
  9. package/dist/es2019/nodeviews/embedCard.js +49 -4
  10. package/dist/es2019/nodeviews/genericCard.js +2 -19
  11. package/dist/es2019/nodeviews/inlineCard.js +2 -42
  12. package/dist/es2019/nodeviews/inlineCardWithAwareness.js +34 -18
  13. package/dist/es2019/pm-plugins/main.js +1 -23
  14. package/dist/es2019/ui/{OpenButtonOverlay → HoverLinkOverlay}/index.js +25 -14
  15. package/dist/es2019/ui/toolbar.js +8 -1
  16. package/dist/esm/nodeviews/embedCard.js +51 -4
  17. package/dist/esm/nodeviews/genericCard.js +2 -19
  18. package/dist/esm/nodeviews/inlineCard.js +2 -46
  19. package/dist/esm/nodeviews/inlineCardWithAwareness.js +34 -18
  20. package/dist/esm/pm-plugins/main.js +3 -23
  21. package/dist/esm/ui/{OpenButtonOverlay → HoverLinkOverlay}/index.js +26 -14
  22. package/dist/esm/ui/toolbar.js +8 -1
  23. package/dist/types/nodeviews/embedCard.d.ts +2 -1
  24. package/dist/types/nodeviews/inlineCard.d.ts +1 -1
  25. package/dist/types/pm-plugins/main.d.ts +0 -2
  26. package/dist/types/ui/HoverLinkOverlay/index.d.ts +9 -0
  27. package/dist/types/ui/{OpenButtonOverlay → HoverLinkOverlay}/types.d.ts +3 -1
  28. package/dist/types/ui/datasourceErrorBoundary.d.ts +1 -1
  29. package/dist/types-ts4.5/nodeviews/embedCard.d.ts +2 -1
  30. package/dist/types-ts4.5/nodeviews/inlineCard.d.ts +1 -1
  31. package/dist/types-ts4.5/pm-plugins/main.d.ts +0 -2
  32. package/dist/types-ts4.5/ui/HoverLinkOverlay/index.d.ts +9 -0
  33. package/dist/types-ts4.5/ui/{OpenButtonOverlay → HoverLinkOverlay}/types.d.ts +3 -1
  34. package/dist/types-ts4.5/ui/datasourceErrorBoundary.d.ts +1 -1
  35. package/package.json +6 -8
  36. package/dist/cjs/ui/PanelButtonOverlay/index.js +0 -171
  37. package/dist/cjs/ui/PanelButtonOverlay/types.js +0 -5
  38. package/dist/es2019/ui/PanelButtonOverlay/index.js +0 -148
  39. package/dist/esm/ui/OpenButtonOverlay/types.js +0 -1
  40. package/dist/esm/ui/PanelButtonOverlay/index.js +0 -158
  41. package/dist/esm/ui/PanelButtonOverlay/types.js +0 -1
  42. package/dist/types/ui/OpenButtonOverlay/index.d.ts +0 -9
  43. package/dist/types/ui/PanelButtonOverlay/index.d.ts +0 -9
  44. package/dist/types/ui/PanelButtonOverlay/types.d.ts +0 -7
  45. package/dist/types-ts4.5/ui/OpenButtonOverlay/index.d.ts +0 -9
  46. package/dist/types-ts4.5/ui/PanelButtonOverlay/index.d.ts +0 -9
  47. package/dist/types-ts4.5/ui/PanelButtonOverlay/types.d.ts +0 -7
  48. /package/dist/cjs/ui/{OpenButtonOverlay → HoverLinkOverlay}/types.js +0 -0
  49. /package/dist/es2019/ui/{OpenButtonOverlay → HoverLinkOverlay}/types.js +0 -0
  50. /package/dist/{es2019/ui/PanelButtonOverlay → esm/ui/HoverLinkOverlay}/types.js +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 7.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#185241](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/185241)
8
+ [`0d1bffce3fedd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0d1bffce3fedd) -
9
+ [ux] View embed as block card when page width smaller or equal to 600px
10
+ - Updated dependencies
11
+
12
+ ## 7.2.0
13
+
14
+ ### Minor Changes
15
+
16
+ - [#189119](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/189119)
17
+ [`3422f57cf2b75`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3422f57cf2b75) -
18
+ Removing linking_platform_smart_links_in_live_pages FF
19
+
20
+ ### Patch Changes
21
+
22
+ - [#187274](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/187274)
23
+ [`06b83ebb34346`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/06b83ebb34346) -
24
+ [ux] ED-28390 platformise open hover button
25
+ - [#187671](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/187671)
26
+ [`f0b9b62ce032f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f0b9b62ce032f) -
27
+ [ux] ED-28547: Added hover card when hover smartlinks
28
+ - Updated dependencies
29
+
3
30
  ## 7.1.0
4
31
 
5
32
  ### Minor Changes
@@ -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.embedCardNodeView = exports.EmbedCardComponent = exports.EmbedCard = void 0;
7
+ exports.embedCardNodeView = exports.EmbedOrBlockCardComponent = exports.EmbedCardComponent = exports.EmbedCard = void 0;
8
8
  var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
9
9
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
10
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
@@ -20,11 +20,15 @@ var _steps = require("@atlaskit/adf-schema/steps");
20
20
  var _hooks = require("@atlaskit/editor-common/hooks");
21
21
  var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
22
22
  var _ui = require("@atlaskit/editor-common/ui");
23
+ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
23
24
  var _utils = require("@atlaskit/editor-common/utils");
24
25
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
26
+ var _platformFeatureFlagsReact = require("@atlaskit/platform-feature-flags-react");
25
27
  var _smartCard = require("@atlaskit/smart-card");
28
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
26
29
  var _actions = require("../pm-plugins/actions");
27
30
  var _ResizableEmbedCard = _interopRequireDefault(require("../ui/ResizableEmbedCard"));
31
+ var _blockCard = require("./blockCard");
28
32
  var _genericCard = require("./genericCard");
29
33
  function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
30
34
  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; }
@@ -57,7 +61,6 @@ var CardInner = function CardInner(_ref) {
57
61
  getLineLength = _ref.getLineLength,
58
62
  view = _ref.view,
59
63
  smartCard = _ref.smartCard,
60
- eventDispatcher = _ref.eventDispatcher,
61
64
  updateSize = _ref.updateSize,
62
65
  getPos = _ref.getPos,
63
66
  aspectRatio = _ref.aspectRatio,
@@ -372,7 +375,51 @@ var EmbedCardComponent = exports.EmbedCardComponent = /*#__PURE__*/function (_Re
372
375
  }
373
376
  }]);
374
377
  }(_react.default.PureComponent);
375
- var WrappedBlockCard = (0, _genericCard.Card)(EmbedCardComponent, _ui.UnsupportedBlock);
378
+ var EmbedOrBlockCardComponent = exports.EmbedOrBlockCardComponent = function EmbedOrBlockCardComponent(props) {
379
+ var width = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(props.pluginInjectionApi, 'width.width');
380
+ var viewAsBlockCard = width && width <= _editorSharedStyles.akEditorFullPageNarrowBreakout;
381
+ return viewAsBlockCard ? /*#__PURE__*/_react.default.createElement(_blockCard.BlockCardComponent, {
382
+ id: props.id,
383
+ node: props.node,
384
+ view: props.view,
385
+ getPos: props.getPos,
386
+ pluginInjectionApi: props.pluginInjectionApi,
387
+ actionOptions: props.actionOptions,
388
+ onClick: props.onClick,
389
+ CompetitorPrompt: props.CompetitorPrompt,
390
+ allowResizing: props.allowResizing,
391
+ fullWidthMode: props.fullWidthMode,
392
+ dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
393
+ eventDispatcher: props.eventDispatcher,
394
+ cardContext: props.cardContext,
395
+ smartCard: props.smartCard,
396
+ hasPreview: props.hasPreview,
397
+ liveHeight: props.liveHeight,
398
+ initialAspectRatio: props.initialAspectRatio
399
+ }) : /*#__PURE__*/_react.default.createElement(EmbedCardComponent, {
400
+ id: props.id,
401
+ node: props.node,
402
+ view: props.view,
403
+ getPos: props.getPos,
404
+ pluginInjectionApi: props.pluginInjectionApi,
405
+ actionOptions: props.actionOptions,
406
+ onClick: props.onClick,
407
+ CompetitorPrompt: props.CompetitorPrompt,
408
+ allowResizing: props.allowResizing,
409
+ fullWidthMode: props.fullWidthMode,
410
+ dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
411
+ eventDispatcher: props.eventDispatcher,
412
+ cardContext: props.cardContext,
413
+ smartCard: props.smartCard,
414
+ hasPreview: props.hasPreview,
415
+ liveHeight: props.liveHeight,
416
+ initialAspectRatio: props.initialAspectRatio
417
+ });
418
+ };
419
+ var WrappedEmbedCardWithCondition = (0, _platformFeatureFlagsReact.componentWithCondition)(function () {
420
+ return (0, _expValEquals.expValEquals)('platform_editor_preview_panel_responsiveness', 'isEnabled', true);
421
+ }, EmbedOrBlockCardComponent, EmbedCardComponent);
422
+ var WrappedEmbedCard = (0, _genericCard.Card)(WrappedEmbedCardWithCondition, _ui.UnsupportedBlock);
376
423
  var EmbedCard = exports.EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
377
424
  function EmbedCard() {
378
425
  var _this2;
@@ -423,7 +470,7 @@ var EmbedCard = exports.EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
423
470
  pluginInjectionApi = _this$reactComponentP3.pluginInjectionApi,
424
471
  onClickCallback = _this$reactComponentP3.onClickCallback,
425
472
  CompetitorPrompt = _this$reactComponentP3.CompetitorPrompt;
426
- return /*#__PURE__*/_react.default.createElement(WrappedBlockCard, {
473
+ return /*#__PURE__*/_react.default.createElement(WrappedEmbedCard, {
427
474
  node: this.node,
428
475
  view: this.view,
429
476
  eventDispatcher: eventDispatcher,
@@ -46,8 +46,7 @@ var WithClickHandler = function WithClickHandler(_ref) {
46
46
  var pluginInjectionApi = _ref.pluginInjectionApi,
47
47
  url = _ref.url,
48
48
  onClickCallback = _ref.onClickCallback,
49
- children = _ref.children,
50
- __livePage = _ref.__livePage;
49
+ children = _ref.children;
51
50
  var _useSharedState = useSharedState(pluginInjectionApi),
52
51
  mode = _useSharedState.mode;
53
52
  var onClick = (0, _react.useCallback)(function (event) {
@@ -60,21 +59,6 @@ var WithClickHandler = function WithClickHandler(_ref) {
60
59
  } catch (_unused) {}
61
60
  }
62
61
  }, [url, onClickCallback]);
63
- if ((0, _platformFeatureFlags.fg)('linking_platform_smart_links_in_live_pages')) {
64
- // Ignored via go/ees007
65
- // eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
66
- /**
67
- * @todo: Add a check to determine if we're currently in a live page once ED-23920 and plugin
68
- * is complete. The logic for which should allow navigation if we're in a live page and no callback
69
- * has been provided. E.g.
70
- *
71
- * const allowNavigation = isLivePage && !onClickCallback;
72
- */
73
- var _allowNavigation = __livePage && !onClickCallback;
74
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children({
75
- onClick: _allowNavigation ? undefined : onClick
76
- }));
77
- }
78
62
 
79
63
  // Setting `onClick` to `undefined` ensures clicks on smartcards navigate to the URL.
80
64
  // If in view mode and not overriding with onClickCallback option, then allow smartlinks to navigate on click.
@@ -151,8 +135,7 @@ function Card(SmartCardComponent, UnsupportedComponent) {
151
135
  }, /*#__PURE__*/_react.default.createElement(WithClickHandler, {
152
136
  pluginInjectionApi: pluginInjectionApi,
153
137
  onClickCallback: onClickCallback,
154
- url: url,
155
- __livePage: this.props.__livePage
138
+ url: url
156
139
  }, function (_ref2) {
157
140
  var onClick = _ref2.onClick;
158
141
  return /*#__PURE__*/_react.default.createElement(_WithCardContext.WithCardContext, null, function (cardContext) {
@@ -9,22 +9,18 @@ exports.InlineCard = void 0;
9
9
  exports.InlineCardNodeView = InlineCardNodeView;
10
10
  exports.inlineCardNodeView = void 0;
11
11
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
12
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
12
  var _react = _interopRequireWildcard(require("react"));
14
13
  var _rafSchd = _interopRequireDefault(require("raf-schd"));
15
14
  var _v = _interopRequireDefault(require("uuid/v4"));
16
15
  var _analytics = require("@atlaskit/editor-common/analytics");
17
16
  var _hooks = require("@atlaskit/editor-common/hooks");
18
- var _link = require("@atlaskit/editor-common/link");
19
17
  var _ui = require("@atlaskit/editor-common/ui");
20
- var _state = require("@atlaskit/editor-prosemirror/state");
21
18
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
22
19
  var _smartCard = require("@atlaskit/smart-card");
23
20
  var _ssr = require("@atlaskit/smart-card/ssr");
24
21
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
25
22
  var _actions = require("../pm-plugins/actions");
26
23
  var _utils = require("../pm-plugins/utils");
27
- var _ConfigureOverlay = _interopRequireDefault(require("../ui/ConfigureOverlay"));
28
24
  var _toolbar = require("../ui/toolbar");
29
25
  var _genericCard = require("./genericCard");
30
26
  var _inlineCardWithAwareness = require("./inlineCardWithAwareness");
@@ -153,7 +149,6 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
153
149
  }, card) : data ? card : null;
154
150
  });
155
151
  var WrappedInlineCardWithAwareness = (0, _genericCard.Card)(_inlineCardWithAwareness.InlineCardWithAwareness, _ui.UnsupportedInline);
156
- var WrappedInlineCard = (0, _genericCard.Card)(InlineCard, _ui.UnsupportedInline);
157
152
  var selector = function selector(states) {
158
153
  var _states$editorViewMod, _states$selectionStat;
159
154
  return {
@@ -189,54 +184,15 @@ function InlineCardNodeView(props) {
189
184
  enableInlineUpgradeFeatures = props.enableInlineUpgradeFeatures,
190
185
  pluginInjectionApi = props.pluginInjectionApi,
191
186
  onClickCallback = props.onClickCallback,
192
- __livePage = props.__livePage,
193
187
  isPageSSRed = props.isPageSSRed,
194
188
  CompetitorPrompt = props.CompetitorPrompt;
195
- var _useState = (0, _react.useState)(false),
196
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
197
- isOverlayHovered = _useState2[0],
198
- setIsOverlayHovered = _useState2[1];
199
189
  var _useSharedState = useSharedState(pluginInjectionApi),
200
- mode = _useSharedState.mode,
201
- selection = _useSharedState.selection;
202
- var floatingToolbarNode = selection instanceof _state.NodeSelection && selection.node;
190
+ mode = _useSharedState.mode;
203
191
  var url = node.attrs.url;
204
192
  var CompetitorPromptComponent = CompetitorPrompt && url ? /*#__PURE__*/_react.default.createElement(CompetitorPrompt, {
205
193
  sourceUrl: url,
206
194
  linkType: "inline"
207
195
  }) : null;
208
- if (__livePage && (0, _platformFeatureFlags.fg)('linking_platform_smart_links_in_live_pages')) {
209
- var showHoverPreview = floatingToolbarNode !== node;
210
- var livePagesHoverCardFadeInDelay = 800;
211
- var inlineCard = /*#__PURE__*/_react.default.createElement(WrappedInlineCard, {
212
- isHovered: isOverlayHovered,
213
- node: node,
214
- view: view,
215
- getPos: getPos,
216
- actionOptions: actionOptions,
217
- useAlternativePreloader: useAlternativePreloader,
218
- onClickCallback: onClickCallback,
219
- showHoverPreview: showHoverPreview,
220
- hoverPreviewOptions: {
221
- fadeInDelay: livePagesHoverCardFadeInDelay
222
- },
223
- isPageSSRed: isPageSSRed
224
- });
225
- return mode === 'view' ? inlineCard : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ConfigureOverlay.default, {
226
- targetElementPos: getPos(),
227
- view: view,
228
- isHoveredCallback: setIsOverlayHovered,
229
- onOpenLinkClick: function onOpenLinkClick(event) {
230
- var _pluginInjectionApi$a2;
231
- (0, _link.handleNavigation)({
232
- fireAnalyticsEvent: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions.fireAnalyticsEvent,
233
- onClickCallback: onClickCallback,
234
- url: url,
235
- event: event
236
- });
237
- }
238
- }, inlineCard), (0, _platformFeatureFlags.fg)('prompt_whiteboard_competitor_link_gate') && CompetitorPromptComponent);
239
- }
240
196
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(WrappedInlineCardWithAwareness, (0, _extends2.default)({
241
197
  node: node,
242
198
  view: view,
@@ -9,29 +9,32 @@ exports.InlineCardWithAwareness = void 0;
9
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
10
  var _react = _interopRequireWildcard(require("react"));
11
11
  var _hooks = require("@atlaskit/editor-common/hooks");
12
+ var _state = require("@atlaskit/editor-prosemirror/state");
12
13
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
14
  var _smartCard = require("@atlaskit/smart-card");
14
15
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
15
16
  var _actions = require("../pm-plugins/actions");
16
17
  var _pluginKey = require("../pm-plugins/plugin-key");
17
18
  var _AwarenessWrapper = require("../ui/AwarenessWrapper");
18
- var _OpenButtonOverlay = _interopRequireDefault(require("../ui/OpenButtonOverlay"));
19
- var _PanelButtonOverlay = _interopRequireDefault(require("../ui/PanelButtonOverlay"));
19
+ var _HoverLinkOverlay = _interopRequireDefault(require("../ui/HoverLinkOverlay"));
20
20
  var _inlineCard = require("./inlineCard");
21
21
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
22
22
  var selector = function selector(states) {
23
- var _states$editorViewMod;
23
+ var _states$editorViewMod, _states$selectionStat;
24
24
  return {
25
- mode: (_states$editorViewMod = states.editorViewModeState) === null || _states$editorViewMod === void 0 ? void 0 : _states$editorViewMod.mode
25
+ mode: (_states$editorViewMod = states.editorViewModeState) === null || _states$editorViewMod === void 0 ? void 0 : _states$editorViewMod.mode,
26
+ selection: (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection
26
27
  };
27
28
  };
28
29
  var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (pluginInjectionApi) {
29
- return (0, _hooks.useSharedPluginStateWithSelector)(pluginInjectionApi, ['editorViewMode'], selector);
30
+ return (0, _hooks.useSharedPluginStateWithSelector)(pluginInjectionApi, ['selection', 'editorViewMode'], selector);
30
31
  }, function (pluginInjectionApi) {
31
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['editorViewMode']),
32
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['selection', 'editorViewMode']),
33
+ selectionState = _useSharedPluginState.selectionState,
32
34
  editorViewModeState = _useSharedPluginState.editorViewModeState;
33
35
  return {
34
- mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode
36
+ mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode,
37
+ selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
35
38
  };
36
39
  });
37
40
  var InlineCardWithAwareness = exports.InlineCardWithAwareness = /*#__PURE__*/(0, _react.memo)(function (_ref) {
@@ -88,10 +91,13 @@ var InlineCardWithAwareness = exports.InlineCardWithAwareness = /*#__PURE__*/(0,
88
91
  }
89
92
  }, [isOverlayEnabled]);
90
93
  var _useSharedState = useSharedState(pluginInjectionApi),
91
- mode = _useSharedState.mode;
94
+ mode = _useSharedState.mode,
95
+ selection = _useSharedState.selection;
96
+ var floatingToolbarNode = selection instanceof _state.NodeSelection && selection.node;
97
+ var showHoverPreview = floatingToolbarNode !== node && (0, _platformFeatureFlags.fg)('platform_editor_preview_panel_linking');
92
98
  var innerCardWithOpenButtonOverlay = (0, _react.useMemo)(function () {
93
99
  var _pluginInjectionApi$a;
94
- return /*#__PURE__*/_react.default.createElement(_OpenButtonOverlay.default, {
100
+ return /*#__PURE__*/_react.default.createElement(_HoverLinkOverlay.default, {
95
101
  isVisible: isResolvedViewRendered,
96
102
  url: node.attrs.url,
97
103
  editorAppearance: editorAppearance,
@@ -108,9 +114,10 @@ var InlineCardWithAwareness = exports.InlineCardWithAwareness = /*#__PURE__*/(0,
108
114
  cardContext: cardContext,
109
115
  isHovered: isHovered,
110
116
  isPageSSRed: isPageSSRed,
111
- pluginInjectionApi: pluginInjectionApi
117
+ pluginInjectionApi: pluginInjectionApi,
118
+ showHoverPreview: showHoverPreview
112
119
  }));
113
- }, [isResolvedViewRendered, node, editorAppearance, view, getPos, useAlternativePreloader, actionOptions, onResolve, onClick, cardContext, isHovered, isPageSSRed, pluginInjectionApi]);
120
+ }, [isResolvedViewRendered, node, editorAppearance, view, getPos, useAlternativePreloader, actionOptions, onResolve, onClick, cardContext, isHovered, isPageSSRed, pluginInjectionApi, showHoverPreview]);
114
121
  var innerCardOriginal = (0, _react.useMemo)(function () {
115
122
  return /*#__PURE__*/_react.default.createElement(_inlineCard.InlineCard, {
116
123
  node: node,
@@ -123,19 +130,20 @@ var InlineCardWithAwareness = exports.InlineCardWithAwareness = /*#__PURE__*/(0,
123
130
  cardContext: cardContext,
124
131
  isHovered: isHovered,
125
132
  isPageSSRed: isPageSSRed,
126
- pluginInjectionApi: pluginInjectionApi
133
+ pluginInjectionApi: pluginInjectionApi,
134
+ showHoverPreview: showHoverPreview
127
135
  });
128
- }, [actionOptions, cardContext, getPos, isHovered, node, onClick, onResolve, useAlternativePreloader, view, isPageSSRed, pluginInjectionApi]);
136
+ }, [actionOptions, cardContext, getPos, isHovered, node, onClick, onResolve, useAlternativePreloader, view, isPageSSRed, pluginInjectionApi, showHoverPreview]);
129
137
  var shouldShowOpenButtonOverlay = (0, _react.useMemo)(function () {
130
138
  var shouldShowOpenButtonOverlayInChomeless = editorAppearance === 'chromeless';
131
- return (mode === 'edit' || editorAppearance === 'comment' || shouldShowOpenButtonOverlayInChomeless) && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1');
139
+ return (mode === 'edit' || editorAppearance === 'comment' || shouldShowOpenButtonOverlayInChomeless) && ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') || (0, _platformFeatureFlags.fg)('platform_editor_preview_panel_linking'));
132
140
  }, [mode, editorAppearance]);
133
141
  var innerCard = shouldShowOpenButtonOverlay ? innerCardWithOpenButtonOverlay : innerCardOriginal;
134
142
  if ((0, _platformFeatureFlags.fg)('platform_editor_preview_panel_linking')) {
135
143
  var _cardContext$value;
136
144
  var cardState = cardContext === null || cardContext === void 0 || (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 || (_cardContext$value = _cardContext$value.store) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.getState()[node.attrs.url];
137
145
  if (cardState) {
138
- var _cardContext$value2, _cardContext$value2$i, _cardContext$value3;
146
+ var _cardContext$value2, _cardContext$value2$i, _cardContext$value3, _pluginInjectionApi$a2;
139
147
  var ari = (0, _smartCard.getObjectAri)(cardState.details);
140
148
  var name = (0, _smartCard.getObjectName)(cardState.details);
141
149
  var iconUrl = (0, _smartCard.getObjectIconUrl)(cardState.details);
@@ -143,8 +151,11 @@ var InlineCardWithAwareness = exports.InlineCardWithAwareness = /*#__PURE__*/(0,
143
151
  ari: ari
144
152
  }));
145
153
  var openPreviewPanel = cardContext === null || cardContext === void 0 || (_cardContext$value3 = cardContext.value) === null || _cardContext$value3 === void 0 ? void 0 : _cardContext$value3.openPreviewPanel;
146
- var handleOpenGlancePanelClick = function handleOpenGlancePanelClick() {
154
+ var handleOpenGlancePanelClick = function handleOpenGlancePanelClick(event) {
147
155
  if (openPreviewPanel && isPanelAvailable) {
156
+ // Prevent anchor default behaviour(click to open the anchor link)
157
+ // When glance panel is available, let openPreviewPanel handle it
158
+ event.preventDefault();
148
159
  openPreviewPanel({
149
160
  url: node.attrs.url,
150
161
  ari: ari,
@@ -153,9 +164,13 @@ var InlineCardWithAwareness = exports.InlineCardWithAwareness = /*#__PURE__*/(0,
153
164
  });
154
165
  }
155
166
  };
156
- var innerCardWithPanelButtonOverlay = /*#__PURE__*/_react.default.createElement(_PanelButtonOverlay.default, {
167
+ var innerCardWithPanelButtonOverlay = /*#__PURE__*/_react.default.createElement(_HoverLinkOverlay.default, {
157
168
  isVisible: isResolvedViewRendered,
169
+ url: node.attrs.url,
158
170
  editorAppearance: editorAppearance,
171
+ editorAnalyticsApi: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions,
172
+ view: view,
173
+ showPanelButton: !!isPanelAvailable,
159
174
  onClick: handleOpenGlancePanelClick
160
175
  }, /*#__PURE__*/_react.default.createElement(_inlineCard.InlineCard, {
161
176
  node: node,
@@ -168,7 +183,8 @@ var InlineCardWithAwareness = exports.InlineCardWithAwareness = /*#__PURE__*/(0,
168
183
  cardContext: cardContext,
169
184
  isHovered: isHovered,
170
185
  isPageSSRed: isPageSSRed,
171
- pluginInjectionApi: pluginInjectionApi
186
+ pluginInjectionApi: pluginInjectionApi,
187
+ showHoverPreview: showHoverPreview
172
188
  }));
173
189
  innerCard = isPanelAvailable && openPreviewPanel ? innerCardWithPanelButtonOverlay : innerCard;
174
190
  }
@@ -4,9 +4,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.stopEvent = exports.createPlugin = exports.ALLOW_EVENTS_CLASSNAME = void 0;
8
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
7
+ exports.createPlugin = void 0;
9
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
10
  var _rafSchd = _interopRequireDefault(require("raf-schd"));
11
11
  var _reactNodeView = require("@atlaskit/editor-common/react-node-view");
12
12
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
@@ -14,7 +14,6 @@ var _styles = require("@atlaskit/editor-common/styles");
14
14
  var _state = require("@atlaskit/editor-prosemirror/state");
15
15
  var _utils = require("@atlaskit/editor-prosemirror/utils");
16
16
  var _linkingCommon = require("@atlaskit/linking-common");
17
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
18
17
  var _inlineCard = require("../nodeviews/inlineCard");
19
18
  var _lazyBlockCard = require("../nodeviews/lazy-block-card");
20
19
  var _lazyEmbedCard = require("../nodeviews/lazy-embed-card");
@@ -31,19 +30,6 @@ var _utils3 = require("./utils");
31
30
  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; }
32
31
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
33
32
  var LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK = 'smart-link-upgrade-pulse';
34
- var ALLOW_EVENTS_CLASSNAME = exports.ALLOW_EVENTS_CLASSNAME = 'card-plugin-element-allow-events';
35
- var stopEvent = exports.stopEvent = function stopEvent(event) {
36
- if (!(0, _platformFeatureFlags.fg)('linking_platform_smart_links_in_live_pages')) {
37
- return false;
38
- }
39
- var target = event.target;
40
- // Stop events from propogating to prose-mirror and selecting the node and/or
41
- // opening the toolbar, unless a parent of the target has a defined className
42
- if (target instanceof HTMLElement && target.closest(".".concat(ALLOW_EVENTS_CLASSNAME))) {
43
- return false;
44
- }
45
- return true;
46
- };
47
33
  var handleAwarenessOverlay = function handleAwarenessOverlay(view) {
48
34
  var currentState = (0, _state2.getPluginState)(view.state);
49
35
  var overlayCandidatePos = currentState === null || currentState === void 0 ? void 0 : currentState.overlayCandidatePosition;
@@ -67,11 +53,10 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
67
53
  allowEmbeds = options.allowEmbeds,
68
54
  allowBlockCards = options.allowBlockCards,
69
55
  onClickCallback = options.onClickCallback,
70
- __livePage = options.__livePage,
71
56
  isPageSSRed = options.isPageSSRed,
72
57
  CompetitorPrompt = options.CompetitorPrompt;
73
58
  var enableInlineUpgradeFeatures = !!showUpgradeDiscoverability;
74
- var inlineCardViewProducer = (0, _reactNodeView.getInlineNodeViewProducer)(_objectSpread({
59
+ var inlineCardViewProducer = (0, _reactNodeView.getInlineNodeViewProducer)({
75
60
  pmPluginFactoryParams: pmPluginFactoryParams,
76
61
  Component: _inlineCard.InlineCardNodeView,
77
62
  extraComponentProps: {
@@ -82,15 +67,10 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
82
67
  allowBlockCards: allowBlockCards,
83
68
  pluginInjectionApi: pluginInjectionApi,
84
69
  onClickCallback: onClickCallback,
85
- __livePage: __livePage,
86
70
  isPageSSRed: isPageSSRed,
87
71
  CompetitorPrompt: CompetitorPrompt
88
72
  }
89
- }, __livePage && (0, _platformFeatureFlags.fg)('linking_platform_smart_links_in_live_pages') && {
90
- extraNodeViewProps: {
91
- stopEvent: stopEvent
92
- }
93
- }));
73
+ });
94
74
  return new _safePlugin.SafePlugin({
95
75
  state: {
96
76
  init: function init() {
@@ -13,6 +13,7 @@ var _reactIntlNext = require("react-intl-next");
13
13
  var _analytics = require("@atlaskit/editor-common/analytics");
14
14
  var _messages = require("@atlaskit/editor-common/messages");
15
15
  var _linkExternal = _interopRequireDefault(require("@atlaskit/icon/core/link-external"));
16
+ var _panelRight = _interopRequireDefault(require("@atlaskit/icon/core/panel-right"));
16
17
  var _primitives = require("@atlaskit/primitives");
17
18
  var _toolbar = require("../toolbar");
18
19
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
@@ -72,19 +73,22 @@ var MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY = 45;
72
73
  var ICON_WIDTH = 16;
73
74
  var DEFAULT_OPEN_TEXT_WIDTH = 28; // Default open text width in English
74
75
 
75
- var OpenButtonOverlay = function OpenButtonOverlay(_ref) {
76
+ var HoverLinkOverlay = function HoverLinkOverlay(_ref) {
76
77
  var children = _ref.children,
77
78
  _ref$isVisible = _ref.isVisible,
78
79
  isVisible = _ref$isVisible === void 0 ? false : _ref$isVisible,
79
80
  url = _ref.url,
80
81
  editorAppearance = _ref.editorAppearance,
81
82
  editorAnalyticsApi = _ref.editorAnalyticsApi,
82
- view = _ref.view;
83
+ view = _ref.view,
84
+ onClick = _ref.onClick,
85
+ _ref$showPanelButton = _ref.showPanelButton,
86
+ showPanelButton = _ref$showPanelButton === void 0 ? false : _ref$showPanelButton;
83
87
  var _useIntl = (0, _reactIntlNext.useIntl)(),
84
88
  formatMessage = _useIntl.formatMessage;
85
- var label = formatMessage(_messages.cardMessages.openButtonTitle);
89
+ var label = showPanelButton ? formatMessage(_messages.cardMessages.panelButtonTitle) : formatMessage(_messages.cardMessages.openButtonTitle);
86
90
  var containerRef = (0, _react.useRef)(null);
87
- var openButtonRef = (0, _react.useRef)(null);
91
+ var hoverLinkButtonRef = (0, _react.useRef)(null);
88
92
  var hiddenTextRef = (0, _react.useRef)(null);
89
93
  var _useState = (0, _react.useState)(true),
90
94
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
@@ -96,12 +100,12 @@ var OpenButtonOverlay = function OpenButtonOverlay(_ref) {
96
100
  setHovered = _useState4[1];
97
101
  var openTextWidthRef = (0, _react.useRef)(null);
98
102
  (0, _react.useLayoutEffect)(function () {
99
- var _containerRef$current, _openButtonRef$curren;
103
+ var _containerRef$current, _hoverLinkButtonRef$c;
100
104
  if (!isVisible || !isHovered) {
101
105
  return;
102
106
  }
103
107
  var cardWidth = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.offsetWidth;
104
- var openButtonWidth = (_openButtonRef$curren = openButtonRef.current) === null || _openButtonRef$curren === void 0 ? void 0 : _openButtonRef$curren.offsetWidth;
108
+ var openButtonWidth = (_hoverLinkButtonRef$c = hoverLinkButtonRef.current) === null || _hoverLinkButtonRef$c === void 0 ? void 0 : _hoverLinkButtonRef$c.offsetWidth;
105
109
 
106
110
  // Get the hidden text width
107
111
  if (!openTextWidthRef.current) {
@@ -136,13 +140,19 @@ var OpenButtonOverlay = function OpenButtonOverlay(_ref) {
136
140
  }
137
141
  };
138
142
  var handleDoubleClick = function handleDoubleClick() {
139
- sendVisitLinkAnalytics(_analytics.INPUT_METHOD.DOUBLE_CLICK);
143
+ if (!showPanelButton) {
144
+ sendVisitLinkAnalytics(_analytics.INPUT_METHOD.DOUBLE_CLICK);
140
145
 
141
- // Double click opens the link in a new tab
142
- window.open(url, '_blank');
146
+ // Double click opens the link in a new tab
147
+ window.open(url, '_blank');
148
+ }
143
149
  };
144
- var handleClick = function handleClick() {
145
- sendVisitLinkAnalytics(_analytics.INPUT_METHOD.BUTTON);
150
+ var handleClick = function handleClick(event) {
151
+ if (showPanelButton && onClick) {
152
+ onClick(event);
153
+ } else {
154
+ sendVisitLinkAnalytics(_analytics.INPUT_METHOD.BUTTON);
155
+ }
146
156
  };
147
157
  return (
148
158
  // eslint-disable-next-line jsx-a11y/no-static-element-interactions
@@ -164,7 +174,7 @@ var OpenButtonOverlay = function OpenButtonOverlay(_ref) {
164
174
  size: "small",
165
175
  maxLines: 1
166
176
  }, label)), isHovered && (0, _react2.jsx)(_primitives.Anchor, {
167
- ref: openButtonRef,
177
+ ref: hoverLinkButtonRef,
168
178
  xcss: linkStyles,
169
179
  href: url,
170
180
  target: "_blank",
@@ -175,7 +185,9 @@ var OpenButtonOverlay = function OpenButtonOverlay(_ref) {
175
185
  }, (0, _react2.jsx)(_primitives.Box, {
176
186
  xcss: iconWrapperStyles,
177
187
  "data-inlinecard-button-overlay": "icon-wrapper-line-height"
178
- }, (0, _react2.jsx)(_linkExternal.default, {
188
+ }, showPanelButton ? (0, _react2.jsx)(_panelRight.default, {
189
+ label: ""
190
+ }) : (0, _react2.jsx)(_linkExternal.default, {
179
191
  label: ""
180
192
  })), showLabel && (0, _react2.jsx)(_primitives.Text, {
181
193
  size: "small",
@@ -184,4 +196,4 @@ var OpenButtonOverlay = function OpenButtonOverlay(_ref) {
184
196
  }, label)))
185
197
  );
186
198
  };
187
- var _default = exports.default = OpenButtonOverlay;
199
+ var _default = exports.default = HoverLinkOverlay;
@@ -33,6 +33,7 @@ var _linkExternalShortcut = _interopRequireDefault(require("@atlaskit/icon/core/
33
33
  var _settingsEditorSettings = _interopRequireDefault(require("@atlaskit/icon/core/migration/settings--editor-settings"));
34
34
  var _settings = _interopRequireDefault(require("@atlaskit/icon/core/settings"));
35
35
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
36
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
36
37
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
37
38
  var _doc = require("../pm-plugins/doc");
38
39
  var _pluginKey = require("../pm-plugins/plugin-key");
@@ -147,7 +148,13 @@ var floatingToolbar = exports.floatingToolbar = function floatingToolbar(cardOpt
147
148
  if (isEmbedCard) {
148
149
  // Ignored via go/ees005
149
150
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
150
- return element.querySelector(".".concat(_styles.richMediaClassName));
151
+ var richMediaElement = element.querySelector(".".concat(_styles.richMediaClassName));
152
+ if (!(0, _expValEquals.expValEquals)('platform_editor_preview_panel_responsiveness', 'isEnabled', true)) {
153
+ return richMediaElement;
154
+ }
155
+ if (richMediaElement) {
156
+ return richMediaElement;
157
+ }
151
158
  }
152
159
  return element;
153
160
  },