@contentful/rich-text-types
Version:
Type definitions and constants for the Contentful rich text field type.
26 lines (25 loc) • 997 B
TypeScript
import { Block, Inline, Node, Text, Document as CDocument } from './types.js';
/**
* Checks if the node is an instance of Inline.
*/
export declare function isInline(node: Node): node is Inline;
/**
* Checks if the node is an instance of Block.
*/
export declare function isBlock(node: Node): node is Block;
/**
* Checks if the node is an instance of Text.
*/
export declare function isText(node: Node): node is Text;
/**
* Checks if a paragraph is empty (has only one child and that child is an empty string text node)
*/
export declare function isEmptyParagraph(node: Block): boolean;
/**
* Strips empty trailing paragraph from a document if enabled
* @param document - The rich text document to process
* @returns A new document with the empty trailing paragraph removed (if conditions are met)
* @example
* const processedDoc = stripEmptyTrailingParagraphFromDocument(document);
*/
export declare function stripEmptyTrailingParagraphFromDocument(document: CDocument): CDocument;