import { Value } from 'platejs'; /** * 内容格式类型 */ export type ContentFormat = 'json' | 'html' | 'markdown'; /** * 内容数据接口 */ export interface ContentData { /** 内容格式 */ format: ContentFormat; /** 内容数据 */ data: string | Value; /** 元数据 */ meta?: { /** 创建时间 */ createdAt?: string; /** 更新时间 */ updatedAt?: string; /** 标题 */ title?: string; /** 版本 */ version?: string; }; } /** * HTML 序列化选项 */ export interface HtmlSerializeOptions { /** 是否包含完整的 HTML 文档结构 */ fullDocument?: boolean; /** 自定义样式 */ customStyles?: string; /** 是否内联样式 */ inlineStyles?: boolean; /** 文档标题 */ title?: string; /** 是否移除 class 名称 */ stripClassNames?: boolean; /** 是否移除 data 属性 */ stripDataAttributes?: boolean; /** 保留的 class 名称前缀 */ preserveClassNames?: string[]; } /** * HTML 反序列化选项 */ export interface HtmlDeserializeOptions { /** 是否清理 HTML */ sanitize?: boolean; /** 是否折叠空白字符 */ collapseWhiteSpace?: boolean; } /** * Markdown 序列化选项 */ export interface MarkdownSerializeOptions { /** 允许的节点类型 */ allowedNodes?: string[]; /** 禁止的节点类型 */ disallowedNodes?: string[]; } /** * Markdown 反序列化选项 */ export interface MarkdownDeserializeOptions { /** 允许的节点类型 */ allowedNodes?: string[]; /** 禁止的节点类型 */ disallowedNodes?: string[]; /** 是否在换行处分割段落 */ splitLineBreaks?: boolean; } /** * 转换结果 */ export interface ConvertResult { /** 是否成功 */ success: boolean; /** 转换后的数据 */ data?: T; /** 错误信息 */ error?: string; } /** * 默认的内联样式 */ export declare const DEFAULT_HTML_STYLES: string; /** * 将 Value 转换为 HTML * * @param value Plate 编辑器内容 * @param options 序列化选项 * @returns HTML 字符串 */ export declare function valueToHtml(value: Value, options?: HtmlSerializeOptions): Promise; /** * 将 HTML 转换为 Value * * @param html HTML 字符串 * @param options 反序列化选项 * @returns Plate 编辑器内容 */ export declare function htmlToValue(html: string, options?: HtmlDeserializeOptions): Value; /** * 将 Value 转换为 Markdown * * @param value Plate 编辑器内容 * @param options 序列化选项 * @returns Markdown 字符串 */ export declare function valueToMarkdown(value: Value, options?: MarkdownSerializeOptions): string; /** * 将 Markdown 转换为 Value * * @param markdown Markdown 字符串 * @param options 反序列化选项 * @returns Plate 编辑器内容 */ export declare function markdownToValue(markdown: string, options?: MarkdownDeserializeOptions): Value; /** * 将 Value 转换为纯文本 * * @param value Plate 编辑器内容 * @returns 纯文本字符串 */ export declare function valueToText(value: Value): string; /** * HTML 转 Markdown */ export declare function htmlToMarkdown(html: string): string; /** * Markdown 转 HTML */ export declare function markdownToHtml(markdown: string, options?: HtmlSerializeOptions): Promise; /** * 从任意格式加载内容 * * @param content 内容数据 * @returns Plate Value */ export declare function loadContent(content: ContentData): Value; /** * 保存内容为指定格式 * * @param value Plate Value * @param format 目标格式 * @param options 序列化选项 * @returns 内容数据 */ export declare function saveContent(value: Value, format: ContentFormat, options?: HtmlSerializeOptions | MarkdownSerializeOptions): Promise; /** * 转换内容格式 * * @param content 源内容 * @param targetFormat 目标格式 * @param options 序列化选项 * @returns 转换后的内容 */ export declare function convertContent(content: ContentData, targetFormat: ContentFormat, options?: HtmlSerializeOptions | MarkdownSerializeOptions): Promise; /** * 转义 HTML 特殊字符 */ export declare function escapeHtml(text: string): string; /** * 清理 HTML,移除危险内容 */ export declare function sanitizeHtml(html: string): string; /** * 检查内容是否为空 */ export declare function isContentEmpty(value: Value): boolean; /** * 验证内容格式 */ export declare function validateContent(content: ContentData): ConvertResult;