/** * Framework-neutral classification of rich-text element attributes. * * The CMS emits HTML-ish attributes on rich-text nodes, some of which are really * CSS declarations. Deciding which is which does not depend on the framework; * only the shape they are finally written in does, so each binding maps the * result onto its own prop names. * * @module */ import { type ImageElement, type LinkElement, type RenderNode, type RichTextPropsBase } from '../../components/richText/renderer.js'; /** Whether an attribute is a boolean one, by its HTML name in any casing. */ export declare const isBooleanAttribute: (name: string) => boolean; /** A boolean attribute is true when present, whatever its value — except the literal "false". */ export declare const isAttributeSet: (value: unknown) => boolean; export type SplitAttributes = { /** HTML attributes, under the names the CMS gave them. */ attributes: Record; /** CSS declarations, camelCased, including any parsed from a `style` string. */ style: Record; }; /** * Separates a rich-text node's attributes into HTML attributes and CSS * declarations. `border`, `width` and `height` stay attributes on * `table`/`img`/`input`/`canvas` and become styles everywhere else. */ export declare function splitAttributes(attributes: Record, elementType?: string): SplitAttributes; /** The attributes a link element contributes, on top of its generic ones. */ export declare const getLinkAttributes: (element: LinkElement) => { href: string; target: "_self" | "_blank" | "_parent" | "_top" | undefined; rel: string | undefined; title: string | undefined; }; /** The attributes an image element contributes, with the preview token applied. */ export declare function getImageAttributes(element: ImageElement): { src: string; alt: string | undefined; title: string | undefined; width: string | number | undefined; height: string | number | undefined; loading: "lazy" | "eager" | undefined; }; /** The render tree for rich-text content, given as the document object or its JSON string. */ export declare const getRichTextTree: (content: RichTextPropsBase["content"], { decodeHtmlEntities }?: { decodeHtmlEntities?: boolean; }) => RenderNode[]; export type RichTextElement = SplitAttributes & { tag: string; /** Rendered without children, like `img` or `br`. */ selfClosing: boolean; }; /** The tag, attributes and styles for a rich-text element node, with the image preview token applied. */ export declare function getRichTextElement(node: RenderNode): RichTextElement; /** The tag for a rich-text mark such as `bold`, or `span` when it is unknown. */ export declare const getMarkTag: (mark: string) => string; /** Writes a camelCased style object as a CSS declaration string, or `undefined` when empty. */ export declare const toStyleString: (style: Record) => string | undefined;