UNPKG

@atlaskit/editor-plugin-card

Version:

Card plugin for @atlaskit/editor-core

61 lines (60 loc) 2.98 kB
import React from 'react'; import ReactNodeView from '@atlaskit/editor-common/react-node-view'; import type { getInlineNodeViewProducer } from '@atlaskit/editor-common/react-node-view'; import type { PMPluginFactoryParams } from '@atlaskit/editor-common/types'; import type { Node } from '@atlaskit/editor-prosemirror/model'; import type { Decoration, DecorationSource, EditorView, NodeView } from '@atlaskit/editor-prosemirror/view'; import { Datasource } from '../nodeviews/datasource'; import type { SmartCardProps } from './genericCard'; export declare class BlockCardComponent extends React.PureComponent<SmartCardProps & { id?: string; }, unknown> { private scrollContainer?; constructor(props: SmartCardProps & { id?: string; }); onResolve: (data: { title?: string; url?: string; }) => void; componentWillUnmount(): void; private removeCardDispatched; private removeCard; gapCursorSpan: () => React.JSX.Element | undefined; onError: ({ err }: { err?: Error; }) => void; render(): React.JSX.Element; } export type BlockCardNodeViewProps = Pick<SmartCardProps, 'actionOptions' | 'pluginInjectionApi' | 'onClickCallback' | 'isPageSSRed' | 'provider' | 'CompetitorPrompt'>; export declare class BlockCard extends ReactNodeView<BlockCardNodeViewProps> { private id; unsubscribe: (() => void) | undefined; createDomRef(): HTMLElement; private updateContentEditable; validUpdate(currentNode: Node, newNode: Node): boolean; update(node: Node, decorations: ReadonlyArray<Decoration>, _innerDecorations?: DecorationSource): boolean; render(): React.JSX.Element; /** * Prevent ProseMirror from handling drag events on the smart-element-link, * allowing native drag to work so SmartLinkDraggable can intercept it. * @see {@link https://prosemirror.net/docs/ref/#view.NodeView.stopEvent} */ stopEvent(event: Event): boolean; destroy(): void; } export interface BlockCardNodeViewProperties { actionOptions: BlockCardNodeViewProps['actionOptions']; allowDatasource: boolean | undefined; CompetitorPrompt?: React.ComponentType<{ linkType?: string; sourceUrl: string; }>; inlineCardViewProducer: ReturnType<typeof getInlineNodeViewProducer>; isPageSSRed: BlockCardNodeViewProps['isPageSSRed']; onClickCallback: BlockCardNodeViewProps['onClickCallback']; pluginInjectionApi: BlockCardNodeViewProps['pluginInjectionApi']; pmPluginFactoryParams: PMPluginFactoryParams; provider: BlockCardNodeViewProps['provider']; } export declare const blockCardNodeView: ({ pmPluginFactoryParams, actionOptions, pluginInjectionApi, onClickCallback, allowDatasource, inlineCardViewProducer, CompetitorPrompt, isPageSSRed, provider, }: BlockCardNodeViewProperties) => (node: Node, view: EditorView, getPos: () => number | undefined, decorations: readonly Decoration[]) => BlockCard | Datasource | NodeView;