forked from tlzzu/SoDiaoEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sde.config.js
245 lines (227 loc) · 6.83 KB
/
sde.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
/*
默认配置项
*/
(function() {
/**
* 编辑器资源文件根路径。它所表示的含义是:以编辑器实例化页面为当前路径,指向编辑器资源文件(即dialog等文件夹)的路径。
* 鉴于很多同学在使用编辑器的时候出现的种种路径问题,此处强烈建议大家使用"相对于网站根目录的相对路径"进行配置。
* "相对于网站根目录的相对路径"也就是以斜杠开头的形如"/myProject/ueditor/"这样的路径。
* 如果站点中有多个不在同一层级的页面需要实例化编辑器,且引用了同一UEditor的时候,此处的URL可能不适用于每个页面的编辑器。
* 因此,UEditor提供了针对不同页面的编辑器可单独配置的根路径,具体来说,在需要实例化编辑器的页面最顶部写上如下代码即可。当然,需要令此处的URL等于对应的配置。
* window.UEDITOR_HOME_URL = "/xxxx/xxxx/"
*/
var URL = window.UEDITOR_HOME_URL || getUEBasePath();
// if (URL.endsWith('static/js/')) {
// URL = URL.replace('static/js/', 'static/sdeEditor/');
// } else {
// URL = URL + 'static/sdeEditor/';
// }
/*
SDE_CONFIG 配置项
*/
window.SDE_CONFIG = {
HOME_URL: URL,
HOME_URL_DIALOGS: URL + 'dialogs/',
EDITOR_URL: URL + 'js/sde-ie8-editor.js',
PAGE_CONFIG: [{//打印纸张定义
name: 'A3',
width: 1123,
height: 1588,
top: 72,
right: 72,
bottom: 72,
left: 72
}, {
name: 'A4',
width: 794,
height: 1123,
top: 72,
right: 72,
bottom: 72,
left: 72
}, {
name: 'A5',
width: 561.5,
height: 794,
top: 72,
right: 72,
bottom: 72,
left: 72
}],
IE8_SCRIPT: [
'/js/modernizr/2.8.3/modernizr.min.js',
'/js/html5shiv/3.7.3/html5shiv.min.js',
'/js/es5-shim/4.5.9/es5-shim.min.js',
], //让ie8中的iframe兼容脚本
};
/**
* 配置项主体。注意,此处所有涉及到路径的配置别遗漏URL变量。
*/
window.UEDITOR_CONFIG = {
UEDITOR_HOME_URL: URL + 'ueditor/', // 为编辑器实例添加一个路径,这个不能被注释
serverUrl: URL + 'data/config.json', // URL + "net/controller.ashx", // 服务器统一请求接口路径
toolbars: [], // 工具栏上的所有的功能按钮和下拉框,可以在new编辑器的实例时选择自己需要的重新定义
autoClearinitialContent: false, // 是否自动清除编辑器初始内容,注意:如果focus属性设置为true,这个也为真,那么编辑器一上来就会触发导致初始化的内容看不到了
// iframeJsUrl: URL + window.SDE_CONFIG.EDITOR_URL + '?temp=' + new Date().getTime(), //给编辑区域的iframe引入一个js文件
// iframeCssUrl: URL + 'EMR/css/default.css?temp=' + new Date().getTime(), //给编辑区域的iframe引入一个css文件
allowDivTransToP: false, // 允许进入编辑器的div标签自动变成p标签
wordCount: false, // 关闭字数统计
elementPathEnabled: false, // 关闭elementPath
imageScaleEnabled: true,
imagePopup: true,
focus: true,
autoHeightEnabled: true,
enableAutoSave: false, // 关闭自动保存
// toolbars: [
// ["message"]
// ]
// toolbars: [
// [
// "fullscreen",
// "source",
// "|",
// "undo",
// "redo",
// "|",
// "bold",
// "italic",
// "underline",
// "fontborder",
// "strikethrough",
// "superscript",
// "subscript",
// "removeformat",
// "formatmatch",
// "autotypeset",
// "blockquote",
// "pasteplain",
// "|",
// "forecolor",
// "backcolor",
// "insertorderedlist",
// "insertunorderedlist",
// "selectall",
// "cleardoc",
// "|",
// "rowspacingtop",
// "rowspacingbottom",
// "lineheight",
// "|",
// "customstyle",
// "paragraph",
// "fontfamily",
// "fontsize",
// "|",
// "directionalityltr",
// "directionalityrtl",
// "indent",
// "|",
// "justifyleft",
// "justifycenter",
// "justifyright",
// "justifyjustify",
// "|",
// "touppercase",
// "tolowercase",
// "|",
// "link",
// "unlink",
// "anchor",
// "|",
// "imagenone",
// "imageleft",
// "imageright",
// "imagecenter",
// "|",
// "simpleupload",
// "insertimage",
// "emotion",
// "scrawl",
// "insertvideo",
// "music",
// "attachment",
// "map",
// "gmap",
// "insertframe",
// "insertcode",
// "webapp",
// "pagebreak",
// "template",
// "background",
// "|",
// "horizontal",
// "date",
// "time",
// "spechars",
// "snapscreen",
// "wordimage",
// "|",
// "inserttable",
// "deletetable",
// "insertparagraphbeforetable",
// "insertrow",
// "deleterow",
// "insertcol",
// "deletecol",
// "mergecells",
// "mergeright",
// "mergedown",
// "splittocells",
// "splittorows",
// "splittocols",
// "charts",
// "|",
// "print",
// "preview",
// "searchreplace",
// "drafts",
// "help"
// ]
// ]
};
function getUEBasePath(docUrl, confUrl) {
return getBasePath(
docUrl || self.document.URL || self.location.href,
confUrl || getConfigFilePath()
);
}
function getConfigFilePath() {
var configPath = document.getElementsByTagName('script');
return configPath[configPath.length - 1].src;
}
function getBasePath(docUrl, confUrl) {
var basePath = confUrl;
if (/^(\/|\\\\)/.test(confUrl)) {
basePath = /^.+?\w(\/|\\\\)/.exec(docUrl)[0] + confUrl.replace(/^(\/|\\\\)/, '');
} else if (!/^[a-z]+:/i.test(confUrl)) {
docUrl = docUrl
.split('#')[0]
.split('?')[0]
.replace(/[^\\\/]+$/, '');
basePath = docUrl + '' + confUrl;
}
return optimizationPath(basePath);
}
function optimizationPath(path) {
var protocol = /^[a-z]+:\/\//.exec(path)[0],
tmp = null,
res = [];
path = path
.replace(protocol, '')
.split('?')[0]
.split('#')[0];
path = path.replace(/\\/g, '/').split(/\//);
path[path.length - 1] = '';
while (path.length) {
if ((tmp = path.shift()) === '..') {
res.pop();
} else if (tmp !== '.') {
res.push(tmp);
}
}
return protocol + res.join('/');
}
window.UE = {
getUEBasePath: getUEBasePath,
};
})();