weboffice-js-sdk 2.0.3 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,656 @@
1
+ import 'core-js/features/promise';
2
+ import 'core-js/features/url';
3
+ import 'core-js/features/array/includes';
4
+ import 'core-js/features/object/assign';
5
+ import 'proxy-polyfill';
6
+ import { TinyEmitter } from 'tiny-emitter';
7
+ import { ContainerMethod, ContainerRect, DisableMentionCards, FileType, InvokeMethod, MouseMovePayload, ReadyState, PerformanceEntry, DeviceMode, GenerateUrlHandler, APIAdaptor, RequestContext, ShowToastOptions, Credentials } from 'weboffice-js-sdk-shared';
8
+ import { Document, DocumentPro, Presentation, Spreadsheet, Table, Form, Flowchart } from '.';
9
+ import { EmptyPageOptions } from './types/EmptyPage';
10
+ import { BaseEditor } from './types/BaseEditor';
11
+ import { SlashMenuOptions } from './types/SlashMenu';
12
+ import type { CollaboratorFacade, CommentsFacade, ContentFacade, DiscussionFacade, DocsOutlineFacade, DocsSearchFacade, DocsSelectionFacade, DocsSettingsFacade, DocsSidebarFacade, DocsTablesFacade, ExternalAppFacade, HistoryFacade, LocksFacade, MentionFacade, PresentationEventSubscriptionFacade, PresentationFacade, PresentationSelectionFacade, PresentationSlidesFacade, PresentationTextFacade, PresentationZoomFacade, SheetChartsFacade, SheetSelectionsFacade, SheetWorkbookFacade, SheetWorksheetFacade, TitleFacade, VersionFacade } from './OfficeSDK.facade.types';
13
+ import type { HeaderBarsFacade } from './OfficeSDK.headerBars';
14
+ export * from './OfficeSDK.facade.types';
15
+ export * from './OfficeSDK.headerBars';
16
+ export declare const MessageEvent: typeof InvokeMethod;
17
+ export declare class OfficeSDK extends TinyEmitter {
18
+ /**
19
+ * 编辑器页面对应的 iframe 元素。需要注意调整父元素大小来控制 iframe 大小。
20
+ */
21
+ element: HTMLIFrameElement;
22
+ readonly uuid: string;
23
+ readonly userUuid?: string;
24
+ /**
25
+ * 传统文档编辑器实例
26
+ * @deprecated - 用 `sdk.getEditor<T>()` 替代
27
+ */
28
+ documentPro?: DocumentPro.Editor;
29
+ /**
30
+ * 轻文档编辑器实例
31
+ * @deprecated - 用 `sdk.getEditor<T>()` 替代
32
+ */
33
+ document?: Document.Editor;
34
+ /**
35
+ * 表格编辑器实例
36
+ * @deprecated - 用 `sdk.getEditor<T>()` 替代
37
+ */
38
+ spreadsheet?: Spreadsheet.Editor;
39
+ /**
40
+ * 当前套件支持的标题能力。
41
+ */
42
+ title?: TitleFacade;
43
+ /**
44
+ * 当前套件支持的历史能力。
45
+ */
46
+ history?: HistoryFacade;
47
+ /**
48
+ * 当前套件支持的评论能力。
49
+ */
50
+ comments?: CommentsFacade;
51
+ /**
52
+ * 当前套件支持的讨论能力。
53
+ */
54
+ discussion?: DiscussionFacade;
55
+ /**
56
+ * 当前套件支持的编写者侧边栏能力。
57
+ */
58
+ collaborator?: CollaboratorFacade;
59
+ /**
60
+ * 当前套件支持的第三方应用插入能力。
61
+ */
62
+ externalApp?: ExternalAppFacade;
63
+ /**
64
+ * 当前套件支持的锁定能力。
65
+ */
66
+ locks?: LocksFacade;
67
+ /**
68
+ * 当前套件支持的提及定位能力。
69
+ */
70
+ mention?: MentionFacade;
71
+ /**
72
+ * 当前套件支持的内容写入能力。
73
+ */
74
+ content?: ContentFacade;
75
+ /**
76
+ * 当前套件支持的版本能力。
77
+ */
78
+ version?: VersionFacade;
79
+ /**
80
+ * 当前套件支持的演示能力。
81
+ */
82
+ presentation?: PresentationFacade;
83
+ /**
84
+ * 当前套件支持的选区能力。
85
+ */
86
+ selection?: DocsSelectionFacade | PresentationSelectionFacade;
87
+ /**
88
+ * 当前套件支持的搜索能力。
89
+ */
90
+ search?: DocsSearchFacade;
91
+ /**
92
+ * 当前套件支持的目录能力。
93
+ */
94
+ outline?: DocsOutlineFacade;
95
+ /**
96
+ * 当前套件支持的侧边栏能力。
97
+ */
98
+ sidebar?: DocsSidebarFacade;
99
+ /**
100
+ * 当前套件支持的表格集合能力。
101
+ */
102
+ tables?: DocsTablesFacade;
103
+ /**
104
+ * 当前套件支持的设置能力。
105
+ */
106
+ settings?: DocsSettingsFacade;
107
+ /**
108
+ * 当前套件支持的工作簿能力。
109
+ */
110
+ workbook?: SheetWorkbookFacade;
111
+ /**
112
+ * 当前套件支持的当前工作表能力。
113
+ */
114
+ activeSheet?: SheetWorksheetFacade;
115
+ /**
116
+ * 当前套件支持的图表能力。
117
+ */
118
+ charts?: SheetChartsFacade;
119
+ /**
120
+ * 当前套件支持的多选区能力。
121
+ */
122
+ selections?: SheetSelectionsFacade;
123
+ /**
124
+ * 当前套件支持的幻灯片集合能力。
125
+ */
126
+ slides?: PresentationSlidesFacade;
127
+ /**
128
+ * 当前套件支持的文本能力。
129
+ */
130
+ text?: PresentationTextFacade;
131
+ /**
132
+ * 当前套件支持的缩放能力。
133
+ */
134
+ zoom?: PresentationZoomFacade;
135
+ /**
136
+ * 当前套件支持的事件订阅能力。
137
+ */
138
+ eventSubscription?: PresentationEventSubscriptionFacade;
139
+ /**
140
+ * 当前套件支持的批量变更能力。
141
+ */
142
+ batchChanges?: <T>(callback: () => T | Promise<T>) => Promise<Awaited<T>>;
143
+ /**
144
+ * 当前套件支持的导出能力。
145
+ */
146
+ export?: (type: string) => Promise<void>;
147
+ /**
148
+ * 当前套件支持的打印能力。
149
+ */
150
+ print?: () => Promise<void>;
151
+ /**
152
+ * 当前套件支持的聚焦能力。
153
+ */
154
+ setFocus?: (isFocus: boolean) => Promise<void>;
155
+ /**
156
+ * 应用表格编辑器实例
157
+ * @deprecated - 用 `sdk.getEditor<T>()` 替代
158
+ */
159
+ table?: Table.Editor;
160
+ /**
161
+ * 表单编辑器实例
162
+ * @deprecated - 用 `sdk.getEditor<T>()` 替代
163
+ */
164
+ form?: Form.Editor;
165
+ /**
166
+ * 图谱编辑器实例
167
+ * @deprecated - 用 `sdk.getEditor<T>()` 替代
168
+ */
169
+ flowchart?: Flowchart.Editor;
170
+ readonly headerBars: HeaderBarsFacade;
171
+ private _fileType;
172
+ private readonly messageHandler;
173
+ /**
174
+ * 内部 event emitter,比如用来中转 editor 事件
175
+ */
176
+ private readonly emitter;
177
+ private channel;
178
+ private readonly connectOptions;
179
+ private _readyState;
180
+ private editor;
181
+ private readonly startParams;
182
+ private collaborators;
183
+ private readonly apiAdaptor;
184
+ private readonly apiAdaptorContext;
185
+ private readonly handledMessageCache;
186
+ /**
187
+ * 消息过期时间,单位毫秒,默认 5 分钟
188
+ */
189
+ private readonly messageExpires;
190
+ /**
191
+ * SDK 服务器的地址
192
+ */
193
+ private readonly endpoint;
194
+ private readonly sameOrigin;
195
+ private headerBarsVisible;
196
+ private readonly headerBarsCommands;
197
+ private readonly headerBarsCommandOverrides;
198
+ private readonly slashMenuCallbacks;
199
+ private readonly editorFacadeCallbacks;
200
+ private readonly headerBarsCommandRefs;
201
+ private headerBarsTitleChangeHandler?;
202
+ private headerBarsTitleChangeSubscribed;
203
+ private readonly onViewportResize;
204
+ /**
205
+ * 归一化后的缺省页配置,构造时一次算完,后续仅读取。
206
+ */
207
+ private readonly normalizedEmptyPage;
208
+ private readonly preloadAckTimeoutMs;
209
+ private readonly preloadDoneTimeoutMs;
210
+ private readonly preloadReadyTimeoutMs;
211
+ constructor(options: OfficeSDKOptions);
212
+ get fileType(): FileType;
213
+ get readyState(): ReadyState;
214
+ /**
215
+ * 判断当前实例是否应该向 iframe 暴露 slashMenu。
216
+ * 输入:无,读取当前文件类型与 startParams.type 提示。
217
+ * 输出:仅在明确是 docs,或尚未拿到文件类型且没有明确非 docs 提示时返回 true。
218
+ */
219
+ private shouldExposeSlashMenu;
220
+ /**
221
+ * 从 startParams 中提取文件类型提示。
222
+ * 输入:无。
223
+ * 输出:标准化后的 type 字符串;若未配置则返回 undefined。
224
+ */
225
+ private getSlashMenuTypeHint;
226
+ /**
227
+ * 将宿主传入的 slashMenu 转成可跨 iframe 传输的纯数据结构。
228
+ * 输入:当前实例上的 `OfficeSDKOptions.slashMenu`。
229
+ * 输出:去除真实函数、附带 callbackId 的 slashMenu 配置;不适用时返回 undefined。
230
+ */
231
+ private createSerializedSlashMenu;
232
+ /**
233
+ * 递归序列化 slashMenu 菜单项,并登记 button callback。
234
+ * 输入:菜单项数组与当前递归路径。
235
+ * 输出:仅包含结构化克隆安全字段的菜单项数组。
236
+ */
237
+ private serializeSlashMenuItems;
238
+ /**
239
+ * 为 slashMenu button callback 生成稳定 id 并注册到内存表。
240
+ * 输入:菜单路径与可选 callback。
241
+ * 输出:注册后的 callbackId;若未提供 callback 则返回 undefined。
242
+ */
243
+ private registerSlashMenuCallback;
244
+ getEditor<T extends BaseEditor | Document.Editor | DocumentPro.Editor | Presentation.Editor | Spreadsheet.Editor | Form.Editor | Flowchart.Editor | Table.Editor = BaseEditor>(): T;
245
+ /**
246
+ * 更新鉴权 signature 和 token
247
+ * @deprecated - 用 `OfficeSDKOptions.getCredentials()` 替代
248
+ */
249
+ setCredentials(payload: {
250
+ signature: string;
251
+ token: string;
252
+ }): Promise<void>;
253
+ /**
254
+ * 设置石墨的鉴权 signature。用于实时更新鉴权信息,优化用户出现因长时间放置,鉴权失败而引起的体验问题。
255
+ * @deprecated - 用 `sdk.setCredentials()` 替代
256
+ */
257
+ setSignature(signature: string): Promise<void>;
258
+ /**
259
+ * 设置您系统的鉴权 token。用于实时更新鉴权信息,优化用户出现因长时间放置,鉴权失败而引起的体验问题。
260
+ * @deprecated - 用 `sdk.setCredentials()` 替代
261
+ */
262
+ setToken(token: string): Promise<void>;
263
+ /**
264
+ * 获取性能信息片段列表,由于性能标记是分段的、异步的,因此每次调用时获取的列表有可能不一致
265
+ */
266
+ getPerformanceEntries(): Promise<PerformanceEntry[]>;
267
+ disconnect(): void;
268
+ /**
269
+ * 初始化 SDK,返回 Promise,当 ReadState 变为 Ready 或 Failed 时,Promise 将被 resolve。
270
+ * Promise resovled 不代表编辑器已经完整加载完毕,只代表 SDK 已经准备好了。
271
+ * 同时 Promise 一直 pending 也不代表编辑器加载失败,只代表无法通过 SDK 和编辑器交互。
272
+ * 比如受浏览器限制无法发出 postMessage() 时,Promise 将会一直 pending。
273
+ */
274
+ init(): Promise<void>;
275
+ /**
276
+ * 等待 SDK 进入 Ready 状态。若已 ready,则直接返回。
277
+ */
278
+ ready(): Promise<void>;
279
+ private initIframe;
280
+ private runPreloadHandshake;
281
+ private initChannel;
282
+ /**
283
+ * 初始化处理编辑器需要容器返回数据的方法
284
+ */
285
+ private bindContainerMethodHandlers;
286
+ private initHeaderBarsFacade;
287
+ /**
288
+ * 订阅 iframe 侧 titleChange 事件,并在宿主设置了 headerBars.onTitleChange 时转发标题值。
289
+ * 输入:无。
290
+ * 输出:监听建立成功后返回 Promise<void>;重复调用只会订阅一次。
291
+ */
292
+ private ensureHeaderBarsTitleChangeSubscription;
293
+ private invokeHeaderBars;
294
+ private syncHeaderBarsCommands;
295
+ private createHeaderBarsHost;
296
+ private applyHeaderBarsChanged;
297
+ private syncHeaderBarsVisible;
298
+ private setHeaderBarsVisible;
299
+ private getHeaderBarsCommandRef;
300
+ /**
301
+ * 注册一个可供 iframe 侧反向调用的 facade callback。
302
+ * 输入:宿主侧 callback。
303
+ * 输出:供跨窗协议使用的 callbackId。
304
+ */
305
+ private registerEditorFacadeCallback;
306
+ /**
307
+ * 注销已注册的 facade callback。
308
+ * 输入:callbackId。
309
+ * 输出:无。
310
+ */
311
+ private unregisterEditorFacadeCallback;
312
+ /**
313
+ * 创建基于 method-path 的模块 facade。
314
+ * 输入:模块前缀与少量自定义实现覆盖。
315
+ * 输出:其余方法按 `${prefix}.${method}` 自动桥接。
316
+ */
317
+ private createEditorFacadeModule;
318
+ /**
319
+ * 为 value-based locator 创建本地对象 facade。
320
+ * 输入:method-path 前缀、locator 和静态属性。
321
+ * 输出:支持继续远程调用的本地 facade。
322
+ */
323
+ private createValueObjectFacade;
324
+ /**
325
+ * 注册一个基于 callback 协议的 listener。
326
+ * 输入:注册方法名与监听器。
327
+ * 输出:供宿主侧取消注册的函数。
328
+ */
329
+ private registerEditorFacadeListener;
330
+ private installRootFacade;
331
+ /**
332
+ * 重置根级能力命名空间,避免不同套件间字段残留。
333
+ * 输入:无。
334
+ * 输出:将所有 facade 字段置空。
335
+ */
336
+ private clearRootFacade;
337
+ /**
338
+ * 调用显式 editor facade method-path。
339
+ * 输入:method-path 与参数数组。
340
+ * 输出:返回 iframe 侧序列化结果。
341
+ */
342
+ private invokeEditorFacade;
343
+ /**
344
+ * 为结构化 facade 建立 editor 事件监听,并返回取消监听函数。
345
+ * 输入:事件名与监听器。
346
+ * 输出:返回一个可取消当前监听的函数。
347
+ */
348
+ private listenEditorEvent;
349
+ private initEditor;
350
+ private shouldHandleMessage;
351
+ private getContainerRect;
352
+ private updateCollaborators;
353
+ }
354
+ /**
355
+ * 需要容器提供给编辑器使用的方法
356
+ */
357
+ export interface ContainerMethods {
358
+ /**
359
+ * 获取容器尺寸等信息
360
+ */
361
+ [ContainerMethod.GetContainerRect]?: () => ContainerRect;
362
+ /**
363
+ * 处理石墨文档内点击链接事件
364
+ */
365
+ [ContainerMethod.OpenLink]?: (
366
+ /**
367
+ * 目标链接
368
+ */
369
+ url: string,
370
+ /**
371
+ * 意义和 window.open 的第二个参数一样,属于石墨建议的值,具体是否需要使用请接入方自行判断。
372
+ */
373
+ target?: string) => void;
374
+ /**
375
+ * 生成插入到石墨文档中的链接,用于处理 @ 文件等功能需要插入的链接
376
+ */
377
+ [ContainerMethod.GenerateUrl]?: GenerateUrlHandler;
378
+ /**
379
+ * 用于移动端处理 @ 点击事件
380
+ */
381
+ [ContainerMethod.MentionClickHandlerForMobile]?: (payload: MouseMovePayload) => void;
382
+ /**
383
+ * 用于从客户业务 URL 中获取对应的文件 ID,供编辑器使用。
384
+ */
385
+ [ContainerMethod.GetFileInfoFromUrl]?: (url: string) => Promise<{
386
+ /**
387
+ * 文件 ID
388
+ */
389
+ fileId: string;
390
+ } | undefined>;
391
+ /**
392
+ * 用于显示客户自定义toast。
393
+ */
394
+ [ContainerMethod.ShowToast]?: (options: ShowToastOptions) => Promise<void>;
395
+ /**
396
+ * 通知用户执行自定义操作,操作由用户自定义按钮触发
397
+ */
398
+ [ContainerMethod.HandleCustomTask]?: (taskId: string) => Promise<void>;
399
+ /**
400
+ * 请求容器获取鉴权信息
401
+ * @returns {Credentials} 鉴权信息
402
+ */
403
+ [ContainerMethod.GetCredentials]: () => Promise<Credentials>;
404
+ }
405
+ export declare enum Event {
406
+ /**
407
+ * SDK 初始化事件,用于内部逻辑
408
+ */
409
+ SDKInit = "SDKInit",
410
+ /**
411
+ * 错误事件,包含编辑器抛出的错误
412
+ */
413
+ Error = "error",
414
+ /**
415
+ * OfficeSDK 状态变化事件
416
+ */
417
+ ReadyState = "readyState",
418
+ /**
419
+ * 编辑器真正完成"首屏渲染"的信号。
420
+ *
421
+ * 由 iframe 内编辑器在自身渲染稳定后通过 channel 发送,SDK 侧转发为本事件。
422
+ * 宿主可按需监听它来区分 SDK Ready 与编辑器视觉首屏完成。
423
+ */
424
+ EditorRendered = "editorRendered",
425
+ /**
426
+ * 编辑器事件
427
+ */
428
+ EditorEvent = "editorEvent"
429
+ }
430
+ /**
431
+ * iframe 内侧用来上报"编辑器已完成首屏渲染"的 channel 事件名。
432
+ *
433
+ * 与 `InvokeMethod.ReadyState` 的枚举值保持在同一命名空间,但不入 shared 包,
434
+ * 以免跨端版本耦合。iframe 侧约定写字符串即可。
435
+ */
436
+ export declare const EDITOR_RENDERED_EVENT = "editorRendered";
437
+ export interface Message {
438
+ uuid?: string;
439
+ event: string;
440
+ body: any;
441
+ error?: Error;
442
+ }
443
+ export interface MessageEventPayload {
444
+ event: InvokeMethod;
445
+ data: unknown[];
446
+ }
447
+ export interface ContainerMethodPayload {
448
+ method: ContainerMethod;
449
+ args: unknown[];
450
+ }
451
+ export interface ReadyStateEvent {
452
+ state: ReadyState;
453
+ fileType: FileType;
454
+ error?: Error | string;
455
+ }
456
+ /**
457
+ * 事件回调函数
458
+ */
459
+ export type EventCallback = (...args: any[]) => any;
460
+ /**
461
+ * SDK toast 文案配置,值仅允许字符串或嵌套对象。
462
+ */
463
+ export interface SDKToastOptions {
464
+ [key: string]: string | SDKToastOptions | undefined;
465
+ }
466
+ /**
467
+ * 透传给 iframe 编辑器的主题配置。
468
+ * 当前 shimo-js-sdk 仅负责跨 iframe 传输,不在宿主侧约束字段细节。
469
+ */
470
+ export interface CommonThemeConfig {
471
+ [key: string]: unknown;
472
+ }
473
+ /**
474
+ * iframe 内置加载页配置,只支持可序列化字段。
475
+ */
476
+ export interface LoadingOptions {
477
+ /**
478
+ * 自定义加载页 Logo。传字符串时作为图片 URL / dataURL 使用;
479
+ * 传 false 时隐藏 Logo;不传时使用 iframe 内默认石墨 Logo。
480
+ */
481
+ logo?: string | false;
482
+ /**
483
+ * 自定义加载页提示文案。不传时使用 iframe 内默认文案。
484
+ */
485
+ tip?: string;
486
+ }
487
+ /**
488
+ * OfficeSDK 初始化参数
489
+ */
490
+ export interface OfficeSDKOptions extends Omit<ContainerMethods, 'getContainerRect'> {
491
+ /**
492
+ * 石墨 SDK 服务器地址
493
+ */
494
+ endpoint: string;
495
+ /**
496
+ * 您要打开的文档 ID
497
+ */
498
+ fileId: string;
499
+ /**
500
+ * 用于石墨 SDK 鉴权用的签名
501
+ */
502
+ signature: string;
503
+ /**
504
+ * iframe 挂载的目标容器
505
+ */
506
+ container: HTMLElement;
507
+ /**
508
+ * 用于您系统鉴权使用的 token
509
+ */
510
+ token: string;
511
+ /**
512
+ * 刷新鉴权信息的间隔时间,单位为毫秒
513
+ */
514
+ refreshCredentialsInterval: number;
515
+ /**
516
+ * 添加到 iframe URLSearchParams 的参数列表
517
+ */
518
+ params?: {
519
+ [key: string]: string;
520
+ };
521
+ /**
522
+ * 当前打开模式。`preview` 用于预览态,其余场景默认按 `edit` 处理。
523
+ */
524
+ mode?: 'edit' | 'preview';
525
+ /**
526
+ * 石墨 SDK URL 参数 url?smParams={params},用于传递石墨 SDK 内部需要的参数。
527
+ */
528
+ smParams?: string | Record<string, unknown> | Array<string | Record<string, unknown>>;
529
+ /**
530
+ * 指定石墨 SDK 编辑器界面语言,添加到 iframe URLSearchParams 的参数列表。
531
+ * 若未指定,则 iframe 使用服务器设置的默认语言。
532
+ *
533
+ * 目前支持的标准语言取值:
534
+ * 1. zh-CN(简体中文)
535
+ * 2. zh-TW(繁体中文)
536
+ * 3. en-US(英文)
537
+ * 4. ja-JP(日文)
538
+ * 5. ko-KR(韩文)
539
+ * 6. es-ES(西班牙语)
540
+ * 7. pt-PT(葡萄牙语)
541
+ * 8. de-DE(德语)
542
+ * 9. fr-FR(法语)
543
+ * 10. it-IT(意大利语)
544
+ * 11. ru-RU(俄语)
545
+ * 12. id-ID(印尼语)
546
+ * 13. vi-VN(越南语)
547
+ * 14. th-TH(泰语)
548
+ * 15. ms-MY(马来语)
549
+ * 16. ar-SA(阿拉伯语)
550
+ *
551
+ * 为兼容旧版写法,仍接受 en、ja,传入后会自动映射为 en-US、ja-JP。
552
+ */
553
+ lang?: 'zh-CN' | 'zh-TW' | 'en-US' | 'ja-JP' | 'ko-KR' | 'es-ES' | 'pt-PT' | 'de-DE' | 'fr-FR' | 'it-IT' | 'ru-RU' | 'id-ID' | 'vi-VN' | 'th-TH' | 'ms-MY' | 'ar-SA' | 'en' | 'ja';
554
+ /**
555
+ * 是否禁用提及的浮动卡片组件
556
+ */
557
+ disableMentionCards?: DisableMentionCards;
558
+ /**
559
+ * 用于覆盖编辑器内部分 toast 文案。
560
+ * 支持套件类型:form、documentPro、presentation、spreadsheet、table(仅对支持 ui 配置的套件生效)。
561
+ * 当前已文档化支持字段:ui.toast.tips.edit.noPermission。
562
+ * 其他字段暂不作为稳定公共 API 承诺。
563
+ */
564
+ ui?: {
565
+ toast?: SDKToastOptions;
566
+ };
567
+ /**
568
+ * 用于控制 iframe feature policy (https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Feature-Policy) 。
569
+ * 会覆盖默认的 policy,因此使用时需要注意把需要的 policy 写完整。
570
+ */
571
+ allowPolicy?: string;
572
+ /**
573
+ * 是否开启调试模式,true 会通过 console 打印一些信息
574
+ */
575
+ debug?: boolean;
576
+ /**
577
+ * 编辑器插件配置,不是所有类型的套件都支持,以套件是否提供 PluginOptions 为准
578
+ */
579
+ plugins?: Spreadsheet.PluginOptions | Table.PluginOptions;
580
+ /**
581
+ * iframe postMessage 的目标 origin,默认是当前页面的 location.origin。
582
+ * @deprecated
583
+ */
584
+ targetOrigin?: string;
585
+ /**
586
+ * 使用什么设备类型模式,会直接影响功能和样式,不传值或空字符串则默认用 user-agent 自动判断。受版本限制,不是所有类型都支持。
587
+ */
588
+ deviceMode?: DeviceMode;
589
+ /**
590
+ * 是否禁用默认的签名组件,以支持自定义签名组件。受版本限制,部分版本的特定类型文档才支持。
591
+ */
592
+ disableSignatureComponent?: boolean;
593
+ /**
594
+ * 控制 headerbar 组件是否展示,false 表示隐藏。
595
+ */
596
+ headerBarsVisible?: boolean;
597
+ /**
598
+ * 是否隐藏 iframe 内 AI 入口。
599
+ * 对应 iframe 内 ShimoSDK 的现有 AI 入口开关能力。
600
+ */
601
+ disableAiEntry?: boolean;
602
+ /**
603
+ * 编辑器主题配置。
604
+ * 该参数会透传到 iframe 内各套件初始化链路;未传时保持 iframe 默认主题。
605
+ */
606
+ theme?: CommonThemeConfig;
607
+ /**
608
+ * docs 斜杠菜单配置。
609
+ * 仅 docs 文件类型生效;`button.callback` 实际运行在宿主页,
610
+ * 会在 iframe 内点击菜单按钮后通过 postMessage/channel 回调触发。
611
+ */
612
+ slashMenu?: SlashMenuOptions;
613
+ /**
614
+ * 是否显示内置的加载动画,只在静态资源加载到编辑器渲染这个阶段显示
615
+ */
616
+ showLoadingEffect?: boolean;
617
+ /**
618
+ * 是否启用 iframe 内置默认加载页,默认 false。
619
+ * 隐藏后接入方可自定义外部 loading。
620
+ */
621
+ showLoading?: boolean;
622
+ /**
623
+ * iframe 内置加载页配置。仅在 `showLoading === true`
624
+ * 或 `showLoadingEffect === true` 时透传给 iframe。
625
+ */
626
+ loadingOptions?: LoadingOptions;
627
+ /**
628
+ * 用于在编辑器发起 API 请求时,对请求参数进行修改的函数。详细用法见文档。
629
+ */
630
+ apiAdaptor?: APIAdaptor;
631
+ /**
632
+ * 用于在编辑器发起 API 请求时,对请求参数进行修改的函数时传入的上下文数据。
633
+ */
634
+ apiAdaptorContext?: RequestContext;
635
+ /**
636
+ * 用于判断通信消息过期时间,过期后的消息会被抛弃,默认 5 分钟。
637
+ */
638
+ messageExpires?: number;
639
+ /**
640
+ * 加密后的用户id
641
+ */
642
+ userUuid?: string;
643
+ /**
644
+ * 缺省页(Empty Page)配置。
645
+ * - 不传或传 `true`:启用默认缺省页能力(有内置图片与默认文案,**无按钮**)
646
+ * - 传 `false`:完全关闭
647
+ * - 传对象:精细控制启用的 scene、token 过期策略,以及每个 scene 的
648
+ * 文案/按钮自定义(`overrides`)。默认不渲染任何按钮,宿主需要按钮时必须
649
+ * 在 `overrides[scene].primary/secondary` 里显式配置 label,点击统一触发
650
+ * `emptyPageAction` 事件由宿主处理。
651
+ *
652
+ * 相关事件:`emptyPageShown` / `emptyPageAction` / `emptyPageHidden`。
653
+ * 详见 `./types/EmptyPage.ts`。
654
+ */
655
+ emptyPage?: boolean | EmptyPageOptions;
656
+ }
@@ -0,0 +1,15 @@
1
+ import { FileType } from 'weboffice-js-sdk-shared';
2
+ import type { OfficeSDKRootFacadeState } from './OfficeSDK.facade.types';
3
+ type EditorFacadeCallback = (...args: unknown[]) => unknown | Promise<unknown>;
4
+ interface FacadeHost {
5
+ fileType: FileType;
6
+ invokeEditorFacade<T>(method: string, args?: unknown[]): Promise<T>;
7
+ listenEditorEvent<T>(event: string, listener: (payload: T) => void): () => void;
8
+ createEditorFacadeModule<T extends object>(prefix: string, staticFields?: Partial<T>): T;
9
+ createValueObjectFacade<T extends object>(prefix: string, locator: Record<string, unknown>, staticFields: Partial<T>): T;
10
+ registerEditorFacadeListener<T>(method: string, listener: (payload: T) => void): () => void;
11
+ registerEditorFacadeCallback(callback: EditorFacadeCallback): string;
12
+ unregisterEditorFacadeCallback(callbackId: string): void;
13
+ }
14
+ export declare function buildRootFacadeState(host: FacadeHost): OfficeSDKRootFacadeState;
15
+ export {};