@atlaskit/editor-plugin-card 2.3.2 → 2.3.4

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.
@@ -1,11 +1,9 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import React, { memo, useCallback, useMemo, useState } from 'react';
3
- import rafSchedule from 'raf-schd';
4
- import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
5
- import { Card as SmartCard } from '@atlaskit/smart-card';
6
- import { registerCard, registerRemoveOverlay } from '../pm-plugins/actions';
3
+ import { registerRemoveOverlay } from '../pm-plugins/actions';
7
4
  import { AwarenessWrapper } from '../ui/AwarenessWrapper';
8
- var InlineCard = function InlineCard(_ref) {
5
+ import { InlineCard } from './inlineCard';
6
+ export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
9
7
  var node = _ref.node,
10
8
  cardContext = _ref.cardContext,
11
9
  actionOptions = _ref.actionOptions,
@@ -13,15 +11,11 @@ var InlineCard = function InlineCard(_ref) {
13
11
  useAlternativePreloader = _ref.useAlternativePreloader,
14
12
  view = _ref.view,
15
13
  getPos = _ref.getPos,
16
- isOverlayEnabled = _ref.isOverlayEnabled,
17
- isPulseEnabled = _ref.isPulseEnabled,
18
14
  pluginInjectionApi = _ref.pluginInjectionApi,
19
- _ref$isSelected = _ref.isSelected,
20
- isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
21
- onClick = _ref.onClick;
22
- var _node$attrs = node.attrs,
23
- url = _node$attrs.url,
24
- data = _node$attrs.data;
15
+ onClick = _ref.onClick,
16
+ isPulseEnabled = _ref.isPulseEnabled,
17
+ isOverlayEnabled = _ref.isOverlayEnabled,
18
+ isSelected = _ref.isSelected;
25
19
  var _useState = useState(false),
26
20
  _useState2 = _slicedToArray(_useState, 2),
27
21
  isHovered = _useState2[0],
@@ -34,50 +28,14 @@ var InlineCard = function InlineCard(_ref) {
34
28
  _useState6 = _slicedToArray(_useState5, 2),
35
29
  isResolvedViewRendered = _useState6[0],
36
30
  setIsResolvedViewRendered = _useState6[1];
37
- var scrollContainer = useMemo(function () {
38
- return findOverflowScrollParent(view.dom) || undefined;
39
- }, [view.dom]);
40
- var onResolve = useCallback(function (data) {
41
- if (!getPos || typeof getPos === 'boolean') {
42
- return;
43
- }
44
- var title = data.title,
45
- url = data.url;
46
- // don't dispatch immediately since we might be in the middle of
47
- // rendering a nodeview
48
- rafSchedule(function () {
49
- // prosemirror-bump-fix
50
- var pos = getPos();
51
- if (typeof pos !== 'number') {
52
- return;
53
- }
54
- var tr = view.state.tr;
55
- registerCard({
56
- title: title,
57
- url: url,
58
- pos: pos
59
- })(tr);
60
- registerRemoveOverlay(function () {
61
- return setIsInserted(false);
62
- })(tr);
63
- view.dispatch(tr);
64
- })();
31
+ var onResolve = useCallback(function (tr, title) {
32
+ registerRemoveOverlay(function () {
33
+ return setIsInserted(false);
34
+ })(tr);
65
35
  if (title) {
66
36
  setIsResolvedViewRendered(true);
67
37
  }
68
- }, [view, getPos]);
69
- var onError = useCallback(function (data) {
70
- var url = data.url,
71
- err = data.err;
72
- if (err) {
73
- throw err;
74
- }
75
- onResolve({
76
- url: url
77
- });
78
- }, [onResolve]);
79
-
80
- // Begin Upgrade Awareness related code
38
+ }, []);
81
39
  var markMostRecentlyInsertedLink = useCallback(function (isLinkMostRecentlyInserted) {
82
40
  if (isOverlayEnabled) {
83
41
  setIsInserted(isLinkMostRecentlyInserted);
@@ -88,51 +46,37 @@ var InlineCard = function InlineCard(_ref) {
88
46
  setIsHovered(isHovered);
89
47
  }
90
48
  }, [isOverlayEnabled]);
91
- // End Upgrade Awareness related code
92
-
93
49
  var innerCard = useMemo(function () {
94
- return /*#__PURE__*/React.createElement(SmartCard, {
95
- key: url,
96
- url: url,
97
- data: data,
98
- appearance: "inline",
99
- onClick: onClick,
100
- container: scrollContainer,
101
- onResolve: onResolve,
102
- onError: onError,
103
- inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
50
+ return /*#__PURE__*/React.createElement(InlineCard, {
51
+ node: node,
52
+ view: view,
53
+ getPos: getPos,
54
+ useAlternativePreloader: useAlternativePreloader,
104
55
  actionOptions: actionOptions,
105
56
  showServerActions: showServerActions,
57
+ onResolve: onResolve,
58
+ onClick: onClick,
59
+ cardContext: cardContext,
106
60
  isHovered: isHovered
107
61
  });
108
- }, [data, isHovered, onError, onResolve, scrollContainer, url, useAlternativePreloader, actionOptions, showServerActions, onClick]);
109
- var card = useMemo(function () {
110
- return isOverlayEnabled || isPulseEnabled ? /*#__PURE__*/React.createElement(AwarenessWrapper, {
111
- isOverlayEnabled: isOverlayEnabled,
112
- isPulseEnabled: isPulseEnabled,
113
- cardContext: cardContext,
114
- getPos: getPos,
115
- isHovered: isHovered,
116
- isInserted: isInserted,
117
- url: url,
118
- isSelected: isSelected,
119
- isResolvedViewRendered: isResolvedViewRendered,
120
- markMostRecentlyInsertedLink: markMostRecentlyInsertedLink,
121
- pluginInjectionApi: pluginInjectionApi,
122
- setOverlayHoveredStyles: setOverlayHoveredStyles,
123
- view: view
124
- }, innerCard) :
125
- /*#__PURE__*/
126
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
127
- React.createElement("span", {
128
- className: "card"
129
- }, innerCard);
130
- }, [cardContext, getPos, innerCard, isHovered, isInserted, isOverlayEnabled, isPulseEnabled, isResolvedViewRendered, isSelected, markMostRecentlyInsertedLink, pluginInjectionApi, setOverlayHoveredStyles, url, view]);
131
-
132
- // [WS-2307]: we only render card wrapped into a Provider when the value is ready,
133
- // otherwise if we got data, we can render the card directly since it doesn't need the Provider
134
- return cardContext && cardContext.value ? /*#__PURE__*/React.createElement(cardContext.Provider, {
135
- value: cardContext.value
136
- }, card) : data ? card : null;
137
- };
138
- export var InlineCardWithAwareness = /*#__PURE__*/memo(InlineCard);
62
+ }, [actionOptions, cardContext, getPos, isHovered, node, onClick, onResolve, showServerActions, useAlternativePreloader, view]);
63
+ return isOverlayEnabled || isPulseEnabled ? /*#__PURE__*/React.createElement(AwarenessWrapper, {
64
+ isOverlayEnabled: isOverlayEnabled,
65
+ isPulseEnabled: isPulseEnabled,
66
+ cardContext: cardContext,
67
+ getPos: getPos,
68
+ isHovered: isHovered,
69
+ isInserted: isInserted,
70
+ url: node.attrs.url,
71
+ isSelected: isSelected,
72
+ isResolvedViewRendered: isResolvedViewRendered,
73
+ markMostRecentlyInsertedLink: markMostRecentlyInsertedLink,
74
+ pluginInjectionApi: pluginInjectionApi,
75
+ setOverlayHoveredStyles: setOverlayHoveredStyles
76
+ }, innerCard) :
77
+ /*#__PURE__*/
78
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
79
+ React.createElement("span", {
80
+ className: "card"
81
+ }, innerCard);
82
+ });
@@ -17,8 +17,8 @@ import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
17
17
  import CogIcon from '@atlaskit/icon/glyph/editor/settings';
18
18
  import UnlinkIcon from '@atlaskit/icon/glyph/editor/unlink';
19
19
  import OpenIcon from '@atlaskit/icon/glyph/shortcut';
20
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
21
- import { changeSelectedCardToText } from '../src/pm-plugins/doc';
20
+ import { fg } from '@atlaskit/platform-feature-flags';
21
+ import { changeSelectedCardToText } from './pm-plugins/doc';
22
22
  import { pluginKey } from './pm-plugins/main';
23
23
  import { DatasourceAppearanceButton } from './ui/DatasourceAppearanceButton';
24
24
  import { editDatasource, EditDatasourceButton } from './ui/EditDatasourceButton';
@@ -198,7 +198,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
198
198
  var currentAppearance = appearanceForNodeType(node.type);
199
199
  var _ref2 = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$d2 = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {},
200
200
  hoverDecoration = _ref2.hoverDecoration;
201
- var isDatasource = getBooleanFF('platform.linking-platform.editor-datasource-typeguards') ? isDatasourceNode(node) : currentAppearance === 'block' && (node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.datasource);
201
+ var isDatasource = fg('platform.linking-platform.editor-datasource-typeguards') ? isDatasourceNode(node) : currentAppearance === 'block' && (node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.datasource);
202
202
  var shouldRenderDatasourceToolbar = isDatasource &&
203
203
  // not showing toolbar in mobile for now since not sure what our plans are for it
204
204
  platform !== 'mobile' && cardOptions.allowDatasource && canRenderDatasource(node === null || node === void 0 || (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 || (_node$attrs2 = _node$attrs2.datasource) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.id);
@@ -216,7 +216,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
216
216
  return getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, node.attrs.datasource.id, state, cardOptions, currentAppearance, platform);
217
217
  } else {
218
218
  var inlineCard = state.schema.nodes.inlineCard;
219
- var isEditDropdownEnabled = getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar') && platform !== 'mobile' && cardOptions.allowDatasource;
219
+ var isEditDropdownEnabled = platform !== 'mobile' && cardOptions.allowDatasource && fg('platform.linking-platform.enable-datasource-edit-dropdown-toolbar');
220
220
  var editItems = isEditDropdownEnabled ? [{
221
221
  type: 'custom',
222
222
  fallback: [],
@@ -293,7 +293,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
293
293
  // This code will be executed only for appearances such as "inline", "block" & "embed"
294
294
  // For url appearance, please see HyperlinkToolbarAppearanceProps
295
295
  if (currentAppearance) {
296
- var showDatasourceAppearance = getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar') && allowDatasource && url;
296
+ var showDatasourceAppearance = allowDatasource && url && fg('platform.linking-platform.enable-datasource-appearance-toolbar');
297
297
  toolbarItems.unshift.apply(toolbarItems, _toConsumableArray(getToolbarViewedItem(url, currentAppearance)).concat([{
298
298
  type: 'custom',
299
299
  fallback: [],
@@ -329,7 +329,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
329
329
  type: 'separator'
330
330
  }]));
331
331
  }
332
- var shouldShowDatasourceEditButton = platform !== 'mobile' && allowDatasource && !getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar');
332
+ var shouldShowDatasourceEditButton = platform !== 'mobile' && allowDatasource && !fg('platform.linking-platform.enable-datasource-edit-dropdown-toolbar');
333
333
  if (shouldShowDatasourceEditButton) {
334
334
  toolbarItems.unshift({
335
335
  type: 'custom',
@@ -367,8 +367,8 @@ export var getHyperlinkToolbarSettingsButton = function getHyperlinkToolbarSetti
367
367
  type: 'button',
368
368
  icon: CogIcon,
369
369
  title: intl.formatMessage(linkToolbarMessages.settingsLink),
370
- onClick: getBooleanFF('platform.editor.card.inject-settings-button') ? openLinkSettings(editorAnalyticsApi, userPreferencesLink) : openLinkSettings(editorAnalyticsApi, undefined),
371
- href: getBooleanFF('platform.editor.card.inject-settings-button') ? userPreferencesLink || getLinkPreferencesURLFromENV() : getLinkPreferencesURLFromENV(),
370
+ onClick: fg('platform.editor.card.inject-settings-button') ? openLinkSettings(editorAnalyticsApi, userPreferencesLink) : openLinkSettings(editorAnalyticsApi, undefined),
371
+ href: fg('platform.editor.card.inject-settings-button') ? userPreferencesLink || getLinkPreferencesURLFromENV() : getLinkPreferencesURLFromENV(),
372
372
  target: '_blank'
373
373
  };
374
374
  };
@@ -378,7 +378,7 @@ export var getSettingsButton = function getSettingsButton(intl, editorAnalyticsA
378
378
  type: 'button',
379
379
  icon: CogIcon,
380
380
  title: intl.formatMessage(linkToolbarMessages.settingsLink),
381
- onClick: getBooleanFF('platform.editor.card.inject-settings-button') ? openLinkSettings(editorAnalyticsApi, userPreferencesLink) : openLinkSettings(editorAnalyticsApi, undefined)
381
+ onClick: fg('platform.editor.card.inject-settings-button') ? openLinkSettings(editorAnalyticsApi, userPreferencesLink) : openLinkSettings(editorAnalyticsApi, undefined)
382
382
  };
383
383
  };
384
384
  export var getSettingsButtonGroup = function getSettingsButtonGroup(intl, editorAnalyticsApi, userPreferencesLink) {
@@ -389,7 +389,7 @@ export var getSettingsButtonGroup = function getSettingsButtonGroup(intl, editor
389
389
  var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state, cardOptions, currentAppearance, platform) {
390
390
  var _node$attrs3;
391
391
  var toolbarItems = [];
392
- if (isDatasourceConfigEditable(datasourceId) && !getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar')) {
392
+ if (isDatasourceConfigEditable(datasourceId) && !fg('platform.linking-platform.enable-datasource-edit-dropdown-toolbar')) {
393
393
  toolbarItems.push({
394
394
  id: 'editor.edit.datasource',
395
395
  type: 'button',
@@ -410,12 +410,12 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
410
410
  }
411
411
  if (
412
412
  // FF that controls visibily of the additional toolbar buttons
413
- !getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar')) {
413
+ !fg('platform.linking-platform.enable-datasource-appearance-toolbar')) {
414
414
  return false;
415
415
  }
416
416
 
417
417
  // FF to enable additional toolbar buttons based on if the datasource is configurable or not
418
- return getBooleanFF('platform.linking-platform.datasource-enable-toolbar-buttons-for-all-datasources') ? true : !isDatasourceConfigEditable(datasourceId);
418
+ return fg('platform.linking-platform.datasource-enable-toolbar-buttons-for-all-datasources') ? true : !isDatasourceConfigEditable(datasourceId);
419
419
  };
420
420
  if (canShowAppearanceSwitch()) {
421
421
  var allowBlockCards = cardOptions.allowBlockCards,
@@ -459,7 +459,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
459
459
  type: 'separator'
460
460
  });
461
461
  }
462
- if (getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar')) {
462
+ if (fg('platform.linking-platform.enable-datasource-edit-dropdown-toolbar')) {
463
463
  toolbarItems.push({
464
464
  type: 'custom',
465
465
  fallback: [],
@@ -520,7 +520,7 @@ export var shouldRenderToolbarPulse = function shouldRenderToolbarPulse(embedEna
520
520
  };
521
521
  export var getStartingToolbarItems = function getStartingToolbarItems(options, api) {
522
522
  return function (intl, link, providerFactory, onEditLink, metadata) {
523
- var isEditDropdownEnabled = getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar') && options.platform !== 'mobile' && options.allowDatasource;
523
+ var isEditDropdownEnabled = options.platform !== 'mobile' && options.allowDatasource && fg('platform.linking-platform.enable-datasource-edit-dropdown-toolbar');
524
524
  var editLinkItem = isEditDropdownEnabled ? [{
525
525
  type: 'custom',
526
526
  fallback: [],
@@ -586,7 +586,7 @@ export var getStartingToolbarItems = function getStartingToolbarItems(options, a
586
586
  };
587
587
  export var getEndingToolbarItems = function getEndingToolbarItems(options, api) {
588
588
  return function (intl, link) {
589
- if (getBooleanFF('platform.editor.card.inject-settings-button')) {
589
+ if (fg('platform.editor.card.inject-settings-button')) {
590
590
  /**
591
591
  * Require either provider to be supplied (controls link preferences)
592
592
  * Or explicit user preferences config in order to enable button
@@ -5,11 +5,9 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
5
5
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
6
6
  import { css, jsx } from '@emotion/react';
7
7
  import { AnalyticsContext } from '@atlaskit/analytics-next';
8
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
9
8
  import useLinkUpgradeDiscoverability from '../../common/hooks/useLinkUpgradeDiscoverability';
10
9
  import { isLocalStorageKeyDiscovered, LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK, LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR, markLocalStorageKeyDiscovered, ONE_DAY_IN_MILLISECONDS } from '../../common/local-storage';
11
10
  import { getResolvedAttributesFromStore } from '../../utils';
12
- import OverlayWrapper from '../ConfigureOverlay';
13
11
  import InlineCardOverlay from '../InlineCardOverlay';
14
12
  import { DiscoveryPulse } from '../Pulse';
15
13
  // editor adds a standard line-height that is bigger than an inline smart link
@@ -33,8 +31,7 @@ export var AwarenessWrapper = function AwarenessWrapper(_ref) {
33
31
  markMostRecentlyInsertedLink = _ref.markMostRecentlyInsertedLink,
34
32
  pluginInjectionApi = _ref.pluginInjectionApi,
35
33
  setOverlayHoveredStyles = _ref.setOverlayHoveredStyles,
36
- url = _ref.url,
37
- view = _ref.view;
34
+ url = _ref.url;
38
35
  var _useState = useState(false),
39
36
  _useState2 = _slicedToArray(_useState, 2),
40
37
  isHovered = _useState2[0],
@@ -74,12 +71,6 @@ export var AwarenessWrapper = function AwarenessWrapper(_ref) {
74
71
  setOverlayHoveredStyles(isHovered);
75
72
  }, [setOverlayHoveredStyles]);
76
73
  var cardWithOverlay = useMemo(function () {
77
- if (getBooleanFF('platform.linking-platform.smart-links-in-live-pages')) {
78
- return jsx(OverlayWrapper, {
79
- targetElementPos: linkPosition,
80
- view: view
81
- }, children);
82
- }
83
74
  if (shouldShowLinkOverlay) {
84
75
  return jsx(InlineCardOverlay, {
85
76
  isSelected: isSelected,
@@ -94,7 +85,7 @@ export var AwarenessWrapper = function AwarenessWrapper(_ref) {
94
85
  }, children);
95
86
  }
96
87
  return children;
97
- }, [shouldShowLinkOverlay, children, isSelected, isResolvedViewRendered, isInserted, isHovered, url, view, linkPosition, handleOverlayChange]);
88
+ }, [shouldShowLinkOverlay, children, isSelected, isResolvedViewRendered, isInserted, isHovered, url, handleOverlayChange]);
98
89
  return useMemo(function () {
99
90
  var _cardContext$value;
100
91
  return (
package/dist/esm/utils.js CHANGED
@@ -3,7 +3,7 @@ import { Fragment } from '@atlaskit/editor-prosemirror/model';
3
3
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
4
4
  import { getResolvedAttributes } from '@atlaskit/link-analytics/resolved-attributes';
5
5
  import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID, CONFLUENCE_SEARCH_DATASOURCE_ID, JIRA_LIST_OF_LINKS_DATASOURCE_ID } from '@atlaskit/link-datasource';
6
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
6
+ import { fg } from '@atlaskit/platform-feature-flags';
7
7
  import { pluginKey } from './pm-plugins/plugin-key';
8
8
  export var appearanceForNodeType = function appearanceForNodeType(spec) {
9
9
  if (spec.name === 'inlineCard') {
@@ -75,7 +75,7 @@ export var getResolvedAttributesFromStore = function getResolvedAttributesFromSt
75
75
  };
76
76
  export var isDatasourceConfigEditable = function isDatasourceConfigEditable(datasourceId) {
77
77
  var datasourcesWithConfigModal = [JIRA_LIST_OF_LINKS_DATASOURCE_ID, ASSETS_LIST_OF_LINKS_DATASOURCE_ID];
78
- if (getBooleanFF('platform.linking-platform.datasource.enable-confluence-search-modal')) {
78
+ if (fg('platform.linking-platform.datasource.enable-confluence-search-modal')) {
79
79
  datasourcesWithConfigModal.push(CONFLUENCE_SEARCH_DATASOURCE_ID);
80
80
  }
81
81
  return datasourcesWithConfigModal.includes(datasourceId);
@@ -125,4 +125,17 @@ export var focusEditorView = function focusEditorView(editorView) {
125
125
  if (!editorView.hasFocus()) {
126
126
  editorView.focus();
127
127
  }
128
+ };
129
+ export var getAwarenessProps = function getAwarenessProps(editorState, getPos, allowEmbeds, allowBlockCards) {
130
+ var _editorState$selectio, _editorState$selectio2;
131
+ var getPosFunction = typeof getPos !== 'boolean' ? getPos : undefined;
132
+ var linkPosition = getPosFunction === null || getPosFunction === void 0 ? void 0 : getPosFunction();
133
+ var canBeUpgradedToEmbed = !!linkPosition && allowEmbeds ? isEmbedSupportedAtPosition(linkPosition, editorState, 'inline') : false;
134
+ var canBeUpgradedToBlock = !!linkPosition && allowBlockCards ? isBlockSupportedAtPosition(linkPosition, editorState, 'inline') : false;
135
+ var isSelected = editorState.selection instanceof NodeSelection && ((_editorState$selectio = editorState.selection) === null || _editorState$selectio === void 0 || (_editorState$selectio = _editorState$selectio.node) === null || _editorState$selectio === void 0 ? void 0 : _editorState$selectio.type) === editorState.schema.nodes.inlineCard && ((_editorState$selectio2 = editorState.selection) === null || _editorState$selectio2 === void 0 ? void 0 : _editorState$selectio2.from) === (getPosFunction === null || getPosFunction === void 0 ? void 0 : getPosFunction());
136
+ return {
137
+ isPulseEnabled: canBeUpgradedToEmbed,
138
+ isOverlayEnabled: canBeUpgradedToEmbed || canBeUpgradedToBlock,
139
+ isSelected: isSelected
140
+ };
128
141
  };
@@ -7,6 +7,7 @@ import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
7
7
  import type { getPosHandler, ReactComponentProps } from '@atlaskit/editor-common/react-node-view';
8
8
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
9
9
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
10
+ import { type Transaction } from '@atlaskit/editor-prosemirror/state';
10
11
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
11
12
  import { type CardContext } from '@atlaskit/link-provider';
12
13
  import type { CardProps as BaseCardProps, CardPlatform } from '@atlaskit/smart-card';
@@ -38,15 +39,16 @@ export interface CardProps extends CardNodeViewProps {
38
39
  showServerActions?: boolean;
39
40
  actionOptions?: BaseCardProps['actionOptions'];
40
41
  pluginInjectionApi?: ExtractInjectionAPI<typeof cardPlugin>;
41
- isOverlayEnabled?: boolean;
42
- isPulseEnabled?: boolean;
43
- linkPosition?: number;
44
- isSelected?: boolean;
45
42
  onClickCallback?: OnClickCallback;
46
43
  }
47
44
  export interface SmartCardProps extends CardProps {
48
45
  pluginInjectionApi?: ExtractInjectionAPI<typeof cardPlugin>;
49
46
  cardContext?: EditorContext<CardContext | undefined>;
50
47
  onClick?: EventHandler<MouseEvent | KeyboardEvent> | undefined;
48
+ onResolve?: (tr: Transaction, title?: string) => void;
49
+ isHovered?: boolean;
50
+ allowEmbeds?: boolean;
51
+ allowBlockCards?: boolean;
52
+ enableInlineUpgradeFeatures?: boolean;
51
53
  }
52
54
  export declare function Card(SmartCardComponent: React.ComponentType<React.PropsWithChildren<SmartCardProps>>, UnsupportedComponent: React.ComponentType<React.PropsWithChildren<unknown>>): React.ComponentType<React.PropsWithChildren<CardProps>>;
@@ -1,11 +1,7 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import type { InlineNodeViewComponentProps } from '@atlaskit/editor-common/react-node-view';
3
3
  import type { SmartCardProps } from './genericCard';
4
+ import { type InlineCardWithAwarenessProps } from './inlineCardWithAwareness';
5
+ export declare const InlineCard: React.MemoExoticComponent<({ node, cardContext, actionOptions, showServerActions, useAlternativePreloader, view, getPos, onClick, onResolve: onRes, isHovered, }: SmartCardProps) => JSX.Element | null>;
4
6
  export type InlineCardNodeViewProps = Pick<SmartCardProps, 'useAlternativePreloader' | 'actionOptions' | 'showServerActions' | 'allowEmbeds' | 'allowBlockCards' | 'enableInlineUpgradeFeatures' | 'pluginInjectionApi' | 'onClickCallback'>;
5
- type InlineCardWithAwarenessProps = {
6
- allowEmbeds?: boolean;
7
- allowBlockCards?: boolean;
8
- enableInlineUpgradeFeatures: boolean;
9
- };
10
7
  export declare function InlineCardNodeView(props: InlineNodeViewComponentProps & InlineCardNodeViewProps & InlineCardWithAwarenessProps): JSX.Element;
11
- export {};
@@ -1,3 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { SmartCardProps } from './genericCard';
3
- export declare const InlineCardWithAwareness: React.MemoExoticComponent<({ node, cardContext, actionOptions, showServerActions, useAlternativePreloader, view, getPos, isOverlayEnabled, isPulseEnabled, pluginInjectionApi, isSelected, onClick, }: SmartCardProps) => JSX.Element | null>;
3
+ export type InlineCardWithAwarenessProps = {
4
+ isPulseEnabled?: boolean;
5
+ isOverlayEnabled?: boolean;
6
+ isSelected?: boolean;
7
+ };
8
+ export declare const InlineCardWithAwareness: React.MemoExoticComponent<({ node, cardContext, actionOptions, showServerActions, useAlternativePreloader, view, getPos, pluginInjectionApi, onClick, isPulseEnabled, isOverlayEnabled, isSelected, }: SmartCardProps & InlineCardWithAwarenessProps) => JSX.Element>;
@@ -1,6 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import { jsx } from '@emotion/react';
3
- import { type EditorView } from '@atlaskit/editor-prosemirror/view';
4
3
  import type { SmartCardProps } from '../../nodeviews/genericCard';
5
4
  type AwarenessWrapperProps = {
6
5
  isInserted?: boolean;
@@ -9,7 +8,9 @@ type AwarenessWrapperProps = {
9
8
  markMostRecentlyInsertedLink: (isLinkMostRecentlyInserted: boolean) => void;
10
9
  setOverlayHoveredStyles: (isHovered: boolean) => void;
11
10
  url: string;
12
- view: EditorView;
11
+ isOverlayEnabled?: boolean;
12
+ isPulseEnabled?: boolean;
13
+ isSelected?: boolean;
13
14
  } & Partial<SmartCardProps>;
14
- export declare const AwarenessWrapper: ({ cardContext, children, getPos, isInserted, isOverlayEnabled, isSelected, isResolvedViewRendered, isPulseEnabled, markMostRecentlyInsertedLink, pluginInjectionApi, setOverlayHoveredStyles, url, view, }: AwarenessWrapperProps) => jsx.JSX.Element;
15
+ export declare const AwarenessWrapper: ({ cardContext, children, getPos, isInserted, isOverlayEnabled, isSelected, isResolvedViewRendered, isPulseEnabled, markMostRecentlyInsertedLink, pluginInjectionApi, setOverlayHoveredStyles, url, }: AwarenessWrapperProps) => jsx.JSX.Element;
15
16
  export {};
@@ -1,4 +1,5 @@
1
1
  import type { CardAppearance } from '@atlaskit/editor-common/provider-factory';
2
+ import { type getPosHandler } from '@atlaskit/editor-common/src/react-node-view';
2
3
  import type { Node, NodeType } from '@atlaskit/editor-prosemirror/model';
3
4
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
5
  import { type EditorView } from '@atlaskit/editor-prosemirror/view';
@@ -43,3 +44,8 @@ export declare const isDatasourceNode: (node?: Node) => node is DatasourceNode;
43
44
  * @param editorView The editor view to focus.
44
45
  */
45
46
  export declare const focusEditorView: (editorView: EditorView) => void;
47
+ export declare const getAwarenessProps: (editorState: EditorState, getPos: getPosHandler, allowEmbeds?: boolean, allowBlockCards?: boolean) => {
48
+ isPulseEnabled: boolean;
49
+ isOverlayEnabled: boolean;
50
+ isSelected: boolean;
51
+ };
@@ -7,6 +7,7 @@ import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
7
7
  import type { getPosHandler, ReactComponentProps } from '@atlaskit/editor-common/react-node-view';
8
8
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
9
9
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
10
+ import { type Transaction } from '@atlaskit/editor-prosemirror/state';
10
11
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
11
12
  import { type CardContext } from '@atlaskit/link-provider';
12
13
  import type { CardProps as BaseCardProps, CardPlatform } from '@atlaskit/smart-card';
@@ -38,15 +39,16 @@ export interface CardProps extends CardNodeViewProps {
38
39
  showServerActions?: boolean;
39
40
  actionOptions?: BaseCardProps['actionOptions'];
40
41
  pluginInjectionApi?: ExtractInjectionAPI<typeof cardPlugin>;
41
- isOverlayEnabled?: boolean;
42
- isPulseEnabled?: boolean;
43
- linkPosition?: number;
44
- isSelected?: boolean;
45
42
  onClickCallback?: OnClickCallback;
46
43
  }
47
44
  export interface SmartCardProps extends CardProps {
48
45
  pluginInjectionApi?: ExtractInjectionAPI<typeof cardPlugin>;
49
46
  cardContext?: EditorContext<CardContext | undefined>;
50
47
  onClick?: EventHandler<MouseEvent | KeyboardEvent> | undefined;
48
+ onResolve?: (tr: Transaction, title?: string) => void;
49
+ isHovered?: boolean;
50
+ allowEmbeds?: boolean;
51
+ allowBlockCards?: boolean;
52
+ enableInlineUpgradeFeatures?: boolean;
51
53
  }
52
54
  export declare function Card(SmartCardComponent: React.ComponentType<React.PropsWithChildren<SmartCardProps>>, UnsupportedComponent: React.ComponentType<React.PropsWithChildren<unknown>>): React.ComponentType<React.PropsWithChildren<CardProps>>;
@@ -1,11 +1,7 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import type { InlineNodeViewComponentProps } from '@atlaskit/editor-common/react-node-view';
3
3
  import type { SmartCardProps } from './genericCard';
4
+ import { type InlineCardWithAwarenessProps } from './inlineCardWithAwareness';
5
+ export declare const InlineCard: React.MemoExoticComponent<({ node, cardContext, actionOptions, showServerActions, useAlternativePreloader, view, getPos, onClick, onResolve: onRes, isHovered, }: SmartCardProps) => JSX.Element | null>;
4
6
  export type InlineCardNodeViewProps = Pick<SmartCardProps, 'useAlternativePreloader' | 'actionOptions' | 'showServerActions' | 'allowEmbeds' | 'allowBlockCards' | 'enableInlineUpgradeFeatures' | 'pluginInjectionApi' | 'onClickCallback'>;
5
- type InlineCardWithAwarenessProps = {
6
- allowEmbeds?: boolean;
7
- allowBlockCards?: boolean;
8
- enableInlineUpgradeFeatures: boolean;
9
- };
10
7
  export declare function InlineCardNodeView(props: InlineNodeViewComponentProps & InlineCardNodeViewProps & InlineCardWithAwarenessProps): JSX.Element;
11
- export {};
@@ -1,3 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { SmartCardProps } from './genericCard';
3
- export declare const InlineCardWithAwareness: React.MemoExoticComponent<({ node, cardContext, actionOptions, showServerActions, useAlternativePreloader, view, getPos, isOverlayEnabled, isPulseEnabled, pluginInjectionApi, isSelected, onClick, }: SmartCardProps) => JSX.Element | null>;
3
+ export type InlineCardWithAwarenessProps = {
4
+ isPulseEnabled?: boolean;
5
+ isOverlayEnabled?: boolean;
6
+ isSelected?: boolean;
7
+ };
8
+ export declare const InlineCardWithAwareness: React.MemoExoticComponent<({ node, cardContext, actionOptions, showServerActions, useAlternativePreloader, view, getPos, pluginInjectionApi, onClick, isPulseEnabled, isOverlayEnabled, isSelected, }: SmartCardProps & InlineCardWithAwarenessProps) => JSX.Element>;
@@ -1,6 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import { jsx } from '@emotion/react';
3
- import { type EditorView } from '@atlaskit/editor-prosemirror/view';
4
3
  import type { SmartCardProps } from '../../nodeviews/genericCard';
5
4
  type AwarenessWrapperProps = {
6
5
  isInserted?: boolean;
@@ -9,7 +8,9 @@ type AwarenessWrapperProps = {
9
8
  markMostRecentlyInsertedLink: (isLinkMostRecentlyInserted: boolean) => void;
10
9
  setOverlayHoveredStyles: (isHovered: boolean) => void;
11
10
  url: string;
12
- view: EditorView;
11
+ isOverlayEnabled?: boolean;
12
+ isPulseEnabled?: boolean;
13
+ isSelected?: boolean;
13
14
  } & Partial<SmartCardProps>;
14
- export declare const AwarenessWrapper: ({ cardContext, children, getPos, isInserted, isOverlayEnabled, isSelected, isResolvedViewRendered, isPulseEnabled, markMostRecentlyInsertedLink, pluginInjectionApi, setOverlayHoveredStyles, url, view, }: AwarenessWrapperProps) => jsx.JSX.Element;
15
+ export declare const AwarenessWrapper: ({ cardContext, children, getPos, isInserted, isOverlayEnabled, isSelected, isResolvedViewRendered, isPulseEnabled, markMostRecentlyInsertedLink, pluginInjectionApi, setOverlayHoveredStyles, url, }: AwarenessWrapperProps) => jsx.JSX.Element;
15
16
  export {};
@@ -1,4 +1,5 @@
1
1
  import type { CardAppearance } from '@atlaskit/editor-common/provider-factory';
2
+ import { type getPosHandler } from '@atlaskit/editor-common/src/react-node-view';
2
3
  import type { Node, NodeType } from '@atlaskit/editor-prosemirror/model';
3
4
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
5
  import { type EditorView } from '@atlaskit/editor-prosemirror/view';
@@ -43,3 +44,8 @@ export declare const isDatasourceNode: (node?: Node) => node is DatasourceNode;
43
44
  * @param editorView The editor view to focus.
44
45
  */
45
46
  export declare const focusEditorView: (editorView: EditorView) => void;
47
+ export declare const getAwarenessProps: (editorState: EditorState, getPos: getPosHandler, allowEmbeds?: boolean, allowBlockCards?: boolean) => {
48
+ isPulseEnabled: boolean;
49
+ isOverlayEnabled: boolean;
50
+ isSelected: boolean;
51
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "2.3.2",
3
+ "version": "2.3.4",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,10 +34,10 @@
34
34
  "dependencies": {
35
35
  "@atlaskit/adf-schema": "^39.0.3",
36
36
  "@atlaskit/analytics-next": "^9.3.0",
37
- "@atlaskit/button": "^18.0.0",
37
+ "@atlaskit/button": "^18.1.0",
38
38
  "@atlaskit/custom-steps": "^0.4.0",
39
39
  "@atlaskit/dropdown-menu": "^12.13.0",
40
- "@atlaskit/editor-common": "^83.5.0",
40
+ "@atlaskit/editor-common": "^83.6.0",
41
41
  "@atlaskit/editor-plugin-analytics": "^1.4.0",
42
42
  "@atlaskit/editor-plugin-decorations": "^1.1.0",
43
43
  "@atlaskit/editor-plugin-editor-disabled": "^1.1.0",