import { a as BlockDescriptor, b as TNode, D as Delta } from '../../ast-types-U4BC1m-E.js'; import { B as BaseRenderer } from '../../base-renderer-CKK0r7zD.js'; import { ParseQuillDeltaOptions } from '../../index.js'; import '../../block-merger-D5SME1EO.js'; /** * HTML-specific collected attributes. * * Used by both the inline attributor system (marks that contribute * styles/classes to the parent element) and block attribute resolvers * (centralized block attribute computation) in HTML renderers. */ interface ResolvedAttrs { /** CSS style properties, e.g. `{ color: 'red', 'background-color': '#ff0' }` */ style?: Record; /** CSS class names to add */ classes?: string[]; /** Arbitrary HTML attributes, e.g. `{ id: 'my-block', 'data-custom': '1' }` */ attrs?: Record; } /** * An empty `ResolvedAttrs` constant — avoids allocating a new object * every time a resolver has nothing to contribute. */ declare const EMPTY_RESOLVED_ATTRS: ResolvedAttrs; /** * Merge two `ResolvedAttrs` objects. Styles and attrs are shallow-merged * (source overwrites target on key conflict). Classes are concatenated. * * Returns a new object — inputs are not mutated. */ declare function mergeResolvedAttrs(target: ResolvedAttrs, source: ResolvedAttrs): ResolvedAttrs; /** * Check whether a `ResolvedAttrs` object has any content. */ declare function hasResolvedAttrs(resolved: ResolvedAttrs): boolean; /** * Escape HTML special characters to prevent XSS. * Uses a single-pass regex replacement for performance. */ declare function escapeHtml(str: string): string; /** * Serialize a {@link ResolvedAttrs} object into an HTML attribute string. * * Returns a leading space if non-empty, or an empty string. * * @example * ```ts * serializeResolvedAttrs({ style: { color: 'red' }, classes: ['bold'] }) * // ' class="bold" style="color:red"' * ``` */ declare function serializeResolvedAttrs(resolved: ResolvedAttrs | undefined): string; /** * Shared base for all HTML string renderers. * * Handles HTML-specific concerns: * - Text escaping * - String concatenation of children * - Serialization of {@link ResolvedAttrs} to HTML attribute strings * - Rendering of declarative block/mark descriptors * * Subclasses provide their own `RendererConfig` to control * how blocks and marks are rendered. */ declare abstract class BaseHtmlRenderer extends BaseRenderer { protected emptyAttrs(): ResolvedAttrs; protected mergeAttrs(target: ResolvedAttrs, source: ResolvedAttrs): ResolvedAttrs; protected hasAttrs(attrs: ResolvedAttrs): boolean; protected joinChildren(children: string[]): string; protected renderText(text: string): string; /** * Wrap content in a `` with the given collected attributor attrs. * Used when a text node has attributor marks but no element marks. */ protected wrapWithAttrs(content: string, attrs: ResolvedAttrs): string; /** * Render a simple tag mark: `content`. */ protected renderSimpleTag(tag: string, content: string, collectedAttrs?: ResolvedAttrs): string; /** * Render a declarative block descriptor: * `{children || '
'}
`. */ protected renderBlockFromDescriptor(descriptor: BlockDescriptor, node: TNode, childrenOutput: string, resolvedAttrs: ResolvedAttrs): string; } /** * Renders an AST into Quill's native HTML format. * * Produces markup that exactly matches Quill editor's output, including: * - `ql-*` CSS classes for indentation, alignment, direction, fonts, and sizes * - `
` for empty blocks * - `spellcheck="false"` on code blocks * - `rel="noopener noreferrer"` on links * - `data-row` on table cells * - `data-list` and `.ql-ui` markers on list items * - Formula and video embed support * * For a configurable HTML renderer (with custom class prefix, inline styles, * hooks, etc.), use `SemanticHtmlRenderer` instead. * * Use `withBlock()` and `withMark()` to override specific handlers * without subclassing. * * @example * ```ts * const renderer = new QuillHtmlRenderer(); * const html = renderer.renderDelta(delta); * ``` */ declare class QuillHtmlRenderer extends BaseHtmlRenderer { constructor(); /** * Convenience method: parses a Quill Delta and renders it to HTML * that exactly matches Quill editor output. * * Unlike `parseQuillDelta()` + `render()`, this disables paragraph * merging (`multiLineParagraph: false`) so each `\n` produces a * separate `

` — matching Quill's native behavior. * * @example * ```ts * const renderer = new QuillHtmlRenderer(); * const html = renderer.renderDelta(delta); * ``` */ renderDelta(delta: Delta, options?: ParseQuillDeltaOptions): string; } /** * A lookup table mapping attribute values to CSS style strings, * or a function that returns a CSS style string. */ type InlineStyleConverter = Record | ((value: string, node: TNode) => string | undefined); /** * Override individual inline style converters. * Keys are attribute names (font, size, indent, align, direction, background). */ type InlineStyleOverrides = Partial>; /** * Group types for beforeRender/afterRender callbacks. */ type RenderGroupType = 'block' | 'list' | 'video' | 'table'; /** * Called before rendering a group. Return a string to replace default rendering, * or a falsy value to use default rendering. */ type BeforeRenderCallback = (groupType: RenderGroupType, node: TNode) => string | null | undefined; /** * Called after rendering a group. Can modify the generated HTML. */ type AfterRenderCallback = (groupType: RenderGroupType, html: string) => string; /** * Called for custom embed/blot nodes that have no built-in handler. * * @param node - The custom embed node * @param contextNode - The parent block node, or null if inline * @returns The HTML string for this custom embed */ type CustomBlotRenderer = (node: TNode, contextNode: TNode | null) => string; /** * Configuration for the SemanticHtmlRenderer. * * All options are optional and have sensible defaults matching * quill-delta-to-html output format. */ interface SemanticHtmlConfig { /** Tag used for paragraphs. Default: `'p'` */ paragraphTag?: string; /** Tag used for ordered lists. Default: `'ol'` */ orderedListTag?: string; /** Tag used for bullet/check lists. Default: `'ul'` */ bulletListTag?: string; /** Tag used for list items. Default: `'li'` */ listItemTag?: string; /** CSS class prefix for generated classes. Default: `'ql'` */ classPrefix?: string; /** * When `true`, render inline styles instead of CSS classes for formatting * attributes like indent, align, direction, font, size. * When an object, provides custom inline style converters per attribute. * Default: `false` (use CSS classes) */ inlineStyles?: boolean | InlineStyleOverrides; /** When `true`, render `background` as a CSS class instead of inline style. Default: `false` */ allowBackgroundClasses?: boolean; /** Target attribute for links. Default: `'_blank'`. Set to `''` to omit. */ linkTarget?: string; /** Rel attribute for links. Optional. */ linkRel?: string; /** Whether to HTML-encode text content. Default: `true` */ encodeHtml?: boolean; /** Custom URL sanitizer. Return a string to use as URL, or undefined for default behavior. */ urlSanitizer?: (url: string) => string | undefined; /** Provide a custom HTML tag for a given format. */ customTag?: (format: string, node: TNode) => string | undefined; /** Provide custom HTML attributes for a node. */ customTagAttributes?: (node: TNode) => Record | undefined; /** Provide custom CSS classes for a node. */ customCssClasses?: (node: TNode) => string | string[] | undefined; /** Provide custom CSS styles for a node. */ customCssStyles?: (node: TNode) => string | string[] | undefined; /** * Whether to add the `ql-syntax` class to code blocks. * When `true`, renders `

`.
     * When `false`, renders `
` (matching quill-delta-to-html).
     * Default: `false`
     */
    codeSyntaxClass?: boolean;
    /**
     * Whether to add the `ql-image` CSS class to image elements.
     * Default: `true` (matching quill-delta-to-html)
     */
    imageClass?: boolean;
    /**
     * Whether to preserve the `alt` attribute on images.
     * quill-delta-to-html drops `alt`; set to `true` to keep it.
     * Default: `false`
     */
    preserveImageAlt?: boolean;
    /**
     * Called before rendering each block-level group.
     * If the callback returns a non-empty string, it replaces the default output.
     */
    beforeRender?: BeforeRenderCallback;
    /**
     * Called after rendering each block-level group.
     * The callback receives the generated HTML and can modify it.
     */
    afterRender?: AfterRenderCallback;
    /**
     * Called for custom embed/blot nodes that have no built-in handler.
     * Return the HTML string for this custom embed.
     */
    customBlotRenderer?: CustomBlotRenderer;
}

/** Default inline style converters used when `inlineStyles: true`. */
declare const DEFAULT_INLINE_STYLES: Record;

/**
 * Renders an AST into clean, configurable HTML.
 *
 * Produces markup compatible with quill-delta-to-html output by default,
 * using `ql-*` CSS classes for formatting. All aspects are configurable:
 * class prefix, tag names, inline styles mode, link behavior, and more.
 *
 * Suitable for CMS output, email, read-only display, or any context
 * where clean, configurable HTML matters.
 *
 * @example
 * ```ts
 * // Default: quill-delta-to-html compatible output
 * const renderer = new SemanticHtmlRenderer();
 * const html = renderer.render(ast);
 * ```
 *
 * @example
 * ```ts
 * // Customized output
 * const renderer = new SemanticHtmlRenderer({
 *   classPrefix: 'article',
 *   paragraphTag: 'div',
 *   linkTarget: '',
 *   inlineStyles: true,
 * });
 * ```
 */
declare class SemanticHtmlRenderer extends BaseHtmlRenderer {
    private readonly cfg;
    constructor(config?: SemanticHtmlConfig);
    protected renderText(text: string): string;
}

export { type AfterRenderCallback, BaseHtmlRenderer, type BeforeRenderCallback, type CustomBlotRenderer, DEFAULT_INLINE_STYLES, EMPTY_RESOLVED_ATTRS, type InlineStyleConverter, type InlineStyleOverrides, QuillHtmlRenderer, type RenderGroupType, type ResolvedAttrs, type SemanticHtmlConfig, SemanticHtmlRenderer, escapeHtml, hasResolvedAttrs, mergeResolvedAttrs, serializeResolvedAttrs };