/** * Lightweight rich-text rendering for agent messages. * * Dependency-free and CSP-safe: everything is built with createElement / * textContent, never innerHTML. The parsing layer is pure (segmentRichText / * segmentInline) so it can be unit-tested in node; renderRichContent is only * a thin DOM mapping over those segments. */ export interface RichTextSegment { readonly kind: "text"; readonly text: string; } export interface RichCodeSegment { readonly kind: "code"; readonly language: string; readonly code: string; } export type RichSegment = RichTextSegment | RichCodeSegment; export type InlinePart = { readonly kind: "text"; readonly text: string; } | { readonly kind: "code"; readonly text: string; } | { readonly kind: "link"; readonly text: string; readonly href: string; }; /** * Split a message into plain-text and fenced-code segments. An unclosed fence * (common while a turn is still streaming) treats the rest of the text as * code instead of dropping it. */ export declare function segmentRichText(text: string): RichSegment[]; /** * Split a plain-text segment into inline parts: `code` spans and http/https * links. URLs inside backtick spans stay literal. Only http/https is linked, * so schemes like javascript: can never become anchors. */ export declare function segmentInline(text: string): InlinePart[]; /** Copy text to the clipboard; resolves to whether the copy succeeded. */ export declare function copyPlainText(text: string): Promise; /** Flash a transient label on a button (e.g. "已复制"), then restore it. */ export declare function flashButtonLabel(button: HTMLButtonElement, label: string, restoreMs?: number): void; /** * Render message text into a container. The container keeps its pre-wrap * whitespace handling; fenced code becomes block-level code blocks with a * language label and copy button. */ export declare function renderRichContent(container: HTMLElement, text: string): void; //# sourceMappingURL=rich-text.d.ts.map