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