UNPKG

@mkljczk/lexical-remark

Version:

This package contains Markdown helpers and functionality for Lexical using remark-parse.

74 lines (73 loc) 2.1 kB
/// <reference types="react" /> import type { DOMConversionMap, DOMExportOutput, EditorConfig, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical'; import { DecoratorNode } from 'lexical'; export interface ImagePayload { /** * The alt text of the image, for screen readers */ altText: string; /** * The height of the image, in pixels */ height?: number; /** * The key id of the node */ key?: NodeKey; /** * The image source url */ src: string; /** * The width of the image, in pixels */ width?: number; } export type SerializedImageNode = Spread<{ altText: string; height?: number; src: string; type: 'image'; version: 1; width?: number; }, SerializedLexicalNode>; /** * A Lexical node to represent an image */ export declare class ImageNode extends DecoratorNode<JSX.Element> { __src: string; __altText: string; __width: 'inherit' | number; __height: 'inherit' | number; static getType(): string; static clone(node: ImageNode): ImageNode; static importJSON(serializedNode: SerializedImageNode): ImageNode; static importDOM(): DOMConversionMap | null; exportDOM(): DOMExportOutput; constructor(src: string, altText: string, width?: 'inherit' | number, height?: 'inherit' | number, key?: NodeKey); exportJSON(): SerializedImageNode; createDOM(config: EditorConfig): HTMLElement; updateDOM(): false; /** * Returns the image source url */ getSrc(): string; /** * Returns the alt text of the image */ getAltText(): string; decorate(): JSX.Element; } /** * Creates an Image node from image props * * @returns An Image node */ export declare function $createImageNode({ altText, height, key, src, width }: ImagePayload): ImageNode; /** * A typeguard function to assert on an Image node * * @param node A Lexical node * @returns true if the node is an Image node, otherwise false */ export declare function $isImageNode(node: LexicalNode | null | undefined): node is ImageNode;