1 |
- import{aj as t,ak as e,aW as s,e as n,d as i,w as o,al as a,L as l,n as r,i as h}from"./index-DNuNVpwk.js";import{n as c,P as d}from"./mp-html.vue_vue_type_style_index_0_scoped_b0aa647f_lang.DLRgampy.js";import{_ as g}from"./_plugin-vue_export-helper.BCo6x5W8.js";const p=[];const m=g({name:"mp-html",data:()=>({nodes:[]}),props:{containerStyle:{type:String,default:""},content:{type:String,default:""},copyLink:{type:[Boolean,String],default:!0},domain:String,errorImg:{type:String,default:""},lazyLoad:{type:[Boolean,String],default:!1},loadingImg:{type:String,default:""},pauseVideo:{type:[Boolean,String],default:!0},previewImg:{type:[Boolean,String],default:!0},scrollTable:[Boolean,String],selectable:[Boolean,String],setTitle:{type:[Boolean,String],default:!0},showImgMenu:{type:[Boolean,String],default:!0},tagStyle:Object,useAnchor:[Boolean,Number]},emits:["load","ready","imgtap","linktap","play","error"],components:{node:c},watch:{content(t){this.setContent(t)}},created(){this.plugins=[];for(let t=p.length;t--;)this.plugins.push(new p[t](this))},mounted(){this.content&&!this.nodes.length&&this.setContent(this.content)},beforeDestroy(){this._hook("onDetached")},methods:{in(t,e,s){t&&e&&s&&(this._in={page:t,selector:e,scrollTop:s})},navigateTo(s,n){return new Promise(((i,o)=>{if(!this.useAnchor)return void o(Error("Anchor is disabled"));n=n||parseInt(this.useAnchor)||0;const a=t().in(this._in?this._in.page:this).select((this._in?this._in.selector:"._root")+(s?` #${s}`:"")).boundingClientRect();this._in?a.select(this._in.selector).scrollOffset().select(this._in.selector).boundingClientRect():a.selectViewport().scrollOffset(),a.exec((t=>{if(!t[0])return void o(Error("Label not found"));const s=t[1].scrollTop+t[0].top-(t[2]?t[2].top:0)+n;this._in?this._in.page[this._in.scrollTop]=s:e({scrollTop:s,duration:300}),i()}))}))},getText(t){let e="";return function t(s){for(let n=0;n<s.length;n++){const i=s[n];if("text"===i.type)e+=i.text.replace(/&/g,"&");else if("br"===i.name)e+="\n";else{const s="p"===i.name||"div"===i.name||"tr"===i.name||"li"===i.name||"h"===i.name[0]&&i.name[1]>"0"&&i.name[1]<"7";s&&e&&"\n"!==e[e.length-1]&&(e+="\n"),i.children&&t(i.children),s&&"\n"!==e[e.length-1]?e+="\n":"td"!==i.name&&"th"!==i.name||(e+="\t")}}}(t||this.nodes),e},getRect(){return new Promise(((e,s)=>{t().in(this).select("#_root").boundingClientRect().exec((t=>t[0]?e(t[0]):s(Error("Root label not found"))))}))},pauseMedia(){for(let t=(this._videos||[]).length;t--;)this._videos[t].pause()},setPlaybackRate(t){this.playbackRate=t;for(let e=(this._videos||[]).length;e--;)this._videos[e].playbackRate(t)},setContent(t,e){e&&this.imgList||(this.imgList=[]);const s=new d(this).parse(t);if(this.$set(this,"nodes",e?(this.nodes||[]).concat(s):s),this._videos=[],this.$nextTick((()=>{this._hook("onLoad"),this.$emit("load")})),this.lazyLoad||this.imgList._unloadimgs<this.imgList.length/2){let t=0;const e=s=>{s&&s.height||(s={}),s.height===t?this.$emit("ready",s):(t=s.height,setTimeout((()=>{this.getRect().then(e).catch(e)}),350))};this.getRect().then(e).catch(e)}else this.imgList._unloadimgs||this.getRect().then((t=>{this.$emit("ready",t)})).catch((()=>{this.$emit("ready",{})}))},_hook(t){for(let e=p.length;e--;)this.plugins[e][t]&&this.plugins[e][t]()}}},[["render",function(t,e,c,d,g,p){const m=s("node"),u=h;return n(),i(u,{id:"_root",class:l((c.selectable?"_select ":"")+"_root"),style:r(c.containerStyle)},{default:o((()=>[g.nodes[0]?(n(),i(m,{key:1,childs:g.nodes,opts:[c.lazyLoad,c.loadingImg,c.errorImg,c.showImgMenu,c.selectable],name:"span"},null,8,["childs","opts"])):a(t.$slots,"default",{key:0},void 0,!0)])),_:3},8,["class","style"])}],["__scopeId","data-v-b0aa647f"]]);export{m as _};
|