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

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,137 @@ 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;
619
+ export declare interface EditorMenuBaseMenuItemConfig<TName extends string> {
645
620
  /**
646
- * 链接
621
+ * 菜单项的唯一标识,用以确定配置的是哪个菜单
647
622
  */
648
- type: 'link';
649
- /**
650
- * 按钮文本
651
- */
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
+ }
653
+
654
+ /**
655
+ * 编辑器菜单配置类型
656
+ * 联合类型,表示可以是任意一种菜单项配置
657
+ */
658
+ export declare type EditorMenuEntryConfig<TName extends string> = EditorMenuHiddenMenuItemConfig<TName> | EditorMenuButtonMenuItemConfig<TName> | EditorMenuLinkMenuItemConfig<TName> | EditorMenuEntryMenuItemConfig<TName>;
679
659
 
680
660
  /**
681
- * 菜单栏二级以下的菜单入口
661
+ * 子菜单入口配置
682
662
  */
683
- export declare interface EditorMenuEntryButton<TName extends string> {
663
+ export declare interface EditorMenuEntryMenuItemConfig<TName extends string> extends EditorMenuBaseMenuItemConfig<TName> {
684
664
  type: 'entry';
685
665
  /**
686
- * 菜单名称
666
+ * 是否禁用菜单项,禁用后菜单项依旧显示不过变为灰色,不可点击
687
667
  */
688
- name: string;
668
+ disabled?: boolean;
669
+ /**
670
+ * 菜单项显示文本,修改该值可以替换此菜单项默认显示文案
671
+ */
672
+ label?: string;
689
673
  /**
690
- * 菜单图标
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> {
688
+ export declare interface EditorMenuFeatureConfig {
704
689
  /**
705
- * 一级菜单名称
690
+ * 是否隐藏菜单项,设置为true则隐藏菜单项
706
691
  */
707
- name: string;
708
- /**
709
- * 二级菜单定义,定一个二维数组,用于定义二级菜单的结构,
710
- * 将第一层数组中的所有按钮放到一个区域内用分隔符隔开,
711
- * 第二层数组为按钮的定义,可以是功能按钮也可以是一个下拉入口。
712
- */
713
- children: Array<EditorMenuFeatureButton<TName> | EditorMenuEntryButton<TName>>[];
692
+ hidden?: boolean;
714
693
  /**
715
- * 是否隐藏一级菜单
694
+ * 是否禁用菜单项,设置为true则变为灰色不可点击
716
695
  */
717
- type?: 'hidden';
696
+ disabled?: boolean;
718
697
  }
719
698
 
720
699
  /**
721
- * 菜单栏功能按钮配置
700
+ * 菜单功能按钮配置
722
701
  */
723
- export declare type EditorMenuFeatureButton<TName extends string> = {
702
+ export declare interface EditorMenuFeatureConfig {
724
703
  /**
725
- * 隐藏按钮,用作在需要隐藏菜单栏时定义
704
+ * 是否隐藏菜单项,设置为true则隐藏菜单项
726
705
  */
727
- type: 'hidden';
706
+ hidden?: boolean;
728
707
  /**
729
- * 按钮名称
708
+ * 是否禁用菜单项,设置为true则变为灰色不可点击
730
709
  */
731
- name: TName;
732
- } | {
733
- type: 'button';
710
+ disabled?: boolean;
711
+ }
712
+
713
+ /**
714
+ * 隐藏菜单项配置
715
+ */
716
+ export declare interface EditorMenuHiddenMenuItemConfig<TName extends string> extends EditorMenuBaseMenuItemConfig<TName> {
717
+ type: 'hidden';
718
+ }
719
+
720
+ /**
721
+ * 菜单项类型
722
+ */
723
+ export declare type EditorMenuItemType = 'hidden' | 'button' | 'link' | 'entry';
724
+
725
+ /**
726
+ * 链接菜单项配置
727
+ */
728
+ export declare interface EditorMenuLinkMenuItemConfig<TName extends string> extends EditorMenuBaseMenuItemConfig<TName> {
729
+ type: 'link';
734
730
  /**
735
- * 按钮名称
731
+ * 是否禁用菜单项,禁用后菜单项依旧显示不过变为灰色,不可点击
736
732
  */
737
- name: TName;
733
+ disabled?: boolean;
738
734
  /**
739
- * 按钮标签(显示文本)
735
+ * 菜单项显示文本,修改该值可以替换此菜单项默认显示文案
740
736
  */
741
- label: string;
737
+ text?: string;
742
738
  /**
743
- * 按钮图标,可以是 base64 的图片信息,也可以是图片 url
739
+ * 菜单项图标,可以是 base64 的图片信息,也可以是图片 url
740
+ * 配置为空字符串则可以隐藏菜单项默认的图标
744
741
  */
745
742
  icon?: string;
746
- };
747
-
748
- /**
749
- * 菜单栏按钮配置
750
- */
751
- export declare type EditorMenuFeatureButtonConfig<TName extends string> = Record<TName, EditorMenuFeatureButton<TName>>;
743
+ /**
744
+ * 跳转链接地址
745
+ */
746
+ url?: string;
747
+ }
752
748
 
753
749
  /**
754
750
  * 菜单栏相关配置,目前菜单栏不是所有套件都支持,
@@ -756,25 +752,26 @@ export declare type EditorMenuFeatureButtonConfig<TName extends string> = Record
756
752
  */
757
753
  export declare interface EditorMenuOptions<TName extends string> {
758
754
  /**
759
- * 菜单栏是否隐藏
755
+ * 菜单栏是否隐藏,设置为true, 则整个菜单栏不显示
760
756
  */
761
757
  hidden?: boolean;
762
758
  /**
763
- * 是否禁用菜单栏所有功能
759
+ * 是否禁用菜单栏所有功能。设置为true,菜单栏依旧显示,但所有菜单项为灰色不可点击
764
760
  */
765
761
  disabled?: boolean;
766
762
  /**
767
- * 菜单栏一级菜单配置
763
+ * 菜单栏一级菜单配置,指显示在菜单栏上的菜单项。
768
764
  */
769
765
  entries?: EditorMenuEntryConfig<TName>[];
770
766
  /**
771
767
  * 菜单栏功能按钮配置
768
+ * TODO 此配置目前没有用到,后续看是保留还是和custom合并
772
769
  */
773
- features?: Partial<EditorMenuFeatureButtonConfig<TName>>;
770
+ features?: Record<TName, EditorMenuFeatureConfig>;
774
771
  /**
775
772
  * 自定义按钮配置
776
773
  */
777
- custom?: EditorMenuCustomButton[];
774
+ custom?: (EditorMenuButtonMenuItemConfig<string> | EditorMenuLinkMenuItemConfig<string>)[];
778
775
  }
779
776
 
780
777
  /**
@@ -1137,43 +1134,15 @@ export declare interface EditorTextOptions<Color = string> {
1137
1134
  }
1138
1135
 
1139
1136
  /**
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
- * 工具栏自定义按钮配置
1159
- */
1160
- export declare interface EditorToolbarCustomButtonConfig {
1161
- /**
1162
- * 按钮配置
1163
- */
1164
- [key: string]: EditorToolbarCustomButton;
1165
- }
1166
-
1167
- /**
1168
- * 工具栏内置功能按钮配置
1137
+ * 工具栏功能按钮配置(包括内置按钮和自定义按钮)
1169
1138
  */
1170
- export declare interface EditorToolbarFeatureButton<ToolButtonName extends string = EditorToolbarFeatureButtonName> {
1139
+ export declare interface EditorToolbarFeatureButton<TName extends string> {
1171
1140
  /**
1172
- * 按钮类型
1141
+ * 按钮的唯一标识,用以确定配置的是哪个按钮。
1173
1142
  */
1174
- name: ToolButtonName;
1143
+ name: TName;
1175
1144
  /**
1176
- * 按钮标签(显示文本)
1145
+ * 按钮标签(显示文本)一般工具栏上的按钮不会显示文本,如果需要显示文本,配置此项。
1177
1146
  */
1178
1147
  label?: string;
1179
1148
  /**
@@ -1181,63 +1150,38 @@ export declare interface EditorToolbarFeatureButton<ToolButtonName extends strin
1181
1150
  */
1182
1151
  icon?: string;
1183
1152
  /**
1184
- * 按钮是否隐藏
1153
+ * 按钮是否隐藏,设置为true则隐藏按钮
1185
1154
  */
1186
1155
  hidden?: boolean;
1187
1156
  /**
1188
- * 按钮是否禁用
1157
+ * 按钮是否禁用,设置为true则变为灰色不可点击
1189
1158
  */
1190
1159
  disabled?: boolean;
1191
1160
  /**
1192
- * 按钮提示文本
1161
+ * 按钮点击事件.接受一个函数,可以自定义点击事件。
1162
+ */
1163
+ callback?: () => void;
1164
+ /**
1165
+ * 按钮提示文本,鼠标悬浮到按钮上时显示的tooltip文字
1193
1166
  */
1194
1167
  tooltip?: string;
1168
+ /**
1169
+ * 按钮在工具栏中位置,不设置则按照默认位置
1170
+ */
1171
+ index?: number;
1195
1172
  }
1196
1173
 
1197
1174
  /**
1198
1175
  * 工具栏内置功能按钮配置
1199
1176
  */
1200
- export declare type EditorToolbarFeatureButtonConfig<ToolButtonName extends string> = {
1201
- [key in ToolButtonName]?: EditorToolbarFeatureButton<ToolButtonName>;
1177
+ export declare type EditorToolbarFeatureButtonConfig<TName extends string> = {
1178
+ [key in TName]?: EditorToolbarFeatureButton<key>;
1202
1179
  };
1203
1180
 
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
1181
  /**
1238
1182
  * 工具栏相关设置,可以控制工具栏的显示内容
1239
1183
  */
1240
- export declare interface EditorToolbarOptions<ToolButtonName extends string = EditorToolbarFeatureButtonName> {
1184
+ export declare interface EditorToolbarOptions<TName extends string> {
1241
1185
  /**
1242
1186
  * 控制工具栏显隐状态
1243
1187
  */
@@ -1249,11 +1193,11 @@ export declare interface EditorToolbarOptions<ToolButtonName extends string = Ed
1249
1193
  /**
1250
1194
  * 现有按钮的功能配置
1251
1195
  */
1252
- features?: EditorToolbarFeatureButtonConfig<ToolButtonName>;
1196
+ features?: EditorToolbarFeatureButtonConfig<TName>;
1253
1197
  /**
1254
1198
  * 自定义按钮
1255
1199
  */
1256
- custom?: EditorToolbarCustomButtonConfig;
1200
+ custom?: EditorToolbarFeatureButtonConfig<string>;
1257
1201
  }
1258
1202
 
1259
1203
  export declare type EditorUploadableFile = EditorLocalUploadableFile;