config.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. "use strict";
  2. function makeMap(e) {
  3. for (var a = {}, t = e.split(","), l = t.length; l--; ) a[t[l]] = !0;
  4. return a;
  5. }
  6. var canIUse = wx.canIUse("editor");
  7. module.exports = {
  8. filter(node, cxt) {
  9. if (node.name === "img" && node.attrs.style && node.attrs.style.length) {
  10. node.attrs.style = node.attrs.style
  11. .replace(/width:(\s*)auto(\s*)!important/, "")
  12. .replace(/height:(\s*)auto(\s*)!important/, "");
  13. }
  14. // node.attrs.style =
  15. // node.attrs.style +
  16. // ";font-size:18px !important;background-color:#ffffff;color:#333333;"; // 给标签添加某个属性
  17. },
  18. highlight: null,
  19. onText: null,
  20. blankChar: makeMap(" , ,\t,\r,\n,\f"),
  21. blockTags: makeMap(
  22. "address,article,aside,body,caption,center,cite,footer,header,html,nav,section" +
  23. (canIUse ? "" : ",pre")
  24. ),
  25. ignoreTags: makeMap(
  26. "area,base,basefont,canvas,command,embed,frame,iframe,input,isindex,keygen,link,map,meta,param,script,source,style,svg,textarea,title,track,use,wbr" +
  27. (canIUse ? ",rp" : "")
  28. ),
  29. richOnlyTags: makeMap(
  30. "a,colgroup,fieldset,legend,picture,table" +
  31. (canIUse ? ",bdi,bdo,rt,ruby" : "")
  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. trustAttrs: makeMap(
  37. "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"
  38. ),
  39. boolAttrs: makeMap("autoplay,controls,ignore,loop,muted"),
  40. trustTags: makeMap(
  41. "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" +
  42. (canIUse ? ",bdi,bdo,caption,pre,rt,ruby" : "")
  43. ),
  44. userAgentStyles: {
  45. address: "font-style:italic",
  46. big: "display:inline;font-size:1.2em",
  47. blockquote:
  48. "background-color:#f6f6f6;border-left:3px solid #dbdbdb;color:#6c6c6c;padding:5px 0 5px 10px",
  49. caption: "display:table-caption;text-align:center",
  50. center: "text-align:center",
  51. cite: "font-style:italic",
  52. dd: "margin-left:40px",
  53. mark: "background-color:yellow",
  54. pre: "font-family:monospace;white-space:pre;overflow:scroll",
  55. s: "text-decoration:line-through",
  56. small: "display:inline;font-size:0.8em",
  57. u: "text-decoration:underline",
  58. },
  59. };