config.js 2.7 KB

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