config.js 2.9 KB

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