/** * Placeholder utilities for AI rewrite flows. * * Both the RTE (Tiptap/HTML) and Feed (Slate/markdown) paths need to protect * certain tokens — links, images, user mentions — before sending text to the * AI, and restore them afterwards. This file provides both sets of helpers. * * ## RTE (HTML) — `extractLinkAndImg` / `restorePlaceholders` * Replaces `` and `` elements with `[PEGA-IMG-XXXX]` / `[PEGA-LINK-XXXX]` * placeholders using DOMParser. Reduces payload size and prevents the AI from * stripping or mangling anchor/image tags. Images wrapped in an anchor are * captured as a single LINK placeholder so the full `` structure * is stored intact. * * ## Feed (markdown) — `extractMentions` / `restoreMentionPlaceholders` * Replaces `` XML elements with `[PEGA-MENTION-XXXX]` * placeholders using regex. Prevents the AI from dropping or mangling user * @mention markup that is stored inline in Slate markdown. * * In both cases: placeholders the AI dropped are appended at the end; * hallucinated placeholder strings not in the map are stripped; * placeholder-like strings the user literally typed are preserved. */ export interface PlaceholderMap { [placeholder: string]: string; } interface ExtractResult { placeholderHtml: string; placeholderMap: PlaceholderMap; userPlaceholders: string[]; } /** * Replaces all `` and standalone `` elements in the HTML with unique * placeholders. Uses DOMParser to reliably locate elements rather than regex. * Anchors are processed first so that linked images (``) are * captured as a single LINK placeholder. */ export declare function extractLinkAndImg(html: string): ExtractResult; /** * Restores placeholders in the rewritten HTML with the original HTML elements. * Placeholders that were dropped by the AI are appended at the end, each * wrapped in a `

` tag (TipTap's default block element). * Any hallucinated placeholder strings (not in the map) are stripped. */ export declare function restorePlaceholders(html: string, placeholderMap: PlaceholderMap, userPlaceholders?: string[]): string; interface ExtractMentionsResult { cleanText: string; mentionMap: PlaceholderMap; userPlaceholders: string[]; } /** * Extracts all `` elements from a markdown string, * replacing them with unique `[PEGA-MENTION-XXXX]` placeholders. * * Call this before sending Feed text to the AI for rewriting. After the AI * responds, call `restoreMentionPlaceholders` to put the original mention XML back. */ export declare function extractMentions(markdown: string): ExtractMentionsResult; /** * Restores `` XML elements in AI-rewritten Feed text. * * - Placeholders present in the AI response are replaced with the original mention XML. * - Placeholders dropped by the AI are appended at the end (preserving all mentions). * - Hallucinated placeholder strings (not in the map) are stripped, unless they were * typed literally by the user. */ export declare function restoreMentionPlaceholders(text: string, mentionMap: PlaceholderMap, userPlaceholders?: string[]): string; export {}; //# sourceMappingURL=htmlPlaceholder.d.ts.map