@officesdk/editor-sdk-core 0.0.0-10 → 0.0.0-11

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.
@@ -1,16 +1,38 @@
1
- export declare abstract class AbstractedDocxSDK extends EditorSDK {
1
+ /**
2
+ * 抽象 Diagram 接口
3
+ */
4
+ export declare abstract class AbstractedDiagramSDK {
5
+ protected options: DiagramSDKOptions;
6
+ constructor(options: DiagramSDKOptions);
2
7
  /**
3
- * 打印文档
8
+ * 初始化 Diagram 、加载插件等操作。
4
9
  */
5
- abstract print(): Promise<void>;
10
+ abstract init(): Promise<void>;
6
11
  /**
7
- * 跳转到某个位置
12
+ * 销毁 Diagram
8
13
  */
9
- abstract goto(options: DocxGotoOptions): boolean;
14
+ abstract destroy(): Promise<void>;
10
15
  /**
11
- * 文档缩放接口
12
- * @param scale
16
+ * 将 Diagram 挂载到指定的根节点上,并渲染,
17
+ * mount 应该在 init 之后调用。
18
+ * @param root
19
+ */
20
+ abstract mount(root: HTMLElement): Promise<void>;
21
+ /**
22
+ * 从根节点卸载 Diagram ,对应 `mount` 操作
23
+ */
24
+ abstract unmount(): Promise<void>;
25
+ }
26
+
27
+ export declare abstract class AbstractedDocxSDK extends EditorSDK {
28
+ /**
29
+ * 文档准备就绪
30
+ */
31
+ abstract ready(): Promise<void>;
32
+ /**
33
+ * 打印文档
13
34
  */
35
+ abstract print(): Promise<void>;
14
36
  /**
15
37
  * 文档目录集合接口,
16
38
  * 一个文档中可以存在多个目录,这个接口是用来管理文档中的所有目录的。
@@ -46,6 +68,165 @@ export declare abstract class AbstractedDocxSDK extends EditorSDK {
46
68
  abstract get search(): DocxSearch;
47
69
  }
48
70
 
71
+ export declare abstract class AbstractedEditorFileUploader {
72
+ /**
73
+ * 开始上传
74
+ * @param options
75
+ */
76
+ abstract start(options: EditorUploadStartOptions): EditorUploadTaskInfo[];
77
+ /**
78
+ * 暂停上传,不传参数则取消所有上传任务
79
+ * @param taskIds
80
+ */
81
+ abstract pause(taskIds?: string[]): void;
82
+ /**
83
+ * 暂停上传,不传参数则暂停所有上传任务
84
+ * @param taskIds
85
+ */
86
+ abstract abort(taskIds?: string[]): void;
87
+ /**
88
+ * 恢复上传,不传参数则恢复所有上传任务
89
+ * @param taskIds
90
+ */
91
+ abstract resume(taskIds?: string[]): void;
92
+ }
93
+
94
+ /**
95
+ * 抽象 Pdf 接口
96
+ */
97
+ export declare abstract class AbstractedPdfSDK {
98
+ protected options: PdfSDKOptions;
99
+ constructor(options: PdfSDKOptions);
100
+ /**
101
+ * 初始化 Pdf 、加载插件等操作。
102
+ */
103
+ abstract init(): Promise<void>;
104
+ /**
105
+ * 销毁 Pdf
106
+ */
107
+ abstract destroy(): Promise<void>;
108
+ /**
109
+ * 将 Pdf 挂载到指定的根节点上,并渲染,
110
+ * mount 应该在 init 之后调用。
111
+ * @param root
112
+ */
113
+ abstract mount(root: HTMLElement): Promise<void>;
114
+ /**
115
+ * 从根节点卸载 pdf ,对应 `mount` 操作
116
+ */
117
+ abstract unmount(): Promise<void>;
118
+ /**
119
+ * pdf 页面操作接口
120
+ */
121
+ abstract get pages(): PdfPages;
122
+ /**
123
+ * pdf 选区接口
124
+ */
125
+ abstract get selection(): PdfSelection;
126
+ /**
127
+ * pdf 目录接口
128
+ */
129
+ abstract get outline(): PdfOutline;
130
+ }
131
+
132
+ export declare abstract class AbstractedPresentationSDK extends EditorSDK {
133
+ /**
134
+ * 幻灯片准备就绪
135
+ */
136
+ abstract ready(): Promise<void>;
137
+ /**
138
+ * 打印幻灯片
139
+ */
140
+ abstract print(): Promise<void>;
141
+ /**
142
+ * 幻灯片集合接口
143
+ */
144
+ abstract get slides(): PresentationSlides;
145
+ /**
146
+ * 幻灯片选区接口,用于获取、操作当前 slide 的选区
147
+ */
148
+ abstract get selection(): PresentationSelection;
149
+ /**
150
+ * 幻灯片缩放接口
151
+ * @param scale
152
+ */
153
+ abstract get zoom(): PresentationZoom;
154
+ /**
155
+ * 文本格式接口
156
+ */
157
+ abstract get text(): PresentationText;
158
+ }
159
+
160
+ export declare abstract class AbstractedSheetSDK extends EditorSDK {
161
+ /**
162
+ * 表格准备就绪
163
+ */
164
+ abstract ready(): Promise<void>;
165
+ /**
166
+ * 打印文档
167
+ */
168
+ abstract print(): Promise<void>;
169
+ /**
170
+ * 工作簿接口
171
+ */
172
+ abstract get workbook(): SheetWorkbook;
173
+ /**
174
+ * 当前活跃工作表对象
175
+ */
176
+ abstract get activeSheet(): SheetWorksheet;
177
+ /**
178
+ * 当前活动单元格
179
+ */
180
+ abstract get activeCell(): SheetCell | null;
181
+ /**
182
+ * 获取当前选区
183
+ */
184
+ abstract get selections(): SheetSelection[] | null;
185
+ /**
186
+ * 文本格式接口
187
+ */
188
+ abstract get text(): SheetText;
189
+ }
190
+
191
+ /**
192
+ * Diagram 初始化参数
193
+ */
194
+ export declare interface DiagramSDKOptions {
195
+ /**
196
+ * Diagram 初始化内容,可以是 string 或者 ArrayBuffer,
197
+ * 也可以通过异步 Promise 加载
198
+ */
199
+ content: MaybePromiseValue<string | ArrayBuffer>;
200
+ /**
201
+ * 当前操作 Diagram 的用户信息
202
+ */
203
+ user?: EditorUserOptions;
204
+ /**
205
+ * i18n 相关设置
206
+ */
207
+ i18n?: EditorI18nOptions;
208
+ /**
209
+ * 品牌相关设置
210
+ */
211
+ brand?: EditorBrandOptions;
212
+ /**
213
+ * Diagram 内部资源请求配置
214
+ */
215
+ assets?: EditorAssetsOptions;
216
+ /**
217
+ * Diagram 内部超链接设置
218
+ */
219
+ link?: EditorLinkOptions;
220
+ /**
221
+ * 初始化水印配置
222
+ */
223
+ watermark?: EditorWatermarkOptions;
224
+ /**
225
+ * Diagram 打印设置
226
+ */
227
+ print?: EditorPrintOptions;
228
+ }
229
+
49
230
  export declare type DocxFontFace = Omit<EditorFontFace, 'meta'> & {
50
231
  meta: DocxFontMeta;
51
232
  };
@@ -117,40 +298,6 @@ export declare interface DocxFontsOptions {
117
298
  list: DocxFontsList;
118
299
  }
119
300
 
120
- export declare type DocxGotoOptions = {
121
- /**
122
- * 区域,跳转到对应区域位置
123
- */
124
- type: 'range';
125
- /**
126
- * 区域值,这个值可以通过 DocxSelection 的 getRange 方法拿到
127
- */
128
- range: string;
129
- } | {
130
- /**
131
- * 页码,跳转到对应页码位置
132
- */
133
- type: 'page';
134
- /**
135
- * 页码
136
- */
137
- page: number;
138
- } | {
139
- /**
140
- * 顶部,跳转到文档顶部
141
- */
142
- type: 'top';
143
- } | {
144
- /**
145
- * 跳转到某个评论
146
- */
147
- type: 'comment';
148
- /**
149
- * 评论 ID
150
- */
151
- commentId: string;
152
- };
153
-
154
301
  /**
155
302
  * 图片水印属性值
156
303
  */
@@ -180,6 +327,8 @@ export declare interface DocxInfoOptions {
180
327
  time?: number;
181
328
  author?: string;
182
329
  };
330
+ id: string;
331
+ name: string;
183
332
  }
184
333
 
185
334
  /**
@@ -817,12 +966,21 @@ export declare type DocxWatermarkOptions = EditorWatermarkOptions;
817
966
  * 文档窗口接口
818
967
  */
819
968
  export declare interface DocxWindow {
969
+ /**
970
+ * 获取当前文档滚动位置,
971
+ * 返回值为当前文档滚动位置的偏移量,
972
+ * 这个偏移量是基于文档的左上角为原点,向右向下为正方向
973
+ * @returns
974
+ */
975
+ getScrollPosition: () => {
976
+ x: number;
977
+ y: number;
978
+ };
820
979
  /**
821
980
  * 滚动到指定位置
822
- * @param x
823
- * @param y
981
+ * @param params 滚动参数
824
982
  */
825
- scrollTo: (x: number, y: number) => void;
983
+ scrollTo: (params: DocxWindowScrollParams) => void;
826
984
  /**
827
985
  * 滚动到指定页面
828
986
  * @param page
@@ -843,6 +1001,65 @@ export declare interface DocxWindow {
843
1001
  }) => void) => () => void;
844
1002
  }
845
1003
 
1004
+ export declare type DocxWindowScrollParams = {
1005
+ /**
1006
+ * 区域,跳转到对应区域位置
1007
+ */
1008
+ type: 'range';
1009
+ /**
1010
+ * 区域值,这个值可以通过 DocxSelection 的 getRange 方法拿到
1011
+ */
1012
+ range: string;
1013
+ } | {
1014
+ /**
1015
+ * 页码,跳转到对应页码位置
1016
+ */
1017
+ type: 'page';
1018
+ /**
1019
+ * 页码
1020
+ */
1021
+ page: number;
1022
+ } | {
1023
+ /**
1024
+ * 顶部,跳转到文档顶部
1025
+ */
1026
+ type: 'top';
1027
+ } | {
1028
+ /**
1029
+ * 滚动到某个位置,
1030
+ * 这个位置是基于文档的左上角为原点,向右向下为正方向
1031
+ */
1032
+ type: 'position';
1033
+ /**
1034
+ * 位置
1035
+ */
1036
+ position: {
1037
+ x: number;
1038
+ y: number;
1039
+ };
1040
+ } | {
1041
+ /**
1042
+ * 偏移量,跳转到对应偏移量位置
1043
+ */
1044
+ type: 'offset';
1045
+ /**
1046
+ * 偏移量
1047
+ */
1048
+ offset: {
1049
+ x: number;
1050
+ y: number;
1051
+ };
1052
+ } | {
1053
+ /**
1054
+ * 跳转到某个评论
1055
+ */
1056
+ type: 'comment';
1057
+ /**
1058
+ * 评论 ID
1059
+ */
1060
+ commentId: string;
1061
+ };
1062
+
846
1063
  /**
847
1064
  * 文档缩放接口
848
1065
  */
@@ -884,7 +1101,7 @@ export declare interface DocxZoom {
884
1101
  /**
885
1102
  * 编辑器内部资源请求配置
886
1103
  */
887
- declare interface EditorAssetsOptions {
1104
+ export declare interface EditorAssetsOptions {
888
1105
  /**
889
1106
  * 通用资源请求代理配置,
890
1107
  * 用于套件内部资源请求时代理请求
@@ -903,7 +1120,7 @@ declare interface EditorAssetsOptions {
903
1120
  /**
904
1121
  * 基于对象存储的图片处理抽象
905
1122
  */
906
- declare interface EditorAssetsOssImageProcessing {
1123
+ export declare interface EditorAssetsOssImageProcessing {
907
1124
  /**
908
1125
  * 压缩图片的方法
909
1126
  * @param imageUrl 图片的 URL
@@ -930,7 +1147,7 @@ declare interface EditorAssetsOssImageProcessing {
930
1147
  }) => Promise<string>;
931
1148
  }
932
1149
 
933
- declare interface EditorAssetsResolver {
1150
+ export declare interface EditorAssetsResolver {
934
1151
  /**
935
1152
  * 将资源文件 ID 转换为 URL 的方法
936
1153
  * @param assetId 资源文件 ID
@@ -952,11 +1169,29 @@ declare interface EditorAssetsResolver {
952
1169
  checkAssetReady: (assetId: string) => Promise<boolean> | boolean;
953
1170
  }
954
1171
 
1172
+ /**
1173
+ * 编辑器附件信息
1174
+ */
1175
+ export declare interface EditorAttachmentOptions {
1176
+ uploader: AbstractedEditorFileUploader;
1177
+ download: (url: string) => void;
1178
+ }
1179
+
1180
+ /**
1181
+ * 基础文件属性
1182
+ */
1183
+ export declare interface EditorBaseUploadableFile {
1184
+ secretly?: boolean;
1185
+ bucket: 'images' | 'attachments';
1186
+ encrypt: string;
1187
+ fileGuid: string;
1188
+ }
1189
+
955
1190
  /**
956
1191
  * 品牌相关设置,
957
1192
  * 用于在套件中展示品牌外露信息
958
1193
  */
959
- declare interface EditorBrandOptions {
1194
+ export declare interface EditorBrandOptions {
960
1195
  /**
961
1196
  * 需要显示在品牌展示位的内容,按数组顺序显示
962
1197
  */
@@ -980,7 +1215,7 @@ declare interface EditorBrandOptions {
980
1215
  /**
981
1216
  * 单条评论数据
982
1217
  */
983
- declare interface EditorCommentItem {
1218
+ export declare interface EditorCommentItem {
984
1219
  /**
985
1220
  * 评论 ID
986
1221
  */
@@ -997,7 +1232,7 @@ declare interface EditorCommentItem {
997
1232
  };
998
1233
  }
999
1234
 
1000
- declare interface EditorComments {
1235
+ export declare interface EditorComments {
1001
1236
  /**
1002
1237
  * 检查是否有评论
1003
1238
  * @returns
@@ -1043,7 +1278,7 @@ declare interface EditorComments {
1043
1278
  /**
1044
1279
  * 编辑器评论初始化配置
1045
1280
  */
1046
- declare interface EditorCommentsOptions {
1281
+ export declare interface EditorCommentsOptions {
1047
1282
  /**
1048
1283
  * 评论作者信息,如果这里的信息为空,将会使用 user 信息
1049
1284
  */
@@ -1074,7 +1309,7 @@ declare interface EditorCommentsOptions {
1074
1309
  };
1075
1310
  }
1076
1311
 
1077
- declare interface EditorContent {
1312
+ export declare interface EditorContent {
1078
1313
  /**
1079
1314
  * 设置编辑器内容
1080
1315
  * @param content
@@ -1091,7 +1326,7 @@ declare interface EditorContent {
1091
1326
  addChangeListener: (listener: (change: EditorDelta) => void) => () => void;
1092
1327
  }
1093
1328
 
1094
- declare interface EditorDelta {
1329
+ export declare interface EditorDelta {
1095
1330
  compose: (other: EditorDelta, isDocument?: boolean) => EditorDelta;
1096
1331
  transform: (other: EditorDelta, priority?: boolean) => EditorDelta;
1097
1332
  stringify: () => string;
@@ -1101,7 +1336,7 @@ declare interface EditorDelta {
1101
1336
  /**
1102
1337
  * 编辑器嵌入对象
1103
1338
  */
1104
- declare interface EditorEmbeddedObject {
1339
+ export declare interface EditorEmbeddedObject {
1105
1340
  /**
1106
1341
  * 嵌入的对象 url
1107
1342
  */
@@ -1119,7 +1354,7 @@ declare interface EditorEmbeddedObject {
1119
1354
  /**
1120
1355
  * 编辑器嵌入对象抽象类
1121
1356
  */
1122
- declare interface EditorEmbeddedObjectOptions {
1357
+ export declare interface EditorEmbeddedObjectOptions {
1123
1358
  /**
1124
1359
  * 执行打开嵌入对象操作,
1125
1360
  * 如果已经处理了打开操作,返回 true,否则返回 false,
@@ -1147,7 +1382,20 @@ declare interface EditorEmbeddedObjectOptions {
1147
1382
  };
1148
1383
  }
1149
1384
 
1150
- declare interface EditorFontFace {
1385
+ export declare interface EditorExportOptions {
1386
+ /**
1387
+ * 可导出类型
1388
+ * @description
1389
+ */
1390
+ supportedTypes?: string[];
1391
+ /**
1392
+ * 导出文件
1393
+ * @description
1394
+ */
1395
+ exportFile: (type: string) => Promise<void>;
1396
+ }
1397
+
1398
+ export declare interface EditorFontFace {
1151
1399
  /**
1152
1400
  * 字体的名称,用于在用户界面上显示的名称
1153
1401
  */
@@ -1173,7 +1421,7 @@ declare interface EditorFontFace {
1173
1421
  /**
1174
1422
  * 字体元数据
1175
1423
  */
1176
- declare interface EditorFontMeta {
1424
+ export declare interface EditorFontMeta {
1177
1425
  head: {
1178
1426
  unitsPerEm: number;
1179
1427
  };
@@ -1207,10 +1455,28 @@ declare interface EditorFontMeta {
1207
1455
  };
1208
1456
  }
1209
1457
 
1458
+ /**
1459
+ * 字体列表
1460
+ */
1461
+ export declare interface EditorFontsList {
1462
+ /**
1463
+ * 返回解析为字体的列表的 Promise。
1464
+ */
1465
+ getAll: () => Promise<EditorFontFace[]>;
1466
+ }
1467
+
1468
+ export declare interface EditorFontsOptions {
1469
+ /**
1470
+ * 服务器字体列表,用于获取服务器端配置的字体列表,
1471
+ * 并提供可用于字体的加载 URL 和字体元数据。
1472
+ */
1473
+ list: EditorFontsList;
1474
+ }
1475
+
1210
1476
  /**
1211
1477
  * i18n 相关设置
1212
1478
  */
1213
- declare interface EditorI18nOptions {
1479
+ export declare interface EditorI18nOptions {
1214
1480
  /**
1215
1481
  * 语言,默认使用浏览器当前环境中的语言
1216
1482
  */
@@ -1221,12 +1487,12 @@ declare interface EditorI18nOptions {
1221
1487
  direction?: 'ltr' | 'rtl';
1222
1488
  }
1223
1489
 
1224
- declare type EditorImageCropPoint = 'nw' | 'north' | 'ne' | 'west' | 'center' | 'east' | 'sw' | 'south' | 'se';
1490
+ export declare type EditorImageCropPoint = 'nw' | 'north' | 'ne' | 'west' | 'center' | 'east' | 'sw' | 'south' | 'se';
1225
1491
 
1226
1492
  /**
1227
1493
  * 链接配置,抽象打开链接等操作
1228
1494
  */
1229
- declare interface EditorLinkOptions {
1495
+ export declare interface EditorLinkOptions {
1230
1496
  /**
1231
1497
  * 打开链接,如果取消了打开链接操作,返回 false
1232
1498
  * @param url
@@ -1236,10 +1502,20 @@ declare interface EditorLinkOptions {
1236
1502
  open: (url: string, target: string) => Promise<boolean>;
1237
1503
  }
1238
1504
 
1505
+ /**
1506
+ * 可上传文件
1507
+ */
1508
+ export declare interface EditorLocalUploadableFile extends EditorBaseUploadableFile {
1509
+ name: string;
1510
+ size: number;
1511
+ mime: string;
1512
+ raw: File;
1513
+ }
1514
+
1239
1515
  /**
1240
1516
  * 菜单栏自定义按钮配置
1241
1517
  */
1242
- declare type EditorMenuCustomButton = {
1518
+ export declare type EditorMenuCustomButton = {
1243
1519
  /**
1244
1520
  * 按钮名称
1245
1521
  */
@@ -1282,7 +1558,7 @@ declare type EditorMenuCustomButton = {
1282
1558
  /**
1283
1559
  * 菜单栏二级以下的菜单入口
1284
1560
  */
1285
- declare interface EditorMenuEntryButton {
1561
+ export declare interface EditorMenuEntryButton {
1286
1562
  type: 'entry';
1287
1563
  /**
1288
1564
  * 菜单名称
@@ -1298,7 +1574,7 @@ declare interface EditorMenuEntryButton {
1298
1574
  * 菜单栏一级菜单配置,此处用于定义一级菜单的操作入口,
1299
1575
  * 一级菜单在鼠标悬停时展示二级列表
1300
1576
  */
1301
- declare interface EditorMenuEntryConfig<TName extends string> {
1577
+ export declare interface EditorMenuEntryConfig<TName extends string> {
1302
1578
  /**
1303
1579
  * 一级菜单名称
1304
1580
  */
@@ -1314,7 +1590,7 @@ declare interface EditorMenuEntryConfig<TName extends string> {
1314
1590
  /**
1315
1591
  * 菜单栏功能按钮配置
1316
1592
  */
1317
- declare type EditorMenuFeatureButton<TName extends string> = {
1593
+ export declare type EditorMenuFeatureButton<TName extends string> = {
1318
1594
  /**
1319
1595
  * 隐藏按钮,用作在需要隐藏菜单栏时定义
1320
1596
  */
@@ -1342,13 +1618,13 @@ declare type EditorMenuFeatureButton<TName extends string> = {
1342
1618
  /**
1343
1619
  * 菜单栏按钮配置
1344
1620
  */
1345
- declare type EditorMenuFeatureButtonConfig<TName extends string> = Record<TName, EditorMenuFeatureButton<TName>>;
1621
+ export declare type EditorMenuFeatureButtonConfig<TName extends string> = Record<TName, EditorMenuFeatureButton<TName>>;
1346
1622
 
1347
1623
  /**
1348
1624
  * 菜单栏相关配置,目前菜单栏不是所有套件都支持,
1349
1625
  * 菜单栏是指的编辑器最上放可以展开二级菜单的那一栏。
1350
1626
  */
1351
- declare interface EditorMenuOptions<TName extends string> {
1627
+ export declare interface EditorMenuOptions<TName extends string> {
1352
1628
  /**
1353
1629
  * 菜单栏是否显示
1354
1630
  */
@@ -1374,7 +1650,7 @@ declare interface EditorMenuOptions<TName extends string> {
1374
1650
  /**
1375
1651
  * 编辑器基础模式接口
1376
1652
  */
1377
- declare interface EditorMode {
1653
+ export declare interface EditorMode {
1378
1654
  /**
1379
1655
  * 获取当前编辑器模式
1380
1656
  */
@@ -1393,7 +1669,7 @@ declare interface EditorMode {
1393
1669
  /**
1394
1670
  * 编辑器初始化的时相关的模式配置
1395
1671
  */
1396
- declare type EditorModeOptions = {
1672
+ export declare type EditorModeOptions = {
1397
1673
  type: 'standard';
1398
1674
  /**
1399
1675
  * 当 mode 为 `standard` 时,可以设置当前编辑器的权限模式
@@ -1411,12 +1687,12 @@ declare type EditorModeOptions = {
1411
1687
  * - `preview` 预览模式,只能查看内容
1412
1688
  * - `presentation` 演示模式,用作演示场景,演示模式下部分套件可以进行一些简单的编辑操作
1413
1689
  */
1414
- declare type EditorModeType = 'standard' | 'preview' | 'presentation';
1690
+ export declare type EditorModeType = 'standard' | 'preview' | 'presentation';
1415
1691
 
1416
1692
  /**
1417
1693
  * 编辑器初始化通用参数
1418
1694
  */
1419
- declare interface EditorOptions {
1695
+ export declare interface EditorOptions {
1420
1696
  /**
1421
1697
  * 编辑器初始化内容,可以是 string 或者 ArrayBuffer,
1422
1698
  * 也可以通过异步 Promise 加载
@@ -1466,12 +1742,20 @@ declare interface EditorOptions {
1466
1742
  * 编辑器评论设置
1467
1743
  */
1468
1744
  comments?: EditorCommentsOptions;
1745
+ /**
1746
+ * 附件设置
1747
+ */
1748
+ attachment?: EditorAttachmentOptions;
1749
+ /**
1750
+ * 导出设置
1751
+ */
1752
+ export?: EditorExportOptions;
1469
1753
  }
1470
1754
 
1471
1755
  /**
1472
1756
  * 大纲目录接口
1473
1757
  */
1474
- declare interface EditorOutline<Content = unknown> {
1758
+ export declare interface EditorOutline<Content = unknown> {
1475
1759
  /**
1476
1760
  * 设置大纲目录是否可见
1477
1761
  * @param visible 是否可见
@@ -1499,7 +1783,7 @@ declare interface EditorOutline<Content = unknown> {
1499
1783
  /**
1500
1784
  * 大纲目录项条目
1501
1785
  */
1502
- declare interface EditorOutlineItem<Content = unknown> {
1786
+ export declare interface EditorOutlineItem<Content = unknown> {
1503
1787
  /**
1504
1788
  * 目录项 ID
1505
1789
  */
@@ -1518,7 +1802,7 @@ declare interface EditorOutlineItem<Content = unknown> {
1518
1802
  * 大纲目录初始化参数,
1519
1803
  * 用于配置大纲目录的行为和外观。
1520
1804
  */
1521
- declare interface EditorOutlineOptions {
1805
+ export declare interface EditorOutlineOptions {
1522
1806
  /**
1523
1807
  * 初始化编辑器时是否显示大纲目录,
1524
1808
  * 默认为 false。
@@ -1529,7 +1813,7 @@ declare interface EditorOutlineOptions {
1529
1813
  /**
1530
1814
  * 编辑器打印设置
1531
1815
  */
1532
- declare interface EditorPrintOptions {
1816
+ export declare interface EditorPrintOptions {
1533
1817
  /**
1534
1818
  * 部分套件如果绕过了编辑器预设的打印接口,直接通过拉起了浏览器的打印页面,这时打印页面无法获取到编辑器的内容,
1535
1819
  * 这种情况下就会 fallback 到这个 options 上,显示一个提示信息。
@@ -1543,10 +1827,21 @@ declare interface EditorPrintOptions {
1543
1827
  disabled?: boolean;
1544
1828
  }
1545
1829
 
1830
+ /**
1831
+ * 远程文件上传
1832
+ */
1833
+ export declare interface EditorRemoteUploadableFile extends EditorBaseUploadableFile {
1834
+ src: string;
1835
+ name?: never;
1836
+ size?: never;
1837
+ mime?: never;
1838
+ raw?: never;
1839
+ }
1840
+
1546
1841
  /**
1547
1842
  * 编辑器通用接口
1548
1843
  */
1549
- declare abstract class EditorSDK {
1844
+ export declare abstract class EditorSDK {
1550
1845
  protected options: EditorOptions;
1551
1846
  constructor(options: EditorOptions);
1552
1847
  /**
@@ -1587,15 +1882,64 @@ declare abstract class EditorSDK {
1587
1882
  * - `viewer` 阅读模式
1588
1883
  * - `reviewer` 评论模式
1589
1884
  */
1590
- declare type EditorStandardRole = 'editor' | 'viewer' | 'reviewer';
1885
+ export declare type EditorStandardRole = 'editor' | 'viewer' | 'reviewer';
1591
1886
 
1592
1887
  /**
1593
- * 文本格式接口,
1594
- * 包括设置、读取选区内文本的 BIUS、family、大小、颜色等
1888
+ * 上传任务回调
1595
1889
  */
1596
- declare interface EditorText<Color = string, TRangeValue = unknown> {
1890
+ export declare interface EditorTaskCallbacks {
1597
1891
  /**
1598
- * 获取当前选区或指定选区内的文本格式状态
1892
+ * 上传进度回调
1893
+ * @param taskId
1894
+ * @param loaded
1895
+ * @param total
1896
+ * @param progress
1897
+ * @param data
1898
+ * @returns
1899
+ */
1900
+ onProgress?: (taskId: string, loaded: number, total: number, progress: number, data?: unknown) => void;
1901
+ /**
1902
+ * 上传错误回调
1903
+ * @param taskId
1904
+ * @param error
1905
+ * @returns
1906
+ */
1907
+ onError?: (taskId: string, error: Error) => void;
1908
+ /**
1909
+ * 上传暂停回调
1910
+ * @param taskId
1911
+ * @returns
1912
+ */
1913
+ onPause?: (taskId: string) => void;
1914
+ /**
1915
+ * 上传取消
1916
+ * @param taskId
1917
+ * @returns
1918
+ */
1919
+ onAbort?: (taskId: string) => void;
1920
+ /**
1921
+ * 上传恢复
1922
+ * @param taskId
1923
+ * @returns
1924
+ */
1925
+ onResume?: (taskId: string) => void;
1926
+ /**
1927
+ * 上传完成回调
1928
+ * @param taskId
1929
+ * @param status
1930
+ * @param data
1931
+ * @returns
1932
+ */
1933
+ onEnd?: (taskId: string, status: 'Error' | 'Finished' | 'Canceled', data: unknown) => void;
1934
+ }
1935
+
1936
+ /**
1937
+ * 文本格式接口,
1938
+ * 包括设置、读取选区内文本的 BIUS、family、大小、颜色等
1939
+ */
1940
+ export declare interface EditorText<Color = string, TRangeValue = unknown> {
1941
+ /**
1942
+ * 获取当前选区或指定选区内的文本格式状态
1599
1943
  */
1600
1944
  get: (range?: TRangeValue) => Partial<EditorTextFormat<Color>>;
1601
1945
  /**
@@ -1617,7 +1961,7 @@ declare interface EditorText<Color = string, TRangeValue = unknown> {
1617
1961
  /**
1618
1962
  * 文本格式状态
1619
1963
  */
1620
- declare interface EditorTextFormat<Color = string> {
1964
+ export declare interface EditorTextFormat<Color = string> {
1621
1965
  /**
1622
1966
  * 粗体
1623
1967
  */
@@ -1655,7 +1999,7 @@ declare interface EditorTextFormat<Color = string> {
1655
1999
  /**
1656
2000
  * 文本格式初始化选项
1657
2001
  */
1658
- declare interface EditorTextOptions<Color = string> {
2002
+ export declare interface EditorTextOptions<Color = string> {
1659
2003
  /**
1660
2004
  * 当前编辑器默认的文本格式
1661
2005
  */
@@ -1665,7 +2009,7 @@ declare interface EditorTextOptions<Color = string> {
1665
2009
  /**
1666
2010
  * 工具栏自定义按钮配置
1667
2011
  */
1668
- declare interface EditorToolbarCustomButton extends Omit<EditorToolbarFeatureButton, 'name'> {
2012
+ export declare interface EditorToolbarCustomButton extends Omit<EditorToolbarFeatureButton, 'name'> {
1669
2013
  /**
1670
2014
  * 自定义按钮名称
1671
2015
  */
@@ -1683,7 +2027,7 @@ declare interface EditorToolbarCustomButton extends Omit<EditorToolbarFeatureBut
1683
2027
  /**
1684
2028
  * 工具栏自定义按钮配置
1685
2029
  */
1686
- declare interface EditorToolbarCustomButtonConfig {
2030
+ export declare interface EditorToolbarCustomButtonConfig {
1687
2031
  /**
1688
2032
  * 按钮配置
1689
2033
  */
@@ -1693,7 +2037,7 @@ declare interface EditorToolbarCustomButtonConfig {
1693
2037
  /**
1694
2038
  * 工具栏内置功能按钮配置
1695
2039
  */
1696
- declare interface EditorToolbarFeatureButton {
2040
+ export declare interface EditorToolbarFeatureButton {
1697
2041
  /**
1698
2042
  * 按钮类型
1699
2043
  */
@@ -1719,14 +2063,14 @@ declare interface EditorToolbarFeatureButton {
1719
2063
  /**
1720
2064
  * 工具栏内置功能按钮配置
1721
2065
  */
1722
- declare type EditorToolbarFeatureButtonConfig = {
2066
+ export declare type EditorToolbarFeatureButtonConfig = {
1723
2067
  [key in EditorToolbarFeatureButtonName]?: EditorToolbarFeatureButton;
1724
2068
  };
1725
2069
 
1726
2070
  /**
1727
2071
  * 工具栏内置功能按钮
1728
2072
  */
1729
- declare type EditorToolbarFeatureButtonName =
2073
+ export declare type EditorToolbarFeatureButtonName =
1730
2074
  /**
1731
2075
  * 加粗
1732
2076
  */
@@ -1759,7 +2103,7 @@ declare type EditorToolbarFeatureButtonName =
1759
2103
  /**
1760
2104
  * 工具栏相关设置,可以控制工具栏的显示内容
1761
2105
  */
1762
- declare interface EditorToolbarOptions {
2106
+ export declare interface EditorToolbarOptions {
1763
2107
  /**
1764
2108
  * 控制工具栏显隐状态
1765
2109
  */
@@ -1778,10 +2122,51 @@ declare interface EditorToolbarOptions {
1778
2122
  custom?: EditorToolbarCustomButtonConfig;
1779
2123
  }
1780
2124
 
2125
+ export declare type EditorUploadableFile = EditorLocalUploadableFile;
2126
+
2127
+ /**
2128
+ * 文件开始上传入参
2129
+ */
2130
+ export declare interface EditorUploadStartOptions extends EditorUploadTaskCallbacks {
2131
+ files: EditorUploadableFile[];
2132
+ }
2133
+
2134
+ /**
2135
+ * 上传状态
2136
+ */
2137
+ export declare enum EditorUploadStatus {
2138
+ Waiting = "Waiting",
2139
+ Uploading = "Uploading",
2140
+ Paused = "Paused",
2141
+ Canceled = "Canceled",
2142
+ Error = "Error",
2143
+ Finished = "Finished"
2144
+ }
2145
+
2146
+ export declare type EditorUploadTaskCallbacks = Omit<EditorTaskCallbacks, 'onEnd'> & {
2147
+ onLoadend: (results: {
2148
+ taskId: string;
2149
+ status: 'Error' | 'Finished' | 'Canceled';
2150
+ data?: unknown;
2151
+ }[]) => void;
2152
+ };
2153
+
2154
+ /**
2155
+ * 上传任务信息
2156
+ */
2157
+ export declare interface EditorUploadTaskInfo {
2158
+ taskId: string;
2159
+ fileInfo: EditorUploadableFile;
2160
+ total: number;
2161
+ readonly loaded: number;
2162
+ readonly progress: number;
2163
+ readonly status: EditorUploadStatus;
2164
+ }
2165
+
1781
2166
  /**
1782
2167
  * 操作当前编辑器的用户信息
1783
2168
  */
1784
- declare interface EditorUserOptions {
2169
+ export declare interface EditorUserOptions {
1785
2170
  /**
1786
2171
  * 用户 ID,用于标识用户
1787
2172
  */
@@ -1799,7 +2184,7 @@ declare interface EditorUserOptions {
1799
2184
  /**
1800
2185
  * 编辑器外部水印信息
1801
2186
  */
1802
- declare interface EditorWatermarkOptions {
2187
+ export declare interface EditorWatermarkOptions {
1803
2188
  /**
1804
2189
  * 获取用作初始化使用的默认水印
1805
2190
  */
@@ -1811,7 +2196,7 @@ declare interface EditorWatermarkOptions {
1811
2196
  required?: boolean;
1812
2197
  }
1813
2198
 
1814
- declare type EditorWatermarkResource = {
2199
+ export declare type EditorWatermarkResource = {
1815
2200
  type: 'data-url';
1816
2201
  url: string;
1817
2202
  } | {
@@ -1822,18 +2207,18 @@ declare type EditorWatermarkResource = {
1822
2207
  /**
1823
2208
  * 请求、响应头
1824
2209
  */
1825
- declare type HTTPHeaders = Record<string, string | number | boolean | undefined>;
2210
+ export declare type HTTPHeaders = Record<string, string | number | boolean | undefined>;
1826
2211
 
1827
2212
  /**
1828
2213
  * 请求方法
1829
2214
  */
1830
- declare type HTTPMethod = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH';
2215
+ export declare type HTTPMethod = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH';
1831
2216
 
1832
2217
  /**
1833
2218
  * HTTP 代理,用于抽象 HTTP 请求,
1834
2219
  * 将请求代理编辑器外部
1835
2220
  */
1836
- declare interface HTTPProxy {
2221
+ export declare interface HTTPProxy {
1837
2222
  /**
1838
2223
  * 发送请求,如果需要做请求、响应拦截,需要在 proxy.interceptors 中实现,
1839
2224
  * 套件内使用 proxy 发送请求的方式应该为类似如下方式:
@@ -1880,7 +2265,7 @@ declare interface HTTPProxy {
1880
2265
  /**
1881
2266
  * 请求配置
1882
2267
  */
1883
- declare interface HTTPRequestConfig<Data = unknown> {
2268
+ export declare interface HTTPRequestConfig<Data = unknown> {
1884
2269
  /**
1885
2270
  * 请求地址
1886
2271
  */
@@ -1906,7 +2291,7 @@ declare interface HTTPRequestConfig<Data = unknown> {
1906
2291
  /**
1907
2292
  * 响应数据
1908
2293
  */
1909
- declare interface HTTPResponse<Data = unknown> {
2294
+ export declare interface HTTPResponse<Data = unknown> {
1910
2295
  /**
1911
2296
  * 响应数据 body
1912
2297
  */
@@ -1924,8 +2309,846 @@ declare interface HTTPResponse<Data = unknown> {
1924
2309
  /**
1925
2310
  * 请求返回类型
1926
2311
  */
1927
- declare type HTTPResponseType = 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream';
2312
+ export declare type HTTPResponseType = 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream';
2313
+
2314
+ export declare type MaybePromiseValue<T> = T | Promise<T>;
2315
+
2316
+ /**
2317
+ * pdf 工具栏一级菜单
2318
+ */
2319
+ export declare type PdfMenuEntryConfig = EditorMenuEntryConfig<PdfMenuFeatureButtonName>;
2320
+
2321
+ /**
2322
+ * 传统文档工具栏功能按钮
2323
+ */
2324
+ export declare type PdfMenuFeatureButtonConfig = EditorMenuFeatureButtonConfig<PdfMenuFeatureButtonName>;
2325
+
2326
+ /**
2327
+ * pdf 工具栏内置功能按钮
2328
+ */
2329
+ export declare type PdfMenuFeatureButtonName = 'selectAll';
2330
+
2331
+ export declare type PdfMenuOptions = EditorMenuOptions<PdfMenuFeatureButtonName>;
2332
+
2333
+ /**
2334
+ * pdf 目录大纲项接口
2335
+ */
2336
+ export declare type PdfOutline = EditorOutline<{
2337
+ text: string;
2338
+ }>;
2339
+
2340
+ /**
2341
+ * pdf 目录大纲项信息,用于描述 pdf 中的目录项信息。
2342
+ */
2343
+ export declare type PdfOutlineItem = EditorOutlineItem<{
2344
+ text: string;
2345
+ }>;
2346
+
2347
+ export declare type PdfOutlineOptions = EditorOutlineOptions;
2348
+
2349
+ /**
2350
+ * pdf 页面实例,
2351
+ * 可以通过实例对对应页面进行操作。
2352
+ */
2353
+ export declare interface PdfPage {
2354
+ /**
2355
+ * 获取当前页码
2356
+ */
2357
+ readonly pageNumber: number;
2358
+ /**
2359
+ * 获取当前页面的大小
2360
+ * @returns
2361
+ */
2362
+ getPageSize: () => {
2363
+ width: number;
2364
+ height: number;
2365
+ };
2366
+ }
2367
+
2368
+ /**
2369
+ * pdf 页面集合操作接口,
2370
+ * 该接口和 PdfPage 负责不同的功能,
2371
+ * PdfPage 是一个页面的抽象,而 PdfPages 是对整个 pdf 文件中所有页面的操作。
2372
+ */
2373
+ export declare interface PdfPages {
2374
+ /**
2375
+ * 获取当前页码
2376
+ * @returns
2377
+ */
2378
+ getCurrentPageNumber: () => number;
2379
+ /**
2380
+ * 设置当前页码并跳转至对应页面
2381
+ * @param page
2382
+ */
2383
+ setCurrentPage: (page: number) => void;
2384
+ /**
2385
+ * 获取总页数
2386
+ * @returns
2387
+ */
2388
+ getPagesCount: () => number;
2389
+ /**
2390
+ * 获取指定页面
2391
+ */
2392
+ getPage: (page: number) => Promise<PdfPage | null>;
2393
+ }
2394
+
2395
+ /**
2396
+ * 区域(Range)
2397
+ * 区域对象,表示文件中的一个连续区域,每个 Range 对象包含起始字符位置和终止字符位置。
2398
+ */
2399
+ /**
2400
+ * Pdf 区域对象,
2401
+ * 用于表示 Pdf 中的一个连续区域,
2402
+ * 每个选区值包含了起始位置和结束位置信息。
2403
+ */
2404
+ export declare interface PdfRange {
2405
+ /**
2406
+ * 区域的开始位置。
2407
+ */
2408
+ readonly start: string;
2409
+ /**
2410
+ * 区域的结束位置。
2411
+ */
2412
+ readonly end: string;
2413
+ /**
2414
+ * 获取该区域对应的纯文本信息。
2415
+ * @returns
2416
+ */
2417
+ getText: () => string;
2418
+ /**
2419
+ * 将区域中的内容以 HTML 格式返回。
2420
+ * @returns
2421
+ */
2422
+ getHtml: () => string;
2423
+ /**
2424
+ * 获取选区在当前屏幕上的位置信息
2425
+ * @returns
2426
+ */
2427
+ getBounding: () => PdfRangeBounding | null;
2428
+ }
2429
+
2430
+ /**
2431
+ * 记录选区在屏幕上的矩形位置信息,
2432
+ * 包含整个选区包围盒的四个边界值(top, right, bottom, left),
2433
+ * 以及第一行开始和最后一行结束的横向坐标。
2434
+ * 这些信息是选区中所有 ClientRects 的集合范围。
2435
+ */
2436
+ export declare interface PdfRangeBounding {
2437
+ /**
2438
+ * 区域的上边界值,
2439
+ * 表示所有选区中最上方的 Y 坐标。
2440
+ */
2441
+ top: number;
2442
+ /**
2443
+ * 区域的右边界值,
2444
+ * 表示所有选区中最右侧的 X 坐标。
2445
+ */
2446
+ right: number;
2447
+ /**
2448
+ * 区域的下边界值,
2449
+ * 表示所有选区中最下方的 Y 坐标。
2450
+ */
2451
+ bottom: number;
2452
+ /**
2453
+ * 区域的左边界值,
2454
+ * 表示所有选区中最左侧的 X 坐标。
2455
+ */
2456
+ left: number;
2457
+ /**
2458
+ * 第一行选区的起始 X 坐标。
2459
+ */
2460
+ start: number;
2461
+ /**
2462
+ * 最后一行选区的结束 X 坐标。
2463
+ */
2464
+ end: number;
2465
+ }
2466
+
2467
+ export declare interface PdfRangeValue {
2468
+ start: string;
2469
+ end: string;
2470
+ }
2471
+
2472
+ /**
2473
+ * Pdf 初始化参数
2474
+ */
2475
+ export declare interface PdfSDKOptions {
2476
+ /**
2477
+ * Pdf 初始化内容,可以是 string 或者 ArrayBuffer,
2478
+ * 也可以通过异步 Promise 加载
2479
+ */
2480
+ content: MaybePromiseValue<string | ArrayBuffer>;
2481
+ /**
2482
+ * 当前操作 Pdf 的用户信息
2483
+ */
2484
+ user?: EditorUserOptions;
2485
+ /**
2486
+ * i18n 相关设置
2487
+ */
2488
+ i18n?: EditorI18nOptions;
2489
+ /**
2490
+ * 品牌相关设置
2491
+ */
2492
+ brand?: EditorBrandOptions;
2493
+ /**
2494
+ * Pdf 内部资源请求配置
2495
+ */
2496
+ assets?: EditorAssetsOptions;
2497
+ /**
2498
+ * Pdf 内部超链接设置
2499
+ */
2500
+ link?: EditorLinkOptions;
2501
+ /**
2502
+ * 初始化水印配置
2503
+ */
2504
+ watermark?: EditorWatermarkOptions;
2505
+ /**
2506
+ * Pdf 打印设置
2507
+ */
2508
+ print?: EditorPrintOptions;
2509
+ /**
2510
+ * Pdf 大纲目录设置
2511
+ */
2512
+ outline?: PdfOutlineOptions;
2513
+ /**
2514
+ * Pdf 菜单栏设置
2515
+ */
2516
+ menu?: PdfMenuOptions;
2517
+ }
2518
+
2519
+ /**
2520
+ * 选区(Selection)
2521
+ * 表示窗口或窗格中的当前选定内容。
2522
+ */
2523
+ export declare interface PdfSelection {
2524
+ /**
2525
+ * 获取选区的区域范围,
2526
+ * 如果没有指定范围,则返回当前选区的范围。
2527
+ * 如果指定了范围,则返回指定范围的选区。
2528
+ * 如果选区不存在,则返回 null。
2529
+ * @returns
2530
+ */
2531
+ getRange: (value?: PdfRangeValue) => PdfRange | null;
2532
+ /**
2533
+ * 设置选区的区域范围,
2534
+ * 设置后,选区会自动选中指定范围。
2535
+ * 如果设置为 null,则清空选区。
2536
+ * @param bounds
2537
+ */
2538
+ setRange: (vale: PdfRangeValue | null) => void;
2539
+ /**
2540
+ * 添加选区变化监听器,当选区发生变化时,会触发回调。
2541
+ * @param listener
2542
+ * @returns
2543
+ */
2544
+ addRangeListener: (listener: (value: PdfRangeValue | null) => void) => void;
2545
+ /**
2546
+ * 获取 pdf 全部选区范围。
2547
+ * @returns
2548
+ */
2549
+ getWholeRange: () => PdfRange;
2550
+ }
2551
+
2552
+ export declare type PresentationFontFace = EditorFontFace;
2553
+
2554
+ export declare type PresentationFontMeta = EditorFontMeta;
2555
+
2556
+ export declare interface PresentationFontsList {
2557
+ getAll: () => Promise<PresentationFontFace[]>;
2558
+ }
2559
+
2560
+ export declare interface PresentationFontsOptions {
2561
+ list: PresentationFontsList;
2562
+ }
2563
+
2564
+ /**
2565
+ * 幻灯片工具栏一级菜单
2566
+ */
2567
+ export declare type PresentationMenuEntryConfig = EditorMenuEntryConfig<PresentationMenuFeatureButtonName>;
2568
+
2569
+ /**
2570
+ * 幻灯片工具栏功能按钮
2571
+ */
2572
+ export declare type PresentationMenuFeatureButtonConfig = EditorMenuFeatureButtonConfig<PresentationMenuFeatureButtonName>;
2573
+
2574
+ /**
2575
+ * 幻灯片工具栏内置功能按钮
2576
+ */
2577
+ export declare type PresentationMenuFeatureButtonName = 'undo' | 'redo' | 'cut' | 'copy' | 'paste' | 'selectAll';
2578
+
2579
+ export declare type PresentationMenuOptions = EditorMenuOptions<PresentationMenuFeatureButtonName>;
2580
+
2581
+ export declare interface PresentationSDKOptions extends EditorOptions {
2582
+ /**
2583
+ * 字体配置
2584
+ */
2585
+ fonts?: PresentationFontsOptions;
2586
+ /**
2587
+ * 菜单栏相关设置
2588
+ */
2589
+ menu?: PresentationMenuOptions;
2590
+ /**
2591
+ * 文本格式相关设置
2592
+ */
2593
+ text?: PresentationTextOptions;
2594
+ }
1928
2595
 
1929
- declare type MaybePromiseValue<T> = T | Promise<T>;
2596
+ /**
2597
+ * 选区(Selection)
2598
+ * 表示窗口中的当前选定内容。
2599
+ * 选定内容表示幻灯片中的选定(或突出显示)区域,或者代表插入点(如果未选择幻灯片中的任何内容)。
2600
+ */
2601
+ export declare interface PresentationSelection {
2602
+ /**
2603
+ * 获取选区的区域范围,
2604
+ * 如果没有指定范围,则返回当前选区的范围。
2605
+ * 如果指定了范围,则返回指定范围的选区。
2606
+ * 如果选区不存在,则返回 null。
2607
+ * @returns
2608
+ */
2609
+ getTextRange: (value?: PresentationTextRangeValue) => PresentationTextRange | null;
2610
+ /**
2611
+ * 设置选区的区域范围,
2612
+ * 设置后,选区会自动选中指定范围。
2613
+ * 如果设置为 null,则清空选区。
2614
+ * @param value
2615
+ */
2616
+ setTextRange: (value: PresentationTextRangeValue | null) => void;
2617
+ /**
2618
+ * 获取当前选中的形状,
2619
+ * 如果没有选中形状,则返回 null。
2620
+ * 如果指定了 value,则返回指定形状。
2621
+ * @param ids 指定的形状 id
2622
+ * @returns
2623
+ */
2624
+ getSelectedShapes: (ids?: string[]) => PresentationShape[] | null;
2625
+ /**
2626
+ * 选中指定的形状,选中形状后会清空文字选区。
2627
+ * 如果 value 为 null,则清空选中的形状。
2628
+ * @param ids 指定的形状 id
2629
+ * @returns
2630
+ */
2631
+ setSelectedShapes: (ids: string[] | null) => void;
2632
+ /**
2633
+ * 添加选区变化监听器,当选区发生变化时,会触发回调。
2634
+ * @param listener
2635
+ * @returns
2636
+ */
2637
+ addRangeListener: (listener: (value: PresentationTextRangeValue | null) => void) => void;
2638
+ }
2639
+
2640
+ /**
2641
+ * 幻灯片形状(Shape)接口
2642
+ */
2643
+ export declare interface PresentationShape {
2644
+ /**
2645
+ * 获取形状的 id
2646
+ */
2647
+ readonly id: string;
2648
+ }
2649
+
2650
+ /**
2651
+ * 幻灯片页面(Slide)对象,
2652
+ * 是幻灯片的基础操作单元,包含幻灯片的基本信息和操作方法。
2653
+ */
2654
+ export declare interface PresentationSlide {
2655
+ /**
2656
+ * 当前幻灯片的 id
2657
+ */
2658
+ readonly id: string;
2659
+ /**
2660
+ * 获取当前幻灯片在所有幻灯片中的索引
2661
+ * @returns
2662
+ */
2663
+ getIndex: () => number;
2664
+ /**
2665
+ * 获取当前页面所有的形状
2666
+ * @returns
2667
+ */
2668
+ getShapes: () => PresentationShape[];
2669
+ }
2670
+
2671
+ /**
2672
+ * 幻灯片集合对象,
2673
+ * 该接口和 PresentationSlide 负责不同的功能,
2674
+ * PresentationSlide 是一个幻灯片页面的抽象,而 PresentationSlides 是对整个文件中所有页面的操作。
2675
+ */
2676
+ export declare interface PresentationSlides {
2677
+ /**
2678
+ * 获取当前幻灯片
2679
+ */
2680
+ getCurrentSlide: () => PresentationSlide;
2681
+ /**
2682
+ * 切换当前幻灯片
2683
+ * @param slideId
2684
+ */
2685
+ setCurrentSlideIndex: (slideId: string) => void;
2686
+ /**
2687
+ * 获取幻灯片索引
2688
+ * @param slideId
2689
+ * @returns
2690
+ */
2691
+ getSlideIndex: (slideId: string) => number;
2692
+ /**
2693
+ * 获取幻灯片总数
2694
+ */
2695
+ getSlidesCount: () => number;
2696
+ /**
2697
+ * 获取所有幻灯片
2698
+ * @returns
2699
+ */
2700
+ getSlides: () => PresentationSlide[];
2701
+ /**
2702
+ * 获取指定幻灯片
2703
+ * @param slideId
2704
+ */
2705
+ getSlideById: (slideId: string) => PresentationSlide;
2706
+ /**
2707
+ * 获取当前选中的幻灯片。
2708
+ * 至少存在一个选中的幻灯片。
2709
+ * @returns
2710
+ */
2711
+ getSelectedSlides: (ids?: string[]) => PresentationSlide[];
2712
+ /**
2713
+ * 设置
2714
+ * @param ids
2715
+ * @returns
2716
+ */
2717
+ setSelectedSlides: (ids: string[]) => void;
2718
+ }
2719
+
2720
+ /**
2721
+ * 演示文稿文本接口
2722
+ */
2723
+ export declare type PresentationText = EditorText<string, PresentationTextRangeValue>;
2724
+
2725
+ /**
2726
+ * 演示文稿文本格式
2727
+ */
2728
+ export declare type PresentationTextFormat = EditorTextFormat;
2729
+
2730
+ /**
2731
+ * 演示文稿文本格式初始化选项
2732
+ */
2733
+ export declare type PresentationTextOptions = EditorTextOptions<string>;
2734
+
2735
+ /**
2736
+ * 区域(Range)
2737
+ * 区域对象,表示幻灯片页面中的一个连续的文字区域,每个 Range 对象包含起始字符位置和终止字符位置。
2738
+ * 区域信息是一个临时状态,当内容发生变化后,或切换了幻灯片 slide 区域信息可能会失效。
2739
+ */
2740
+ /**
2741
+ * 幻灯片区域对象,
2742
+ * 用于表示页面中的一个连续区域,
2743
+ * 每个选区值包含了起始位置和结束位置信息的字符串。
2744
+ */
2745
+ export declare interface PresentationTextRange {
2746
+ /**
2747
+ * 区域的开始位置,
2748
+ * 当内容发生变化后,区域的标识可能会失效。
2749
+ */
2750
+ readonly start: string;
2751
+ /**
2752
+ * 区域的结束位置,
2753
+ * 当内容发生变化后,区域的标识可能会失效。
2754
+ */
2755
+ readonly end: string;
2756
+ /**
2757
+ * 获取该区域对应的纯文本信息。
2758
+ * @returns
2759
+ */
2760
+ getText: () => string;
2761
+ /**
2762
+ * 设置该区域的内容
2763
+ * @param text 内容
2764
+ */
2765
+ setText: (text: string) => void;
2766
+ /**
2767
+ * 将区域中的内容以 HTML 格式返回
2768
+ */
2769
+ getHtml: () => string;
2770
+ /**
2771
+ * 设置该区域的内容为 HTML 格式
2772
+ * @param html 内容
2773
+ */
2774
+ setHtml: (html: string) => void;
2775
+ }
2776
+
2777
+ export declare interface PresentationTextRangeValue {
2778
+ start: string;
2779
+ end: string;
2780
+ }
2781
+
2782
+ /**
2783
+ * 幻灯片缩放接口
2784
+ */
2785
+ export declare interface PresentationZoom {
2786
+ /**
2787
+ * 获取当前缩放比例。
2788
+ * @returns
2789
+ */
2790
+ getPercentage: () => number;
2791
+ /**
2792
+ * 设置缩放比例,
2793
+ * 有效范围 10 ~ 500。
2794
+ * @param percentage
2795
+ */
2796
+ setPercentage: (percentage: number) => void;
2797
+ /**
2798
+ * 设置自动缩放模式,
2799
+ * none: 不自动缩放,默认值。
2800
+ * window: 根据窗口宽度自动缩放,页面宽度随着窗口宽度变化而变化
2801
+ * @param mode 缩放模式,可以是 'window'
2802
+ */
2803
+ setFitMode: (mode: 'none' | 'window') => void;
2804
+ /**
2805
+ * 获取当前缩放模式。
2806
+ * @returns
2807
+ */
2808
+ getFitMode: () => 'none' | 'window';
2809
+ /**
2810
+ * 放大。
2811
+ */
2812
+ zoomIn: () => void;
2813
+ /**
2814
+ * 缩小。
2815
+ */
2816
+ zoomOut: () => void;
2817
+ }
2818
+
2819
+ /**
2820
+ * 表格单元格对象
2821
+ */
2822
+ export declare interface SheetCell {
2823
+ /**
2824
+ * 单元格所在的行号
2825
+ */
2826
+ row: number;
2827
+ /**
2828
+ * 单元格所在的列号
2829
+ */
2830
+ column: number;
2831
+ /**
2832
+ * 单元格所在的工作表 ID
2833
+ */
2834
+ sheetId: string;
2835
+ /**
2836
+ * 获取单元格的文本
2837
+ */
2838
+ getCellText: () => string;
2839
+ /**
2840
+ * 获取单元格的值
2841
+ */
2842
+ getCellValue: () => SheetCellValue | null;
2843
+ }
2844
+
2845
+ /**
2846
+ * 单元格值类型
2847
+ */
2848
+ export declare type SheetCellValue = {
2849
+ type: 'primitive';
2850
+ value: string | number | boolean;
2851
+ } | {
2852
+ type: 'date';
2853
+ value: number;
2854
+ } | {
2855
+ type: 'calcError';
2856
+ value: {
2857
+ error: string;
2858
+ };
2859
+ };
2860
+
2861
+ /**
2862
+ * 电子表格工具栏一级菜单
2863
+ */
2864
+ export declare type SheetMenuEntryConfig = EditorMenuEntryConfig<SheetMenuFeatureButtonName>;
2865
+
2866
+ /**
2867
+ * 电子表格工具栏功能按钮
2868
+ */
2869
+ export declare type SheetMenuFeatureButtonConfig = EditorMenuFeatureButtonConfig<SheetMenuFeatureButtonName>;
2870
+
2871
+ /**
2872
+ * 电子表格工具栏内置功能按钮
2873
+ */
2874
+ export declare type SheetMenuFeatureButtonName = 'undo' | 'redo' | 'cut' | 'copy' | 'paste' | 'selectAll';
2875
+
2876
+ export declare type SheetMenuOptions = EditorMenuOptions<SheetMenuFeatureButtonName>;
2877
+
2878
+ /**
2879
+ * 表格区域对象,
2880
+ * 用于表示表格中被选中的单元格区域,
2881
+ * 可以是一个单元格、一行、一列、或某个区域。
2882
+ */
2883
+ export declare interface SheetRange {
2884
+ /**
2885
+ * 区域类型
2886
+ */
2887
+ type: `${SheetRangeType}`;
2888
+ /**
2889
+ * 区域的行开始位置
2890
+ */
2891
+ readonly row: number;
2892
+ /**
2893
+ * 区域的列开始位置
2894
+ */
2895
+ readonly column: number;
2896
+ /**
2897
+ * 区域的行数
2898
+ */
2899
+ readonly rowCount: number;
2900
+ /**
2901
+ * 区域的列数
2902
+ */
2903
+ readonly columnCount: number;
2904
+ /**
2905
+ * 获取该区域对应的纯文本信息。
2906
+ * @returns
2907
+ */
2908
+ getText: () => string;
2909
+ /**
2910
+ * 设置该区域的内容
2911
+ * @param text 内容
2912
+ */
2913
+ setText: (text: string) => void;
2914
+ /**
2915
+ * 将区域中的内容以 HTML 格式返回
2916
+ */
2917
+ getHtml: () => string;
2918
+ /**
2919
+ * 设置该区域的内容为 HTML 格式
2920
+ * @param html 内容
2921
+ */
2922
+ setHtml: (html: string) => void;
2923
+ }
2924
+
2925
+ /**
2926
+ * 区域(Range)
2927
+ * 区域对象,表示表格中的一个单元格区域,每个 Range 对象包含了一个或多个单元格、行、列信息。
2928
+ */
2929
+ /**
2930
+ * 选区类型
2931
+ */
2932
+ export declare enum SheetRangeType {
2933
+ /**
2934
+ * 选中一个或多个单元格
2935
+ */
2936
+ Cells = "cells",
2937
+ /**
2938
+ * 选中一行或多行
2939
+ */
2940
+ Rows = "rows",
2941
+ /**
2942
+ * 选中一列或多列
2943
+ */
2944
+ Columns = "columns",
2945
+ /**
2946
+ * 选中整个工作表
2947
+ */
2948
+ Sheet = "sheet"
2949
+ }
2950
+
2951
+ export declare type SheetRangeValue = {
2952
+ /**
2953
+ * 单个或多个单元格
2954
+ */
2955
+ type: `${SheetRangeType.Cells}`;
2956
+ /**
2957
+ * 起始单元格的行号
2958
+ */
2959
+ row: number;
2960
+ /**
2961
+ * 总计行数
2962
+ */
2963
+ rowCount: number;
2964
+ /**
2965
+ * 起始单元格的列号
2966
+ */
2967
+ column: number;
2968
+ /**
2969
+ * 总计列数
2970
+ */
2971
+ columnCount: number;
2972
+ } | {
2973
+ /**
2974
+ * 一列或多列
2975
+ */
2976
+ type: `${SheetRangeType.Rows}`;
2977
+ /**
2978
+ * 起始列号
2979
+ */
2980
+ row: number;
2981
+ /**
2982
+ * 总计行数
2983
+ */
2984
+ rowCount: number;
2985
+ } | {
2986
+ /**
2987
+ * 一行或多行
2988
+ */
2989
+ type: `${SheetRangeType.Columns}`;
2990
+ /**
2991
+ * 起始行号
2992
+ */
2993
+ column: number;
2994
+ /**
2995
+ * 总计列数
2996
+ */
2997
+ columnCount: number;
2998
+ } | {
2999
+ /**
3000
+ * 整个工作表
3001
+ */
3002
+ type: `${SheetRangeType.Sheet}`;
3003
+ };
3004
+
3005
+ export declare interface SheetSDKOptions extends EditorOptions {
3006
+ /**
3007
+ * 字体配置
3008
+ */
3009
+ fonts?: EditorFontsOptions;
3010
+ /**
3011
+ * 菜单栏相关设置
3012
+ */
3013
+ menu?: SheetMenuOptions;
3014
+ /**
3015
+ * 文本格式相关设置
3016
+ */
3017
+ text?: SheetTextOptions;
3018
+ }
3019
+
3020
+ /**
3021
+ * 选区(Selection)
3022
+ * 表示窗口或窗格中的当前选定内容。
3023
+ * 选定内容表示表格中的选定(或突出显示)的单元格区域。
3024
+ */
3025
+ export declare interface SheetSelection {
3026
+ /**
3027
+ * 获取选区的区域范围,
3028
+ * 如果没有指定范围,则返回当前选区的范围。
3029
+ * 如果指定了范围,则返回指定范围的选区。
3030
+ * 如果选区不存在,则返回 null。
3031
+ */
3032
+ getRange: (value?: SheetRangeValue) => SheetRange | null;
3033
+ /**
3034
+ * 设置选区的区域范围,
3035
+ * 设置后,选区会自动选中指定范围。
3036
+ * 如果设置为 null,则清空选区。
3037
+ */
3038
+ setRange: (value: SheetRangeValue | null) => void;
3039
+ }
3040
+
3041
+ /**
3042
+ * 电子表格文本接口
3043
+ */
3044
+ export declare type SheetText = EditorText<string, SheetRangeValue>;
3045
+
3046
+ /**
3047
+ * 电子表格文本格式
3048
+ */
3049
+ export declare type SheetTextFormat = EditorTextFormat;
3050
+
3051
+ /**
3052
+ * 电子表格文本格式初始化选项
3053
+ */
3054
+ export declare type SheetTextOptions = EditorTextOptions<string>;
3055
+
3056
+ /**
3057
+ * 工作表集合对象
3058
+ */
3059
+ export declare interface SheetWorkbook {
3060
+ /**
3061
+ * 获取所有工作表
3062
+ * @returns
3063
+ */
3064
+ getWorksheets: () => SheetWorksheet[];
3065
+ /**
3066
+ * 获取指定的工作表
3067
+ * @param sheetId
3068
+ * @returns
3069
+ */
3070
+ getWorksheetById: (sheetId: string) => SheetWorksheet | null;
3071
+ /**
3072
+ * 获取当前活动的工作表
3073
+ * TODO: 是否存在返回空的场景
3074
+ * @returns
3075
+ */
3076
+ getActiveWorksheet: () => SheetWorksheet;
3077
+ /**
3078
+ * 激活指定的工作表
3079
+ * @param sheetId
3080
+ */
3081
+ setActiveWorksheet: (sheetId: string) => void;
3082
+ }
3083
+
3084
+ /**
3085
+ * 工作表对象
3086
+ */
3087
+ export declare interface SheetWorksheet {
3088
+ /**
3089
+ * 工作表对应编号
3090
+ */
3091
+ get id(): string;
3092
+ /**
3093
+ * 获取当前工作表名称
3094
+ */
3095
+ get name(): string;
3096
+ /**
3097
+ * 这个工作表是否为当前活动的工作表
3098
+ */
3099
+ get isActive(): boolean;
3100
+ /**
3101
+ * 获取工作表的所有选区
3102
+ * @returns
3103
+ */
3104
+ getSelections: () => SheetSelection[] | null;
3105
+ /**
3106
+ * 获取选区的物理位置(相对于浏览器窗口),如果选区完全不在工作表的可视区域内,返回 null。
3107
+ * 其中选区超出可视区域的部分会被截断处理。
3108
+ *
3109
+ * 当工作表存在冻结行列时,可视区域将被分成四个部分(如果仅存在冻结行或冻结列则被分为两个部分),
3110
+ * 此时需要计算出选区在**视觉上**与可视区域的交集。
3111
+ */
3112
+ getPhysicalPosition: (range: SheetRangeValue) => {
3113
+ left: number;
3114
+ top: number;
3115
+ width: number;
3116
+ height: number;
3117
+ } | null;
3118
+ /**
3119
+ * 添加选区变化监听器,当选区发生变化时,会触发回调。
3120
+ * @param listener
3121
+ * @returns 用于移除监听的回调
3122
+ */
3123
+ addRangeListener: (listener: (range: {
3124
+ sheet: string;
3125
+ ranges: SheetRangeValue[] | null;
3126
+ }) => void) => () => void;
3127
+ /**
3128
+ * 获取工作表中指定区域的单元格对象
3129
+ * @returns
3130
+ */
3131
+ getCell: (row: number, column: number) => SheetCell | null;
3132
+ /**
3133
+ * 获取工作表中选中的单元格对象
3134
+ * @returns
3135
+ */
3136
+ getActiveCell: () => SheetCell | null;
3137
+ /**
3138
+ * 激活工作表中某个单元格
3139
+ * @param cell 单元格对象,需要传入行和列的索引值
3140
+ * @returns
3141
+ */
3142
+ setActiveCell: (cell: {
3143
+ row: number;
3144
+ column: number;
3145
+ }) => void;
3146
+ /**
3147
+ * 定位到单元格所在位置
3148
+ * @param row 单元格所在行
3149
+ * @param column 单元格所在列
3150
+ */
3151
+ locateCell: (row: number, column: number) => void;
3152
+ }
1930
3153
 
1931
3154
  export { }