@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.
@@ -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,137 @@ 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;
582
+ export declare interface EditorMenuBaseMenuItemConfig<TName extends string> {
608
583
  /**
609
- * 链接
584
+ * 菜单项的唯一标识,用以确定配置的是哪个菜单
610
585
  */
611
- type: 'link';
612
- /**
613
- * 按钮文本
614
- */
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
+ }
616
+
617
+ /**
618
+ * 编辑器菜单配置类型
619
+ * 联合类型,表示可以是任意一种菜单项配置
620
+ */
621
+ export declare type EditorMenuEntryConfig<TName extends string> = EditorMenuHiddenMenuItemConfig<TName> | EditorMenuButtonMenuItemConfig<TName> | EditorMenuLinkMenuItemConfig<TName> | EditorMenuEntryMenuItemConfig<TName>;
642
622
 
643
623
  /**
644
- * 菜单栏二级以下的菜单入口
624
+ * 子菜单入口配置
645
625
  */
646
- export declare interface EditorMenuEntryButton<TName extends string> {
626
+ export declare interface EditorMenuEntryMenuItemConfig<TName extends string> extends EditorMenuBaseMenuItemConfig<TName> {
647
627
  type: 'entry';
648
628
  /**
649
- * 菜单名称
629
+ * 是否禁用菜单项,禁用后菜单项依旧显示不过变为灰色,不可点击
650
630
  */
651
- name: string;
631
+ disabled?: boolean;
632
+ /**
633
+ * 菜单项显示文本,修改该值可以替换此菜单项默认显示文案
634
+ */
635
+ label?: string;
652
636
  /**
653
- * 菜单图标
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> {
651
+ export declare interface EditorMenuFeatureConfig {
667
652
  /**
668
- * 一级菜单名称
653
+ * 是否隐藏菜单项,设置为true则隐藏菜单项
669
654
  */
670
- name: string;
671
- /**
672
- * 二级菜单定义,定一个二维数组,用于定义二级菜单的结构,
673
- * 将第一层数组中的所有按钮放到一个区域内用分隔符隔开,
674
- * 第二层数组为按钮的定义,可以是功能按钮也可以是一个下拉入口。
675
- */
676
- children: Array<EditorMenuFeatureButton<TName> | EditorMenuEntryButton<TName>>[];
655
+ hidden?: boolean;
677
656
  /**
678
- * 是否隐藏一级菜单
657
+ * 是否禁用菜单项,设置为true则变为灰色不可点击
679
658
  */
680
- type?: 'hidden';
659
+ disabled?: boolean;
681
660
  }
682
661
 
683
662
  /**
684
- * 菜单栏功能按钮配置
663
+ * 菜单功能按钮配置
685
664
  */
686
- export declare type EditorMenuFeatureButton<TName extends string> = {
665
+ export declare interface EditorMenuFeatureConfig {
687
666
  /**
688
- * 隐藏按钮,用作在需要隐藏菜单栏时定义
667
+ * 是否隐藏菜单项,设置为true则隐藏菜单项
689
668
  */
690
- type: 'hidden';
669
+ hidden?: boolean;
691
670
  /**
692
- * 按钮名称
671
+ * 是否禁用菜单项,设置为true则变为灰色不可点击
693
672
  */
694
- name: TName;
695
- } | {
696
- type: 'button';
673
+ disabled?: boolean;
674
+ }
675
+
676
+ /**
677
+ * 隐藏菜单项配置
678
+ */
679
+ export declare interface EditorMenuHiddenMenuItemConfig<TName extends string> extends EditorMenuBaseMenuItemConfig<TName> {
680
+ type: 'hidden';
681
+ }
682
+
683
+ /**
684
+ * 菜单项类型
685
+ */
686
+ export declare type EditorMenuItemType = 'hidden' | 'button' | 'link' | 'entry';
687
+
688
+ /**
689
+ * 链接菜单项配置
690
+ */
691
+ export declare interface EditorMenuLinkMenuItemConfig<TName extends string> extends EditorMenuBaseMenuItemConfig<TName> {
692
+ type: 'link';
697
693
  /**
698
- * 按钮名称
694
+ * 是否禁用菜单项,禁用后菜单项依旧显示不过变为灰色,不可点击
699
695
  */
700
- name: TName;
696
+ disabled?: boolean;
701
697
  /**
702
- * 按钮标签(显示文本)
698
+ * 菜单项显示文本,修改该值可以替换此菜单项默认显示文案
703
699
  */
704
- label: string;
700
+ text?: string;
705
701
  /**
706
- * 按钮图标,可以是 base64 的图片信息,也可以是图片 url
702
+ * 菜单项图标,可以是 base64 的图片信息,也可以是图片 url
703
+ * 配置为空字符串则可以隐藏菜单项默认的图标
707
704
  */
708
705
  icon?: string;
709
- };
710
-
711
- /**
712
- * 菜单栏按钮配置
713
- */
714
- export declare type EditorMenuFeatureButtonConfig<TName extends string> = Record<TName, EditorMenuFeatureButton<TName>>;
706
+ /**
707
+ * 跳转链接地址
708
+ */
709
+ url?: string;
710
+ }
715
711
 
716
712
  /**
717
713
  * 菜单栏相关配置,目前菜单栏不是所有套件都支持,
@@ -719,25 +715,26 @@ export declare type EditorMenuFeatureButtonConfig<TName extends string> = Record
719
715
  */
720
716
  export declare interface EditorMenuOptions<TName extends string> {
721
717
  /**
722
- * 菜单栏是否隐藏
718
+ * 菜单栏是否隐藏,设置为true, 则整个菜单栏不显示
723
719
  */
724
720
  hidden?: boolean;
725
721
  /**
726
- * 是否禁用菜单栏所有功能
722
+ * 是否禁用菜单栏所有功能。设置为true,菜单栏依旧显示,但所有菜单项为灰色不可点击
727
723
  */
728
724
  disabled?: boolean;
729
725
  /**
730
- * 菜单栏一级菜单配置
726
+ * 菜单栏一级菜单配置,指显示在菜单栏上的菜单项。
731
727
  */
732
728
  entries?: EditorMenuEntryConfig<TName>[];
733
729
  /**
734
730
  * 菜单栏功能按钮配置
731
+ * TODO 此配置目前没有用到,后续看是保留还是和custom合并
735
732
  */
736
- features?: Partial<EditorMenuFeatureButtonConfig<TName>>;
733
+ features?: Record<TName, EditorMenuFeatureConfig>;
737
734
  /**
738
735
  * 自定义按钮配置
739
736
  */
740
- custom?: EditorMenuCustomButton[];
737
+ custom?: (EditorMenuButtonMenuItemConfig<string> | EditorMenuLinkMenuItemConfig<string>)[];
741
738
  }
742
739
 
743
740
  /**
@@ -1100,43 +1097,15 @@ export declare interface EditorTextOptions<Color = string> {
1100
1097
  }
1101
1098
 
1102
1099
  /**
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
- * 工具栏自定义按钮配置
1122
- */
1123
- export declare interface EditorToolbarCustomButtonConfig {
1124
- /**
1125
- * 按钮配置
1126
- */
1127
- [key: string]: EditorToolbarCustomButton;
1128
- }
1129
-
1130
- /**
1131
- * 工具栏内置功能按钮配置
1100
+ * 工具栏功能按钮配置(包括内置按钮和自定义按钮)
1132
1101
  */
1133
- export declare interface EditorToolbarFeatureButton<ToolButtonName extends string = EditorToolbarFeatureButtonName> {
1102
+ export declare interface EditorToolbarFeatureButton<TName extends string> {
1134
1103
  /**
1135
- * 按钮类型
1104
+ * 按钮的唯一标识,用以确定配置的是哪个按钮。
1136
1105
  */
1137
- name: ToolButtonName;
1106
+ name: TName;
1138
1107
  /**
1139
- * 按钮标签(显示文本)
1108
+ * 按钮标签(显示文本)一般工具栏上的按钮不会显示文本,如果需要显示文本,配置此项。
1140
1109
  */
1141
1110
  label?: string;
1142
1111
  /**
@@ -1144,63 +1113,38 @@ export declare interface EditorToolbarFeatureButton<ToolButtonName extends strin
1144
1113
  */
1145
1114
  icon?: string;
1146
1115
  /**
1147
- * 按钮是否隐藏
1116
+ * 按钮是否隐藏,设置为true则隐藏按钮
1148
1117
  */
1149
1118
  hidden?: boolean;
1150
1119
  /**
1151
- * 按钮是否禁用
1120
+ * 按钮是否禁用,设置为true则变为灰色不可点击
1152
1121
  */
1153
1122
  disabled?: boolean;
1154
1123
  /**
1155
- * 按钮提示文本
1124
+ * 按钮点击事件.接受一个函数,可以自定义点击事件。
1125
+ */
1126
+ callback?: () => void;
1127
+ /**
1128
+ * 按钮提示文本,鼠标悬浮到按钮上时显示的tooltip文字
1156
1129
  */
1157
1130
  tooltip?: string;
1131
+ /**
1132
+ * 按钮在工具栏中位置,不设置则按照默认位置
1133
+ */
1134
+ index?: number;
1158
1135
  }
1159
1136
 
1160
1137
  /**
1161
1138
  * 工具栏内置功能按钮配置
1162
1139
  */
1163
- export declare type EditorToolbarFeatureButtonConfig<ToolButtonName extends string> = {
1164
- [key in ToolButtonName]?: EditorToolbarFeatureButton<ToolButtonName>;
1140
+ export declare type EditorToolbarFeatureButtonConfig<TName extends string> = {
1141
+ [key in TName]?: EditorToolbarFeatureButton<key>;
1165
1142
  };
1166
1143
 
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
1144
  /**
1201
1145
  * 工具栏相关设置,可以控制工具栏的显示内容
1202
1146
  */
1203
- export declare interface EditorToolbarOptions<ToolButtonName extends string = EditorToolbarFeatureButtonName> {
1147
+ export declare interface EditorToolbarOptions<TName extends string> {
1204
1148
  /**
1205
1149
  * 控制工具栏显隐状态
1206
1150
  */
@@ -1212,11 +1156,11 @@ export declare interface EditorToolbarOptions<ToolButtonName extends string = Ed
1212
1156
  /**
1213
1157
  * 现有按钮的功能配置
1214
1158
  */
1215
- features?: EditorToolbarFeatureButtonConfig<ToolButtonName>;
1159
+ features?: EditorToolbarFeatureButtonConfig<TName>;
1216
1160
  /**
1217
1161
  * 自定义按钮
1218
1162
  */
1219
- custom?: EditorToolbarCustomButtonConfig;
1163
+ custom?: EditorToolbarFeatureButtonConfig<string>;
1220
1164
  }
1221
1165
 
1222
1166
  export declare type EditorUploadableFile = EditorLocalUploadableFile;
@@ -1434,12 +1378,12 @@ export declare type PresentationMenuEntryConfig = EditorMenuEntryConfig<Presenta
1434
1378
  /**
1435
1379
  * 幻灯片工具栏功能按钮
1436
1380
  */
1437
- export declare type PresentationMenuFeatureButtonConfig = EditorMenuFeatureButtonConfig<PresentationMenuFeatureButtonName>;
1381
+ export declare type PresentationMenuFeatureButtonConfig = EditorMenuEntryConfig<PresentationMenuFeatureButtonName>;
1438
1382
 
1439
1383
  /**
1440
1384
  * 幻灯片工具栏内置功能按钮
1441
1385
  */
1442
- export declare type PresentationMenuFeatureButtonName = 'undo' | 'redo' | 'cut' | 'copy' | 'paste' | 'selectAll';
1386
+ export declare type PresentationMenuFeatureButtonName = 'edit' | 'insert' | 'format' | 'animation' | 'arrange' | 'design' | 'slide' | 'view' | 'slideshow' | 'review' | 'exportConverter';
1443
1387
 
1444
1388
  export declare type PresentationMenuOptions = EditorMenuOptions<PresentationMenuFeatureButtonName>;
1445
1389