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