@atlaskit/editor-plugin-card
Version:
Card plugin for @atlaskit/editor-core
44 lines (43 loc) • 2.18 kB
TypeScript
import { type EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
/**
* A native embed is an `extension` node that `editor-plugin-native-embeds` builds from
* embedCard ADF (via the `embedCardNodeTransformer` registered on the card plugin).
* A 1P link that resolves to an embed appearance — a whiteboard, page, slide or
* database — therefore lands in the document as one of these rather than as an
* `embedCard`, so card node types alone are not enough to describe what was pasted.
*
* `editor-plugin-native-embeds` owns the equivalent predicate, but the card plugin
* cannot depend on it: that would close the cycle
* editor-plugin-card -> editor-plugin-native-embeds -> editor-plugin-card.
*/
export declare const isNativeEmbedNode: (node: PMNode | null | undefined) => boolean;
/**
* Reads the embedded URL from a native embed node. The URL is stored in
* `parameters.macroParams`, where values may be wrapped (`{ value }`) or bare, and is
* mirrored in `parameters.macroMetadata` so it survives a revert to a card.
*/
export declare const getNativeEmbedUrl: (node: PMNode) => string | undefined;
/**
* Whether a native embed at `pos` can be replaced by the given appearance. `url` and
* `inline` both become a paragraph, `block` becomes a blockCard.
*/
export declare const isNativeEmbedAppearanceSupported: ({ editorView, pos, appearance, }: {
appearance: 'url' | 'inline' | 'block';
editorView: EditorView;
pos: number;
}) => boolean;
/**
* Replaces a native embed with a link, an inline card or a block card. Mirrors
* `setNativeEmbedAppearance` in `editor-plugin-native-embeds`, which cannot be reused
* here because of the package cycle described on `isNativeEmbedNode`.
*/
export declare const changeNativeEmbedAppearance: ({ editorView, pos, node, appearance, url, editorAnalyticsApi, }: {
appearance: 'url' | 'inline' | 'block';
editorAnalyticsApi?: EditorAnalyticsAPI;
editorView: EditorView;
node: PMNode;
pos: number;
url: string;
}) => boolean;