@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.
@@ -384,27 +384,6 @@ export declare interface EditorContent<Delta = EditorDelta> {
384
384
  addChangeListener: (listener: (change: Delta) => void) => () => void;
385
385
  }
386
386
 
387
- /**
388
- * 右键菜单栏二级以下的菜单入口
389
- */
390
- export declare type EditorContextMenuEntryButton<TName extends string> = EditorMenuEntryButton<TName>;
391
-
392
- /**
393
- * 右键菜单栏一级菜单配置,此处用于定义一级菜单的操作入口,
394
- * 右键菜单栏一级菜单指点击右键弹出菜单时的菜单项
395
- */
396
- export declare type EditorContextMenuEntryConfig<TName extends string> = EditorMenuEntryConfig<TName>;
397
-
398
- /**
399
- * 右键菜单栏功能按钮配置
400
- */
401
- export declare type EditorContextMenuFeatureButton<TName extends string> = EditorMenuFeatureButton<TName>;
402
-
403
- /**
404
- * 右键菜单栏按钮配置
405
- */
406
- export declare type EditorContextMenuFeatureButtonConfig<TName extends string> = EditorMenuFeatureButtonConfig<TName>;
407
-
408
387
  /**
409
388
  * 右键菜单栏相关配置
410
389
  * 右键菜单栏是指的编辑器中点击右键弹出的菜单栏。目前等于菜单栏配置,可扩展
@@ -598,120 +577,109 @@ export declare interface EditorLocalUploadableFile extends EditorBaseUploadableF
598
577
  }
599
578
 
600
579
  /**
601
- * 菜单栏自定义按钮配置
580
+ * 基础菜单项配置,所有菜单项类型都包含这些属性
602
581
  */
603
- export declare type EditorMenuCustomButton = {
604
- /**
605
- * 按钮名称
606
- */
607
- name: string;
608
- /**
609
- * 链接
610
- */
611
- type: 'link';
582
+ declare interface EditorMenuBaseMenuItemConfig<TName extends string> {
612
583
  /**
613
- * 按钮文本
584
+ * 菜单项的唯一标识,用以确定配置的是哪个菜单
614
585
  */
615
- text: string;
616
- /**
617
- * 链接地址
618
- */
619
- url: string;
620
- } | {
586
+ name: TName;
621
587
  /**
622
- * 按钮名称
588
+ * 菜单项类型
623
589
  */
624
- name: string;
590
+ type?: EditorMenuItemType;
591
+ }
592
+
593
+ /**
594
+ * 按钮菜单项配置
595
+ */
596
+ export declare interface EditorMenuButtonMenuItemConfig<TName extends string> extends EditorMenuBaseMenuItemConfig<TName> {
597
+ type?: 'button';
625
598
  /**
626
- * 按钮,点击后触发 callback 回调
599
+ * 是否禁用菜单项,禁用后菜单项依旧显示不过变为灰色,不可点击
627
600
  */
628
- type: 'button';
601
+ disabled?: boolean;
629
602
  /**
630
- * 按钮文本
603
+ * 菜单项显示文本,修改该值可以替换此菜单项默认显示文案
631
604
  */
632
- label: string;
605
+ label?: string;
633
606
  /**
634
- * 按钮图标,可以是 base64 的图片信息,也可以是图片 url
607
+ * 菜单项图标,可以是 base64 的图片信息,也可以是图片 url
608
+ * 配置为空字符串则可以隐藏菜单项默认的图标
635
609
  */
636
610
  icon?: string;
637
611
  /**
638
- * 按钮点击事件
612
+ * 菜单项点击事件,接受一个函数,可以自定义点击事件
639
613
  */
640
- callback: () => void;
641
- };
614
+ callback?: () => void;
615
+ }
642
616
 
643
617
  /**
644
- * 菜单栏二级以下的菜单入口
618
+ * 编辑器菜单配置类型
619
+ * 联合类型,表示可以是任意一种菜单项配置
645
620
  */
646
- export declare interface EditorMenuEntryButton<TName extends string> {
647
- type: 'entry';
621
+ export declare type EditorMenuEntryConfig<TName extends string> = EditorMenuHiddenMenuItemConfig<TName> | EditorMenuButtonMenuItemConfig<TName> | EditorMenuLinkMenuItemConfig<TName> | EditorMenuEntryMenuItemConfig<TName>;
622
+
623
+ /**
624
+ * 子菜单入口配置
625
+ */
626
+ export declare interface EditorMenuEntryMenuItemConfig<TName extends string> extends EditorMenuBaseMenuItemConfig<TName> {
627
+ type?: 'entry';
648
628
  /**
649
- * 菜单名称
629
+ * 是否禁用菜单项,禁用后菜单项依旧显示不过变为灰色,不可点击
650
630
  */
651
- name: string;
631
+ disabled?: boolean;
652
632
  /**
653
- * 菜单图标
633
+ * 菜单项显示文本,修改该值可以替换此菜单项默认显示文案
634
+ */
635
+ label?: string;
636
+ /**
637
+ * 菜单项图标,可以是 base64 的图片信息,也可以是图片 url
638
+ * 配置为空字符串则可以隐藏菜单项默认的图标
654
639
  */
655
640
  icon?: string;
656
641
  /**
657
- * 下一级子菜单
642
+ * 下一级菜单配置,下一级菜单配置项和上一级相同
643
+ * 如果下一级仍然是 entry 类型,可以无限向下扩展
658
644
  */
659
- children?: Array<EditorMenuFeatureButton<TName> | EditorMenuEntryButton<TName>>[];
645
+ children?: EditorMenuEntryConfig<TName>[];
660
646
  }
661
647
 
662
648
  /**
663
- * 菜单栏一级菜单配置,此处用于定义一级菜单的操作入口,
664
- * 一级菜单在鼠标悬停时展示二级列表
649
+ * 隐藏菜单项配置
665
650
  */
666
- export declare interface EditorMenuEntryConfig<TName extends string> {
667
- /**
668
- * 一级菜单名称
669
- */
670
- name: string;
671
- /**
672
- * 二级菜单定义,定一个二维数组,用于定义二级菜单的结构,
673
- * 将第一层数组中的所有按钮放到一个区域内用分隔符隔开,
674
- * 第二层数组为按钮的定义,可以是功能按钮也可以是一个下拉入口。
675
- */
676
- children: Array<EditorMenuFeatureButton<TName> | EditorMenuEntryButton<TName>>[];
677
- /**
678
- * 是否隐藏一级菜单
679
- */
651
+ export declare interface EditorMenuHiddenMenuItemConfig<TName extends string> extends EditorMenuBaseMenuItemConfig<TName> {
680
652
  type?: 'hidden';
681
653
  }
682
654
 
683
655
  /**
684
- * 菜单栏功能按钮配置
656
+ * 菜单项类型
685
657
  */
686
- export declare type EditorMenuFeatureButton<TName extends string> = {
687
- /**
688
- * 隐藏按钮,用作在需要隐藏菜单栏时定义
689
- */
690
- type: 'hidden';
658
+ export declare type EditorMenuItemType = 'hidden' | 'button' | 'link' | 'entry';
659
+
660
+ /**
661
+ * 链接菜单项配置
662
+ */
663
+ export declare interface EditorMenuLinkMenuItemConfig<TName extends string> extends EditorMenuBaseMenuItemConfig<TName> {
664
+ type?: 'link';
691
665
  /**
692
- * 按钮名称
666
+ * 是否禁用菜单项,禁用后菜单项依旧显示不过变为灰色,不可点击
693
667
  */
694
- name: TName;
695
- } | {
696
- type: 'button';
668
+ disabled?: boolean;
697
669
  /**
698
- * 按钮名称
670
+ * 菜单项显示文本,修改该值可以替换此菜单项默认显示文案
699
671
  */
700
- name: TName;
672
+ label?: string;
701
673
  /**
702
- * 按钮标签(显示文本)
674
+ * 菜单项图标,可以是 base64 的图片信息,也可以是图片 url
675
+ * 配置为空字符串则可以隐藏菜单项默认的图标
703
676
  */
704
- label: string;
677
+ icon?: string;
705
678
  /**
706
- * 按钮图标,可以是 base64 的图片信息,也可以是图片 url
679
+ * 跳转链接地址
707
680
  */
708
- icon?: string;
709
- };
710
-
711
- /**
712
- * 菜单栏按钮配置
713
- */
714
- export declare type EditorMenuFeatureButtonConfig<TName extends string> = Record<TName, EditorMenuFeatureButton<TName>>;
681
+ url?: string;
682
+ }
715
683
 
716
684
  /**
717
685
  * 菜单栏相关配置,目前菜单栏不是所有套件都支持,
@@ -719,25 +687,26 @@ export declare type EditorMenuFeatureButtonConfig<TName extends string> = Record
719
687
  */
720
688
  export declare interface EditorMenuOptions<TName extends string> {
721
689
  /**
722
- * 菜单栏是否隐藏
690
+ * 菜单栏是否隐藏,设置为true, 则整个菜单栏不显示
723
691
  */
724
692
  hidden?: boolean;
725
693
  /**
726
- * 是否禁用菜单栏所有功能
694
+ * 是否禁用菜单栏所有功能。设置为true,菜单栏依旧显示,但所有菜单项为灰色不可点击
727
695
  */
728
696
  disabled?: boolean;
729
697
  /**
730
- * 菜单栏一级菜单配置
698
+ * 菜单栏一级菜单配置,指显示在菜单栏上的菜单项。
731
699
  */
732
700
  entries?: EditorMenuEntryConfig<TName>[];
733
701
  /**
734
702
  * 菜单栏功能按钮配置
703
+ * TODO 此配置目前没有用到,后续看是保留还是和custom合并
735
704
  */
736
- features?: Partial<EditorMenuFeatureButtonConfig<TName>>;
705
+ features?: EditorMenuEntryConfig<TName>[];
737
706
  /**
738
707
  * 自定义按钮配置
739
708
  */
740
- custom?: EditorMenuCustomButton[];
709
+ custom?: EditorMenuEntryConfig<TName>[];
741
710
  }
742
711
 
743
712
  /**
@@ -1100,43 +1069,15 @@ export declare interface EditorTextOptions<Color = string> {
1100
1069
  }
1101
1070
 
1102
1071
  /**
1103
- * 工具栏自定义按钮配置
1104
- */
1105
- export declare interface EditorToolbarCustomButton extends Omit<EditorToolbarFeatureButton, 'name'> {
1106
- /**
1107
- * 自定义按钮名称
1108
- */
1109
- name: string;
1110
- /**
1111
- * 按钮点击事件
1112
- */
1113
- callback: () => void;
1114
- /**
1115
- * 按钮在工具栏中的位置,默认添加到工具栏所有按钮后面
1116
- */
1117
- index?: number;
1118
- }
1119
-
1120
- /**
1121
- * 工具栏自定义按钮配置
1072
+ * 工具栏功能按钮配置(包括内置按钮和自定义按钮)
1122
1073
  */
1123
- export declare interface EditorToolbarCustomButtonConfig {
1074
+ export declare interface EditorToolbarFeatureButton<TName extends string> {
1124
1075
  /**
1125
- * 按钮配置
1076
+ * 按钮的唯一标识,用以确定配置的是哪个按钮。
1126
1077
  */
1127
- [key: string]: EditorToolbarCustomButton;
1128
- }
1129
-
1130
- /**
1131
- * 工具栏内置功能按钮配置
1132
- */
1133
- export declare interface EditorToolbarFeatureButton<ToolButtonName extends string = EditorToolbarFeatureButtonName> {
1134
- /**
1135
- * 按钮类型
1136
- */
1137
- name: ToolButtonName;
1078
+ name: TName;
1138
1079
  /**
1139
- * 按钮标签(显示文本)
1080
+ * 按钮标签(显示文本)一般工具栏上的按钮不会显示文本,如果需要显示文本,配置此项。
1140
1081
  */
1141
1082
  label?: string;
1142
1083
  /**
@@ -1144,63 +1085,38 @@ export declare interface EditorToolbarFeatureButton<ToolButtonName extends strin
1144
1085
  */
1145
1086
  icon?: string;
1146
1087
  /**
1147
- * 按钮是否隐藏
1088
+ * 按钮是否隐藏,设置为true则隐藏按钮
1148
1089
  */
1149
1090
  hidden?: boolean;
1150
1091
  /**
1151
- * 按钮是否禁用
1092
+ * 按钮是否禁用,设置为true则变为灰色不可点击
1152
1093
  */
1153
1094
  disabled?: boolean;
1154
1095
  /**
1155
- * 按钮提示文本
1096
+ * 按钮点击事件.接受一个函数,可以自定义点击事件。
1097
+ */
1098
+ callback?: () => void;
1099
+ /**
1100
+ * 按钮提示文本,鼠标悬浮到按钮上时显示的tooltip文字
1156
1101
  */
1157
1102
  tooltip?: string;
1103
+ /**
1104
+ * 按钮在工具栏中位置,不设置则按照默认位置
1105
+ */
1106
+ index?: number;
1158
1107
  }
1159
1108
 
1160
1109
  /**
1161
1110
  * 工具栏内置功能按钮配置
1162
1111
  */
1163
- export declare type EditorToolbarFeatureButtonConfig<ToolButtonName extends string> = {
1164
- [key in ToolButtonName]?: EditorToolbarFeatureButton<ToolButtonName>;
1112
+ export declare type EditorToolbarFeatureButtonConfig<TName extends string> = {
1113
+ [key in TName]?: EditorToolbarFeatureButton<key>;
1165
1114
  };
1166
1115
 
1167
- /**
1168
- * 工具栏内置功能按钮
1169
- */
1170
- export declare type EditorToolbarFeatureButtonName =
1171
- /**
1172
- * 加粗
1173
- */
1174
- 'bold'
1175
- /**
1176
- * 斜体
1177
- */
1178
- | 'italic'
1179
- /**
1180
- * 下划线
1181
- */
1182
- | 'underline'
1183
- /**
1184
- * 删除线
1185
- */
1186
- | 'strikethrough'
1187
- /**
1188
- * 插入图片
1189
- */
1190
- | 'insertImage'
1191
- /**
1192
- * 插入链接
1193
- */
1194
- | 'insertLink'
1195
- /**
1196
- * 限制编辑
1197
- */
1198
- | 'restriction';
1199
-
1200
1116
  /**
1201
1117
  * 工具栏相关设置,可以控制工具栏的显示内容
1202
1118
  */
1203
- export declare interface EditorToolbarOptions<ToolButtonName extends string = EditorToolbarFeatureButtonName> {
1119
+ export declare interface EditorToolbarOptions<TName extends string> {
1204
1120
  /**
1205
1121
  * 控制工具栏显隐状态
1206
1122
  */
@@ -1212,11 +1128,11 @@ export declare interface EditorToolbarOptions<ToolButtonName extends string = Ed
1212
1128
  /**
1213
1129
  * 现有按钮的功能配置
1214
1130
  */
1215
- features?: EditorToolbarFeatureButtonConfig<ToolButtonName>;
1131
+ features?: EditorToolbarFeatureButtonConfig<TName>;
1216
1132
  /**
1217
1133
  * 自定义按钮
1218
1134
  */
1219
- custom?: EditorToolbarCustomButtonConfig;
1135
+ custom?: EditorToolbarFeatureButtonConfig<string>;
1220
1136
  }
1221
1137
 
1222
1138
  export declare type EditorUploadableFile = EditorLocalUploadableFile;
@@ -1434,7 +1350,7 @@ export declare type PresentationMenuEntryConfig = EditorMenuEntryConfig<Presenta
1434
1350
  /**
1435
1351
  * 幻灯片工具栏功能按钮
1436
1352
  */
1437
- export declare type PresentationMenuFeatureButtonConfig = EditorMenuFeatureButtonConfig<PresentationMenuFeatureButtonName>;
1353
+ export declare type PresentationMenuFeatureButtonConfig = EditorMenuEntryConfig<PresentationMenuFeatureButtonName>;
1438
1354
 
1439
1355
  /**
1440
1356
  * 幻灯片工具栏内置功能按钮