UNPKG

2.63 kBPlain TextView Raw
1/**
2 * @description 编辑器配置
3 * @author wangfupeng
4 */
5
6import menusConfig, { EmotionsType, FontSizeConfType, IndentationType } from './menus'
7import eventsConfig from './events'
8import styleConfig from './style'
9import pasteConfig from './paste'
10import cmdConfig from './cmd'
11import imageConfig, { UploadImageHooksType } from './image'
12import textConfig from './text'
13import langConfig from './lang'
14import historyConfig from './history'
15
16// 字典类型
17export type DicType = {
18 [key: string]: string
19}
20
21// 定义配置项的类型规范
22export type ConfigType = {
23 height: number
24 languageType: string[]
25 languageTab: string
26 menus: string[]
27 fontNames: string[]
28 lineHeights: string[]
29 indentation: IndentationType
30 fontSizes: FontSizeConfType
31 colors: string[]
32 emotions: EmotionsType[]
33 zIndex: number
34 onchange: Function
35 onfocus: Function
36 onblur: Function
37 onchangeTimeout: number
38 pasteFilterStyle: boolean
39 pasteIgnoreImg: boolean
40 pasteTextHandle: Function
41 styleWithCSS: boolean
42 linkImgCallback: Function
43
44 placeholder: string
45 zIndexFullScreen: number
46 showFullScreen: boolean
47 showLinkImg: boolean
48 uploadImgServer: string
49 uploadImgShowBase64: boolean
50 uploadImgMaxSize: number
51 uploadImgMaxLength: number
52 uploadFileName: string
53 uploadImgParams: DicType
54 uploadImgParamsWithUrl: boolean
55 uploadImgHeaders: DicType
56 uploadImgHooks: UploadImageHooksType
57 uploadImgTimeout: number
58 withCredentials: boolean
59 customUploadImg: Function | null
60 customAlert: Function | null
61
62 onCatalogChange: Function | null
63
64 lang: string
65 languages: typeof langConfig
66
67 linkCheck: Function
68 linkImgCheck: Function
69 compatibleMode: () => boolean
70 historyMaxSize: number
71
72 focus: boolean
73}
74
75export type Resource = {
76 [language: string]: ResourceLanguage
77}
78
79export type ResourceLanguage = {
80 [namespace: string]: ResourceKey
81}
82
83export type ResourceKey =
84 | string
85 | {
86 [key: string]: any
87 }
88
89// 合并所有的配置信息
90const defaultConfig = Object.assign(
91 {},
92 menusConfig,
93 eventsConfig,
94 styleConfig,
95 cmdConfig,
96 pasteConfig,
97 imageConfig,
98 textConfig,
99 langConfig,
100 historyConfig,
101 //链接校验的配置函数
102 {
103 linkCheck: function (text: string, link: string): string | boolean {
104 return true
105 },
106 },
107 //网络图片校验的配置函数
108 {
109 linkImgCheck: function (src: string): string | boolean {
110 return true
111 },
112 }
113)
114
115export default defaultConfig