UNPKG

@atlaskit/editor-plugin-card

Version:

Card plugin for @atlaskit/editor-core

67 lines (66 loc) • 3.15 kB
import type { EventHandler, KeyboardEvent, MouseEvent } from 'react'; import React from 'react'; import type { IntlShape } from 'react-intl'; import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics/types/dispatch-analytics-event'; import type { OnClickCallback } from '@atlaskit/editor-common/card/cardOptions'; import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher'; import type ProviderFactory from '@atlaskit/editor-common/provider-factory/provider-factory'; import type { Providers } from '@atlaskit/editor-common/provider-factory/types'; import type { ReactComponentProps, getPosHandler } from '@atlaskit/editor-common/react-node-view/types'; import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types/next-editor-plugin'; 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/types'; import type { CardProps as BaseCardProps } from '@atlaskit/smart-card/card/types'; 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; intl?: IntlShape; isHovered?: boolean; isPageSSRed?: boolean; onClick?: EventHandler<MouseEvent | KeyboardEvent> | undefined; onResolve?: (tr: Transaction | undefined, title?: string) => void; pluginInjectionApi?: ExtractInjectionAPI<typeof cardPlugin>; provider?: Providers['cardProvider']; smartCardContext?: CardContext; } /** * * @param SmartCardComponent * @param UnsupportedComponent * @example */ export declare function Card<Props extends SmartCardProps>(SmartCardComponent: React.ComponentType<React.PropsWithChildren<Props>>, UnsupportedComponent: React.ComponentType<React.PropsWithChildren<unknown>>): React.ComponentType<React.PropsWithChildren<Props>>;