@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.
@@ -421,27 +421,6 @@ export declare interface EditorContent<Delta = EditorDelta> {
421
421
  addChangeListener: (listener: (change: Delta) => void) => () => void;
422
422
  }
423
423
 
424
- /**
425
- * 右键菜单栏二级以下的菜单入口
426
- */
427
- export declare type EditorContextMenuEntryButton<TName extends string> = EditorMenuEntryButton<TName>;
428
-
429
- /**
430
- * 右键菜单栏一级菜单配置,此处用于定义一级菜单的操作入口,
431
- * 右键菜单栏一级菜单指点击右键弹出菜单时的菜单项
432
- */
433
- export declare type EditorContextMenuEntryConfig<TName extends string> = EditorMenuEntryConfig<TName>;
434
-
435
- /**
436
- * 右键菜单栏功能按钮配置
437
- */
438
- export declare type EditorContextMenuFeatureButton<TName extends string> = EditorMenuFeatureButton<TName>;
439
-
440
- /**
441
- * 右键菜单栏按钮配置
442
- */
443
- export declare type EditorContextMenuFeatureButtonConfig<TName extends string> = EditorMenuFeatureButtonConfig<TName>;
444
-
445
424
  /**
446
425
  * 右键菜单栏相关配置
447
426
  * 右键菜单栏是指的编辑器中点击右键弹出的菜单栏。目前等于菜单栏配置,可扩展
@@ -635,120 +614,109 @@ export declare interface EditorLocalUploadableFile extends EditorBaseUploadableF
635
614
  }
636
615
 
637
616
  /**
638
- * 菜单栏自定义按钮配置
617
+ * 基础菜单项配置,所有菜单项类型都包含这些属性
639
618
  */
640
- export declare type EditorMenuCustomButton = {
641
- /**
642
- * 按钮名称
643
- */
644
- name: string;
645
- /**
646
- * 链接
647
- */
648
- type: 'link';
619
+ declare interface EditorMenuBaseMenuItemConfig<TName extends string> {
649
620
  /**
650
- * 按钮文本
621
+ * 菜单项的唯一标识,用以确定配置的是哪个菜单
651
622
  */
652
- text: string;
653
- /**
654
- * 链接地址
655
- */
656
- url: string;
657
- } | {
623
+ name: TName;
658
624
  /**
659
- * 按钮名称
625
+ * 菜单项类型
660
626
  */
661
- name: string;
627
+ type?: EditorMenuItemType;
628
+ }
629
+
630
+ /**
631
+ * 按钮菜单项配置
632
+ */
633
+ export declare interface EditorMenuButtonMenuItemConfig<TName extends string> extends EditorMenuBaseMenuItemConfig<TName> {
634
+ type?: 'button';
662
635
  /**
663
- * 按钮,点击后触发 callback 回调
636
+ * 是否禁用菜单项,禁用后菜单项依旧显示不过变为灰色,不可点击
664
637
  */
665
- type: 'button';
638
+ disabled?: boolean;
666
639
  /**
667
- * 按钮文本
640
+ * 菜单项显示文本,修改该值可以替换此菜单项默认显示文案
668
641
  */
669
- label: string;
642
+ label?: string;
670
643
  /**
671
- * 按钮图标,可以是 base64 的图片信息,也可以是图片 url
644
+ * 菜单项图标,可以是 base64 的图片信息,也可以是图片 url
645
+ * 配置为空字符串则可以隐藏菜单项默认的图标
672
646
  */
673
647
  icon?: string;
674
648
  /**
675
- * 按钮点击事件
649
+ * 菜单项点击事件,接受一个函数,可以自定义点击事件
676
650
  */
677
- callback: () => void;
678
- };
651
+ callback?: () => void;
652
+ }
679
653
 
680
654
  /**
681
- * 菜单栏二级以下的菜单入口
655
+ * 编辑器菜单配置类型
656
+ * 联合类型,表示可以是任意一种菜单项配置
682
657
  */
683
- export declare interface EditorMenuEntryButton<TName extends string> {
684
- type: 'entry';
658
+ export declare type EditorMenuEntryConfig<TName extends string> = EditorMenuHiddenMenuItemConfig<TName> | EditorMenuButtonMenuItemConfig<TName> | EditorMenuLinkMenuItemConfig<TName> | EditorMenuEntryMenuItemConfig<TName>;
659
+
660
+ /**
661
+ * 子菜单入口配置
662
+ */
663
+ export declare interface EditorMenuEntryMenuItemConfig<TName extends string> extends EditorMenuBaseMenuItemConfig<TName> {
664
+ type?: 'entry';
685
665
  /**
686
- * 菜单名称
666
+ * 是否禁用菜单项,禁用后菜单项依旧显示不过变为灰色,不可点击
687
667
  */
688
- name: string;
668
+ disabled?: boolean;
689
669
  /**
690
- * 菜单图标
670
+ * 菜单项显示文本,修改该值可以替换此菜单项默认显示文案
671
+ */
672
+ label?: string;
673
+ /**
674
+ * 菜单项图标,可以是 base64 的图片信息,也可以是图片 url
675
+ * 配置为空字符串则可以隐藏菜单项默认的图标
691
676
  */
692
677
  icon?: string;
693
678
  /**
694
- * 下一级子菜单
679
+ * 下一级菜单配置,下一级菜单配置项和上一级相同
680
+ * 如果下一级仍然是 entry 类型,可以无限向下扩展
695
681
  */
696
- children?: Array<EditorMenuFeatureButton<TName> | EditorMenuEntryButton<TName>>[];
682
+ children?: EditorMenuEntryConfig<TName>[];
697
683
  }
698
684
 
699
685
  /**
700
- * 菜单栏一级菜单配置,此处用于定义一级菜单的操作入口,
701
- * 一级菜单在鼠标悬停时展示二级列表
686
+ * 隐藏菜单项配置
702
687
  */
703
- export declare interface EditorMenuEntryConfig<TName extends string> {
704
- /**
705
- * 一级菜单名称
706
- */
707
- name: string;
708
- /**
709
- * 二级菜单定义,定一个二维数组,用于定义二级菜单的结构,
710
- * 将第一层数组中的所有按钮放到一个区域内用分隔符隔开,
711
- * 第二层数组为按钮的定义,可以是功能按钮也可以是一个下拉入口。
712
- */
713
- children: Array<EditorMenuFeatureButton<TName> | EditorMenuEntryButton<TName>>[];
714
- /**
715
- * 是否隐藏一级菜单
716
- */
688
+ export declare interface EditorMenuHiddenMenuItemConfig<TName extends string> extends EditorMenuBaseMenuItemConfig<TName> {
717
689
  type?: 'hidden';
718
690
  }
719
691
 
720
692
  /**
721
- * 菜单栏功能按钮配置
693
+ * 菜单项类型
722
694
  */
723
- export declare type EditorMenuFeatureButton<TName extends string> = {
724
- /**
725
- * 隐藏按钮,用作在需要隐藏菜单栏时定义
726
- */
727
- type: 'hidden';
695
+ export declare type EditorMenuItemType = 'hidden' | 'button' | 'link' | 'entry';
696
+
697
+ /**
698
+ * 链接菜单项配置
699
+ */
700
+ export declare interface EditorMenuLinkMenuItemConfig<TName extends string> extends EditorMenuBaseMenuItemConfig<TName> {
701
+ type?: 'link';
728
702
  /**
729
- * 按钮名称
703
+ * 是否禁用菜单项,禁用后菜单项依旧显示不过变为灰色,不可点击
730
704
  */
731
- name: TName;
732
- } | {
733
- type: 'button';
705
+ disabled?: boolean;
734
706
  /**
735
- * 按钮名称
707
+ * 菜单项显示文本,修改该值可以替换此菜单项默认显示文案
736
708
  */
737
- name: TName;
709
+ label?: string;
738
710
  /**
739
- * 按钮标签(显示文本)
711
+ * 菜单项图标,可以是 base64 的图片信息,也可以是图片 url
712
+ * 配置为空字符串则可以隐藏菜单项默认的图标
740
713
  */
741
- label: string;
714
+ icon?: string;
742
715
  /**
743
- * 按钮图标,可以是 base64 的图片信息,也可以是图片 url
716
+ * 跳转链接地址
744
717
  */
745
- icon?: string;
746
- };
747
-
748
- /**
749
- * 菜单栏按钮配置
750
- */
751
- export declare type EditorMenuFeatureButtonConfig<TName extends string> = Record<TName, EditorMenuFeatureButton<TName>>;
718
+ url?: string;
719
+ }
752
720
 
753
721
  /**
754
722
  * 菜单栏相关配置,目前菜单栏不是所有套件都支持,
@@ -756,25 +724,26 @@ export declare type EditorMenuFeatureButtonConfig<TName extends string> = Record
756
724
  */
757
725
  export declare interface EditorMenuOptions<TName extends string> {
758
726
  /**
759
- * 菜单栏是否隐藏
727
+ * 菜单栏是否隐藏,设置为true, 则整个菜单栏不显示
760
728
  */
761
729
  hidden?: boolean;
762
730
  /**
763
- * 是否禁用菜单栏所有功能
731
+ * 是否禁用菜单栏所有功能。设置为true,菜单栏依旧显示,但所有菜单项为灰色不可点击
764
732
  */
765
733
  disabled?: boolean;
766
734
  /**
767
- * 菜单栏一级菜单配置
735
+ * 菜单栏一级菜单配置,指显示在菜单栏上的菜单项。
768
736
  */
769
737
  entries?: EditorMenuEntryConfig<TName>[];
770
738
  /**
771
739
  * 菜单栏功能按钮配置
740
+ * TODO 此配置目前没有用到,后续看是保留还是和custom合并
772
741
  */
773
- features?: Partial<EditorMenuFeatureButtonConfig<TName>>;
742
+ features?: EditorMenuEntryConfig<TName>[];
774
743
  /**
775
744
  * 自定义按钮配置
776
745
  */
777
- custom?: EditorMenuCustomButton[];
746
+ custom?: EditorMenuEntryConfig<TName>[];
778
747
  }
779
748
 
780
749
  /**
@@ -1137,43 +1106,15 @@ export declare interface EditorTextOptions<Color = string> {
1137
1106
  }
1138
1107
 
1139
1108
  /**
1140
- * 工具栏自定义按钮配置
1141
- */
1142
- export declare interface EditorToolbarCustomButton extends Omit<EditorToolbarFeatureButton, 'name'> {
1143
- /**
1144
- * 自定义按钮名称
1145
- */
1146
- name: string;
1147
- /**
1148
- * 按钮点击事件
1149
- */
1150
- callback: () => void;
1151
- /**
1152
- * 按钮在工具栏中的位置,默认添加到工具栏所有按钮后面
1153
- */
1154
- index?: number;
1155
- }
1156
-
1157
- /**
1158
- * 工具栏自定义按钮配置
1109
+ * 工具栏功能按钮配置(包括内置按钮和自定义按钮)
1159
1110
  */
1160
- export declare interface EditorToolbarCustomButtonConfig {
1111
+ export declare interface EditorToolbarFeatureButton<TName extends string> {
1161
1112
  /**
1162
- * 按钮配置
1113
+ * 按钮的唯一标识,用以确定配置的是哪个按钮。
1163
1114
  */
1164
- [key: string]: EditorToolbarCustomButton;
1165
- }
1166
-
1167
- /**
1168
- * 工具栏内置功能按钮配置
1169
- */
1170
- export declare interface EditorToolbarFeatureButton<ToolButtonName extends string = EditorToolbarFeatureButtonName> {
1171
- /**
1172
- * 按钮类型
1173
- */
1174
- name: ToolButtonName;
1115
+ name: TName;
1175
1116
  /**
1176
- * 按钮标签(显示文本)
1117
+ * 按钮标签(显示文本)一般工具栏上的按钮不会显示文本,如果需要显示文本,配置此项。
1177
1118
  */
1178
1119
  label?: string;
1179
1120
  /**
@@ -1181,63 +1122,38 @@ export declare interface EditorToolbarFeatureButton<ToolButtonName extends strin
1181
1122
  */
1182
1123
  icon?: string;
1183
1124
  /**
1184
- * 按钮是否隐藏
1125
+ * 按钮是否隐藏,设置为true则隐藏按钮
1185
1126
  */
1186
1127
  hidden?: boolean;
1187
1128
  /**
1188
- * 按钮是否禁用
1129
+ * 按钮是否禁用,设置为true则变为灰色不可点击
1189
1130
  */
1190
1131
  disabled?: boolean;
1191
1132
  /**
1192
- * 按钮提示文本
1133
+ * 按钮点击事件.接受一个函数,可以自定义点击事件。
1134
+ */
1135
+ callback?: () => void;
1136
+ /**
1137
+ * 按钮提示文本,鼠标悬浮到按钮上时显示的tooltip文字
1193
1138
  */
1194
1139
  tooltip?: string;
1140
+ /**
1141
+ * 按钮在工具栏中位置,不设置则按照默认位置
1142
+ */
1143
+ index?: number;
1195
1144
  }
1196
1145
 
1197
1146
  /**
1198
1147
  * 工具栏内置功能按钮配置
1199
1148
  */
1200
- export declare type EditorToolbarFeatureButtonConfig<ToolButtonName extends string> = {
1201
- [key in ToolButtonName]?: EditorToolbarFeatureButton<ToolButtonName>;
1149
+ export declare type EditorToolbarFeatureButtonConfig<TName extends string> = {
1150
+ [key in TName]?: EditorToolbarFeatureButton<key>;
1202
1151
  };
1203
1152
 
1204
- /**
1205
- * 工具栏内置功能按钮
1206
- */
1207
- export declare type EditorToolbarFeatureButtonName =
1208
- /**
1209
- * 加粗
1210
- */
1211
- 'bold'
1212
- /**
1213
- * 斜体
1214
- */
1215
- | 'italic'
1216
- /**
1217
- * 下划线
1218
- */
1219
- | 'underline'
1220
- /**
1221
- * 删除线
1222
- */
1223
- | 'strikethrough'
1224
- /**
1225
- * 插入图片
1226
- */
1227
- | 'insertImage'
1228
- /**
1229
- * 插入链接
1230
- */
1231
- | 'insertLink'
1232
- /**
1233
- * 限制编辑
1234
- */
1235
- | 'restriction';
1236
-
1237
1153
  /**
1238
1154
  * 工具栏相关设置,可以控制工具栏的显示内容
1239
1155
  */
1240
- export declare interface EditorToolbarOptions<ToolButtonName extends string = EditorToolbarFeatureButtonName> {
1156
+ export declare interface EditorToolbarOptions<TName extends string> {
1241
1157
  /**
1242
1158
  * 控制工具栏显隐状态
1243
1159
  */
@@ -1249,11 +1165,11 @@ export declare interface EditorToolbarOptions<ToolButtonName extends string = Ed
1249
1165
  /**
1250
1166
  * 现有按钮的功能配置
1251
1167
  */
1252
- features?: EditorToolbarFeatureButtonConfig<ToolButtonName>;
1168
+ features?: EditorToolbarFeatureButtonConfig<TName>;
1253
1169
  /**
1254
1170
  * 自定义按钮
1255
1171
  */
1256
- custom?: EditorToolbarCustomButtonConfig;
1172
+ custom?: EditorToolbarFeatureButtonConfig<string>;
1257
1173
  }
1258
1174
 
1259
1175
  export declare type EditorUploadableFile = EditorLocalUploadableFile;