2 lines
31 KiB
JavaScript
2 lines
31 KiB
JavaScript
|
import{X as t,Y as e,V as s,q as i,Z as n,_ as a,r,o,c as l,w as c,d as h,F as d,e as p,n as m,h as g,f,K as u,i as y,t as x,g as b,y as k,k as v,j,W as w,a0 as T,O as _,a1 as $,P as N,a2 as L,a3 as O}from"./index-22d2df30.js";var S={abbr:!0,b:!0,big:!0,code:!0,del:!0,em:!0,i:!0,ins:!0,label:!0,q:!0,small:!0,span:!0,strong:!0,sub:!0,sup:!0};const I={isInline:function(t,e){return S[t]||-1!==(e||"").indexOf("display:inline")}},C=t=>{t.$wxs||(t.$wxs=[]),t.$wxs.push("handler"),t.mixins||(t.mixins=[]),t.mixins.push({beforeCreate(){this.handler=I}})},R={name:"node",options:{},data:()=>({ctrl:{}}),props:{name:String,attrs:{type:Object,default:()=>({})},childs:Array,opts:Array},components:{},mounted(){if(this.$nextTick((()=>{for(this.root=this.$parent;"mp-html"!==this.root.$options.name;this.root=this.root.$parent);})),this.opts[0]){let e;for(e=this.childs.length;e--&&"img"!==this.childs[e].name;);-1!==e&&(this.observer=t(this).relativeToViewport({top:500,bottom:500}),this.observer.observe("._img",(t=>{t.intersectionRatio&&(this.$set(this.ctrl,"load",1),this.observer.disconnect())})))}},beforeDestroy(){this.observer&&this.observer.disconnect()},methods:{play(t){if(this.root.$emit("play"),this.root.pauseVideo){let s=!1;const i=t.target.id;for(let t=this.root._videos.length;t--;)this.root._videos[t].id===i?s=!0:this.root._videos[t].pause();if(!s){const t=e(i,this);t.id=i,this.root.playbackRate&&t.playbackRate(this.root.playbackRate),this.root._videos.push(t)}}},imgTap(t){const e=this.childs[t.currentTarget.dataset.i];e.a?this.linkTap(e.a):e.attrs.ignore||(e.attrs.src=e.attrs.src||e.attrs["data-src"],this.root.$emit("imgtap",e.attrs),this.root.previewImg&&s({current:parseInt(e.attrs.i),urls:this.root.imgList}))},imgLongTap(t){},imgLoad(t){const e=t.currentTarget.dataset.i;(this.opts[1]&&!this.ctrl[e]||-1===this.ctrl[e])&&this.$set(this.ctrl,e,1),this.checkReady()},checkReady(){this.root&&!this.root.lazyLoad&&(this.root._unloadimgs-=1,this.root._unloadimgs||setTimeout((()=>{this.root.getRect().then((t=>{this.root.$emit("ready",t)})).catch((()=>{this.root.$emit("ready",{})}))}),350))},linkTap(t){const e=t.currentTarget?this.childs[t.currentTarget.dataset.i]:{},s=e.attrs||t,a=s.href;this.root.$emit("linktap",Object.assign({innerText:this.root.getText(e.children||[])},s)),a&&("#"===a[0]?this.root.navigateTo(a.substring(1)).catch((()=>{})):a.split("?")[0].includes("://")?this.root.copyLink&&window.open(a):i({url:a,fail(){n({url:a,fail(){}})}}))},mediaError(t){const e=t.currentTarget.dataset.i,s=this.childs[e];if("video"===s.name||"audio"===s.name){let t=(this.ctrl[e]||0)+1;if(t>s.src.length&&(t=0),t<s.src.length)return void this.$set(this.ctrl,e,t)}else if("img"===s.name){if(this.opts[0]&&!this.ctrl.load)return;this.opts[2]&&this.$set(this.ctrl,e,-1),this.checkReady()}this.root&&this.root.$emit("error",{source:s.name,attrs:s.attrs})}}};C(R);const A=a(R,[["render",function(t,e,s,i,n,a){const _=k,$=v,N=r("node",!0),L=j,O=w,S=T;return o(),l(L,{id:s.attrs.id,class:f("_block _"+s.name+" "+s.attrs.class),style:m(s.attrs.style)},{default:c((()=>[(o(!0),h(d,null,p(s.childs,((i,r)=>(o(),h(d,{key:r},["img"===i.name&&!i.t&&(s.opts[1]&&!n.ctrl[r]||n.ctrl[r]<0)?(o(),l(_,{key:0,class:"_img",style:m(i.attrs.style),src:n.ctrl[r]<0?s.opts[2]:s.opts[1],mode:"widthFix"},null,8,["style","src"])):g("",!0),"img"===i.name?(o(),h("img",{key:1,id:i.attrs.id,class:f("_img "+i.attrs.class),style:m((-1===n.ctrl[r]?"display:none;":"")+i.attrs.style),src:i.attrs.src||(n.ctrl.load?i.attrs["data-src"]:""),"data-i":r,onLoad:e[0]||(e[0]=(...t)=>a.imgLoad&&a.imgLoad(...t)),onError:e[1]||(e[1]=(...t)=>a.mediaError&&a.mediaError(...t)),onClick:e[2]||(e[2]=u(((...t)=>a.imgTap&&a.imgTap(...t)),["stop"])),onLongpress:e[3]||(e[3]=(...t)=>a.imgLongTap&&a.imgLongTap(...t))},null,46,["id","src","data-i"])):i.text?(o(),l($,{key:2,decode:""},{default:c((()=>[y(x(i.text),1)])),_:2},1024)):"br"===i.name?(o(),l($,{key:3},{default:c((()=>[y("\\n")])),_:1})):"a"===i.name?(o(),l(L,{key:4,id:i.attrs.id,class:f((i.attrs.href?"_a ":"")+i.attrs.class),"hover-class":"_hover",style:m("display
|