@atlaskit/editor-plugin-card 0.12.1 → 0.13.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 (57) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/common/hooks/useLinkUpgradeDiscoverability.js +56 -0
  3. package/dist/cjs/common/local-storage.js +4 -1
  4. package/dist/cjs/common/pulse/index.js +8 -4
  5. package/dist/cjs/messages.js +2 -2
  6. package/dist/cjs/nodeviews/inlineCard.js +26 -4
  7. package/dist/cjs/nodeviews/inlineCardWithAwareness.js +83 -33
  8. package/dist/cjs/plugin.js +4 -2
  9. package/dist/cjs/pm-plugins/main.js +33 -4
  10. package/dist/cjs/ui/InlineCardOverlay/index.js +2 -1
  11. package/dist/cjs/ui/LinkToolbarAppearance.js +5 -4
  12. package/dist/cjs/utils.js +13 -1
  13. package/dist/es2019/common/hooks/useLinkUpgradeDiscoverability.js +44 -0
  14. package/dist/es2019/common/local-storage.js +3 -0
  15. package/dist/es2019/common/pulse/index.js +7 -4
  16. package/dist/es2019/messages.js +2 -2
  17. package/dist/es2019/nodeviews/inlineCard.js +26 -4
  18. package/dist/es2019/nodeviews/inlineCardWithAwareness.js +58 -13
  19. package/dist/es2019/plugin.js +4 -2
  20. package/dist/es2019/pm-plugins/main.js +33 -4
  21. package/dist/es2019/ui/InlineCardOverlay/index.js +2 -1
  22. package/dist/es2019/ui/LinkToolbarAppearance.js +4 -3
  23. package/dist/es2019/utils.js +9 -1
  24. package/dist/esm/common/hooks/useLinkUpgradeDiscoverability.js +49 -0
  25. package/dist/esm/common/local-storage.js +3 -0
  26. package/dist/esm/common/pulse/index.js +8 -4
  27. package/dist/esm/messages.js +2 -2
  28. package/dist/esm/nodeviews/inlineCard.js +26 -4
  29. package/dist/esm/nodeviews/inlineCardWithAwareness.js +82 -30
  30. package/dist/esm/plugin.js +4 -2
  31. package/dist/esm/pm-plugins/main.js +33 -4
  32. package/dist/esm/ui/InlineCardOverlay/index.js +2 -1
  33. package/dist/esm/ui/LinkToolbarAppearance.js +5 -4
  34. package/dist/esm/utils.js +12 -0
  35. package/dist/types/common/hooks/useLinkUpgradeDiscoverability.d.ts +17 -0
  36. package/dist/types/common/local-storage.d.ts +3 -0
  37. package/dist/types/common/pulse/index.d.ts +7 -1
  38. package/dist/types/nodeviews/genericCard.d.ts +5 -2
  39. package/dist/types/nodeviews/inlineCard.d.ts +8 -2
  40. package/dist/types/nodeviews/inlineCardWithAwareness.d.ts +3 -2
  41. package/dist/types/pm-plugins/util/state.d.ts +4 -0
  42. package/dist/types/types.d.ts +11 -7
  43. package/dist/types/ui/LinkToolbarAppearance.d.ts +1 -1
  44. package/dist/types/utils.d.ts +5 -3
  45. package/dist/types-ts4.5/common/hooks/useLinkUpgradeDiscoverability.d.ts +17 -0
  46. package/dist/types-ts4.5/common/local-storage.d.ts +3 -0
  47. package/dist/types-ts4.5/common/pulse/index.d.ts +7 -1
  48. package/dist/types-ts4.5/nodeviews/genericCard.d.ts +5 -2
  49. package/dist/types-ts4.5/nodeviews/inlineCard.d.ts +8 -2
  50. package/dist/types-ts4.5/nodeviews/inlineCardWithAwareness.d.ts +3 -2
  51. package/dist/types-ts4.5/pm-plugins/util/state.d.ts +4 -0
  52. package/dist/types-ts4.5/types.d.ts +11 -7
  53. package/dist/types-ts4.5/ui/LinkToolbarAppearance.d.ts +1 -1
  54. package/dist/types-ts4.5/utils.d.ts +5 -3
  55. package/package.json +4 -4
  56. package/report.api.md +9 -5
  57. package/tmp/api-report-tmp.d.ts +9 -5
@@ -54,13 +54,14 @@ export var cardPlugin = function cardPlugin(_ref) {
54
54
  return nodes;
55
55
  },
56
56
  pmPlugins: function pmPlugins() {
57
- var _options$allowBlockCa, _options$allowResizin, _options$useAlternati, _options$allowWrappin, _options$allowAlignme, _options$allowDatasou;
57
+ var _options$allowBlockCa, _options$allowResizin, _options$useAlternati, _options$allowWrappin, _options$allowAlignme, _options$allowDatasou, _options$showUpgradeD;
58
58
  var allowBlockCards = (_options$allowBlockCa = options.allowBlockCards) !== null && _options$allowBlockCa !== void 0 ? _options$allowBlockCa : true;
59
59
  var allowResizing = (_options$allowResizin = options.allowResizing) !== null && _options$allowResizin !== void 0 ? _options$allowResizin : true;
60
60
  var useAlternativePreloader = (_options$useAlternati = options.useAlternativePreloader) !== null && _options$useAlternati !== void 0 ? _options$useAlternati : true;
61
61
  var allowWrapping = (_options$allowWrappin = options.allowWrapping) !== null && _options$allowWrappin !== void 0 ? _options$allowWrappin : true;
62
62
  var allowAlignment = (_options$allowAlignme = options.allowAlignment) !== null && _options$allowAlignme !== void 0 ? _options$allowAlignme : true;
63
63
  var allowDatasource = (_options$allowDatasou = options.allowDatasource) !== null && _options$allowDatasou !== void 0 ? _options$allowDatasou : false;
64
+ var showUpgradeDiscoverability = (_options$showUpgradeD = options.showUpgradeDiscoverability) !== null && _options$showUpgradeD !== void 0 ? _options$showUpgradeD : true;
64
65
  var plugins = [{
65
66
  name: 'card',
66
67
  plugin: createPlugin(_objectSpread(_objectSpread({}, options), {}, {
@@ -70,7 +71,8 @@ export var cardPlugin = function cardPlugin(_ref) {
70
71
  allowWrapping: allowWrapping,
71
72
  allowAlignment: allowAlignment,
72
73
  allowDatasource: allowDatasource,
73
- cardPluginEvents: cardPluginEvents
74
+ cardPluginEvents: cardPluginEvents,
75
+ showUpgradeDiscoverability: showUpgradeDiscoverability
74
76
  }), api)
75
77
  }, {
76
78
  name: 'cardHyperlink',
@@ -6,17 +6,21 @@ import { DATASOURCE_INNER_CONTAINER_CLASSNAME } from '@atlaskit/editor-common/st
6
6
  import { canRenderDatasource } from '@atlaskit/editor-common/utils';
7
7
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
8
8
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
9
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
9
10
  import { eventsFromTransaction } from '../analytics/events-from-tr';
11
+ import { isLocalStorageKeyDiscovered } from '../common/local-storage';
10
12
  import { BlockCard } from '../nodeviews/blockCard';
11
13
  import { Datasource } from '../nodeviews/datasource';
12
14
  import { EmbedCard } from '../nodeviews/embedCard';
13
15
  import { InlineCardNodeView } from '../nodeviews/inlineCard';
16
+ import { isEmbedSupportedAtPosition } from '../utils';
14
17
  import { setCardLayoutAndDatasourceTableRef, setDatasourceTableRef } from './actions';
15
18
  import { pluginKey } from './plugin-key';
16
19
  import reducer from './reducers';
17
20
  import { handleProvider, resolveWithProvider } from './util/resolve';
18
21
  import { getNewRequests, getPluginState, getPluginStateWithUpdatedPos } from './util/state';
19
22
  export { pluginKey } from './plugin-key';
23
+ var LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK = 'smart-link-upgrade-pulse';
20
24
  export var createPlugin = function createPlugin(options, pluginInjectionApi) {
21
25
  return function (pmPluginFactoryParams) {
22
26
  var editorAppearance = options.editorAppearance,
@@ -25,13 +29,21 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
25
29
  useAlternativePreloader = options.useAlternativePreloader,
26
30
  fullWidthMode = options.fullWidthMode,
27
31
  showServerActions = options.showServerActions,
28
- cardPluginEvents = options.cardPluginEvents;
32
+ cardPluginEvents = options.cardPluginEvents,
33
+ showUpgradeDiscoverability = options.showUpgradeDiscoverability,
34
+ allowEmbeds = options.allowEmbeds,
35
+ allowBlockCards = options.allowBlockCards;
36
+ var enableInlineUpgradeFeatures = !!showUpgradeDiscoverability && platform !== 'mobile';
29
37
  var inlineCardViewProducer = getInlineNodeViewProducer({
30
38
  pmPluginFactoryParams: pmPluginFactoryParams,
31
39
  Component: InlineCardNodeView,
32
40
  extraComponentProps: {
33
41
  useAlternativePreloader: useAlternativePreloader,
34
- showServerActions: showServerActions
42
+ showServerActions: showServerActions,
43
+ enableInlineUpgradeFeatures: enableInlineUpgradeFeatures,
44
+ allowEmbeds: allowEmbeds,
45
+ allowBlockCards: allowBlockCards,
46
+ pluginInjectionApi: pluginInjectionApi
35
47
  }
36
48
  });
37
49
  return new SafePlugin({
@@ -51,6 +63,7 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
51
63
  };
52
64
  },
53
65
  apply: function apply(tr, pluginState, prevEditorState) {
66
+ var _pluginState$requests;
54
67
  // Update all the positions of outstanding requests and
55
68
  // cards in the plugin state.
56
69
  var pluginStateWithUpdatedPos = getPluginStateWithUpdatedPos(pluginState, tr);
@@ -61,10 +74,26 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
61
74
  var events = eventsFromTransaction(tr, prevEditorState);
62
75
  cardPluginEvents.push.apply(cardPluginEvents, _toConsumableArray(events));
63
76
  }
64
- if (meta) {
77
+ if (!meta) {
78
+ return pluginStateWithUpdatedPos;
79
+ }
80
+ if (!getBooleanFF('platform.linking-platform.smart-card.inline-switcher')) {
65
81
  return reducer(pluginStateWithUpdatedPos, meta);
66
82
  }
67
- return pluginStateWithUpdatedPos;
83
+ var newState = reducer(pluginStateWithUpdatedPos, meta);
84
+
85
+ // the code below is related to the "Inline Switcher" project, for more information pls see EDM-7984
86
+ var isSingleInlineLink = (pluginState === null || pluginState === void 0 || (_pluginState$requests = pluginState.requests) === null || _pluginState$requests === void 0 ? void 0 : _pluginState$requests.length) === 1 && pluginState.requests[0].appearance === 'inline';
87
+ var isSmartLinkPulseDiscovered = isLocalStorageKeyDiscovered(LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK);
88
+ if (meta.type !== 'RESOLVE' || !enableInlineUpgradeFeatures || isSmartLinkPulseDiscovered || !isSingleInlineLink) {
89
+ return newState;
90
+ }
91
+ var linkPosition = pluginState.requests[0].pos;
92
+ var canBeUpgradedToEmbed = allowEmbeds && isEmbedSupportedAtPosition(linkPosition, prevEditorState, 'inline');
93
+ if (canBeUpgradedToEmbed) {
94
+ newState.inlineCardAwarenessCandidatePosition = linkPosition;
95
+ }
96
+ return newState;
68
97
  }
69
98
  },
70
99
  view: function view(_view) {
@@ -14,7 +14,8 @@ import { N20A, N800 } from '@atlaskit/theme/colors';
14
14
  import { messages } from '../../messages';
15
15
  var PADDING_IN_PX = 2;
16
16
  var containerStyles = css({
17
- position: 'relative'
17
+ position: 'relative',
18
+ lineHeight: 'normal'
18
19
  });
19
20
  var linkStyles = css({
20
21
  color: "var(--ds-text, #172B4D)",
@@ -16,6 +16,7 @@ import { commandWithMetadata, getButtonGroupOption, LinkToolbarButtonGroup } fro
16
16
  import nodeNames, { cardMessages as messages } from '@atlaskit/editor-common/messages';
17
17
  import { isSupportedInParent } from '@atlaskit/editor-common/utils';
18
18
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
19
+ import { LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR } from '../common/local-storage';
19
20
  import { DiscoveryPulse } from '../common/pulse';
20
21
  import { shouldRenderToolbarPulse } from '../toolbar';
21
22
  // eslint-disable-next-line @repo/internal/react/no-class-components
@@ -42,8 +43,8 @@ export var LinkToolbarAppearance = /*#__PURE__*/function (_React$Component) {
42
43
  platform = _this$props.platform,
43
44
  editorAnalyticsApi = _this$props.editorAnalyticsApi,
44
45
  cardActions = _this$props.cardActions,
45
- _this$props$showInlin = _this$props.showInlineUpgradeDiscoverability,
46
- showInlineUpgradeDiscoverability = _this$props$showInlin === void 0 ? false : _this$props$showInlin;
46
+ _this$props$showUpgra = _this$props.showUpgradeDiscoverability,
47
+ showUpgradeDiscoverability = _this$props$showUpgra === void 0 ? false : _this$props$showUpgra;
47
48
  var preview = allowEmbeds && cardContext && url && cardContext.extractors.getPreview(url, platform);
48
49
  var defaultCommand = function defaultCommand() {
49
50
  return false;
@@ -104,7 +105,7 @@ export var LinkToolbarAppearance = /*#__PURE__*/function (_React$Component) {
104
105
  options.push(embedOption);
105
106
  }
106
107
  var LinkToolbarButtons = /*#__PURE__*/React.createElement(LinkToolbarButtonGroup, {
107
- key: "link-toolbar-button-group",
108
+ key: LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR,
108
109
  options: options.map(function (option) {
109
110
  return getButtonGroupOption(intl, dispatchCommand, _objectSpread(_objectSpread({}, option), {}, {
110
111
  onClick: commandWithMetadata(option.onClick, {
@@ -115,7 +116,7 @@ export var LinkToolbarAppearance = /*#__PURE__*/function (_React$Component) {
115
116
  });
116
117
  var status = url ? cardContext === null || cardContext === void 0 || (_cardContext$store2 = cardContext.store) === null || _cardContext$store2 === void 0 || (_cardContext$store2 = _cardContext$store2.getState()[url]) === null || _cardContext$store2 === void 0 ? void 0 : _cardContext$store2.status : '';
117
118
  var embedEnabled = embedOption ? !embedOption.disabled : false;
118
- if (shouldRenderToolbarPulse(embedEnabled, currentAppearance !== null && currentAppearance !== void 0 ? currentAppearance : '', status !== null && status !== void 0 ? status : '', showInlineUpgradeDiscoverability)) {
119
+ if (shouldRenderToolbarPulse(embedEnabled, currentAppearance !== null && currentAppearance !== void 0 ? currentAppearance : '', status !== null && status !== void 0 ? status : '', showUpgradeDiscoverability)) {
119
120
  return (
120
121
  /*#__PURE__*/
121
122
  // This div is necessary because the toolbar uses :first-child to add margins and can't add margins to the pulse element
package/dist/esm/utils.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { Fragment } from '@atlaskit/editor-prosemirror/model';
1
2
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
2
3
  import { pluginKey } from './pm-plugins/plugin-key';
3
4
  export var appearanceForNodeType = function appearanceForNodeType(spec) {
@@ -45,4 +46,15 @@ export var findCardInfo = function findCardInfo(state) {
45
46
  return pluginState.cards.find(function (cardInfo) {
46
47
  return cardInfo.pos === state.selection.from;
47
48
  });
49
+ };
50
+ var isAppearanceSupportedInParent = function isAppearanceSupportedInParent(currentNodePosition, editorState, fragment, currentAppearance) {
51
+ var resolvedPosition = editorState.doc.resolve(currentNodePosition);
52
+ var parent = currentAppearance === 'embed' || currentAppearance === 'block' ? resolvedPosition.node() : resolvedPosition.node(-1);
53
+ return parent && parent.type.validContent(fragment);
54
+ };
55
+ export var isEmbedSupportedAtPosition = function isEmbedSupportedAtPosition(currentNodePosition, editorState, currentAppearance) {
56
+ return isAppearanceSupportedInParent(currentNodePosition, editorState, Fragment.from(editorState.schema.nodes.embedCard.createChecked({})), currentAppearance);
57
+ };
58
+ export var isBlockSupportedAtPosition = function isBlockSupportedAtPosition(currentNodePosition, editorState, currentAppearance) {
59
+ return isAppearanceSupportedInParent(currentNodePosition, editorState, Fragment.from(editorState.schema.nodes.blockCard.createChecked({})), currentAppearance);
48
60
  };
@@ -0,0 +1,17 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import type { CardContext } from '@atlaskit/link-provider';
3
+ import type { cardPlugin } from '../../plugin';
4
+ export type LinkUpgradeDiscoverabilityProps = {
5
+ url: string;
6
+ linkPosition: number;
7
+ cardContext?: CardContext;
8
+ pluginInjectionApi?: ExtractInjectionAPI<typeof cardPlugin>;
9
+ isPulseEnabled?: boolean;
10
+ isOverlayEnabled?: boolean;
11
+ };
12
+ declare const useLinkUpgradeDiscoverability: ({ url, linkPosition, cardContext, pluginInjectionApi, isPulseEnabled, isOverlayEnabled, }: LinkUpgradeDiscoverabilityProps) => {
13
+ shouldShowToolbarPulse: boolean | undefined;
14
+ shouldShowLinkPulse: boolean | undefined;
15
+ shouldShowLinkOverlay: boolean | undefined;
16
+ };
17
+ export default useLinkUpgradeDiscoverability;
@@ -1,4 +1,7 @@
1
1
  export declare const LOCAL_STORAGE_CLIENT_KEY = "@atlaskit/editor-plugin-card";
2
2
  export declare const LOCAL_STORAGE_DISCOVERED_KEY = "discovered";
3
+ export declare const LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK = "smart-link-upgrade-pulse";
4
+ export declare const LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR = "link-toolbar-button-group";
5
+ export declare const ONE_DAY_IN_MILLISECONDS = 86400000;
3
6
  export declare const isLocalStorageKeyDiscovered: (key: string) => boolean;
4
7
  export declare const markLocalStorageKeyDiscovered: (key: string, expiration?: number) => void;
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { Pulse } from '@atlaskit/linking-common';
3
+ export type PulseDiscoveryMode = 'start' | 'iteration';
3
4
  export interface PulseProps {
4
5
  /**
5
6
  * The component around which the Pulse should be displayed
@@ -17,6 +18,11 @@ export interface PulseProps {
17
18
  * And indicator that the feature was discovered externally and the pulsation needs to stop.
18
19
  */
19
20
  isDiscovered?: boolean;
21
+ /**
22
+ * Indicates when the feature is considered discovered. If "start" is passed, local storage key will be invalidated
23
+ * as soon as the animation starts. If "iteration" is passed (the default one), it will be invalidated after the first iteration
24
+ */
25
+ discoveryMode?: PulseDiscoveryMode;
20
26
  }
21
- export declare const DiscoveryPulse: ({ children, localStorageKey, isDiscovered, localStorageKeyExpirationInMs, }: PulseProps) => JSX.Element;
27
+ export declare const DiscoveryPulse: ({ children, localStorageKey, isDiscovered, localStorageKeyExpirationInMs, discoveryMode, }: PulseProps) => JSX.Element;
22
28
  export default Pulse;
@@ -6,7 +6,7 @@ import type { getPosHandler, ReactComponentProps } from '@atlaskit/editor-common
6
6
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
7
7
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
8
8
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
9
- import type { SmartCardContext } from '@atlaskit/link-provider';
9
+ import type { CardContext } from '@atlaskit/link-provider';
10
10
  import type { CardPlatform } from '@atlaskit/smart-card';
11
11
  import type { cardPlugin } from '../index';
12
12
  export type EditorContext<T> = React.Context<T> & {
@@ -30,8 +30,11 @@ export interface CardProps extends CardNodeViewProps {
30
30
  useAlternativePreloader?: boolean;
31
31
  showServerActions?: boolean;
32
32
  pluginInjectionApi?: ExtractInjectionAPI<typeof cardPlugin>;
33
+ isOverlayEnabled?: boolean;
34
+ isPulseEnabled?: boolean;
35
+ linkPosition?: number;
33
36
  }
34
37
  export interface SmartCardProps extends CardProps {
35
- cardContext?: EditorContext<typeof SmartCardContext>;
38
+ cardContext?: EditorContext<CardContext | undefined>;
36
39
  }
37
40
  export declare function Card(SmartCardComponent: React.ComponentType<SmartCardProps>, UnsupportedComponent: React.ComponentType): React.ComponentType<CardProps>;
@@ -19,5 +19,11 @@ export declare class InlineCardComponent extends React.PureComponent<SmartCardPr
19
19
  }) => void;
20
20
  render(): JSX.Element | null;
21
21
  }
22
- export type InlineCardNodeViewProps = Pick<SmartCardProps, 'useAlternativePreloader' | 'showServerActions'>;
23
- export declare function InlineCardNodeView(props: InlineNodeViewComponentProps & InlineCardNodeViewProps): JSX.Element;
22
+ export type InlineCardNodeViewProps = Pick<SmartCardProps, 'useAlternativePreloader' | 'showServerActions' | 'allowEmbeds' | 'allowBlockCards' | 'enableInlineUpgradeFeatures' | 'pluginInjectionApi'>;
23
+ type InlineCardWithAwarenessProps = {
24
+ allowEmbeds?: boolean;
25
+ allowBlockCards?: boolean;
26
+ enableInlineUpgradeFeatures: boolean;
27
+ };
28
+ export declare function InlineCardNodeView(props: InlineNodeViewComponentProps & InlineCardNodeViewProps & InlineCardWithAwarenessProps): JSX.Element;
29
+ export {};
@@ -1,3 +1,4 @@
1
- import React from 'react';
1
+ /// <reference types="react" />
2
+ import { jsx } from '@emotion/react';
2
3
  import type { SmartCardProps } from './genericCard';
3
- export declare const InlineCardWithAwareness: React.MemoExoticComponent<({ node, cardContext, showServerActions, useAlternativePreloader, view, getPos, }: SmartCardProps) => JSX.Element | null>;
4
+ export declare const InlineCardWithAwareness: import("react").MemoExoticComponent<({ node, cardContext, showServerActions, useAlternativePreloader, view, getPos, isOverlayEnabled, isPulseEnabled, pluginInjectionApi, }: SmartCardProps) => jsx.JSX.Element | null>;
@@ -26,5 +26,9 @@ export declare const getPluginStateWithUpdatedPos: (pluginState: CardPluginState
26
26
  datasourceModalType?: import("@atlaskit/editor-common/types").DatasourceModalType | undefined;
27
27
  datasourceTableRef?: HTMLElement | undefined;
28
28
  layout?: import("../../ui/LayoutButton/types").DatasourceTableLayout | undefined;
29
+ inlineCardAwarenessCandidatePosition?: number | undefined;
30
+ selectedInlineLinkPosition?: number | undefined;
31
+ allowEmbeds?: boolean | undefined;
32
+ allowBlockCards?: boolean | undefined;
29
33
  };
30
34
  export declare const getNewRequests: (oldState: CardPluginState | undefined, currentState: CardPluginState) => Request[];
@@ -1,12 +1,12 @@
1
- import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
2
- import { ACTION } from '@atlaskit/editor-common/analytics';
1
+ import type { UIAnalyticsEvent } from '@atlaskit/analytics-next';
2
+ import type { ACTION } from '@atlaskit/editor-common/analytics';
3
3
  import type { CardOptions, CardReplacementInputMethod } from '@atlaskit/editor-common/card';
4
- import { CardAppearance, CardProvider } from '@atlaskit/editor-common/provider-factory';
4
+ import type { CardAppearance, CardProvider } from '@atlaskit/editor-common/provider-factory';
5
5
  import type { DatasourceModalType, EditorAppearance, LinkPickerOptions } from '@atlaskit/editor-common/types';
6
- import { SmartLinkEvents } from '@atlaskit/smart-card';
7
- import { EditorCardPluginEvents } from './analytics/create-events-queue';
8
- import { CardPluginEvent } from './analytics/types';
9
- import { DatasourceTableLayout } from './ui/LayoutButton/types';
6
+ import type { SmartLinkEvents } from '@atlaskit/smart-card';
7
+ import type { EditorCardPluginEvents } from './analytics/create-events-queue';
8
+ import type { CardPluginEvent } from './analytics/types';
9
+ import type { DatasourceTableLayout } from './ui/LayoutButton/types';
10
10
  export type CardInfo = {
11
11
  title?: string;
12
12
  url?: string;
@@ -76,6 +76,10 @@ export type CardPluginState = {
76
76
  datasourceModalType?: DatasourceModalType;
77
77
  datasourceTableRef?: HTMLElement;
78
78
  layout?: DatasourceTableLayout;
79
+ inlineCardAwarenessCandidatePosition?: number;
80
+ selectedInlineLinkPosition?: number;
81
+ allowEmbeds?: boolean;
82
+ allowBlockCards?: boolean;
79
83
  };
80
84
  export type CardPluginOptions = CardOptions & {
81
85
  editorAppearance?: EditorAppearance;
@@ -19,7 +19,7 @@ export interface LinkToolbarAppearanceProps {
19
19
  allowBlockCards?: boolean;
20
20
  platform?: CardPlatform;
21
21
  cardActions: CardPluginActions | undefined;
22
- showInlineUpgradeDiscoverability?: boolean;
22
+ showUpgradeDiscoverability?: boolean;
23
23
  }
24
24
  export declare class LinkToolbarAppearance extends React.Component<LinkToolbarAppearanceProps, {}> {
25
25
  static contextTypes: {
@@ -1,6 +1,6 @@
1
- import { CardAppearance } from '@atlaskit/editor-common/provider-factory';
2
- import { Node, NodeType } from '@atlaskit/editor-prosemirror/model';
3
- import { EditorState } from '@atlaskit/editor-prosemirror/state';
1
+ import type { CardAppearance } from '@atlaskit/editor-common/provider-factory';
2
+ import type { Node, NodeType } from '@atlaskit/editor-prosemirror/model';
3
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { CardInfo } from './types';
5
5
  export declare const appearanceForNodeType: (spec: NodeType) => CardAppearance | undefined;
6
6
  export declare const selectedCardAppearance: (state: EditorState) => CardAppearance | undefined;
@@ -17,3 +17,5 @@ export declare const titleUrlPairFromNode: (node: Node) => TitleUrlPair;
17
17
  export declare const mergeCardInfo: (titleUrlPair: TitleUrlPair, info?: CardInfo) => TitleUrlPair;
18
18
  export declare const displayInfoForCard: (node: Node, info?: CardInfo) => TitleUrlPair;
19
19
  export declare const findCardInfo: (state: EditorState) => CardInfo | undefined;
20
+ export declare const isEmbedSupportedAtPosition: (currentNodePosition: number, editorState: EditorState, currentAppearance?: CardAppearance) => boolean;
21
+ export declare const isBlockSupportedAtPosition: (currentNodePosition: number, editorState: EditorState, currentAppearance?: CardAppearance) => boolean;
@@ -0,0 +1,17 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import type { CardContext } from '@atlaskit/link-provider';
3
+ import type { cardPlugin } from '../../plugin';
4
+ export type LinkUpgradeDiscoverabilityProps = {
5
+ url: string;
6
+ linkPosition: number;
7
+ cardContext?: CardContext;
8
+ pluginInjectionApi?: ExtractInjectionAPI<typeof cardPlugin>;
9
+ isPulseEnabled?: boolean;
10
+ isOverlayEnabled?: boolean;
11
+ };
12
+ declare const useLinkUpgradeDiscoverability: ({ url, linkPosition, cardContext, pluginInjectionApi, isPulseEnabled, isOverlayEnabled, }: LinkUpgradeDiscoverabilityProps) => {
13
+ shouldShowToolbarPulse: boolean | undefined;
14
+ shouldShowLinkPulse: boolean | undefined;
15
+ shouldShowLinkOverlay: boolean | undefined;
16
+ };
17
+ export default useLinkUpgradeDiscoverability;
@@ -1,4 +1,7 @@
1
1
  export declare const LOCAL_STORAGE_CLIENT_KEY = "@atlaskit/editor-plugin-card";
2
2
  export declare const LOCAL_STORAGE_DISCOVERED_KEY = "discovered";
3
+ export declare const LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK = "smart-link-upgrade-pulse";
4
+ export declare const LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR = "link-toolbar-button-group";
5
+ export declare const ONE_DAY_IN_MILLISECONDS = 86400000;
3
6
  export declare const isLocalStorageKeyDiscovered: (key: string) => boolean;
4
7
  export declare const markLocalStorageKeyDiscovered: (key: string, expiration?: number) => void;
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { Pulse } from '@atlaskit/linking-common';
3
+ export type PulseDiscoveryMode = 'start' | 'iteration';
3
4
  export interface PulseProps {
4
5
  /**
5
6
  * The component around which the Pulse should be displayed
@@ -17,6 +18,11 @@ export interface PulseProps {
17
18
  * And indicator that the feature was discovered externally and the pulsation needs to stop.
18
19
  */
19
20
  isDiscovered?: boolean;
21
+ /**
22
+ * Indicates when the feature is considered discovered. If "start" is passed, local storage key will be invalidated
23
+ * as soon as the animation starts. If "iteration" is passed (the default one), it will be invalidated after the first iteration
24
+ */
25
+ discoveryMode?: PulseDiscoveryMode;
20
26
  }
21
- export declare const DiscoveryPulse: ({ children, localStorageKey, isDiscovered, localStorageKeyExpirationInMs, }: PulseProps) => JSX.Element;
27
+ export declare const DiscoveryPulse: ({ children, localStorageKey, isDiscovered, localStorageKeyExpirationInMs, discoveryMode, }: PulseProps) => JSX.Element;
22
28
  export default Pulse;
@@ -6,7 +6,7 @@ import type { getPosHandler, ReactComponentProps } from '@atlaskit/editor-common
6
6
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
7
7
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
8
8
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
9
- import type { SmartCardContext } from '@atlaskit/link-provider';
9
+ import type { CardContext } from '@atlaskit/link-provider';
10
10
  import type { CardPlatform } from '@atlaskit/smart-card';
11
11
  import type { cardPlugin } from '../index';
12
12
  export type EditorContext<T> = React.Context<T> & {
@@ -30,8 +30,11 @@ export interface CardProps extends CardNodeViewProps {
30
30
  useAlternativePreloader?: boolean;
31
31
  showServerActions?: boolean;
32
32
  pluginInjectionApi?: ExtractInjectionAPI<typeof cardPlugin>;
33
+ isOverlayEnabled?: boolean;
34
+ isPulseEnabled?: boolean;
35
+ linkPosition?: number;
33
36
  }
34
37
  export interface SmartCardProps extends CardProps {
35
- cardContext?: EditorContext<typeof SmartCardContext>;
38
+ cardContext?: EditorContext<CardContext | undefined>;
36
39
  }
37
40
  export declare function Card(SmartCardComponent: React.ComponentType<SmartCardProps>, UnsupportedComponent: React.ComponentType): React.ComponentType<CardProps>;
@@ -19,5 +19,11 @@ export declare class InlineCardComponent extends React.PureComponent<SmartCardPr
19
19
  }) => void;
20
20
  render(): JSX.Element | null;
21
21
  }
22
- export type InlineCardNodeViewProps = Pick<SmartCardProps, 'useAlternativePreloader' | 'showServerActions'>;
23
- export declare function InlineCardNodeView(props: InlineNodeViewComponentProps & InlineCardNodeViewProps): JSX.Element;
22
+ export type InlineCardNodeViewProps = Pick<SmartCardProps, 'useAlternativePreloader' | 'showServerActions' | 'allowEmbeds' | 'allowBlockCards' | 'enableInlineUpgradeFeatures' | 'pluginInjectionApi'>;
23
+ type InlineCardWithAwarenessProps = {
24
+ allowEmbeds?: boolean;
25
+ allowBlockCards?: boolean;
26
+ enableInlineUpgradeFeatures: boolean;
27
+ };
28
+ export declare function InlineCardNodeView(props: InlineNodeViewComponentProps & InlineCardNodeViewProps & InlineCardWithAwarenessProps): JSX.Element;
29
+ export {};
@@ -1,3 +1,4 @@
1
- import React from 'react';
1
+ /// <reference types="react" />
2
+ import { jsx } from '@emotion/react';
2
3
  import type { SmartCardProps } from './genericCard';
3
- export declare const InlineCardWithAwareness: React.MemoExoticComponent<({ node, cardContext, showServerActions, useAlternativePreloader, view, getPos, }: SmartCardProps) => JSX.Element | null>;
4
+ export declare const InlineCardWithAwareness: import("react").MemoExoticComponent<({ node, cardContext, showServerActions, useAlternativePreloader, view, getPos, isOverlayEnabled, isPulseEnabled, pluginInjectionApi, }: SmartCardProps) => jsx.JSX.Element | null>;
@@ -26,5 +26,9 @@ export declare const getPluginStateWithUpdatedPos: (pluginState: CardPluginState
26
26
  datasourceModalType?: import("@atlaskit/editor-common/types").DatasourceModalType | undefined;
27
27
  datasourceTableRef?: HTMLElement | undefined;
28
28
  layout?: import("../../ui/LayoutButton/types").DatasourceTableLayout | undefined;
29
+ inlineCardAwarenessCandidatePosition?: number | undefined;
30
+ selectedInlineLinkPosition?: number | undefined;
31
+ allowEmbeds?: boolean | undefined;
32
+ allowBlockCards?: boolean | undefined;
29
33
  };
30
34
  export declare const getNewRequests: (oldState: CardPluginState | undefined, currentState: CardPluginState) => Request[];
@@ -1,12 +1,12 @@
1
- import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
2
- import { ACTION } from '@atlaskit/editor-common/analytics';
1
+ import type { UIAnalyticsEvent } from '@atlaskit/analytics-next';
2
+ import type { ACTION } from '@atlaskit/editor-common/analytics';
3
3
  import type { CardOptions, CardReplacementInputMethod } from '@atlaskit/editor-common/card';
4
- import { CardAppearance, CardProvider } from '@atlaskit/editor-common/provider-factory';
4
+ import type { CardAppearance, CardProvider } from '@atlaskit/editor-common/provider-factory';
5
5
  import type { DatasourceModalType, EditorAppearance, LinkPickerOptions } from '@atlaskit/editor-common/types';
6
- import { SmartLinkEvents } from '@atlaskit/smart-card';
7
- import { EditorCardPluginEvents } from './analytics/create-events-queue';
8
- import { CardPluginEvent } from './analytics/types';
9
- import { DatasourceTableLayout } from './ui/LayoutButton/types';
6
+ import type { SmartLinkEvents } from '@atlaskit/smart-card';
7
+ import type { EditorCardPluginEvents } from './analytics/create-events-queue';
8
+ import type { CardPluginEvent } from './analytics/types';
9
+ import type { DatasourceTableLayout } from './ui/LayoutButton/types';
10
10
  export type CardInfo = {
11
11
  title?: string;
12
12
  url?: string;
@@ -76,6 +76,10 @@ export type CardPluginState = {
76
76
  datasourceModalType?: DatasourceModalType;
77
77
  datasourceTableRef?: HTMLElement;
78
78
  layout?: DatasourceTableLayout;
79
+ inlineCardAwarenessCandidatePosition?: number;
80
+ selectedInlineLinkPosition?: number;
81
+ allowEmbeds?: boolean;
82
+ allowBlockCards?: boolean;
79
83
  };
80
84
  export type CardPluginOptions = CardOptions & {
81
85
  editorAppearance?: EditorAppearance;
@@ -19,7 +19,7 @@ export interface LinkToolbarAppearanceProps {
19
19
  allowBlockCards?: boolean;
20
20
  platform?: CardPlatform;
21
21
  cardActions: CardPluginActions | undefined;
22
- showInlineUpgradeDiscoverability?: boolean;
22
+ showUpgradeDiscoverability?: boolean;
23
23
  }
24
24
  export declare class LinkToolbarAppearance extends React.Component<LinkToolbarAppearanceProps, {}> {
25
25
  static contextTypes: {
@@ -1,6 +1,6 @@
1
- import { CardAppearance } from '@atlaskit/editor-common/provider-factory';
2
- import { Node, NodeType } from '@atlaskit/editor-prosemirror/model';
3
- import { EditorState } from '@atlaskit/editor-prosemirror/state';
1
+ import type { CardAppearance } from '@atlaskit/editor-common/provider-factory';
2
+ import type { Node, NodeType } from '@atlaskit/editor-prosemirror/model';
3
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { CardInfo } from './types';
5
5
  export declare const appearanceForNodeType: (spec: NodeType) => CardAppearance | undefined;
6
6
  export declare const selectedCardAppearance: (state: EditorState) => CardAppearance | undefined;
@@ -17,3 +17,5 @@ export declare const titleUrlPairFromNode: (node: Node) => TitleUrlPair;
17
17
  export declare const mergeCardInfo: (titleUrlPair: TitleUrlPair, info?: CardInfo) => TitleUrlPair;
18
18
  export declare const displayInfoForCard: (node: Node, info?: CardInfo) => TitleUrlPair;
19
19
  export declare const findCardInfo: (state: EditorState) => CardInfo | undefined;
20
+ export declare const isEmbedSupportedAtPosition: (currentNodePosition: number, editorState: EditorState, currentAppearance?: CardAppearance) => boolean;
21
+ export declare const isBlockSupportedAtPosition: (currentNodePosition: number, editorState: EditorState, currentAppearance?: CardAppearance) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "0.12.1",
3
+ "version": "0.13.0",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,7 +34,7 @@
34
34
  "@atlaskit/adf-schema": "^32.0.0",
35
35
  "@atlaskit/analytics-next": "^9.1.0",
36
36
  "@atlaskit/custom-steps": "^0.0.2",
37
- "@atlaskit/editor-common": "^76.18.0",
37
+ "@atlaskit/editor-common": "^76.19.0",
38
38
  "@atlaskit/editor-plugin-analytics": "^0.3.0",
39
39
  "@atlaskit/editor-plugin-decorations": "^0.2.0",
40
40
  "@atlaskit/editor-plugin-feature-flags": "^1.0.0",
@@ -48,8 +48,8 @@
48
48
  "@atlaskit/icon": "^21.12.0",
49
49
  "@atlaskit/link-analytics": "^8.3.0",
50
50
  "@atlaskit/link-client-extension": "^1.8.0",
51
- "@atlaskit/link-datasource": "^1.15.0",
52
- "@atlaskit/linking-common": "^4.17.0",
51
+ "@atlaskit/link-datasource": "^1.16.0",
52
+ "@atlaskit/linking-common": "^4.18.0",
53
53
  "@atlaskit/linking-types": "^8.4.0",
54
54
  "@atlaskit/platform-feature-flags": "^0.2.0",
55
55
  "@atlaskit/primitives": "^1.9.0",
package/report.api.md CHANGED
@@ -15,12 +15,12 @@
15
15
  <!--SECTION START: Main Entry Types-->
16
16
 
17
17
  ```ts
18
- import { ACTION } from '@atlaskit/editor-common/analytics';
18
+ import type { ACTION } from '@atlaskit/editor-common/analytics';
19
19
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
20
- import { CardAppearance } from '@atlaskit/editor-common/provider-factory';
20
+ import type { CardAppearance } from '@atlaskit/editor-common/provider-factory';
21
21
  import type { CardOptions } from '@atlaskit/editor-common/card';
22
22
  import type { CardPluginActions } from '@atlaskit/editor-common/card';
23
- import { CardProvider } from '@atlaskit/editor-common/provider-factory';
23
+ import type { CardProvider } from '@atlaskit/editor-common/provider-factory';
24
24
  import type { CardReplacementInputMethod } from '@atlaskit/editor-common/card';
25
25
  import type { DatasourceModalType } from '@atlaskit/editor-common/types';
26
26
  import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
@@ -33,8 +33,8 @@ import type { LinkPickerOptions } from '@atlaskit/editor-common/types';
33
33
  import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
34
34
  import type { Node as Node_2 } from '@atlaskit/editor-prosemirror/model';
35
35
  import type { OptionalPlugin } from '@atlaskit/editor-common/types';
36
- import { SmartLinkEvents } from '@atlaskit/smart-card';
37
- import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
36
+ import type { SmartLinkEvents } from '@atlaskit/smart-card';
37
+ import type { UIAnalyticsEvent } from '@atlaskit/analytics-next';
38
38
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
39
39
 
40
40
  // @public (undocumented)
@@ -90,6 +90,10 @@ type CardPluginState = {
90
90
  datasourceModalType?: DatasourceModalType;
91
91
  datasourceTableRef?: HTMLElement;
92
92
  layout?: DatasourceTableLayout;
93
+ inlineCardAwarenessCandidatePosition?: number;
94
+ selectedInlineLinkPosition?: number;
95
+ allowEmbeds?: boolean;
96
+ allowBlockCards?: boolean;
93
97
  };
94
98
 
95
99
  // @public (undocumented)
@@ -4,12 +4,12 @@
4
4
 
5
5
  ```ts
6
6
 
7
- import { ACTION } from '@atlaskit/editor-common/analytics';
7
+ import type { ACTION } from '@atlaskit/editor-common/analytics';
8
8
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
9
- import { CardAppearance } from '@atlaskit/editor-common/provider-factory';
9
+ import type { CardAppearance } from '@atlaskit/editor-common/provider-factory';
10
10
  import type { CardOptions } from '@atlaskit/editor-common/card';
11
11
  import type { CardPluginActions } from '@atlaskit/editor-common/card';
12
- import { CardProvider } from '@atlaskit/editor-common/provider-factory';
12
+ import type { CardProvider } from '@atlaskit/editor-common/provider-factory';
13
13
  import type { CardReplacementInputMethod } from '@atlaskit/editor-common/card';
14
14
  import type { DatasourceModalType } from '@atlaskit/editor-common/types';
15
15
  import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
@@ -22,8 +22,8 @@ import type { LinkPickerOptions } from '@atlaskit/editor-common/types';
22
22
  import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
23
23
  import type { Node as Node_2 } from '@atlaskit/editor-prosemirror/model';
24
24
  import type { OptionalPlugin } from '@atlaskit/editor-common/types';
25
- import { SmartLinkEvents } from '@atlaskit/smart-card';
26
- import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
25
+ import type { SmartLinkEvents } from '@atlaskit/smart-card';
26
+ import type { UIAnalyticsEvent } from '@atlaskit/analytics-next';
27
27
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
28
28
 
29
29
  // @public (undocumented)
@@ -76,6 +76,10 @@ type CardPluginState = {
76
76
  datasourceModalType?: DatasourceModalType;
77
77
  datasourceTableRef?: HTMLElement;
78
78
  layout?: DatasourceTableLayout;
79
+ inlineCardAwarenessCandidatePosition?: number;
80
+ selectedInlineLinkPosition?: number;
81
+ allowEmbeds?: boolean;
82
+ allowBlockCards?: boolean;
79
83
  };
80
84
 
81
85
  // @public (undocumented)