config.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /* 配置文件 */
  2. // #ifdef MP-WEIXIN
  3. const canIUse = wx.canIUse('editor'); // 高基础库标识,用于兼容
  4. // #endif
  5. module.exports = {
  6. // 出错占位图
  7. errorImg: null,
  8. // 过滤器函数
  9. filter: null,
  10. // 代码高亮函数
  11. highlight: null,
  12. // 文本处理函数
  13. onText: null,
  14. // 实体编码列表
  15. entities: {
  16. quot: '"',
  17. apos: "'",
  18. semi: ';',
  19. nbsp: '\xA0',
  20. ensp: '\u2002',
  21. emsp: '\u2003',
  22. ndash: '–',
  23. mdash: '—',
  24. middot: '·',
  25. lsquo: '‘',
  26. rsquo: '’',
  27. ldquo: '“',
  28. rdquo: '”',
  29. bull: '•',
  30. hellip: '…'
  31. },
  32. blankChar: makeMap(' ,\xA0,\t,\r,\n,\f'),
  33. // 块级标签,将被转为 div
  34. blockTags: makeMap('address,article,aside,body,caption,center,cite,footer,header,html,nav,section' + (
  35. // #ifdef MP-WEIXIN
  36. canIUse ? '' :
  37. // #endif
  38. ',pre')),
  39. // 将被移除的标签
  40. ignoreTags: makeMap(
  41. 'area,base,canvas,frame,input,link,map,meta,param,script,source,style,svg,textarea,title,track,wbr'
  42. // #ifdef MP-WEIXIN
  43. + (canIUse ? ',rp' : '')
  44. // #endif
  45. // #ifndef APP-PLUS
  46. + ',iframe'
  47. // #endif
  48. ),
  49. // 只能被 rich-text 显示的标签
  50. richOnlyTags: makeMap('a,colgroup,fieldset,legend,picture,table'
  51. // #ifdef MP-WEIXIN
  52. + (canIUse ? ',bdi,bdo,caption,rt,ruby' : '')
  53. // #endif
  54. ),
  55. // 自闭合的标签
  56. selfClosingTags: makeMap(
  57. 'area,base,br,col,circle,ellipse,embed,frame,hr,img,input,line,link,meta,param,path,polygon,rect,source,track,use,wbr'
  58. ),
  59. // 信任的属性
  60. trustAttrs: makeMap(
  61. 'align,allowfullscreen,alt,app-id,author,autoplay,autostart,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'
  62. ),
  63. // bool 型的属性
  64. boolAttrs: makeMap('allowfullscreen,autoplay,autostart,controls,ignore,loop,muted'),
  65. // 信任的标签
  66. trustTags: makeMap(
  67. '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'
  68. // #ifdef MP-WEIXIN
  69. + (canIUse ? ',bdi,bdo,caption,pre,rt,ruby' : '')
  70. // #endif
  71. // #ifdef APP-PLUS
  72. + ',embed,iframe'
  73. // #endif
  74. ),
  75. // 默认的标签样式
  76. userAgentStyles: {
  77. address: 'font-style:italic',
  78. big: 'display:inline;font-size:12px',
  79. blockquote: 'background-color:#f6f6f6;border-left:3px solid #dbdbdb;color:#6c6c6c;padding:5px 0 5px 10px',
  80. caption: 'display:table-caption;text-align:center',
  81. center: 'text-align:center',
  82. cite: 'font-style:italic',
  83. dd: 'margin-left:40px',
  84. mark: 'background-color:yellow',
  85. pre: 'font-family:monospace;white-space:pre;overflow:scroll',
  86. s: 'text-decoration:line-through',
  87. small: 'display:inline;font-size:0.8em',
  88. u: 'text-decoration:underline',
  89. p:'font-size:13px;color:#666;line-height:17px;',
  90. img:'display:block'
  91. }
  92. }
  93. function makeMap(str) {
  94. var map = Object.create(null),
  95. list = str.split(',');
  96. for (var i = list.length; i--;)
  97. map[list[i]] = true;
  98. return map;
  99. }