@atlaskit/editor-plugin-card
Version:
Card plugin for @atlaskit/editor-core
51 lines (50 loc) • 4.26 kB
TypeScript
import type { CreateUIAnalyticsEvent, UIAnalyticsEvent } from '@atlaskit/analytics-next';
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
import { ACTION } from '@atlaskit/editor-common/analytics';
import type { CardReplacementInputMethod, EmbedCardNodeTransformer } from '@atlaskit/editor-common/card';
import type { CardAppearance } from '@atlaskit/editor-common/provider-factory';
import type { Command } from '@atlaskit/editor-common/types';
import type { Attrs, Node, NodeType } from '@atlaskit/editor-prosemirror/model';
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
import type { CardAdf, DatasourceAdf, InlineCardAdf } from '@atlaskit/linking-common';
import type { Request } from '../types';
export declare const replaceQueuedUrlWithCard: (url: string, cardData: CardAdf | DatasourceAdf, analyticsAction?: ACTION, editorAnalyticsApi?: EditorAnalyticsAPI, createAnalyticsEvent?: CreateUIAnalyticsEvent, embedCardNodeTransformer?: EmbedCardNodeTransformer) => Command;
export declare const handleFallbackWithAnalytics: (request: Request, editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
export declare const queueCardsFromChangedTr: (state: EditorState, tr: Transaction, source: CardReplacementInputMethod, analyticsAction?: ACTION, normalizeLinkText?: boolean, sourceEvent?: UIAnalyticsEvent | null | undefined, appearance?: CardAppearance) => Transaction;
/**
* Queue link-mark → smart-link resolution for text nodes within an explicit
* document range, rather than the entire step range of the transaction.
*
* Use this instead of `queueCardsFromChangedTr` when you know the exact range
* that was inserted/modified and want to avoid accidentally queuing pre-existing
* links that happen to fall within the broader step range.
*/
export declare const queueCardsFromRange: (state: EditorState, tr: Transaction, from: number, to: number, source: CardReplacementInputMethod, analyticsAction?: ACTION, normalizeLinkText?: boolean, sourceEvent?: UIAnalyticsEvent | null | undefined, appearance?: CardAppearance) => Transaction;
export declare const queueCardFromChangedTr: (state: EditorState, tr: Transaction, source: CardReplacementInputMethod, analyticsAction: ACTION, normalizeLinkText?: boolean, sourceEvent?: UIAnalyticsEvent | null | undefined, previousAppearance?: CardAppearance | 'url') => Transaction;
export declare const convertHyperlinkToSmartCard: (state: EditorState, source: CardReplacementInputMethod, appearance: CardAppearance, normalizeLinkText?: boolean) => Transaction;
export declare const changeSelectedCardToLink: (text?: string, href?: string, sendAnalytics?: boolean, node?: Node, pos?: number, editorAnalyticsApi?: EditorAnalyticsAPI) => Command;
export declare const changeSelectedCardToLinkFallback: (text?: string, href?: string, sendAnalytics?: boolean, node?: Node, pos?: number, editorAnalyticsApi?: EditorAnalyticsAPI) => Command;
export declare const updateCard: (href: string, sourceEvent?: UIAnalyticsEvent | null | undefined) => Command;
export declare const changeSelectedCardToText: (text: string, editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
export declare const setSelectedCardAppearance: (appearance: CardAppearance, editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
export type LinkNodes = {
[key in 'inlineCard' | 'blockCard' | 'embedCard']: NodeType;
};
export declare const getLinkNodeType: (appearance: CardAppearance, linkNodes: LinkNodes) => NodeType;
type UpdateCardArgs = {
inputMethod?: string;
isDeletingConfig?: boolean;
newAdf: DatasourceAdf | InlineCardAdf;
node: Node;
sourceEvent?: UIAnalyticsEvent;
state: EditorState;
view: EditorView;
};
export declare const updateCardViaDatasource: (args: UpdateCardArgs) => void;
export declare const insertDatasource: (state: EditorState, adf: DatasourceAdf | InlineCardAdf, view: EditorView, sourceEvent?: UIAnalyticsEvent) => void;
/**
* Get attributes for new Card Appearance
*/
export declare const getAttrsForAppearance: (appearance: CardAppearance, selectedNode: Node, isInsideBodiedSyncBlock?: boolean) => Attrs;
export {};