config.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. blankChar: makeMap(' ,\xA0,\t,\r,\n,\f'),
  13. // 块级标签,将被转为 div
  14. blockTags: makeMap('address,article,aside,body,caption,center,cite,footer,header,html,nav,section' + (
  15. // #ifdef MP-WEIXIN
  16. canIUse ? '' :
  17. // #endif
  18. ',pre')),
  19. // 将被移除的标签
  20. ignoreTags: makeMap(
  21. 'area,base,basefont,canvas,command,frame,input,isindex,keygen,link,map,meta,param,script,source,style,svg,textarea,title,track,use,wbr'
  22. // #ifdef MP-WEIXIN
  23. + (canIUse ? ',rp' : '')
  24. // #endif
  25. // #ifndef APP-PLUS
  26. + ',embed,iframe'
  27. // #endif
  28. ),
  29. // 只能被 rich-text 显示的标签
  30. richOnlyTags: makeMap('a,colgroup,fieldset,legend,picture,table'
  31. // #ifdef MP-WEIXIN
  32. + (canIUse ? ',bdi,bdo,caption,rt,ruby' : '')
  33. // #endif
  34. ),
  35. // 自闭合的标签
  36. selfClosingTags: makeMap(
  37. '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'
  38. ),
  39. // 信任的属性
  40. trustAttrs: makeMap(
  41. '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'
  42. ),
  43. // bool 型的属性
  44. boolAttrs: makeMap('autoplay,controls,ignore,loop,muted'),
  45. // 信任的标签
  46. trustTags: makeMap(
  47. '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'
  48. // #ifdef MP-WEIXIN
  49. + (canIUse ? ',bdi,bdo,caption,pre,rt,ruby' : '')
  50. // #endif
  51. // #ifdef APP-PLUS
  52. + ',embed,iframe'
  53. // #endif
  54. ),
  55. // 默认的标签样式
  56. userAgentStyles: {
  57. address: 'font-style:italic',
  58. big: 'display:inline;font-size:1.2em',
  59. blockquote: 'background-color:#f6f6f6;border-left:3px solid #dbdbdb;color:#6c6c6c;padding:5px 0 5px 10px',
  60. caption: 'display:table-caption;text-align:center',
  61. center: 'text-align:center',
  62. cite: 'font-style:italic',
  63. dd: 'margin-left:40px',
  64. img: 'max-width:100%',
  65. mark: 'background-color:yellow',
  66. picture: 'max-width:100%',
  67. pre: 'font-family:monospace;white-space:pre;overflow:scroll',
  68. s: 'text-decoration:line-through',
  69. small: 'display:inline;font-size:0.8em',
  70. u: 'text-decoration:underline'
  71. }
  72. }
  73. function makeMap(maprichee55text9oppplugin) {
  74. var map = {},
  75. list = maprichee55text9oppplugin.split(',');
  76. for (var i = list.length; i--;)
  77. map[list[i]] = true;
  78. return map;
  79. }