@atlaskit/editor-plugin-card 4.5.17 → 4.5.19

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 (60) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/nodeviews/blockCard.js +18 -2
  3. package/dist/cjs/nodeviews/embedCard.js +16 -1
  4. package/dist/cjs/nodeviews/inlineCard.js +18 -2
  5. package/dist/cjs/nodeviews/inlineCardWithAwareness.js +18 -3
  6. package/dist/cjs/pm-plugins/actions.js +12 -3
  7. package/dist/cjs/pm-plugins/reducers.js +13 -0
  8. package/dist/es2019/nodeviews/blockCard.js +19 -3
  9. package/dist/es2019/nodeviews/embedCard.js +17 -2
  10. package/dist/es2019/nodeviews/inlineCard.js +22 -4
  11. package/dist/es2019/nodeviews/inlineCardWithAwareness.js +12 -1
  12. package/dist/es2019/pm-plugins/actions.js +7 -2
  13. package/dist/es2019/pm-plugins/reducers.js +12 -0
  14. package/dist/esm/nodeviews/blockCard.js +19 -3
  15. package/dist/esm/nodeviews/embedCard.js +17 -2
  16. package/dist/esm/nodeviews/inlineCard.js +20 -4
  17. package/dist/esm/nodeviews/inlineCardWithAwareness.js +18 -3
  18. package/dist/esm/pm-plugins/actions.js +11 -2
  19. package/dist/esm/pm-plugins/reducers.js +13 -0
  20. package/dist/types/nodeviews/blockCard.d.ts +11 -5
  21. package/dist/types/nodeviews/embedCard.d.ts +10 -4
  22. package/dist/types/nodeviews/genericCard.d.ts +3 -1
  23. package/dist/types/nodeviews/inlineCard.d.ts +2 -2
  24. package/dist/types/nodeviews/inlineCardWithAwareness.d.ts +1 -1
  25. package/dist/types/pm-plugins/actions.d.ts +2 -1
  26. package/dist/types/pm-plugins/util/state.d.ts +1 -0
  27. package/dist/types/types/index.d.ts +7 -1
  28. package/dist/types/ui/DatasourceIcon/index.d.ts +2 -2
  29. package/dist/types/ui/DatasourceModal/ModalWithState.d.ts +1 -1
  30. package/dist/types/ui/DatasourceModal/index.d.ts +2 -2
  31. package/dist/types/ui/EditLinkToolbar.d.ts +2 -2
  32. package/dist/types/ui/EditorAnalyticsContext.d.ts +1 -1
  33. package/dist/types/ui/EditorLinkingPlatformAnalytics/index.d.ts +1 -1
  34. package/dist/types/ui/HyperlinkToolbarAppearance.d.ts +2 -2
  35. package/dist/types/ui/LinkToolbarAppearance.d.ts +2 -2
  36. package/dist/types/ui/Pulse/index.d.ts +2 -2
  37. package/dist/types/ui/ToolbarViewedEvent.d.ts +2 -2
  38. package/dist/types/ui/WithCardContext.d.ts +1 -1
  39. package/dist/types/ui/datasourceErrorBoundary.d.ts +1 -1
  40. package/dist/types-ts4.5/nodeviews/blockCard.d.ts +11 -5
  41. package/dist/types-ts4.5/nodeviews/embedCard.d.ts +10 -4
  42. package/dist/types-ts4.5/nodeviews/genericCard.d.ts +3 -1
  43. package/dist/types-ts4.5/nodeviews/inlineCard.d.ts +2 -2
  44. package/dist/types-ts4.5/nodeviews/inlineCardWithAwareness.d.ts +1 -1
  45. package/dist/types-ts4.5/pm-plugins/actions.d.ts +2 -1
  46. package/dist/types-ts4.5/pm-plugins/util/state.d.ts +1 -0
  47. package/dist/types-ts4.5/types/index.d.ts +7 -1
  48. package/dist/types-ts4.5/ui/DatasourceIcon/index.d.ts +2 -2
  49. package/dist/types-ts4.5/ui/DatasourceModal/ModalWithState.d.ts +1 -1
  50. package/dist/types-ts4.5/ui/DatasourceModal/index.d.ts +2 -2
  51. package/dist/types-ts4.5/ui/EditLinkToolbar.d.ts +2 -2
  52. package/dist/types-ts4.5/ui/EditorAnalyticsContext.d.ts +1 -1
  53. package/dist/types-ts4.5/ui/EditorLinkingPlatformAnalytics/index.d.ts +1 -1
  54. package/dist/types-ts4.5/ui/HyperlinkToolbarAppearance.d.ts +2 -2
  55. package/dist/types-ts4.5/ui/LinkToolbarAppearance.d.ts +2 -2
  56. package/dist/types-ts4.5/ui/Pulse/index.d.ts +2 -2
  57. package/dist/types-ts4.5/ui/ToolbarViewedEvent.d.ts +2 -2
  58. package/dist/types-ts4.5/ui/WithCardContext.d.ts +1 -1
  59. package/dist/types-ts4.5/ui/datasourceErrorBoundary.d.ts +1 -1
  60. package/package.json +15 -11
@@ -1,14 +1,16 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
- import React, { memo, useCallback, useMemo, useState } from 'react';
3
+ import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
4
4
  import rafSchedule from 'raf-schd';
5
+ import uuid from 'uuid/v4';
5
6
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
6
7
  import { handleNavigation } from '@atlaskit/editor-common/link';
7
8
  import { findOverflowScrollParent, UnsupportedInline } from '@atlaskit/editor-common/ui';
8
9
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
9
10
  import { fg } from '@atlaskit/platform-feature-flags';
10
11
  import { Card as SmartCard } from '@atlaskit/smart-card';
11
- import { registerCard } from '../pm-plugins/actions';
12
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
13
+ import { registerCard, removeCard } from '../pm-plugins/actions';
12
14
  import { getAwarenessProps } from '../pm-plugins/utils';
13
15
  import OverlayWrapper from '../ui/ConfigureOverlay';
14
16
  import { Card } from './genericCard';
@@ -28,6 +30,19 @@ export var InlineCard = /*#__PURE__*/memo(function (_ref) {
28
30
  var _node$attrs = node.attrs,
29
31
  url = _node$attrs.url,
30
32
  data = _node$attrs.data;
33
+ var refId = useRef(uuid());
34
+ useEffect(function () {
35
+ var id = refId.current;
36
+ return function () {
37
+ if (fg('platform_editor_fix_card_plugin_state')) {
38
+ var tr = view.state.tr;
39
+ removeCard({
40
+ id: id
41
+ })(tr);
42
+ view.dispatch(tr);
43
+ }
44
+ };
45
+ }, [getPos, view]);
31
46
  var scrollContainer = useMemo(
32
47
  // Ignored via go/ees005
33
48
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
@@ -52,7 +67,8 @@ export var InlineCard = /*#__PURE__*/memo(function (_ref) {
52
67
  registerCard({
53
68
  title: title,
54
69
  url: url,
55
- pos: pos
70
+ pos: pos,
71
+ id: refId.current
56
72
  })(tr);
57
73
  onRes === null || onRes === void 0 || onRes(tr, title);
58
74
  view.dispatch(tr);
@@ -154,7 +170,7 @@ export function InlineCardNodeView(props) {
154
170
  onClickCallback: onClickCallback
155
171
  // Ignored via go/ees005
156
172
  // eslint-disable-next-line react/jsx-props-no-spreading
157
- }, enableInlineUpgradeFeatures && getAwarenessProps(view.state, getPos, allowEmbeds, allowBlockCards, (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view')));
173
+ }, enableInlineUpgradeFeatures && getAwarenessProps(view.state, getPos, allowEmbeds, allowBlockCards, !editorExperiment('live_pages_graceful_edit', 'control') ? true : (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view')));
158
174
  }
159
175
  export var inlineCardNodeView = function inlineCardNodeView(_ref2) {
160
176
  var inlineCardViewProducer = _ref2.inlineCardViewProducer;
@@ -1,6 +1,8 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import React, { memo, useCallback, useMemo, useState } from 'react';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  import { registerRemoveOverlay } from '../pm-plugins/actions';
5
+ import { pluginKey } from '../pm-plugins/plugin-key';
4
6
  import { AwarenessWrapper } from '../ui/AwarenessWrapper';
5
7
  import { InlineCard } from './inlineCard';
6
8
  export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
@@ -28,9 +30,22 @@ export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
28
30
  isResolvedViewRendered = _useState6[0],
29
31
  setIsResolvedViewRendered = _useState6[1];
30
32
  var onResolve = useCallback(function (tr, title) {
31
- registerRemoveOverlay(function () {
32
- return setIsInserted(false);
33
- })(tr);
33
+ if (fg('platform_editor_fix_card_plugin_state')) {
34
+ var metadata = tr.getMeta(pluginKey);
35
+ if (metadata && metadata.type === 'REGISTER') {
36
+ registerRemoveOverlay(function () {
37
+ return setIsInserted(false);
38
+ }, metadata.info)(tr);
39
+ } else {
40
+ registerRemoveOverlay(function () {
41
+ return setIsInserted(false);
42
+ })(tr);
43
+ }
44
+ } else {
45
+ registerRemoveOverlay(function () {
46
+ return setIsInserted(false);
47
+ })(tr);
48
+ }
34
49
  if (title) {
35
50
  setIsResolvedViewRendered(true);
36
51
  }
@@ -26,11 +26,20 @@ export var registerCard = function registerCard(info) {
26
26
  });
27
27
  };
28
28
  };
29
- export var registerRemoveOverlay = function registerRemoveOverlay(callback) {
29
+ export var removeCard = function removeCard(info) {
30
+ return function (tr) {
31
+ return cardAction(tr, {
32
+ type: 'REMOVE_CARD',
33
+ info: info
34
+ });
35
+ };
36
+ };
37
+ export var registerRemoveOverlay = function registerRemoveOverlay(callback, info) {
30
38
  return function (tr) {
31
39
  return cardAction(tr, {
32
40
  type: 'REGISTER_REMOVE_OVERLAY_ON_INSERTED_LINK',
33
- callback: callback
41
+ callback: callback,
42
+ info: info
34
43
  });
35
44
  };
36
45
  };
@@ -28,6 +28,13 @@ var register = function register(state, action) {
28
28
  }).concat(action.info)
29
29
  });
30
30
  };
31
+ var removeCard = function removeCard(state, action) {
32
+ return _objectSpread(_objectSpread({}, state), {}, {
33
+ cards: state.cards.filter(function (card) {
34
+ return card.id !== action.info.id;
35
+ })
36
+ });
37
+ };
31
38
  var setProvider = function setProvider(state, action) {
32
39
  return _objectSpread(_objectSpread({}, state), {}, {
33
40
  provider: action.provider
@@ -78,6 +85,10 @@ var clearOverlayCandidate = function clearOverlayCandidate(state) {
78
85
  };
79
86
  var registerRemoveOverlayOnInsertedLink = function registerRemoveOverlayOnInsertedLink(state, action) {
80
87
  return _objectSpread(_objectSpread({}, state), {}, {
88
+ cards: action.info ? state.cards.filter(function (card) {
89
+ var _action$info;
90
+ return card.pos !== ((_action$info = action.info) === null || _action$info === void 0 ? void 0 : _action$info.pos);
91
+ }).concat(action.info) : state.cards,
81
92
  removeOverlay: action.callback
82
93
  });
83
94
  };
@@ -107,6 +118,8 @@ export default (function (state, action) {
107
118
  return resolve(state, action);
108
119
  case 'REGISTER':
109
120
  return register(state, action);
121
+ case 'REMOVE_CARD':
122
+ return removeCard(state, action);
110
123
  case 'REGISTER_EVENTS':
111
124
  return registerEvents(state, action);
112
125
  case 'SET_DATASOURCE_TABLE_REF':
@@ -5,28 +5,34 @@ import type { Node } from '@atlaskit/editor-prosemirror/model';
5
5
  import type { Decoration, DecorationSource, EditorView } from '@atlaskit/editor-prosemirror/view';
6
6
  import { Datasource } from '../nodeviews/datasource';
7
7
  import type { SmartCardProps } from './genericCard';
8
- export declare class BlockCardComponent extends React.PureComponent<SmartCardProps> {
8
+ export declare class BlockCardComponent extends React.PureComponent<SmartCardProps & {
9
+ id?: string;
10
+ }> {
9
11
  private scrollContainer?;
10
- constructor(props: SmartCardProps);
12
+ constructor(props: SmartCardProps & {
13
+ id?: string;
14
+ });
11
15
  onResolve: (data: {
12
16
  url?: string | undefined;
13
17
  title?: string | undefined;
14
18
  }) => void;
15
- gapCursorSpan: () => JSX.Element | undefined;
19
+ gapCursorSpan: () => React.JSX.Element | undefined;
16
20
  onError: ({ err }: {
17
21
  err?: Error | undefined;
18
22
  }) => void;
19
- render(): JSX.Element;
23
+ render(): React.JSX.Element;
20
24
  }
21
25
  export type BlockCardNodeViewProps = Pick<SmartCardProps, 'actionOptions' | 'pluginInjectionApi' | 'onClickCallback'>;
22
26
  export declare class BlockCard extends ReactNodeView<BlockCardNodeViewProps> {
27
+ private id;
23
28
  unsubscribe: (() => void) | undefined;
24
29
  createDomRef(): HTMLElement;
25
30
  private updateContentEditable;
26
31
  validUpdate(currentNode: Node, newNode: Node): boolean;
27
32
  update(node: Node, decorations: ReadonlyArray<Decoration>, _innerDecorations?: DecorationSource): boolean;
28
- render(): JSX.Element;
33
+ render(): React.JSX.Element;
29
34
  destroy(): void;
35
+ private removeCard;
30
36
  }
31
37
  export interface BlockCardNodeViewProperties {
32
38
  pmPluginFactoryParams: PMPluginFactoryParams;
@@ -11,10 +11,14 @@ export type EmbedCardState = {
11
11
  liveHeight?: number;
12
12
  initialAspectRatio?: number;
13
13
  };
14
- export declare class EmbedCardComponent extends React.PureComponent<SmartCardProps, EmbedCardState> {
14
+ export declare class EmbedCardComponent extends React.PureComponent<SmartCardProps & {
15
+ id?: string;
16
+ }, EmbedCardState> {
15
17
  private scrollContainer?;
16
18
  private embedIframeRef;
17
- constructor(props: SmartCardProps);
19
+ constructor(props: SmartCardProps & {
20
+ id?: string;
21
+ });
18
22
  state: EmbedCardState;
19
23
  private getPosSafely;
20
24
  onResolve: (data: {
@@ -34,16 +38,18 @@ export declare class EmbedCardComponent extends React.PureComponent<SmartCardPro
34
38
  onError: ({ err }: {
35
39
  err?: Error | undefined;
36
40
  }) => void;
37
- render(): JSX.Element;
41
+ render(): React.JSX.Element;
38
42
  }
39
43
  export type EmbedCardNodeViewProps = Pick<SmartCardProps, 'eventDispatcher' | 'allowResizing' | 'fullWidthMode' | 'dispatchAnalyticsEvent' | 'pluginInjectionApi' | 'actionOptions' | 'onClickCallback'>;
40
44
  export declare class EmbedCard extends ReactNodeView<EmbedCardNodeViewProps> {
45
+ private id;
41
46
  unsubscribe: (() => void) | undefined;
42
47
  viewShouldUpdate(nextNode: PMNode): boolean;
43
48
  createDomRef(): HTMLElement;
44
49
  private updateContentEditable;
45
- render(): JSX.Element;
50
+ render(): React.JSX.Element;
46
51
  destroy(): void;
52
+ private removeCard;
47
53
  }
48
54
  export interface EmbedCardNodeViewProperties {
49
55
  allowResizing: EmbedCardNodeViewProps['allowResizing'];
@@ -46,4 +46,6 @@ export interface SmartCardProps extends CardProps {
46
46
  allowBlockCards?: boolean;
47
47
  enableInlineUpgradeFeatures?: boolean;
48
48
  }
49
- export declare function Card(SmartCardComponent: React.ComponentType<React.PropsWithChildren<SmartCardProps>>, UnsupportedComponent: React.ComponentType<React.PropsWithChildren<unknown>>): React.ComponentType<React.PropsWithChildren<CardProps>>;
49
+ export declare function Card(SmartCardComponent: React.ComponentType<React.PropsWithChildren<SmartCardProps & {
50
+ id?: string;
51
+ }>>, UnsupportedComponent: React.ComponentType<React.PropsWithChildren<unknown>>): React.ComponentType<React.PropsWithChildren<CardProps>>;
@@ -4,9 +4,9 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
4
  import type { Decoration, EditorView } from '@atlaskit/editor-prosemirror/view';
5
5
  import type { SmartCardProps } from './genericCard';
6
6
  import { type InlineCardWithAwarenessProps } from './inlineCardWithAwareness';
7
- export declare const InlineCard: React.MemoExoticComponent<({ node, cardContext, actionOptions, useAlternativePreloader, view, getPos, onClick, onResolve: onRes, isHovered, showHoverPreview, hoverPreviewOptions, }: SmartCardProps) => JSX.Element | null>;
7
+ export declare const InlineCard: React.MemoExoticComponent<({ node, cardContext, actionOptions, useAlternativePreloader, view, getPos, onClick, onResolve: onRes, isHovered, showHoverPreview, hoverPreviewOptions, }: SmartCardProps) => React.JSX.Element | null>;
8
8
  export type InlineCardNodeViewProps = Pick<SmartCardProps, 'useAlternativePreloader' | 'actionOptions' | 'allowEmbeds' | 'allowBlockCards' | 'enableInlineUpgradeFeatures' | 'pluginInjectionApi' | 'onClickCallback' | '__livePage'>;
9
- export declare function InlineCardNodeView(props: InlineNodeViewComponentProps & InlineCardNodeViewProps & InlineCardWithAwarenessProps): JSX.Element;
9
+ export declare function InlineCardNodeView(props: InlineNodeViewComponentProps & InlineCardNodeViewProps & InlineCardWithAwarenessProps): React.JSX.Element;
10
10
  export interface InlineCardNodeViewProperties {
11
11
  inlineCardViewProducer: ReturnType<typeof getInlineNodeViewProducer>;
12
12
  }
@@ -5,4 +5,4 @@ export type InlineCardWithAwarenessProps = {
5
5
  isOverlayEnabled?: boolean;
6
6
  isSelected?: boolean;
7
7
  };
8
- export declare const InlineCardWithAwareness: React.MemoExoticComponent<({ node, cardContext, actionOptions, useAlternativePreloader, view, getPos, pluginInjectionApi, onClick, isPulseEnabled, isOverlayEnabled, isSelected, }: SmartCardProps & InlineCardWithAwarenessProps) => JSX.Element>;
8
+ export declare const InlineCardWithAwareness: React.MemoExoticComponent<({ node, cardContext, actionOptions, useAlternativePreloader, view, getPos, pluginInjectionApi, onClick, isPulseEnabled, isOverlayEnabled, isSelected, }: SmartCardProps & InlineCardWithAwarenessProps) => React.JSX.Element>;
@@ -9,7 +9,8 @@ export declare const cardAction: (tr: Transaction, action: CardPluginAction) =>
9
9
  export declare const resolveCard: (url: string) => (tr: Transaction) => Transaction;
10
10
  export declare const queueCards: (requests: Request[]) => (tr: Transaction) => Transaction;
11
11
  export declare const registerCard: (info: CardInfo) => (tr: Transaction) => Transaction;
12
- export declare const registerRemoveOverlay: (callback: () => void) => (tr: Transaction) => Transaction;
12
+ export declare const removeCard: (info: Partial<CardInfo>) => (tr: Transaction) => Transaction;
13
+ export declare const registerRemoveOverlay: (callback: () => void, info?: CardInfo) => (tr: Transaction) => Transaction;
13
14
  export declare const registerSmartCardEvents: (smartLinkEvents: SmartLinkEvents) => (tr: Transaction) => Transaction;
14
15
  export declare const setProvider: (cardProvider: CardProvider | null) => (tr: Transaction) => Transaction;
15
16
  export declare const setDatasourceTableRef: (datasourceTableRef?: HTMLElement) => (tr: Transaction) => Transaction;
@@ -17,6 +17,7 @@ export declare const getPluginStateWithUpdatedPos: (pluginState: CardPluginState
17
17
  pos: number;
18
18
  title?: string | undefined;
19
19
  url?: string | undefined;
20
+ id?: string | undefined;
20
21
  }[];
21
22
  provider: import("@atlaskit/editor-common/provider-factory").CardProvider | null;
22
23
  datasourceStash: {
@@ -17,6 +17,7 @@ export type DatasourceNode = Omit<Node, 'attrs'> & {
17
17
  export type CardInfo = {
18
18
  title?: string;
19
19
  url?: string;
20
+ id?: string;
20
21
  pos: number;
21
22
  };
22
23
  export type Request = {
@@ -123,6 +124,10 @@ export type Register = {
123
124
  type: 'REGISTER';
124
125
  info: CardInfo;
125
126
  };
127
+ export type RemoveCard = {
128
+ type: 'REMOVE_CARD';
129
+ info: Partial<CardInfo>;
130
+ };
126
131
  export type ShowLinkToolbar = {
127
132
  type: 'SHOW_LINK_TOOLBAR';
128
133
  };
@@ -159,6 +164,7 @@ type ClearOverlayCandidate = {
159
164
  type RegisterRemoveOverlayOnInsertedLink = {
160
165
  type: 'REGISTER_REMOVE_OVERLAY_ON_INSERTED_LINK';
161
166
  callback: () => void;
167
+ info?: Register['info'];
162
168
  };
163
169
  export type SetDatasourceStash = {
164
170
  type: 'SET_DATASOURCE_STASH';
@@ -171,5 +177,5 @@ export type RemoveDatasourceStash = {
171
177
  type: 'REMOVE_DATASOURCE_STASH';
172
178
  url: string;
173
179
  };
174
- export type CardPluginAction = SetProvider | Queue | Resolve | Register | ShowLinkToolbar | HideLinkToolbar | ShowDatasourceModal | HideDatasourceModal | RegisterSmartCardEvents | SetDatasourceTableRef | SetCardLayout | SetCardLayoutAndDatasourceTableRef | ClearOverlayCandidate | RegisterRemoveOverlayOnInsertedLink | SetDatasourceStash | RemoveDatasourceStash;
180
+ export type CardPluginAction = SetProvider | Queue | Resolve | Register | RemoveCard | ShowLinkToolbar | HideLinkToolbar | ShowDatasourceModal | HideDatasourceModal | RegisterSmartCardEvents | SetDatasourceTableRef | SetCardLayout | SetCardLayoutAndDatasourceTableRef | ClearOverlayCandidate | RegisterRemoveOverlayOnInsertedLink | SetDatasourceStash | RemoveDatasourceStash;
175
181
  export {};
@@ -1,3 +1,3 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import type { GlyphProps } from '@atlaskit/icon/types';
3
- export declare const DatasourceIcon: (props: GlyphProps) => JSX.Element;
3
+ export declare const DatasourceIcon: (props: GlyphProps) => React.JSX.Element;
@@ -9,7 +9,7 @@ type ModalWithStateProps = {
9
9
  api: ExtractInjectionAPI<typeof cardPlugin> | undefined;
10
10
  editorView: EditorView;
11
11
  };
12
- declare const SafeModalWithState: React.MemoExoticComponent<({ api, editorView }: ModalWithStateProps) => JSX.Element>;
12
+ declare const SafeModalWithState: React.MemoExoticComponent<({ api, editorView }: ModalWithStateProps) => React.JSX.Element>;
13
13
  export type ModalTypeToComponentMap = {
14
14
  componentType: React.ComponentType<ConfigModalProps<InlineCardAdf | DatasourceAdf, DatasourceParameters>>;
15
15
  datasourceId: string;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
3
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
4
  import type { CardContext } from '@atlaskit/link-provider';
@@ -8,5 +8,5 @@ type DatasourceModalProps = {
8
8
  editorAnalyticsApi?: EditorAnalyticsAPI;
9
9
  cardContext?: CardContext;
10
10
  } & ModalTypeToComponentMap;
11
- export declare const DatasourceModal: ({ view, cardContext, datasourceId: defaultDatasourceId, componentType: Component, }: DatasourceModalProps) => JSX.Element | null;
11
+ export declare const DatasourceModal: ({ view, cardContext, datasourceId: defaultDatasourceId, componentType: Component, }: DatasourceModalProps) => React.JSX.Element | null;
12
12
  export {};
@@ -19,12 +19,12 @@ export type EditLinkToolbarProps = {
19
19
  forceFocusSelector: ForceFocusSelector | undefined;
20
20
  lpLinkPicker: boolean;
21
21
  };
22
- export declare function HyperlinkAddToolbarWithState({ linkPickerOptions, onSubmit, displayText, displayUrl, providerFactory, view, onCancel, invokeMethod, lpLinkPicker, onClose, onEscapeCallback, onClickAwayCallback, }: HyperlinkAddToolbarProps): JSX.Element;
22
+ export declare function HyperlinkAddToolbarWithState({ linkPickerOptions, onSubmit, displayText, displayUrl, providerFactory, view, onCancel, invokeMethod, lpLinkPicker, onClose, onEscapeCallback, onClickAwayCallback, }: HyperlinkAddToolbarProps): React.JSX.Element;
23
23
  export declare class EditLinkToolbar extends React.Component<EditLinkToolbarProps> {
24
24
  componentDidUpdate(prevProps: EditLinkToolbarProps): void;
25
25
  componentWillUnmount(): void;
26
26
  private hideLinkToolbar;
27
- render(): JSX.Element;
27
+ render(): React.JSX.Element;
28
28
  }
29
29
  export declare const getEditLinkCallback: (editorAnalyticsApi: EditorAnalyticsAPI | undefined, scrollIntoView: boolean) => Command;
30
30
  export declare const buildEditLinkToolbar: ({ providerFactory, node, pluginInjectionApi, linkPicker, lpLinkPicker, }: {
@@ -7,4 +7,4 @@ export type EditorAnalyticsContextProps = {
7
7
  /**
8
8
  * Provides location attribute to child events
9
9
  */
10
- export declare const EditorAnalyticsContext: ({ editorView, children }: EditorAnalyticsContextProps) => JSX.Element;
10
+ export declare const EditorAnalyticsContext: ({ editorView, children }: EditorAnalyticsContextProps) => React.JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  import type { AnalyticsBindingsProps } from './common';
3
3
  export declare class EditorLinkingPlatformAnalytics extends React.PureComponent<AnalyticsBindingsProps> {
4
- render(): JSX.Element;
4
+ render(): React.JSX.Element;
5
5
  }
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import type { IntlShape } from 'react-intl-next';
3
3
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
4
4
  import type { CardOptions } from '@atlaskit/editor-common/card';
@@ -15,4 +15,4 @@ export interface HyperlinkToolbarAppearanceProps {
15
15
  editorAnalyticsApi: EditorAnalyticsAPI | undefined;
16
16
  editorPluginApi: ExtractInjectionAPI<CardPlugin> | undefined;
17
17
  }
18
- export declare function HyperlinkToolbarAppearance(props: HyperlinkToolbarAppearanceProps): JSX.Element | null;
18
+ export declare function HyperlinkToolbarAppearance(props: HyperlinkToolbarAppearanceProps): React.JSX.Element | null;
@@ -18,6 +18,6 @@ export interface LinkToolbarAppearanceProps {
18
18
  isDatasourceView?: boolean;
19
19
  }
20
20
  export declare class LinkToolbarAppearance extends React.Component<LinkToolbarAppearanceProps, Object> {
21
- renderDropdown: (view?: EditorView, cardContext?: CardContext) => JSX.Element | null;
22
- render(): JSX.Element;
21
+ renderDropdown: (view?: EditorView, cardContext?: CardContext) => React.JSX.Element | null;
22
+ render(): React.JSX.Element;
23
23
  }
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  export type PulseDiscoveryMode = 'start' | 'iteration';
3
3
  export interface PulseProps {
4
4
  /**
@@ -21,4 +21,4 @@ export interface PulseProps {
21
21
  shouldShowPulse?: boolean;
22
22
  testId?: string;
23
23
  }
24
- export declare const DiscoveryPulse: ({ children, localStorageKey, localStorageKeyExpirationInMs, discoveryMode, shouldShowPulse, testId, }: PulseProps) => JSX.Element;
24
+ export declare const DiscoveryPulse: ({ children, localStorageKey, localStorageKeyExpirationInMs, discoveryMode, shouldShowPulse, testId, }: PulseProps) => React.JSX.Element;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import type { EditorAnalyticsContextProps } from './EditorAnalyticsContext';
3
3
  type ToolbarViewedEventProps = {
4
4
  url?: string;
@@ -7,5 +7,5 @@ type ToolbarViewedEventProps = {
7
7
  /**
8
8
  * Provides analytics context and card context
9
9
  */
10
- export declare const ToolbarViewedEvent: ({ url, display, editorView, }: ToolbarViewedEventProps & Omit<EditorAnalyticsContextProps, 'children'>) => JSX.Element;
10
+ export declare const ToolbarViewedEvent: ({ url, display, editorView, }: ToolbarViewedEventProps & Omit<EditorAnalyticsContextProps, 'children'>) => React.JSX.Element;
11
11
  export {};
@@ -2,4 +2,4 @@ import React from 'react';
2
2
  import { useSmartCardContext } from '@atlaskit/link-provider';
3
3
  export declare const WithCardContext: ({ children, }: {
4
4
  children: (cardContext: ReturnType<typeof useSmartCardContext>) => React.ReactNode;
5
- }) => JSX.Element;
5
+ }) => React.JSX.Element;
@@ -20,5 +20,5 @@ export declare class DatasourceErrorBoundary extends React.Component<DatasourceE
20
20
  error: Error | APIError;
21
21
  };
22
22
  componentDidCatch(error: Error | APIError): void;
23
- render(): string | number | boolean | JSX.Element | React.ReactFragment | null | undefined;
23
+ render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
24
24
  }
@@ -5,28 +5,34 @@ import type { Node } from '@atlaskit/editor-prosemirror/model';
5
5
  import type { Decoration, DecorationSource, EditorView } from '@atlaskit/editor-prosemirror/view';
6
6
  import { Datasource } from '../nodeviews/datasource';
7
7
  import type { SmartCardProps } from './genericCard';
8
- export declare class BlockCardComponent extends React.PureComponent<SmartCardProps> {
8
+ export declare class BlockCardComponent extends React.PureComponent<SmartCardProps & {
9
+ id?: string;
10
+ }> {
9
11
  private scrollContainer?;
10
- constructor(props: SmartCardProps);
12
+ constructor(props: SmartCardProps & {
13
+ id?: string;
14
+ });
11
15
  onResolve: (data: {
12
16
  url?: string | undefined;
13
17
  title?: string | undefined;
14
18
  }) => void;
15
- gapCursorSpan: () => JSX.Element | undefined;
19
+ gapCursorSpan: () => React.JSX.Element | undefined;
16
20
  onError: ({ err }: {
17
21
  err?: Error | undefined;
18
22
  }) => void;
19
- render(): JSX.Element;
23
+ render(): React.JSX.Element;
20
24
  }
21
25
  export type BlockCardNodeViewProps = Pick<SmartCardProps, 'actionOptions' | 'pluginInjectionApi' | 'onClickCallback'>;
22
26
  export declare class BlockCard extends ReactNodeView<BlockCardNodeViewProps> {
27
+ private id;
23
28
  unsubscribe: (() => void) | undefined;
24
29
  createDomRef(): HTMLElement;
25
30
  private updateContentEditable;
26
31
  validUpdate(currentNode: Node, newNode: Node): boolean;
27
32
  update(node: Node, decorations: ReadonlyArray<Decoration>, _innerDecorations?: DecorationSource): boolean;
28
- render(): JSX.Element;
33
+ render(): React.JSX.Element;
29
34
  destroy(): void;
35
+ private removeCard;
30
36
  }
31
37
  export interface BlockCardNodeViewProperties {
32
38
  pmPluginFactoryParams: PMPluginFactoryParams;
@@ -11,10 +11,14 @@ export type EmbedCardState = {
11
11
  liveHeight?: number;
12
12
  initialAspectRatio?: number;
13
13
  };
14
- export declare class EmbedCardComponent extends React.PureComponent<SmartCardProps, EmbedCardState> {
14
+ export declare class EmbedCardComponent extends React.PureComponent<SmartCardProps & {
15
+ id?: string;
16
+ }, EmbedCardState> {
15
17
  private scrollContainer?;
16
18
  private embedIframeRef;
17
- constructor(props: SmartCardProps);
19
+ constructor(props: SmartCardProps & {
20
+ id?: string;
21
+ });
18
22
  state: EmbedCardState;
19
23
  private getPosSafely;
20
24
  onResolve: (data: {
@@ -34,16 +38,18 @@ export declare class EmbedCardComponent extends React.PureComponent<SmartCardPro
34
38
  onError: ({ err }: {
35
39
  err?: Error | undefined;
36
40
  }) => void;
37
- render(): JSX.Element;
41
+ render(): React.JSX.Element;
38
42
  }
39
43
  export type EmbedCardNodeViewProps = Pick<SmartCardProps, 'eventDispatcher' | 'allowResizing' | 'fullWidthMode' | 'dispatchAnalyticsEvent' | 'pluginInjectionApi' | 'actionOptions' | 'onClickCallback'>;
40
44
  export declare class EmbedCard extends ReactNodeView<EmbedCardNodeViewProps> {
45
+ private id;
41
46
  unsubscribe: (() => void) | undefined;
42
47
  viewShouldUpdate(nextNode: PMNode): boolean;
43
48
  createDomRef(): HTMLElement;
44
49
  private updateContentEditable;
45
- render(): JSX.Element;
50
+ render(): React.JSX.Element;
46
51
  destroy(): void;
52
+ private removeCard;
47
53
  }
48
54
  export interface EmbedCardNodeViewProperties {
49
55
  allowResizing: EmbedCardNodeViewProps['allowResizing'];
@@ -46,4 +46,6 @@ export interface SmartCardProps extends CardProps {
46
46
  allowBlockCards?: boolean;
47
47
  enableInlineUpgradeFeatures?: boolean;
48
48
  }
49
- export declare function Card(SmartCardComponent: React.ComponentType<React.PropsWithChildren<SmartCardProps>>, UnsupportedComponent: React.ComponentType<React.PropsWithChildren<unknown>>): React.ComponentType<React.PropsWithChildren<CardProps>>;
49
+ export declare function Card(SmartCardComponent: React.ComponentType<React.PropsWithChildren<SmartCardProps & {
50
+ id?: string;
51
+ }>>, UnsupportedComponent: React.ComponentType<React.PropsWithChildren<unknown>>): React.ComponentType<React.PropsWithChildren<CardProps>>;
@@ -4,9 +4,9 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
4
  import type { Decoration, EditorView } from '@atlaskit/editor-prosemirror/view';
5
5
  import type { SmartCardProps } from './genericCard';
6
6
  import { type InlineCardWithAwarenessProps } from './inlineCardWithAwareness';
7
- export declare const InlineCard: React.MemoExoticComponent<({ node, cardContext, actionOptions, useAlternativePreloader, view, getPos, onClick, onResolve: onRes, isHovered, showHoverPreview, hoverPreviewOptions, }: SmartCardProps) => JSX.Element | null>;
7
+ export declare const InlineCard: React.MemoExoticComponent<({ node, cardContext, actionOptions, useAlternativePreloader, view, getPos, onClick, onResolve: onRes, isHovered, showHoverPreview, hoverPreviewOptions, }: SmartCardProps) => React.JSX.Element | null>;
8
8
  export type InlineCardNodeViewProps = Pick<SmartCardProps, 'useAlternativePreloader' | 'actionOptions' | 'allowEmbeds' | 'allowBlockCards' | 'enableInlineUpgradeFeatures' | 'pluginInjectionApi' | 'onClickCallback' | '__livePage'>;
9
- export declare function InlineCardNodeView(props: InlineNodeViewComponentProps & InlineCardNodeViewProps & InlineCardWithAwarenessProps): JSX.Element;
9
+ export declare function InlineCardNodeView(props: InlineNodeViewComponentProps & InlineCardNodeViewProps & InlineCardWithAwarenessProps): React.JSX.Element;
10
10
  export interface InlineCardNodeViewProperties {
11
11
  inlineCardViewProducer: ReturnType<typeof getInlineNodeViewProducer>;
12
12
  }
@@ -5,4 +5,4 @@ export type InlineCardWithAwarenessProps = {
5
5
  isOverlayEnabled?: boolean;
6
6
  isSelected?: boolean;
7
7
  };
8
- export declare const InlineCardWithAwareness: React.MemoExoticComponent<({ node, cardContext, actionOptions, useAlternativePreloader, view, getPos, pluginInjectionApi, onClick, isPulseEnabled, isOverlayEnabled, isSelected, }: SmartCardProps & InlineCardWithAwarenessProps) => JSX.Element>;
8
+ export declare const InlineCardWithAwareness: React.MemoExoticComponent<({ node, cardContext, actionOptions, useAlternativePreloader, view, getPos, pluginInjectionApi, onClick, isPulseEnabled, isOverlayEnabled, isSelected, }: SmartCardProps & InlineCardWithAwarenessProps) => React.JSX.Element>;
@@ -9,7 +9,8 @@ export declare const cardAction: (tr: Transaction, action: CardPluginAction) =>
9
9
  export declare const resolveCard: (url: string) => (tr: Transaction) => Transaction;
10
10
  export declare const queueCards: (requests: Request[]) => (tr: Transaction) => Transaction;
11
11
  export declare const registerCard: (info: CardInfo) => (tr: Transaction) => Transaction;
12
- export declare const registerRemoveOverlay: (callback: () => void) => (tr: Transaction) => Transaction;
12
+ export declare const removeCard: (info: Partial<CardInfo>) => (tr: Transaction) => Transaction;
13
+ export declare const registerRemoveOverlay: (callback: () => void, info?: CardInfo) => (tr: Transaction) => Transaction;
13
14
  export declare const registerSmartCardEvents: (smartLinkEvents: SmartLinkEvents) => (tr: Transaction) => Transaction;
14
15
  export declare const setProvider: (cardProvider: CardProvider | null) => (tr: Transaction) => Transaction;
15
16
  export declare const setDatasourceTableRef: (datasourceTableRef?: HTMLElement) => (tr: Transaction) => Transaction;
@@ -17,6 +17,7 @@ export declare const getPluginStateWithUpdatedPos: (pluginState: CardPluginState
17
17
  pos: number;
18
18
  title?: string | undefined;
19
19
  url?: string | undefined;
20
+ id?: string | undefined;
20
21
  }[];
21
22
  provider: import("@atlaskit/editor-common/provider-factory").CardProvider | null;
22
23
  datasourceStash: {
@@ -17,6 +17,7 @@ export type DatasourceNode = Omit<Node, 'attrs'> & {
17
17
  export type CardInfo = {
18
18
  title?: string;
19
19
  url?: string;
20
+ id?: string;
20
21
  pos: number;
21
22
  };
22
23
  export type Request = {
@@ -123,6 +124,10 @@ export type Register = {
123
124
  type: 'REGISTER';
124
125
  info: CardInfo;
125
126
  };
127
+ export type RemoveCard = {
128
+ type: 'REMOVE_CARD';
129
+ info: Partial<CardInfo>;
130
+ };
126
131
  export type ShowLinkToolbar = {
127
132
  type: 'SHOW_LINK_TOOLBAR';
128
133
  };
@@ -159,6 +164,7 @@ type ClearOverlayCandidate = {
159
164
  type RegisterRemoveOverlayOnInsertedLink = {
160
165
  type: 'REGISTER_REMOVE_OVERLAY_ON_INSERTED_LINK';
161
166
  callback: () => void;
167
+ info?: Register['info'];
162
168
  };
163
169
  export type SetDatasourceStash = {
164
170
  type: 'SET_DATASOURCE_STASH';
@@ -171,5 +177,5 @@ export type RemoveDatasourceStash = {
171
177
  type: 'REMOVE_DATASOURCE_STASH';
172
178
  url: string;
173
179
  };
174
- export type CardPluginAction = SetProvider | Queue | Resolve | Register | ShowLinkToolbar | HideLinkToolbar | ShowDatasourceModal | HideDatasourceModal | RegisterSmartCardEvents | SetDatasourceTableRef | SetCardLayout | SetCardLayoutAndDatasourceTableRef | ClearOverlayCandidate | RegisterRemoveOverlayOnInsertedLink | SetDatasourceStash | RemoveDatasourceStash;
180
+ export type CardPluginAction = SetProvider | Queue | Resolve | Register | RemoveCard | ShowLinkToolbar | HideLinkToolbar | ShowDatasourceModal | HideDatasourceModal | RegisterSmartCardEvents | SetDatasourceTableRef | SetCardLayout | SetCardLayoutAndDatasourceTableRef | ClearOverlayCandidate | RegisterRemoveOverlayOnInsertedLink | SetDatasourceStash | RemoveDatasourceStash;
175
181
  export {};
@@ -1,3 +1,3 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import type { GlyphProps } from '@atlaskit/icon/types';
3
- export declare const DatasourceIcon: (props: GlyphProps) => JSX.Element;
3
+ export declare const DatasourceIcon: (props: GlyphProps) => React.JSX.Element;
@@ -9,7 +9,7 @@ type ModalWithStateProps = {
9
9
  api: ExtractInjectionAPI<typeof cardPlugin> | undefined;
10
10
  editorView: EditorView;
11
11
  };
12
- declare const SafeModalWithState: React.MemoExoticComponent<({ api, editorView }: ModalWithStateProps) => JSX.Element>;
12
+ declare const SafeModalWithState: React.MemoExoticComponent<({ api, editorView }: ModalWithStateProps) => React.JSX.Element>;
13
13
  export type ModalTypeToComponentMap = {
14
14
  componentType: React.ComponentType<ConfigModalProps<InlineCardAdf | DatasourceAdf, DatasourceParameters>>;
15
15
  datasourceId: string;