@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/shared.d.ts CHANGED
@@ -356,27 +356,6 @@ export declare interface EditorContent<Delta = EditorDelta> {
356
356
  addChangeListener: (listener: (change: Delta) => void) => () => void;
357
357
  }
358
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
359
  /**
381
360
  * 右键菜单栏相关配置
382
361
  * 右键菜单栏是指的编辑器中点击右键弹出的菜单栏。目前等于菜单栏配置,可扩展
@@ -570,120 +549,109 @@ export declare interface EditorLocalUploadableFile extends EditorBaseUploadableF
570
549
  }
571
550
 
572
551
  /**
573
- * 菜单栏自定义按钮配置
552
+ * 基础菜单项配置,所有菜单项类型都包含这些属性
574
553
  */
575
- export declare type EditorMenuCustomButton = {
576
- /**
577
- * 按钮名称
578
- */
579
- name: string;
580
- /**
581
- * 链接
582
- */
583
- type: 'link';
554
+ declare interface EditorMenuBaseMenuItemConfig<TName extends string> {
584
555
  /**
585
- * 按钮文本
556
+ * 菜单项的唯一标识,用以确定配置的是哪个菜单
586
557
  */
587
- text: string;
588
- /**
589
- * 链接地址
590
- */
591
- url: string;
592
- } | {
558
+ name: TName;
593
559
  /**
594
- * 按钮名称
560
+ * 菜单项类型
595
561
  */
596
- name: string;
562
+ type?: EditorMenuItemType;
563
+ }
564
+
565
+ /**
566
+ * 按钮菜单项配置
567
+ */
568
+ export declare interface EditorMenuButtonMenuItemConfig<TName extends string> extends EditorMenuBaseMenuItemConfig<TName> {
569
+ type?: 'button';
597
570
  /**
598
- * 按钮,点击后触发 callback 回调
571
+ * 是否禁用菜单项,禁用后菜单项依旧显示不过变为灰色,不可点击
599
572
  */
600
- type: 'button';
573
+ disabled?: boolean;
601
574
  /**
602
- * 按钮文本
575
+ * 菜单项显示文本,修改该值可以替换此菜单项默认显示文案
603
576
  */
604
- label: string;
577
+ label?: string;
605
578
  /**
606
- * 按钮图标,可以是 base64 的图片信息,也可以是图片 url
579
+ * 菜单项图标,可以是 base64 的图片信息,也可以是图片 url
580
+ * 配置为空字符串则可以隐藏菜单项默认的图标
607
581
  */
608
582
  icon?: string;
609
583
  /**
610
- * 按钮点击事件
584
+ * 菜单项点击事件,接受一个函数,可以自定义点击事件
611
585
  */
612
- callback: () => void;
613
- };
586
+ callback?: () => void;
587
+ }
614
588
 
615
589
  /**
616
- * 菜单栏二级以下的菜单入口
590
+ * 编辑器菜单配置类型
591
+ * 联合类型,表示可以是任意一种菜单项配置
617
592
  */
618
- export declare interface EditorMenuEntryButton<TName extends string> {
619
- type: 'entry';
593
+ export declare type EditorMenuEntryConfig<TName extends string> = EditorMenuHiddenMenuItemConfig<TName> | EditorMenuButtonMenuItemConfig<TName> | EditorMenuLinkMenuItemConfig<TName> | EditorMenuEntryMenuItemConfig<TName>;
594
+
595
+ /**
596
+ * 子菜单入口配置
597
+ */
598
+ export declare interface EditorMenuEntryMenuItemConfig<TName extends string> extends EditorMenuBaseMenuItemConfig<TName> {
599
+ type?: 'entry';
620
600
  /**
621
- * 菜单名称
601
+ * 是否禁用菜单项,禁用后菜单项依旧显示不过变为灰色,不可点击
622
602
  */
623
- name: string;
603
+ disabled?: boolean;
624
604
  /**
625
- * 菜单图标
605
+ * 菜单项显示文本,修改该值可以替换此菜单项默认显示文案
606
+ */
607
+ label?: string;
608
+ /**
609
+ * 菜单项图标,可以是 base64 的图片信息,也可以是图片 url
610
+ * 配置为空字符串则可以隐藏菜单项默认的图标
626
611
  */
627
612
  icon?: string;
628
613
  /**
629
- * 下一级子菜单
614
+ * 下一级菜单配置,下一级菜单配置项和上一级相同
615
+ * 如果下一级仍然是 entry 类型,可以无限向下扩展
630
616
  */
631
- children?: Array<EditorMenuFeatureButton<TName> | EditorMenuEntryButton<TName>>[];
617
+ children?: EditorMenuEntryConfig<TName>[];
632
618
  }
633
619
 
634
620
  /**
635
- * 菜单栏一级菜单配置,此处用于定义一级菜单的操作入口,
636
- * 一级菜单在鼠标悬停时展示二级列表
621
+ * 隐藏菜单项配置
637
622
  */
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
- */
623
+ export declare interface EditorMenuHiddenMenuItemConfig<TName extends string> extends EditorMenuBaseMenuItemConfig<TName> {
652
624
  type?: 'hidden';
653
625
  }
654
626
 
655
627
  /**
656
- * 菜单栏功能按钮配置
628
+ * 菜单项类型
657
629
  */
658
- export declare type EditorMenuFeatureButton<TName extends string> = {
659
- /**
660
- * 隐藏按钮,用作在需要隐藏菜单栏时定义
661
- */
662
- type: 'hidden';
630
+ export declare type EditorMenuItemType = 'hidden' | 'button' | 'link' | 'entry';
631
+
632
+ /**
633
+ * 链接菜单项配置
634
+ */
635
+ export declare interface EditorMenuLinkMenuItemConfig<TName extends string> extends EditorMenuBaseMenuItemConfig<TName> {
636
+ type?: 'link';
663
637
  /**
664
- * 按钮名称
638
+ * 是否禁用菜单项,禁用后菜单项依旧显示不过变为灰色,不可点击
665
639
  */
666
- name: TName;
667
- } | {
668
- type: 'button';
640
+ disabled?: boolean;
669
641
  /**
670
- * 按钮名称
642
+ * 菜单项显示文本,修改该值可以替换此菜单项默认显示文案
671
643
  */
672
- name: TName;
644
+ label?: string;
673
645
  /**
674
- * 按钮标签(显示文本)
646
+ * 菜单项图标,可以是 base64 的图片信息,也可以是图片 url
647
+ * 配置为空字符串则可以隐藏菜单项默认的图标
675
648
  */
676
- label: string;
649
+ icon?: string;
677
650
  /**
678
- * 按钮图标,可以是 base64 的图片信息,也可以是图片 url
651
+ * 跳转链接地址
679
652
  */
680
- icon?: string;
681
- };
682
-
683
- /**
684
- * 菜单栏按钮配置
685
- */
686
- export declare type EditorMenuFeatureButtonConfig<TName extends string> = Record<TName, EditorMenuFeatureButton<TName>>;
653
+ url?: string;
654
+ }
687
655
 
688
656
  /**
689
657
  * 菜单栏相关配置,目前菜单栏不是所有套件都支持,
@@ -691,25 +659,26 @@ export declare type EditorMenuFeatureButtonConfig<TName extends string> = Record
691
659
  */
692
660
  export declare interface EditorMenuOptions<TName extends string> {
693
661
  /**
694
- * 菜单栏是否隐藏
662
+ * 菜单栏是否隐藏,设置为true, 则整个菜单栏不显示
695
663
  */
696
664
  hidden?: boolean;
697
665
  /**
698
- * 是否禁用菜单栏所有功能
666
+ * 是否禁用菜单栏所有功能。设置为true,菜单栏依旧显示,但所有菜单项为灰色不可点击
699
667
  */
700
668
  disabled?: boolean;
701
669
  /**
702
- * 菜单栏一级菜单配置
670
+ * 菜单栏一级菜单配置,指显示在菜单栏上的菜单项。
703
671
  */
704
672
  entries?: EditorMenuEntryConfig<TName>[];
705
673
  /**
706
674
  * 菜单栏功能按钮配置
675
+ * TODO 此配置目前没有用到,后续看是保留还是和custom合并
707
676
  */
708
- features?: Partial<EditorMenuFeatureButtonConfig<TName>>;
677
+ features?: EditorMenuEntryConfig<TName>[];
709
678
  /**
710
679
  * 自定义按钮配置
711
680
  */
712
- custom?: EditorMenuCustomButton[];
681
+ custom?: EditorMenuEntryConfig<TName>[];
713
682
  }
714
683
 
715
684
  /**
@@ -1072,43 +1041,15 @@ export declare interface EditorTextOptions<Color = string> {
1072
1041
  }
1073
1042
 
1074
1043
  /**
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
- * 工具栏自定义按钮配置
1044
+ * 工具栏功能按钮配置(包括内置按钮和自定义按钮)
1094
1045
  */
1095
- export declare interface EditorToolbarCustomButtonConfig {
1046
+ export declare interface EditorToolbarFeatureButton<TName extends string> {
1096
1047
  /**
1097
- * 按钮配置
1048
+ * 按钮的唯一标识,用以确定配置的是哪个按钮。
1098
1049
  */
1099
- [key: string]: EditorToolbarCustomButton;
1100
- }
1101
-
1102
- /**
1103
- * 工具栏内置功能按钮配置
1104
- */
1105
- export declare interface EditorToolbarFeatureButton<ToolButtonName extends string = EditorToolbarFeatureButtonName> {
1106
- /**
1107
- * 按钮类型
1108
- */
1109
- name: ToolButtonName;
1050
+ name: TName;
1110
1051
  /**
1111
- * 按钮标签(显示文本)
1052
+ * 按钮标签(显示文本)一般工具栏上的按钮不会显示文本,如果需要显示文本,配置此项。
1112
1053
  */
1113
1054
  label?: string;
1114
1055
  /**
@@ -1116,63 +1057,38 @@ export declare interface EditorToolbarFeatureButton<ToolButtonName extends strin
1116
1057
  */
1117
1058
  icon?: string;
1118
1059
  /**
1119
- * 按钮是否隐藏
1060
+ * 按钮是否隐藏,设置为true则隐藏按钮
1120
1061
  */
1121
1062
  hidden?: boolean;
1122
1063
  /**
1123
- * 按钮是否禁用
1064
+ * 按钮是否禁用,设置为true则变为灰色不可点击
1124
1065
  */
1125
1066
  disabled?: boolean;
1126
1067
  /**
1127
- * 按钮提示文本
1068
+ * 按钮点击事件.接受一个函数,可以自定义点击事件。
1069
+ */
1070
+ callback?: () => void;
1071
+ /**
1072
+ * 按钮提示文本,鼠标悬浮到按钮上时显示的tooltip文字
1128
1073
  */
1129
1074
  tooltip?: string;
1075
+ /**
1076
+ * 按钮在工具栏中位置,不设置则按照默认位置
1077
+ */
1078
+ index?: number;
1130
1079
  }
1131
1080
 
1132
1081
  /**
1133
1082
  * 工具栏内置功能按钮配置
1134
1083
  */
1135
- export declare type EditorToolbarFeatureButtonConfig<ToolButtonName extends string> = {
1136
- [key in ToolButtonName]?: EditorToolbarFeatureButton<ToolButtonName>;
1084
+ export declare type EditorToolbarFeatureButtonConfig<TName extends string> = {
1085
+ [key in TName]?: EditorToolbarFeatureButton<key>;
1137
1086
  };
1138
1087
 
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
1088
  /**
1173
1089
  * 工具栏相关设置,可以控制工具栏的显示内容
1174
1090
  */
1175
- export declare interface EditorToolbarOptions<ToolButtonName extends string = EditorToolbarFeatureButtonName> {
1091
+ export declare interface EditorToolbarOptions<TName extends string> {
1176
1092
  /**
1177
1093
  * 控制工具栏显隐状态
1178
1094
  */
@@ -1184,11 +1100,11 @@ export declare interface EditorToolbarOptions<ToolButtonName extends string = Ed
1184
1100
  /**
1185
1101
  * 现有按钮的功能配置
1186
1102
  */
1187
- features?: EditorToolbarFeatureButtonConfig<ToolButtonName>;
1103
+ features?: EditorToolbarFeatureButtonConfig<TName>;
1188
1104
  /**
1189
1105
  * 自定义按钮
1190
1106
  */
1191
- custom?: EditorToolbarCustomButtonConfig;
1107
+ custom?: EditorToolbarFeatureButtonConfig<string>;
1192
1108
  }
1193
1109
 
1194
1110
  export declare type EditorUploadableFile = EditorLocalUploadableFile;