weboffice-js-sdk 2.0.5-beta.10 → 2.0.5-beta.12
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.
- package/README.md +21 -0
- package/dist/OfficeSDK.d.ts +11 -5
- package/dist/OfficeSDK.facade.d.ts +0 -1
- package/dist/OfficeSDK.facade.types.d.ts +0 -90
- package/dist/connect.d.ts +19 -0
- package/dist/editorFacade.contract.d.ts +1 -7
- package/dist/index.d.ts +0 -1
- package/dist/index.js +2 -2
- package/dist/preload.d.ts +13 -0
- package/dist/types/ConnectV2.d.ts +21 -0
- package/package.json +4 -6
- package/dist/jsapi/contract.d.ts +0 -22
- package/dist/jsapi/index.d.ts +0 -3
- package/dist/jsapi/light-doc-p0.contract.d.ts +0 -2
package/README.md
CHANGED
|
@@ -47,6 +47,27 @@ connect({
|
|
|
47
47
|
- `disableAiEntry` 为可选布尔值,透传到 iframe 内 `OfficeSDK` 的 AI 入口开关能力。
|
|
48
48
|
- `theme` 为可选主题对象,宿主侧仅负责透传;未传时 iframe 内仍使用默认主题配置。
|
|
49
49
|
|
|
50
|
+
### V2 统一编辑 / 预览入口
|
|
51
|
+
|
|
52
|
+
V2 使用独立的 `connectV2()`,旧 `connect()` 保持兼容。V2 要求 `type` 和 `mode` 必填:
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
import { connectV2 } from 'weboffice-js-sdk'
|
|
56
|
+
|
|
57
|
+
const sdk = await connectV2({
|
|
58
|
+
fileId: 'your-file-id',
|
|
59
|
+
endpoint: 'https://your-shimo-endpoint',
|
|
60
|
+
signature: 'your-signature',
|
|
61
|
+
token: 'your-token',
|
|
62
|
+
container: document.querySelector('#shimo-file'),
|
|
63
|
+
type: 'writer',
|
|
64
|
+
mode: 'edit',
|
|
65
|
+
refreshCredentialsInterval: 600000
|
|
66
|
+
})
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
支持的 `type` 包括 `file`、`document`、`documentPro`、`writer`、`spreadsheet`、`presentation`、`table` 和 `form`。`writer` 与 `documentPro` 当前共存,`writer` 目前处于内测阶段。当前 `type` 主要作为 iframe 后续基于 `manifest.json` 选择资源的预留字段,不改变后端编辑准备判断。
|
|
70
|
+
|
|
50
71
|
返回值:
|
|
51
72
|
|
|
52
73
|
```
|
package/dist/OfficeSDK.d.ts
CHANGED
|
@@ -9,7 +9,8 @@ import { Document, DocumentPro, Presentation, Spreadsheet, Table, Form, Flowchar
|
|
|
9
9
|
import { EmptyPageOptions } from './types/EmptyPage';
|
|
10
10
|
import { BaseEditor } from './types/BaseEditor';
|
|
11
11
|
import { SlashMenuOptions } from './types/SlashMenu';
|
|
12
|
-
import type {
|
|
12
|
+
import type { ContentVersion } from './types/ConnectV2';
|
|
13
|
+
import type { CollaboratorFacade, CommentsFacade, ContentFacade, DiscussionFacade, DocsOutlineFacade, DocsSearchFacade, DocsSelectionFacade, DocsSettingsFacade, DocsSidebarFacade, DocsTablesFacade, ExternalAppFacade, HistoryFacade, LocksFacade, MentionFacade, OfficeSDKPresentationFacade, PresentationEventSubscriptionFacade, PresentationSelectionFacade, PresentationSlidesFacade, PresentationTextFacade, PresentationZoomFacade, SheetChartsFacade, SheetSelectionsFacade, SheetWorkbookFacade, SheetWorksheetFacade, TitleFacade, VersionFacade } from './OfficeSDK.facade.types';
|
|
13
14
|
import type { HeaderBarsFacade } from './OfficeSDK.headerBars';
|
|
14
15
|
export * from './OfficeSDK.facade.types';
|
|
15
16
|
export * from './OfficeSDK.headerBars';
|
|
@@ -36,8 +37,6 @@ export declare class OfficeSDK extends TinyEmitter {
|
|
|
36
37
|
* @deprecated - 用 `sdk.getEditor<T>()` 替代
|
|
37
38
|
*/
|
|
38
39
|
spreadsheet?: Spreadsheet.Editor;
|
|
39
|
-
/** 当前轻文档的标准化、强类型文档入口。 */
|
|
40
|
-
ActiveDocument?: DocsActiveDocumentFacade;
|
|
41
40
|
/**
|
|
42
41
|
* 当前套件支持的标题能力。
|
|
43
42
|
*/
|
|
@@ -179,6 +178,7 @@ export declare class OfficeSDK extends TinyEmitter {
|
|
|
179
178
|
private readonly emitter;
|
|
180
179
|
private channel;
|
|
181
180
|
private readonly connectOptions;
|
|
181
|
+
private readonly contentVersion?;
|
|
182
182
|
private _readyState;
|
|
183
183
|
private editor;
|
|
184
184
|
private readonly startParams;
|
|
@@ -208,10 +208,15 @@ export declare class OfficeSDK extends TinyEmitter {
|
|
|
208
208
|
* 归一化后的缺省页配置,构造时一次算完,后续仅读取。
|
|
209
209
|
*/
|
|
210
210
|
private readonly normalizedEmptyPage;
|
|
211
|
+
private readonly preloadCredentialsMessageHandler;
|
|
212
|
+
private pendingInitializationErrorHandler?;
|
|
213
|
+
private pendingInitializationError?;
|
|
214
|
+
private preloadCredentialsPromise?;
|
|
215
|
+
private disconnected;
|
|
211
216
|
private readonly preloadAckTimeoutMs;
|
|
212
217
|
private readonly preloadDoneTimeoutMs;
|
|
213
218
|
private readonly preloadReadyTimeoutMs;
|
|
214
|
-
constructor(options: OfficeSDKOptions);
|
|
219
|
+
constructor(options: OfficeSDKOptions, contentVersion?: ContentVersion);
|
|
215
220
|
get fileType(): FileType;
|
|
216
221
|
get readyState(): ReadyState;
|
|
217
222
|
/**
|
|
@@ -280,6 +285,8 @@ export declare class OfficeSDK extends TinyEmitter {
|
|
|
280
285
|
*/
|
|
281
286
|
ready(): Promise<void>;
|
|
282
287
|
private initIframe;
|
|
288
|
+
private handlePreloadMessage;
|
|
289
|
+
private getPreloadCredentials;
|
|
283
290
|
private runPreloadHandshake;
|
|
284
291
|
private initChannel;
|
|
285
292
|
/**
|
|
@@ -312,7 +319,6 @@ export declare class OfficeSDK extends TinyEmitter {
|
|
|
312
319
|
* 输出:无。
|
|
313
320
|
*/
|
|
314
321
|
private unregisterEditorFacadeCallback;
|
|
315
|
-
private reportEditorFacadeError;
|
|
316
322
|
/**
|
|
317
323
|
* 创建基于 method-path 的模块 facade。
|
|
318
324
|
* 输入:模块前缀与少量自定义实现覆盖。
|
|
@@ -10,7 +10,6 @@ interface FacadeHost {
|
|
|
10
10
|
registerEditorFacadeListener<T>(method: string, listener: (payload: T) => void): () => void;
|
|
11
11
|
registerEditorFacadeCallback(callback: EditorFacadeCallback): string;
|
|
12
12
|
unregisterEditorFacadeCallback(callbackId: string): void;
|
|
13
|
-
reportEditorFacadeError(message: string, error: unknown): void;
|
|
14
13
|
}
|
|
15
14
|
export declare function buildRootFacadeState(host: FacadeHost): OfficeSDKRootFacadeState;
|
|
16
15
|
export {};
|
|
@@ -3,95 +3,6 @@ export interface TitleFacade {
|
|
|
3
3
|
addChangedListener: (listener: (title: string) => void) => () => void;
|
|
4
4
|
setTitle: (title: string) => Promise<void>;
|
|
5
5
|
}
|
|
6
|
-
/**
|
|
7
|
-
* 可安全跨 iframe 传输的文档 Delta 快照。
|
|
8
|
-
*
|
|
9
|
-
* 这里只公开序列化结果和基础元数据,不承诺编辑器运行时对象上的
|
|
10
|
-
* compose / transform 等方法。
|
|
11
|
-
*/
|
|
12
|
-
export interface DocsEditorDeltaSnapshot {
|
|
13
|
-
length: number;
|
|
14
|
-
serialized: string;
|
|
15
|
-
stringify: () => string;
|
|
16
|
-
}
|
|
17
|
-
export interface DocsDocumentPermission {
|
|
18
|
-
read: boolean;
|
|
19
|
-
write: boolean;
|
|
20
|
-
comment: boolean;
|
|
21
|
-
}
|
|
22
|
-
export type DocsDownloadDocumentType = 'pdf' | 'word' | 'image' | 'md';
|
|
23
|
-
export interface DocsProductFontFacade {
|
|
24
|
-
SetTextColor: (color: string) => Promise<boolean>;
|
|
25
|
-
SetHighLightColor: (color: string) => Promise<boolean>;
|
|
26
|
-
SetBold: (value?: boolean) => Promise<boolean>;
|
|
27
|
-
SetItalic: (value?: boolean) => Promise<boolean>;
|
|
28
|
-
SetUnderline: (value?: boolean) => Promise<boolean>;
|
|
29
|
-
SetStrike: (value?: boolean) => Promise<boolean>;
|
|
30
|
-
}
|
|
31
|
-
export interface DocsProductMarkdownFacade {
|
|
32
|
-
GetMarkdown: () => Promise<string>;
|
|
33
|
-
AppendMarkdown: (value: string) => Promise<DocsRangeValue>;
|
|
34
|
-
InsertMarkdown: (value: string) => Promise<DocsRangeValue>;
|
|
35
|
-
ValidateMarkdown: (value: string) => Promise<boolean>;
|
|
36
|
-
}
|
|
37
|
-
export interface DocsProductContentFacade {
|
|
38
|
-
ReplaceSelection: (value: string) => Promise<boolean>;
|
|
39
|
-
ReplaceAllContent: (value: string) => Promise<boolean>;
|
|
40
|
-
}
|
|
41
|
-
export interface DocsProductDocumentFacade {
|
|
42
|
-
GetContent: () => Promise<DocsEditorDeltaSnapshot>;
|
|
43
|
-
GetTitleContent: () => Promise<string>;
|
|
44
|
-
SetTitleContent: (title: string) => Promise<void>;
|
|
45
|
-
Font: DocsProductFontFacade;
|
|
46
|
-
Markdown: DocsProductMarkdownFacade;
|
|
47
|
-
Content: DocsProductContentFacade;
|
|
48
|
-
}
|
|
49
|
-
export interface DocsProductEditorFacade {
|
|
50
|
-
GetEditMode: () => Promise<string>;
|
|
51
|
-
Document: DocsProductDocumentFacade;
|
|
52
|
-
}
|
|
53
|
-
export interface DocsActiveDocumentFacade {
|
|
54
|
-
Editor: DocsProductEditorFacade;
|
|
55
|
-
Reference: DocsProductReferenceFacade;
|
|
56
|
-
Service: DocsProductServiceFacade;
|
|
57
|
-
Sub: DocsProductSubFacade;
|
|
58
|
-
Env: DocsProductEnvFacade;
|
|
59
|
-
}
|
|
60
|
-
/** 轻文档产品引用能力。 */
|
|
61
|
-
export interface DocsProductReferenceFacade {
|
|
62
|
-
CanIUse: (scopes: string | string[]) => Promise<boolean>;
|
|
63
|
-
}
|
|
64
|
-
export interface DocsProductUserFacade {
|
|
65
|
-
GetUserInfo: () => Promise<unknown>;
|
|
66
|
-
}
|
|
67
|
-
export interface DocsProductPermissionFacade {
|
|
68
|
-
GetDocumentPermission: () => Promise<DocsDocumentPermission>;
|
|
69
|
-
}
|
|
70
|
-
export interface DocsProductExportFacade {
|
|
71
|
-
DownloadDocument: (format: DocsDownloadDocumentType) => Promise<void>;
|
|
72
|
-
}
|
|
73
|
-
export interface DocsProductCollaborationFacade {
|
|
74
|
-
GetSaveStatus: () => Promise<unknown>;
|
|
75
|
-
}
|
|
76
|
-
export interface DocsProductServiceFacade {
|
|
77
|
-
User: DocsProductUserFacade;
|
|
78
|
-
Permission: DocsProductPermissionFacade;
|
|
79
|
-
Export: DocsProductExportFacade;
|
|
80
|
-
Collaboration: DocsProductCollaborationFacade;
|
|
81
|
-
}
|
|
82
|
-
export interface DocsProductSubFacade {
|
|
83
|
-
OnDocumentChange: (handler: (delta: DocsEditorDeltaSnapshot) => void) => () => void;
|
|
84
|
-
}
|
|
85
|
-
export interface DocsProductLanguageFacade {
|
|
86
|
-
GetLanguage: () => Promise<string>;
|
|
87
|
-
}
|
|
88
|
-
export interface DocsProductModeFacade {
|
|
89
|
-
GetDocsMode: () => Promise<string>;
|
|
90
|
-
}
|
|
91
|
-
export interface DocsProductEnvFacade {
|
|
92
|
-
Language: DocsProductLanguageFacade;
|
|
93
|
-
DocsMode: DocsProductModeFacade;
|
|
94
|
-
}
|
|
95
6
|
export interface CommentsFacade {
|
|
96
7
|
show: (type?: 'list' | 'card') => Promise<void>;
|
|
97
8
|
hide: (type?: 'list' | 'card') => Promise<void>;
|
|
@@ -919,7 +830,6 @@ export interface PresentationEventSubscriptionFacade {
|
|
|
919
830
|
addLoadedListener: (listener: () => void) => () => void;
|
|
920
831
|
}
|
|
921
832
|
export interface OfficeSDKRootFacadeState {
|
|
922
|
-
ActiveDocument?: DocsActiveDocumentFacade;
|
|
923
833
|
title?: TitleFacade;
|
|
924
834
|
history?: HistoryFacade;
|
|
925
835
|
comments?: CommentsFacade;
|
package/dist/connect.d.ts
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import { OfficeSDK, OfficeSDKOptions } from './OfficeSDK';
|
|
2
|
+
import { type ConnectV2FileType } from './types/ConnectV2';
|
|
3
|
+
export { CONNECT_V2_FILE_TYPES, isConnectV2FileType, isConnectV2Mode, validateConnectV2Options } from './types/ConnectV2';
|
|
4
|
+
export type { ConnectV2FileType } from './types/ConnectV2';
|
|
2
5
|
export interface ConnectOptions extends OfficeSDKOptions {
|
|
3
6
|
}
|
|
7
|
+
export interface ConnectV2Options extends ConnectOptions {
|
|
8
|
+
/**
|
|
9
|
+
* V2 套件类型。当前用于 iframe 侧资源选择预留。
|
|
10
|
+
*/
|
|
11
|
+
type: ConnectV2FileType;
|
|
12
|
+
/**
|
|
13
|
+
* V2 打开模式。
|
|
14
|
+
*/
|
|
15
|
+
mode: 'edit' | 'preview';
|
|
16
|
+
}
|
|
4
17
|
/**
|
|
5
18
|
* 初始化 SDK,返回 Promise,当 ReadState 变为 Ready 或 Failed 时,Promise 将被 resolve。
|
|
6
19
|
* Promise resovled 不代表编辑器已经完整加载完毕,只代表 SDK 已经准备好了。
|
|
@@ -8,3 +21,9 @@ export interface ConnectOptions extends OfficeSDKOptions {
|
|
|
8
21
|
* 比如受浏览器限制无法发出 postMessage() 时,Promise 将会一直 pending。
|
|
9
22
|
*/
|
|
10
23
|
export declare function connect(options: ConnectOptions): Promise<OfficeSDK>;
|
|
24
|
+
/**
|
|
25
|
+
* 初始化 V2 统一编辑 / 预览入口。
|
|
26
|
+
*
|
|
27
|
+
* V2 在运行时强制校验 type 和 mode,底层 iframe 初始化流程与旧 connect 共用。
|
|
28
|
+
*/
|
|
29
|
+
export declare function connectV2(options: ConnectV2Options): Promise<OfficeSDK>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AddChartFromSelectionResult, BasicPresentationFacade,
|
|
1
|
+
import type { AddChartFromSelectionResult, BasicPresentationFacade, DocsRangeFacade, DocsRangeValue, DocsTableFacade, EditorTextFormat, OfficeSDK, PresentationFacade, PresentationSlideFacade, PresentationShape, PresentationShapeBase, PresentationTableCell, PresentationTableItem, PresentationTableRange, PresentationTableSelection, PresentationTextShape, PresentationTextRangeFacade, PresentationTextRangeValue, SheetRangeValue, SheetRangeFacade, SheetSelection } from './OfficeSDK';
|
|
2
2
|
type IsAssignable<T, U> = T extends U ? true : false;
|
|
3
3
|
type IsEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends <V>() => V extends U ? 1 : 2 ? (<V>() => V extends U ? 1 : 2) extends <V>() => V extends T ? 1 : 2 ? true : false : false;
|
|
4
4
|
type Assert<T extends true> = T;
|
|
@@ -11,12 +11,6 @@ type PresentationSelection = Extract<RootSelection, {
|
|
|
11
11
|
}>;
|
|
12
12
|
type RootPresentation = NonNullable<OfficeSDK['presentation']>;
|
|
13
13
|
export type EditorFacadeContractAssertions = [
|
|
14
|
-
Assert<IsEqual<NonNullable<OfficeSDK['ActiveDocument']>, DocsActiveDocumentFacade>>,
|
|
15
|
-
Assert<IsEqual<DocsActiveDocumentFacade['Editor']['Document']['GetContent'], () => Promise<DocsEditorDeltaSnapshot>>>,
|
|
16
|
-
Assert<IsEqual<DocsActiveDocumentFacade['Editor']['Document']['Markdown']['AppendMarkdown'], (value: string) => Promise<DocsRangeValue>>>,
|
|
17
|
-
Assert<IsEqual<DocsActiveDocumentFacade['Service']['Permission']['GetDocumentPermission'], () => Promise<import('./OfficeSDK').DocsDocumentPermission>>>,
|
|
18
|
-
Assert<IsEqual<DocsActiveDocumentFacade['Service']['Export']['DownloadDocument'], (format: import('./OfficeSDK').DocsDownloadDocumentType) => Promise<void>>>,
|
|
19
|
-
Assert<IsEqual<DocsActiveDocumentFacade['Sub']['OnDocumentChange'], (handler: (delta: DocsEditorDeltaSnapshot) => void) => () => void>>,
|
|
20
14
|
Assert<IsAssignable<NonNullable<OfficeSDK['title']>['setTitle'], (title: string) => Promise<void>>>,
|
|
21
15
|
Assert<IsAssignable<NonNullable<OfficeSDK['title']>['addChangedListener'], (listener: (title: string) => void) => () => void>>,
|
|
22
16
|
Assert<IsAssignable<NonNullable<OfficeSDK['locks']>['addRangeLock'], (options: import('./OfficeSDK').AddRangeLockParams) => Promise<void>>>,
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ import * as Flowchart from './types/FlowChart';
|
|
|
8
8
|
import { EventMap as BaseEventMap, BaseEditor } from './types/BaseEditor';
|
|
9
9
|
export * from 'weboffice-js-sdk-shared';
|
|
10
10
|
export * from './connect';
|
|
11
|
-
export type { JSAPIAdapter, JSAPIContract, JSAPIContractCatalog, JSAPITransport } from './jsapi';
|
|
12
11
|
export * from './OfficeSDK';
|
|
13
12
|
export type { EmptyPageScene, EmptyPageOptions, EmptyPageActionOverride, EmptyPageContentOverride, NormalizedEmptyPageOptions, EmptyPageShownPayload, EmptyPageActionPayload, EmptyPageHiddenPayload, FileOpenFailedReason, TokenExpiredStrategy } from './types/EmptyPage';
|
|
14
13
|
export type { SlashMenuButton, SlashMenuEntry, SlashMenuOptions } from './types/SlashMenu';
|