@atlaskit/editor-plugin-card
Version:
Card plugin for @atlaskit/editor-core
65 lines (64 loc) • 2.87 kB
TypeScript
import type { EventHandler, KeyboardEvent, MouseEvent } from 'react';
import React from 'react';
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
import type { OnClickCallback } from '@atlaskit/editor-common/card';
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
import type { ProviderFactory, Providers } from '@atlaskit/editor-common/provider-factory';
import type { ReactComponentProps, getPosHandler } from '@atlaskit/editor-common/react-node-view';
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
import type { CardContext } from '@atlaskit/link-provider';
import type { CardProps as BaseCardProps } from '@atlaskit/smart-card';
import type { cardPlugin } from '../index';
export type EditorContext<T> = React.Context<T> & {
value: T;
};
export interface CardNodeViewProps extends ReactComponentProps {
eventDispatcher?: EventDispatcher;
providerFactory?: ProviderFactory;
}
export interface CardProps extends CardNodeViewProps {
__livePage?: boolean;
actionOptions?: BaseCardProps['actionOptions'];
allowResizing?: boolean;
children?: React.ReactNode;
dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
eventDispatcher?: EventDispatcher;
fullWidthMode?: boolean;
getPos: getPosHandler;
hoverPreviewOptions?: BaseCardProps['hoverPreviewOptions'];
node: PMNode;
onClickCallback?: OnClickCallback;
pluginInjectionApi?: ExtractInjectionAPI<typeof cardPlugin>;
showHoverPreview?: BaseCardProps['showHoverPreview'];
useAlternativePreloader?: boolean;
view: EditorView;
}
export interface SmartCardProps extends CardProps {
allowBlockCards?: boolean;
allowEmbeds?: boolean;
cardContext?: EditorContext<CardContext | undefined>;
CompetitorPrompt?: React.ComponentType<{
linkType?: string;
sourceUrl: string;
}>;
disablePreviewPanel?: BaseCardProps['disablePreviewPanel'];
enableInlineUpgradeFeatures?: boolean;
isHovered?: boolean;
isPageSSRed?: boolean;
onClick?: EventHandler<MouseEvent | KeyboardEvent> | undefined;
onResolve?: (tr: Transaction, title?: string) => void;
pluginInjectionApi?: ExtractInjectionAPI<typeof cardPlugin>;
provider?: Providers['cardProvider'];
}
/**
*
* @param SmartCardComponent
* @param UnsupportedComponent
* @example
*/
export declare function Card(SmartCardComponent: React.ComponentType<React.PropsWithChildren<SmartCardProps & {
id?: string;
}>>, UnsupportedComponent: React.ComponentType<React.PropsWithChildren<unknown>>): React.ComponentType<React.PropsWithChildren<CardProps>>;