PageRenderTime 48ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/uedit/umeditor.config.js

https://gitlab.com/0072016/0072016-mmzrb-
JavaScript | 257 lines | 34 code | 47 blank | 176 comment | 2 complexity | b4fe50868987f0c0196277a9a3160b6f MD5 | raw file
  1. /**
  2. * umeditor完整配置项
  3. * 可以在这里配置整个编辑器的特性
  4. */
  5. /**************************提示********************************
  6. * 所有被注释的配置项均为UEditor默认值。
  7. * 修改默认配置请首先确保已经完全明确该参数的真实用途。
  8. * 主要有两种修改方案,一种是取消此处注释,然后修改成对应参数;另一种是在实例化编辑器时传入对应参数。
  9. * 当升级编辑器时,可直接使用旧版配置文件替换新版配置文件,不用担心旧版配置文件中因缺少新功能所需的参数而导致脚本报错。
  10. **************************提示********************************/
  11. (function () {
  12. /**
  13. * 编辑器资源文件根路径。它所表示的含义是:以编辑器实例化页面为当前路径,指向编辑器资源文件(即dialog等文件夹)的路径。
  14. * 鉴于很多同学在使用编辑器的时候出现的种种路径问题,此处强烈建议大家使用"相对于网站根目录的相对路径"进行配置。
  15. * "相对于网站根目录的相对路径"也就是以斜杠开头的形如"/myProject/umeditor/"这样的路径。
  16. * 如果站点中有多个不在同一层级的页面需要实例化编辑器,且引用了同一UEditor的时候,此处的URL可能不适用于每个页面的编辑器。
  17. * 因此,UEditor提供了针对不同页面的编辑器可单独配置的根路径,具体来说,在需要实例化编辑器的页面最顶部写上如下代码即可。当然,需要令此处的URL等于对应的配置。
  18. * window.UMEDITOR_HOME_URL = "/xxxx/xxxx/";
  19. */
  20. //window.UMEDITOR_HOME_URL = "/xxxx/xxxx/"
  21. var URL = window.UMEDITOR_HOME_URL || (function(){
  22. function PathStack() {
  23. this.documentURL = self.document.URL || self.location.href;
  24. this.separator = '/';
  25. this.separatorPattern = /\\|\//g;
  26. this.currentDir = './';
  27. this.currentDirPattern = /^[.]\/]/;
  28. this.path = this.documentURL;
  29. this.stack = [];
  30. this.push( this.documentURL );
  31. }
  32. PathStack.isParentPath = function( path ){
  33. return path === '..';
  34. };
  35. PathStack.hasProtocol = function( path ){
  36. return !!PathStack.getProtocol( path );
  37. };
  38. PathStack.getProtocol = function( path ){
  39. var protocol = /^[^:]*:\/*/.exec( path );
  40. return protocol ? protocol[0] : null;
  41. };
  42. PathStack.prototype = {
  43. push: function( path ){
  44. this.path = path;
  45. update.call( this );
  46. parse.call( this );
  47. return this;
  48. },
  49. getPath: function(){
  50. return this + "";
  51. },
  52. toString: function(){
  53. return this.protocol + ( this.stack.concat( [''] ) ).join( this.separator );
  54. }
  55. };
  56. function update() {
  57. var protocol = PathStack.getProtocol( this.path || '' );
  58. if( protocol ) {
  59. //根协议
  60. this.protocol = protocol;
  61. //local
  62. this.localSeparator = /\\|\//.exec( this.path.replace( protocol, '' ) )[0];
  63. this.stack = [];
  64. } else {
  65. protocol = /\\|\//.exec( this.path );
  66. protocol && (this.localSeparator = protocol[0]);
  67. }
  68. }
  69. function parse(){
  70. var parsedStack = this.path.replace( this.currentDirPattern, '' );
  71. if( PathStack.hasProtocol( this.path ) ) {
  72. parsedStack = parsedStack.replace( this.protocol , '');
  73. }
  74. parsedStack = parsedStack.split( this.localSeparator );
  75. parsedStack.length = parsedStack.length - 1;
  76. for(var i= 0,tempPath,l=parsedStack.length,root = this.stack;i<l;i++){
  77. tempPath = parsedStack[i];
  78. if(tempPath){
  79. if( PathStack.isParentPath( tempPath ) ) {
  80. root.pop();
  81. } else {
  82. root.push( tempPath );
  83. }
  84. }
  85. }
  86. }
  87. var currentPath = document.getElementsByTagName('script');
  88. currentPath = currentPath[ currentPath.length -1 ].src;
  89. return new PathStack().push( currentPath ) + "";
  90. })();
  91. /**
  92. * 配置项主体。注意,此处所有涉及到路径的配置别遗漏URL变量。
  93. */
  94. window.UMEDITOR_CONFIG = {
  95. //为编辑器实例添加一个路径,这个不能被注释
  96. UMEDITOR_HOME_URL : "../uedit/"
  97. //图片上传配置区
  98. ,imageUrl:"../admin/upload.php?infImgUpload=1" //图片上传提交地址
  99. ,imagePath:URL //图片修正地址,引用了fixedImagePath,如有特殊需求,可自行配置
  100. ,imageFieldName:"abcd" //图片数据的key,若此处修改,需要在后台对应文件修改对应参数
  101. //工具栏上的所有的功能按钮和下拉框,可以在new编辑器的实例时选择自己需要的从新定义
  102. //,toolbar:[
  103. // 'source | undo redo | bold italic underline strikethrough | superscript subscript | forecolor backcolor | removeformat |',
  104. // 'insertorderedlist insertunorderedlist | selectall cleardoc paragraph | fontfamily fontsize' ,
  105. // '| justifyleft justifycenter justifyright justifyjustify |',
  106. // 'link unlink | emotion image video | map',
  107. // '| horizontal print preview fullscreen', 'drafts', 'formula'
  108. //]
  109. ,toolbar:[
  110. 'source | undo redo | bold italic underline strikethrough | superscript subscript | forecolor backcolor | removeformat |',
  111. 'insertorderedlist insertunorderedlist | selectall cleardoc paragraph | fontfamily fontsize' ,
  112. '| justifyleft justifycenter justifyright justifyjustify |',
  113. 'link unlink | image ',
  114. '| horizontal '
  115. ]
  116. //语言配置项,默认是zh-cn。有需要的话也可以使用如下这样的方式来自动多语言切换,当然,前提条件是lang文件夹下存在对应的语言文件:
  117. //lang值也可以通过自动获取 (navigator.language||navigator.browserLanguage ||navigator.userLanguage).toLowerCase()
  118. //,lang:"zh-cn"
  119. //,langPath:URL +"lang/"
  120. //ie下的链接自动监测
  121. //,autourldetectinie:false
  122. //主题配置项,默认是default。有需要的话也可以使用如下这样的方式来自动多主题切换,当然,前提条件是themes文件夹下存在对应的主题文件:
  123. //现有如下皮肤:default
  124. //,theme:'default'
  125. //,themePath:URL +"themes/"
  126. //针对getAllHtml方法,会在对应的head标签中增加该编码设置。
  127. //,charset:"utf-8"
  128. //常用配置项目
  129. //,isShow : true //默认显示编辑器
  130. //,initialContent:'欢迎使用UMEDITOR!' //初始化编辑器的内容,也可以通过textarea/script给值,看官网例子
  131. //,initialFrameWidth:500 //初始化编辑器宽度,默认500
  132. //,initialFrameHeight:500 //初始化编辑器高度,默认500
  133. //,autoClearinitialContent:true //是否自动清除编辑器初始内容,注意:如果focus属性设置为true,这个也为真,那么编辑器一上来就会触发导致初始化的内容看不到了
  134. //,textarea:'editorValue' // 提交表单时,服务器获取编辑器提交内容的所用的参数,多实例时可以给容器name属性,会将name给定的值最为每个实例的键值,不用每次实例化的时候都设置这个值
  135. //,focus:false //初始化时,是否让编辑器获得焦点true或false
  136. //,autoClearEmptyNode : true //getContent时,是否删除空的inlineElement节点(包括嵌套的情况)
  137. //,fullscreen : false //是否开启初始化时即全屏,默认关闭
  138. //,readonly : false //编辑器初始化结束后,编辑区域是否是只读的,默认是false
  139. //,zIndex : 900 //编辑器层级的基数,默认是900
  140. //如果自定义,最好给p标签如下的行高,要不输入中文时,会有跳动感
  141. //注意这里添加的样式,最好放在.edui-editor-body .edui-body-container这两个的下边,防止跟页面上css冲突
  142. //,initialStyle:'.edui-editor-body .edui-body-container p{line-height:1em}'
  143. //,autoSyncData:true //自动同步编辑器要提交的数据
  144. //,emotionLocalization:false //是否开启表情本地化,默认关闭。若要开启请确保emotion文件夹下包含官网提供的images表情文件夹
  145. //,allHtmlEnabled:false //提交到后台的数据是否包含整个html字符串
  146. //fontfamily
  147. //字体设置
  148. // ,'fontfamily':[
  149. // { name: 'songti', val: '宋体,SimSun'},
  150. // ]
  151. //fontsize
  152. //字号
  153. //,'fontsize':[10, 11, 12, 14, 16, 18, 20, 24, 36]
  154. //paragraph
  155. //段落格式 值留空时支持多语言自动识别,若配置,则以配置值为准
  156. //,'paragraph':{'p':'', 'h1':'', 'h2':'', 'h3':'', 'h4':'', 'h5':'', 'h6':''}
  157. //undo
  158. //可以最多回退的次数,默认20
  159. //,maxUndoCount:20
  160. //当输入的字符数超过该值时,保存一次现场
  161. //,maxInputCount:1
  162. //imageScaleEnabled
  163. // 是否允许点击文件拖拽改变大小,默认true
  164. //,imageScaleEnabled:true
  165. //dropFileEnabled
  166. // 是否允许拖放图片到编辑区域,上传并插入,默认true
  167. //,dropFileEnabled:true
  168. //pasteImageEnabled
  169. // 是否允许粘贴QQ截屏,上传并插入,默认true
  170. //,pasteImageEnabled:true
  171. //autoHeightEnabled
  172. // 是否自动长高,默认true
  173. //,autoHeightEnabled:true
  174. //autoFloatEnabled
  175. //是否保持toolbar的位置不动,默认true
  176. //,autoFloatEnabled:true
  177. //浮动时工具栏距离浏览器顶部的高度,用于某些具有固定头部的页面
  178. //,topOffset:30
  179. //填写过滤规则
  180. //,filterRules: {}
  181. };
  182. })();