import { default as React, ReactNode } from 'react'; import { Locale } from '../locales'; /** * 自定义请求头配置 */ export type CustomHeaders = Record; /** * 上传配置 */ export interface UploadConfig { /** 上传 API 地址,支持相对路径或完整 URL */ url?: string; /** 上传文件字段名,默认 'file' */ fieldName?: string; /** 最大文件大小(字节),默认 10MB */ maxSize?: number; /** 允许的文件类型,如 ['image/*', 'video/*'] */ acceptTypes?: string[]; /** 上传请求头 */ headers?: CustomHeaders; /** 额外的表单数据 */ extraData?: Record; /** 自定义上传函数,用于完全自定义上传逻辑 */ customUpload?: (file: File, onProgress?: (progress: number) => void) => Promise; } /** * 上传结果 */ export interface UploadResult { /** 文件 URL */ url: string; /** 文件名 */ name?: string; /** 文件大小 */ size?: number; /** 文件类型 */ type?: string; /** 服务端返回的文件 ID 或 key */ key?: string; } /** * AI 配置 */ export interface AIConfig { /** Copilot 自动补全 API 地址 */ copilotUrl?: string; /** AI 命令/对话 API 地址 */ commandUrl?: string; /** AI API 密钥 */ apiKey?: string; /** AI 请求头 */ headers?: CustomHeaders; /** AI 模型名称 */ model?: string; /** 自定义 Copilot 请求函数 */ customCopilot?: (prompt: string, context: string) => Promise; /** 自定义 AI 命令请求函数 */ customCommand?: (messages: unknown[], options?: unknown) => Promise; } /** * 编辑器配置接口 */ export interface EditorConfig { /** API 请求基础地址,应用于所有相对路径的请求 */ baseURL?: string; /** AI Copilot API 地址(简化配置) */ aiApiUrl?: string; /** AI API 密钥(简化配置) */ aiApiKey?: string; /** 详细的 AI 配置 */ ai?: AIConfig; /** 文件上传 API 地址(简化配置) */ uploadApiUrl?: string; /** 详细的上传配置 */ upload?: UploadConfig; /** 语言设置 */ locale?: Locale; /** * 自定义请求头 * 应用于所有编辑器发起的 HTTP 请求(文件上传、AI API 等) * @example * ```ts * customHeaders: { * 'Authorization': 'Bearer token', * 'X-Custom-Header': 'value', * } * ``` */ customHeaders?: CustomHeaders; } interface ConfigContextType { config: EditorConfig; updateConfig: (newConfig: Partial) => void; resetConfig: () => void; } export interface ConfigProviderProps { children: ReactNode; config?: EditorConfig; /** localStorage 存储键名,默认 'kc-plate-editor-config' */ persistKey?: string; /** 是否启用配置持久化,默认 true */ enablePersist?: boolean; /** * 是否禁用内置的 I18nProvider * 设为 true 时需要手动在外层包裹 I18nProvider * @default false */ disableI18n?: boolean; } /** * 编辑器配置提供者组件 * * @example * ```tsx * // 默认使用(自动包含国际化) * * * * * // 手动管理国际化 * * * * * * ``` */ export declare const ConfigProvider: React.FC; /** * 获取编辑器配置的 Hook */ export declare const useEditorConfig: () => ConfigContextType; export {};