124 lines
4.9 KiB
JavaScript
124 lines
4.9 KiB
JavaScript
(function () {
|
|
// 获取UEditor基础路径
|
|
var getUEBasePath = function (docObj) {
|
|
var baseElement = docObj.getElementsByTagName("script")[0];
|
|
var basePath = baseElement.src;
|
|
basePath = basePath.substring(0, basePath.lastIndexOf('/') + 1);
|
|
return basePath;
|
|
};
|
|
|
|
var URL = window.UEDITOR_HOME_URL || getUEBasePath(document.currentScript || document.scripts[document.scripts.length - 1]);
|
|
|
|
// 自定义UEditor配置
|
|
window.UEDITOR_CONFIG = {
|
|
// 基础路径配置
|
|
UEDITOR_HOME_URL: URL,
|
|
UEDITOR_CORS_URL: URL,
|
|
|
|
// 编辑器基本配置
|
|
initialFrameHeight: 500,
|
|
initialFrameWidth: '100%',
|
|
autoHeightEnabled: false,
|
|
catchRemoteImageEnable: false,
|
|
|
|
// 不从服务器加载配置
|
|
loadConfigFromServer: false,
|
|
|
|
// 文件上传配置
|
|
serverUrl: '/support/file/upload',
|
|
serverHeaders: {},
|
|
|
|
// 图片上传配置
|
|
imageActionName: 'uploadimage',
|
|
imageFieldName: 'file',
|
|
imageMaxSize: 2048000,
|
|
imageAllowFiles: ['.png', '.jpg', '.jpeg', '.gif', '.bmp'],
|
|
imageCompressEnable: true,
|
|
imageCompressBorder: 1600,
|
|
imageInsertAlign: 'none',
|
|
imageUrlPrefix: '',
|
|
|
|
// 视频上传配置
|
|
videoActionName: 'uploadvideo',
|
|
videoFieldName: 'file',
|
|
videoMaxSize: 102400000,
|
|
videoAllowFiles: ['.flv', '.swf', '.mkv', '.avi', '.rm', '.rmvb', '.mpeg', '.mpg', '.ogg', '.ogv', '.mov', '.wmv', '.mp4', '.webm', '.wav', '.mid'],
|
|
videoUrlPrefix: '',
|
|
|
|
// 附件上传配置
|
|
fileActionName: 'uploadfile',
|
|
fileFieldName: 'file',
|
|
fileMaxSize: 51200000,
|
|
fileAllowFiles: ['.png', '.jpg', '.jpeg', '.gif', '.bmp', '.flv', '.swf', '.mkv', '.avi', '.rm', '.rmvb', '.mpeg', '.mpg', '.ogg', '.ogv', '.mov', '.wmv', '.mp4', '.webm', '.wav', '.mid', '.rar', '.zip', '.tar', '.gz', '.7z', '.bz2', '.cab', '.iso', '.doc', '.docx', '.xls', '.xlsx', '.ppt', '.pptx', '.pdf', '.txt', '.md', '.xml'],
|
|
fileUrlPrefix: '',
|
|
|
|
// 完整的工具栏配置
|
|
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", "imagecenter", "imageright", "|",
|
|
"simpleupload", "insertimage", "emotion", "scrawl", "insertvideo", "insertaudio", "attachment", "insertframe", "insertcode", "pagebreak", "template", "background", "formula", "|",
|
|
"horizontal", "date", "time", "spechars", "wordimage", "|",
|
|
"inserttable", "deletetable", "insertparagraphbeforetable", "insertrow", "deleterow", "insertcol", "deletecol", "mergecells", "mergeright", "mergedown", "splittocells", "splittorows", "splittocols", "|",
|
|
"print", "preview", "searchreplace", "|",
|
|
"contentimport", "help"
|
|
]
|
|
],
|
|
|
|
// 编辑器功能配置
|
|
enableAutoSave: true,
|
|
autoSaveInterval: 60000,
|
|
enableContextMenu: true,
|
|
elementPathEnabled: true,
|
|
wordCount: true,
|
|
maximumWords: 10000,
|
|
maxUndoCount: 20,
|
|
maxInputCount: 1,
|
|
minFrameHeight: 220,
|
|
autoFloatEnabled: false,
|
|
topOffset: 0,
|
|
toolbarTopOffset: 0,
|
|
|
|
// 自动排版配置
|
|
autotypeset: {
|
|
mergeEmptyline: true,
|
|
removeClass: true,
|
|
removeEmptyline: false,
|
|
textAlign: 'left',
|
|
imageBlockLine: 'center',
|
|
pasteFilter: false,
|
|
clearFontSize: false,
|
|
clearFontFamily: false,
|
|
removeEmptyNode: true,
|
|
removeTagNames: {div: 1},
|
|
indent: true,
|
|
indentValue: '2em',
|
|
bdc2sb: false,
|
|
tobdc: false
|
|
},
|
|
|
|
// 其他配置
|
|
allowDivTransToP: true,
|
|
rgb2Hex: true,
|
|
debug: false,
|
|
|
|
// 错误处理
|
|
tipError: function (message, title) {
|
|
console.error('UEditor Error:', message);
|
|
}
|
|
};
|
|
|
|
// 设置全局UE对象
|
|
window.UE = {
|
|
getUEBasePath: getUEBasePath
|
|
};
|
|
})();
|