@atlaskit/editor-plugin-card
Version:
Card plugin for @atlaskit/editor-core
49 lines (48 loc) • 3.03 kB
TypeScript
import type { CardAppearance } from '@atlaskit/editor-common/provider-factory';
import type { getPosHandler } from '@atlaskit/editor-common/react-node-view';
import type { Node, NodeType } from '@atlaskit/editor-prosemirror/model';
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
import type { CardContext } from '@atlaskit/link-provider';
import type { CardInfo, DatasourceNode, ToolbarResolvedAttributes } from '../types';
export declare const appearanceForNodeType: (spec: NodeType) => CardAppearance | undefined;
export declare const selectedCardAppearance: (state: EditorState) => CardAppearance | undefined;
export type TitleUrlPair = {
title?: string;
url?: string;
};
export declare const titleUrlPairFromNode: (node: Node) => TitleUrlPair;
/**
* Merges the title and url from attributes and CardInfo from the resolved view, preferring the CardInfo.
* @param titleUrlPair title and url information from the node attributes
* @param info information stored in state from the resolved UI component view
*/
export declare const mergeCardInfo: (titleUrlPair: TitleUrlPair, info?: CardInfo) => TitleUrlPair;
export declare const displayInfoForCard: (node: Node, info?: CardInfo) => TitleUrlPair;
export declare const findCardInfo: (state: EditorState) => CardInfo | undefined;
export declare const isEmbedSupportedAtPosition: (currentNodePosition: number, editorState: EditorState, currentAppearance?: CardAppearance) => boolean;
export declare const isBlockSupportedAtPosition: (currentNodePosition: number, editorState: EditorState, currentAppearance?: CardAppearance) => boolean;
export declare const getResolvedAttributesFromStore: (url: string, display: string | null, store?: CardContext["store"]) => Partial<ToolbarResolvedAttributes>;
export declare const isDatasourceConfigEditable: (datasourceId: string) => boolean;
/**
* Typeguard that checks node attributes are datasource node attributes
* ** WARNING ** Typeguards are not a guarantee, if the asserted type changes
* this function will not be updated automatically
*/
export declare const isDatasourceAdfAttributes: (attrs: Record<string, unknown> | undefined) => attrs is DatasourceNode["attrs"];
/**
* Typeguard that checks a node is a datasource node (blockCard and has datasource attributes)
* ** WARNING ** Typeguards are not a guarantee, if the asserted type changes
* this function will not be updated automatically
*/
export declare const isDatasourceNode: (node?: Node) => node is DatasourceNode;
/**
* Focuses the editorView if it's not already focused.
* @param editorView The editor view to focus.
*/
export declare const focusEditorView: (editorView: EditorView) => void;
export declare const getAwarenessProps: (editorState: EditorState, getPos: getPosHandler, allowEmbeds?: boolean, allowBlockCards?: boolean, disableOverlay?: boolean) => {
isOverlayEnabled: boolean;
isPulseEnabled: boolean;
isSelected: boolean;
};