config.js 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // +----------------------------------------------------------------------
  2. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  3. // +----------------------------------------------------------------------
  4. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  5. // +----------------------------------------------------------------------
  6. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  7. // +----------------------------------------------------------------------
  8. // | Author: CRMEB Team <admin@crmeb.com>
  9. // +----------------------------------------------------------------------
  10. /* 配置文件 */
  11. // #ifdef MP-WEIXIN
  12. const canIUse = wx.canIUse('editor'); // 高基础库标识,用于兼容
  13. // #endif
  14. module.exports = {
  15. // 过滤器函数
  16. filter: null,
  17. // 代码高亮函数
  18. highlight: null,
  19. // 文本处理函数
  20. onText: null,
  21. blankChar: makeMap(' ,\xA0,\t,\r,\n,\f'),
  22. // 块级标签,将被转为 div
  23. blockTags: makeMap('address,article,aside,body,caption,center,cite,footer,header,html,nav,section' + (
  24. // #ifdef MP-WEIXIN
  25. canIUse ? '' :
  26. // #endif
  27. ',pre')),
  28. // 将被移除的标签
  29. ignoreTags: makeMap(
  30. 'area,base,basefont,canvas,command,frame,input,isindex,keygen,link,map,meta,param,script,source,style,svg,textarea,title,track,use,wbr'
  31. // #ifdef MP-WEIXIN
  32. + (canIUse ? ',rp' : '')
  33. // #endif
  34. // #ifndef APP-PLUS
  35. + ',embed,iframe'
  36. // #endif
  37. ),
  38. // 只能被 rich-text 显示的标签
  39. richOnlyTags: makeMap('a,colgroup,fieldset,legend,picture,table'
  40. // #ifdef MP-WEIXIN
  41. + (canIUse ? ',bdi,bdo,caption,rt,ruby' : '')
  42. // #endif
  43. ),
  44. // 自闭合的标签
  45. selfClosingTags: makeMap(
  46. 'area,base,basefont,br,col,circle,ellipse,embed,frame,hr,img,input,isindex,keygen,line,link,meta,param,path,polygon,rect,source,track,use,wbr'
  47. ),
  48. // 信任的属性
  49. trustAttrs: makeMap(
  50. 'align,alt,app-id,author,autoplay,border,cellpadding,cellspacing,class,color,colspan,controls,data-src,dir,face,height,href,id,ignore,loop,media,muted,name,path,poster,rowspan,size,span,src,start,style,type,unit-id,width,xmlns'
  51. ),
  52. // bool 型的属性
  53. boolAttrs: makeMap('autoplay,controls,ignore,loop,muted'),
  54. // 信任的标签
  55. trustTags: makeMap(
  56. 'a,abbr,ad,audio,b,blockquote,br,code,col,colgroup,dd,del,dl,dt,div,em,fieldset,h1,h2,h3,h4,h5,h6,hr,i,img,ins,label,legend,li,ol,p,q,source,span,strong,sub,sup,table,tbody,td,tfoot,th,thead,tr,title,ul,video'
  57. // #ifdef MP-WEIXIN
  58. + (canIUse ? ',bdi,bdo,caption,pre,rt,ruby' : '')
  59. // #endif
  60. // #ifdef APP-PLUS
  61. + ',embed,iframe'
  62. // #endif
  63. ),
  64. // 默认的标签样式
  65. userAgentStyles: {
  66. address: 'font-style:italic',
  67. big: 'display:inline;font-size:1.2em',
  68. blockquote: 'background-color:#f6f6f6;border-left:3px solid #dbdbdb;color:#6c6c6c;padding:5px 0 5px 10px',
  69. caption: 'display:table-caption;text-align:center',
  70. center: 'text-align:center',
  71. cite: 'font-style:italic',
  72. dd: 'margin-left:40px',
  73. img: 'max-width:100%',
  74. mark: 'background-color:yellow',
  75. picture: 'max-width:100%',
  76. pre: 'font-family:monospace;white-space:pre;overflow:scroll',
  77. s: 'text-decoration:line-through',
  78. small: 'display:inline;font-size:0.8em',
  79. u: 'text-decoration:underline'
  80. }
  81. }
  82. function makeMap(str) {
  83. var map = {},
  84. list = str.split(',');
  85. for (var i = list.length; i--;)
  86. map[list[i]] = true;
  87. return map;
  88. }