@atlaskit/editor-plugin-card 7.1.0 → 7.2.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/nodeviews/genericCard.js +2 -19
  3. package/dist/cjs/nodeviews/inlineCard.js +1 -45
  4. package/dist/cjs/nodeviews/inlineCardWithAwareness.js +34 -18
  5. package/dist/cjs/pm-plugins/main.js +4 -24
  6. package/dist/cjs/ui/{OpenButtonOverlay → HoverLinkOverlay}/index.js +26 -14
  7. package/dist/es2019/nodeviews/genericCard.js +2 -19
  8. package/dist/es2019/nodeviews/inlineCard.js +2 -42
  9. package/dist/es2019/nodeviews/inlineCardWithAwareness.js +34 -18
  10. package/dist/es2019/pm-plugins/main.js +1 -23
  11. package/dist/es2019/ui/{OpenButtonOverlay → HoverLinkOverlay}/index.js +25 -14
  12. package/dist/esm/nodeviews/genericCard.js +2 -19
  13. package/dist/esm/nodeviews/inlineCard.js +2 -46
  14. package/dist/esm/nodeviews/inlineCardWithAwareness.js +34 -18
  15. package/dist/esm/pm-plugins/main.js +3 -23
  16. package/dist/esm/ui/{OpenButtonOverlay → HoverLinkOverlay}/index.js +26 -14
  17. package/dist/types/nodeviews/inlineCard.d.ts +1 -1
  18. package/dist/types/pm-plugins/main.d.ts +0 -2
  19. package/dist/types/ui/HoverLinkOverlay/index.d.ts +9 -0
  20. package/dist/types/ui/{OpenButtonOverlay → HoverLinkOverlay}/types.d.ts +3 -1
  21. package/dist/types/ui/datasourceErrorBoundary.d.ts +1 -1
  22. package/dist/types-ts4.5/nodeviews/inlineCard.d.ts +1 -1
  23. package/dist/types-ts4.5/pm-plugins/main.d.ts +0 -2
  24. package/dist/types-ts4.5/ui/HoverLinkOverlay/index.d.ts +9 -0
  25. package/dist/types-ts4.5/ui/{OpenButtonOverlay → HoverLinkOverlay}/types.d.ts +3 -1
  26. package/dist/types-ts4.5/ui/datasourceErrorBoundary.d.ts +1 -1
  27. package/package.json +5 -8
  28. package/dist/cjs/ui/PanelButtonOverlay/index.js +0 -171
  29. package/dist/cjs/ui/PanelButtonOverlay/types.js +0 -5
  30. package/dist/es2019/ui/PanelButtonOverlay/index.js +0 -148
  31. package/dist/esm/ui/OpenButtonOverlay/types.js +0 -1
  32. package/dist/esm/ui/PanelButtonOverlay/index.js +0 -158
  33. package/dist/esm/ui/PanelButtonOverlay/types.js +0 -1
  34. package/dist/types/ui/OpenButtonOverlay/index.d.ts +0 -9
  35. package/dist/types/ui/PanelButtonOverlay/index.d.ts +0 -9
  36. package/dist/types/ui/PanelButtonOverlay/types.d.ts +0 -7
  37. package/dist/types-ts4.5/ui/OpenButtonOverlay/index.d.ts +0 -9
  38. package/dist/types-ts4.5/ui/PanelButtonOverlay/index.d.ts +0 -9
  39. package/dist/types-ts4.5/ui/PanelButtonOverlay/types.d.ts +0 -7
  40. /package/dist/cjs/ui/{OpenButtonOverlay → HoverLinkOverlay}/types.js +0 -0
  41. /package/dist/es2019/ui/{OpenButtonOverlay → HoverLinkOverlay}/types.js +0 -0
  42. /package/dist/{es2019/ui/PanelButtonOverlay → esm/ui/HoverLinkOverlay}/types.js +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 7.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#189119](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/189119)
8
+ [`3422f57cf2b75`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3422f57cf2b75) -
9
+ Removing linking_platform_smart_links_in_live_pages FF
10
+
11
+ ### Patch Changes
12
+
13
+ - [#187274](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/187274)
14
+ [`06b83ebb34346`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/06b83ebb34346) -
15
+ [ux] ED-28390 platformise open hover button
16
+ - [#187671](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/187671)
17
+ [`f0b9b62ce032f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f0b9b62ce032f) -
18
+ [ux] ED-28547: Added hover card when hover smartlinks
19
+ - Updated dependencies
20
+
3
21
  ## 7.1.0
4
22
 
5
23
  ### Minor Changes
@@ -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;
@@ -31,8 +31,7 @@ const WithClickHandler = ({
31
31
  pluginInjectionApi,
32
32
  url,
33
33
  onClickCallback,
34
- children,
35
- __livePage
34
+ children
36
35
  }) => {
37
36
  const {
38
37
  mode
@@ -47,21 +46,6 @@ const WithClickHandler = ({
47
46
  } catch {}
48
47
  }
49
48
  }, [url, onClickCallback]);
50
- if (fg('linking_platform_smart_links_in_live_pages')) {
51
- // Ignored via go/ees007
52
- // eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
53
- /**
54
- * @todo: Add a check to determine if we're currently in a live page once ED-23920 and plugin
55
- * is complete. The logic for which should allow navigation if we're in a live page and no callback
56
- * has been provided. E.g.
57
- *
58
- * const allowNavigation = isLivePage && !onClickCallback;
59
- */
60
- const allowNavigation = __livePage && !onClickCallback;
61
- return /*#__PURE__*/React.createElement(React.Fragment, null, children({
62
- onClick: allowNavigation ? undefined : onClick
63
- }));
64
- }
65
49
 
66
50
  // Setting `onClick` to `undefined` ensures clicks on smartcards navigate to the URL.
67
51
  // If in view mode and not overriding with onClickCallback option, then allow smartlinks to navigate on click.
@@ -130,8 +114,7 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
130
114
  }, /*#__PURE__*/React.createElement(WithClickHandler, {
131
115
  pluginInjectionApi: pluginInjectionApi,
132
116
  onClickCallback: onClickCallback,
133
- url: url,
134
- __livePage: this.props.__livePage
117
+ url: url
135
118
  }, ({
136
119
  onClick
137
120
  }) => /*#__PURE__*/React.createElement(WithCardContext, null, cardContext => /*#__PURE__*/React.createElement(SmartCardComponent, _extends({
@@ -1,19 +1,16 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
+ import React, { memo, useCallback, useEffect, useMemo, useRef } from 'react';
3
3
  import rafSchedule from 'raf-schd';
4
4
  import uuid from 'uuid/v4';
5
5
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
6
6
  import { sharedPluginStateHookMigratorFactory, useSharedPluginState, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
7
- import { handleNavigation } from '@atlaskit/editor-common/link';
8
7
  import { UnsupportedInline, findOverflowScrollParent } from '@atlaskit/editor-common/ui';
9
- import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
10
8
  import { fg } from '@atlaskit/platform-feature-flags';
11
9
  import { Card as SmartCard } from '@atlaskit/smart-card';
12
10
  import { CardSSR } from '@atlaskit/smart-card/ssr';
13
11
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
14
12
  import { registerCard, removeCard } from '../pm-plugins/actions';
15
13
  import { getAwarenessProps } from '../pm-plugins/utils';
16
- import OverlayWrapper from '../ui/ConfigureOverlay';
17
14
  import { visitCardLinkAnalytics } from '../ui/toolbar';
18
15
  import { Card } from './genericCard';
19
16
  import { InlineCardWithAwareness } from './inlineCardWithAwareness';
@@ -148,7 +145,6 @@ export const InlineCard = /*#__PURE__*/memo(({
148
145
  }, card) : data ? card : null;
149
146
  });
150
147
  const WrappedInlineCardWithAwareness = Card(InlineCardWithAwareness, UnsupportedInline);
151
- const WrappedInlineCard = Card(InlineCard, UnsupportedInline);
152
148
  const selector = states => {
153
149
  var _states$editorViewMod, _states$selectionStat;
154
150
  return {
@@ -186,53 +182,17 @@ export function InlineCardNodeView(props) {
186
182
  enableInlineUpgradeFeatures,
187
183
  pluginInjectionApi,
188
184
  onClickCallback,
189
- __livePage,
190
185
  isPageSSRed,
191
186
  CompetitorPrompt
192
187
  } = props;
193
- const [isOverlayHovered, setIsOverlayHovered] = useState(false);
194
188
  const {
195
- mode,
196
- selection
189
+ mode
197
190
  } = useSharedState(pluginInjectionApi);
198
- const floatingToolbarNode = selection instanceof NodeSelection && selection.node;
199
191
  const url = node.attrs.url;
200
192
  const CompetitorPromptComponent = CompetitorPrompt && url ? /*#__PURE__*/React.createElement(CompetitorPrompt, {
201
193
  sourceUrl: url,
202
194
  linkType: "inline"
203
195
  }) : null;
204
- if (__livePage && fg('linking_platform_smart_links_in_live_pages')) {
205
- const showHoverPreview = floatingToolbarNode !== node;
206
- const livePagesHoverCardFadeInDelay = 800;
207
- const inlineCard = /*#__PURE__*/React.createElement(WrappedInlineCard, {
208
- isHovered: isOverlayHovered,
209
- node: node,
210
- view: view,
211
- getPos: getPos,
212
- actionOptions: actionOptions,
213
- useAlternativePreloader: useAlternativePreloader,
214
- onClickCallback: onClickCallback,
215
- showHoverPreview: showHoverPreview,
216
- hoverPreviewOptions: {
217
- fadeInDelay: livePagesHoverCardFadeInDelay
218
- },
219
- isPageSSRed: isPageSSRed
220
- });
221
- return mode === 'view' ? inlineCard : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(OverlayWrapper, {
222
- targetElementPos: getPos(),
223
- view: view,
224
- isHoveredCallback: setIsOverlayHovered,
225
- onOpenLinkClick: event => {
226
- var _pluginInjectionApi$a2;
227
- handleNavigation({
228
- fireAnalyticsEvent: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions.fireAnalyticsEvent,
229
- onClickCallback,
230
- url,
231
- event
232
- });
233
- }
234
- }, inlineCard), fg('prompt_whiteboard_competitor_link_gate') && CompetitorPromptComponent);
235
- }
236
196
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(WrappedInlineCardWithAwareness, _extends({
237
197
  node: node,
238
198
  view: view,