ueditor.config.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. /**
  2. * ueditor完整配置项
  3. * 可以在这里配置整个编辑器的特性
  4. */
  5. /**************************提示********************************
  6. * 所有被注释的配置项均为UEditor默认值。
  7. * 修改默认配置请首先确保已经完全明确该参数的真实用途。
  8. * 主要有两种修改方案,一种是取消此处注释,然后修改成对应参数;另一种是在实例化编辑器时传入对应参数。
  9. * 当升级编辑器时,可直接使用旧版配置文件替换新版配置文件,不用担心旧版配置文件中因缺少新功能所需的参数而导致脚本报错。
  10. **************************提示********************************/
  11. // import json from './jsp/config.json'
  12. // const json = require('./jsp/config.json')
  13. ;(function () {
  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. * 配置项主体。注意,此处所有涉及到路径的配置别遗漏URL变量。
  25. */
  26. window.UEDITOR_CONFIG = {
  27. //为编辑器实例添加一个路径,这个不能被注释
  28. UEDITOR_HOME_URL: URL,
  29. // 服务器统一请求接口路径
  30. serverUrl: URL + 'jsp/controller.jsp',
  31. //工具栏上的所有的功能按钮和下拉框,可以在new编辑器的实例时选择自己需要的重新定义
  32. toolbars: [
  33. [
  34. 'fullscreen',
  35. 'source',
  36. '|',
  37. 'undo',
  38. 'redo',
  39. '|',
  40. 'bold',
  41. 'italic',
  42. 'underline',
  43. 'fontborder',
  44. 'strikethrough',
  45. 'superscript',
  46. 'subscript',
  47. 'removeformat',
  48. 'formatmatch',
  49. 'autotypeset',
  50. 'blockquote',
  51. 'pasteplain',
  52. '|',
  53. 'forecolor',
  54. 'backcolor',
  55. 'insertorderedlist',
  56. 'insertunorderedlist',
  57. 'selectall',
  58. 'cleardoc',
  59. '|',
  60. 'rowspacingtop',
  61. 'rowspacingbottom',
  62. 'lineheight',
  63. '|',
  64. 'customstyle',
  65. 'paragraph',
  66. 'fontfamily',
  67. 'fontsize',
  68. '|',
  69. ,
  70. // 'simpleupload',
  71. // 'insertimage',
  72. // 'insertvideo',
  73. 'imagenone',
  74. 'imageleft',
  75. 'imageright',
  76. 'imagecenter',
  77. '|',
  78. 'justifyleft',
  79. 'justifycenter',
  80. 'justifyright',
  81. 'justifyjustify',
  82. '|',
  83. 'touppercase',
  84. 'tolowercase',
  85. '|',
  86. 'link',
  87. 'unlink',
  88. 'anchor',
  89. '|',
  90. ,
  91. 'horizontal',
  92. 'date',
  93. 'time',
  94. 'spechars',
  95. 'snapscreen',
  96. 'wordimage',
  97. '|',
  98. 'inserttable',
  99. 'deletetable'
  100. // '|',
  101. // 'print',
  102. // 'searchreplace'
  103. // 'preview'
  104. ]
  105. ],
  106. //当鼠标放在工具栏上时显示的tooltip提示,留空支持自动多语言配置,否则以配置值为准
  107. //,labelMap:{
  108. // 'anchor':'', 'undo':''
  109. //}
  110. //语言配置项,默认是zh-cn。有需要的话也可以使用如下这样的方式来自动多语言切换,当然,前提条件是lang文件夹下存在对应的语言文件:
  111. //lang值也可以通过自动获取 (navigator.language||navigator.browserLanguage ||navigator.userLanguage).toLowerCase()
  112. //,lang:"zh-cn"
  113. //,langPath:URL +"lang/"
  114. //主题配置项,默认是default。有需要的话也可以使用如下这样的方式来自动多主题切换,当然,前提条件是themes文件夹下存在对应的主题文件:
  115. //现有如下皮肤:default
  116. //,theme:'default'
  117. //,themePath:URL +"themes/"
  118. //,zIndex : 900 //编辑器层级的基数,默认是900
  119. //针对getAllHtml方法,会在对应的head标签中增加该编码设置。
  120. //,charset:"utf-8"
  121. //若实例化编辑器的页面手动修改的domain,此处需要设置为true
  122. //,customDomain:false
  123. //常用配置项目
  124. //,isShow : true //默认显示编辑器
  125. //,textarea:'editorValue' // 提交表单时,服务器获取编辑器提交内容的所用的参数,多实例时可以给容器name属性,会将name给定的值最为每个实例的键值,不用每次实例化的时候都设置这个值
  126. //,initialContent:'欢迎使用ueditor!' //初始化编辑器的内容,也可以通过textarea/script给值,看官网例子
  127. //,autoClearinitialContent:true //是否自动清除编辑器初始内容,注意:如果focus属性设置为true,这个也为真,那么编辑器一上来就会触发导致初始化的内容看不到了
  128. //,focus:false //初始化时,是否让编辑器获得焦点true或false
  129. //如果自定义,最好给p标签如下的行高,要不输入中文时,会有跳动感
  130. //,initialStyle:'p{line-height:1em}'//编辑器层级的基数,可以用来改变字体等
  131. //,iframeCssUrl: URL + '/themes/iframe.css' //给编辑区域的iframe引入一个css文件
  132. //indentValue
  133. //首行缩进距离,默认是2em
  134. //,indentValue:'2em'
  135. //,initialFrameWidth:1000 //初始化编辑器宽度,默认1000
  136. //,initialFrameHeight:320 //初始化编辑器高度,默认320
  137. //,readonly : false //编辑器初始化结束后,编辑区域是否是只读的,默认是false
  138. //,autoClearEmptyNode : true //getContent时,是否删除空的inlineElement节点(包括嵌套的情况)
  139. //启用自动保存
  140. //,enableAutoSave: true
  141. //自动保存间隔时间, 单位ms
  142. //,saveInterval: 500
  143. //,fullscreen : false //是否开启初始化时即全屏,默认关闭
  144. //,imagePopup:true //图片操作的浮层开关,默认打开
  145. //,autoSyncData:true //自动同步编辑器要提交的数据
  146. //,emotionLocalization:false //是否开启表情本地化,默认关闭。若要开启请确保emotion文件夹下包含官网提供的images表情文件夹
  147. //粘贴只保留标签,去除标签所有属性
  148. //,retainOnlyLabelPasted: false
  149. //,pasteplain:false //是否默认为纯文本粘贴。false为不使用纯文本粘贴,true为使用纯文本粘贴
  150. //纯文本粘贴模式下的过滤规则
  151. //'filterTxtRules' : function(){
  152. // function transP(node){
  153. // node.tagName = 'p';
  154. // node.setStyle();
  155. // }
  156. // return {
  157. // //直接删除及其字节点内容
  158. // '-' : 'script style object iframe embed input select',
  159. // 'p': {$:{}},
  160. // 'br':{$:{}},
  161. // 'div':{'$':{}},
  162. // 'li':{'$':{}},
  163. // 'caption':transP,
  164. // 'th':transP,
  165. // 'tr':transP,
  166. // 'h1':transP,'h2':transP,'h3':transP,'h4':transP,'h5':transP,'h6':transP,
  167. // 'td':function(node){
  168. // //没有内容的td直接删掉
  169. // var txt = !!node.innerText();
  170. // if(txt){
  171. // node.parentNode.insertAfter(UE.uNode.createText('    '),node);
  172. // }
  173. // node.parentNode.removeChild(node,node.innerText())
  174. // }
  175. // }
  176. //}()
  177. //,allHtmlEnabled:false //提交到后台的数据是否包含整个html字符串
  178. //insertorderedlist
  179. //有序列表的下拉配置,值留空时支持多语言自动识别,若配置值,则以此值为准
  180. //,'insertorderedlist':{
  181. // //自定的样式
  182. // 'num':'1,2,3...',
  183. // 'num1':'1),2),3)...',
  184. // 'num2':'(1),(2),(3)...',
  185. // 'cn':'一,二,三....',
  186. // 'cn1':'一),二),三)....',
  187. // 'cn2':'(一),(二),(三)....',
  188. // //系统自带
  189. // 'decimal' : '' , //'1,2,3...'
  190. // 'lower-alpha' : '' , // 'a,b,c...'
  191. // 'lower-roman' : '' , //'i,ii,iii...'
  192. // 'upper-alpha' : '' , lang //'A,B,C'
  193. // 'upper-roman' : '' //'I,II,III...'
  194. //}
  195. //insertunorderedlist
  196. //无序列表的下拉配置,值留空时支持多语言自动识别,若配置值,则以此值为准
  197. //,insertunorderedlist : { //自定的样式
  198. // 'dash' :'— 破折号', //-破折号
  199. // 'dot':' 。 小圆圈', //系统自带
  200. // 'circle' : '', // '○ 小圆圈'
  201. // 'disc' : '', // '● 小圆点'
  202. // 'square' : '' //'■ 小方块'
  203. //}
  204. //,listDefaultPaddingLeft : '30'//默认的左边缩进的基数倍
  205. //,listiconpath : 'http://bs.baidu.com/listicon/'//自定义标号的路径
  206. //,maxListLevel : 3 //限制可以tab的级数, 设置-1为不限制
  207. //,autoTransWordToList:false //禁止word中粘贴进来的列表自动变成列表标签
  208. //fontfamily
  209. //字体设置 label留空支持多语言自动切换,若配置,则以配置值为准
  210. //,'fontfamily':[
  211. // { label:'',name:'songti',val:'宋体,SimSun'},
  212. // { label:'',name:'kaiti',val:'楷体,楷体_GB2312, SimKai'},
  213. // { label:'',name:'yahei',val:'微软雅黑,Microsoft YaHei'},
  214. // { label:'',name:'heiti',val:'黑体, SimHei'},
  215. // { label:'',name:'lishu',val:'隶书, SimLi'},
  216. // { label:'',name:'andaleMono',val:'andale mono'},
  217. // { label:'',name:'arial',val:'arial, helvetica,sans-serif'},
  218. // { label:'',name:'arialBlack',val:'arial black,avant garde'},
  219. // { label:'',name:'comicSansMs',val:'comic sans ms'},
  220. // { label:'',name:'impact',val:'impact,chicago'},
  221. // { label:'',name:'timesNewRoman',val:'times new roman'}
  222. //]
  223. //fontsize
  224. //字号
  225. //,'fontsize':[10, 11, 12, 14, 16, 18, 20, 24, 36]
  226. //paragraph
  227. //段落格式 值留空时支持多语言自动识别,若配置,则以配置值为准
  228. //,'paragraph':{'p':'', 'h1':'', 'h2':'', 'h3':'', 'h4':'', 'h5':'', 'h6':''}
  229. //rowspacingtop
  230. //段间距 值和显示的名字相同
  231. //,'rowspacingtop':['5', '10', '15', '20', '25']
  232. //rowspacingBottom
  233. //段间距 值和显示的名字相同
  234. //,'rowspacingbottom':['5', '10', '15', '20', '25']
  235. //lineheight
  236. //行内间距 值和显示的名字相同
  237. //,'lineheight':['1', '1.5','1.75','2', '3', '4', '5']
  238. //customstyle
  239. //自定义样式,不支持国际化,此处配置值即可最后显示值
  240. //block的元素是依据设置段落的逻辑设置的,inline的元素依据BIU的逻辑设置
  241. //尽量使用一些常用的标签
  242. //参数说明
  243. //tag 使用的标签名字
  244. //label 显示的名字也是用来标识不同类型的标识符,注意这个值每个要不同,
  245. //style 添加的样式
  246. //每一个对象就是一个自定义的样式
  247. //,'customstyle':[
  248. // {tag:'h1', name:'tc', label:'', style:'border-bottom:#ccc 2px solid;padding:0 4px 0 0;text-align:center;margin:0 0 20px 0;'},
  249. // {tag:'h1', name:'tl',label:'', style:'border-bottom:#ccc 2px solid;padding:0 4px 0 0;margin:0 0 10px 0;'},
  250. // {tag:'span',name:'im', label:'', style:'font-style:italic;font-weight:bold'},
  251. // {tag:'span',name:'hi', label:'', style:'font-style:italic;font-weight:bold;color:rgb(51, 153, 204)'}
  252. //]
  253. //打开右键菜单功能
  254. //,enableContextMenu: true
  255. //右键菜单的内容,可以参考plugins/contextmenu.js里边的默认菜单的例子,label留空支持国际化,否则以此配置为准
  256. //,contextMenu:[
  257. // {
  258. // label:'', //显示的名称
  259. // cmdName:'selectall',//执行的command命令,当点击这个右键菜单时
  260. // //exec可选,有了exec就会在点击时执行这个function,优先级高于cmdName
  261. // exec:function () {
  262. // //this是当前编辑器的实例
  263. // //this.ui._dialogs['inserttableDialog'].open();
  264. // }
  265. // }
  266. //]
  267. //快捷菜单
  268. //,shortcutMenu:["fontfamily", "fontsize", "bold", "italic", "underline", "forecolor", "backcolor", "insertorderedlist", "insertunorderedlist"]
  269. //elementPathEnabled
  270. //是否启用元素路径,默认是显示
  271. elementPathEnabled: false,
  272. //wordCount
  273. wordCount: false, //是否开启字数统计
  274. //,maximumWords:10000 //允许的最大字符数
  275. //字数统计提示,{#count}代表当前字数,{#leave}代表还可以输入多少字符数,留空支持多语言自动切换,否则按此配置显示
  276. //,wordCountMsg:'' //当前已输入 {#count} 个字符,您还可以输入{#leave} 个字符
  277. //超出字数限制提示 留空支持多语言自动切换,否则按此配置显示
  278. //,wordOverFlowMsg:'' //<span style="color:red;">你输入的字符个数已经超出最大允许值,服务器可能会拒绝保存!</span>
  279. //tab
  280. //点击tab键时移动的距离,tabSize倍数,tabNode什么字符做为单位
  281. //,tabSize:4
  282. //,tabNode:'&nbsp;'
  283. //removeFormat
  284. //清除格式时可以删除的标签和属性
  285. //removeForamtTags标签
  286. //,removeFormatTags:'b,big,code,del,dfn,em,font,i,ins,kbd,q,samp,small,span,strike,strong,sub,sup,tt,u,var'
  287. //removeFormatAttributes属性
  288. //,removeFormatAttributes:'class,style,lang,width,height,align,hspace,valign'
  289. //undo
  290. //可以最多回退的次数,默认20
  291. //,maxUndoCount:20
  292. //当输入的字符数超过该值时,保存一次现场
  293. //,maxInputCount:1
  294. //autoHeightEnabled
  295. // 是否自动长高,默认true
  296. //,autoHeightEnabled:true
  297. //scaleEnabled
  298. //是否可以拉伸长高,默认true(当开启时,自动长高失效)
  299. scaleEnabled: false,
  300. //,minFrameWidth:800 //编辑器拖动时最小宽度,默认800
  301. //,minFrameHeight:220 //编辑器拖动时最小高度,默认220
  302. //autoFloatEnabled
  303. //是否保持toolbar的位置不动,默认true
  304. //,autoFloatEnabled:true
  305. //浮动时工具栏距离浏览器顶部的高度,用于某些具有固定头部的页面
  306. //,topOffset:30
  307. //编辑器底部距离工具栏高度(如果参数大于等于编辑器高度,则设置无效)
  308. //,toolbarTopOffset:400
  309. //设置远程图片是否抓取到本地保存
  310. //,catchRemoteImageEnable: true //设置是否抓取远程图片
  311. //pageBreakTag
  312. //分页标识符,默认是_ueditor_page_break_tag_
  313. //,pageBreakTag:'_ueditor_page_break_tag_'
  314. //autotypeset
  315. //自动排版参数
  316. //,autotypeset: {
  317. // mergeEmptyline: true, //合并空行
  318. // removeClass: true, //去掉冗余的class
  319. // removeEmptyline: false, //去掉空行
  320. // textAlign:"left", //段落的排版方式,可以是 left,right,center,justify 去掉这个属性表示不执行排版
  321. // imageBlockLine: 'center', //图片的浮动方式,独占一行剧中,左右浮动,默认: center,left,right,none 去掉这个属性表示不执行排版
  322. // pasteFilter: false, //根据规则过滤没事粘贴进来的内容
  323. // clearFontSize: false, //去掉所有的内嵌字号,使用编辑器默认的字号
  324. // clearFontFamily: false, //去掉所有的内嵌字体,使用编辑器默认的字体
  325. // removeEmptyNode: false, // 去掉空节点
  326. // //可以去掉的标签
  327. // removeTagNames: {标签名字:1},
  328. // indent: false, // 行首缩进
  329. // indentValue : '2em', //行首缩进的大小
  330. // bdc2sb: false,
  331. // tobdc: false
  332. //}
  333. //tableDragable
  334. //表格是否可以拖拽
  335. //,tableDragable: true
  336. //sourceEditor
  337. //源码的查看方式,codemirror 是代码高亮,textarea是文本框,默认是codemirror
  338. //注意默认codemirror只能在ie8+和非ie中使用
  339. //,sourceEditor:"codemirror"
  340. //如果sourceEditor是codemirror,还用配置一下两个参数
  341. //codeMirrorJsUrl js加载的路径,默认是 URL + "third-party/codemirror/codemirror.js"
  342. //,codeMirrorJsUrl:URL + "third-party/codemirror/codemirror.js"
  343. //codeMirrorCssUrl css加载的路径,默认是 URL + "third-party/codemirror/codemirror.css"
  344. //,codeMirrorCssUrl:URL + "third-party/codemirror/codemirror.css"
  345. //编辑器初始化完成后是否进入源码模式,默认为否。
  346. //,sourceEditorFirst:false
  347. //iframeUrlMap
  348. //dialog内容的路径 ~会被替换成URL,垓属性一旦打开,将覆盖所有的dialog的默认路径
  349. //,iframeUrlMap:{
  350. // 'anchor':'~/dialogs/anchor/anchor.html',
  351. //}
  352. //allowLinkProtocol 允许的链接地址,有这些前缀的链接地址不会自动添加http
  353. //, allowLinkProtocols: ['http:', 'https:', '#', '/', 'ftp:', 'mailto:', 'tel:', 'git:', 'svn:']
  354. //webAppKey 百度应用的APIkey,每个站长必须首先去百度官网注册一个key后方能正常使用app功能,注册介绍,http://app.baidu.com/static/cms/getapikey.html
  355. //, webAppKey: ""
  356. //默认过滤规则相关配置项目
  357. //,disabledTableInTable:true //禁止表格嵌套
  358. //,allowDivTransToP:true //允许进入编辑器的div标签自动变成p标签
  359. //,rgb2Hex:true //默认产出的数据中的color自动从rgb格式变成16进制格式
  360. // xss 过滤是否开启,inserthtml等操作
  361. xssFilterRules: true,
  362. //input xss过滤
  363. inputXssFilter: true,
  364. //output xss过滤
  365. outputXssFilter: true,
  366. // xss过滤白名单 名单来源: https://raw.githubusercontent.com/leizongmin/js-xss/master/lib/default.js
  367. whiteList: {
  368. a: ['target', 'href', 'title', 'class', 'style'],
  369. abbr: ['title', 'class', 'style'],
  370. address: ['class', 'style'],
  371. area: ['shape', 'coords', 'href', 'alt'],
  372. article: [],
  373. aside: [],
  374. audio: ['autoplay', 'controls', 'loop', 'preload', 'src', 'class', 'style'],
  375. b: ['class', 'style'],
  376. bdi: ['dir'],
  377. bdo: ['dir'],
  378. big: [],
  379. blockquote: ['cite', 'class', 'style'],
  380. br: [],
  381. caption: ['class', 'style'],
  382. center: [],
  383. cite: [],
  384. code: ['class', 'style'],
  385. col: ['align', 'valign', 'span', 'width', 'class', 'style'],
  386. colgroup: ['align', 'valign', 'span', 'width', 'class', 'style'],
  387. dd: ['class', 'style'],
  388. del: ['datetime'],
  389. details: ['open'],
  390. div: ['class', 'style'],
  391. dl: ['class', 'style'],
  392. dt: ['class', 'style'],
  393. em: ['class', 'style'],
  394. font: ['color', 'size', 'face'],
  395. footer: [],
  396. h1: ['class', 'style'],
  397. h2: ['class', 'style'],
  398. h3: ['class', 'style'],
  399. h4: ['class', 'style'],
  400. h5: ['class', 'style'],
  401. h6: ['class', 'style'],
  402. header: [],
  403. hr: [],
  404. i: ['class', 'style'],
  405. img: [
  406. 'src',
  407. 'alt',
  408. 'title',
  409. 'width',
  410. 'height',
  411. 'id',
  412. '_src',
  413. 'loadingclass',
  414. 'class',
  415. 'data-latex'
  416. ],
  417. ins: ['datetime'],
  418. li: ['class', 'style'],
  419. mark: [],
  420. nav: [],
  421. ol: ['class', 'style'],
  422. p: ['class', 'style'],
  423. pre: ['class', 'style'],
  424. s: [],
  425. section: [],
  426. small: [],
  427. span: ['class', 'style'],
  428. sub: ['class', 'style'],
  429. sup: ['class', 'style'],
  430. strong: ['class', 'style'],
  431. table: ['width', 'border', 'align', 'valign', 'class', 'style'],
  432. tbody: ['align', 'valign', 'class', 'style'],
  433. td: ['width', 'rowspan', 'colspan', 'align', 'valign', 'class', 'style'],
  434. tfoot: ['align', 'valign', 'class', 'style'],
  435. th: ['width', 'rowspan', 'colspan', 'align', 'valign', 'class', 'style'],
  436. thead: ['align', 'valign', 'class', 'style'],
  437. tr: ['rowspan', 'align', 'valign', 'class', 'style'],
  438. tt: [],
  439. u: [],
  440. ul: ['class', 'style'],
  441. video: ['autoplay', 'controls', 'loop', 'preload', 'src', 'height', 'width', 'class', 'style']
  442. },
  443. imageActionName: 'uploadimage' /* 执行上传图片的action名称 */,
  444. imageFieldName: 'file' /* 提交的图片表单名称 */,
  445. imageMaxSize: 2048000 /* 上传大小限制,单位B */,
  446. imageAllowFiles: ['.png', '.jpg', '.jpeg', '.gif', '.bmp'] /* 上传图片格式显示 */,
  447. imageCompressEnable: true /* 是否压缩图片,默认是true */,
  448. imageCompressBorder: 1600 /* 图片压缩最长边限制 */,
  449. imageInsertAlign: 'none' /* 插入的图片浮动方式 */,
  450. imageUrlPrefix: '' /* 图片访问路径前缀 */,
  451. imagePathFormat:
  452. '/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}' /* 上传保存路径,可以自定义保存路径和文件名格式 */,
  453. /* 上传视频配置 */
  454. videoActionName: 'uploadvideo' /* 执行上传视频的action名称 */,
  455. videoFieldName: 'file' /* 提交的视频表单名称 */,
  456. videoPathFormat:
  457. '/ueditor/jsp/upload/video/{yyyy}{mm}{dd}/{time}{rand:6}' /* 上传保存路径,可以自定义保存路径和文件名格式 */,
  458. videoUrlPrefix: '' /* 视频访问路径前缀 */,
  459. videoMaxSize: 102400000 /* 上传大小限制,单位B,默认100MB */,
  460. videoAllowFiles: [
  461. '.flv',
  462. '.swf',
  463. '.mkv',
  464. '.avi',
  465. '.rm',
  466. '.rmvb',
  467. '.mpeg',
  468. '.mpg',
  469. '.ogg',
  470. '.ogv',
  471. '.mov',
  472. '.wmv',
  473. '.mp4',
  474. '.webm',
  475. '.mp3',
  476. '.wav',
  477. '.mid'
  478. ] /* 上传视频格式显示 */,
  479. /* 上传文件配置 */
  480. fileActionName: 'uploadfile' /* controller里,执行上传视频的action名称 */,
  481. fileFieldName: 'file' /* 提交的文件表单名称 */,
  482. filePathFormat:
  483. '/ueditor/jsp/upload/file/{yyyy}{mm}{dd}/{time}{rand:6}' /* 上传保存路径,可以自定义保存路径和文件名格式 */,
  484. fileUrlPrefix: '' /* 文件访问路径前缀 */,
  485. fileMaxSize: 838860800 /* 上传大小限制,单位B,默认50MB */,
  486. fileAllowFiles: [
  487. '.png',
  488. '.jpg',
  489. '.jpeg',
  490. '.gif',
  491. '.bmp',
  492. '.flv',
  493. '.swf',
  494. '.mkv',
  495. '.avi',
  496. '.rm',
  497. '.rmvb',
  498. '.mpeg',
  499. '.mpg',
  500. '.ogg',
  501. '.ogv',
  502. '.mov',
  503. '.wmv',
  504. '.mp4',
  505. '.webm',
  506. '.mp3',
  507. '.wav',
  508. '.mid',
  509. '.rar',
  510. '.zip',
  511. '.tar',
  512. '.gz',
  513. '.7z',
  514. '.bz2',
  515. '.cab',
  516. '.iso',
  517. '.doc',
  518. '.docx',
  519. '.xls',
  520. '.xlsx',
  521. '.ppt',
  522. '.pptx',
  523. '.pdf',
  524. '.txt',
  525. '.md',
  526. '.xml'
  527. ] /* 上传文件格式显示 */
  528. }
  529. function getUEBasePath(docUrl, confUrl) {
  530. return getBasePath(
  531. docUrl || self.document.URL || self.location.href,
  532. confUrl || getConfigFilePath()
  533. )
  534. }
  535. function getConfigFilePath() {
  536. var configPath = document.getElementsByTagName('script')
  537. return configPath[configPath.length - 1].src
  538. }
  539. function getBasePath(docUrl, confUrl) {
  540. var basePath = confUrl
  541. if (/^(\/|\\\\)/.test(confUrl)) {
  542. basePath = /^.+?\w(\/|\\\\)/.exec(docUrl)[0] + confUrl.replace(/^(\/|\\\\)/, '')
  543. } else if (!/^[a-z]+:/i.test(confUrl)) {
  544. docUrl = docUrl
  545. .split('#')[0]
  546. .split('?')[0]
  547. .replace(/[^\\\/]+$/, '')
  548. basePath = docUrl + '' + confUrl
  549. }
  550. return optimizationPath(basePath)
  551. }
  552. function optimizationPath(path) {
  553. var protocol = /^[a-z]+:\/\//.exec(path)[0],
  554. tmp = null,
  555. res = []
  556. path = path.replace(protocol, '').split('?')[0].split('#')[0]
  557. path = path.replace(/\\/g, '/').split(/\//)
  558. path[path.length - 1] = ''
  559. while (path.length) {
  560. if ((tmp = path.shift()) === '..') {
  561. res.pop()
  562. } else if (tmp !== '.') {
  563. res.push(tmp)
  564. }
  565. }
  566. return protocol + res.join('/')
  567. }
  568. window.UE = {
  569. getUEBasePath: getUEBasePath
  570. }
  571. })()