weboffice-js-sdk 2.0.5-beta.14 → 2.0.5-beta.16
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 +15 -1
- package/dist/OfficeSDK.facade.types.d.ts +0 -5
- package/dist/OfficeSDK.methods.d.ts +67 -0
- package/dist/connect.d.ts +19 -0
- package/dist/editorFacade.contract.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -2
- package/dist/jsapi/index.d.ts +1 -0
- package/dist/jsapi/public-methods.d.ts +15 -0
- package/dist/preload.d.ts +13 -0
- package/dist/types/ConnectV2.d.ts +21 -0
- package/package.json +2 -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,9 @@ 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 { ContentVersion } from './types/ConnectV2';
|
|
12
13
|
import type { CollaboratorFacade, CommentsFacade, ContentFacade, DiscussionFacade, DocsActiveOutlineFacade, 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';
|
|
14
|
+
import type { OfficeSDKMethodPath } from './OfficeSDK.methods';
|
|
13
15
|
import type { HeaderBarsFacade } from './OfficeSDK.headerBars';
|
|
14
16
|
export * from './OfficeSDK.facade.types';
|
|
15
17
|
export * from './OfficeSDK.headerBars';
|
|
@@ -39,6 +41,10 @@ export declare class OfficeSDK extends TinyEmitter {
|
|
|
39
41
|
spreadsheet?: Spreadsheet.Editor;
|
|
40
42
|
/** 当前轻文档的标准化、强类型文档入口。 */
|
|
41
43
|
ActiveOutline?: DocsActiveOutlineFacade;
|
|
44
|
+
/**
|
|
45
|
+
* 判断当前套件和 iframe runtime 是否支持指定的公开 SDK 方法。
|
|
46
|
+
*/
|
|
47
|
+
canIUse(method: OfficeSDKMethodPath): Promise<boolean>;
|
|
42
48
|
/**
|
|
43
49
|
* 当前套件支持的标题能力。
|
|
44
50
|
*/
|
|
@@ -180,6 +186,7 @@ export declare class OfficeSDK extends TinyEmitter {
|
|
|
180
186
|
private readonly emitter;
|
|
181
187
|
private channel;
|
|
182
188
|
private readonly connectOptions;
|
|
189
|
+
private readonly contentVersion?;
|
|
183
190
|
private _readyState;
|
|
184
191
|
private editor;
|
|
185
192
|
private readonly startParams;
|
|
@@ -211,10 +218,15 @@ export declare class OfficeSDK extends TinyEmitter {
|
|
|
211
218
|
* 归一化后的缺省页配置,构造时一次算完,后续仅读取。
|
|
212
219
|
*/
|
|
213
220
|
private readonly normalizedEmptyPage;
|
|
221
|
+
private readonly preloadCredentialsMessageHandler;
|
|
222
|
+
private pendingInitializationErrorHandler?;
|
|
223
|
+
private pendingInitializationError?;
|
|
224
|
+
private preloadCredentialsPromise?;
|
|
225
|
+
private disconnected;
|
|
214
226
|
private readonly preloadAckTimeoutMs;
|
|
215
227
|
private readonly preloadDoneTimeoutMs;
|
|
216
228
|
private readonly preloadReadyTimeoutMs;
|
|
217
|
-
constructor(options: OfficeSDKOptions);
|
|
229
|
+
constructor(options: OfficeSDKOptions, contentVersion?: ContentVersion);
|
|
218
230
|
get fileType(): FileType;
|
|
219
231
|
get readyState(): ReadyState;
|
|
220
232
|
/**
|
|
@@ -283,6 +295,8 @@ export declare class OfficeSDK extends TinyEmitter {
|
|
|
283
295
|
*/
|
|
284
296
|
ready(): Promise<void>;
|
|
285
297
|
private initIframe;
|
|
298
|
+
private handlePreloadMessage;
|
|
299
|
+
private getPreloadCredentials;
|
|
286
300
|
private runPreloadHandshake;
|
|
287
301
|
private initChannel;
|
|
288
302
|
/**
|
|
@@ -52,15 +52,10 @@ export interface DocsProductEditorFacade {
|
|
|
52
52
|
}
|
|
53
53
|
export interface DocsActiveOutlineFacade {
|
|
54
54
|
Editor: DocsProductEditorFacade;
|
|
55
|
-
Reference: DocsProductReferenceFacade;
|
|
56
55
|
Service: DocsProductServiceFacade;
|
|
57
56
|
Sub: DocsProductSubFacade;
|
|
58
57
|
Env: DocsProductEnvFacade;
|
|
59
58
|
}
|
|
60
|
-
/** 轻文档产品引用能力。 */
|
|
61
|
-
export interface DocsProductReferenceFacade {
|
|
62
|
-
CanIUse: (scopes: string | string[]) => Promise<boolean>;
|
|
63
|
-
}
|
|
64
59
|
export interface DocsProductUserFacade {
|
|
65
60
|
GetUserInfo: () => Promise<unknown>;
|
|
66
61
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK capability method identifiers.
|
|
3
|
+
*
|
|
4
|
+
* Values are public SDK method paths. Keeping the object tree aligned with the
|
|
5
|
+
* public facade makes the accepted canIUse arguments discoverable without
|
|
6
|
+
* exposing product-specific API namespaces.
|
|
7
|
+
*/
|
|
8
|
+
export declare const OfficeSDKMethods: {
|
|
9
|
+
readonly ActiveOutline: {
|
|
10
|
+
readonly Editor: {
|
|
11
|
+
readonly GetEditMode: "ActiveOutline.Editor.GetEditMode";
|
|
12
|
+
readonly Document: {
|
|
13
|
+
readonly GetContent: "ActiveOutline.Editor.Document.GetContent";
|
|
14
|
+
readonly GetTitleContent: "ActiveOutline.Editor.Document.GetTitleContent";
|
|
15
|
+
readonly SetTitleContent: "ActiveOutline.Editor.Document.SetTitleContent";
|
|
16
|
+
readonly Font: {
|
|
17
|
+
readonly SetTextColor: "ActiveOutline.Editor.Document.Font.SetTextColor";
|
|
18
|
+
readonly SetHighLightColor: "ActiveOutline.Editor.Document.Font.SetHighLightColor";
|
|
19
|
+
readonly SetBold: "ActiveOutline.Editor.Document.Font.SetBold";
|
|
20
|
+
readonly SetItalic: "ActiveOutline.Editor.Document.Font.SetItalic";
|
|
21
|
+
readonly SetUnderline: "ActiveOutline.Editor.Document.Font.SetUnderline";
|
|
22
|
+
readonly SetStrike: "ActiveOutline.Editor.Document.Font.SetStrike";
|
|
23
|
+
};
|
|
24
|
+
readonly Markdown: {
|
|
25
|
+
readonly GetMarkdown: "ActiveOutline.Editor.Document.Markdown.GetMarkdown";
|
|
26
|
+
readonly AppendMarkdown: "ActiveOutline.Editor.Document.Markdown.AppendMarkdown";
|
|
27
|
+
readonly InsertMarkdown: "ActiveOutline.Editor.Document.Markdown.InsertMarkdown";
|
|
28
|
+
readonly ValidateMarkdown: "ActiveOutline.Editor.Document.Markdown.ValidateMarkdown";
|
|
29
|
+
};
|
|
30
|
+
readonly Content: {
|
|
31
|
+
readonly ReplaceSelection: "ActiveOutline.Editor.Document.Content.ReplaceSelection";
|
|
32
|
+
readonly ReplaceAllContent: "ActiveOutline.Editor.Document.Content.ReplaceAllContent";
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
readonly Service: {
|
|
37
|
+
readonly User: {
|
|
38
|
+
readonly GetUserInfo: "ActiveOutline.Service.User.GetUserInfo";
|
|
39
|
+
};
|
|
40
|
+
readonly Permission: {
|
|
41
|
+
readonly GetDocumentPermission: "ActiveOutline.Service.Permission.GetDocumentPermission";
|
|
42
|
+
};
|
|
43
|
+
readonly Export: {
|
|
44
|
+
readonly DownloadDocument: "ActiveOutline.Service.Export.DownloadDocument";
|
|
45
|
+
};
|
|
46
|
+
readonly Collaboration: {
|
|
47
|
+
readonly GetSaveStatus: "ActiveOutline.Service.Collaboration.GetSaveStatus";
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
readonly Env: {
|
|
51
|
+
readonly Language: {
|
|
52
|
+
readonly GetLanguage: "ActiveOutline.Env.Language.GetLanguage";
|
|
53
|
+
};
|
|
54
|
+
readonly DocsMode: {
|
|
55
|
+
readonly GetDocsMode: "ActiveOutline.Env.DocsMode.GetDocsMode";
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
readonly Sub: {
|
|
59
|
+
readonly OnDocumentChange: "ActiveOutline.Sub.OnDocumentChange";
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
type LeafValues<T> = T extends string ? T : T extends object ? {
|
|
64
|
+
[K in keyof T]: LeafValues<T[K]>;
|
|
65
|
+
}[keyof T] : never;
|
|
66
|
+
export type OfficeSDKMethodPath = LeafValues<typeof OfficeSDKMethods>;
|
|
67
|
+
export {};
|
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,5 @@
|
|
|
1
1
|
import type { AddChartFromSelectionResult, BasicPresentationFacade, DocsActiveOutlineFacade, DocsEditorDeltaSnapshot, DocsRangeFacade, DocsRangeValue, DocsTableFacade, EditorTextFormat, OfficeSDK, PresentationFacade, PresentationSlideFacade, PresentationShape, PresentationShapeBase, PresentationTableCell, PresentationTableItem, PresentationTableRange, PresentationTableSelection, PresentationTextShape, PresentationTextRangeFacade, PresentationTextRangeValue, SheetRangeValue, SheetRangeFacade, SheetSelection } from './OfficeSDK';
|
|
2
|
+
import type { OfficeSDKMethodPath } from './OfficeSDK.methods';
|
|
2
3
|
type IsAssignable<T, U> = T extends U ? true : false;
|
|
3
4
|
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
5
|
type Assert<T extends true> = T;
|
|
@@ -11,6 +12,7 @@ type PresentationSelection = Extract<RootSelection, {
|
|
|
11
12
|
}>;
|
|
12
13
|
type RootPresentation = NonNullable<OfficeSDK['presentation']>;
|
|
13
14
|
export type EditorFacadeContractAssertions = [
|
|
15
|
+
Assert<IsEqual<OfficeSDK['canIUse'], (method: OfficeSDKMethodPath) => Promise<boolean>>>,
|
|
14
16
|
Assert<IsEqual<NonNullable<OfficeSDK['ActiveOutline']>, DocsActiveOutlineFacade>>,
|
|
15
17
|
Assert<IsEqual<DocsActiveOutlineFacade['Editor']['Document']['GetContent'], () => Promise<DocsEditorDeltaSnapshot>>>,
|
|
16
18
|
Assert<IsEqual<DocsActiveOutlineFacade['Editor']['Document']['Markdown']['AppendMarkdown'], (value: string) => Promise<DocsRangeValue>>>,
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * from 'weboffice-js-sdk-shared';
|
|
|
10
10
|
export * from './connect';
|
|
11
11
|
export type { JSAPIAdapter, JSAPIContract, JSAPIContractCatalog, JSAPITransport } from './jsapi';
|
|
12
12
|
export * from './OfficeSDK';
|
|
13
|
+
export * from './OfficeSDK.methods';
|
|
13
14
|
export type { EmptyPageScene, EmptyPageOptions, EmptyPageActionOverride, EmptyPageContentOverride, NormalizedEmptyPageOptions, EmptyPageShownPayload, EmptyPageActionPayload, EmptyPageHiddenPayload, FileOpenFailedReason, TokenExpiredStrategy } from './types/EmptyPage';
|
|
14
15
|
export type { SlashMenuButton, SlashMenuEntry, SlashMenuOptions } from './types/SlashMenu';
|
|
15
16
|
export { ALL_EMPTY_PAGE_SCENES, normalizeEmptyPageOptions } from './types/EmptyPage';
|