weboffice-js-sdk 2.0.2

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,168 @@
1
+ import { MouseMovePayload } from 'weboffice-js-sdk-shared';
2
+ import { BaseEditor, EventMap as BaseEventMap } from './BaseEditor';
3
+ export interface DocumentErrorMessage {
4
+ message: string;
5
+ }
6
+ export interface ExternalAppParams {
7
+ title?: string;
8
+ width?: number | string;
9
+ height?: number;
10
+ }
11
+ export interface EventMap extends BaseEventMap {
12
+ /**
13
+ * 标题发生变更
14
+ */
15
+ titleChange: string;
16
+ /**
17
+ * 鼠标移动事件
18
+ */
19
+ MouseMove: MouseMovePayload;
20
+ /**
21
+ * 垂直滚动事件
22
+ */
23
+ VerticalScroll: MouseMovePayload;
24
+ /**
25
+ * 水平滚动事件
26
+ */
27
+ HorizontalScroll: MouseMovePayload;
28
+ }
29
+ export interface Editor extends BaseEditor<EventMap> {
30
+ /**
31
+ * 显示历史侧边栏
32
+ * @since 22.2.1
33
+ */
34
+ showHistory: (options?: {}) => Promise<void>;
35
+ /**
36
+ * 隐藏历史侧边栏
37
+ * @since 22.2.1
38
+ */
39
+ hideHistory: (options?: {}) => Promise<void>;
40
+ /**
41
+ * 显示版本侧边栏
42
+ * @since 22.2.1
43
+ */
44
+ showRevision: (options?: {}) => Promise<void>;
45
+ /**
46
+ * 隐藏版本侧边栏
47
+ * @since 22.2.1
48
+ */
49
+ hideRevision: (options?: {}) => Promise<void>;
50
+ /**
51
+ * 显示讨论侧边栏
52
+ * @since 22.2.1
53
+ */
54
+ showDiscussion: (options?: {}) => Promise<void>;
55
+ /**
56
+ * 隐藏讨论侧边栏
57
+ * @since 22.2.1
58
+ */
59
+ hideDiscussion: (options?: {}) => Promise<void>;
60
+ /**
61
+ * 显示目录
62
+ * @since 22.2.1
63
+ */
64
+ showToc: (options?: {}) => Promise<void>;
65
+ /**
66
+ * 隐藏目录
67
+ * @since 22.2.1
68
+ */
69
+ hideToc: (options?: {}) => Promise<void>;
70
+ /**
71
+ * 创建版本
72
+ * @since 22.2.1
73
+ * @param options.name 版本名称,since co-1.6
74
+ */
75
+ createRevision: (options?: {
76
+ name?: string;
77
+ }) => Promise<null | DocumentErrorMessage>;
78
+ /**
79
+ * 进入演示模式
80
+ * @since 22.2.1
81
+ */
82
+ startDemonstration: (options?: {}) => Promise<void>;
83
+ /**
84
+ * 退出演示模式
85
+ * @since 22.2.1
86
+ */
87
+ endDemonstration: (options?: {}) => Promise<void>;
88
+ /**
89
+ * 打印
90
+ * @since 22.2.1
91
+ */
92
+ print: (options?: {}) => Promise<void>;
93
+ /**
94
+ * 显示评论侧边栏
95
+ * @since 22.6.1
96
+ */
97
+ showComments: (options?: {}) => Promise<void>;
98
+ /**
99
+ * 隐藏评论侧边栏
100
+ * @since 22.6.1
101
+ */
102
+ hideComments: (options?: {}) => Promise<void>;
103
+ /**
104
+ * 显示编写者信息
105
+ * @since 24.11.1
106
+ */
107
+ showCollaborator: (options?: {}) => Promise<void>;
108
+ /**
109
+ * 隐藏编写者信息
110
+ * @since 24.11.1
111
+ */
112
+ hideCollaborator: (options?: {}) => Promise<void>;
113
+ /**
114
+ * 获取侧边栏显示隐藏状态
115
+ * @since 24.11.1
116
+ */
117
+ isSidebarVisible: () => Promise<boolean>;
118
+ /**
119
+ * 显示评论侧边栏
120
+ * @since 24.11.1
121
+ */
122
+ showComment: () => Promise<void>;
123
+ /**
124
+ * 隐藏评论侧边栏
125
+ * @since 24.11.1
126
+ */
127
+ hideComment: () => Promise<void>;
128
+ /**
129
+ * 开始跟随模式
130
+ * @since 24.11.1
131
+ */
132
+ startFollowMode: () => Promise<void>;
133
+ /**
134
+ * 获取文档标题
135
+ * @since 24.11.1
136
+ */
137
+ getTitle: () => Promise<string>;
138
+ /**
139
+ * 设置文档标题
140
+ * @since 24.11.1
141
+ */
142
+ setTitle: (value: string) => Promise<void>;
143
+ /**
144
+ * 插入第三方应用
145
+ * @since 22.6.1
146
+ */
147
+ insertExternalApp: (url: string, params: ExternalAppParams) => Promise<null | DocumentErrorMessage>;
148
+ /**
149
+ * 插入链接卡片
150
+ * @since 24.11.1
151
+ */
152
+ insertLinkCard: (url: string, title: string) => Promise<void>;
153
+ /**
154
+ * 插入链接
155
+ * @since 24.11.1
156
+ */
157
+ insertLink: (url: string, text: string) => Promise<void>;
158
+ /**
159
+ * 获取选区内容的 Markdown 格式
160
+ * @since 24.11.1
161
+ */
162
+ getMarkdownFromSelection: () => Promise<string>;
163
+ /**
164
+ * 插入 Markdown 内容
165
+ * @since 24.11.1
166
+ */
167
+ insertMarkdown: (content: string) => Promise<void>;
168
+ }
@@ -0,0 +1,389 @@
1
+ import { MouseMovePayload } from 'weboffice-js-sdk-shared';
2
+ import { BaseEditor, EventMap as BaseEventMap } from './BaseEditor';
3
+ /**
4
+ * 评论
5
+ */
6
+ export interface Comment {
7
+ /**
8
+ * 评论的 ID
9
+ */
10
+ id: string;
11
+ /**
12
+ * 评论数据
13
+ */
14
+ data: CommentData;
15
+ /**
16
+ * 评论引用的的文本
17
+ */
18
+ quoteText: string;
19
+ /**
20
+ * 评论对应的标题信息
21
+ */
22
+ title: string;
23
+ }
24
+ /**
25
+ * 评论数据
26
+ */
27
+ export interface CommentData {
28
+ /**
29
+ * 评论数据的 ID
30
+ */
31
+ id: string;
32
+ /**
33
+ * 评论的创建时间
34
+ */
35
+ createTime: string;
36
+ /**
37
+ * 评论的更新时间
38
+ */
39
+ lastUpdateTime: string;
40
+ /**
41
+ * 创建评论的用户 ID
42
+ */
43
+ userId: string;
44
+ /**
45
+ * 创建评论的用户名
46
+ */
47
+ userName: string;
48
+ /**
49
+ * 评论的所有回复
50
+ */
51
+ replies: CommentData[];
52
+ }
53
+ /**
54
+ * 文档位置
55
+ * 0 - 正文
56
+ * 1 - 页眉
57
+ * 2 - 页脚
58
+ */
59
+ export type DocumentPos = 0 | 1 | 2;
60
+ /**
61
+ * 水平对齐方式
62
+ * 0 - 右对齐
63
+ * 1 - 左对齐
64
+ * 2 - 居中对齐
65
+ */
66
+ export type HorizontalAlignment = 0 | 1 | 2;
67
+ /** 事件名 */
68
+ export type Events = 'selectionEnded' | 'documentChanged' | 'commentClicked' | 'FullRecalculated';
69
+ export interface EventMap extends BaseEventMap {
70
+ selectionEnded: {};
71
+ documentChanged: {};
72
+ commentClicked: {
73
+ /**
74
+ * 所有被点击的评论ID列表
75
+ * @since 22.2.1
76
+ */
77
+ commentIds?: string[];
78
+ };
79
+ documentRecalculated: {};
80
+ error: {
81
+ /** 错误信息 */
82
+ data?: any;
83
+ /** 错误码 */
84
+ code: number;
85
+ };
86
+ /**
87
+ * 鼠标移动事件
88
+ */
89
+ MouseMove: MouseMovePayload;
90
+ /**
91
+ * 垂直滚动事件
92
+ */
93
+ VerticalScroll: MouseMovePayload;
94
+ /**
95
+ * 水平滚动事件
96
+ */
97
+ HorizontalScroll: MouseMovePayload;
98
+ /**
99
+ * 请求打开签名组件
100
+ */
101
+ showSignatureComponent: {
102
+ /**
103
+ * 签名图片的宽高比
104
+ */
105
+ aspectRatio: number;
106
+ /**
107
+ * 该签名图片的唯一 ID,用于在 `updateSignature()` 时指定想更新的签名组件
108
+ */
109
+ id: string;
110
+ };
111
+ }
112
+ export interface UpdateSignaturePayload {
113
+ /**
114
+ * 待更新的签名图片,需要是 data:<media type>;base64,<base64 data> 的格式,传 null 则清除签名图片。
115
+ * Ref: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs
116
+ */
117
+ url: string | null;
118
+ /**
119
+ * 待更新的签名图片 ID,用于指定更新的签名组件,需要和 `showSignatureComponent` 事件中的 `id` 一致。
120
+ */
121
+ id: string;
122
+ }
123
+ export interface Editor extends BaseEditor<EventMap> {
124
+ /**
125
+ * 获取所有评论
126
+ * @since 22.2.1
127
+ */
128
+ getComments: (options: {
129
+ /**
130
+ * 包含对应的标题信息
131
+ * @default false
132
+ */
133
+ includeChapterTitle?: boolean;
134
+ }) => Promise<DocumentProComment[]>;
135
+ /**
136
+ * 获取单条评论
137
+ * @since 22.2.1
138
+ */
139
+ getComment: (options: {
140
+ /**
141
+ * 评论ID
142
+ */
143
+ commentId: string;
144
+ /** 包含对应的标题信息 */
145
+ includeChapterTitle?: boolean;
146
+ }) => Promise<DocumentProComment>;
147
+ /**
148
+ * 获取一个选区已存在的评论
149
+ * @since 22.2.1
150
+ * @returns 评论 ID
151
+ */
152
+ getCommentBySelection: (options?: {}) => Promise<string>;
153
+ /**
154
+ * 添加评论
155
+ * @since 22.2.1
156
+ */
157
+ addComment: (options: {
158
+ /**
159
+ * 评论内容
160
+ */
161
+ text: string;
162
+ }) => Promise<DocumentProComment>;
163
+ /**
164
+ * 添加回复
165
+ * @since 22.2.1
166
+ */
167
+ replyComment: (options: {
168
+ /**
169
+ * 评论ID
170
+ */
171
+ commentId: string;
172
+ /** 回复内容 */
173
+ text: string;
174
+ }) => Promise<DocumentProCommentData>;
175
+ /**
176
+ * 删除评论
177
+ * @since 22.2.1
178
+ */
179
+ removeComment: (options: {
180
+ /**
181
+ * 评论ID
182
+ */
183
+ commentId: string;
184
+ }) => Promise<void>;
185
+ /**
186
+ * 删除回复
187
+ * @since 22.2.1
188
+ */
189
+ removeReply: (options: {
190
+ /**
191
+ * 回复数据的ID
192
+ */
193
+ commentDataId: string;
194
+ }) => Promise<void>;
195
+ /**
196
+ * 更新评论或回复
197
+ * @since 22.2.1
198
+ */
199
+ updateComment: (options: {
200
+ /**
201
+ * 评论数据或回复数据的ID
202
+ */
203
+ commentDataId: string;
204
+ /** 评论内容 */
205
+ text: string;
206
+ }) => Promise<void>;
207
+ /**
208
+ * 跳转到评论所在位置
209
+ * @since 22.2.1
210
+ */
211
+ goToComment: (options: {
212
+ /**
213
+ * 评论ID
214
+ */
215
+ commentId: string;
216
+ /**
217
+ * 是否滚动到评论所在位置
218
+ * @default true
219
+ */
220
+ shouldScrollToComment?: boolean;
221
+ /**
222
+ * 是否需要选中评论正文
223
+ * @default false
224
+ */
225
+ shouldSelectComment?: boolean;
226
+ }) => Promise<void>;
227
+ /**
228
+ * 获取选区文本
229
+ * @since 22.2.1
230
+ */
231
+ getSelectedText: (options?: {}) => Promise<void>;
232
+ /**
233
+ * 跳转页面
234
+ * @since 22.2.1
235
+ */
236
+ goToPage: (options: {
237
+ /**
238
+ * 页码
239
+ */
240
+ pageNum: number;
241
+ }) => Promise<void>;
242
+ /**
243
+ * 跳到文档顶部
244
+ * @since 22.2.1
245
+ */
246
+ goToTop: (options?: {}) => Promise<void>;
247
+ /**
248
+ * 添加页码
249
+ * @since 22.2.1
250
+ */
251
+ addPageNum: (options: {
252
+ /**
253
+ * 页码的插入位置
254
+ */
255
+ position: DocumentPos;
256
+ /**
257
+ * 页码的对齐方式
258
+ * @default 1
259
+ */
260
+ alignment?: HorizontalAlignment;
261
+ }) => Promise<void>;
262
+ /**
263
+ * 删除所有页码
264
+ * @since 22.2.1
265
+ */
266
+ removeAllPageNums: (options?: {}) => Promise<void>;
267
+ /**
268
+ * 显示文档结构
269
+ * @since 22.2.1
270
+ */
271
+ showToc: (this: Editor, options: {
272
+ /**
273
+ * 禁用文档结构图的默认缓存
274
+ * @default true
275
+ */
276
+ shouldDisableCache?: boolean;
277
+ }) => Promise<void>;
278
+ /**
279
+ * 隐藏文档结构图
280
+ * @since 22.2.1
281
+ */
282
+ hideToc: (options?: {}) => Promise<void>;
283
+ /**
284
+ * 文档缩放
285
+ * @since 22.2.1
286
+ */
287
+ zoom: (this: Editor, options: {
288
+ /**
289
+ * 缩放百分比
290
+ */
291
+ percent: number;
292
+ }) => Promise<void>;
293
+ /**
294
+ * 设置加粗
295
+ * @since 22.2.1
296
+ */
297
+ setBold: (this: Editor, options: {
298
+ /**
299
+ * 是否加粗
300
+ * @default false
301
+ */
302
+ isBold?: boolean;
303
+ }) => Promise<void>;
304
+ /**
305
+ * 设置斜体
306
+ * @since 22.2.1
307
+ */
308
+ setItalic: (options: {
309
+ isItalic?: boolean;
310
+ }) => Promise<void>;
311
+ /**
312
+ * 打印
313
+ * @since 22.2.1
314
+ */
315
+ print: (options: {
316
+ /**
317
+ * 页码列表
318
+ */
319
+ pageNums: number[];
320
+ }) => Promise<void>;
321
+ /**
322
+ * 打印所有页面
323
+ * @since 22.2.1
324
+ */
325
+ printAll: (options?: {}) => Promise<void>;
326
+ /**
327
+ * 创建版本
328
+ */
329
+ createRevision: (options?: {
330
+ name: string;
331
+ }) => Promise<void>;
332
+ /** 预览历史版本 */
333
+ showHistory: (options?: {}) => Promise<void>;
334
+ /** 关闭历史版本预览 */
335
+ hideHistory: (options?: {}) => Promise<void>;
336
+ /**
337
+ * 更新签名图片
338
+ */
339
+ updateSignature: (payload: UpdateSignaturePayload) => Promise<void>;
340
+ /**
341
+ * 导出
342
+ * @param type image:导出图片,imagePdf: 导出pdf
343
+ * @since co-1.5
344
+ */
345
+ export: (type: 'image' | 'imagePdf') => Promise<void>;
346
+ }
347
+ export interface DocumentProComment {
348
+ id: string;
349
+ /**
350
+ * 评论对应的文本
351
+ */
352
+ quoteText: string;
353
+ /**
354
+ * 评论的数据
355
+ */
356
+ data: DocumentProCommentData;
357
+ title?: string;
358
+ /**
359
+ * 评论的位置
360
+ */
361
+ startInfo: {
362
+ x: number;
363
+ y: number;
364
+ pageNum: number;
365
+ };
366
+ /**
367
+ * timestamp string
368
+ */
369
+ createTime: string;
370
+ /**
371
+ * timestamp string
372
+ */
373
+ lastUpdateTime: string;
374
+ }
375
+ export interface DocumentProCommentData {
376
+ id: string;
377
+ userId: string;
378
+ userName: string;
379
+ text: string;
380
+ createTime: string;
381
+ /**
382
+ * timestamp string
383
+ */
384
+ lastUpdateTime: '';
385
+ /**
386
+ * 该条评论的回复
387
+ */
388
+ replies: DocumentProCommentData[];
389
+ }
@@ -0,0 +1,11 @@
1
+ import { BaseEditor } from './BaseEditor';
2
+ export interface EventMap {
3
+ error: {
4
+ /** 错误信息 */
5
+ data?: any;
6
+ /** 错误码 */
7
+ code: number;
8
+ };
9
+ }
10
+ export interface Editor extends BaseEditor<EventMap> {
11
+ }
@@ -0,0 +1,15 @@
1
+ import { BaseEditor } from './BaseEditor';
2
+ export interface EventMap {
3
+ error: {
4
+ /** 错误信息 */
5
+ data?: unknown;
6
+ /** 错误码 */
7
+ code: number;
8
+ };
9
+ /**
10
+ * 标题发生变更
11
+ */
12
+ titleChange: string;
13
+ }
14
+ export interface Editor extends BaseEditor<EventMap> {
15
+ }
@@ -0,0 +1,49 @@
1
+ import { BaseEditor, EventMap as BaseEventMap } from './BaseEditor';
2
+ export interface EventMap extends BaseEventMap {
3
+ /**
4
+ * 错误
5
+ */
6
+ error: {
7
+ /** 错误信息 */
8
+ data?: any;
9
+ /** 错误码 */
10
+ code: number;
11
+ };
12
+ }
13
+ export interface Editor extends BaseEditor<EventMap> {
14
+ /**
15
+ * 显示历史
16
+ */
17
+ showHistory: () => Promise<void>;
18
+ /**
19
+ 隐藏历史
20
+ */
21
+ hideHistory: () => Promise<void>;
22
+ /**
23
+ 开始本地演示
24
+ */
25
+ startDemonstration: () => Promise<void>;
26
+ /**
27
+ 结束本地演示
28
+ */
29
+ endDemonstration: () => Promise<void>;
30
+ /**
31
+ * 创建版本
32
+ * @since co-1.5
33
+ * @param options.name 版本名称,since co-1.6
34
+ */
35
+ createRevision: (options?: {
36
+ name?: string;
37
+ }) => Promise<void>;
38
+ /**
39
+ * 导出
40
+ * @param type image:导出图片,imagePdf: 导出pdf
41
+ * @since co-1.5
42
+ */
43
+ export: (type: 'image' | 'imagePdf') => Promise<void>;
44
+ /**
45
+ * 打印
46
+ * @since co-1.5
47
+ */
48
+ print: () => Promise<void>;
49
+ }