@officesdk/editor-sdk-core 0.0.0-11 → 0.0.0-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/cjs/diagram/index.js +16 -1
- package/cjs/diagram/sdk.js +1 -1
- package/cjs/docs/index.js +21 -0
- package/cjs/docs/info.js +3 -0
- package/cjs/docs/range.js +7 -0
- package/cjs/docs/sdk.js +28 -0
- package/cjs/docs/selection.js +3 -0
- package/cjs/docx/context-menu.js +3 -0
- package/cjs/docx/index.js +16 -1
- package/cjs/docx/menu.js +1 -1
- package/cjs/docx/sdk.js +1 -1
- package/cjs/docx/selection.js +1 -1
- package/cjs/docx/theme.js +1 -1
- package/cjs/docx/window.js +1 -1
- package/cjs/pdf/index.js +16 -1
- package/cjs/presentation/index.js +16 -1
- package/cjs/presentation/sdk.js +1 -1
- package/cjs/presentation/toolbar.js +3 -0
- package/cjs/shared/attachment.js +1 -1
- package/cjs/shared/content.js +1 -1
- package/cjs/shared/context-menu.js +3 -0
- package/cjs/shared/editor.js +1 -1
- package/cjs/shared/index.js +1 -1
- package/cjs/shared/menu.js +1 -1
- package/cjs/shared/toolbar.js +1 -1
- package/cjs/shared/user.js +1 -1
- package/cjs/sheet/index.js +16 -1
- package/cjs/table/content.js +3 -0
- package/cjs/table/index.js +23 -0
- package/cjs/table/resource.js +3 -0
- package/cjs/table/sdk.js +11 -0
- package/cjs/table/selection.js +21 -0
- package/cjs/table/table.js +3 -0
- package/esm/diagram/index.js +2 -1
- package/esm/diagram/sdk.js +1 -1
- package/esm/docs/index.js +3 -0
- package/esm/docs/info.js +2 -0
- package/esm/docs/range.js +6 -0
- package/esm/docs/sdk.js +25 -0
- package/esm/docs/selection.js +2 -0
- package/esm/docx/context-menu.js +2 -0
- package/esm/docx/index.js +2 -1
- package/esm/docx/menu.js +1 -1
- package/esm/docx/sdk.js +1 -1
- package/esm/docx/selection.js +1 -1
- package/esm/docx/theme.js +1 -1
- package/esm/docx/window.js +1 -1
- package/esm/pdf/index.js +2 -1
- package/esm/presentation/index.js +2 -1
- package/esm/presentation/sdk.js +1 -1
- package/esm/presentation/toolbar.js +2 -0
- package/esm/shared/attachment.js +1 -1
- package/esm/shared/content.js +1 -1
- package/esm/shared/context-menu.js +2 -0
- package/esm/shared/editor.js +1 -1
- package/esm/shared/index.js +1 -1
- package/esm/shared/menu.js +1 -1
- package/esm/shared/toolbar.js +1 -1
- package/esm/shared/user.js +1 -1
- package/esm/sheet/index.js +2 -1
- package/esm/table/content.js +2 -0
- package/esm/table/index.js +4 -0
- package/esm/table/resource.js +2 -0
- package/esm/table/sdk.js +8 -0
- package/esm/table/selection.js +18 -0
- package/esm/table/table.js +2 -0
- package/package.json +72 -7
- package/types/diagram.d.ts +1454 -0
- package/types/docs.d.ts +1581 -0
- package/{index.d.ts → types/docx.d.ts} +215 -1017
- package/types/pdf.d.ts +1663 -0
- package/types/presentation.d.ts +1708 -0
- package/types/shared.d.ts +1389 -0
- package/types/sheet.d.ts +1755 -0
- package/types/table.d.ts +1704 -0
- package/cjs/index.js +0 -18
- package/esm/index.js +0 -7
|
@@ -0,0 +1,1389 @@
|
|
|
1
|
+
export declare abstract class AbstractedEditorFileUploader {
|
|
2
|
+
/**
|
|
3
|
+
* 开始上传
|
|
4
|
+
* @param options
|
|
5
|
+
*/
|
|
6
|
+
abstract start(options: EditorUploadStartOptions): EditorUploadTaskInfo[];
|
|
7
|
+
/**
|
|
8
|
+
* 暂停上传,不传参数则取消所有上传任务
|
|
9
|
+
* @param taskIds
|
|
10
|
+
*/
|
|
11
|
+
abstract pause(taskIds?: string[]): void;
|
|
12
|
+
/**
|
|
13
|
+
* 暂停上传,不传参数则暂停所有上传任务
|
|
14
|
+
* @param taskIds
|
|
15
|
+
*/
|
|
16
|
+
abstract abort(taskIds?: string[]): void;
|
|
17
|
+
/**
|
|
18
|
+
* 恢复上传,不传参数则恢复所有上传任务
|
|
19
|
+
* @param taskIds
|
|
20
|
+
*/
|
|
21
|
+
abstract resume(taskIds?: string[]): void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 匿名用户信息
|
|
26
|
+
* 当前用户信息未知时的缺省值
|
|
27
|
+
*/
|
|
28
|
+
export declare interface EditorAnonymousOptions {
|
|
29
|
+
/**
|
|
30
|
+
* 匿名用户默认显示名称
|
|
31
|
+
*/
|
|
32
|
+
name: string;
|
|
33
|
+
/**
|
|
34
|
+
* 匿名用户默认头像
|
|
35
|
+
*/
|
|
36
|
+
avatar: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 编辑器内部资源请求配置
|
|
41
|
+
*/
|
|
42
|
+
export declare interface EditorAssetsOptions {
|
|
43
|
+
/**
|
|
44
|
+
* 通用资源请求代理配置,
|
|
45
|
+
* 用于套件内部资源请求时代理请求
|
|
46
|
+
*/
|
|
47
|
+
proxy: HTTPProxy;
|
|
48
|
+
/**
|
|
49
|
+
* 资源文件 URL 转换和解析
|
|
50
|
+
*/
|
|
51
|
+
resolver: EditorAssetsResolver;
|
|
52
|
+
/**
|
|
53
|
+
* 图片处理器
|
|
54
|
+
*/
|
|
55
|
+
imageProcessing: EditorAssetsOssImageProcessing;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 基于对象存储的图片处理抽象
|
|
60
|
+
*/
|
|
61
|
+
export declare interface EditorAssetsOssImageProcessing {
|
|
62
|
+
/**
|
|
63
|
+
* 压缩图片的方法
|
|
64
|
+
* @param imageUrl 图片的 URL
|
|
65
|
+
* @param compressOptions 压缩配置,例如质量、最大宽度和最大高度
|
|
66
|
+
* @returns 压缩后的图片 URL
|
|
67
|
+
*/
|
|
68
|
+
compress: (imageUrl: string, compressOptions?: {
|
|
69
|
+
quality?: number;
|
|
70
|
+
maxWidth?: number;
|
|
71
|
+
maxHeight?: number;
|
|
72
|
+
}) => Promise<string>;
|
|
73
|
+
/**
|
|
74
|
+
* 裁切图片的方法
|
|
75
|
+
* @param imageUrl 图片的 URL
|
|
76
|
+
* @param cropOptions 裁切配置,例如宽度、高度和起始点
|
|
77
|
+
* @returns 裁切后的图片 URL
|
|
78
|
+
*/
|
|
79
|
+
crop: (imageUrl: string, cropOptions: {
|
|
80
|
+
x?: number;
|
|
81
|
+
y?: number;
|
|
82
|
+
w: number;
|
|
83
|
+
h: number;
|
|
84
|
+
g?: EditorImageCropPoint;
|
|
85
|
+
}) => Promise<string>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export declare interface EditorAssetsResolver {
|
|
89
|
+
/**
|
|
90
|
+
* 将资源文件 ID 转换为 URL 的方法
|
|
91
|
+
* @param assetId 资源文件 ID
|
|
92
|
+
* @returns 转换后的资源 URL ,如果无法转换则返回 null
|
|
93
|
+
*/
|
|
94
|
+
resolveUrl: (assetId: string) => Promise<string | null>;
|
|
95
|
+
/**
|
|
96
|
+
* 从 URL 中解析资源文件 ID 的方法
|
|
97
|
+
* @param url 资源 URL
|
|
98
|
+
* @returns 解析出的资源文件 ID
|
|
99
|
+
*/
|
|
100
|
+
parseId: (url: string) => Promise<string | null>;
|
|
101
|
+
/**
|
|
102
|
+
* 检查资源文件 ID 对应的文件是否准备就绪,
|
|
103
|
+
* 在部分环境中,资源文件需要异步导入,在编辑器加载的时候可能还未准备就绪
|
|
104
|
+
* @param assetId 资源文件 ID
|
|
105
|
+
* @returns
|
|
106
|
+
*/
|
|
107
|
+
checkAssetReady: (assetId: string) => Promise<boolean> | boolean;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* 编辑器附件限制配置,sdk中会使用在不同的场景下使用不同的限制规则组合
|
|
112
|
+
*/
|
|
113
|
+
export declare interface EditorAttachmentLimitationOptions {
|
|
114
|
+
/**
|
|
115
|
+
* 检查附件大小的规则
|
|
116
|
+
* @param file
|
|
117
|
+
* @returns
|
|
118
|
+
*/
|
|
119
|
+
checkFile: (params: EditorAttachmentLimitationOptionsCheckFunctionParams) => Promise<{
|
|
120
|
+
limited: true;
|
|
121
|
+
message: string;
|
|
122
|
+
} | {
|
|
123
|
+
limited: false;
|
|
124
|
+
}>;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* 编辑器附件限制配置检查函数参数
|
|
129
|
+
*/
|
|
130
|
+
export declare interface EditorAttachmentLimitationOptionsCheckFunctionParams {
|
|
131
|
+
/**
|
|
132
|
+
* 文件名称,带后缀名
|
|
133
|
+
*/
|
|
134
|
+
name: string;
|
|
135
|
+
/**
|
|
136
|
+
* 文件大小,单位为Byte
|
|
137
|
+
*/
|
|
138
|
+
size: number;
|
|
139
|
+
/**
|
|
140
|
+
* 文件的mime类型,例如image/jpeg、application/vnd.ms-excel等
|
|
141
|
+
*/
|
|
142
|
+
mime?: string;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* 编辑器附件限制配置
|
|
147
|
+
* @deprecated 使用limitations代替
|
|
148
|
+
*/
|
|
149
|
+
export declare interface EditorAttachmentMaxSizeOptions {
|
|
150
|
+
/**
|
|
151
|
+
* 图片大小上限值,单位为Byte
|
|
152
|
+
* 设置为Infinity时表示不限制图片大小
|
|
153
|
+
*/
|
|
154
|
+
value?: number;
|
|
155
|
+
/**
|
|
156
|
+
* 超限警告相关配置
|
|
157
|
+
*/
|
|
158
|
+
warning?: {
|
|
159
|
+
/**
|
|
160
|
+
* 超限警告文本
|
|
161
|
+
*/
|
|
162
|
+
text?: string;
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* 编辑器附件信息
|
|
168
|
+
*/
|
|
169
|
+
export declare interface EditorAttachmentOptions {
|
|
170
|
+
uploader: AbstractedEditorFileUploader;
|
|
171
|
+
download: (url: string) => void;
|
|
172
|
+
/**
|
|
173
|
+
* 图片附件相关配置
|
|
174
|
+
*/
|
|
175
|
+
image?: {
|
|
176
|
+
/**
|
|
177
|
+
* 图片大小上限相关配置
|
|
178
|
+
* @deprecated 使用limitations代替
|
|
179
|
+
*/
|
|
180
|
+
maxSize?: EditorAttachmentMaxSizeOptions;
|
|
181
|
+
/**
|
|
182
|
+
* 支持的图片格式列表,例如jpg,png等
|
|
183
|
+
*/
|
|
184
|
+
supportTypes?: string[];
|
|
185
|
+
/**
|
|
186
|
+
* 图片附件的限制配置
|
|
187
|
+
*/
|
|
188
|
+
limitations?: EditorAttachmentLimitationOptions;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* 其他附件相关配置
|
|
192
|
+
*/
|
|
193
|
+
attachment?: {
|
|
194
|
+
/**
|
|
195
|
+
* 图片大小上限相关配置
|
|
196
|
+
* @deprecated 使用limitations代替
|
|
197
|
+
*/
|
|
198
|
+
maxSize?: EditorAttachmentMaxSizeOptions;
|
|
199
|
+
/**
|
|
200
|
+
* 支持的附件格式列表,例如doc,docx等
|
|
201
|
+
*/
|
|
202
|
+
supportTypes?: string[];
|
|
203
|
+
/**
|
|
204
|
+
* 附件的限制配置
|
|
205
|
+
*/
|
|
206
|
+
limitations?: EditorAttachmentLimitationOptions;
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* 基础文件属性
|
|
212
|
+
*/
|
|
213
|
+
export declare interface EditorBaseUploadableFile {
|
|
214
|
+
secretly?: boolean;
|
|
215
|
+
bucket: 'images' | 'attachments';
|
|
216
|
+
encrypt: string;
|
|
217
|
+
fileGuid: string;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* 品牌相关设置,
|
|
222
|
+
* 用于在套件中展示品牌外露信息
|
|
223
|
+
*/
|
|
224
|
+
export declare interface EditorBrandOptions {
|
|
225
|
+
/**
|
|
226
|
+
* 需要显示在品牌展示位的内容,按数组顺序显示
|
|
227
|
+
*/
|
|
228
|
+
content: Array<{
|
|
229
|
+
type: 'image';
|
|
230
|
+
src: string;
|
|
231
|
+
} | {
|
|
232
|
+
type: 'text';
|
|
233
|
+
content: string;
|
|
234
|
+
color?: string;
|
|
235
|
+
}>;
|
|
236
|
+
/**
|
|
237
|
+
* 品牌展示位的布局信息
|
|
238
|
+
*/
|
|
239
|
+
layout: {
|
|
240
|
+
width: string;
|
|
241
|
+
height: string;
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* 单条评论数据
|
|
247
|
+
*/
|
|
248
|
+
export declare interface EditorCommentItem {
|
|
249
|
+
/**
|
|
250
|
+
* 评论 ID
|
|
251
|
+
*/
|
|
252
|
+
id: string;
|
|
253
|
+
/**
|
|
254
|
+
* 评论用户信息
|
|
255
|
+
*/
|
|
256
|
+
user: {
|
|
257
|
+
id: string;
|
|
258
|
+
name: string;
|
|
259
|
+
};
|
|
260
|
+
content: {
|
|
261
|
+
text: string;
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export declare interface EditorComments {
|
|
266
|
+
/**
|
|
267
|
+
* 检查是否有评论
|
|
268
|
+
* @returns
|
|
269
|
+
*/
|
|
270
|
+
hasAny: () => Promise<boolean>;
|
|
271
|
+
/**
|
|
272
|
+
* 获取评论列表
|
|
273
|
+
* @returns
|
|
274
|
+
*/
|
|
275
|
+
getAll: () => Promise<EditorCommentItem[]>;
|
|
276
|
+
/**
|
|
277
|
+
* 获取单个评论
|
|
278
|
+
* @param commentId
|
|
279
|
+
* @returns
|
|
280
|
+
*/
|
|
281
|
+
getOne: (commentId: string) => Promise<EditorCommentItem | null>;
|
|
282
|
+
/**
|
|
283
|
+
* 添加内容
|
|
284
|
+
* @param options
|
|
285
|
+
* @returns
|
|
286
|
+
*/
|
|
287
|
+
add: (options: {
|
|
288
|
+
/**
|
|
289
|
+
* 评论内容
|
|
290
|
+
*/
|
|
291
|
+
text: string;
|
|
292
|
+
/**
|
|
293
|
+
* 默认评论是添加到当前选区上,也可以指定一个区域
|
|
294
|
+
*/
|
|
295
|
+
range?: string;
|
|
296
|
+
}) => Promise<string | null>;
|
|
297
|
+
/**
|
|
298
|
+
* 删除所有评论
|
|
299
|
+
* @returns
|
|
300
|
+
*/
|
|
301
|
+
deleteAll: () => Promise<boolean>;
|
|
302
|
+
/**
|
|
303
|
+
* 删除单条评论
|
|
304
|
+
*/
|
|
305
|
+
deleteOne: (commentId: string) => Promise<boolean>;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* 编辑器评论初始化配置
|
|
310
|
+
*/
|
|
311
|
+
export declare interface EditorCommentsOptions {
|
|
312
|
+
/**
|
|
313
|
+
* 评论作者信息,如果这里的信息为空,将会使用 user 信息
|
|
314
|
+
*/
|
|
315
|
+
author?: {
|
|
316
|
+
/**
|
|
317
|
+
* 评论作者 ID
|
|
318
|
+
*/
|
|
319
|
+
id: string;
|
|
320
|
+
/**
|
|
321
|
+
* 评论作者信息
|
|
322
|
+
*/
|
|
323
|
+
name: string;
|
|
324
|
+
/**
|
|
325
|
+
* 评论作者头像
|
|
326
|
+
*/
|
|
327
|
+
avatar?: string;
|
|
328
|
+
};
|
|
329
|
+
/**
|
|
330
|
+
* 显示的视图配置
|
|
331
|
+
*/
|
|
332
|
+
view?: {
|
|
333
|
+
/**
|
|
334
|
+
* 评论显示模式,
|
|
335
|
+
* none: 不显示评论,默认值。
|
|
336
|
+
* card: 评论以卡片形式显示。
|
|
337
|
+
*/
|
|
338
|
+
mode: 'none' | 'card';
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
export declare interface EditorContent<Delta = EditorDelta> {
|
|
343
|
+
/**
|
|
344
|
+
* 设置编辑器内容
|
|
345
|
+
* @param content
|
|
346
|
+
*/
|
|
347
|
+
setContent: (content: string | ArrayBuffer) => Promise<void>;
|
|
348
|
+
/**
|
|
349
|
+
* 获取编辑器内容
|
|
350
|
+
*/
|
|
351
|
+
getContent: () => Promise<Delta>;
|
|
352
|
+
/**
|
|
353
|
+
* 添加监听,当内容发生变化时触发监听,传入 Delta
|
|
354
|
+
* @param listener
|
|
355
|
+
*/
|
|
356
|
+
addChangeListener: (listener: (change: Delta) => void) => () => void;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* 右键菜单栏二级以下的菜单入口
|
|
361
|
+
*/
|
|
362
|
+
export declare type EditorContextMenuEntryButton<TName extends string> = EditorMenuEntryButton<TName>;
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* 右键菜单栏一级菜单配置,此处用于定义一级菜单的操作入口,
|
|
366
|
+
* 右键菜单栏一级菜单指点击右键弹出菜单时的菜单项
|
|
367
|
+
*/
|
|
368
|
+
export declare type EditorContextMenuEntryConfig<TName extends string> = EditorMenuEntryConfig<TName>;
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* 右键菜单栏功能按钮配置
|
|
372
|
+
*/
|
|
373
|
+
export declare type EditorContextMenuFeatureButton<TName extends string> = EditorMenuFeatureButton<TName>;
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* 右键菜单栏按钮配置
|
|
377
|
+
*/
|
|
378
|
+
export declare type EditorContextMenuFeatureButtonConfig<TName extends string> = EditorMenuFeatureButtonConfig<TName>;
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* 右键菜单栏相关配置
|
|
382
|
+
* 右键菜单栏是指的编辑器中点击右键弹出的菜单栏。目前等于菜单栏配置,可扩展
|
|
383
|
+
*/
|
|
384
|
+
export declare type EditorContextMenuOptions<TName extends string> = EditorMenuOptions<TName>;
|
|
385
|
+
|
|
386
|
+
export declare interface EditorDelta {
|
|
387
|
+
compose: (other: EditorDelta, isDocument?: boolean) => EditorDelta;
|
|
388
|
+
transform: (other: EditorDelta, priority?: boolean) => EditorDelta;
|
|
389
|
+
stringify: () => string;
|
|
390
|
+
length: number;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* 编辑器嵌入对象
|
|
395
|
+
*/
|
|
396
|
+
export declare interface EditorEmbeddedObject {
|
|
397
|
+
/**
|
|
398
|
+
* 嵌入的对象 url
|
|
399
|
+
*/
|
|
400
|
+
url: string;
|
|
401
|
+
/**
|
|
402
|
+
* 嵌入对象的类型描述
|
|
403
|
+
*/
|
|
404
|
+
type?: string;
|
|
405
|
+
/**
|
|
406
|
+
* 嵌入对象的名
|
|
407
|
+
*/
|
|
408
|
+
name?: string;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* 编辑器嵌入对象抽象类
|
|
413
|
+
*/
|
|
414
|
+
export declare interface EditorEmbeddedObjectOptions {
|
|
415
|
+
/**
|
|
416
|
+
* 执行打开嵌入对象操作,
|
|
417
|
+
* 如果已经处理了打开操作,返回 true,否则返回 false,
|
|
418
|
+
* 如果返回 false,编辑器会继续后续默认的打开操作。
|
|
419
|
+
* @param object
|
|
420
|
+
* @returns
|
|
421
|
+
*/
|
|
422
|
+
open: (object: EditorEmbeddedObject) => Promise<boolean>;
|
|
423
|
+
/**
|
|
424
|
+
* 嵌入对象的页面功能
|
|
425
|
+
*/
|
|
426
|
+
ui?: {
|
|
427
|
+
/**
|
|
428
|
+
* 预览功能
|
|
429
|
+
*/
|
|
430
|
+
preview?: {
|
|
431
|
+
disabled?: boolean;
|
|
432
|
+
};
|
|
433
|
+
/**
|
|
434
|
+
* 下载功能
|
|
435
|
+
*/
|
|
436
|
+
download?: {
|
|
437
|
+
disabled?: boolean;
|
|
438
|
+
};
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
export declare interface EditorExportOptions {
|
|
443
|
+
/**
|
|
444
|
+
* 可导出类型
|
|
445
|
+
* @description
|
|
446
|
+
*/
|
|
447
|
+
supportedTypes?: string[];
|
|
448
|
+
/**
|
|
449
|
+
* 导出文件
|
|
450
|
+
* @description
|
|
451
|
+
*/
|
|
452
|
+
exportFile: (type: string) => Promise<void>;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
export declare interface EditorFontFace {
|
|
456
|
+
/**
|
|
457
|
+
* 字体的名称,用于在用户界面上显示的名称
|
|
458
|
+
*/
|
|
459
|
+
name: string;
|
|
460
|
+
/**
|
|
461
|
+
* 字体族
|
|
462
|
+
*/
|
|
463
|
+
family: string;
|
|
464
|
+
/**
|
|
465
|
+
* 用于加载字体的 URL
|
|
466
|
+
*/
|
|
467
|
+
url?: string;
|
|
468
|
+
/**
|
|
469
|
+
* 是否为受版权保护的字体,如果是在用户界面上会有所标识。
|
|
470
|
+
*/
|
|
471
|
+
isCopyrightProtected: boolean;
|
|
472
|
+
/**
|
|
473
|
+
* 字体元数据
|
|
474
|
+
*/
|
|
475
|
+
meta: EditorFontMeta;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* 字体元数据
|
|
480
|
+
*/
|
|
481
|
+
export declare interface EditorFontMeta {
|
|
482
|
+
head: {
|
|
483
|
+
unitsPerEm: number;
|
|
484
|
+
};
|
|
485
|
+
hhea: {
|
|
486
|
+
ascender: number;
|
|
487
|
+
descender: number;
|
|
488
|
+
lineGap: number;
|
|
489
|
+
};
|
|
490
|
+
vhea?: {
|
|
491
|
+
ascender: number;
|
|
492
|
+
descender: number;
|
|
493
|
+
lineGap: number;
|
|
494
|
+
};
|
|
495
|
+
os2: {
|
|
496
|
+
usWeightClass?: number;
|
|
497
|
+
usWidthClass?: number;
|
|
498
|
+
italic?: boolean;
|
|
499
|
+
isSymbol?: boolean;
|
|
500
|
+
ulCodePageRange: [number, number];
|
|
501
|
+
};
|
|
502
|
+
/**
|
|
503
|
+
* opentype中没有强制要求必须有en条目,只能确定name下的value的类型是对象
|
|
504
|
+
*/
|
|
505
|
+
name: {
|
|
506
|
+
preferredFamily?: Record<string, string>;
|
|
507
|
+
preferredSubfamily?: Record<string, string>;
|
|
508
|
+
fontFamily?: Record<string, string>;
|
|
509
|
+
fontSubfamily?: Record<string, string>;
|
|
510
|
+
fullName?: Record<string, string>;
|
|
511
|
+
postScriptName?: Record<string, string>;
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* 字体列表
|
|
517
|
+
*/
|
|
518
|
+
export declare interface EditorFontsList {
|
|
519
|
+
/**
|
|
520
|
+
* 返回解析为字体的列表的 Promise。
|
|
521
|
+
*/
|
|
522
|
+
getAll: () => Promise<EditorFontFace[]>;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
export declare interface EditorFontsOptions {
|
|
526
|
+
/**
|
|
527
|
+
* 服务器字体列表,用于获取服务器端配置的字体列表,
|
|
528
|
+
* 并提供可用于字体的加载 URL 和字体元数据。
|
|
529
|
+
*/
|
|
530
|
+
list: EditorFontsList;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* i18n 相关设置
|
|
535
|
+
*/
|
|
536
|
+
export declare interface EditorI18nOptions {
|
|
537
|
+
/**
|
|
538
|
+
* 语言,默认使用浏览器当前环境中的语言
|
|
539
|
+
*/
|
|
540
|
+
language?: string;
|
|
541
|
+
/**
|
|
542
|
+
* 文本方向,默认根据语言自动适配
|
|
543
|
+
*/
|
|
544
|
+
direction?: 'ltr' | 'rtl';
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
export declare type EditorImageCropPoint = 'nw' | 'north' | 'ne' | 'west' | 'center' | 'east' | 'sw' | 'south' | 'se';
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* 链接配置,抽象打开链接等操作
|
|
551
|
+
*/
|
|
552
|
+
export declare interface EditorLinkOptions {
|
|
553
|
+
/**
|
|
554
|
+
* 打开链接,如果取消了打开链接操作,返回 false
|
|
555
|
+
* @param url
|
|
556
|
+
* @param target
|
|
557
|
+
* @returns
|
|
558
|
+
*/
|
|
559
|
+
open: (url: string, target: string) => Promise<boolean>;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* 可上传文件
|
|
564
|
+
*/
|
|
565
|
+
export declare interface EditorLocalUploadableFile extends EditorBaseUploadableFile {
|
|
566
|
+
name: string;
|
|
567
|
+
size: number;
|
|
568
|
+
mime: string;
|
|
569
|
+
raw: File;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* 菜单栏自定义按钮配置
|
|
574
|
+
*/
|
|
575
|
+
export declare type EditorMenuCustomButton = {
|
|
576
|
+
/**
|
|
577
|
+
* 按钮名称
|
|
578
|
+
*/
|
|
579
|
+
name: string;
|
|
580
|
+
/**
|
|
581
|
+
* 链接
|
|
582
|
+
*/
|
|
583
|
+
type: 'link';
|
|
584
|
+
/**
|
|
585
|
+
* 按钮文本
|
|
586
|
+
*/
|
|
587
|
+
text: string;
|
|
588
|
+
/**
|
|
589
|
+
* 链接地址
|
|
590
|
+
*/
|
|
591
|
+
url: string;
|
|
592
|
+
} | {
|
|
593
|
+
/**
|
|
594
|
+
* 按钮名称
|
|
595
|
+
*/
|
|
596
|
+
name: string;
|
|
597
|
+
/**
|
|
598
|
+
* 按钮,点击后触发 callback 回调
|
|
599
|
+
*/
|
|
600
|
+
type: 'button';
|
|
601
|
+
/**
|
|
602
|
+
* 按钮文本
|
|
603
|
+
*/
|
|
604
|
+
label: string;
|
|
605
|
+
/**
|
|
606
|
+
* 按钮图标,可以是 base64 的图片信息,也可以是图片 url
|
|
607
|
+
*/
|
|
608
|
+
icon?: string;
|
|
609
|
+
/**
|
|
610
|
+
* 按钮点击事件
|
|
611
|
+
*/
|
|
612
|
+
callback: () => void;
|
|
613
|
+
};
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* 菜单栏二级以下的菜单入口
|
|
617
|
+
*/
|
|
618
|
+
export declare interface EditorMenuEntryButton<TName extends string> {
|
|
619
|
+
type: 'entry';
|
|
620
|
+
/**
|
|
621
|
+
* 菜单名称
|
|
622
|
+
*/
|
|
623
|
+
name: string;
|
|
624
|
+
/**
|
|
625
|
+
* 菜单图标
|
|
626
|
+
*/
|
|
627
|
+
icon?: string;
|
|
628
|
+
/**
|
|
629
|
+
* 下一级子菜单
|
|
630
|
+
*/
|
|
631
|
+
children?: Array<EditorMenuFeatureButton<TName> | EditorMenuEntryButton<TName>>[];
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* 菜单栏一级菜单配置,此处用于定义一级菜单的操作入口,
|
|
636
|
+
* 一级菜单在鼠标悬停时展示二级列表
|
|
637
|
+
*/
|
|
638
|
+
export declare interface EditorMenuEntryConfig<TName extends string> {
|
|
639
|
+
/**
|
|
640
|
+
* 一级菜单名称
|
|
641
|
+
*/
|
|
642
|
+
name: string;
|
|
643
|
+
/**
|
|
644
|
+
* 二级菜单定义,定一个二维数组,用于定义二级菜单的结构,
|
|
645
|
+
* 将第一层数组中的所有按钮放到一个区域内用分隔符隔开,
|
|
646
|
+
* 第二层数组为按钮的定义,可以是功能按钮也可以是一个下拉入口。
|
|
647
|
+
*/
|
|
648
|
+
children: Array<EditorMenuFeatureButton<TName> | EditorMenuEntryButton<TName>>[];
|
|
649
|
+
/**
|
|
650
|
+
* 是否隐藏一级菜单
|
|
651
|
+
*/
|
|
652
|
+
type?: 'hidden';
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* 菜单栏功能按钮配置
|
|
657
|
+
*/
|
|
658
|
+
export declare type EditorMenuFeatureButton<TName extends string> = {
|
|
659
|
+
/**
|
|
660
|
+
* 隐藏按钮,用作在需要隐藏菜单栏时定义
|
|
661
|
+
*/
|
|
662
|
+
type: 'hidden';
|
|
663
|
+
/**
|
|
664
|
+
* 按钮名称
|
|
665
|
+
*/
|
|
666
|
+
name: TName;
|
|
667
|
+
} | {
|
|
668
|
+
type: 'button';
|
|
669
|
+
/**
|
|
670
|
+
* 按钮名称
|
|
671
|
+
*/
|
|
672
|
+
name: TName;
|
|
673
|
+
/**
|
|
674
|
+
* 按钮标签(显示文本)
|
|
675
|
+
*/
|
|
676
|
+
label: string;
|
|
677
|
+
/**
|
|
678
|
+
* 按钮图标,可以是 base64 的图片信息,也可以是图片 url
|
|
679
|
+
*/
|
|
680
|
+
icon?: string;
|
|
681
|
+
};
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* 菜单栏按钮配置
|
|
685
|
+
*/
|
|
686
|
+
export declare type EditorMenuFeatureButtonConfig<TName extends string> = Record<TName, EditorMenuFeatureButton<TName>>;
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* 菜单栏相关配置,目前菜单栏不是所有套件都支持,
|
|
690
|
+
* 菜单栏是指的编辑器最上放可以展开二级菜单的那一栏。
|
|
691
|
+
*/
|
|
692
|
+
export declare interface EditorMenuOptions<TName extends string> {
|
|
693
|
+
/**
|
|
694
|
+
* 菜单栏是否隐藏
|
|
695
|
+
*/
|
|
696
|
+
hidden?: boolean;
|
|
697
|
+
/**
|
|
698
|
+
* 是否禁用菜单栏所有功能
|
|
699
|
+
*/
|
|
700
|
+
disabled?: boolean;
|
|
701
|
+
/**
|
|
702
|
+
* 菜单栏一级菜单配置
|
|
703
|
+
*/
|
|
704
|
+
entries?: EditorMenuEntryConfig<TName>[];
|
|
705
|
+
/**
|
|
706
|
+
* 菜单栏功能按钮配置
|
|
707
|
+
*/
|
|
708
|
+
features?: Partial<EditorMenuFeatureButtonConfig<TName>>;
|
|
709
|
+
/**
|
|
710
|
+
* 自定义按钮配置
|
|
711
|
+
*/
|
|
712
|
+
custom?: EditorMenuCustomButton[];
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* 编辑器基础模式接口
|
|
717
|
+
*/
|
|
718
|
+
export declare interface EditorMode {
|
|
719
|
+
/**
|
|
720
|
+
* 获取当前编辑器模式
|
|
721
|
+
*/
|
|
722
|
+
getModeType: () => EditorModeType;
|
|
723
|
+
/**
|
|
724
|
+
* 设置编辑器权限模式,仅在 `standard` 模式下有效
|
|
725
|
+
* @param permission
|
|
726
|
+
*/
|
|
727
|
+
setStandardRole: (standardRole: EditorStandardRole) => Promise<void>;
|
|
728
|
+
/**
|
|
729
|
+
* 获取当前编辑器权限模式,仅在 `standard` 模式下有效
|
|
730
|
+
*/
|
|
731
|
+
getStandardRole: () => EditorStandardRole;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* 编辑器初始化的时相关的模式配置
|
|
736
|
+
*/
|
|
737
|
+
export declare type EditorModeOptions = {
|
|
738
|
+
type: 'standard';
|
|
739
|
+
/**
|
|
740
|
+
* 当 mode 为 `standard` 时,可以设置当前编辑器的权限模式
|
|
741
|
+
*/
|
|
742
|
+
role?: EditorStandardRole;
|
|
743
|
+
} | {
|
|
744
|
+
type: 'preview';
|
|
745
|
+
} | {
|
|
746
|
+
type: 'presentation';
|
|
747
|
+
};
|
|
748
|
+
|
|
749
|
+
/**
|
|
750
|
+
* 编辑器模式
|
|
751
|
+
* - `standard` 标准模式,会根据用户权限配置不同的功能
|
|
752
|
+
* - `preview` 预览模式,只能查看内容
|
|
753
|
+
* - `presentation` 演示模式,用作演示场景,演示模式下部分套件可以进行一些简单的编辑操作
|
|
754
|
+
*/
|
|
755
|
+
export declare type EditorModeType = 'standard' | 'preview' | 'presentation';
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* 编辑器初始化通用参数
|
|
759
|
+
*/
|
|
760
|
+
export declare interface EditorOptions {
|
|
761
|
+
/**
|
|
762
|
+
* 编辑器初始化内容,可以是 string 或者 ArrayBuffer,
|
|
763
|
+
* 也可以通过异步 Promise 加载
|
|
764
|
+
*/
|
|
765
|
+
content: MaybePromiseValue<string | ArrayBuffer>;
|
|
766
|
+
/**
|
|
767
|
+
* 初始化时的编辑模式,默认为 `preview`
|
|
768
|
+
*/
|
|
769
|
+
mode?: EditorModeOptions;
|
|
770
|
+
/**
|
|
771
|
+
* 当前操作编辑器的用户信息
|
|
772
|
+
*/
|
|
773
|
+
user?: EditorUserOptions;
|
|
774
|
+
/**
|
|
775
|
+
* 匿名用户的缺省信息
|
|
776
|
+
*/
|
|
777
|
+
anonymous?: EditorAnonymousOptions;
|
|
778
|
+
/**
|
|
779
|
+
* i18n 相关设置
|
|
780
|
+
*/
|
|
781
|
+
i18n?: EditorI18nOptions;
|
|
782
|
+
/**
|
|
783
|
+
* 品牌相关设置
|
|
784
|
+
*/
|
|
785
|
+
brand?: EditorBrandOptions;
|
|
786
|
+
/**
|
|
787
|
+
* 编辑器内部资源请求配置
|
|
788
|
+
*/
|
|
789
|
+
assets?: EditorAssetsOptions;
|
|
790
|
+
/**
|
|
791
|
+
* 编辑器内部超链接设置
|
|
792
|
+
*/
|
|
793
|
+
link?: EditorLinkOptions;
|
|
794
|
+
/**
|
|
795
|
+
* 嵌入对象相关配置
|
|
796
|
+
*/
|
|
797
|
+
embeddedObject?: EditorEmbeddedObjectOptions;
|
|
798
|
+
/**
|
|
799
|
+
* 初始化水印配置
|
|
800
|
+
*/
|
|
801
|
+
watermark?: EditorWatermarkOptions;
|
|
802
|
+
/**
|
|
803
|
+
* 编辑器打印设置
|
|
804
|
+
*/
|
|
805
|
+
print?: EditorPrintOptions;
|
|
806
|
+
/**
|
|
807
|
+
* 编辑器评论设置
|
|
808
|
+
*/
|
|
809
|
+
comments?: EditorCommentsOptions;
|
|
810
|
+
/**
|
|
811
|
+
* 附件设置
|
|
812
|
+
*/
|
|
813
|
+
attachment?: EditorAttachmentOptions;
|
|
814
|
+
/**
|
|
815
|
+
* 导出设置
|
|
816
|
+
*/
|
|
817
|
+
export?: EditorExportOptions;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
/**
|
|
821
|
+
* 大纲目录接口
|
|
822
|
+
*/
|
|
823
|
+
export declare interface EditorOutline<Content = unknown> {
|
|
824
|
+
/**
|
|
825
|
+
* 设置大纲目录是否可见
|
|
826
|
+
* @param visible 是否可见
|
|
827
|
+
*/
|
|
828
|
+
setVisible: (visible: boolean) => void;
|
|
829
|
+
/**
|
|
830
|
+
* 获取目录信息
|
|
831
|
+
* @returns 目录信息
|
|
832
|
+
*/
|
|
833
|
+
getContent: () => Promise<EditorOutlineItem<Content>[]>;
|
|
834
|
+
/**
|
|
835
|
+
* 添加目录信息改变时的监听器
|
|
836
|
+
* @param listener 监听器
|
|
837
|
+
* @returns 取消监听器的函数
|
|
838
|
+
*/
|
|
839
|
+
addChangedListener: (listener: (content: EditorOutlineItem<Content>[]) => void) => () => void;
|
|
840
|
+
/**
|
|
841
|
+
* 跳转到指定条目对应的正文位置
|
|
842
|
+
* @param id 条目id
|
|
843
|
+
* @returns 跳转是否成功
|
|
844
|
+
*/
|
|
845
|
+
goto: (id: string) => Promise<boolean>;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* 大纲目录项条目
|
|
850
|
+
*/
|
|
851
|
+
export declare interface EditorOutlineItem<Content = unknown> {
|
|
852
|
+
/**
|
|
853
|
+
* 目录项 ID
|
|
854
|
+
*/
|
|
855
|
+
id: string;
|
|
856
|
+
/**
|
|
857
|
+
* 目录项层级
|
|
858
|
+
*/
|
|
859
|
+
level: number;
|
|
860
|
+
/**
|
|
861
|
+
* 目录项内容
|
|
862
|
+
*/
|
|
863
|
+
content: Content;
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
/**
|
|
867
|
+
* 大纲目录初始化参数,
|
|
868
|
+
* 用于配置大纲目录的行为和外观。
|
|
869
|
+
*/
|
|
870
|
+
export declare interface EditorOutlineOptions {
|
|
871
|
+
/**
|
|
872
|
+
* 初始化编辑器时是否显示大纲目录,
|
|
873
|
+
* 默认为 false。
|
|
874
|
+
*/
|
|
875
|
+
visible?: boolean;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
/**
|
|
879
|
+
* 编辑器打印设置
|
|
880
|
+
*/
|
|
881
|
+
export declare interface EditorPrintOptions {
|
|
882
|
+
/**
|
|
883
|
+
* 部分套件如果绕过了编辑器预设的打印接口,直接通过拉起了浏览器的打印页面,这时打印页面无法获取到编辑器的内容,
|
|
884
|
+
* 这种情况下就会 fallback 到这个 options 上,显示一个提示信息。
|
|
885
|
+
*/
|
|
886
|
+
fallback?: {
|
|
887
|
+
message: string;
|
|
888
|
+
};
|
|
889
|
+
/**
|
|
890
|
+
* 是否禁用打印功能
|
|
891
|
+
*/
|
|
892
|
+
disabled?: boolean;
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
/**
|
|
896
|
+
* 远程文件上传
|
|
897
|
+
*/
|
|
898
|
+
export declare interface EditorRemoteUploadableFile extends EditorBaseUploadableFile {
|
|
899
|
+
src: string;
|
|
900
|
+
name?: never;
|
|
901
|
+
size?: never;
|
|
902
|
+
mime?: never;
|
|
903
|
+
raw?: never;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
/**
|
|
907
|
+
* 编辑器通用接口
|
|
908
|
+
*/
|
|
909
|
+
export declare abstract class EditorSDK {
|
|
910
|
+
protected options: EditorOptions;
|
|
911
|
+
constructor(options: EditorOptions);
|
|
912
|
+
/**
|
|
913
|
+
* 初始化编辑器、加载插件等操作。
|
|
914
|
+
*/
|
|
915
|
+
abstract init(): Promise<void>;
|
|
916
|
+
/**
|
|
917
|
+
* 销毁编辑器
|
|
918
|
+
*/
|
|
919
|
+
abstract destroy(): Promise<void>;
|
|
920
|
+
/**
|
|
921
|
+
* 将编辑器挂载到指定的根节点上,并渲染,
|
|
922
|
+
* mount 应该在 init 之后调用。
|
|
923
|
+
* @param root
|
|
924
|
+
*/
|
|
925
|
+
abstract mount(root: HTMLElement): Promise<void>;
|
|
926
|
+
/**
|
|
927
|
+
* 从根节点卸载编辑器,对应 `mount` 操作
|
|
928
|
+
*/
|
|
929
|
+
abstract unmount(): Promise<void>;
|
|
930
|
+
/**
|
|
931
|
+
* 编辑器内容相关接口
|
|
932
|
+
*/
|
|
933
|
+
abstract get content(): EditorContent;
|
|
934
|
+
/**
|
|
935
|
+
* 编辑器模式相关接口
|
|
936
|
+
*/
|
|
937
|
+
abstract get mode(): EditorMode;
|
|
938
|
+
/**
|
|
939
|
+
* 编辑器评论相关接口
|
|
940
|
+
*/
|
|
941
|
+
abstract get comments(): EditorComments;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
/**
|
|
945
|
+
* 编辑器在 `standard` 模式下的权限模式
|
|
946
|
+
* - `editor` 编辑模式
|
|
947
|
+
* - `viewer` 阅读模式
|
|
948
|
+
* - `reviewer` 评论模式
|
|
949
|
+
*/
|
|
950
|
+
export declare type EditorStandardRole = 'editor' | 'viewer' | 'reviewer';
|
|
951
|
+
|
|
952
|
+
/**
|
|
953
|
+
* 上传任务回调
|
|
954
|
+
*/
|
|
955
|
+
export declare interface EditorTaskCallbacks {
|
|
956
|
+
/**
|
|
957
|
+
* 上传进度回调
|
|
958
|
+
* @param taskId
|
|
959
|
+
* @param loaded
|
|
960
|
+
* @param total
|
|
961
|
+
* @param progress
|
|
962
|
+
* @param data
|
|
963
|
+
* @returns
|
|
964
|
+
*/
|
|
965
|
+
onProgress?: (taskId: string, loaded: number, total: number, progress: number, data?: unknown) => void;
|
|
966
|
+
/**
|
|
967
|
+
* 上传错误回调
|
|
968
|
+
* @param taskId
|
|
969
|
+
* @param error
|
|
970
|
+
* @returns
|
|
971
|
+
*/
|
|
972
|
+
onError?: (taskId: string, error: Error) => void;
|
|
973
|
+
/**
|
|
974
|
+
* 上传暂停回调
|
|
975
|
+
* @param taskId
|
|
976
|
+
* @returns
|
|
977
|
+
*/
|
|
978
|
+
onPause?: (taskId: string) => void;
|
|
979
|
+
/**
|
|
980
|
+
* 上传取消
|
|
981
|
+
* @param taskId
|
|
982
|
+
* @returns
|
|
983
|
+
*/
|
|
984
|
+
onAbort?: (taskId: string) => void;
|
|
985
|
+
/**
|
|
986
|
+
* 上传恢复
|
|
987
|
+
* @param taskId
|
|
988
|
+
* @returns
|
|
989
|
+
*/
|
|
990
|
+
onResume?: (taskId: string) => void;
|
|
991
|
+
/**
|
|
992
|
+
* 上传完成回调
|
|
993
|
+
* @param taskId
|
|
994
|
+
* @param status
|
|
995
|
+
* @param data
|
|
996
|
+
* @returns
|
|
997
|
+
*/
|
|
998
|
+
onEnd?: (taskId: string, status: 'Error' | 'Finished' | 'Canceled', data: unknown) => void;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
/**
|
|
1002
|
+
* 文本格式接口,
|
|
1003
|
+
* 包括设置、读取选区内文本的 BIUS、family、大小、颜色等
|
|
1004
|
+
*/
|
|
1005
|
+
export declare interface EditorText<Color = string, TRangeValue = unknown> {
|
|
1006
|
+
/**
|
|
1007
|
+
* 获取当前选区或指定选区内的文本格式状态
|
|
1008
|
+
*/
|
|
1009
|
+
get: (range?: TRangeValue) => Partial<EditorTextFormat<Color>>;
|
|
1010
|
+
/**
|
|
1011
|
+
* 将文本的格式应用到当前选区或指定选区上,
|
|
1012
|
+
* 传入的非空字段会覆盖对应的属性,其他没有传入的属性会保持不变。
|
|
1013
|
+
* @param range
|
|
1014
|
+
* @param format
|
|
1015
|
+
* @returns
|
|
1016
|
+
*/
|
|
1017
|
+
apply: (format: Partial<EditorTextFormat<Color>>, range?: TRangeValue) => Partial<EditorTextFormat<Color>>;
|
|
1018
|
+
/**
|
|
1019
|
+
* 清空当前选区或指定选区内文本的格式,将文本格式恢复到默认状态
|
|
1020
|
+
* @param range
|
|
1021
|
+
* @returns
|
|
1022
|
+
*/
|
|
1023
|
+
clear: (range: TRangeValue) => void;
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
/**
|
|
1027
|
+
* 文本格式状态
|
|
1028
|
+
*/
|
|
1029
|
+
export declare interface EditorTextFormat<Color = string> {
|
|
1030
|
+
/**
|
|
1031
|
+
* 粗体
|
|
1032
|
+
*/
|
|
1033
|
+
bold: boolean;
|
|
1034
|
+
/**
|
|
1035
|
+
* 斜体
|
|
1036
|
+
*/
|
|
1037
|
+
italic: boolean;
|
|
1038
|
+
/**
|
|
1039
|
+
* 下划线
|
|
1040
|
+
*/
|
|
1041
|
+
underline: boolean;
|
|
1042
|
+
/**
|
|
1043
|
+
* 删除线
|
|
1044
|
+
*/
|
|
1045
|
+
strike: boolean;
|
|
1046
|
+
/**
|
|
1047
|
+
* 文本颜色
|
|
1048
|
+
*/
|
|
1049
|
+
color: Color;
|
|
1050
|
+
/**
|
|
1051
|
+
* 文本背景高亮颜色
|
|
1052
|
+
*/
|
|
1053
|
+
highlight: Color;
|
|
1054
|
+
/**
|
|
1055
|
+
* 文本大小
|
|
1056
|
+
*/
|
|
1057
|
+
size: number | string;
|
|
1058
|
+
/**
|
|
1059
|
+
* 文本名称
|
|
1060
|
+
*/
|
|
1061
|
+
family: string;
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
/**
|
|
1065
|
+
* 文本格式初始化选项
|
|
1066
|
+
*/
|
|
1067
|
+
export declare interface EditorTextOptions<Color = string> {
|
|
1068
|
+
/**
|
|
1069
|
+
* 当前编辑器默认的文本格式
|
|
1070
|
+
*/
|
|
1071
|
+
defaultFormat?: Partial<EditorTextFormat<Color>>;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
/**
|
|
1075
|
+
* 工具栏自定义按钮配置
|
|
1076
|
+
*/
|
|
1077
|
+
export declare interface EditorToolbarCustomButton extends Omit<EditorToolbarFeatureButton, 'name'> {
|
|
1078
|
+
/**
|
|
1079
|
+
* 自定义按钮名称
|
|
1080
|
+
*/
|
|
1081
|
+
name: string;
|
|
1082
|
+
/**
|
|
1083
|
+
* 按钮点击事件
|
|
1084
|
+
*/
|
|
1085
|
+
callback: () => void;
|
|
1086
|
+
/**
|
|
1087
|
+
* 按钮在工具栏中的位置,默认添加到工具栏所有按钮后面
|
|
1088
|
+
*/
|
|
1089
|
+
index?: number;
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
/**
|
|
1093
|
+
* 工具栏自定义按钮配置
|
|
1094
|
+
*/
|
|
1095
|
+
export declare interface EditorToolbarCustomButtonConfig {
|
|
1096
|
+
/**
|
|
1097
|
+
* 按钮配置
|
|
1098
|
+
*/
|
|
1099
|
+
[key: string]: EditorToolbarCustomButton;
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
/**
|
|
1103
|
+
* 工具栏内置功能按钮配置
|
|
1104
|
+
*/
|
|
1105
|
+
export declare interface EditorToolbarFeatureButton<ToolButtonName extends string = EditorToolbarFeatureButtonName> {
|
|
1106
|
+
/**
|
|
1107
|
+
* 按钮类型
|
|
1108
|
+
*/
|
|
1109
|
+
name: ToolButtonName;
|
|
1110
|
+
/**
|
|
1111
|
+
* 按钮标签(显示文本)
|
|
1112
|
+
*/
|
|
1113
|
+
label?: string;
|
|
1114
|
+
/**
|
|
1115
|
+
* 按钮图标,可以是 base64 的图片信息,也可以是图片 url
|
|
1116
|
+
*/
|
|
1117
|
+
icon?: string;
|
|
1118
|
+
/**
|
|
1119
|
+
* 按钮是否隐藏
|
|
1120
|
+
*/
|
|
1121
|
+
hidden?: boolean;
|
|
1122
|
+
/**
|
|
1123
|
+
* 按钮是否禁用
|
|
1124
|
+
*/
|
|
1125
|
+
disabled?: boolean;
|
|
1126
|
+
/**
|
|
1127
|
+
* 按钮提示文本
|
|
1128
|
+
*/
|
|
1129
|
+
tooltip?: string;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
/**
|
|
1133
|
+
* 工具栏内置功能按钮配置
|
|
1134
|
+
*/
|
|
1135
|
+
export declare type EditorToolbarFeatureButtonConfig<ToolButtonName extends string> = {
|
|
1136
|
+
[key in ToolButtonName]?: EditorToolbarFeatureButton<ToolButtonName>;
|
|
1137
|
+
};
|
|
1138
|
+
|
|
1139
|
+
/**
|
|
1140
|
+
* 工具栏内置功能按钮
|
|
1141
|
+
*/
|
|
1142
|
+
export declare type EditorToolbarFeatureButtonName =
|
|
1143
|
+
/**
|
|
1144
|
+
* 加粗
|
|
1145
|
+
*/
|
|
1146
|
+
'bold'
|
|
1147
|
+
/**
|
|
1148
|
+
* 斜体
|
|
1149
|
+
*/
|
|
1150
|
+
| 'italic'
|
|
1151
|
+
/**
|
|
1152
|
+
* 下划线
|
|
1153
|
+
*/
|
|
1154
|
+
| 'underline'
|
|
1155
|
+
/**
|
|
1156
|
+
* 删除线
|
|
1157
|
+
*/
|
|
1158
|
+
| 'strikethrough'
|
|
1159
|
+
/**
|
|
1160
|
+
* 插入图片
|
|
1161
|
+
*/
|
|
1162
|
+
| 'insertImage'
|
|
1163
|
+
/**
|
|
1164
|
+
* 插入链接
|
|
1165
|
+
*/
|
|
1166
|
+
| 'insertLink'
|
|
1167
|
+
/**
|
|
1168
|
+
* 限制编辑
|
|
1169
|
+
*/
|
|
1170
|
+
| 'restriction';
|
|
1171
|
+
|
|
1172
|
+
/**
|
|
1173
|
+
* 工具栏相关设置,可以控制工具栏的显示内容
|
|
1174
|
+
*/
|
|
1175
|
+
export declare interface EditorToolbarOptions<ToolButtonName extends string = EditorToolbarFeatureButtonName> {
|
|
1176
|
+
/**
|
|
1177
|
+
* 控制工具栏显隐状态
|
|
1178
|
+
*/
|
|
1179
|
+
hidden?: boolean;
|
|
1180
|
+
/**
|
|
1181
|
+
* 是否禁用工具栏所有功能
|
|
1182
|
+
*/
|
|
1183
|
+
disabled?: boolean;
|
|
1184
|
+
/**
|
|
1185
|
+
* 现有按钮的功能配置
|
|
1186
|
+
*/
|
|
1187
|
+
features?: EditorToolbarFeatureButtonConfig<ToolButtonName>;
|
|
1188
|
+
/**
|
|
1189
|
+
* 自定义按钮
|
|
1190
|
+
*/
|
|
1191
|
+
custom?: EditorToolbarCustomButtonConfig;
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
export declare type EditorUploadableFile = EditorLocalUploadableFile;
|
|
1195
|
+
|
|
1196
|
+
/**
|
|
1197
|
+
* 文件开始上传入参
|
|
1198
|
+
*/
|
|
1199
|
+
export declare interface EditorUploadStartOptions extends EditorUploadTaskCallbacks {
|
|
1200
|
+
files: EditorUploadableFile[];
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
/**
|
|
1204
|
+
* 上传状态
|
|
1205
|
+
*/
|
|
1206
|
+
export declare enum EditorUploadStatus {
|
|
1207
|
+
Waiting = "Waiting",
|
|
1208
|
+
Uploading = "Uploading",
|
|
1209
|
+
Paused = "Paused",
|
|
1210
|
+
Canceled = "Canceled",
|
|
1211
|
+
Error = "Error",
|
|
1212
|
+
Finished = "Finished"
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
export declare type EditorUploadTaskCallbacks = Omit<EditorTaskCallbacks, 'onEnd'> & {
|
|
1216
|
+
onLoadend: (results: {
|
|
1217
|
+
taskId: string;
|
|
1218
|
+
status: 'Error' | 'Finished' | 'Canceled';
|
|
1219
|
+
data?: unknown;
|
|
1220
|
+
}[]) => void;
|
|
1221
|
+
};
|
|
1222
|
+
|
|
1223
|
+
/**
|
|
1224
|
+
* 上传任务信息
|
|
1225
|
+
*/
|
|
1226
|
+
export declare interface EditorUploadTaskInfo {
|
|
1227
|
+
taskId: string;
|
|
1228
|
+
fileInfo: EditorUploadableFile;
|
|
1229
|
+
total: number;
|
|
1230
|
+
readonly loaded: number;
|
|
1231
|
+
readonly progress: number;
|
|
1232
|
+
readonly status: EditorUploadStatus;
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
/**
|
|
1236
|
+
* 操作当前编辑器的用户信息
|
|
1237
|
+
*/
|
|
1238
|
+
export declare interface EditorUserOptions {
|
|
1239
|
+
/**
|
|
1240
|
+
* 用户 ID,用于标识用户
|
|
1241
|
+
*/
|
|
1242
|
+
uid: string;
|
|
1243
|
+
/**
|
|
1244
|
+
* 用户名
|
|
1245
|
+
*/
|
|
1246
|
+
name: string;
|
|
1247
|
+
/**
|
|
1248
|
+
* 用户头像
|
|
1249
|
+
*/
|
|
1250
|
+
avatar?: string;
|
|
1251
|
+
/**
|
|
1252
|
+
* 用户默认头像,当用户未设置头像时显示
|
|
1253
|
+
*/
|
|
1254
|
+
defaultAvatar?: string;
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
/**
|
|
1258
|
+
* 编辑器外部水印信息
|
|
1259
|
+
*/
|
|
1260
|
+
export declare interface EditorWatermarkOptions {
|
|
1261
|
+
/**
|
|
1262
|
+
* 获取用作初始化使用的默认水印
|
|
1263
|
+
*/
|
|
1264
|
+
getWatermark: () => MaybePromiseValue<EditorWatermarkResource | null>;
|
|
1265
|
+
/**
|
|
1266
|
+
* 是否必须,如果为 true,编辑器将在初始化时强制渲染水印,
|
|
1267
|
+
* 水印配置信息加载失败将导致编辑器初始化失败
|
|
1268
|
+
*/
|
|
1269
|
+
required?: boolean;
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
export declare type EditorWatermarkResource = {
|
|
1273
|
+
type: 'data-url';
|
|
1274
|
+
url: string;
|
|
1275
|
+
} | {
|
|
1276
|
+
type: 'object-url';
|
|
1277
|
+
url: string;
|
|
1278
|
+
};
|
|
1279
|
+
|
|
1280
|
+
/**
|
|
1281
|
+
* 请求、响应头
|
|
1282
|
+
*/
|
|
1283
|
+
export declare type HTTPHeaders = Record<string, string | number | boolean | undefined>;
|
|
1284
|
+
|
|
1285
|
+
/**
|
|
1286
|
+
* 请求方法
|
|
1287
|
+
*/
|
|
1288
|
+
export declare type HTTPMethod = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH';
|
|
1289
|
+
|
|
1290
|
+
/**
|
|
1291
|
+
* HTTP 代理,用于抽象 HTTP 请求,
|
|
1292
|
+
* 将请求代理编辑器外部
|
|
1293
|
+
*/
|
|
1294
|
+
export declare interface HTTPProxy {
|
|
1295
|
+
/**
|
|
1296
|
+
* 发送请求,如果需要做请求、响应拦截,需要在 proxy.interceptors 中实现,
|
|
1297
|
+
* 套件内使用 proxy 发送请求的方式应该为类似如下方式:
|
|
1298
|
+
* ```ts
|
|
1299
|
+
* const raw = await proxy.request(proxy.interceptors?.request?.intercept(requestConfig) ?? requestConfig);
|
|
1300
|
+
* const response = proxy.interceptors?.response?.intercept(raw) ?? raw;
|
|
1301
|
+
* ```
|
|
1302
|
+
*
|
|
1303
|
+
* 套件内如果需要通过其他方式发送请求,比如通过浏览器的 Image API 加载,可以使用 proxy.interceptors?.request?.intercept(requestConfig) 处理请求配置
|
|
1304
|
+
* @param config
|
|
1305
|
+
* @returns
|
|
1306
|
+
*/
|
|
1307
|
+
request: <D = unknown, T = unknown>(config: HTTPRequestConfig<D>) => Promise<HTTPResponse<T>>;
|
|
1308
|
+
/**
|
|
1309
|
+
* 请求、响应拦截器,
|
|
1310
|
+
*
|
|
1311
|
+
*/
|
|
1312
|
+
interceptors?: {
|
|
1313
|
+
request?: {
|
|
1314
|
+
/**
|
|
1315
|
+
* 请求拦截器,传入请求配置,返回处理后的请求配置
|
|
1316
|
+
* @param requestConfig 请求配置
|
|
1317
|
+
* @returns
|
|
1318
|
+
*/
|
|
1319
|
+
intercept: <D = unknown>(requestConfig: HTTPRequestConfig<D>) => HTTPRequestConfig<D>;
|
|
1320
|
+
};
|
|
1321
|
+
response?: {
|
|
1322
|
+
/**
|
|
1323
|
+
* 响应拦截器,传入响应,返回处理后的响应
|
|
1324
|
+
* @param response
|
|
1325
|
+
* @returns
|
|
1326
|
+
*/
|
|
1327
|
+
intercept: <T = unknown>(response: HTTPResponse<T>) => HTTPResponse<T>;
|
|
1328
|
+
};
|
|
1329
|
+
};
|
|
1330
|
+
/**
|
|
1331
|
+
* 创建一个新的 HTTP 代理,用于为不同请求场景创建不同的代理
|
|
1332
|
+
* @param id
|
|
1333
|
+
* @returns
|
|
1334
|
+
*/
|
|
1335
|
+
create: (id: string) => Promise<HTTPProxy>;
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
/**
|
|
1339
|
+
* 请求配置
|
|
1340
|
+
*/
|
|
1341
|
+
export declare interface HTTPRequestConfig<Data = unknown> {
|
|
1342
|
+
/**
|
|
1343
|
+
* 请求地址
|
|
1344
|
+
*/
|
|
1345
|
+
url: string;
|
|
1346
|
+
/**
|
|
1347
|
+
* 请求方法
|
|
1348
|
+
*/
|
|
1349
|
+
method?: HTTPMethod;
|
|
1350
|
+
/**
|
|
1351
|
+
* 请求携带数据,主要是 POST、PUT、PATCH 等方法的请求数据
|
|
1352
|
+
*/
|
|
1353
|
+
data?: Data;
|
|
1354
|
+
/**
|
|
1355
|
+
* 期望的响应数据类型
|
|
1356
|
+
*/
|
|
1357
|
+
responseType?: HTTPResponseType;
|
|
1358
|
+
/**
|
|
1359
|
+
* 请求头
|
|
1360
|
+
*/
|
|
1361
|
+
headers?: HTTPHeaders;
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
/**
|
|
1365
|
+
* 响应数据
|
|
1366
|
+
*/
|
|
1367
|
+
export declare interface HTTPResponse<Data = unknown> {
|
|
1368
|
+
/**
|
|
1369
|
+
* 响应数据 body
|
|
1370
|
+
*/
|
|
1371
|
+
data: Data;
|
|
1372
|
+
/**
|
|
1373
|
+
* 响应状态码
|
|
1374
|
+
*/
|
|
1375
|
+
status: number;
|
|
1376
|
+
/**
|
|
1377
|
+
* 响应头
|
|
1378
|
+
*/
|
|
1379
|
+
headers: HTTPHeaders;
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
/**
|
|
1383
|
+
* 请求返回类型
|
|
1384
|
+
*/
|
|
1385
|
+
export declare type HTTPResponseType = 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream';
|
|
1386
|
+
|
|
1387
|
+
export declare type MaybePromiseValue<T> = T | Promise<T>;
|
|
1388
|
+
|
|
1389
|
+
export { }
|