config.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* 配置文件 */
  2. const canIUse = wx.canIUse('editor'); // 高基础库标识,用于兼容
  3. module.exports = {
  4. // 出错占位图
  5. errorImg: null,
  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. ndash: '–',
  19. mdash: '—',
  20. middot: '·',
  21. lsquo: '‘',
  22. rsquo: '’',
  23. ldquo: '“',
  24. rdquo: '”',
  25. bull: '•',
  26. hellip: '…'
  27. },
  28. blankChar: makeMap(' ,\xA0,\t,\r,\n,\f'),
  29. boolAttrs: makeMap('autoplay,autostart,controls,ignore,loop,muted'),
  30. // 块级标签,将被转为 div
  31. blockTags: makeMap('address,article,aside,body,caption,center,cite,footer,header,html,nav,section' + (canIUse ? '' : ',pre')),
  32. // 将被移除的标签
  33. ignoreTags: makeMap('area,base,canvas,frame,iframe,input,link,map,meta,param,script,source,style,svg,textarea,title,track,wbr' + (canIUse ? ',rp' : '')),
  34. // 只能被 rich-text 显示的标签
  35. richOnlyTags: makeMap('a,colgroup,fieldset,legend,table' + (canIUse ? ',bdi,bdo,rt,ruby' : '')),
  36. // 自闭合的标签
  37. selfClosingTags: makeMap('area,base,br,col,circle,ellipse,embed,frame,hr,img,input,line,link,meta,param,path,polygon,rect,source,track,use,wbr'),
  38. // 信任的标签
  39. trustTags: makeMap('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' + (canIUse ? ',bdi,bdo,caption,pre,rt,ruby' : '')),
  40. // 默认的标签样式
  41. userAgentStyles: {
  42. address: 'font-style:italic',
  43. big: 'display:inline;font-size:1.2em',
  44. blockquote: 'background-color:#f6f6f6;border-left:3px solid #dbdbdb;color:#6c6c6c;padding:5px 0 5px 10px',
  45. caption: 'display:table-caption;text-align:center',
  46. center: 'text-align:center',
  47. cite: 'font-style:italic',
  48. dd: 'margin-left:40px',
  49. mark: 'background-color:yellow',
  50. pre: 'font-family:monospace;white-space:pre;overflow:scroll',
  51. s: 'text-decoration:line-through',
  52. small: 'display:inline;font-size:0.8em',
  53. u: 'text-decoration:underline'
  54. }
  55. }
  56. function makeMap(str) {
  57. var map = Object.create(null),
  58. list = str.split(',');
  59. for (var i = list.length; i--;)
  60. map[list[i]] = true;
  61. return map;
  62. }