懒羊羊
2023-08-30 1ac2bc1590406d9babec036e154d8d08f34a6aa1
提交 | 用户 | 时间
1ac2bc 1 /**
2  * ueditor完整配置项
3  * 可以在这里配置整个编辑器的特性
4  */
5 /**************************提示********************************
6  * 所有被注释的配置项均为UEditor默认值。
7  * 修改默认配置请首先确保已经完全明确该参数的真实用途。
8  * 主要有两种修改方案,一种是取消此处注释,然后修改成对应参数;另一种是在实例化编辑器时传入对应参数。
9  * 当升级编辑器时,可直接使用旧版配置文件替换新版配置文件,不用担心旧版配置文件中因缺少新功能所需的参数而导致脚本报错。
10  **************************提示********************************/
11
12 (function () {
13
14     /**
15      * 编辑器资源文件根路径。它所表示的含义是:以编辑器实例化页面为当前路径,指向编辑器资源文件(即dialog等文件夹)的路径。
16      * 鉴于很多同学在使用编辑器的时候出现的种种路径问题,此处强烈建议大家使用"相对于网站根目录的相对路径"进行配置。
17      * "相对于网站根目录的相对路径"也就是以斜杠开头的形如"/myProject/ueditor/"这样的路径。
18      * 如果站点中有多个不在同一层级的页面需要实例化编辑器,且引用了同一UEditor的时候,此处的URL可能不适用于每个页面的编辑器。
19      * 因此,UEditor提供了针对不同页面的编辑器可单独配置的根路径,具体来说,在需要实例化编辑器的页面最顶部写上如下代码即可。当然,需要令此处的URL等于对应的配置。
20      * window.UEDITOR_HOME_URL = "/xxxx/xxxx/";
21      */
22     var URL = window.UEDITOR_HOME_URL || getUEBasePath();
23
24     /**
25      * 配置项主体。注意,此处所有涉及到路径的配置别遗漏URL变量。
26      */
27     window.UEDITOR_CONFIG = {
28
29         UEDITOR_HOME_URL: URL
30         , serverUrl: Feng.ctxPath + "/ueditor/config"
31         //字体设置 label留空支持多语言自动切换,若配置,则以配置值为准
32         , 'fontfamily':
33             [
34                 {label: '', name: 'songti', val: '宋体,SimSun'},
35                 {label: '', name: 'kaiti', val: '楷体,楷体_GB2312, SimKai'},
36                 {label: '', name: 'yahei', val: '微软雅黑,Microsoft YaHei'},
37                 {label: '', name: 'heiti', val: '黑体, SimHei'},
38                 {label: '', name: 'lishu', val: '隶书, SimLi'},
39                 {label: '', name: 'andaleMono', val: 'andale mono'},
40                 {label: '', name: 'arial', val: 'arial, helvetica,sans-serif'},
41                 {label: '', name: 'arialBlack', val: 'arial black,avant garde'},
42                 {label: '', name: 'comicSansMs', val: 'comic sans ms'},
43                 {label: '', name: 'impact', val: 'impact,chicago'},
44                 {label: '', name: 'timesNewRoman', val: 'times new roman'}
45             ]
46         , toolbars: [[
47             'fullscreen', 'source', '|', 'undo', 'redo', '|',
48             'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
49             'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
50             'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
51             'directionalityltr', 'directionalityrtl', 'indent', '|',
52             'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
53             'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
54             'simpleupload', 'insertimage', 'emotion', 'scrawl', 'insertvideo', 'music', 'attachment', 'map', 'gmap', 'insertframe', 'insertcode', 'webapp', 'pagebreak', 'template', 'background', '|',
55             'horizontal', 'date', 'time', 'spechars', 'snapscreen', 'wordimage', '|',
56             'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
57             'print', 'preview', 'searchreplace', 'drafts', 'help'
58         ]]
59         , xssFilterRules: true
60         , inputXssFilter: true
61         , outputXssFilter: true
62         , whitList: {
63             a: ['target', 'href', 'title', 'class', 'style'],
64             abbr: ['title', 'class', 'style'],
65             address: ['class', 'style'],
66             area: ['shape', 'coords', 'href', 'alt'],
67             article: [],
68             aside: [],
69             audio: ['autoplay', 'controls', 'loop', 'preload', 'src', 'class', 'style'],
70             b: ['class', 'style'],
71             bdi: ['dir'],
72             bdo: ['dir'],
73             big: [],
74             blockquote: ['cite', 'class', 'style'],
75             br: [],
76             caption: ['class', 'style'],
77             center: [],
78             cite: [],
79             code: ['class', 'style'],
80             col: ['align', 'valign', 'span', 'width', 'class', 'style'],
81             colgroup: ['align', 'valign', 'span', 'width', 'class', 'style'],
82             dd: ['class', 'style'],
83             del: ['datetime'],
84             details: ['open'],
85             div: ['class', 'style'],
86             dl: ['class', 'style'],
87             dt: ['class', 'style'],
88             em: ['class', 'style'],
89             font: ['color', 'size', 'face'],
90             footer: [],
91             h1: ['class', 'style'],
92             h2: ['class', 'style'],
93             h3: ['class', 'style'],
94             h4: ['class', 'style'],
95             h5: ['class', 'style'],
96             h6: ['class', 'style'],
97             header: [],
98             hr: [],
99             i: ['class', 'style'],
100             img: ['src', 'alt', 'title', 'width', 'height', 'id', '_src', 'loadingclass', 'class', 'data-latex', 'style'],
101             ins: ['datetime'],
102             li: ['class', 'style'],
103             mark: [],
104             nav: [],
105             ol: ['class', 'style'],
106             p: ['class', 'style', 'data-background'],
107             pre: ['class', 'style'],
108             s: [],
109             section: [],
110             small: [],
111             span: ['class', 'style'],
112             sub: ['class', 'style'],
113             sup: ['class', 'style'],
114             strong: ['class', 'style'],
115             table: ['width', 'border', 'align', 'valign', 'class', 'style', 'cellpadding', 'cellspacing'],
116             tbody: ['align', 'valign', 'class', 'style'],
117             td: ['width', 'rowspan', 'colspan', 'align', 'valign', 'class', 'style'],
118             tfoot: ['align', 'valign', 'class', 'style'],
119             th: ['width', 'rowspan', 'colspan', 'align', 'valign', 'class', 'style'],
120             thead: ['align', 'valign', 'class', 'style'],
121             tr: ['rowspan', 'align', 'valign', 'class', 'style'],
122             tt: [],
123             u: [],
124             ul: ['class', 'style'],
125             video: ['autoplay', 'controls', 'loop', 'preload', 'src', 'height', 'width', 'class', 'style'],
126             source: ['src', 'type'],
127             embed: ['type', 'class', 'pluginspage', 'src', 'width', 'height', 'align', 'style', 'wmode', 'play', 'autoplay', 'loop', 'menu', 'allowscriptaccess', 'allowfullscreen', 'controls', 'preload'],
128             iframe: ['src', 'class', 'height', 'width', 'max-width', 'max-height', 'align', 'frameborder', 'allowfullscreen']
129         }
130     };
131
132     function getUEBasePath(docUrl, confUrl) {
133
134         return getBasePath(docUrl || self.document.URL || self.location.href, confUrl || getConfigFilePath());
135
136     }
137
138     function getConfigFilePath() {
139
140         var configPath = document.getElementsByTagName('script');
141
142         return configPath[configPath.length - 1].src;
143
144     }
145
146     function getBasePath(docUrl, confUrl) {
147
148         var basePath = confUrl;
149
150
151         if (/^(\/|\\\\)/.test(confUrl)) {
152
153             basePath = /^.+?\w(\/|\\\\)/.exec(docUrl)[0] + confUrl.replace(/^(\/|\\\\)/, '');
154
155         } else if (!/^[a-z]+:/i.test(confUrl)) {
156
157             docUrl = docUrl.split("#")[0].split("?")[0].replace(/[^\\\/]+$/, '');
158
159             basePath = docUrl + "" + confUrl;
160
161         }
162
163         return optimizationPath(basePath);
164
165     }
166
167     function optimizationPath(path) {
168
169         var protocol = /^[a-z]+:\/\//.exec(path)[0],
170             tmp = null,
171             res = [];
172
173         path = path.replace(protocol, "").split("?")[0].split("#")[0];
174
175         path = path.replace(/\\/g, '/').split(/\//);
176
177         path[path.length - 1] = "";
178
179         while (path.length) {
180
181             if ((tmp = path.shift()) === "..") {
182                 res.pop();
183             } else if (tmp !== ".") {
184                 res.push(tmp);
185             }
186
187         }
188
189         return protocol + res.join("/");
190
191     }
192
193     window.UE = {
194         getUEBasePath: getUEBasePath
195     };
196
197 })();