@officesdk/editor-sdk-core 0.0.0-12 → 0.0.0-13

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/types/docs.d.ts CHANGED
@@ -548,27 +548,6 @@ export declare interface EditorContent<Delta = EditorDelta> {
548
548
  addChangeListener: (listener: (change: Delta) => void) => () => void;
549
549
  }
550
550
 
551
- /**
552
- * 右键菜单栏二级以下的菜单入口
553
- */
554
- export declare type EditorContextMenuEntryButton<TName extends string> = EditorMenuEntryButton<TName>;
555
-
556
- /**
557
- * 右键菜单栏一级菜单配置,此处用于定义一级菜单的操作入口,
558
- * 右键菜单栏一级菜单指点击右键弹出菜单时的菜单项
559
- */
560
- export declare type EditorContextMenuEntryConfig<TName extends string> = EditorMenuEntryConfig<TName>;
561
-
562
- /**
563
- * 右键菜单栏功能按钮配置
564
- */
565
- export declare type EditorContextMenuFeatureButton<TName extends string> = EditorMenuFeatureButton<TName>;
566
-
567
- /**
568
- * 右键菜单栏按钮配置
569
- */
570
- export declare type EditorContextMenuFeatureButtonConfig<TName extends string> = EditorMenuFeatureButtonConfig<TName>;
571
-
572
551
  /**
573
552
  * 右键菜单栏相关配置
574
553
  * 右键菜单栏是指的编辑器中点击右键弹出的菜单栏。目前等于菜单栏配置,可扩展
@@ -762,120 +741,109 @@ export declare interface EditorLocalUploadableFile extends EditorBaseUploadableF
762
741
  }
763
742
 
764
743
  /**
765
- * 菜单栏自定义按钮配置
744
+ * 基础菜单项配置,所有菜单项类型都包含这些属性
766
745
  */
767
- export declare type EditorMenuCustomButton = {
768
- /**
769
- * 按钮名称
770
- */
771
- name: string;
772
- /**
773
- * 链接
774
- */
775
- type: 'link';
746
+ declare interface EditorMenuBaseMenuItemConfig<TName extends string> {
776
747
  /**
777
- * 按钮文本
748
+ * 菜单项的唯一标识,用以确定配置的是哪个菜单
778
749
  */
779
- text: string;
780
- /**
781
- * 链接地址
782
- */
783
- url: string;
784
- } | {
750
+ name: TName;
785
751
  /**
786
- * 按钮名称
752
+ * 菜单项类型
787
753
  */
788
- name: string;
754
+ type?: EditorMenuItemType;
755
+ }
756
+
757
+ /**
758
+ * 按钮菜单项配置
759
+ */
760
+ export declare interface EditorMenuButtonMenuItemConfig<TName extends string> extends EditorMenuBaseMenuItemConfig<TName> {
761
+ type?: 'button';
789
762
  /**
790
- * 按钮,点击后触发 callback 回调
763
+ * 是否禁用菜单项,禁用后菜单项依旧显示不过变为灰色,不可点击
791
764
  */
792
- type: 'button';
765
+ disabled?: boolean;
793
766
  /**
794
- * 按钮文本
767
+ * 菜单项显示文本,修改该值可以替换此菜单项默认显示文案
795
768
  */
796
- label: string;
769
+ label?: string;
797
770
  /**
798
- * 按钮图标,可以是 base64 的图片信息,也可以是图片 url
771
+ * 菜单项图标,可以是 base64 的图片信息,也可以是图片 url
772
+ * 配置为空字符串则可以隐藏菜单项默认的图标
799
773
  */
800
774
  icon?: string;
801
775
  /**
802
- * 按钮点击事件
776
+ * 菜单项点击事件,接受一个函数,可以自定义点击事件
803
777
  */
804
- callback: () => void;
805
- };
778
+ callback?: () => void;
779
+ }
806
780
 
807
781
  /**
808
- * 菜单栏二级以下的菜单入口
782
+ * 编辑器菜单配置类型
783
+ * 联合类型,表示可以是任意一种菜单项配置
809
784
  */
810
- export declare interface EditorMenuEntryButton<TName extends string> {
811
- type: 'entry';
785
+ export declare type EditorMenuEntryConfig<TName extends string> = EditorMenuHiddenMenuItemConfig<TName> | EditorMenuButtonMenuItemConfig<TName> | EditorMenuLinkMenuItemConfig<TName> | EditorMenuEntryMenuItemConfig<TName>;
786
+
787
+ /**
788
+ * 子菜单入口配置
789
+ */
790
+ export declare interface EditorMenuEntryMenuItemConfig<TName extends string> extends EditorMenuBaseMenuItemConfig<TName> {
791
+ type?: 'entry';
812
792
  /**
813
- * 菜单名称
793
+ * 是否禁用菜单项,禁用后菜单项依旧显示不过变为灰色,不可点击
814
794
  */
815
- name: string;
795
+ disabled?: boolean;
816
796
  /**
817
- * 菜单图标
797
+ * 菜单项显示文本,修改该值可以替换此菜单项默认显示文案
798
+ */
799
+ label?: string;
800
+ /**
801
+ * 菜单项图标,可以是 base64 的图片信息,也可以是图片 url
802
+ * 配置为空字符串则可以隐藏菜单项默认的图标
818
803
  */
819
804
  icon?: string;
820
805
  /**
821
- * 下一级子菜单
806
+ * 下一级菜单配置,下一级菜单配置项和上一级相同
807
+ * 如果下一级仍然是 entry 类型,可以无限向下扩展
822
808
  */
823
- children?: Array<EditorMenuFeatureButton<TName> | EditorMenuEntryButton<TName>>[];
809
+ children?: EditorMenuEntryConfig<TName>[];
824
810
  }
825
811
 
826
812
  /**
827
- * 菜单栏一级菜单配置,此处用于定义一级菜单的操作入口,
828
- * 一级菜单在鼠标悬停时展示二级列表
813
+ * 隐藏菜单项配置
829
814
  */
830
- export declare interface EditorMenuEntryConfig<TName extends string> {
831
- /**
832
- * 一级菜单名称
833
- */
834
- name: string;
835
- /**
836
- * 二级菜单定义,定一个二维数组,用于定义二级菜单的结构,
837
- * 将第一层数组中的所有按钮放到一个区域内用分隔符隔开,
838
- * 第二层数组为按钮的定义,可以是功能按钮也可以是一个下拉入口。
839
- */
840
- children: Array<EditorMenuFeatureButton<TName> | EditorMenuEntryButton<TName>>[];
841
- /**
842
- * 是否隐藏一级菜单
843
- */
815
+ export declare interface EditorMenuHiddenMenuItemConfig<TName extends string> extends EditorMenuBaseMenuItemConfig<TName> {
844
816
  type?: 'hidden';
845
817
  }
846
818
 
847
819
  /**
848
- * 菜单栏功能按钮配置
820
+ * 菜单项类型
849
821
  */
850
- export declare type EditorMenuFeatureButton<TName extends string> = {
851
- /**
852
- * 隐藏按钮,用作在需要隐藏菜单栏时定义
853
- */
854
- type: 'hidden';
822
+ export declare type EditorMenuItemType = 'hidden' | 'button' | 'link' | 'entry';
823
+
824
+ /**
825
+ * 链接菜单项配置
826
+ */
827
+ export declare interface EditorMenuLinkMenuItemConfig<TName extends string> extends EditorMenuBaseMenuItemConfig<TName> {
828
+ type?: 'link';
855
829
  /**
856
- * 按钮名称
830
+ * 是否禁用菜单项,禁用后菜单项依旧显示不过变为灰色,不可点击
857
831
  */
858
- name: TName;
859
- } | {
860
- type: 'button';
832
+ disabled?: boolean;
861
833
  /**
862
- * 按钮名称
834
+ * 菜单项显示文本,修改该值可以替换此菜单项默认显示文案
863
835
  */
864
- name: TName;
836
+ label?: string;
865
837
  /**
866
- * 按钮标签(显示文本)
838
+ * 菜单项图标,可以是 base64 的图片信息,也可以是图片 url
839
+ * 配置为空字符串则可以隐藏菜单项默认的图标
867
840
  */
868
- label: string;
841
+ icon?: string;
869
842
  /**
870
- * 按钮图标,可以是 base64 的图片信息,也可以是图片 url
843
+ * 跳转链接地址
871
844
  */
872
- icon?: string;
873
- };
874
-
875
- /**
876
- * 菜单栏按钮配置
877
- */
878
- export declare type EditorMenuFeatureButtonConfig<TName extends string> = Record<TName, EditorMenuFeatureButton<TName>>;
845
+ url?: string;
846
+ }
879
847
 
880
848
  /**
881
849
  * 菜单栏相关配置,目前菜单栏不是所有套件都支持,
@@ -883,25 +851,26 @@ export declare type EditorMenuFeatureButtonConfig<TName extends string> = Record
883
851
  */
884
852
  export declare interface EditorMenuOptions<TName extends string> {
885
853
  /**
886
- * 菜单栏是否隐藏
854
+ * 菜单栏是否隐藏,设置为true, 则整个菜单栏不显示
887
855
  */
888
856
  hidden?: boolean;
889
857
  /**
890
- * 是否禁用菜单栏所有功能
858
+ * 是否禁用菜单栏所有功能。设置为true,菜单栏依旧显示,但所有菜单项为灰色不可点击
891
859
  */
892
860
  disabled?: boolean;
893
861
  /**
894
- * 菜单栏一级菜单配置
862
+ * 菜单栏一级菜单配置,指显示在菜单栏上的菜单项。
895
863
  */
896
864
  entries?: EditorMenuEntryConfig<TName>[];
897
865
  /**
898
866
  * 菜单栏功能按钮配置
867
+ * TODO 此配置目前没有用到,后续看是保留还是和custom合并
899
868
  */
900
- features?: Partial<EditorMenuFeatureButtonConfig<TName>>;
869
+ features?: EditorMenuEntryConfig<TName>[];
901
870
  /**
902
871
  * 自定义按钮配置
903
872
  */
904
- custom?: EditorMenuCustomButton[];
873
+ custom?: EditorMenuEntryConfig<TName>[];
905
874
  }
906
875
 
907
876
  /**
@@ -1264,43 +1233,15 @@ export declare interface EditorTextOptions<Color = string> {
1264
1233
  }
1265
1234
 
1266
1235
  /**
1267
- * 工具栏自定义按钮配置
1268
- */
1269
- export declare interface EditorToolbarCustomButton extends Omit<EditorToolbarFeatureButton, 'name'> {
1270
- /**
1271
- * 自定义按钮名称
1272
- */
1273
- name: string;
1274
- /**
1275
- * 按钮点击事件
1276
- */
1277
- callback: () => void;
1278
- /**
1279
- * 按钮在工具栏中的位置,默认添加到工具栏所有按钮后面
1280
- */
1281
- index?: number;
1282
- }
1283
-
1284
- /**
1285
- * 工具栏自定义按钮配置
1236
+ * 工具栏功能按钮配置(包括内置按钮和自定义按钮)
1286
1237
  */
1287
- export declare interface EditorToolbarCustomButtonConfig {
1238
+ export declare interface EditorToolbarFeatureButton<TName extends string> {
1288
1239
  /**
1289
- * 按钮配置
1240
+ * 按钮的唯一标识,用以确定配置的是哪个按钮。
1290
1241
  */
1291
- [key: string]: EditorToolbarCustomButton;
1292
- }
1293
-
1294
- /**
1295
- * 工具栏内置功能按钮配置
1296
- */
1297
- export declare interface EditorToolbarFeatureButton<ToolButtonName extends string = EditorToolbarFeatureButtonName> {
1298
- /**
1299
- * 按钮类型
1300
- */
1301
- name: ToolButtonName;
1242
+ name: TName;
1302
1243
  /**
1303
- * 按钮标签(显示文本)
1244
+ * 按钮标签(显示文本)一般工具栏上的按钮不会显示文本,如果需要显示文本,配置此项。
1304
1245
  */
1305
1246
  label?: string;
1306
1247
  /**
@@ -1308,63 +1249,38 @@ export declare interface EditorToolbarFeatureButton<ToolButtonName extends strin
1308
1249
  */
1309
1250
  icon?: string;
1310
1251
  /**
1311
- * 按钮是否隐藏
1252
+ * 按钮是否隐藏,设置为true则隐藏按钮
1312
1253
  */
1313
1254
  hidden?: boolean;
1314
1255
  /**
1315
- * 按钮是否禁用
1256
+ * 按钮是否禁用,设置为true则变为灰色不可点击
1316
1257
  */
1317
1258
  disabled?: boolean;
1318
1259
  /**
1319
- * 按钮提示文本
1260
+ * 按钮点击事件.接受一个函数,可以自定义点击事件。
1261
+ */
1262
+ callback?: () => void;
1263
+ /**
1264
+ * 按钮提示文本,鼠标悬浮到按钮上时显示的tooltip文字
1320
1265
  */
1321
1266
  tooltip?: string;
1267
+ /**
1268
+ * 按钮在工具栏中位置,不设置则按照默认位置
1269
+ */
1270
+ index?: number;
1322
1271
  }
1323
1272
 
1324
1273
  /**
1325
1274
  * 工具栏内置功能按钮配置
1326
1275
  */
1327
- export declare type EditorToolbarFeatureButtonConfig<ToolButtonName extends string> = {
1328
- [key in ToolButtonName]?: EditorToolbarFeatureButton<ToolButtonName>;
1276
+ export declare type EditorToolbarFeatureButtonConfig<TName extends string> = {
1277
+ [key in TName]?: EditorToolbarFeatureButton<key>;
1329
1278
  };
1330
1279
 
1331
- /**
1332
- * 工具栏内置功能按钮
1333
- */
1334
- export declare type EditorToolbarFeatureButtonName =
1335
- /**
1336
- * 加粗
1337
- */
1338
- 'bold'
1339
- /**
1340
- * 斜体
1341
- */
1342
- | 'italic'
1343
- /**
1344
- * 下划线
1345
- */
1346
- | 'underline'
1347
- /**
1348
- * 删除线
1349
- */
1350
- | 'strikethrough'
1351
- /**
1352
- * 插入图片
1353
- */
1354
- | 'insertImage'
1355
- /**
1356
- * 插入链接
1357
- */
1358
- | 'insertLink'
1359
- /**
1360
- * 限制编辑
1361
- */
1362
- | 'restriction';
1363
-
1364
1280
  /**
1365
1281
  * 工具栏相关设置,可以控制工具栏的显示内容
1366
1282
  */
1367
- export declare interface EditorToolbarOptions<ToolButtonName extends string = EditorToolbarFeatureButtonName> {
1283
+ export declare interface EditorToolbarOptions<TName extends string> {
1368
1284
  /**
1369
1285
  * 控制工具栏显隐状态
1370
1286
  */
@@ -1376,11 +1292,11 @@ export declare interface EditorToolbarOptions<ToolButtonName extends string = Ed
1376
1292
  /**
1377
1293
  * 现有按钮的功能配置
1378
1294
  */
1379
- features?: EditorToolbarFeatureButtonConfig<ToolButtonName>;
1295
+ features?: EditorToolbarFeatureButtonConfig<TName>;
1380
1296
  /**
1381
1297
  * 自定义按钮
1382
1298
  */
1383
- custom?: EditorToolbarCustomButtonConfig;
1299
+ custom?: EditorToolbarFeatureButtonConfig<string>;
1384
1300
  }
1385
1301
 
1386
1302
  export declare type EditorUploadableFile = EditorLocalUploadableFile;