import { S as SimpleRenderer } from '../../simple-renderer-yivghYpg.js'; import { b as TNode, a as BlockDescriptor } from '../../ast-types-U4BC1m-E.js'; import { B as BaseRenderer } from '../../base-renderer-CKK0r7zD.js'; /** * Callback to render a custom embed node to Markdown (or extended format). * Receives the embed node (`node.type` is the embed key, e.g. `'myEmbed'`; * `node.data` is the embed payload). Return a string to emit, or `undefined` * to fall back to attribute-based rendering or empty. */ type EmbedHandler = (node: TNode) => string | undefined; /** * Callback to provide only attributes for an embed. The renderer builds the * tag (HTML or bracket) from these attributes. Use for a simple path when * you don't need full control. Ignored if {@link EmbedHandler} returns a string. */ type EmbedAttributesHandler = (node: TNode) => Record | undefined; /** * Configuration options for the {@link MarkdownRenderer}. * * All options are optional and have sensible defaults matching * the output of the existing `convertDeltaToMarkdown()` function. */ interface MarkdownConfig { /** * Character used for unordered (bullet) list items. * @default '*' */ bulletChar?: string; /** * Padding after the bullet character. * @default ' ' (3 spaces — matches existing output) */ bulletPadding?: string; /** * Indentation string for nested list levels. * @default ' ' (4 spaces) */ indentString?: string; /** * String used for horizontal rules (thematic breaks). * @default '* * *' */ hrString?: string; /** * Characters used for fenced code blocks. * @default '```' */ fenceChar?: string; /** * Full override for custom embed nodes. Return the string to emit, or * `undefined` to fall back to attribute-based rendering (if configured) or empty. */ embedHandler?: EmbedHandler; /** * Simple path: return only attributes for the embed; the renderer builds * a self-closing tag (HTML <embed /> or bracket [EMBED ...]). Used when no {@link embedHandler} result. */ embedAttributesHandler?: EmbedAttributesHandler; } /** * Bracket markdown renderer: uses [STYLE]...[/STYLE] and other [TAG]...[/TAG] * formats for content with no standard Markdown syntax. Same blocks and standard * marks as {@link MarkdownRenderer}, plus non-standard formats as bracket tags * (e.g. [STYLE underline=true], [STYLE color=red]). Content inside can include * **bold**, *italic*, `code`. * * Currently supports [STYLE] with: underline, sub, sup, color, bg, font, size. * Additional bracket tag types can be added via the bracket renderer config. * * @example * ```ts * const renderer = new BracketMarkdownRenderer(); * const md = renderer.render(ast); * // e.g. [STYLE color=red]**bold**[/STYLE] * ``` */ declare class BracketMarkdownRenderer extends SimpleRenderer { constructor(config?: MarkdownConfig); protected joinChildren(children: string[]): string; protected renderText(text: string): string; } /** * Collected attributes for HTML markdown inline spans (color, background, font, size). * Used so multiple formats merge into one tag instead of nested spans. * @internal */ interface MarkdownHtmlAttrs { attrs?: Record; } /** * Markdown renderer that uses HTML for formats with no standard Markdown syntax. * Same blocks and standard marks as {@link MarkdownRenderer}, plus: * * - **Underline** → `...` * - **Script (subscript)** → `...` * - **Script (superscript)** → `...` * - **Color, background, font, size** → single `` with all attributes * * Use when the output is rendered by a Markdown processor that allows inline * HTML (e.g. GitHub Flavored Markdown, CommonMark). Use {@link MarkdownRenderer} * for strict standard Markdown only. * * @example * ```ts * const renderer = new HtmlMarkdownRenderer(); * const md = renderer.render(ast); * // Underline and script appear as , , ; color/font etc. in one * ``` */ declare class HtmlMarkdownRenderer extends BaseRenderer { constructor(config?: MarkdownConfig); protected joinChildren(children: string[]): string; protected renderText(text: string): string; protected emptyAttrs(): MarkdownHtmlAttrs; protected mergeAttrs(target: MarkdownHtmlAttrs, source: MarkdownHtmlAttrs): MarkdownHtmlAttrs; protected hasAttrs(attrs: MarkdownHtmlAttrs): boolean; protected wrapWithAttrs(content: string, attrs: MarkdownHtmlAttrs): string; protected renderSimpleTag(tag: string, content: string, collectedAttrs?: MarkdownHtmlAttrs): string; protected renderBlockFromDescriptor(_descriptor: BlockDescriptor, _node: TNode, childrenOutput: string, _resolvedAttrs: MarkdownHtmlAttrs): string; /** * Override so attributors (color, font, etc.) wrap outside element marks. * Element marks output Markdown (**bold**, _italic_, etc.); then we wrap * with for a result like **text**. */ protected renderTextNode(node: TNode): string; } /** * Renders an AST into standard Markdown text. * * Supports all standard Quill block types (paragraphs, headers, blockquotes, * code blocks, lists, images, video, horizontal rules) and inline marks that * have native Markdown syntax: bold, italic, strike, code, link. * * Formats with no standard Markdown equivalent (underline, script, color, * background, font, size) are stripped. For HTML fallbacks (e.g. ``, * ``, ``) use {@link HtmlMarkdownRenderer}. * * The renderer is designed for extensibility — use `withBlock()` and * `withMark()` to add handlers for custom embed types (e.g. mentions, * link previews, formulas). * * @example * ```ts * const renderer = new MarkdownRenderer(); * const md = renderer.render(ast); * ``` * * @example * ```ts * // Customized output * const renderer = new MarkdownRenderer({ * bulletChar: '-', * hrString: '---', * fenceChar: '~~~', * }); * ``` * * @example * ```ts * // Extend with custom embed * const renderer = new MarkdownRenderer().withBlock('user_mention', (node) => { * const data = node.data as Record; * return `[@${data.name}](#user_mention#${data.id})`; * }); * ``` */ declare class MarkdownRenderer extends SimpleRenderer { constructor(config?: MarkdownConfig); protected joinChildren(children: string[]): string; protected renderText(text: string): string; } export { BracketMarkdownRenderer, type EmbedAttributesHandler, type EmbedHandler, HtmlMarkdownRenderer, type MarkdownConfig, MarkdownRenderer };