ueditor.config.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  1. /**
  2. * ueditor plus 完整配置项
  3. * 可以在这里配置整个编辑器的特性
  4. */
  5. /**************************提示********************************
  6. * 所有被注释的配置项均为UEditor默认值。
  7. * 修改默认配置请首先确保已经完全明确该参数的真实用途。
  8. * 主要有两种修改方案,一种是取消此处注释,然后修改成对应参数;另一种是在实例化编辑器时传入对应参数。
  9. * 当升级编辑器时,可直接使用旧版配置文件替换新版配置文件,不用担心旧版配置文件中因缺少新功能所需的参数而导致脚本报错。
  10. **************************提示********************************/
  11. (function () {
  12. // 资源文件根路径,如果你的页面不是放在根目录下,请注意修改这个路径
  13. // 通常情况下这个可以配置成静态资源CDN的地址
  14. var URL, CORS_URL;
  15. if (window.UEDITOR_HOME_URL) {
  16. URL = window.UEDITOR_HOME_URL;
  17. } else if (window.__msCDN) {
  18. URL = window.__msCDN + 'asset/vendor/ueditor/';
  19. } else if (window.__msRoot) {
  20. URL = window.__msRoot + 'asset/vendor/ueditor/';
  21. } else {
  22. URL = getUEBasePath();
  23. }
  24. // 需要能跨域的静态资源请求,主要用户弹窗页面等静态资源
  25. // 通常情况下这个可以配置成静态资源CDN的地址
  26. if (window.UEDITOR_CORS_URL) {
  27. CORS_URL = window.UEDITOR_CORS_URL;
  28. } else if (window.__msRoot) {
  29. CORS_URL = window.__msRoot + 'asset/vendor/ueditor/';
  30. } else if (window.UEDITOR_HOME_URL) {
  31. CORS_URL = window.UEDITOR_HOME_URL;
  32. } else {
  33. CORS_URL = getUEBasePath();
  34. }
  35. /**
  36. * 配置项主体。注意,此处所有涉及到路径的配置别遗漏URL变量。
  37. */
  38. window.UEDITOR_CONFIG = {
  39. // 为编辑器实例添加一个路径,这个不能被注释
  40. UEDITOR_HOME_URL: URL,
  41. // 需要能跨域的静态资源请求,主要用户弹窗页面等静态资源
  42. UEDITOR_CORS_URL: CORS_URL,
  43. // 是否开启Debug模式
  44. debug: false,
  45. // 服务器统一请求接口路径
  46. //serverUrl: "/ueditor-plus/_demo_server/handle.php",
  47. // 从服务器获取配置
  48. //loadConfigFromServer: true,
  49. // 服务器统一请求头信息,会在所有请求中带上该信息
  50. serverHeaders: {
  51. // 'Authorization': 'Bearer xxx'
  52. },
  53. // 服务器返回参数统一转换方法,可以在这里统一处理返回参数
  54. serverResponsePrepare: function (res) {
  55. if (!res || typeof res.code === 'undefined') {
  56. return res;
  57. }
  58. if (res.code === 1) {
  59. res.state = "SUCCESS";
  60. if (res.path) {
  61. res.url = res.path;
  62. }
  63. }
  64. //console.log('serverResponsePrepare', res);
  65. return res;
  66. },
  67. //工具栏上的所有的功能按钮和下拉框,可以在new编辑器的实例时选择自己需要的重新定义
  68. toolbars: [
  69. [
  70. "fullscreen", // 全屏
  71. "source", // 源代码
  72. "|",
  73. "undo", // 撤销
  74. "redo", // 重做
  75. "|",
  76. "bold", // 加粗
  77. "italic", // 斜体
  78. "underline", // 下划线
  79. "fontborder", // 字符边框
  80. "strikethrough",// 删除线
  81. "superscript", // 上标
  82. "subscript", // 下标
  83. "removeformat", // 清除格式
  84. "formatmatch", // 格式刷
  85. "autotypeset", // 自动排版
  86. "blockquote", // 引用
  87. "pasteplain", // 纯文本粘贴模式
  88. "|",
  89. "forecolor", // 字体颜色
  90. "backcolor", // 背景色
  91. "insertorderedlist", // 有序列表
  92. "insertunorderedlist", // 无序列表
  93. "selectall", // 全选
  94. "cleardoc", // 清空文档
  95. "|",
  96. "rowspacingtop",// 段前距
  97. "rowspacingbottom", // 段后距
  98. "lineheight", // 行间距
  99. "|",
  100. "customstyle", // 自定义标题
  101. "paragraph", // 段落格式
  102. "fontfamily", // 字体
  103. "fontsize", // 字号
  104. "|",
  105. "directionalityltr", // 从左向右输入
  106. "directionalityrtl", // 从右向左输入
  107. "indent", // 首行缩进
  108. "|",
  109. "justifyleft", // 居左对齐
  110. "justifycenter", // 居中对齐
  111. "justifyright",
  112. "justifyjustify", // 两端对齐
  113. "|",
  114. "touppercase", // 字母大写
  115. "tolowercase", // 字母小写
  116. "|",
  117. "link", // 超链接
  118. "unlink", // 取消链接
  119. "anchor", // 锚点
  120. "|",
  121. "imagenone", // 图片默认
  122. "imageleft", // 图片左浮动
  123. "imagecenter", // 图片居中
  124. "imageright", // 图片右浮动
  125. "|",
  126. "simpleupload", // 单图上传
  127. "insertimage", // 多图上传
  128. "emotion", // 表情
  129. //"scrawl", // 涂鸦
  130. "insertvideo", // 视频
  131. "insertaudio", // 音频
  132. "attachment", // 附件
  133. "insertframe", // 插入Iframe
  134. "insertcode", // 插入代码
  135. "pagebreak", // 分页
  136. "template", // 模板
  137. "background", // 背景
  138. "formula", // 公式
  139. "|",
  140. "horizontal", // 分隔线
  141. "date", // 日期
  142. "time", // 时间
  143. "spechars", // 特殊字符
  144. "wordimage", // Word图片转存
  145. "|",
  146. "inserttable", // 插入表格
  147. "deletetable", // 删除表格
  148. "insertparagraphbeforetable", // 表格前插入行
  149. "insertrow", // 前插入行
  150. "deleterow", // 删除行
  151. "insertcol", // 前插入列
  152. "deletecol", // 删除列
  153. "mergecells", // 合并多个单元格
  154. "mergeright", // 右合并单元格
  155. "mergedown", // 下合并单元格
  156. "splittocells", // 完全拆分单元格
  157. "splittorows", // 拆分成行
  158. "splittocols", // 拆分成列
  159. "|",
  160. "print", // 打印
  161. "preview", // 预览
  162. "searchreplace", // 查询替换
  163. "|",
  164. "contentimport",
  165. "help", // 帮助
  166. ]
  167. ]
  168. // 自定义工具栏按钮点击,返回 true 表示已经处理点击,会阻止默认事件
  169. , toolbarCallback: function (cmd, editor) {
  170. // console.log('toolbarCallback',cmd, editor);
  171. // switch(cmd){
  172. // case 'insertimage':
  173. // editor.execCommand('insertHtml', '<p><img src="xxxxx" /></p>');
  174. // console.log('toolbarCallback',cmd, editor)
  175. // return true;
  176. // case 'insertvideo':
  177. // editor.execCommand('insertHtml', '<p><iframe src="xxxxx" /></p>');
  178. // console.log('toolbarCallback',cmd, editor)
  179. // return true;
  180. // case 'attachment':
  181. // console.log('toolbarCallback',cmd, editor)
  182. // editor.execCommand('insertHtml', '<p><a href="xxx.zip">下载文件</a></p>');
  183. // return true;
  184. // }
  185. }
  186. // 自定义上传功能
  187. , uploadServiceEnable: false
  188. // 自定义上传函数,需要在这个函数中实现自定义上传逻辑
  189. // type 上传类型,image 图片,video 视频,audio 音频,attachment 附件
  190. // file 文件对象
  191. // callback 回调函数,需要在上传完成后调用 callback.success、callback.error、callback.progress
  192. // option 上传配置,其他一些未来扩展配置
  193. , uploadServiceUpload: function(type, file, callback, option ) {
  194. console.log('uploadServiceUpload', type, file, callback, option);
  195. // var i = 0;
  196. // var call = function(){
  197. // i++;
  198. // if(i > 3){
  199. // callback.success({
  200. // "state": "SUCCESS",
  201. // "url": "https://ms-assets.modstart.com/demo/modstart.jpg",
  202. // })
  203. // return;
  204. // }
  205. // setTimeout(function(){
  206. // callback.progress(0.3 * i);
  207. // call();
  208. // },500);
  209. // }
  210. // call();
  211. }
  212. // 插入图片自定义配置
  213. , imageConfig: {
  214. // 禁止本地上传
  215. disableUpload: false,
  216. // 禁止在线管理
  217. disableOnline: false,
  218. // 自定义选择按钮
  219. selectCallback: null,
  220. // selectCallback: function(editor,cb){
  221. // console.log('selectCallback',cb);
  222. // setTimeout(function(){
  223. // cb({
  224. // path:'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png',
  225. // name:'测试图片'
  226. // });
  227. // },1000);
  228. // }
  229. }
  230. // 插入视频配置
  231. , videoConfig: {
  232. // 禁止本地上传,
  233. disableUpload: false,
  234. // 自定义选择按钮
  235. selectCallback: null,
  236. // selectCallback: function(editor,cb){
  237. // console.log('selectCallback',cb);
  238. // setTimeout(function(){
  239. // cb({
  240. // path:'https://www.bilibili.com/video/BV1y44y1g7NR?spm_id_from=333.1007.tianma.1-1-1.click',
  241. // name:'测试视频'
  242. // });
  243. // },1000);
  244. // }
  245. }
  246. // 插入音频配置
  247. , audioConfig: {
  248. // 禁止本地上传,
  249. disableUpload: false,
  250. // 自定义选择按钮
  251. selectCallback: null,
  252. // selectCallback: function(editor,cb){
  253. // console.log('selectCallback',cb);
  254. // setTimeout(function(){
  255. // cb({
  256. // path:'https://example.com/test.mp3',
  257. // name:'测试音频'
  258. // });
  259. // },1000);
  260. // }
  261. }
  262. // 公式配置
  263. , formulaConfig: {
  264. // 公式渲染链接模板
  265. imageUrlTemplate: 'https://r.latexeasy.com/image.svg?{}',
  266. // 编辑器模式 plain live
  267. editorMode: 'live',
  268. // 编辑器地址
  269. editorLiveServer: 'https://latexeasy.com',
  270. }
  271. // 自动保存
  272. , autoSaveEnable: true
  273. // 浏览器初始化时自动恢复上一次的内容
  274. , autoSaveRestore: false
  275. // 自动保存Key,为空时根据网址自动计算
  276. , autoSaveKey: null
  277. //当鼠标放在工具栏上时显示的tooltip提示,留空支持自动多语言配置,否则以配置值为准
  278. //,labelMap:{
  279. // 'anchor':'', 'undo':''
  280. //}
  281. //语言配置项,默认是zh-cn。有需要的话也可以使用如下这样的方式来自动多语言切换,当然,前提条件是lang文件夹下存在对应的语言文件:
  282. //lang值也可以通过自动获取 (navigator.language||navigator.browserLanguage ||navigator.userLanguage).toLowerCase()
  283. //,lang:"zh-cn"
  284. //,langPath:URL +"lang/"
  285. //主题配置项,默认是default。有需要的话也可以使用如下这样的方式来自动多主题切换,当然,前提条件是themes文件夹下存在对应的主题文件:
  286. //现有如下皮肤:default
  287. //,theme:'default'
  288. //,themePath:URL +"themes/"
  289. //,zIndex : 900 //编辑器层级的基数,默认是900
  290. //针对getAllHtml方法,会在对应的head标签中增加该编码设置。
  291. //,charset:"utf-8"
  292. //若实例化编辑器的页面手动修改的domain,此处需要设置为true
  293. //,customDomain:false
  294. // 默认显示编辑器
  295. //,isShow : true
  296. // 提交表单时,服务器获取编辑器提交内容的所用的参数,多实例时可以给容器name属性,会将name给定的值最为每个实例的键值,不用每次实例化的时候都设置这个值
  297. //,textarea:'editorValue'
  298. // 初始化编辑器的内容,也可以通过 textarea/script 给值
  299. , initialContent: ''
  300. //,autoClearinitialContent:true //是否自动清除编辑器初始内容,注意:如果focus属性设置为true,这个也为真,那么编辑器一上来就会触发导致初始化的内容看不到了
  301. // 初始化时,是否让编辑器获得焦点
  302. , focus: false
  303. // 编辑区自定义样式,如果自定义,最好给 p 标签如下的行高,要不输入中文时,会有跳动感
  304. , initialStyle: '' // p{line-height:1em}
  305. //,iframeJsUrl: '' //给编辑区域的iframe引入一个js文件
  306. //,iframeCssUrl: URL + '/themes/iframe.css' //给编辑区域的iframe引入一个css文件
  307. // 给编辑器引入更多样式文件
  308. //,iframeCssUrlsAddition: []
  309. // 首行缩进距离,默认是 2em
  310. , indentValue: '2em'
  311. // 初始化编辑器宽度,默认 1000
  312. // ,initialFrameWidth:1000
  313. // 初始化编辑器高度,默认 320
  314. // ,initialFrameHeight:320
  315. // 编辑器初始化结束后,编辑区域是否是只读的,默认是false
  316. , readonly: false
  317. // getContent时,是否删除空的inlineElement节点(包括嵌套的情况)
  318. , autoClearEmptyNode: true
  319. // 启用拖放上传
  320. //,enableDragUpload: true
  321. // 启用粘贴上传
  322. //,enablePasteUpload: true
  323. // 启用图片拉伸缩放
  324. //,imageScaleEnabled: true
  325. // 是否开启初始化时即全屏,默认关闭
  326. , fullscreen: false
  327. // 图片操作的浮层开关,默认打开
  328. //,imagePopup:true
  329. // 自动同步编辑器要提交的数据
  330. //,autoSyncData:true
  331. // 是否开启表情本地化,默认关闭。若要开启请确保emotion文件夹下包含官网提供的images表情文件夹
  332. //,emotionLocalization:false
  333. // 粘贴只保留标签,去除标签所有属性
  334. //,retainOnlyLabelPasted: false
  335. // 是否默认为纯文本粘贴。false为不使用纯文本粘贴,true为使用纯文本粘贴
  336. //,pasteplain:false
  337. // 纯文本粘贴模式下的过滤规则
  338. //'filterTxtRules' : function(){
  339. // function transP(node){
  340. // node.tagName = 'p';
  341. // node.setStyle();
  342. // }
  343. // return {
  344. // //直接删除及其字节点内容
  345. // '-' : 'script style object iframe embed input select',
  346. // 'p': {$:{}},
  347. // 'br':{$:{}},
  348. // 'div':{'$':{}},
  349. // 'li':{'$':{}},
  350. // 'caption':transP,
  351. // 'th':transP,
  352. // 'tr':transP,
  353. // 'h1':transP,'h2':transP,'h3':transP,'h4':transP,'h5':transP,'h6':transP,
  354. // 'td':function(node){
  355. // //没有内容的td直接删掉
  356. // var txt = !!node.innerText();
  357. // if(txt){
  358. // node.parentNode.insertAfter(UE.uNode.createText(' &nbsp; &nbsp;'),node);
  359. // }
  360. // node.parentNode.removeChild(node,node.innerText())
  361. // }
  362. // }
  363. //}()
  364. // 提交到后台的数据是否包含整个html字符串
  365. , allHtmlEnabled: false
  366. //有序列表的下拉配置,值留空时支持多语言自动识别,若配置值,则以此值为准
  367. //,'insertorderedlist':{
  368. // 'decimal' : '' , //'1,2,3...'
  369. // 'lower-alpha' : '' , // 'a,b,c...'
  370. // 'lower-roman' : '' , //'i,ii,iii...'
  371. // 'upper-alpha' : '' , lang //'A,B,C'
  372. // 'upper-roman' : '' //'I,II,III...'
  373. //}
  374. //insertunorderedlist
  375. //无序列表的下拉配置,值留空时支持多语言自动识别,若配置值,则以此值为准
  376. //,insertunorderedlist : { //自定的样式
  377. // 'circle' : '', // '○ 小圆圈'
  378. // 'disc' : '', // '● 小圆点'
  379. // 'square' : '' //'■ 小方块'
  380. //}
  381. //,listDefaultPaddingLeft : '30'//默认的左边缩进的基数倍
  382. //,listiconpath : 'http://bs.baidu.com/listicon/'//自定义标号的路径
  383. //,maxListLevel : 3 //限制可以tab的级数, 设置-1为不限制
  384. //,autoTransWordToList:false //禁止word中粘贴进来的列表自动变成列表标签
  385. // 字体设置 label 留空支持多语言自动切换,若配置,则以配置值为准
  386. //,'fontfamily':[
  387. // { label:'',name:'songti',val:'宋体,SimSun'},
  388. // { label:'',name:'kaiti',val:'楷体,楷体_GB2312, SimKai'},
  389. // { label:'',name:'yahei',val:'微软雅黑,Microsoft YaHei'},
  390. // { label:'',name:'heiti',val:'黑体, SimHei'},
  391. // { label:'',name:'lishu',val:'隶书, SimLi'},
  392. // { label:'',name:'andaleMono',val:'andale mono'},
  393. // { label:'',name:'arial',val:'arial, helvetica,sans-serif'},
  394. // { label:'',name:'arialBlack',val:'arial black,avant garde'},
  395. // { label:'',name:'comicSansMs',val:'comic sans ms'},
  396. // { label:'',name:'impact',val:'impact,chicago'},
  397. // { label:'',name:'timesNewRoman',val:'times new roman'}
  398. //]
  399. // 字号
  400. //,'fontsize':[10, 11, 12, 14, 16, 18, 20, 24, 36]
  401. // 段落格式 值留空时支持多语言自动识别,若配置,则以配置值为准
  402. //,'paragraph':{'p':'', 'h1':'', 'h2':'', 'h3':'', 'h4':'', 'h5':'', 'h6':''}
  403. // 段间距 值和显示的名字相同
  404. //,'rowspacingtop':['5', '10', '15', '20', '25']
  405. // 段间距 值和显示的名字相同
  406. //,'rowspacingbottom':['5', '10', '15', '20', '25']
  407. //行内间距 值和显示的名字相同
  408. //,'lineheight':['1', '1.5','1.75','2', '3', '4', '5']
  409. // customstyle
  410. //自定义样式,不支持国际化,此处配置值即可最后显示值
  411. //block的元素是依据设置段落的逻辑设置的,inline的元素依据BIU的逻辑设置
  412. //尽量使用一些常用的标签
  413. //参数说明
  414. //tag 使用的标签名字
  415. //label 显示的名字也是用来标识不同类型的标识符,注意这个值每个要不同,
  416. //style 添加的样式
  417. //每一个对象就是一个自定义的样式
  418. //,'customstyle':[
  419. // {tag:'h1', name:'tc', label:'', style:'border-bottom:#ccc 2px solid;padding:0 4px 0 0;text-align:center;margin:0 0 20px 0;'},
  420. // {tag:'h1', name:'tl',label:'', style:'border-bottom:#ccc 2px solid;padding:0 4px 0 0;margin:0 0 10px 0;'},
  421. // {tag:'span',name:'im', label:'', style:'font-style:italic;font-weight:bold'},
  422. // {tag:'span',name:'hi', label:'', style:'font-style:italic;font-weight:bold;color:rgb(51, 153, 204)'}
  423. //]
  424. // 打开右键菜单功能
  425. , enableContextMenu: true
  426. //右键菜单的内容,可以参考plugins/contextmenu.js里边的默认菜单的例子,label留空支持国际化,否则以此配置为准
  427. //,contextMenu:[
  428. // {
  429. // label:'', //显示的名称
  430. // cmdName:'selectall',//执行的command命令,当点击这个右键菜单时
  431. // //exec可选,有了exec就会在点击时执行这个function,优先级高于cmdName
  432. // exec:function () {
  433. // //this是当前编辑器的实例
  434. // //this.ui._dialogs['inserttableDialog'].open();
  435. // }
  436. // }
  437. //]
  438. //快捷菜单
  439. , shortcutMenu: [
  440. // "fontfamily", // 字体
  441. // "fontsize", // 字号
  442. "bold", // 加粗
  443. "italic", // 斜体
  444. "underline", // 下划线
  445. "strikethrough", // 删除线
  446. "fontborder", // 字符边框
  447. "forecolor", // 字体颜色
  448. "backcolor", // 背景色
  449. "imagenone", // 图片默认
  450. "imageleft", // 图片左浮动
  451. "imagecenter", // 图片居中
  452. "imageright", // 图片右浮动
  453. "insertimage", // 插入图片
  454. "formula",
  455. // "justifyleft", // 居左对齐
  456. // "justifycenter", // 居中对齐
  457. // "justifyright", // 居右对齐
  458. // "justifyjustify", // 两端对齐
  459. // "rowspacingtop", // 段前距
  460. // "rowspacingbottom", // 段后距
  461. // "lineheight", // 行间距
  462. // "insertorderedlist", // 有序列表
  463. // "insertunorderedlist", // 无序列表
  464. // "superscript", // 上标
  465. // "subscript", // 下标
  466. // "link", // 超链接
  467. // "unlink", // 取消链接
  468. // "touppercase", // 字母大写
  469. // "tolowercase" // 字母小写
  470. ]
  471. // 是否启用元素路径,默认是显示
  472. , elementPathEnabled: true
  473. // 是否开启字数统计
  474. , wordCount: true
  475. // 允许的最大字符数
  476. , maximumWords: 10000
  477. //字数统计提示,{#count} 代表当前字数,{#leave}代表还可以输入多少字符数,留空支持多语言自动切换,否则按此配置显示
  478. //,wordCountMsg:'' //当前已输入 {#count} 个字符,您还可以输入{#leave} 个字符
  479. //超出字数限制提示 留空支持多语言自动切换,否则按此配置显示
  480. //,wordOverFlowMsg:'' //<span style="color:red;">你输入的字符个数已经超出最大允许值,服务器可能会拒绝保存!</span>
  481. // 点击tab键时移动的距离,tabSize倍数,tabNode什么字符做为单位
  482. //,tabSize:4
  483. //,tabNode:'&nbsp;'
  484. // 清除格式时可以删除的标签
  485. //,removeFormatTags:'b,big,code,del,dfn,em,font,i,ins,kbd,q,samp,small,span,strike,strong,sub,sup,tt,u,var'
  486. // 清除格式时可以删除的属性
  487. //,removeFormatAttributes:'class,style,lang,width,height,align,hspace,valign'
  488. // 可以最多撤销退回的次数,默认20
  489. , maxUndoCount: 20
  490. // 当输入的字符数超过该值时,保存一次现场
  491. , maxInputCount: 1
  492. // 是否自动长高,默认true
  493. , autoHeightEnabled: true
  494. // 是否可以拉伸长高,默认true(当开启时,自动长高失效)
  495. //,scaleEnabled:false
  496. //,minFrameWidth:800 //编辑器拖动时最小宽度,默认800
  497. // 编辑器最小高度,默认220
  498. , minFrameHeight: 220
  499. // 是否保持toolbar的位置不动,默认true
  500. , autoFloatEnabled: true
  501. // 浮动时工具栏距离浏览器顶部的高度,用于某些具有固定头部的页面
  502. , topOffset: 0
  503. // 编辑器底部距离工具栏高度(如果参数大于等于编辑器高度,则设置无效)
  504. , toolbarTopOffset: 0
  505. //设置远程图片是否抓取到本地保存
  506. , catchRemoteImageEnable: false //设置是否抓取远程图片
  507. //pageBreakTag
  508. //分页标识符,默认是_ueditor_page_break_tag_
  509. ,pageBreakTag:'[page]'
  510. // 自动排版参数
  511. , autotypeset: {
  512. // 合并空行
  513. mergeEmptyline: true,
  514. // 去掉冗余的class
  515. removeClass: true,
  516. // 去掉空行
  517. removeEmptyline: false,
  518. // 段落的排版方式,可以是 left,right,center,justify 去掉这个属性表示不执行排版
  519. textAlign: "left",
  520. // 图片的浮动方式,独占一行剧中,左右浮动,默认: center,left,right,none 去掉这个属性表示不执行排版
  521. imageBlockLine: "center",
  522. // 根据规则过滤没事粘贴进来的内容
  523. pasteFilter: false,
  524. // 去掉所有的内嵌字号,使用编辑器默认的字号
  525. clearFontSize: false,
  526. // 去掉所有的内嵌字体,使用编辑器默认的字体
  527. clearFontFamily: false,
  528. // 去掉空节点
  529. removeEmptyNode: false,
  530. // 可以去掉的标签
  531. removeTagNames: {div: 1},
  532. // 行首缩进
  533. indent: false,
  534. // 行首缩进的大小
  535. indentValue: "2em",
  536. // 全角转半角
  537. bdc2sb: false,
  538. // 半角转全角
  539. tobdc: false
  540. }
  541. //表格是否可以拖拽
  542. //,tableDragable: true
  543. //sourceEditor
  544. //源码的查看方式,codemirror 是代码高亮,textarea是文本框,默认是codemirror
  545. //注意默认codemirror只能在ie8+和非ie中使用
  546. //,sourceEditor:"codemirror"
  547. //如果sourceEditor是codemirror,还用配置一下两个参数
  548. //codeMirrorJsUrl js加载的路径,默认是 URL + "third-party/codemirror/codemirror.js"
  549. //,codeMirrorJsUrl:URL + "third-party/codemirror/codemirror.js"
  550. //codeMirrorCssUrl css加载的路径,默认是 URL + "third-party/codemirror/codemirror.css"
  551. //,codeMirrorCssUrl:URL + "third-party/codemirror/codemirror.css"
  552. //编辑器初始化完成后是否进入源码模式,默认为否。
  553. //,sourceEditorFirst:false
  554. //iframeUrlMap
  555. //dialog内容的路径 ~会被替换成URL,垓属性一旦打开,将覆盖所有的dialog的默认路径
  556. //,iframeUrlMap:{
  557. // 'anchor':'~/dialogs/anchor/anchor.html',
  558. //}
  559. //allowLinkProtocol 允许的链接地址,有这些前缀的链接地址不会自动添加http
  560. //, allowLinkProtocols: ['http:', 'https:', '#', '/', 'ftp:', 'mailto:', 'tel:', 'git:', 'svn:']
  561. //默认过滤规则相关配置项目
  562. //,disabledTableInTable:true //禁止表格嵌套
  563. // 允许进入编辑器的 div 标签自动变成 p 标签
  564. , allowDivTransToP: true
  565. // 默认产出的数据中的color自动从rgb格式变成16进制格式
  566. , rgb2Hex: true,
  567. tipError: function (msg, param) {
  568. if (window && window.MS && window.MS.dialog) {
  569. window.MS.dialog.tipError(msg);
  570. } else {
  571. alert(msg);
  572. }
  573. }
  574. };
  575. function getUEBasePath(docUrl, confUrl) {
  576. return getBasePath(
  577. docUrl || self.document.URL || self.location.href,
  578. confUrl || getConfigFilePath()
  579. );
  580. }
  581. function getConfigFilePath() {
  582. var configPath = document.getElementsByTagName("script");
  583. return configPath[configPath.length - 1].src;
  584. }
  585. function getBasePath(docUrl, confUrl) {
  586. var basePath = confUrl;
  587. if (/^(\/|\\\\)/.test(confUrl)) {
  588. basePath =
  589. /^.+?\w(\/|\\\\)/.exec(docUrl)[0] + confUrl.replace(/^(\/|\\\\)/, "");
  590. } else if (!/^[a-z]+:/i.test(confUrl)) {
  591. docUrl = docUrl.split("#")[0].split("?")[0].replace(/[^\\\/]+$/, "");
  592. basePath = docUrl + "" + confUrl;
  593. }
  594. return optimizationPath(basePath);
  595. }
  596. function optimizationPath(path) {
  597. var protocol = /^[a-z]+:\/\//.exec(path)[0],
  598. tmp = null,
  599. res = [];
  600. path = path.replace(protocol, "").split("?")[0].split("#")[0];
  601. path = path.replace(/\\/g, "/").split(/\//);
  602. path[path.length - 1] = "";
  603. while (path.length) {
  604. if ((tmp = path.shift()) === "..") {
  605. res.pop();
  606. } else if (tmp !== ".") {
  607. res.push(tmp);
  608. }
  609. }
  610. return protocol + res.join("/");
  611. }
  612. window.UE = {
  613. getUEBasePath: getUEBasePath
  614. };
  615. })();