@ai-stack/payloadcms
Version:
<p align="center"> <img alt="Payload AI Plugin" src="assets/payload-ai-intro.gif" width="100%" /> </p>
21 lines (20 loc) • 1.46 kB
TypeScript
import type { SerializedEditorState } from 'lexical';
import { type SanitizedServerEditorConfig } from '@payloadcms/richtext-lexical';
export declare const BLOCK_PLACEHOLDER_PREFIX = "[[[BLOCK_";
export declare const BLOCK_PLACEHOLDER_SUFFIX = "]]]";
/**
* Non-Compose text actions (Translate/Simplify/Proofread/...) only ever give the model this
* rendered HTML as its view of the current content (via the `{{toHTML field}}` prompt
* placeholder) - the model never sees the underlying Lexical JSON. Custom `block` nodes
* (BlocksFeature) have no registered HTML converter, so richtext-lexical's HTML conversion
* silently produces nothing for them: the model isn't just unable to reproduce a block, it has
* no way of knowing one exists there at all, so it's removed the moment any such action runs.
*
* Substituting a plain-text marker in a block's place gives the model something it CAN
* legally see and echo back (paired with an instruction to preserve it verbatim, see
* `endpoints/index.ts`), which `setSafeLexicalState.ts` then uses to reinsert the real block
* afterwards. Only top-level `root.children` blocks are covered; blocks nested inside other
* node types are out of scope for this pass.
*/
export declare const withBlockPlaceholders: (editorData: SerializedEditorState) => SerializedEditorState;
export declare function lexicalToHTML(editorData: SerializedEditorState, editorConfig: SanitizedServerEditorConfig): Promise<string>;