UNPKG

@koi-br/office-provider-sdk

Version:

Universal Office Provider SDK supporting WPS, OnlyOffice and more. Framework-agnostic library for React, Vue, Angular, and vanilla JavaScript / 通用 Office 提供商 SDK,支持 WPS、OnlyOffice 等多种办公套件。框架无关库,支持 React、Vue、Angular 和原生 JavaScript

1,132 lines (1,121 loc) 30.3 kB
/** * Office Provider SDK - 重构后的统一接口定义 * 支持 WPS、OnlyOffice 等多种 Office 提供商 * * @version 3.0.0 - Breaking Changes */ /** * Office 提供商类型枚举 */ declare enum OfficeProviderType { WPS = "wps", ONLYOFFICE = "onlyoffice" } /** * 文档类型枚举 */ declare enum DocumentType { WRITER = "writer",// 文档 SPREADSHEET = "spreadsheet",// 表格 PRESENTATION = "presentation" } /** * Office SDK 配置接口(重构后) * 极简配置,支持智能配置和手动配置两种模式 */ interface OfficeConfig { /** 文件ID - 必需 */ fileId: string; /** 容器选择器 - 必需 */ containerSelector: string; /** 配置API地址 - 可选(autoConfig=true时必需) */ configApiUrl?: string; /** 是否只读模式 - 可选 */ isReadOnly?: boolean; /** 自动配置模式 - 默认 true */ autoConfig?: boolean; /** WPS 请求认证令牌 - 可选 */ token?: string; /** API 请求权限认证令牌 - 可选 */ permissionToken?: string; /** WPS Office类型 - 可选,支持 "writer" | "spreadsheet" | "presentation" | "pdf" | "otl" | "dbt" */ officeType?: string; /** 透传给 WebOffice 的通用配置 */ commonOptions?: Record<string, any>; /** 手动配置模式下的提供商类型 - autoConfig=false 时必需 */ providerType?: OfficeProviderType; /** 手动配置详情 - autoConfig=false 时必需 */ manualConfig?: ManualProviderConfig; /** 编辑器就绪回调 */ onReady?: (provider: any, details?: ReadyEventDetails) => void; /** 错误回调 */ onError?: (error: ErrorEventDetails) => void; } /** * 手动配置时的提供商配置 */ interface ManualProviderConfig { wps?: { appId: string; token: string; refreshToken?: string; documentType?: DocumentType; officeType?: string; simple?: boolean; /** 透传给 WebOffice 的通用配置 */ commonOptions?: Record<string, any>; }; onlyoffice?: { documentServerUrl: string; token?: string; document: { fileType: string; key: string; title: string; url: string; token?: string; }; editorConfig?: { mode?: "edit" | "view"; callbackUrl?: string; user?: { id: string; name: string; group?: string; }; customization?: any; }; permissions?: { edit?: boolean; download?: boolean; review?: boolean; comment?: boolean; }; }; } /** * 配置API统一响应格式 */ interface ConfigApiResponse { /** 检测到的提供商类型 */ type: OfficeProviderType; data: { /** 服务器地址 */ documentServerUrl: string; /** 提供商配置 */ config: WPSApiResponse | OnlyOfficeApiResponse; }; } /** * WPS API 响应 */ interface WPSApiResponse { appId: string; token: string; refreshToken?: string; officeType: "writer" | "spreadsheet" | "presentation"; simple?: boolean; callbackUrl?: string; user?: { id: string; name: string; }; } /** * OnlyOffice API 响应 */ interface OnlyOfficeApiResponse { documentServerUrl: string; token?: string; document: { fileType: string; key: string; title: string; url: string; token?: string; }; editorConfig?: { mode?: "edit" | "view"; callbackUrl?: string; user?: { id: string; name: string; group?: string; }; customization?: any; }; permissions?: { edit?: boolean; download?: boolean; review?: boolean; comment?: boolean; }; } /** * 就绪事件详情 */ interface ReadyEventDetails { providerType: OfficeProviderType; providerName: string; timestamp: string; isReady: boolean; [key: string]: any; } /** * 错误事件详情 */ interface ErrorEventDetails { type: string; message: string; provider: string; timestamp: string; originalError?: any; [key: string]: any; } /** * 搜索结果接口 */ interface SearchResult { /** 找到的位置 */ pos: number; /** 匹配长度 */ length: number; /** 匹配的文本 */ text: string; /** 是否找到 */ found: boolean; } /** * 修订信息接口 */ interface RevisionInfo { /** 修订索引 */ index: number; /** 修订内容 */ text: string; /** 修订日期 */ date: string; /** 修订位置 */ start: number; /** 修订位置 */ end: number; /** 修订作者 */ author: string; /** 修订类型 */ type: "insert" | "delete" | "format"; } /** * 字体格式接口 */ interface FontFormat { /** 字体名称 */ name?: string; /** 字体大小 */ size?: number; /** 是否粗体 */ bold?: boolean; /** 是否斜体 */ italic?: boolean; /** 字体颜色 */ color?: string; } /** * Office Provider 基础接口 */ interface IOfficeProvider { /** 提供商类型 */ readonly type: OfficeProviderType; /** 提供商名称 */ readonly name: string; /** 是否已就绪 */ readonly isReady: boolean; /** * 初始化 Office 实例 * @param config 配置参数 * @param callbacks 可选的事件回调 */ initialize(config: any, callbacks?: OfficeEventCallbacks): Promise<void>; /** * 销毁 Office 实例 */ destroy(): Promise<void>; /** * 搜索并定位文本 * @returns SearchResult 包含位置信息 | true 表示找到但无详细位置 | null 表示未找到 */ searchAndLocateText(text: string, highlight?: boolean): Promise<SearchResult | boolean | null>; /** * 获取原生实例 */ getNativeInstance(): any; /** * 设置文档只读状态 */ setReadOnly(isReadOnly: boolean): Promise<void>; /** * 保存文档 */ saveDocument(): Promise<boolean>; /** * 添加内容控制 */ addContentControl(field: { fieldId: string; placeholderText?: string; }): Promise<boolean>; /** * 设置内容控制的值 */ setContentControlValue(fieldId: string, value?: string): Promise<boolean>; /** * 删除内容控制 */ removeContentControl(fieldId: string): Promise<boolean>; /** * 设置内容控制高亮颜色 */ setControlsHighlight(color: [number, number, number, number]): Promise<boolean>; /** * 适应宽度 */ zoomFitToWidth(): Promise<any>; /** * 获取评论列表 */ getCommentsList(key: string): Promise<any>; /** * 根据文本定位 */ locateByText(field: { text: string; }): Promise<boolean>; /** * 搜索和替换 */ searchAndReplace(field: { old: string; new: string; }): Promise<boolean>; /** * 撤回插入文本操作 */ rejectReviewByText(field: { old: string; new: string; }): Promise<boolean>; /** * 滚动到指定位置 */ viewScrollToY(y: number): Promise<boolean>; /** * 跳转评论 */ jumpCommentDto(jumpId: string, documentKey: string): Promise<boolean>; } /** * WPS Provider 接口 */ interface IWPSProvider extends IOfficeProvider { readonly type: OfficeProviderType.WPS; /** * 在光标位置插入文本 */ insertTextAtCursor(text: string): Promise<boolean>; /** * 替换指定位置的内容 */ replaceText(pos: number, length: number, newText: string): Promise<boolean>; /** * 高亮指定范围的文本 */ highlightText(pos: number, length: number): Promise<boolean>; /** * 清除所有高亮 */ clearHighlight(): Promise<void>; /** * 获取文档长度 */ getDocumentLength(): Promise<number>; /** * 格式化文档字体 */ formatDocumentFont(fontFormat: FontFormat): Promise<boolean>; /** * 获取修订信息 */ getRevisions(date?: string): Promise<RevisionInfo[]>; /** * 处理修订(接受或拒绝) */ handleRevisions(revisionIds: number[], action: "accept" | "reject"): Promise<boolean>; /** * 接受修订 */ acceptReviewByText(field: { old: string; new: string; }): Promise<boolean>; } /** * OnlyOffice Provider 接口 */ interface IOnlyOfficeProvider extends IOfficeProvider { readonly type: OfficeProviderType.ONLYOFFICE; } /** * HTTP 请求配置 */ interface HttpRequestConfig { /** 请求超时时间(毫秒),默认10秒 */ timeout?: number; /** 请求头 */ headers?: Record<string, string>; /** 请求方法,默认GET */ method?: "GET" | "POST"; /** 请求体 */ body?: any; } /** * HTTP 响应接口 */ interface HttpResponse<T = any> { data: T; status: number; statusText: string; headers: Record<string, string>; } /** * Office 事件回调接口 * 统一的事件回调定义,用于不同 Provider 的事件处理 */ interface OfficeEventCallbacks { /** 编辑器就绪回调 */ onReady?: (provider: any, details?: ReadyEventDetails) => void; /** 错误回调 */ onError?: (error: ErrorEventDetails) => void; } /** * Office SDK 配置接口(兼容性别名) * @deprecated 请使用 OfficeConfig 替代 */ type OfficeSDKConfig$1 = OfficeConfig; /** * Office SDK 统一入口类 * 提供统一的 API 接口,支持多种 Office 提供商 */ /** * Office SDK 配置接口(方案2) */ type OfficeSDKConfig = OfficeConfig; /** * Office SDK 主类 * 这是用户使用的主要接口 */ declare class OfficeSDK { private currentProvider; private factory; private eventCallbacks; constructor(); /** * 初始化 Office SDK(方案2) * @param config SDK 配置 * @param callbacks 事件回调 */ initialize(config: OfficeSDKConfig, callbacks?: OfficeEventCallbacks): Promise<void>; /** * 切换 Office 提供商(方案2) * @param newConfig 新的统一配置 */ switchProvider(newConfig: OfficeSDKConfig): Promise<void>; /** * 销毁 SDK 实例 */ destroy(): Promise<void>; /** * 获取当前提供商类型 */ getCurrentProviderType(): OfficeProviderType | null; /** * 获取当前提供商名称 */ getCurrentProviderName(): string | null; /** * 检查 SDK 是否已准备就绪 */ get isReady(): boolean; /** * 获取支持的所有提供商信息 */ getSupportedProviders(): Array<{ name: string; type: OfficeProviderType; }>; /** * 搜索并定位文本 */ searchAndLocateText(text: string, highlight?: boolean): Promise<SearchResult | boolean | null>; /** * 在光标位置插入文本 * ⚠️ 此方法仅在 WPS 提供商下可用 */ insertTextAtCursor(text: string): Promise<boolean>; /** * 替换指定位置的内容 * ⚠️ 此方法仅在 WPS 提供商下可用 */ replaceText(pos: number, length: number, newText: string): Promise<boolean>; /** * 高亮指定范围的文本 * ⚠️ 此方法仅在 WPS 提供商下可用 */ highlightText(pos: number, length: number): Promise<boolean>; /** * 清除所有高亮 * ⚠️ 此方法仅在 WPS 提供商下可用 */ clearHighlight(): Promise<void>; /** * 设置文档只读状态 */ setReadOnly(isReadOnly: boolean): Promise<void>; /** * 保存文档 */ saveDocument(): Promise<boolean>; /** * 获取文档长度 * ⚠️ 此方法仅在 WPS 提供商下可用 */ getDocumentLength(): Promise<number>; /** * 格式化文档字体 * ⚠️ 此方法仅在 WPS 提供商下可用 */ formatDocumentFont(fontFormat: FontFormat): Promise<boolean>; /** * 获取修订信息 * ⚠️ 此方法仅在 WPS 提供商下可用 */ getRevisions(date?: string): Promise<RevisionInfo[]>; /** * 处理修订(接受或拒绝) * ⚠️ 此方法仅在 WPS 提供商下可用 */ handleRevisions(revisionIds: number[], action: "accept" | "reject"): Promise<boolean>; /** * 获取原生 Office 实例(用于高级操作) * ⚠️ 注意:此方法返回的实例因提供商而异,使用时需要检查当前提供商类型 */ getNativeInstance(): any; /** * 添加内容控制 * @param field 字段配置 * @returns 是否成功 */ addContentControl(field: { fieldId: string; placeholderText?: string; }): Promise<boolean>; /** * 删除内容控制 * @param fieldId 字段ID * @returns 是否成功 */ removeContentControl(fieldId: string): Promise<boolean>; /** * 设置内容控制的值 * @param fieldId 字段ID * @param value 要设置的值 * @returns 是否成功 */ setContentControlValue(fieldId: string, value: string): Promise<boolean>; /** * 设置内容控制高亮颜色 * @param color 高亮颜色 */ setControlsHighlight(color: [number, number, number, number]): Promise<boolean>; /** * 滚动到指定位置 * @param y 位置 */ viewScrollToY(y: number): Promise<boolean>; /** * 获取评论列表 * @param key 文档ID */ getCommentsList(key: string): Promise<any>; /** * 根据文本定位 * @param field 字段配置 */ locateByText(field: { text: string; }): Promise<boolean>; /** * 搜索和替换 * @param field 字段配置 */ searchAndReplace(field: { old: string; new: string; }): Promise<boolean>; /** * 撤回插入文本操作 * @param field 字段配置 */ rejectReviewByText(field: { old: string; new: string; }): Promise<boolean>; /** * 接受修订 * ⚠️ 此方法仅在 WPS 提供商下可用 * @param field 字段配置 */ acceptReviewByText(field: { old: string; new: string; }): Promise<boolean>; /** * 跳转评论 * @param jumpId 跳转ID * @param documentKey 文档ID */ jumpCommentDto(jumpId: string, documentKey: string): Promise<boolean>; /** * 适应宽度 */ zoomFitToWidth(): Promise<any>; /** * 确保 provider 已准备就绪 */ private ensureProviderReady; /** * 确保当前提供商是 WPS */ private ensureWPSProvider; /** * 确保当前提供商是 OnlyOffice */ private ensureOnlyOfficeProvider; } /** * 创建 Office SDK 实例的便捷函数 */ declare const createOfficeSDK: () => OfficeSDK; /** * 获取全局 Office SDK 实例 */ declare const getGlobalOfficeSDK: () => OfficeSDK; /** * Office Provider 工厂类 * 负责创建和管理不同的 Office 提供商实例 */ /** * Office Provider 工厂实现类 */ declare class OfficeProviderFactory { private static instance; private providers; private constructor(); /** * 获取工厂单例实例 */ static getInstance(): OfficeProviderFactory; /** * 创建 Office Provider 实例 */ createProvider(type: OfficeProviderType): IOfficeProvider; /** * 注册新的 Office Provider */ registerProvider(type: OfficeProviderType, providerClass: new () => IOfficeProvider): void; /** * 获取支持的提供商列表 */ getSupportedProviders(): OfficeProviderType[]; /** * 检查是否支持指定的提供商 */ isProviderSupported(type: OfficeProviderType): boolean; /** * 获取提供商信息 */ getProviderInfo(type: OfficeProviderType): { name: string; type: OfficeProviderType; } | null; /** * 获取所有支持的提供商信息 */ getAllProvidersInfo(): Array<{ name: string; type: OfficeProviderType; }>; /** * 注册默认的 Office 提供商 */ private registerDefaultProviders; } /** * 便捷函数:获取工厂实例 */ declare const getOfficeProviderFactory: () => OfficeProviderFactory; /** * 定义用户通用事件订阅 */ interface ISubscriptionsConf { [key: string]: any; /** * 导航事件 */ navigate: (arg0?: any) => any; /** * WPSWEB ready 事件 */ ready: (arg0?: any) => any; /** * 打印事件 */ print?: { custom?: boolean; subscribe: (arg0?: any) => any; }; /** * 导出 PDF 事件 */ exportPdf?: (arg0?: any) => any; } /** * WPS Office Provider 实现类 */ declare class WPSProvider implements IOfficeProvider { readonly type = OfficeProviderType.WPS; readonly name = "WPS Office"; private _isReady; private _wpsInstance; private _appInstance; private _config; get isReady(): boolean; /** * 初始化 WPS 实例 */ initialize(config: any, callbacks?: OfficeEventCallbacks): Promise<void>; /** * 获取WPS文档类型 */ private getWPSOfficeType; /** * 销毁 WPS 实例 */ destroy(): Promise<void>; /** * 搜索并定位文本 * @returns SearchResult 包含位置信息 | null 表示未找到 */ searchAndLocateText(text: string, highlight?: boolean): Promise<SearchResult | boolean | null>; /** * 在光标位置插入文本 */ insertTextAtCursor(text: string): Promise<boolean>; /** * 替换指定位置的内容(基于成熟实现) */ replaceText(pos: number, length: number, newText: string): Promise<boolean>; /** * 高亮指定范围的文本(基于成熟实现) */ highlightText(pos: number, length: number): Promise<boolean>; /** * 清除所有高亮 */ clearHighlight(): Promise<void>; /** * 设置文档只读状态 */ setReadOnly(isReadOnly: boolean): Promise<void>; /** * 保存文档 */ saveDocument(): Promise<boolean>; /** * 获取文档长度 */ getDocumentLength(): Promise<number>; /** * 格式化文档字体 */ formatDocumentFont(fontFormat: FontFormat): Promise<boolean>; /** * 获取修订信息 */ getRevisions(date?: string): Promise<RevisionInfo[]>; /** * 处理修订(接受或拒绝) */ handleRevisions(revisionIds: number[], action: "accept" | "reject"): Promise<boolean>; /** * 获取原生 WPS 实例 */ getNativeInstance(): any; /** * 处理修订内容(来自成熟实现) */ handleRevisionContent(date: string, isReject?: boolean): Promise<void>; /** * 获取WPS应用程序实例(来自成熟实现) */ getWPSApplication(): any; /** * 获取WPS实例(来自成熟实现) */ getWPSInstance(): ISubscriptionsConf | null; /** * 高亮按范围(来自成熟实现的精确版本) */ highlightByRange(pos: number, length: number): Promise<{ pos: number; length: number; }>; /** * 替换原文内容(来自成熟实现的完整版本) */ replaceOriginalContent(origin: string | undefined, replace: string | undefined, pos: number, len: number): Promise<{ success: boolean; modifyDate: string; }>; /** * 收集修订信息(来自成熟实现) */ collectRevisionInfos(revisions: any, count: number): Promise<RevisionInfo[]>; /** * 检查WPS实例是否准备就绪 */ checkWPSReady(): boolean; /** * 生成随机字符串 */ private generateRandomString; /** * 等待并确保容器元素存在 * @param selector 容器选择器 * @param description 描述信息 * @param timeout 超时时间(毫秒) */ private ensureContainer; /** * 获取最新修订日期 */ private getLatestRevisionDate; addContentControl(field: { fieldId: string; placeholderText?: string; }): Promise<boolean>; setContentControlValue(fieldId: string, value?: string): Promise<boolean>; removeContentControl(fieldId: string): Promise<boolean>; setControlsHighlight(color: [number, number, number, number]): Promise<boolean>; zoomFitToWidth(): Promise<any>; getCommentsList(): Promise<any>; locateByText(field: { text: string; }): Promise<boolean>; searchAndReplace(field: { old: string; new: string; }): Promise<boolean>; /** * 根据文本处理修订 */ handleRevisionByText(text: string, action: 'accept' | 'reject'): Promise<boolean>; acceptReviewByText(field: { old: string; new: string; }): Promise<boolean>; rejectReviewByText(field: { old: string; new: string; }): Promise<boolean>; viewScrollToY(y: number): Promise<boolean>; jumpCommentDto(jumpId: string, documentKey: string): Promise<boolean>; } /** * OnlyOffice Provider 适配器 * 支持官方 @onlyoffice/document-editor-vue 组件和原生 iframe 通信方式 */ /** * OnlyOffice Provider 实现类 */ declare class OnlyOfficeProvider implements IOnlyOfficeProvider { readonly type = OfficeProviderType.ONLYOFFICE; readonly name = "OnlyOffice"; private _isReady; private _config; private _container; private _iframe; private _docEditor; private _vueComponent; private _integrationMode; private _messageHandlers; private _pendingRequests; private _requestId; private _userOnError; private _userOnReady; private _editorReadyResolve; private _editorReadyReject; private _timeouts; get isReady(): boolean; /** * 初始化 OnlyOffice 实例 * @param config OnlyOffice 配置,可以包含 timeouts 属性来配置超时时间 * @param callbacks 回调函数 */ initialize(config: any, callbacks?: any): Promise<void>; /** * 销毁 OnlyOffice 实例 */ destroy(): Promise<void>; /** * 设置消息监听器 */ private setupMessageListener; /** * 处理全局错误 */ private handleGlobalError; /** * 处理未处理的 Promise 拒绝 */ private handleUnhandledRejection; /** * 处理来自 iframe 的消息 */ private handleMessage; /** * 查找编辑器 iframe */ private findEditorIframe; /** * 向 OnlyOffice 发送消息(支持多种传参方式) * * 使用方式1 - 传统方式(向后兼容): * sendMessage("asc_SearchText", ["text", true, false]) * * 使用方式2 - 完整消息对象: * sendMessage({ type: "JumpCommentDto", data: jumpId, key: documentKey }) * sendMessage({ type: "callMethod", methodName: "custom_Method", params: [1, 2] }) * sendMessage({ type: "SearchAndReplace", params: { old: "a", new: "b" } }) */ private sendMessage; /** * 向 OnlyOffice 发送消息(不等待响应,支持多种传参方式) * * 使用方式1 - 传统方式: * sendMessageNoResponse("methodName", [param1, param2]) * * 使用方式2 - 完整消息对象: * sendMessageNoResponse({ type: "JumpCommentDto", data: jumpId, key: documentKey }) */ private sendMessageNoResponse; /** * 搜索并定位文本 * OnlyOffice 不提供详细的位置信息,所以返回 boolean 表示是否找到 */ searchAndLocateText(text: string, highlight?: boolean): Promise<SearchResult | boolean | null>; /** * 设置文档只读状态 */ setReadOnly(isReadOnly: boolean): Promise<void>; /** * 保存文档 */ saveDocument(): Promise<boolean>; /** * 获取原生 OnlyOffice 实例 */ getNativeInstance(): any; /** * 添加内容控制 * @param field 字段配置 */ addContentControl(field: { fieldId: string; placeholderText?: string; }): Promise<boolean>; /** * 设置内容控制的值 * @param field 字段配置 */ setContentControlValue(fieldId: string, value?: string): Promise<boolean>; /** * 设置内容控制高亮颜色 * @param color 高亮颜色 */ setControlsHighlight(color: [number, number, number, number]): Promise<boolean>; /** * 缩放文档以适应宽度 * @returns 返回操作结果 */ zoomFitToWidth(): Promise<any>; /** * 获取评论列表 * @returns 返回操作结果 */ getCommentsList(key: string): Promise<any>; /** * 跳转评论 * @param field 字段配置 */ jumpCommentDto(jumpId: string, documentKey: string): Promise<boolean>; /** * 删除内容控制 * @param fieldId 字段ID */ removeContentControl(fieldId: string): Promise<boolean>; /** * 根据文本定位 * @param fieldId 字段ID */ locateByText(field: { text: string; }): Promise<boolean>; /** * 获取内容控制的值 * @param fieldId 字段ID */ searchAndReplace(field: { old: string; new: string; }): Promise<boolean>; /** * 撤回插入文本操作 * @param field 字段配置 */ rejectReviewByText(field: { old: string; new: string; }): Promise<boolean>; /** * 滚动到指定位置 * @param fieldId 字段ID */ viewScrollToY(y: number): Promise<boolean>; /** * 等待并确保容器元素存在 * @param selector 容器选择器 * @param description 描述信息 * @param timeout 超时时间(毫秒) */ private ensureContainer; /** * 确定集成模式 */ private determineIntegrationMode; /** * Vue 组件模式初始化 */ private initializeVueComponentMode; /** * iframe 模式初始化 */ private initializeIframeMode; /** * 查找现有的编辑器实例 */ private findExistingEditor; /** * 等待编辑器准备就绪 */ private waitForEditorReady; /** * 加载 OnlyOffice 脚本 */ private loadOnlyOfficeScript; /** * 构建编辑器配置 */ private buildEditorConfig; /** * 构建事件配置 */ private buildEvents; /** * 将内部 DocumentType 枚举转换为 OnlyOffice documentType 字符串 */ private getOnlyOfficeDocumentType; } /** * 初始化 Office SDK(重构后的统一接口) * * @param config 简化的配置对象 * @returns Office SDK 实例 * * @example * ```typescript * // 🚀 自动配置模式(推荐)- 通过API自动获取配置 * const sdk = await initOfficeSDK({ * fileId: 'doc123', * containerSelector: '#office-container', * configApiUrl: 'https://api.example.com/office/config', * onReady: (provider) => console.log('✅ Office编辑器就绪'), * onError: (error) => console.log('❌ 错误:', error) * }); * * * // 📝 手动配置模式(离线场景) * const sdk = await initOfficeSDK({ * fileId: 'doc123', * containerSelector: '#office-container', * configApiUrl: '', * autoConfig: false, * providerType: OfficeProviderType.ONLYOFFICE, * manualConfig: { * onlyoffice: { * documentServerUrl: 'https://your-server.com', * document: { fileType: 'docx', key: 'unique-key', title: 'Document', url: 'file-url' } * } * } * }); * ``` */ declare function initOfficeSDK(config: OfficeConfig): Promise<OfficeSDK>; /** * 创建错误处理回调 * @param handler 用户定义的错误处理函数 * @returns 格式化的错误回调 */ declare function createErrorHandler(handler: (error: ErrorEventDetails) => void): (error: any) => void; /** * 创建就绪回调 * @param handler 用户定义的就绪处理函数 * @returns 格式化的就绪回调 */ declare function createReadyHandler(handler: (provider: any, details: ReadyEventDetails) => void): (provider: any) => void; /** * 获取支持的 Office 提供商列表 * @returns 支持的提供商信息数组 */ declare function getSupportedProviders(): Promise<Array<{ name: string; type: OfficeProviderType; }>>; /** * 检查是否支持指定的 Office 提供商 * @param providerType 提供商类型 * @returns 是否支持 */ declare function isProviderSupported(providerType: OfficeProviderType): Promise<boolean>; declare const VERSION = "3.0.0"; declare const SUPPORTED_PROVIDERS: readonly ["WPS", "OnlyOffice"]; declare const _default: { initOfficeSDK: typeof initOfficeSDK; createErrorHandler: typeof createErrorHandler; createReadyHandler: typeof createReadyHandler; getSupportedProviders: typeof getSupportedProviders; isProviderSupported: typeof isProviderSupported; createOfficeSDK: () => Promise<OfficeSDK>; getGlobalSDK: () => Promise<OfficeSDK>; VERSION: string; SUPPORTED_PROVIDERS: readonly ["WPS", "OnlyOffice"]; }; export { type ConfigApiResponse, DocumentType, type ErrorEventDetails, type FontFormat, type HttpRequestConfig, type HttpResponse, type IOfficeProvider, type IOnlyOfficeProvider, type IWPSProvider, type ManualProviderConfig, type OfficeConfig, type OfficeEventCallbacks, OfficeProviderFactory, OfficeProviderType, OfficeSDK, type OfficeSDKConfig$1 as OfficeSDKConfig, type OnlyOfficeApiResponse, OnlyOfficeProvider, type ReadyEventDetails, type RevisionInfo, SUPPORTED_PROVIDERS, type SearchResult, VERSION, type WPSApiResponse, WPSProvider, createErrorHandler, createOfficeSDK, createReadyHandler, _default as default, getGlobalOfficeSDK, getOfficeProviderFactory, getSupportedProviders, initOfficeSDK, isProviderSupported };