Commit 059ecd20 authored by wangxuelai's avatar wangxuelai

''

parent c0f1af8c
/* Parser 小程序富文本插件 https://github.com/jin-yufeng/Parser */
"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Document;try{Document=require("./libs/document.js")}catch(t){}var parseHtmlSync=require("./libs/MpHtmlParser.js").parseHtmlSync,App=getApp();Component({created:function(){var t=this;this.navigateTo=function(e){e.success=e.success||function(){return null},e.fail=e.fail||function(){return null};var a=function(a){var o=t.createSelectorQuery();o.select(a).boundingClientRect(),o.selectViewport().scrollOffset(),o.exec(function(t){if(!t||!t[0])return e.fail({errMsg:"Label Not Found"});wx.pageScrollTo({scrollTop:t[1].scrollTop+t[0].top,success:e.success,fail:e.fail})})};a(e.id?"#contain >>> #"+e.id:"#contain")},this.getText=function(){var e="";if(!t.data.html)return"";var a=!0,o=!1,n=void 0;try{for(var r,i=(t.data.html.nodes||(t.data.html[0].name||t.data.html[0].type?t.data.html:t.data.nodes))[Symbol.iterator]();!(a=(r=i.next()).done);a=!0){var l=r.value;!function t(a){if("text"==a.type)return e+=a.text;"p"!=a.name&&"div"!=a.name&&"br"!=a.name||"\n"==e[e.length-1]||(e+="\n");var o=!0,n=!1,r=void 0;try{for(var i,l=a.children[Symbol.iterator]();!(o=(i=l.next()).done);o=!0){t(i.value)}}catch(t){n=!0,r=t}finally{try{!o&&l.return&&l.return()}finally{if(n)throw r}}}(l)}}catch(t){o=!0,n=t}finally{try{!a&&i.return&&i.return()}finally{if(o)throw n}}return e},this.getVideoContext=function(e){if(!e)return t.videoContexts;var a=!0,o=!1,n=void 0;try{for(var r,i=t.videoContexts[Symbol.iterator]();!(a=(r=i.next()).done);a=!0){var l=r.value;if(l.id==e)return l}}catch(t){o=!0,n=t}finally{try{!a&&i.return&&i.return()}finally{if(o)throw n}}return null},this._ready=function(e,a){e&&t.data.autosetTitle&&wx.setNavigationBarTitle({title:e}),t.imgList=a||[],t.videoContexts=[];var o=[t.selectComponent("#contain")];o=o.concat(t.selectAllComponents("#contain>>>.node"));var n=!0,r=!1,i=void 0;try{for(var l,s=o[Symbol.iterator]();!(n=(l=s.next()).done);n=!0){var u=l.value;u._top=t;var c=!0,d=!1,y=void 0;try{for(var v,m=u.data.nodes[Symbol.iterator]();!(c=(v=m.next()).done);c=!0){var f=v.value;if("video"==f.name){var h=wx.createVideoContext(f.attrs.id,u);h.id=f.attrs.id,t.videoContexts.push(h)}else"audio"==f.name&&f.attrs.autoplay&&wx.createAudioContext(f.attrs.id,u).play()}}catch(t){d=!0,y=t}finally{try{!c&&m.return&&m.return()}finally{if(d)throw y}}}}catch(t){r=!0,i=t}finally{try{!n&&s.return&&s.return()}finally{if(r)throw i}}(wx.nextTick||setTimeout)(function(){var e=!0,a=!1,n=void 0;try{for(var r,i=o[Symbol.iterator]();!(e=(r=i.next()).done);e=!0){var l,s;!function(){var e=r.value;l=!1;var a=!0,o=!1,n=void 0;try{for(var i,u=e.data.nodes[Symbol.iterator]();!(a=(i=u.next()).done);a=!0)s=i.value,"img"!=s.name||l||(l=!0,t.data.lazyLoad&&e.createIntersectionObserver?(e._observer=e.createIntersectionObserver(),e._observer.relativeToViewport({top:1e3,bottom:1e3}).observe(".img",function(t){e.setData({imgLoad:!0}),e._observer.disconnect(),e._observer=null})):e.setData({imgLoad:!0}))}catch(t){o=!0,n=t}finally{try{!a&&u.return&&u.return()}finally{if(o)throw n}}}()}}catch(t){a=!0,n=t}finally{try{!e&&i.return&&i.return()}finally{if(a)throw n}}t.createSelectorQuery().select("#contain").boundingClientRect(function(e){t.triggerEvent("ready",e)}).exec()},50)}},properties:{html:{type:null,value:"",observer:function(t){var e={},a={};if(this.data.showWithAnimation&&(e=wx.createAnimation({duration:this.data.animationDuration,timingFunction:"ease"}).opacity(0).step().export(),a=wx.createAnimation({duration:this.data.animationDuration,timingFunction:"ease"}).opacity(1).step().export()),t)if("string"==typeof t){var o;this.data.cacheId?(App.globalData=App.globalData||{},App.globalData[this.data.cacheId]?o=App.globalData[this.data.cacheId]:(o=parseHtmlSync(t,this.data),App.globalData[this.data.cacheId]=o)):o=parseHtmlSync(t,this.data),this.setData({nodes:o.nodes,controls:{imgMode:this.data.imgMode},showAnimation:a,hideAnimation:e}),this.triggerEvent("parse",o),Document&&(this.document=new Document("nodes",o.nodes,this)),this._ready(o.title,o.imgList)}else if(t.constructor==Array)this.setData({controls:{imgMode:this.data.imgMode},showAnimation:a,hideAnimation:e}),Document&&(this.document=new Document("html",t,this)),this._ready();else if("object"==(void 0===t?"undefined":_typeof(t))){if(!t.nodes||t.nodes.constructor!=Array){if(t.name&&t.children&&t.attrs||"text"==t.type)return;return void this.triggerEvent("error",{source:"parse",errMsg:"传入的nodes数组格式不正确!应该传入的类型是array,实际传入的类型是:"+_typeof(t.nodes)})}this.setData({controls:{imgMode:this.data.imgMode},showAnimation:a,hideAnimation:e}),Document&&(this.document=new Document("html.nodes",t.nodes,this)),this._ready(t.title,t.imgList)}else this.triggerEvent("error",{source:"parse",errMsg:"错误的html类型:"+(void 0===t?"undefined":_typeof(t))});else this.setData({nodes:[]})}},autocopy:{type:Boolean,value:!0},autopause:{type:Boolean,value:!0},autopreview:{type:Boolean,value:!0},autosetTitle:{type:Boolean,value:!0},cacheId:{type:String,value:null},domain:{type:String,value:null},imgMode:{type:String,value:"default"},lazyLoad:{type:Boolean,value:!1},selectable:{type:Boolean,value:!1},tagStyle:{type:Object,value:{}},showWithAnimation:{type:Boolean,value:!1},animationDuration:{type:Number,value:400},useAnchor:{type:Boolean,value:!1}},methods:{_playVideo:function(t){if(this.videoContexts.length>1&&this.data.autopause){var e=!0,a=!1,o=void 0;try{for(var n,r=this.videoContexts[Symbol.iterator]();!(e=(n=r.next()).done);e=!0){var i=n.value;i.id!=t.detail&&i.context.pause()}}catch(t){a=!0,o=t}finally{try{!e&&r.return&&r.return()}finally{if(a)throw o}}}}}});
\ No newline at end of file
{"component":true,"usingComponents":{"trees":"./trees/trees"}}
\ No newline at end of file
<slot wx:if="{{!(html.nodes||((html[0].name||html[0].type)?1:nodes.length))}}" animation="{{hideAnimation}}"></slot><trees id="contain" style="{{(showWithAnimation?'opacity:0;':'')+(selectable?'user-select:text;-webkit-user-select:text':'')}}" animation="{{showAnimation}}" nodes="{{html.nodes||((html[0].name||html[0].type)?html:nodes)}}" controls="{{controls}}" lazy-load="{{lazyLoad}}" />
\ No newline at end of file
:host{display:block;overflow:scroll;-webkit-overflow-scrolling:touch}
\ No newline at end of file
/* Parser富文本插件 https://github.com/jin-yufeng/Parser */
"use strict";function _classCallCheck(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function isBlankChar(t){return" "==t||"\t"==t||"\r"==t||"\n"==t||"\v"==t||"\f"==t}var _createClass=function(){function t(t,s){for(var i=0;i<s.length;i++){var e=s[i];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,e.key,e)}}return function(s,i,e){return i&&t(s.prototype,i),e&&t(s,e),s}}(),config=require("./config.js"),CssHandler=function(){function t(s){_classCallCheck(this,t),this.parseCss=function(t){return new CssParser(t,{},!0).parse()},this.styles=s}return _createClass(t,[{key:"getStyle",value:function(t){var s="";return t=t.replace(/<style[\s\S]*?>([\s\S]*?)<\/style[\s\S]*?>/g,function(){return s+=arguments[1],""}),this.styles=new CssParser(s,this.styles).parse(),t}},{key:"match",value:function(t,s){var i=(this.styles[t]||"")+";";if(s.class)for(var e=s.class.split(" "),a=0;a<e.length;a++)i+=(this.styles["."+e[a]]||"")+";";return s.id&&(i+=(this.styles["#"+s.id]||"")+";"),";"==i?"":i}}]),t}();module.exports=CssHandler;var CssParser=function(){function t(s){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e=arguments[2];_classCallCheck(this,t),this.data=s,this.res=e?i:this.merge(i),this._floor=0,this._i=0,this._list=[],this._comma=!1,this._sectionStart=0,this._stateHandler=this.SpaceHandler}return _createClass(t,[{key:"merge",value:function(t){var s=JSON.parse(JSON.stringify(config.userAgentStyles));for(var i in t)s[i]=(s[i]||"")+t[i];return s}},{key:"parse",value:function(){for(;this._i<this.data.length;this._i++)this._stateHandler(this.data[this._i]);return this.res}},{key:"SpaceHandler",value:function(t){"."==t||"#"==t||t>="a"&&t<="z"||t>="A"&&t<="Z"?(this._sectionStart=this._i,this._stateHandler=this.StyleNameHandler):"/"==t&&"*"==this.data[this._i+1]?this.CommentHandler():isBlankChar(t)||";"==t||(this._stateHandler=this.IgnoreHandler)}},{key:"CommentHandler",value:function(){this._i=this.data.indexOf("*/",this._i),-1==this._i&&(this._i=this.data.length),this._i++,this._stateHandler=this.SpaceHandler}},{key:"IgnoreHandler",value:function(t){"{"==t?this._floor++:"}"==t&&--this._floor<=0&&(this._list=[],this._stateHandler=this.SpaceHandler)}},{key:"StyleNameHandler",value:function(t){isBlankChar(t)?(this._list.push(this.data.substring(this._sectionStart,this._i)),this._stateHandler=this.NameSpaceHandler):"{"==t?(this._list.push(this.data.substring(this._sectionStart,this._i)),this._floor=1,this._sectionStart=this._i+1,this.ContentHandler()):","==t?(this._list.push(this.data.substring(this._sectionStart,this._i)),this._sectionStart=this._i+1,this._comma=!0):t>="a"&&t<="z"||t>="A"&&t<="Z"||t>="0"&&t<="9"||"."==t||"#"==t||"-"==t||"_"==t||(this._stateHandler=this.IgnoreHandler)}},{key:"NameSpaceHandler",value:function(t){"{"==t?(this._floor=1,this._sectionStart=this._i+1,this.ContentHandler()):","==t?(this._comma=!0,this._sectionStart=this._i+1,this._stateHandler=this.StyleNameHandler):isBlankChar(t)||(this._comma?(this._stateHandler=this.StyleNameHandler,this._sectionStart=this._i,this._i--,this._comma=!1):this._stateHandler=this.IgnoreHandler)}},{key:"ContentHandler",value:function(){this._i=this.data.indexOf("}",this._i),-1==this._i&&(this._i=this.data.length);for(var t,s=!1,i=this.data.substring(this._sectionStart,this._i),e=0;e<i.length;e++)isBlankChar(i[e])?s||(t=e,s=!0):s&&(0==t?i=i.substring(e):e-t>1&&(i=i.substring(0,t)+" "+i.substring(e)),e=t,s=!1);s&&(i=i.substring(0,t));for(var e=0;e<this._list.length;e++)this.res[this._list[e]]=(this.res[this._list[e]]||"")+i;this._list=[],this._stateHandler=this.SpaceHandler}}]),t}();
\ No newline at end of file
/* Parser富文本插件 https://github.com/jin-yufeng/Parser */
"use strict";function _classCallCheck(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function isBlankChar(t){return void 0!=t&&(" "==t||"\t"==t||"\r"==t||"\n"==t||"\v"==t||"\f"==t)}var _createClass=function(){function t(t,i){for(var s=0;s<i.length;s++){var e=i[s];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,e.key,e)}}return function(i,s,e){return s&&t(i.prototype,s),e&&t(i,e),i}}(),CssHandler=require("./CssHandler.js"),config=require("./config.js"),emoji;try{emoji=require("./emoji.js")}catch(t){}var MpHtmlParser=function(){function t(i){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e=arguments[2];_classCallCheck(this,t),this.cb=e,this.CssHandler=new CssHandler(s.tagStyle),this.data=i,this.DOM=[],this.imgList=[],this.title="",this._attrName="",this._attrValue="",this._attrs={},this._domain=s.domain,this._protocol=s.domain?s.domain.includes("://")?this._domain.split("://")[0]:"http":void 0,this._i=0,this._sectionStart=0,this._stateHandler=this.TextHandler,this._STACK=[],this._tagName="",this._audioNum=0,this._videoNum=0,this._useAnchor=s.useAnchor,this._whiteSpace=!1}return _createClass(t,[{key:"parse",value:function(){for(this.CssHandler&&(this.data=this.CssHandler.getStyle(this.data));this._i<this.data.length;this._i++)this._stateHandler(this.data[this._i]);for(this._stateHandler==this.TextHandler&&this.setText();this._STACK.length;)this.popNode(this._STACK.pop());var t={title:this.title,nodes:this.DOM,imgList:this.imgList};if(!this.cb)return t;this.cb(t)}},{key:"TextHandler",value:function(t){if("<"==t){var i=this.data[this._i+1];i>="a"&&i<="z"||i>="A"&&i<="Z"?(this.setText(),this._stateHandler=this.TagNameHandler):"/"==i?(this.setText(),this._i++,i=this.data[this._i+1],i>="a"&&i<="z"||i>="A"&&i<="Z"?(this._sectionStart=this._i+1,this._stateHandler=this.EndTagHandler):this._stateHandler=this.CommentHandler):"!"==i&&(this.setText(),this._stateHandler=this.CommentHandler)}}},{key:"CommentHandler",value:function(){if("--"==this.data.substring(this._i+1,this._i+3)||"[CDATA["==this.data.substring(this._i+1,this._i+7)){if(this._i=this.data.indexOf("--\x3e",this._i+1),-1==this._i)return this._i=this.data.length;this._i=this._i+2}else if(this._i=this.data.indexOf(">",this._i+1),-1==this._i)return this._i=this.data.length;this._sectionStart=this._i+1,this._stateHandler=this.TextHandler}},{key:"TagNameHandler",value:function(t){isBlankChar(t)?(this._tagName=this.getSelection(!0),this.checkClose()?this.setNode():this._stateHandler=this.AttrNameHandler):this.checkClose()&&(this._tagName=this.getSelection(),this.setNode())}},{key:"AttrNameHandler",value:function(t){if(isBlankChar(t))if(this._attrName=this.getSelection(!0),"="==this.data[this._i]){for(;isBlankChar(this.data[++this._i]););this._sectionStart=this._i,this._i--,this._stateHandler=this.AttrValueHandler}else this.setAttr();else if("="==t){for(this._attrName=this.getSelection();isBlankChar(this.data[++this._i]););this._sectionStart=this._i,this._i--,this._stateHandler=this.AttrValueHandler}else this.checkClose()&&(this._attrName=this.getSelection(),this.setAttr())}},{key:"AttrValueHandler",value:function(t){if('"'==t||"'"==t){if(this._sectionStart++,-1==(this._i=this.data.indexOf(t,this._i+1)))return this._i=this.data.length}else for(;!isBlankChar(this.data[this._i]&&"/"!=this.data[this._i]&&">"!=this.data[this._i]);this._i++);for(this._attrValue=this.getSelection();this._attrValue.includes("&quot;");)this._attrValue=this._attrValue.replace("&quot;","");this.setAttr()}},{key:"EndTagHandler",value:function(t){if(isBlankChar(t)||">"==t||"/"==t){for(var i=this.getSelection().toLowerCase(),s=!1,e=this._STACK.length-1;e>=0;e--)if(this._STACK[e].name==i){s=!0;break}if(s)for(var a;s;)a=this._STACK.pop(),a.name==i&&(s=!1),this.popNode(a);else if("p"==i||"br"==i){var h=this._STACK.length?this._STACK[this._STACK.length-1].children:this.DOM,a={name:i,attrs:{},children:[]};h.push(a)}this._i=this.data.indexOf(">",this._i),-1==this._i?this._i=this.data.length:this._stateHandler=this.TextHandler}}},{key:"checkClose",value:function(){return">"==this.data[this._i]||"/"==this.data[this._i]&&">"==this.data[this._i+1]}},{key:"getSelection",value:function(t){for(var i=this._sectionStart==this._i?"":this.data.substring(this._sectionStart,this._i);t&&isBlankChar(this.data[++this._i]););return t&&this._i--,this._sectionStart=this._i+1,i}},{key:"setAttr",value:function(){for(config.trustAttrs[this._attrName]&&(this._attrs[this._attrName]=this._attrValue||"true"),this._attrValue="";isBlankChar(this.data[this._i]);)this._i++;this.checkClose()?this.setNode():this._stateHandler=this.AttrNameHandler}},{key:"setText",value:function(){var t=this.getSelection();if(t){if(!this._whiteSpace){for(var i,s=!1,e=!1,a=0;a<t.length;a++)isBlankChar(t[a])?s||(i=a,s=!0):(e=!0,s&&(a-i>1&&(t=t.substring(0,i)+" "+t.substring(a)),a=i,s=!1));if(s&&(t=t.substring(0,i)+" "),!t||!e)return}for(emoji&&(t=emoji.parseEmoji(t));t.includes("&nbsp;");)t=t.replace("&nbsp;"," ");for(var h,r,a=t.indexOf("&");-1!=a&&a<t.length;){if((h=t.indexOf(";",a))-a>=2&&h-a<=6){var n=t.substring(a,h);if(!n.includes("sp")&&!n.includes("lt")&&!n.includes("gt")){r=!0;break}}a=t.indexOf("&",a+1)}var l=this._STACK.length?this._STACK[this._STACK.length-1].children:this.DOM;if(l.length&&"text"==l[l.length-1].type)l[l.length-1].text+=t,r&&(l[l.length-1].decode=!0);else{var d={type:"text",text:t,decode:r};r&&(d.decode=!0),l.push(d)}}}},{key:"bubbling",value:function(){for(var t=this._STACK.length-1;t>=0;t--){if(0===config.trustTags[this._STACK[t].name])return this._STACK[t].name;this._STACK[t].continue=!0}}},{key:"setNode",value:function(){var t=this._STACK.length?this._STACK[this._STACK.length-1].children:this.DOM,i={name:this._tagName.toLowerCase(),attrs:this._attrs,children:[]};if(config.LabelAttrsHandler(i,this),this._useAnchor&&i.attrs.id&&this.bubbling(),this._attrs={},!config.selfClosingTags[this._tagName]){if(config.ignoreTags[i.name]||"title"==i.name){for(var s=++this._i;this._i<this.data.length;){if(this._i=this.data.indexOf("</",this._i),-1==this._i)return this._i=this.data.length;for(this._i+=2,this._sectionStart=this._i;!isBlankChar(this.data[this._i])&&">"!=this.data[this._i]&&"/"!=this.data[this._i];)this._i++;if(this.data.substring(this._sectionStart,this._i).toLowerCase()==i.name){"title"==i.name&&(this.title=this.data.substring(s,this._sectionStart-2)),this._i=this.data.indexOf(">",this._i),-1==this._i?this._i=this.data.length:this._sectionStart=this._i+1,this._stateHandler=this.TextHandler;break}}return}this._STACK.push(i),"pre"==i.name&&(this._whiteSapce=!0,i.pre=!0,config.highlight&&(this._sectionStart=this._i+1,this._i=this.data.indexOf("</pre",this._sectionStart),this.data=this.data.substring(0,this._sectionStart)+config.highlight(this.data.substring(this._sectionStart,this._i),i.attrs)+this.data.substring(this._i),this._i=this._sectionStart-1))}if("/"==this.data[this._i]&&this._i++,this._sectionStart=this._i+1,this._stateHandler=this.TextHandler,!config.ignoreTags[i.name]){i.attrs.style=this.CssHandler.match(i.name,i.attrs,i)+(i.attrs.style||""),i.attrs.style||delete i.attrs.style;for(var e=i.attrs.style?i.attrs.style.toLowerCase().split(";"):[],a=0;a<e.length;a++)if(e[a].includes("white-space")&&e[a].includes("pre")){this._whiteSpace=!0,i.pre=!0;break}t.push(i)}}},{key:"popNode",value:function(t){if(config.blockTags[t.name]?t.name="div":config.trustTags.hasOwnProperty(t.name)||(t.name="span"),t.pre){this._whiteSpace=!1,delete t.pre;for(var i=0;i<this._STACK.length;i++)this._STACK[i].pre&&(this._whiteSpace=!0)}if("table"==t.name){if(t.attrs.style=t.attrs.style||"",t.attrs.border&&(t.attrs.style+=";border:"+t.attrs.border+"px solid gray;"),t.attrs.hasOwnProperty("cellspacing")&&(t.attrs.style+=";border-spacing:"+t.attrs.cellspacing+"px"),t.attrs.border||t.attrs.hasOwnProperty("cellpadding"))for(var i=0;i<t.children.length;i++)!function i(s){if("th"==s.name||"td"==s.name)return t.attrs.border&&(s.attrs.style=(s.attrs.style||"")+";border:"+t.attrs.border+"px solid gray;"),void(t.attrs.hasOwnProperty("cellpadding")&&(s.attrs.style=(s.attrs.style||"")+";padding:"+t.attrs.cellpadding+"px"));if("text"!=s.type)for(var e=0;e<s.children.length;e++)i(s.children[e])}(t.children[i])}if(1==t.children.length&&"div"==t.name&&"div"==t.children[0].name){var s=t.children[0];t.attrs.style=t.attrs.style||"",s.attrs.style=s.attrs.style||"",!(t.attrs.style.includes("padding")&&(t.attrs.style.includes("margin")||s.attrs.style.includes("margin"))&&t.attrs.style.includes("display")&&s.attrs.style.includes("display"))||t.attrs.id&&t.attrs.id||t.attrs.class&&s.attrs.class||(s.attrs.style.includes("padding")&&(s.attrs.style="box-sizing:border-box;"+s.attrs.style),t.attrs.style=t.attrs.style+";"+s.attrs.style,t.attrs.id=(s.attrs.id||"")+(t.attrs.id||""),t.attrs.class=(s.attrs.class||"")+(t.attrs.class||""),t.children=s.children)}this.CssHandler.pop&&this.CssHandler.pop(t)}}]),t}();module.exports={parseHtml:function(t,i){return new Promise(function(s){return new MpHtmlParser(t,i,s).parse()})},parseHtmlSync:function(t,i){return new MpHtmlParser(t,i).parse()}};
\ No newline at end of file
"use strict";var trustTags={a:0,abbr:1,ad:0,audio:0,b:1,blockquote:1,br:0,code:1,col:0,colgroup:0,dd:1,del:1,dl:1,dt:1,div:1,em:1,fieldset:0,font:1,h1:0,h2:0,h3:0,h4:0,h5:0,h6:0,hr:0,i:1,img:1,ins:1,label:1,legend:0,li:0,ol:0,p:1,q:1,source:0,span:1,strong:1,sub:0,sup:0,table:0,tbody:0,td:0,tfoot:0,th:0,thead:0,tr:0,u:1,ul:0,video:1},blockTags={address:!0,article:!0,aside:!0,body:!0,center:!0,cite:!0,footer:!0,header:!0,html:!0,nav:!0,pre:!0,section:!0},ignoreTags={area:!0,base:!0,basefont:!0,canvas:!0,circle:!0,command:!0,ellipse:!0,embed:!0,frame:!0,head:!0,iframe:!0,input:!0,isindex:!0,keygen:!0,line:!0,link:!0,map:!0,meta:!0,param:!0,path:!0,polygon:!0,polyline:!0,rect:!0,script:!0,source:!0,textarea:!0,title:!0,track:!0,use:!0,wbr:!0},userAgentStyles={a:"display:inline;color:#366092;word-break:break-all;",address:"font-style:italic;",blockquote:"background-color:#f6f6f6;border-left:3px solid #dbdbdb;color:#6c6c6c;padding:5px 0 5px 10px;",center:"text-align:center;",cite:"font-style:italic;",code:"padding:0 1px 0 1px;margin-left:2px;margin-right:2px;background-color:#f8f8f8;border-radius:3px;",dd:"margin-left:40px;",img:"max-width:100%;",mark:"display:inline;background-color:yellow;",pre:"font-family:monospace;white-space:pre;overflow:scroll;",s:"display:inline;text-decoration:line-through;",u:"display:inline;text-decoration:underline;"},SDKVersion=wx.getSystemInfoSync().SDKVersion,versionHigherThan=function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=SDKVersion.split("."),s=t.split("."),r=Math.max(e.length,s.length);e.length<r;)e.push("0");for(;s.length<r;)s.push("0");for(var a=0;a<r;a++){var i=parseInt(e[a]),l=parseInt(s[a]);if(i>l)return!0;if(i<l)return!1}return!0};versionHigherThan("2.7.1")?(trustTags.bdi=0,trustTags.bdo=0,trustTags.caption=0,trustTags.rt=0,trustTags.ruby=0,ignoreTags.rp=!0,trustTags.big=1,trustTags.small=1,trustTags.pre=0,delete blockTags.pre):(blockTags.caption=!0,userAgentStyles.big="display:inline;font-size:1.2em;",userAgentStyles.small="display:inline;font-size:0.8em;"),module.exports={highlight:null,LabelAttrsHandler:function(t,e){switch(t.name){case"div":case"p":t.attrs.align&&(t.attrs.style="text-align:"+t.attrs.align+";"+(t.attrs.style||""),delete t.attrs.align);break;case"img":t.attrs["data-src"]&&(t.attrs.src=t.attrs.src||t.attrs["data-src"],delete t.attrs["data-src"]),!t.attrs.ignore&&t.attrs.src&&(e.imgList.includes(t.attrs.src)&&t.attrs.src.includes("http")&&(t.attrs.src=t.attrs.src+(t.attrs.src.includes("?")?"&":"?")+"parserid="+e.imgList.length),e.imgList.push(t.attrs.src),"a"==e.bubbling()&&(t.attrs.ignore="true")),e._domain&&"/"==t.attrs.src[0]&&("/"==t.attrs.src[1]?t.attrs.src=e._protocol+":"+t.attrs.src:t.attrs.src=e._domain+t.attrs.src);break;case"a":case"ad":e.bubbling();break;case"font":if(name="span",t.attrs.style=t.attrs.style||"",t.attrs.color&&(t.attrs.style="color:"+t.attrs.color+";"+t.attrs.style,delete t.attrs.color),t.attrs.face&&(t.attrs.style="font-family:"+t.attrs.face+";"+t.attrs.style,delete t.attrs.face),t.attrs.size){var s=parseInt(attrs.size);s<1?s=1:s>7&&(s=7);var r=[10,13,16,18,24,32,48];t.attrs.style="font-size:"+r[s-1]+"px;"+t.attrs.style,delete t.attrs.size}break;case"video":case"audio":t.attrs.id?e["_"+t.name+"Num"]++:t.attrs.id=t.name+ ++e["_"+t.name+"Num"],"video"==t.name&&(t.attrs.style=t.attrs.style||"",t.attrs.width&&(t.attrs.style="width:"+parseFloat(t.attrs.width)+(t.attrs.width.includes("%")?"%":"px")+";"+t.attrs.style,delete t.attrs.width),t.attrs.height&&(t.attrs.style="height:"+parseFloat(t.attrs.height)+(t.attrs.height.includes("%")?"%":"px")+";"+t.attrs.style,delete t.attrs.height),e._videoNum>3&&(t.lazyLoad=!0)),t.attrs.source=[],t.attrs.src&&t.attrs.source.push(t.attrs.src),t.attrs.controls||t.attrs.autoplay||console.warn("存在没有controls属性的"+t.name+"标签,可能导致无法播放",t),e.bubbling();break;case"source":var a=e._STACK[e._STACK.length-1];!a||"video"!=a.name&&"audio"!=a.name||(a.attrs.source.push(t.attrs.src),a.attrs.src||(a.attrs.src=t.attrs.src))}},trustAttrs:{align:!0,alt:!0,author:!0,autoplay:!0,border:!0,cellpadding:!0,cellspacing:!0,class:!0,color:!0,colspan:!0,controls:!0,"data-src":!0,dir:!0,face:!0,height:!0,href:!0,id:!0,ignore:!0,loop:!0,muted:!0,name:!0,poster:!0,rowspan:!0,size:!0,span:!0,src:!0,start:!0,style:!0,type:!0,"unit-id":!0,width:!0},selfClosingTags:{area:!0,base:!0,basefont:!0,br:!0,col:!0,circle:!0,ellipse:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,isindex:!0,keygen:!0,line:!0,link:!0,meta:!0,param:!0,path:!0,polygon:!0,polyline:!0,rect:!0,source:!0,track:!0,use:!0,wbr:!0},trustTags:trustTags,blockTags:blockTags,ignoreTags:ignoreTags,userAgentStyles:userAgentStyles,versionHigherThan:versionHigherThan};
\ No newline at end of file
"use strict";var inlineTags={abbr:!0,b:!0,big:!0,code:!0,del:!0,em:!0,font:!0,i:!0,ins:!0,label:!0,mark:!0,q:!0,s:!0,small:!0,span:!0,strong:!0,u:!0};module.exports={getStyle:function(t,e){res="";var s=getRegExp("float[^;]+(?![sS]*?float)","i");return s.test(t)&&(res+=s.exec(t)[0]),s=getRegExp("margin[^;]+","gi"),s.test(t)&&(res+=";"+t.match(s).join(";")),s=getRegExp("displays*:s*([^;]*)(?![sS]*?display)","i"),s.test(t)&&"flex"!=s.exec(t)[1]?res+=";"+s.exec(t)[0]:res+=";display:"+e,s=getRegExp("flex[^;]*:[^;]+","ig"),s.test(t)&&(res+=";"+t.match(s).join(";")),s=getRegExp("[^;s]*width[^;]+","ig"),s.test(t)&&(res+=";"+t.match(s).join(";")),res},setImgStyle:function(t,e,s){return"widthFix"==e&&(t.attrs.style+=";height:auto !important"),t.attrs.style&&(t.attrs.style=t.attrs.style.replace(getRegExp("width[^;]*?%","gi"),"width:100%").replace(getRegExp("margin[^;]+","gi"),"")),s||(delete t.attrs.src,t.attrs.style+=";width:5px !important;height:5px !important"),[t]},setStyle:function(t){return t.attrs.style&&(t.attrs.style=t.attrs.style.replace(getRegExp("width[^;]*?%","gi"),"width:100%").replace(getRegExp("margin[^;]+","gi"),"")),[t]},notContinue:function(t){return"a"==t.name||"li"==t.name||"ol"==t.name||"ul"==t.name||!(t["continue"]||inlineTags[t.name])}};
\ No newline at end of file
/* Parser富文本插件 https://github.com/jin-yufeng/Parser */
"use strict";Component({data:{imgLoad:!1},created:function(){var t=this;this.triggerError=function(r,e,o,a,i){t._top&&t._top.triggerEvent("error",{source:r,target:e,errMsg:o,errCode:a,context:i})},this.loadSource=function(r){return!t.data.controls[r.id]&&r.source.length>1?(t.data.controls[r.id]={play:!1,index:1},t.setData({controls:t.data.controls}),!0):!!(t.data.controls[r.id]&&r.source.length>t.data.controls[r.id].index+1)&&(t.data.controls[r.id].index++,t.setData({controls:t.data.controls}),!0)}},detached:function(){this._observer&&this._observer.disconnect()},properties:{nodes:{type:Array,value:[]},controls:{type:Object,value:{}}},methods:{playEvent:function(t){if(this._top&&this._top.videoContexts.length>1&&this._top.data.autopause){var r=!0,e=!1,o=void 0;try{for(var a,i=this._top.videoContexts[Symbol.iterator]();!(r=(a=i.next()).done);r=!0){var n=a.value;n.id!=t.currentTarget.dataset.id&&n.pause()}}catch(t){e=!0,o=t}finally{try{!r&&i.return&&i.return()}finally{if(e)throw o}}}},previewEvent:function(t){if(this._top&&!t.target.dataset.hasOwnProperty("ignore")){var r=!0,e=t.currentTarget.dataset.src;this._top.triggerEvent("imgtap",{id:t.currentTarget.id,src:e,ignore:function(){return r=!1}}),r&&this._top.data.autopreview&&wx.previewImage({current:e,urls:this._top.imgList.length?this._top.imgList:[e]})}},tapEvent:function(t){if(this._top){var r=!0,e=t.currentTarget.dataset.href;this._top.triggerEvent("linkpress",{href:e,ignore:function(){return r=!1}}),r&&e&&("#"==e[0]?this._top.data.useAnchor&&this._top.navigateTo({id:e.substring(1)}):/^http/.test(e)?this._top.data.autocopy&&wx.setClipboardData({data:e,success:function(){wx.showToast({title:"链接已复制"})}}):wx.navigateTo({url:e}))}},adError:function(t){this.triggerError("ad",t.currentTarget,t.detail.errMsg,t.detail.errCode)},videoError:function(t){!this.loadSource(t.currentTarget.dataset)&&this._top&&this.triggerError("video",t.currentTarget,t.detail.errMsg,void 0,this._top.getVideoContext(t.currentTarget.id))},audioError:function(t){this.loadSource(t.currentTarget.dataset)||this.triggerError("audio",t.currentTarget,t.detail.errMsg)},loadVideo:function(t){this.data.controls[t.currentTarget.dataset.id]={play:!0,index:0},this.setData({controls:this.data.controls})}}});
\ No newline at end of file
{"component":true,"usingComponents":{"trees":"./trees"}}
\ No newline at end of file
<wxs module="Handler" src="./handler.wxs" /><block wx:for='{{nodes}}' wx:key="index"><block wx:if="{{Handler.notContinue(item)}}"><rich-text wx:if="{{item.name=='img'}}" id="{{item.attrs.id}}" class="img" style="text-indent:0;{{Handler.getStyle(item.attrs.style,'inline-block')}}" nodes='{{Handler.setImgStyle(item,controls.imgMode,imgLoad)}}' data-ignore='{{item.attrs.ignore}}' data-src='{{item.attrs.src}}' bindtap='previewEvent' /><block wx:elif="{{item.type=='text'}}"><text wx:if="{{!item.decode}}" decode>{{item.text}}</text><rich-text wx:else style="display:inline-block" nodes="{{[item]}}"></rich-text></block><text wx:elif="{{item.name=='br'}}">\n</text><block wx:elif="{{item.name=='video'}}"><view wx:if="{{item.lazyLoad&&!controls[item.attrs.id].play}}" class="pvideo {{item.attrs.class||''}}" style="{{item.attrs.style}}" data-id="{{item.attrs.id}}" bindtap="loadVideo"><view class="video-triangle" /></view><video wx:else src='{{controls[item.attrs.id]?item.attrs.source[controls[item.attrs.id].index]:item.attrs.src}}' id="{{item.attrs.id}}" loop='{{item.attrs.loop}}' controls='{{item.attrs.controls}}' autoplay="{{item.attrs.autoplay||controls[item.attrs.id].play}}" unit-id="{{item.attrs['unit-id']}}" class="v {{item.attrs.class||''}}" muted="{{item.attrs.muted}}" style="{{item.attrs.style}}" data-id="{{item.attrs.id}}" data-source="{{item.attrs.source}}" bindplay='playEvent' binderror="videoError" /></block><audio wx:elif="{{item.name=='audio'}}" id="{{item.attrs.id}}" class="{{item.attrs.class}}" src='{{controls[item.attrs.id]?item.attrs.source[controls[item.attrs.id].index]:item.attrs.src}}' loop='{{item.attrs.loop}}' controls='{{item.attrs.controls}}' poster='{{item.attrs.poster}}' name='{{item.attrs.name}}' author='{{item.attrs.author}}' style="{{item.attrs.style}}" data-id="{{item.attrs.id}}" data-source="{{item.attrs.source}}" binderror="audioError" /><view wx:elif="{{item.name=='a'}}" url="{{item.attrs.href}}" class="a {{item.attrs.class||''}}" style="{{item.attrs.style}}" data-href='{{item.attrs.href}}' hover-class="navigator-hover" hover-start-time="25" hover-stay-time="300" bindtap="tapEvent"><trees class="node" nodes="{{item.children}}" controls="{{controls}}" /></view><ad wx:elif="{{item.name=='ad'}}" unit-id="{{item.attrs['unit-id']}}" class="{{item.attrs.class}}" style="{{item.attrs.style}}" binderror="adError"></ad><rich-text wx:else id="{{item.attrs.id}}" class="{{item.name}}" style="{{Handler.getStyle(item.attrs.style,'block')}}" nodes="{{Handler.setStyle(item)}}" /></block><trees wx:else id="{{item.attrs.id}}" class="node {{item.name+' '+(item.attrs.class||'')}}" style="{{item.attrs.style}}" nodes="{{item.children}}" controls="{{controls}}" /></block>
\ No newline at end of file
.navigator-hover{opacity:.7;text-decoration:underline}:host{display:inherit;float:inherit}.a{display:inline;color:#366092}.sub,.sup,.bdo,.bdi,.ruby,.rt{display:inline-block!important}.div,.blockquote,.p{display:block}.b,.strong{display:inline;font-weight:bold}.em,.i{display:inline;font-style:italic}.del{display:inline;text-decoration:line-through}.ins{display:inline;text-decoration:underline}.code{display:inline;font-family:monospace}.big{font-size:1.2em;display:inline}.small{font-size:.8em;display:inline}.q,.span,.label,.abbr{display:inline}.q::before{content:'"'}.q::after{content:'"'}.pvideo{background-color:black;width:300px;height:225px;display:inline-block;position:relative}.video-triangle{border-width:15px 0 15px 30px;border-style:solid;border-color:transparent transparent transparent white;position:absolute;left:50%;top:50%;margin:-15px 0 0 -15px}
\ No newline at end of file
export default {
imageRoot: 'https://cdn.img.shangjiadao.cn/qingxiao/daka/images/',
host: 'https://qxapi.qingxiao.online/daka',
host2: 'https://wx.m.shangjiadao.cn',
// host: 'https://qxapi.qingxiao.online/daka',
// host2: 'https://wx.m.shangjiadao.cn',
storageVersion: '4.0',
imageVersion: '20191104',
// host: 'https://clock.wp53.cn',
// host2: 'https://test.wp53.cn',
host: 'https://clock.wp53.cn',
host2: 'https://test.wp53.cn',
appId: 'wxc1246ea029394785',
miniProgram: {
clock: 'wxdeee20e52a1fd7ee'
......
......@@ -517,7 +517,6 @@ Page({
let failVideos = imageBox.filter(ele => (ele.status == 'fail' && ele.type == 'video'));
let fullfilledImages = imageBox.filter(ele => ele.status == 'fullfilled');
let notUploadedImagesAndVideo = imageBox.filter(ele => (ele.status == 'resolving' || ele.status == 'pending'));
console.log(notUploadedImagesAndVideo, 'notUploadedImagesAndVideo');
if (notUploadedImagesAndVideo.length > 0) {
wx.showToast({
title: '您的打卡内容尚未全部上传,请稍后...',
......@@ -874,6 +873,7 @@ Page({
}
})
that.data.uploadVideoTask[`${filename}`].onProgressUpdate((res) => {
console.log(res.progress, filename, 'imageBox[videoInsertIndex].videoprogress');
imageBox[videoInsertIndex].videoprogress = res.progress > 95 ? 95 : res.progress;
that.setData({
imageBox: imageBox
......
......@@ -67,6 +67,9 @@
</view>
<view class="text-box" wx:if="{{item.type == 'text'}}">
<view class="text-item">{{item.value}}</view>
</view>
<view class="text-box" style="max-width: 100%" wx:if="{{item.type == 'editor'}}">
<rich-text nodes="{{item.value}}"></rich-text>
</view>
</block>
<view class="business-box" bindtap="goWebsiteIndex">
......
......@@ -269,7 +269,7 @@
}
.content-box .introduction{
height: calc(100vh - 328px);
padding: 36rpx;
padding: 36rpx 12rpx 36rpx 12rpx;
}
.content-box .introduction .img-box{
margin-bottom: 26rpx;
......
......@@ -5,6 +5,7 @@
"empty-content": "../../../components/emptycontent",
"clock-item": "../../components/newclockitem",
"comment-editor": "../../../components/commenteditor",
"canvasdrawer": "/components/canvasdrawer/canvasdrawer"
"canvasdrawer": "/components/canvasdrawer/canvasdrawer",
"parser": "../../../components/Parser"
}
}
\ No newline at end of file
......@@ -117,6 +117,9 @@
</view>
<view class="text-box" wx:if="{{item.type == 'text'}}">
<view class="text-item">{{item.value}}</view>
</view>
<view class="rich-text-box" wx:if="{{item.type == 'editor'}}">
<rich-text nodes="{{item.value}}"></rich-text>
</view>
</block>
<view class="business-box" bindtap="goWebsiteIndex">
......
......@@ -232,7 +232,7 @@
color:rgba(249,187,0,1);
}
.content-box .introduction{
padding: 36rpx;
padding: 36rpx 12rpx 36px 12px;
}
.content-box .introduction .audio-box{
width:100%;
......@@ -996,4 +996,10 @@
display: flex;
align-items: center;
justify-content: center;
}
.rich-text-box {
max-width: 100%;
}
.rich-text-box img{
max-width: 100%;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment