@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
@@ -1,20 +1,16 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
- import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
+ import React, { memo, useCallback, useEffect, useMemo, useRef } from 'react';
4
3
  import rafSchedule from 'raf-schd';
5
4
  import uuid from 'uuid/v4';
6
5
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
7
6
  import { sharedPluginStateHookMigratorFactory, useSharedPluginState, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
8
- import { handleNavigation } from '@atlaskit/editor-common/link';
9
7
  import { UnsupportedInline, findOverflowScrollParent } from '@atlaskit/editor-common/ui';
10
- import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
11
8
  import { fg } from '@atlaskit/platform-feature-flags';
12
9
  import { Card as SmartCard } from '@atlaskit/smart-card';
13
10
  import { CardSSR } from '@atlaskit/smart-card/ssr';
14
11
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
15
12
  import { registerCard, removeCard } from '../pm-plugins/actions';
16
13
  import { getAwarenessProps } from '../pm-plugins/utils';
17
- import OverlayWrapper from '../ui/ConfigureOverlay';
18
14
  import { visitCardLinkAnalytics } from '../ui/toolbar';
19
15
  import { Card } from './genericCard';
20
16
  import { InlineCardWithAwareness } from './inlineCardWithAwareness';
@@ -142,7 +138,6 @@ export var InlineCard = /*#__PURE__*/memo(function (_ref) {
142
138
  }, card) : data ? card : null;
143
139
  });
144
140
  var WrappedInlineCardWithAwareness = Card(InlineCardWithAwareness, UnsupportedInline);
145
- var WrappedInlineCard = Card(InlineCard, UnsupportedInline);
146
141
  var selector = function selector(states) {
147
142
  var _states$editorViewMod, _states$selectionStat;
148
143
  return {
@@ -178,54 +173,15 @@ export function InlineCardNodeView(props) {
178
173
  enableInlineUpgradeFeatures = props.enableInlineUpgradeFeatures,
179
174
  pluginInjectionApi = props.pluginInjectionApi,
180
175
  onClickCallback = props.onClickCallback,
181
- __livePage = props.__livePage,
182
176
  isPageSSRed = props.isPageSSRed,
183
177
  CompetitorPrompt = props.CompetitorPrompt;
184
- var _useState = useState(false),
185
- _useState2 = _slicedToArray(_useState, 2),
186
- isOverlayHovered = _useState2[0],
187
- setIsOverlayHovered = _useState2[1];
188
178
  var _useSharedState = useSharedState(pluginInjectionApi),
189
- mode = _useSharedState.mode,
190
- selection = _useSharedState.selection;
191
- var floatingToolbarNode = selection instanceof NodeSelection && selection.node;
179
+ mode = _useSharedState.mode;
192
180
  var url = node.attrs.url;
193
181
  var CompetitorPromptComponent = CompetitorPrompt && url ? /*#__PURE__*/React.createElement(CompetitorPrompt, {
194
182
  sourceUrl: url,
195
183
  linkType: "inline"
196
184
  }) : null;
197
- if (__livePage && fg('linking_platform_smart_links_in_live_pages')) {
198
- var showHoverPreview = floatingToolbarNode !== node;
199
- var livePagesHoverCardFadeInDelay = 800;
200
- var inlineCard = /*#__PURE__*/React.createElement(WrappedInlineCard, {
201
- isHovered: isOverlayHovered,
202
- node: node,
203
- view: view,
204
- getPos: getPos,
205
- actionOptions: actionOptions,
206
- useAlternativePreloader: useAlternativePreloader,
207
- onClickCallback: onClickCallback,
208
- showHoverPreview: showHoverPreview,
209
- hoverPreviewOptions: {
210
- fadeInDelay: livePagesHoverCardFadeInDelay
211
- },
212
- isPageSSRed: isPageSSRed
213
- });
214
- return mode === 'view' ? inlineCard : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(OverlayWrapper, {
215
- targetElementPos: getPos(),
216
- view: view,
217
- isHoveredCallback: setIsOverlayHovered,
218
- onOpenLinkClick: function onOpenLinkClick(event) {
219
- var _pluginInjectionApi$a2;
220
- handleNavigation({
221
- fireAnalyticsEvent: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions.fireAnalyticsEvent,
222
- onClickCallback: onClickCallback,
223
- url: url,
224
- event: event
225
- });
226
- }
227
- }, inlineCard), fg('prompt_whiteboard_competitor_link_gate') && CompetitorPromptComponent);
228
- }
229
185
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(WrappedInlineCardWithAwareness, _extends({
230
186
  node: node,
231
187
  view: view,
@@ -1,28 +1,31 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import React, { memo, useCallback, useMemo, useState } from 'react';
3
3
  import { sharedPluginStateHookMigratorFactory, useSharedPluginState, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
+ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
4
5
  import { fg } from '@atlaskit/platform-feature-flags';
5
6
  import { getObjectAri, getObjectName, getObjectIconUrl } from '@atlaskit/smart-card';
6
7
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
8
  import { registerRemoveOverlay } from '../pm-plugins/actions';
8
9
  import { pluginKey } from '../pm-plugins/plugin-key';
9
10
  import { AwarenessWrapper } from '../ui/AwarenessWrapper';
10
- import OpenButtonOverlay from '../ui/OpenButtonOverlay';
11
- import PanelButtonOverlay from '../ui/PanelButtonOverlay';
11
+ import HoverLinkOverlay from '../ui/HoverLinkOverlay';
12
12
  import { InlineCard } from './inlineCard';
13
13
  var selector = function selector(states) {
14
- var _states$editorViewMod;
14
+ var _states$editorViewMod, _states$selectionStat;
15
15
  return {
16
- mode: (_states$editorViewMod = states.editorViewModeState) === null || _states$editorViewMod === void 0 ? void 0 : _states$editorViewMod.mode
16
+ mode: (_states$editorViewMod = states.editorViewModeState) === null || _states$editorViewMod === void 0 ? void 0 : _states$editorViewMod.mode,
17
+ selection: (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection
17
18
  };
18
19
  };
19
20
  var useSharedState = sharedPluginStateHookMigratorFactory(function (pluginInjectionApi) {
20
- return useSharedPluginStateWithSelector(pluginInjectionApi, ['editorViewMode'], selector);
21
+ return useSharedPluginStateWithSelector(pluginInjectionApi, ['selection', 'editorViewMode'], selector);
21
22
  }, function (pluginInjectionApi) {
22
- var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['editorViewMode']),
23
+ var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['selection', 'editorViewMode']),
24
+ selectionState = _useSharedPluginState.selectionState,
23
25
  editorViewModeState = _useSharedPluginState.editorViewModeState;
24
26
  return {
25
- mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode
27
+ mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode,
28
+ selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
26
29
  };
27
30
  });
28
31
  export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
@@ -79,10 +82,13 @@ export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
79
82
  }
80
83
  }, [isOverlayEnabled]);
81
84
  var _useSharedState = useSharedState(pluginInjectionApi),
82
- mode = _useSharedState.mode;
85
+ mode = _useSharedState.mode,
86
+ selection = _useSharedState.selection;
87
+ var floatingToolbarNode = selection instanceof NodeSelection && selection.node;
88
+ var showHoverPreview = floatingToolbarNode !== node && fg('platform_editor_preview_panel_linking');
83
89
  var innerCardWithOpenButtonOverlay = useMemo(function () {
84
90
  var _pluginInjectionApi$a;
85
- return /*#__PURE__*/React.createElement(OpenButtonOverlay, {
91
+ return /*#__PURE__*/React.createElement(HoverLinkOverlay, {
86
92
  isVisible: isResolvedViewRendered,
87
93
  url: node.attrs.url,
88
94
  editorAppearance: editorAppearance,
@@ -99,9 +105,10 @@ export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
99
105
  cardContext: cardContext,
100
106
  isHovered: isHovered,
101
107
  isPageSSRed: isPageSSRed,
102
- pluginInjectionApi: pluginInjectionApi
108
+ pluginInjectionApi: pluginInjectionApi,
109
+ showHoverPreview: showHoverPreview
103
110
  }));
104
- }, [isResolvedViewRendered, node, editorAppearance, view, getPos, useAlternativePreloader, actionOptions, onResolve, onClick, cardContext, isHovered, isPageSSRed, pluginInjectionApi]);
111
+ }, [isResolvedViewRendered, node, editorAppearance, view, getPos, useAlternativePreloader, actionOptions, onResolve, onClick, cardContext, isHovered, isPageSSRed, pluginInjectionApi, showHoverPreview]);
105
112
  var innerCardOriginal = useMemo(function () {
106
113
  return /*#__PURE__*/React.createElement(InlineCard, {
107
114
  node: node,
@@ -114,19 +121,20 @@ export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
114
121
  cardContext: cardContext,
115
122
  isHovered: isHovered,
116
123
  isPageSSRed: isPageSSRed,
117
- pluginInjectionApi: pluginInjectionApi
124
+ pluginInjectionApi: pluginInjectionApi,
125
+ showHoverPreview: showHoverPreview
118
126
  });
119
- }, [actionOptions, cardContext, getPos, isHovered, node, onClick, onResolve, useAlternativePreloader, view, isPageSSRed, pluginInjectionApi]);
127
+ }, [actionOptions, cardContext, getPos, isHovered, node, onClick, onResolve, useAlternativePreloader, view, isPageSSRed, pluginInjectionApi, showHoverPreview]);
120
128
  var shouldShowOpenButtonOverlay = useMemo(function () {
121
129
  var shouldShowOpenButtonOverlayInChomeless = editorAppearance === 'chromeless';
122
- return (mode === 'edit' || editorAppearance === 'comment' || shouldShowOpenButtonOverlayInChomeless) && editorExperiment('platform_editor_controls', 'variant1');
130
+ return (mode === 'edit' || editorAppearance === 'comment' || shouldShowOpenButtonOverlayInChomeless) && (editorExperiment('platform_editor_controls', 'variant1') || fg('platform_editor_preview_panel_linking'));
123
131
  }, [mode, editorAppearance]);
124
132
  var innerCard = shouldShowOpenButtonOverlay ? innerCardWithOpenButtonOverlay : innerCardOriginal;
125
133
  if (fg('platform_editor_preview_panel_linking')) {
126
134
  var _cardContext$value;
127
135
  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];
128
136
  if (cardState) {
129
- var _cardContext$value2, _cardContext$value2$i, _cardContext$value3;
137
+ var _cardContext$value2, _cardContext$value2$i, _cardContext$value3, _pluginInjectionApi$a2;
130
138
  var ari = getObjectAri(cardState.details);
131
139
  var name = getObjectName(cardState.details);
132
140
  var iconUrl = getObjectIconUrl(cardState.details);
@@ -134,8 +142,11 @@ export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
134
142
  ari: ari
135
143
  }));
136
144
  var openPreviewPanel = cardContext === null || cardContext === void 0 || (_cardContext$value3 = cardContext.value) === null || _cardContext$value3 === void 0 ? void 0 : _cardContext$value3.openPreviewPanel;
137
- var handleOpenGlancePanelClick = function handleOpenGlancePanelClick() {
145
+ var handleOpenGlancePanelClick = function handleOpenGlancePanelClick(event) {
138
146
  if (openPreviewPanel && isPanelAvailable) {
147
+ // Prevent anchor default behaviour(click to open the anchor link)
148
+ // When glance panel is available, let openPreviewPanel handle it
149
+ event.preventDefault();
139
150
  openPreviewPanel({
140
151
  url: node.attrs.url,
141
152
  ari: ari,
@@ -144,9 +155,13 @@ export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
144
155
  });
145
156
  }
146
157
  };
147
- var innerCardWithPanelButtonOverlay = /*#__PURE__*/React.createElement(PanelButtonOverlay, {
158
+ var innerCardWithPanelButtonOverlay = /*#__PURE__*/React.createElement(HoverLinkOverlay, {
148
159
  isVisible: isResolvedViewRendered,
160
+ url: node.attrs.url,
149
161
  editorAppearance: editorAppearance,
162
+ editorAnalyticsApi: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions,
163
+ view: view,
164
+ showPanelButton: !!isPanelAvailable,
150
165
  onClick: handleOpenGlancePanelClick
151
166
  }, /*#__PURE__*/React.createElement(InlineCard, {
152
167
  node: node,
@@ -159,7 +174,8 @@ export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
159
174
  cardContext: cardContext,
160
175
  isHovered: isHovered,
161
176
  isPageSSRed: isPageSSRed,
162
- pluginInjectionApi: pluginInjectionApi
177
+ pluginInjectionApi: pluginInjectionApi,
178
+ showHoverPreview: showHoverPreview
163
179
  }));
164
180
  innerCard = isPanelAvailable && openPreviewPanel ? innerCardWithPanelButtonOverlay : innerCard;
165
181
  }
@@ -1,5 +1,5 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
3
  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; }
4
4
  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) { _defineProperty(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; }
5
5
  import rafSchedule from 'raf-schd';
@@ -9,7 +9,6 @@ import { DATASOURCE_INNER_CONTAINER_CLASSNAME } from '@atlaskit/editor-common/st
9
9
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
10
10
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
11
11
  import { DATASOURCE_DEFAULT_LAYOUT } from '@atlaskit/linking-common';
12
- import { fg } from '@atlaskit/platform-feature-flags';
13
12
  import { InlineCardNodeView } from '../nodeviews/inlineCard';
14
13
  import { lazyBlockCardView } from '../nodeviews/lazy-block-card';
15
14
  import { lazyEmbedCardView } from '../nodeviews/lazy-embed-card';
@@ -24,19 +23,6 @@ import { handleProvider, resolveWithProvider } from './util/resolve';
24
23
  import { getNewRequests, getPluginState, getPluginStateWithUpdatedPos } from './util/state';
25
24
  import { isBlockSupportedAtPosition, isEmbedSupportedAtPosition } from './utils';
26
25
  var LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK = 'smart-link-upgrade-pulse';
27
- export var ALLOW_EVENTS_CLASSNAME = 'card-plugin-element-allow-events';
28
- export var stopEvent = function stopEvent(event) {
29
- if (!fg('linking_platform_smart_links_in_live_pages')) {
30
- return false;
31
- }
32
- var target = event.target;
33
- // Stop events from propogating to prose-mirror and selecting the node and/or
34
- // opening the toolbar, unless a parent of the target has a defined className
35
- if (target instanceof HTMLElement && target.closest(".".concat(ALLOW_EVENTS_CLASSNAME))) {
36
- return false;
37
- }
38
- return true;
39
- };
40
26
  var handleAwarenessOverlay = function handleAwarenessOverlay(view) {
41
27
  var currentState = getPluginState(view.state);
42
28
  var overlayCandidatePos = currentState === null || currentState === void 0 ? void 0 : currentState.overlayCandidatePosition;
@@ -60,11 +46,10 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
60
46
  allowEmbeds = options.allowEmbeds,
61
47
  allowBlockCards = options.allowBlockCards,
62
48
  onClickCallback = options.onClickCallback,
63
- __livePage = options.__livePage,
64
49
  isPageSSRed = options.isPageSSRed,
65
50
  CompetitorPrompt = options.CompetitorPrompt;
66
51
  var enableInlineUpgradeFeatures = !!showUpgradeDiscoverability;
67
- var inlineCardViewProducer = getInlineNodeViewProducer(_objectSpread({
52
+ var inlineCardViewProducer = getInlineNodeViewProducer({
68
53
  pmPluginFactoryParams: pmPluginFactoryParams,
69
54
  Component: InlineCardNodeView,
70
55
  extraComponentProps: {
@@ -75,15 +60,10 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
75
60
  allowBlockCards: allowBlockCards,
76
61
  pluginInjectionApi: pluginInjectionApi,
77
62
  onClickCallback: onClickCallback,
78
- __livePage: __livePage,
79
63
  isPageSSRed: isPageSSRed,
80
64
  CompetitorPrompt: CompetitorPrompt
81
65
  }
82
- }, __livePage && fg('linking_platform_smart_links_in_live_pages') && {
83
- extraNodeViewProps: {
84
- stopEvent: stopEvent
85
- }
86
- }));
66
+ });
87
67
  return new SafePlugin({
88
68
  state: {
89
69
  init: function init() {
@@ -12,6 +12,7 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
12
12
  import { cardMessages } from '@atlaskit/editor-common/messages';
13
13
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
14
14
  import LinkExternalIcon from '@atlaskit/icon/core/link-external';
15
+ import PanelRightIcon from '@atlaskit/icon/core/panel-right';
15
16
  // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
16
17
  import { Anchor, Box, Text, xcss } from '@atlaskit/primitives';
17
18
  import { visitCardLinkAnalytics } from '../toolbar';
@@ -58,19 +59,22 @@ var MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY = 45;
58
59
  var ICON_WIDTH = 16;
59
60
  var DEFAULT_OPEN_TEXT_WIDTH = 28; // Default open text width in English
60
61
 
61
- var OpenButtonOverlay = function OpenButtonOverlay(_ref) {
62
+ var HoverLinkOverlay = function HoverLinkOverlay(_ref) {
62
63
  var children = _ref.children,
63
64
  _ref$isVisible = _ref.isVisible,
64
65
  isVisible = _ref$isVisible === void 0 ? false : _ref$isVisible,
65
66
  url = _ref.url,
66
67
  editorAppearance = _ref.editorAppearance,
67
68
  editorAnalyticsApi = _ref.editorAnalyticsApi,
68
- view = _ref.view;
69
+ view = _ref.view,
70
+ onClick = _ref.onClick,
71
+ _ref$showPanelButton = _ref.showPanelButton,
72
+ showPanelButton = _ref$showPanelButton === void 0 ? false : _ref$showPanelButton;
69
73
  var _useIntl = useIntl(),
70
74
  formatMessage = _useIntl.formatMessage;
71
- var label = formatMessage(cardMessages.openButtonTitle);
75
+ var label = showPanelButton ? formatMessage(cardMessages.panelButtonTitle) : formatMessage(cardMessages.openButtonTitle);
72
76
  var containerRef = useRef(null);
73
- var openButtonRef = useRef(null);
77
+ var hoverLinkButtonRef = useRef(null);
74
78
  var hiddenTextRef = useRef(null);
75
79
  var _useState = useState(true),
76
80
  _useState2 = _slicedToArray(_useState, 2),
@@ -82,12 +86,12 @@ var OpenButtonOverlay = function OpenButtonOverlay(_ref) {
82
86
  setHovered = _useState4[1];
83
87
  var openTextWidthRef = useRef(null);
84
88
  useLayoutEffect(function () {
85
- var _containerRef$current, _openButtonRef$curren;
89
+ var _containerRef$current, _hoverLinkButtonRef$c;
86
90
  if (!isVisible || !isHovered) {
87
91
  return;
88
92
  }
89
93
  var cardWidth = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.offsetWidth;
90
- var openButtonWidth = (_openButtonRef$curren = openButtonRef.current) === null || _openButtonRef$curren === void 0 ? void 0 : _openButtonRef$curren.offsetWidth;
94
+ var openButtonWidth = (_hoverLinkButtonRef$c = hoverLinkButtonRef.current) === null || _hoverLinkButtonRef$c === void 0 ? void 0 : _hoverLinkButtonRef$c.offsetWidth;
91
95
 
92
96
  // Get the hidden text width
93
97
  if (!openTextWidthRef.current) {
@@ -122,13 +126,19 @@ var OpenButtonOverlay = function OpenButtonOverlay(_ref) {
122
126
  }
123
127
  };
124
128
  var handleDoubleClick = function handleDoubleClick() {
125
- sendVisitLinkAnalytics(INPUT_METHOD.DOUBLE_CLICK);
129
+ if (!showPanelButton) {
130
+ sendVisitLinkAnalytics(INPUT_METHOD.DOUBLE_CLICK);
126
131
 
127
- // Double click opens the link in a new tab
128
- window.open(url, '_blank');
132
+ // Double click opens the link in a new tab
133
+ window.open(url, '_blank');
134
+ }
129
135
  };
130
- var handleClick = function handleClick() {
131
- sendVisitLinkAnalytics(INPUT_METHOD.BUTTON);
136
+ var handleClick = function handleClick(event) {
137
+ if (showPanelButton && onClick) {
138
+ onClick(event);
139
+ } else {
140
+ sendVisitLinkAnalytics(INPUT_METHOD.BUTTON);
141
+ }
132
142
  };
133
143
  return (
134
144
  // eslint-disable-next-line jsx-a11y/no-static-element-interactions
@@ -150,7 +160,7 @@ var OpenButtonOverlay = function OpenButtonOverlay(_ref) {
150
160
  size: "small",
151
161
  maxLines: 1
152
162
  }, label)), isHovered && jsx(Anchor, {
153
- ref: openButtonRef,
163
+ ref: hoverLinkButtonRef,
154
164
  xcss: linkStyles,
155
165
  href: url,
156
166
  target: "_blank",
@@ -161,7 +171,9 @@ var OpenButtonOverlay = function OpenButtonOverlay(_ref) {
161
171
  }, jsx(Box, {
162
172
  xcss: iconWrapperStyles,
163
173
  "data-inlinecard-button-overlay": "icon-wrapper-line-height"
164
- }, jsx(LinkExternalIcon, {
174
+ }, showPanelButton ? jsx(PanelRightIcon, {
175
+ label: ""
176
+ }) : jsx(LinkExternalIcon, {
165
177
  label: ""
166
178
  })), showLabel && jsx(Text, {
167
179
  size: "small",
@@ -170,4 +182,4 @@ var OpenButtonOverlay = function OpenButtonOverlay(_ref) {
170
182
  }, label)))
171
183
  );
172
184
  };
173
- export default OpenButtonOverlay;
185
+ export default HoverLinkOverlay;
@@ -27,6 +27,7 @@ import OpenIcon from '@atlaskit/icon/core/migration/link-external--shortcut';
27
27
  import CogIcon from '@atlaskit/icon/core/migration/settings--editor-settings';
28
28
  import SettingsIcon from '@atlaskit/icon/core/settings';
29
29
  import { fg } from '@atlaskit/platform-feature-flags';
30
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
30
31
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
31
32
  import { changeSelectedCardToText } from '../pm-plugins/doc';
32
33
  import { pluginKey } from '../pm-plugins/plugin-key';
@@ -138,7 +139,13 @@ export var floatingToolbar = function floatingToolbar(cardOptions, lpLinkPicker,
138
139
  if (isEmbedCard) {
139
140
  // Ignored via go/ees005
140
141
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
141
- return element.querySelector(".".concat(richMediaClassName));
142
+ var richMediaElement = element.querySelector(".".concat(richMediaClassName));
143
+ if (!expValEquals('platform_editor_preview_panel_responsiveness', 'isEnabled', true)) {
144
+ return richMediaElement;
145
+ }
146
+ if (richMediaElement) {
147
+ return richMediaElement;
148
+ }
142
149
  }
143
150
  return element;
144
151
  },
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { type ComponentProps } from 'react';
2
2
  import type { RichMediaLayout } from '@atlaskit/adf-schema';
3
3
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
4
4
  import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
@@ -43,6 +43,7 @@ export declare class EmbedCardComponent extends React.PureComponent<SmartCardPro
43
43
  private removeCard;
44
44
  render(): React.JSX.Element;
45
45
  }
46
+ export declare const EmbedOrBlockCardComponent: (props: ComponentProps<typeof EmbedCardComponent>) => React.JSX.Element;
46
47
  export type EmbedCardNodeViewProps = Pick<SmartCardProps, 'eventDispatcher' | 'allowResizing' | 'fullWidthMode' | 'dispatchAnalyticsEvent' | 'pluginInjectionApi' | 'actionOptions' | 'onClickCallback' | 'CompetitorPrompt'>;
47
48
  export declare class EmbedCard extends ReactNodeView<EmbedCardNodeViewProps> {
48
49
  private id;
@@ -5,7 +5,7 @@ import type { Decoration, EditorView } from '@atlaskit/editor-prosemirror/view';
5
5
  import type { SmartCardProps } from './genericCard';
6
6
  import { type InlineCardWithAwarenessProps } from './inlineCardWithAwareness';
7
7
  export declare const InlineCard: React.MemoExoticComponent<({ node, cardContext, actionOptions, useAlternativePreloader, view, getPos, onClick: propsOnClick, onResolve: onRes, isHovered, showHoverPreview, hoverPreviewOptions, isPageSSRed, pluginInjectionApi, }: SmartCardProps) => React.JSX.Element | null>;
8
- export type InlineCardNodeViewProps = Pick<SmartCardProps, 'useAlternativePreloader' | 'actionOptions' | 'allowEmbeds' | 'allowBlockCards' | 'enableInlineUpgradeFeatures' | 'pluginInjectionApi' | 'onClickCallback' | '__livePage' | 'isPageSSRed' | 'CompetitorPrompt'>;
8
+ export type InlineCardNodeViewProps = Pick<SmartCardProps, 'useAlternativePreloader' | 'actionOptions' | 'allowEmbeds' | 'allowBlockCards' | 'enableInlineUpgradeFeatures' | 'pluginInjectionApi' | 'onClickCallback' | 'isPageSSRed' | 'CompetitorPrompt'>;
9
9
  /**
10
10
  *
11
11
  * @param props
@@ -2,6 +2,4 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
3
3
  import type { cardPlugin } from '../index';
4
4
  import type { CardPluginOptions, CardPluginState } from '../types';
5
- export declare const ALLOW_EVENTS_CLASSNAME = "card-plugin-element-allow-events";
6
- export declare const stopEvent: (event: Event) => boolean;
7
5
  export declare const createPlugin: (options: CardPluginOptions, pluginInjectionApi: ExtractInjectionAPI<typeof cardPlugin> | undefined) => (pmPluginFactoryParams: PMPluginFactoryParams) => SafePlugin<CardPluginState>;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+ import React from 'react';
6
+ import { jsx } from '@emotion/react';
7
+ import type { HoverLinkOverlayProps } from './types';
8
+ declare const HoverLinkOverlay: ({ children, isVisible, url, editorAppearance, editorAnalyticsApi, view, onClick, showPanelButton, }: React.PropsWithChildren<HoverLinkOverlayProps>) => jsx.JSX.Element;
9
+ export default HoverLinkOverlay;
@@ -2,10 +2,12 @@
2
2
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
3
  import type { EditorAppearance } from '@atlaskit/editor-common/types';
4
4
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
- export type OpenButtonOverlayProps = React.HTMLAttributes<HTMLSpanElement> & {
5
+ export type HoverLinkOverlayProps = React.HTMLAttributes<HTMLSpanElement> & {
6
6
  isVisible?: boolean;
7
7
  url: string;
8
8
  editorAppearance?: EditorAppearance;
9
9
  editorAnalyticsApi?: EditorAnalyticsAPI;
10
10
  view?: EditorView;
11
+ onClick?: (event: React.MouseEvent<HTMLAnchorElement>) => void;
12
+ showPanelButton?: boolean;
11
13
  };
@@ -20,5 +20,5 @@ export declare class DatasourceErrorBoundary extends React.Component<DatasourceE
20
20
  error: Error | APIError;
21
21
  };
22
22
  componentDidCatch(error: Error | APIError): void;
23
- render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
23
+ render(): string | number | boolean | React.JSX.Element | Iterable<React.ReactNode> | null | undefined;
24
24
  }
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { type ComponentProps } from 'react';
2
2
  import type { RichMediaLayout } from '@atlaskit/adf-schema';
3
3
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
4
4
  import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
@@ -43,6 +43,7 @@ export declare class EmbedCardComponent extends React.PureComponent<SmartCardPro
43
43
  private removeCard;
44
44
  render(): React.JSX.Element;
45
45
  }
46
+ export declare const EmbedOrBlockCardComponent: (props: ComponentProps<typeof EmbedCardComponent>) => React.JSX.Element;
46
47
  export type EmbedCardNodeViewProps = Pick<SmartCardProps, 'eventDispatcher' | 'allowResizing' | 'fullWidthMode' | 'dispatchAnalyticsEvent' | 'pluginInjectionApi' | 'actionOptions' | 'onClickCallback' | 'CompetitorPrompt'>;
47
48
  export declare class EmbedCard extends ReactNodeView<EmbedCardNodeViewProps> {
48
49
  private id;
@@ -5,7 +5,7 @@ import type { Decoration, EditorView } from '@atlaskit/editor-prosemirror/view';
5
5
  import type { SmartCardProps } from './genericCard';
6
6
  import { type InlineCardWithAwarenessProps } from './inlineCardWithAwareness';
7
7
  export declare const InlineCard: React.MemoExoticComponent<({ node, cardContext, actionOptions, useAlternativePreloader, view, getPos, onClick: propsOnClick, onResolve: onRes, isHovered, showHoverPreview, hoverPreviewOptions, isPageSSRed, pluginInjectionApi, }: SmartCardProps) => React.JSX.Element | null>;
8
- export type InlineCardNodeViewProps = Pick<SmartCardProps, 'useAlternativePreloader' | 'actionOptions' | 'allowEmbeds' | 'allowBlockCards' | 'enableInlineUpgradeFeatures' | 'pluginInjectionApi' | 'onClickCallback' | '__livePage' | 'isPageSSRed' | 'CompetitorPrompt'>;
8
+ export type InlineCardNodeViewProps = Pick<SmartCardProps, 'useAlternativePreloader' | 'actionOptions' | 'allowEmbeds' | 'allowBlockCards' | 'enableInlineUpgradeFeatures' | 'pluginInjectionApi' | 'onClickCallback' | 'isPageSSRed' | 'CompetitorPrompt'>;
9
9
  /**
10
10
  *
11
11
  * @param props
@@ -2,6 +2,4 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
3
3
  import type { cardPlugin } from '../index';
4
4
  import type { CardPluginOptions, CardPluginState } from '../types';
5
- export declare const ALLOW_EVENTS_CLASSNAME = "card-plugin-element-allow-events";
6
- export declare const stopEvent: (event: Event) => boolean;
7
5
  export declare const createPlugin: (options: CardPluginOptions, pluginInjectionApi: ExtractInjectionAPI<typeof cardPlugin> | undefined) => (pmPluginFactoryParams: PMPluginFactoryParams) => SafePlugin<CardPluginState>;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+ import React from 'react';
6
+ import { jsx } from '@emotion/react';
7
+ import type { HoverLinkOverlayProps } from './types';
8
+ declare const HoverLinkOverlay: ({ children, isVisible, url, editorAppearance, editorAnalyticsApi, view, onClick, showPanelButton, }: React.PropsWithChildren<HoverLinkOverlayProps>) => jsx.JSX.Element;
9
+ export default HoverLinkOverlay;
@@ -2,10 +2,12 @@
2
2
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
3
  import type { EditorAppearance } from '@atlaskit/editor-common/types';
4
4
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
- export type OpenButtonOverlayProps = React.HTMLAttributes<HTMLSpanElement> & {
5
+ export type HoverLinkOverlayProps = React.HTMLAttributes<HTMLSpanElement> & {
6
6
  isVisible?: boolean;
7
7
  url: string;
8
8
  editorAppearance?: EditorAppearance;
9
9
  editorAnalyticsApi?: EditorAnalyticsAPI;
10
10
  view?: EditorView;
11
+ onClick?: (event: React.MouseEvent<HTMLAnchorElement>) => void;
12
+ showPanelButton?: boolean;
11
13
  };
@@ -20,5 +20,5 @@ export declare class DatasourceErrorBoundary extends React.Component<DatasourceE
20
20
  error: Error | APIError;
21
21
  };
22
22
  componentDidCatch(error: Error | APIError): void;
23
- render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
23
+ render(): string | number | boolean | React.JSX.Element | Iterable<React.ReactNode> | null | undefined;
24
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "7.1.0",
3
+ "version": "7.2.1",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -49,7 +49,7 @@
49
49
  "@atlaskit/editor-prosemirror": "7.0.0",
50
50
  "@atlaskit/editor-shared-styles": "^3.5.0",
51
51
  "@atlaskit/frontend-utilities": "^3.1.0",
52
- "@atlaskit/icon": "^27.5.0",
52
+ "@atlaskit/icon": "^27.7.0",
53
53
  "@atlaskit/link": "^3.2.0",
54
54
  "@atlaskit/link-analytics": "^10.0.0",
55
55
  "@atlaskit/link-client-extension": "^5.0.0",
@@ -58,10 +58,11 @@
58
58
  "@atlaskit/linking-types": "^14.0.0",
59
59
  "@atlaskit/menu": "^8.0.0",
60
60
  "@atlaskit/platform-feature-flags": "^1.1.0",
61
+ "@atlaskit/platform-feature-flags-react": "^0.2.0",
61
62
  "@atlaskit/primitives": "^14.10.0",
62
- "@atlaskit/smart-card": "^40.4.0",
63
+ "@atlaskit/smart-card": "^40.5.0",
63
64
  "@atlaskit/theme": "^19.0.0",
64
- "@atlaskit/tmp-editor-statsig": "^9.9.0",
65
+ "@atlaskit/tmp-editor-statsig": "^9.12.0",
65
66
  "@atlaskit/tokens": "^5.6.0",
66
67
  "@babel/runtime": "^7.0.0",
67
68
  "@emotion/react": "^11.7.1",
@@ -71,7 +72,7 @@
71
72
  "uuid": "^3.1.0"
72
73
  },
73
74
  "peerDependencies": {
74
- "@atlaskit/editor-common": "^107.9.0",
75
+ "@atlaskit/editor-common": "^107.12.0",
75
76
  "@atlaskit/link-provider": "^3.4.0",
76
77
  "react": "^18.2.0",
77
78
  "react-intl-next": "npm:react-intl@^5.18.1"
@@ -116,9 +117,6 @@
116
117
  "editor_inline_comments_paste_insert_nodes": {
117
118
  "type": "boolean"
118
119
  },
119
- "linking_platform_smart_links_in_live_pages": {
120
- "type": "boolean"
121
- },
122
120
  "confluence-issue-terminology-refresh": {
123
121
  "type": "boolean"
124
122
  },