@waline/client 3.9.0 → 3.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/comment.js +1 -1
- package/dist/component.js +1 -1
- package/dist/component.js.map +1 -1
- package/dist/pageview.js +1 -1
- package/dist/pageview.js.map +1 -1
- package/dist/slim.d.ts +40 -2
- package/dist/slim.js +12 -12
- package/dist/slim.js.map +1 -1
- package/dist/waline.css +1 -1
- package/dist/waline.css.map +1 -1
- package/dist/waline.d.ts +40 -2
- package/dist/waline.js +36 -36
- package/dist/waline.js.map +1 -1
- package/dist/waline.umd.js +45 -45
- package/dist/waline.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/comment.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const h=e=>`${e.replace(/\/?$/,"/")}api/`,g=(e,t="")=>{if(typeof e=="object"&&e.errno)throw new TypeError(`${t} failed with ${e.errno}: ${e.errmsg}`);return e},i=({serverURL:e,lang:t,paths:r,signal:o})=>fetch(`${h(e)}comment?type=count&url=${encodeURIComponent(r.join(","))}&lang=${t}`,{signal:o}).then(n=>n.json()).then(n=>g(n,"Get comment count").data),u=e=>{try{return decodeURI(e)}catch{return e}},p=(e="")=>e.replace(/\/$/u,""),m=e=>/^(https?:)?\/\//.test(e),d=e=>{const t=p(e);return m(t)?t:`https://${t}`},$=e=>{e.name!=="AbortError"&&console.error(e.message)},f=e=>{const{path:t}=e.dataset;return t!=null&&t.length?t:null},v=({serverURL:e,path:t=window.location.pathname,selector:r=".waline-comment-count",lang:o=navigator.language})=>{const n=new AbortController,a=document.querySelectorAll(r);return a.length>0&&i({serverURL:d(e),paths:Array.from(a,c=>u(f(c)??t)),lang:o,signal:n.signal}).then(c=>{a.forEach((s,l)=>{s.textContent=c[l].toString()})}).catch($),n.abort.bind(n)},w="3.
|
|
1
|
+
const h=e=>`${e.replace(/\/?$/,"/")}api/`,g=(e,t="")=>{if(typeof e=="object"&&e.errno)throw new TypeError(`${t} failed with ${e.errno}: ${e.errmsg}`);return e},i=({serverURL:e,lang:t,paths:r,signal:o})=>fetch(`${h(e)}comment?type=count&url=${encodeURIComponent(r.join(","))}&lang=${t}`,{signal:o}).then(n=>n.json()).then(n=>g(n,"Get comment count").data),u=e=>{try{return decodeURI(e)}catch{return e}},p=(e="")=>e.replace(/\/$/u,""),m=e=>/^(https?:)?\/\//.test(e),d=e=>{const t=p(e);return m(t)?t:`https://${t}`},$=e=>{e.name!=="AbortError"&&console.error(e.message)},f=e=>{const{path:t}=e.dataset;return t!=null&&t.length?t:null},v=({serverURL:e,path:t=window.location.pathname,selector:r=".waline-comment-count",lang:o=navigator.language})=>{const n=new AbortController,a=document.querySelectorAll(r);return a.length>0&&i({serverURL:d(e),paths:Array.from(a,c=>u(f(c)??t)),lang:o,signal:n.signal}).then(c=>{a.forEach((s,l)=>{s.textContent=c[l].toString()})}).catch($),n.abort.bind(n)},w="3.11.0";export{v as commentCount,w as version};
|
|
2
2
|
//# sourceMappingURL=comment.js.map
|
package/dist/component.js
CHANGED
|
@@ -9,5 +9,5 @@ import{h as I,defineComponent as re,inject as Ce,ref as x,computed as W,onMounte
|
|
|
9
9
|
Số từ hiện tại: $2`,"Vô danh","Người lùn","Người tí hon","Thần rừng","Pháp sư","Tiên tộc","Maiar","Ảnh GIF","Tìm kiếm ảnh GIF","thông tin cá nhân","Đã được phê duyệt","Đang chờ đợi","Thư rác","Không dính","lâu đời nhất","muộn nhất","nóng nhất","What do you think?","Bình luận của bạn đang được xem xét và hiện chỉ hiển thị với bạn. Nó sẽ được công khai sau khi được phê duyệt."]),et=Y(["昵称","昵称不能少于3个字符","邮箱","请填写正确的邮件地址","网址","可选","欢迎评论","来发评论吧~","提交","喜欢","取消喜欢","回复","取消回复","评论","刷新","加载更多...","预览","表情","上传图片","秒前","分钟前","小时前","天前","刚刚","正在上传","登录","退出","博主","置顶","字",`评论字数应在 $0 到 $1 字之间!
|
|
10
10
|
当前字数:$2`,"匿名","潜水","冒泡","吐槽","活跃","话痨","传说","表情包","搜索表情包","个人资料","通过","待审核","垃圾","取消置顶","按倒序","按正序","按热度","你认为这篇文章怎么样?","评论正在审核中,当前仅自己可见,审核通过后公开可见。"]),ba=Y(["暱稱","暱稱不能少於3個字元","郵箱","請填寫正確的郵件地址","網址","可選","歡迎留言","來發留言吧~","送出","喜歡","取消喜歡","回覆","取消回覆","留言","重整","載入更多...","預覽","表情","上傳圖片","秒前","分鐘前","小時前","天前","剛剛","正在上傳","登入","登出","管理者","置頂","字",`留言字數應在 $0 到 $1 字之間!
|
|
11
11
|
目前字數:$2`,"匿名","潛水","冒泡","吐槽","活躍","多話","傳說","表情包","搜尋表情包","個人資料","通過","待審核","垃圾","取消置頂","最早","最新","熱門","你認為這篇文章怎麼樣?","您的評論正在審核中,目前僅您可見。審核通過後將公開顯示。"]);const tt="en-US",Ae={zh:et,"zh-cn":et,"zh-tw":ba,en:Oe,"en-us":Oe,fr:Ze,"fr-fr":Ze,it:Xe,"it-it":Xe,jp:Ye,"jp-jp":Ye,"pt-br":wa,ru:Je,"ru-ru":Je,vi:Qe,"vi-vn":Qe,de:ya,es:Ke,"es-mx":Ke},ka=e=>Ae[e.toLowerCase()]??Ae[tt.toLowerCase()],at=e=>Object.keys(Ae).includes(e.toLowerCase())?e:tt,lt={latest:"insertedAt_desc",oldest:"insertedAt_asc",hottest:"like_desc"},Ca=Object.keys(lt),ye=Symbol("waline-config"),$a={key:0,class:"wl-reaction"},La=["textContent"],Ia={class:"wl-reaction-list"},Ea=["onClick"],Aa={class:"wl-reaction-img"},Ma=["src","alt"],Sa=["textContent"],xa=["textContent"];var za=re({__name:"ArticleReaction",setup(e){const a=ta(),t=Ce(ye),n=x(-1),o=x([]),v=W(()=>t.value.locale),S=W(()=>{const{reaction:k}=t.value;return k!=null&&k.length?k:null}),b=W(()=>{var k;const{path:M}=t.value;return((k=S.value)==null?void 0:k.map((V,f)=>({icon:V,desc:v.value[`reaction${f}`],active:a.value[M]===f})))??null});let d;const R=async()=>{const{serverURL:k,lang:M,path:V}=t.value;if(!S.value)return;const f=new AbortController;d=f.abort.bind(f);const[A]=await xt({serverURL:k,lang:M,paths:[V],type:S.value.map(($,u)=>`reaction${u}`),signal:f.signal});o.value=S.value.map(($,u)=>A[`reaction${u}`])},h=async k=>{if(n.value!==-1)return;const{serverURL:M,lang:V,path:f}=t.value,A=a.value[f];n.value=k,A!=null&&(await Te({serverURL:M,lang:V,path:f,type:`reaction${A}`,action:"desc"}),o.value[A]=Math.max(o.value[A]-1,0)),A!==k&&(await Te({serverURL:M,lang:V,path:f,type:`reaction${k}`}),o.value[k]=(o.value[k]||0)+1),A===k?delete a.value[f]:a.value[f]=k,n.value=-1};return ge(()=>{se(()=>[t.value.serverURL,t.value.path],()=>R())}),Ue(()=>{d==null||d()}),(k,M)=>b.value?(i(),r("div",$a,[s("div",{class:"wl-reaction-title",textContent:E(v.value.reactionTitle)},null,8,La),s("ul",Ia,[(i(!0),r(D,null,Z(b.value,({active:V,icon:f,desc:A},$)=>(i(),r("li",{key:$,class:G(["wl-reaction-item",{active:V}]),onClick:u=>h($)},[s("div",Aa,[s("img",{src:f,alt:A},null,8,Ma),n.value===$?(i(),J(y(ce),{key:0,class:"wl-reaction-loading"})):(i(),r("div",{key:1,class:"wl-reaction-votes",textContent:E(o.value[$]||0)},null,8,Sa))]),s("div",{class:"wl-reaction-text",textContent:E(A)},null,8,xa)],10,Ea))),128))])])):C("v-if",!0)}});const Ra=["data-index"],ja=["src","title","onClick"];var Va=re({__name:"ImageWall",props:{items:{default:()=>[]},columnWidth:{default:300},gap:{default:0}},emits:["insert"],setup(e){let a=null;const t=ee("wall"),n=x({}),o=x([]),v=()=>{const h=Math.floor((t.value.getBoundingClientRect().width+e.gap)/(e.columnWidth+e.gap));return h>0?h:1},S=h=>Array.from({length:h},()=>[]),b=async h=>{var k;if(h>=e.items.length)return;await _e();const M=[...((k=t.value)==null?void 0:k.children)??[]].reduce((V,f)=>f.getBoundingClientRect().height<V.getBoundingClientRect().height?f:V);o.value[Number(M.dataset.index)].push(h),await b(h+1)},d=async(h=!1)=>{if(o.value.length===v()&&!h)return;o.value=S(v());const{scrollY:k}=window;await b(0),window.scrollTo({top:k})},R=h=>{n.value[h.target.src]=!0};return ge(()=>{d(!0),a=new ResizeObserver(()=>{d()}),a.observe(t.value),$e(()=>[e.items],()=>{n.value={},d(!0)}),$e(()=>[e.columnWidth,e.gap],()=>{d()})}),wt(()=>{a.unobserve(t.value)}),(h,k)=>(i(),r("div",{ref_key:"wall",ref:t,class:"wl-gallery",style:Le({gap:`${e.gap}px`})},[(i(!0),r(D,null,Z(o.value,(M,V)=>(i(),r("div",{key:V,class:"wl-gallery-column","data-index":V,style:Le({gap:`${e.gap}px`})},[(i(!0),r(D,null,Z(M,f=>(i(),r(D,{key:f},[n.value[e.items[f].src]?C("v-if",!0):(i(),J(y(ce),{key:0,size:36,style:{margin:"20px auto"}})),s("img",{class:"wl-gallery-item",src:e.items[f].src,title:e.items[f].title,loading:"lazy",onLoad:R,onClick:A=>h.$emit("insert",``)},null,40,ja)],64))),128))],12,Ra))),128))],4))}});const Ua=e=>{try{return decodeURI(e)}catch{return e}},nt=(e="")=>e.replace(/\/$/u,""),it=e=>/^(https?:)?\/\//.test(e),_a=e=>{const a=nt(e);return it(a)?a:`https://${a}`},Ha=e=>Array.isArray(e)?e:typeof e=="number"?[0,e]:!1,ue=(e,a)=>e==null||e===!0?a:e===!1?null:e,Fa=({serverURL:e,path:a=location.pathname,lang:t=typeof navigator>"u"?"en-US":navigator.language,locale:n,meta:o=["nick","mail","link"],requiredMeta:v=[],dark:S=!1,pageSize:b=10,wordLimit:d,noCopyright:R=!1,login:h="enable",recaptchaV3Key:k="",turnstileKey:M="",commentSorting:V="latest",emoji:f=Ge,imageUploader:A,highlighter:$,texRenderer:u,search:P,reaction:X,...L})=>({serverURL:_a(e),path:Ua(a),lang:at(t),locale:{...ka(at(t)),...typeof n=="object"?n:{}},wordLimit:Ha(d),meta:De(o),requiredMeta:De(v),dark:S,pageSize:b,commentSorting:V,login:h,noCopyright:R,recaptchaV3Key:k,turnstileKey:M,...L,reaction:X===!0?ra:X||null,imageUploader:ue(A,sa),highlighter:ue($,ha),texRenderer:ue(u,ca),emoji:ue(f,Ge),search:ue(P,ua(t))}),Me=e=>typeof e=="string",Se="{--waline-white:#000;--waline-light-grey:#666;--waline-dark-grey:#999;--waline-color:#888;--waline-bg-color:#1e1e1e;--waline-bg-color-light:#272727;--waline-bg-color-hover: #444;--waline-border-color:#333;--waline-disable-bg-color:#444;--waline-disable-color:#272727;--waline-bq-color:#272727;--waline-info-bg-color:#272727;--waline-info-color:#666}",Ta=e=>Me(e)?e==="auto"?`@media(prefers-color-scheme:dark){body${Se}}`:`${e}${Se}`:e===!0?`:root${Se}`:"",xe=(e,a)=>{let t=e.toString();for(;t.length<a;)t=`0${t}`;return t},Na=e=>{const a=xe(e.getDate(),2),t=xe(e.getMonth()+1,2);return`${xe(e.getFullYear(),2)}-${t}-${a}`},Ba=(e,a,t)=>{if(!e)return"";const n=Me(e)?new Date(e.includes(" ")?e.replaceAll("-","/"):e):e,o=a.getTime()-n.getTime(),v=Math.floor(o/(24*3600*1e3));if(v===0){const S=o%864e5,b=Math.floor(S/(3600*1e3));if(b===0){const d=S%36e5,R=Math.floor(d/(60*1e3));if(R===0){const h=d%6e4;return`${Math.round(h/1e3)} ${t.seconds}`}return`${R} ${t.minutes}`}return`${b} ${t.hours}`}return v<0?t.now:v<8?`${v} ${t.days}`:Na(n)},Pa=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Wa=e=>Pa.test(e),Da="WALINE_EMOJI",ot=ie(Da,{}),Ga=e=>/@[0-9]+\.[0-9]+\.[0-9]+/.test(e),qa=e=>{const a=Ga(e);if(a){const t=ot.value[e];if(t)return Promise.resolve(t)}return fetch(`${e}/info.json`).then(t=>t.json()).then(t=>{const n={folder:e,...t};return a&&(ot.value[e]=n),n})},rt=(e,a="",t="",n="")=>`${a?`${a}/`:""}${t}${e}${n?`.${n}`:""}`,Oa=e=>Promise.all(e?e.map(a=>Me(a)?qa(nt(a)):Promise.resolve(a)):[]).then(a=>{const t={tabs:[],map:{}};return a.forEach(n=>{const{name:o,folder:v,icon:S,prefix:b="",type:d,items:R}=n;t.tabs.push({name:o,icon:rt(S,v,b,d),items:R.map(h=>{const k=`${b}${h}`;return t.map[k]=rt(h,v,b,d),k})})}),t}),st=e=>{const a=[...e].find(t=>t.type.includes("image"));return a?a.getAsFile():null},Ka=/\$.*?\$/,Za=/^\$(.*?)\$/,Xa=/^(?:\s{0,3})\$\$((?:[^\n]|\n[^\n])+?)\n{0,1}\$\$/,Ya=e=>[{name:"blockMath",level:"block",tokenizer(a){const t=Xa.exec(a);if(t!=null)return{type:"html",raw:t[0],text:e(!0,t[1])}}},{name:"inlineMath",level:"inline",start(a){const t=a.search(Ka);return t===-1?a.length:t},tokenizer(a){const t=Za.exec(a);if(t!=null)return{type:"html",raw:t[0],text:e(!1,t[1])}}}],ct=(e="",a={})=>e.replaceAll(/:(.+?):/g,(t,n)=>a[n]?`<img class="wl-emoji" src="${a[n]}" alt="${n}">`:t),Ja=(e,{emojiMap:a,highlighter:t,texRenderer:n})=>{const o=new Ut;if(o.setOptions({breaks:!0}),t&&o.use(_t({highlight:t})),n){const v=Ya(n);o.use({extensions:v})}return o.parse(ct(e,a))},Qa=e=>e.match(/[\w\d\s,.\u00C0-\u024F\u0400-\u04FF]+/giu),el=e=>e.match(/[\u4E00-\u9FD5]/gu),tl=e=>{var a,t;return(((a=Qa(e))==null?void 0:a.reduce((n,o)=>n+(["",",","."].includes(o.trim())?0:o.trim().split(/\s+/u).length),0))??0)+(((t=el(e))==null?void 0:t.length)??0)},al=async()=>{const{userAgentData:e}=navigator;let a=navigator.userAgent;if((e==null?void 0:e.platform)!=="Windows")return a;const{platformVersion:t}=await e.getHighEntropyValues(["platformVersion"]);return t&&Number.parseInt(t.split(".")[0],10)>=13&&(a=a.replace("Windows NT 10.0","Windows NT 11.0")),a},ll={key:0,class:"wl-login-info"},nl={class:"wl-avatar"},il=["title"],ol=["title"],rl=["src"],sl=["title","textContent"],cl={class:"wl-panel"},ul=["for","textContent"],ml=["id","onUpdate:modelValue","name","type"],vl=["placeholder"],dl={class:"wl-preview"},pl=["innerHTML"],gl={class:"wl-footer"},hl={class:"wl-actions"},fl={href:"https://guides.github.com/features/mastering-markdown/",title:"Markdown Guide","aria-label":"Markdown is supported",class:"wl-action",target:"_blank",rel:"noopener noreferrer"},yl=["title"],wl=["title"],bl=["title","aria-label"],kl=["title"],Cl={class:"wl-info"},$l={class:"wl-text-number"},Ll={key:0},Il=["textContent"],El=["textContent"],Al=["disabled"],Ml=["placeholder"],Sl={key:1,class:"wl-loading"},xl=["title","onClick","onMouseenter"],zl=["src","alt"],Rl=["src"],jl={key:0,class:"wl-tabs"},Vl=["onClick"],Ul=["src","alt","title"],_l=["title"];var ut=re({__name:"CommentBox",props:{edit:{},rootId:{},replyId:{},replyUser:{}},emits:["log","cancelEdit","cancelReply","submit"],setup(e,{emit:a}){const t=e,n=a,o=Ce(ye),v=Xt(),S=Zt(),b=Ie(),d=x({}),R=ee("textarea"),h=ee("image-uploader"),k=ee("emoji-button"),M=ee("emoji-popup"),V=ee("gif-button"),f=ee("gif-popup"),A=ee("gif-search"),$=x({tabs:[],map:{}}),u=x(0),P=x(!1),X=x(""),L=x({});let H;const me=(c,l)=>{clearTimeout(H),X.value=l;const p=c.currentTarget,j=M.value;if(p&&j){const m=p.getBoundingClientRect(),N=j.getBoundingClientRect();L.value={left:`${m.left-N.left+m.width/2}px`,top:`${m.top-N.top}px`,transform:"translate(-50%, -100%)"}}},ve=()=>{H=setTimeout(()=>{X.value=""},50)},Q=x(!1),le=x(!1),oe=x(""),g=x(0),w=bt({loading:!0,list:[]}),z=x(0),F=x(!1),O=x(""),T=x(!1),ae=x(!1),U=W(()=>o.value.locale),ne=W(()=>!!b.value.token),de=W(()=>o.value.imageUploader!=null),we=c=>{const l=R.value,p=l.selectionStart,j=l.selectionEnd||0,{scrollTop:m}=l;v.value=l.value.slice(0,p)+c+l.value.slice(j),l.focus(),l.selectionStart=p+c.length,l.selectionEnd=p+c.length,l.scrollTop=m},vt=({key:c,ctrlKey:l,metaKey:p})=>{T.value||(l||p)&&c==="Enter"&&ze()},be=async c=>{const l=`![${o.value.locale.uploading} ${c.name}]()`;we(l),T.value=!0;try{const p=await o.value.imageUploader(c);v.value=v.value.replace(l,`\r
|
|
12
|
-
`)}catch(p){alert(p.message),v.value=v.value.replace(l,"")}finally{T.value=!1}},dt=c=>{var l;if((l=c.dataTransfer)!=null&&l.items){const p=st(c.dataTransfer.items);p&&de.value&&(be(p),c.preventDefault())}},pt=c=>{if(c.clipboardData){const l=st(c.clipboardData.items);l&&de.value&&be(l)}},gt=()=>{const c=h.value;c.files&&de.value&&be(c.files[0]).then(()=>{c.value=""})},ze=async()=>{var c;const{serverURL:l,lang:p,login:j,wordLimit:m,requiredMeta:N,recaptchaV3Key:B,turnstileKey:K}=o.value,_={comment:O.value,nick:S.value.nick,mail:S.value.mail,link:S.value.link,url:o.value.path,ua:await al()};if(!t.edit)if(b.value.token)_.nick=b.value.display_name,_.mail=b.value.email,_.link=b.value.url;else{if(j==="force")return;if(N.includes("nick")&&!_.nick){d.value.nick.focus(),alert(U.value.nickError);return}if(N.includes("mail")&&!_.mail||_.mail&&!Wa(_.mail)){d.value.mail.focus(),alert(U.value.mailError);return}_.nick||(_.nick=U.value.anonymous)}if(!_.comment){R.value.focus();return}if(!F.value){alert(U.value.wordHint.replace("$0",m[0].toString()).replace("$1",m[1].toString()).replace("$2",g.value.toString()));return}_.comment=ct(_.comment,$.value.map),t.replyId&&t.rootId&&(_.pid=t.replyId,_.rid=t.rootId,_.at=t.replyUser),T.value=!0;try{B&&(_.recaptchaV3=await aa(B).execute("social")),K&&(_.turnstile=await la(K).execute("social"));const pe={serverURL:l,lang:p,token:b.value.token,comment:_},ke=await(t.edit?fe({objectId:t.edit.objectId,...pe}):zt(pe));if(T.value=!1,ke.errmsg){alert(ke.errmsg);return}n("submit",ke.data),v.value="",oe.value="",await _e(),t.replyId&&n("cancelReply"),(c=t.edit)!=null&&c.objectId&&n("cancelEdit")}catch(pe){T.value=!1,alert(pe.message)}},ht=c=>{c.preventDefault();const{lang:l,serverURL:p}=o.value;Rt({serverURL:p,lang:l}).then(j=>{b.value=j,(j.remember?localStorage:sessionStorage).setItem("WALINE_USER",JSON.stringify(j)),n("log")})},ft=()=>{b.value={},localStorage.setItem("WALINE_USER","null"),sessionStorage.setItem("WALINE_USER","null"),n("log")},Re=c=>{c.preventDefault();const{lang:l,serverURL:p}=o.value,j=800,m=800,N=(window.innerWidth-j)/2,B=(window.innerHeight-m)/2,K=new URLSearchParams({lng:l,token:b.value.token}),_=window.open(`${p}/ui/profile?${K.toString()}`,"_blank",`width=${j},height=${m},left=${N},top=${B},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`);_==null||_.postMessage({type:"TOKEN",data:b.value.token},"*")},yt=c=>{var l,p,j,m;!((l=k.value)!=null&&l.contains(c.target))&&!((p=M.value)!=null&&p.contains(c.target))&&(P.value=!1),!((j=V.value)!=null&&j.contains(c.target))&&!((m=f.value)!=null&&m.contains(c.target))&&(Q.value=!1)},je=async c=>{var l;const{scrollTop:p,clientHeight:j,scrollHeight:m}=c.target,N=(j+p)/m,B=o.value.search,K=((l=A.value)==null?void 0:l.value)??"";N<.9||w.loading||ae.value||(w.loading=!0,(B.more&&w.list.length>0?await B.more(K,w.list.length):await B.search(K)).length>0?w.list=[...w.list,...B.more&&w.list.length>0?await B.more(K,w.list.length):await B.search(K)]:ae.value=!0,w.loading=!1,setTimeout(()=>{c.target.scrollTop=p},50))},Ve=At(c=>{w.list=[],ae.value=!1,je(c)},300);return Fe("click",yt),Fe("message",({data:c})=>{(c==null?void 0:c.type)==="profile"&&(b.value={...b.value,...c.data},[localStorage,sessionStorage].filter(l=>l.getItem("WALINE_USER")).forEach(l=>{l.setItem("WALINE_USER",JSON.stringify(b))}))}),se([o,g],([c,l])=>{const{wordLimit:p}=c;p?l<p[0]&&p[0]!==0?([z.value]=p,F.value=!1):l>p[1]?([,z.value]=p,F.value=!1):([,z.value]=p,F.value=!0):(z.value=0,F.value=!0)}),$e(Q,async c=>{var l;if(!c)return;const p=o.value.search;A.value&&(A.value.value=""),w.loading=!0,w.list=await(((l=p.default)==null?void 0:l.call(p))??p.search("")),w.loading=!1}),ge(()=>{var c;(c=t.edit)!=null&&c.objectId&&(v.value=t.edit.orig),se(()=>v.value,l=>{const{highlighter:p,texRenderer:j}=o.value;O.value=l,oe.value=Ja(l,{emojiMap:$.value.map,highlighter:p,texRenderer:j}),g.value=tl(l),l?Ne(R.value):Ne.destroy(R.value)}),se(()=>o.value.emoji,async l=>{$.value=await Oa(l)})}),(c,l)=>{var p,j;return i(),r("div",{key:y(b).token,class:"wl-comment"},[y(o).login!=="disable"&&ne.value&&!((p=e.edit)!=null&&p.objectId)?(i(),r("div",ll,[s("div",nl,[s("button",{type:"submit",class:"wl-logout-btn",title:U.value.logout,onClick:ft},[q(y(Be),{size:14})],8,il),s("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",title:U.value.profile,onClick:Re},[s("img",{src:y(b).avatar,alt:"avatar"},null,8,rl)],8,ol)]),s("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",title:U.value.profile,onClick:Re,textContent:E(y(b).display_name)},null,8,sl)])):C("v-if",!0),s("div",cl,[y(o).login!=="force"&&y(o).meta.length&&!ne.value?(i(),r("div",{key:0,class:G(["wl-header",`item${y(o).meta.length}`])},[(i(!0),r(D,null,Z(y(o).meta,m=>(i(),r("div",{key:m,class:"wl-header-item"},[s("label",{for:`wl-${m}`,textContent:E(U.value[m]+(y(o).requiredMeta.includes(m)||!y(o).requiredMeta.length?"":`(${U.value.optional})`))},null,8,ul),he(s("input",{id:`wl-${m}`,ref_for:!0,ref:N=>{N&&(d.value[m]=N)},"onUpdate:modelValue":N=>y(S)[m]=N,class:G(["wl-input",`wl-${m}`]),name:m,type:m==="mail"?"email":"text"},null,10,ml),[[kt,y(S)[m]]])]))),128))],2)):C("v-if",!0),he(s("textarea",{id:"wl-edit",ref:"textarea","onUpdate:modelValue":l[0]||(l[0]=m=>Ct(v)?v.value=m:null),class:"wl-editor",placeholder:e.replyUser?`@${e.replyUser}`:U.value.placeholder,onKeydown:vt,onDrop:dt,onPaste:pt},null,40,vl),[[$t,y(v)]]),he(s("div",dl,[l[7]||(l[7]=s("hr",null,null,-1)),s("h4",null,E(U.value.preview)+":",1),s("div",{class:"wl-content",innerHTML:oe.value},null,8,pl)],512),[[He,le.value]]),s("div",gl,[s("div",hl,[s("a",fl,[q(y(Wt))]),he(s("button",{ref:"emoji-button",type:"button",class:G(["wl-action",{active:P.value}]),title:U.value.emoji,onClick:l[1]||(l[1]=m=>P.value=!P.value)},[q(y(Tt))],10,yl),[[He,$.value.tabs.length]]),y(o).search?(i(),r("button",{key:0,ref:"gif-button",type:"button",class:G(["wl-action",{active:Q.value}]),title:U.value.gif,onClick:l[2]||(l[2]=m=>Q.value=!Q.value)},[q(y(Kt))],10,wl)):C("v-if",!0),s("input",{id:"wl-image-upload",ref:"image-uploader",class:"upload","aria-hidden":"true",type:"file",accept:".png,.jpg,.jpeg,.webp,.bmp,.gif",onChange:gt},null,544),de.value?(i(),r("label",{key:1,for:"wl-image-upload",class:"wl-action",title:U.value.uploadImage,"aria-label":U.value.uploadImage},[q(y(Nt))],8,bl)):C("v-if",!0),s("button",{type:"button",class:G(["wl-action",{active:le.value}]),title:U.value.preview,onClick:l[3]||(l[3]=m=>le.value=!le.value)},[q(y(Pt))],10,kl)]),s("div",Cl,[l[9]||(l[9]=s("div",{class:"wl-captcha-container"},null,-1)),s("div",$l,[te(E(g.value)+" ",1),y(o).wordLimit?(i(),r("span",Ll,[l[8]||(l[8]=te(" / ",-1)),s("span",{class:G({illegal:!F.value}),textContent:E(z.value)},null,10,Il)])):C("v-if",!0),te(" "+E(U.value.word),1)]),y(o).login!=="disable"&&!ne.value?(i(),r("button",{key:0,type:"button",class:"wl-btn",onClick:ht,textContent:E(U.value.login)},null,8,El)):C("v-if",!0),y(o).login!=="force"||ne.value?(i(),r("button",{key:1,type:"submit",class:"primary wl-btn",title:"Cmd|Ctrl + Enter",disabled:T.value,onClick:ze},[T.value?(i(),J(y(ce),{key:0,size:16})):(i(),r(D,{key:1},[te(E(U.value.submit),1)],64))],8,Al)):C("v-if",!0)]),s("div",{ref:"gif-popup",class:G(["wl-gif-popup",{display:Q.value}])},[s("input",{ref:"gif-search",type:"text",placeholder:U.value.gifSearchPlaceholder,onInput:l[4]||(l[4]=(...m)=>y(Ve)&&y(Ve)(...m))},null,40,Ml),w.list.length?(i(),J(Va,{key:0,items:w.list,"column-width":200,gap:6,onInsert:l[5]||(l[5]=m=>we(m)),onScroll:je},null,8,["items"])):C("v-if",!0),w.loading?(i(),r("div",Sl,[q(y(ce),{size:30})])):C("v-if",!0)],2),s("div",{ref:"emoji-popup",class:G(["wl-emoji-popup",{display:P.value}])},[(i(!0),r(D,null,Z($.value.tabs,(m,N)=>(i(),r(D,{key:m.name},[N===u.value?(i(),r("div",{key:0,class:"wl-tab-wrapper",onScroll:ve},[(i(!0),r(D,null,Z(m.items,B=>(i(),r("button",{key:B,type:"button",title:B,onClick:K=>we(`:${B}:`),onMouseenter:K=>me(K,B),onMouseleave:ve},[P.value?(i(),r("img",{key:0,class:"wl-emoji",src:$.value.map[B],alt:B,loading:"lazy",referrerPolicy:"no-referrer"},null,8,zl)):C("v-if",!0)],40,xl))),128))],32)):C("v-if",!0)],64))),128)),s("div",null,[X.value?(i(),r("img",{key:0,class:"wl-emoji-preview",src:$.value.map[X.value],alt:"preview",loading:"lazy",referrerPolicy:"no-referrer",style:Le(L.value)},null,12,Rl)):C("v-if",!0)]),$.value.tabs.length>1?(i(),r("div",jl,[(i(!0),r(D,null,Z($.value.tabs,(m,N)=>(i(),r("button",{key:m.name,type:"button",class:G(["wl-tab",{active:u.value===N}]),onClick:B=>u.value=N},[s("img",{class:"wl-emoji",src:m.icon,alt:m.name,title:m.name,loading:"lazy",referrerPolicy:"no-referrer"},null,8,Ul)],10,Vl))),128))])):C("v-if",!0)],2)])]),e.replyId||(j=e.edit)!=null&&j.objectId?(i(),r("button",{key:1,type:"button",class:"wl-close",title:U.value.cancelReply,onClick:l[6]||(l[6]=m=>e.replyId?n("cancelReply"):n("cancelEdit"))},[q(y(Be),{size:24})],8,_l)):C("v-if",!0)])}}});const Hl=["id"],Fl={class:"wl-user","aria-hidden":"true"},Tl=["src"],Nl={class:"wl-card"},Bl={class:"wl-head"},Pl=["href"],Wl={key:1,class:"wl-nick"},Dl=["textContent"],Gl=["textContent"],ql=["textContent"],Ol=["textContent"],Kl={class:"wl-comment-actions"},Zl=["title"],Xl=["title"],Yl={class:"wl-meta","aria-hidden":"true"},Jl=["data-value","textContent"],Ql={key:0,class:"wl-warning","aria-hidden":"true"},en={key:1,class:"wl-content"},tn={key:0},an=["href"],ln=["innerHTML"],nn={key:2,class:"wl-admin-actions"},on={class:"wl-comment-status"},rn=["disabled","onClick","textContent"],sn={key:4,class:"wl-quote"};var cn=re({__name:"CommentCard",props:{comment:{},edit:{},rootId:{},reply:{}},emits:["log","submit","delete","like","sticky","edit","reply","status"],setup(e,{emit:a}){const t=a,n=["approved","waiting","spam"],o=Ce(ye),v=Pe(),S=Mt(),b=Ie(),d=W(()=>o.value.locale),R=W(()=>{const{link:$}=e.comment;return $?it($)?$:`https://${$}`:""}),h=W(()=>v.value.includes(e.comment.objectId)),k=W(()=>Ba(new Date(e.comment.time),S.value,d.value)),M=W(()=>b.value.type==="administrator"),V=W(()=>e.comment.user_id&&b.value.objectId===e.comment.user_id),f=W(()=>{var $;return e.comment.objectId===(($=e.reply)==null?void 0:$.objectId)}),A=W(()=>{var $;return e.comment.objectId===(($=e.edit)==null?void 0:$.objectId)});return($,u)=>{var P;const X=Lt("CommentCard",!0);return i(),r("div",{id:e.comment.objectId.toString(),class:"wl-card-item"},[s("div",Fl,[e.comment.avatar?(i(),r("img",{key:0,class:"wl-user-avatar",src:e.comment.avatar,alt:""},null,8,Tl)):C("v-if",!0),e.comment.type==="guest"?(i(),J(y(qt),{key:1})):C("v-if",!0),e.comment.type==="administrator"?(i(),J(y(Ot),{key:2})):C("v-if",!0)]),s("div",Nl,[s("div",Bl,[R.value?(i(),r("a",{key:0,class:"wl-nick",href:R.value,target:"_blank",rel:"nofollow noopener noreferrer"},E(e.comment.nick),9,Pl)):(i(),r("span",Wl,E(e.comment.nick),1)),e.comment.label?(i(),r("span",{key:2,class:"wl-badge",textContent:E(e.comment.label)},null,8,Dl)):C("v-if",!0),e.comment.sticky?(i(),r("span",{key:3,class:"wl-badge",textContent:E(d.value.sticky)},null,8,Gl)):C("v-if",!0),typeof e.comment.level=="number"?(i(),r("span",{key:4,class:G(`wl-badge level${e.comment.level}`),textContent:E(d.value[`level${e.comment.level}`]||`Level ${e.comment.level}`)},null,10,ql)):C("v-if",!0),s("span",{class:"wl-time",textContent:E(k.value)},null,8,Ol),s("div",Kl,[M.value||V.value?(i(),r(D,{key:0},[s("button",{type:"button",class:"wl-edit",onClick:u[0]||(u[0]=L=>t("edit",e.comment))},[q(y(Gt))]),s("button",{type:"button",class:"wl-delete",onClick:u[1]||(u[1]=L=>t("delete",e.comment))},[q(y(Ft))])],64)):C("v-if",!0),s("button",{type:"button",class:"wl-like",title:h.value?d.value.cancelLike:d.value.like,onClick:u[2]||(u[2]=L=>t("like",e.comment))},[q(y(Bt),{active:h.value},null,8,["active"]),te(" "+E("like"in e.comment?e.comment.like:""),1)],8,Zl),s("button",{type:"button",class:G(["wl-reply",{active:f.value}]),title:f.value?d.value.cancelReply:d.value.reply,onClick:u[3]||(u[3]=L=>t("reply",f.value?null:e.comment))},[q(y(Dt))],10,Xl)])]),s("div",Yl,[(i(),r(D,null,Z(["addr","browser","os"],L=>(i(),r(D,null,[e.comment[L]?(i(),r("span",{key:L,class:G(`wl-${L}`),"data-value":e.comment[L],textContent:E(e.comment[L])},null,10,Jl)):C("v-if",!0)],64))),64))]),e.comment.status==="waiting"&&!M.value?(i(),r("div",Ql,E(d.value.commentUnderReview),1)):C("v-if",!0),A.value?C("v-if",!0):(i(),r("div",en,["reply_user"in e.comment&&e.comment.reply_user?(i(),r("p",tn,[s("a",{href:"#"+e.comment.pid},"@"+E(e.comment.reply_user.nick),9,an),u[17]||(u[17]=s("span",null,": ",-1))])):C("v-if",!0),s("div",{innerHTML:e.comment.comment},null,8,ln)])),M.value&&!A.value?(i(),r("div",nn,[s("span",on,[(i(),r(D,null,Z(n,L=>s("button",{key:L,type:"submit",class:G(`wl-btn wl-${L}`),disabled:e.comment.status===L,onClick:H=>t("status",{status:L,comment:e.comment}),textContent:E(d.value[L])},null,10,rn)),64))]),M.value&&!("rid"in e.comment)?(i(),r("button",{key:0,type:"submit",class:"wl-btn wl-sticky",onClick:u[4]||(u[4]=L=>t("sticky",e.comment))},E(e.comment.sticky?d.value.unsticky:d.value.sticky),1)):C("v-if",!0)])):C("v-if",!0),f.value||A.value?(i(),r("div",{key:3,class:G({"wl-reply-wrapper":f.value,"wl-edit-wrapper":A.value})},[q(ut,{edit:e.edit,"reply-id":(P=e.reply)==null?void 0:P.objectId,"reply-user":e.comment.nick,"root-id":e.rootId,onLog:u[5]||(u[5]=L=>t("log")),onCancelReply:u[6]||(u[6]=L=>t("reply",null)),onCancelEdit:u[7]||(u[7]=L=>t("edit",null)),onSubmit:u[8]||(u[8]=L=>t("submit",L))},null,8,["edit","reply-id","reply-user","root-id"])],2)):C("v-if",!0),"children"in e.comment?(i(),r("div",sn,[(i(!0),r(D,null,Z(e.comment.children,L=>(i(),J(X,{key:L.objectId,comment:L,reply:e.reply,edit:e.edit,"root-id":e.rootId,onLog:u[9]||(u[9]=H=>t("log")),onDelete:u[10]||(u[10]=H=>t("delete",H)),onEdit:u[11]||(u[11]=H=>t("edit",H)),onLike:u[12]||(u[12]=H=>t("like",H)),onReply:u[13]||(u[13]=H=>t("reply",H)),onStatus:u[14]||(u[14]=H=>t("status",H)),onSticky:u[15]||(u[15]=H=>t("sticky",H)),onSubmit:u[16]||(u[16]=H=>t("submit",H))},null,8,["comment","reply","edit","root-id"]))),128))])):C("v-if",!0)])],8,Hl)}}});const mt="3.9.0",un={"data-waline":""},mn={class:"wl-meta-head"},vn={class:"wl-count"},dn=["textContent"],pn={class:"wl-sort"},gn=["onClick"],hn={class:"wl-cards"},fn={key:1,class:"wl-operation"},yn=["textContent"],wn={key:2,class:"wl-loading"},bn=["textContent"],kn={key:4,class:"wl-operation"},Cn=["textContent"],$n={key:5,class:"wl-power"};var Ln=re({__name:"WalineComment",props:{serverURL:{},path:{},meta:{},requiredMeta:{},wordLimit:{},pageSize:{},lang:{},locale:{},commentSorting:{},dark:{type:[String,Boolean]},login:{},noCopyright:{type:Boolean},recaptchaV3Key:{},turnstileKey:{},reaction:{type:[Array,Boolean]},emoji:{},search:{},highlighter:{type:Function},imageUploader:{type:Function},texRenderer:{type:Function}},setup(e){const a=e,t=Ie(),n=Pe(),o=x("loading"),v=x(0),S=x(1),b=x(0),d=W(()=>Fa(a)),R=x(d.value.commentSorting),h=x([]),k=x(null),M=x(null),V=W(()=>Ta(d.value.dark)),f=W(()=>d.value.locale);St(V,{id:"waline-darkmode"});let A=null;const $=g=>{const{serverURL:w,path:z,pageSize:F}=d.value,O=new AbortController;o.value="loading",A==null||A(),Vt({serverURL:w,lang:d.value.lang,path:z,pageSize:F,sortBy:lt[R.value],page:g,signal:O.signal,token:t.value.token}).then(T=>{o.value="success",v.value=T.count,h.value.push(...T.data),S.value=g,b.value=T.totalPages}).catch(T=>{T.name!=="AbortError"&&(console.error(T.message),o.value="error")}),A=O.abort.bind(O)},u=()=>{$(S.value+1)},P=()=>{v.value=0,h.value=[],$(1)},X=g=>{R.value!==g&&(R.value=g,P())},L=g=>{k.value=g},H=g=>{M.value=g},me=g=>{if(M.value)M.value.comment=g.comment,M.value.orig=g.orig;else if("rid"in g){const w=h.value.find(({objectId:z})=>z===g.rid);if(!w)return;Array.isArray(w.children)||(w.children=[]),w.children.push(g)}else h.value.unshift(g),v.value+=1},ve=async({comment:g,status:w})=>{if(g.status===w)return;const{serverURL:z,lang:F}=d.value;await fe({serverURL:z,lang:F,token:t.value.token,objectId:g.objectId,comment:{status:w}}),g.status=w},Q=async g=>{if("rid"in g)return;const{serverURL:w,lang:z}=d.value;await fe({serverURL:w,lang:z,token:t.value.token,objectId:g.objectId,comment:{sticky:g.sticky?0:1}}),g.sticky=!g.sticky},le=async({objectId:g})=>{if(!confirm("Are you sure you want to delete this comment?"))return;const{serverURL:w,lang:z}=d.value;await jt({serverURL:w,lang:z,token:t.value.token,objectId:g}),h.value.some((F,O)=>F.objectId===g?(h.value=h.value.filter((T,ae)=>ae!==O),!0):F.children.some((T,ae)=>T.objectId===g?(h.value[O].children=F.children.filter((U,ne)=>ne!==ae),!0):!1))},oe=async g=>{const{serverURL:w,lang:z}=d.value,{objectId:F}=g,O=n.value.includes(F);await fe({serverURL:w,lang:z,objectId:F,token:t.value.token,comment:{like:!O}}),O?n.value=n.value.filter(T=>T!==F):(n.value=[...n.value,F],n.value.length>50&&(n.value=n.value.slice(-50))),g.like=Math.max(0,(g.like||0)+(O?-1:1))};return It(ye,d),ge(()=>{se(()=>[a.serverURL,a.path],()=>{P()})}),Ue(()=>{A==null||A()}),(g,w)=>(i(),r("div",un,[q(za),!k.value&&!M.value?(i(),J(ut,{key:0,onLog:P,onSubmit:me})):C("v-if",!0),s("div",mn,[s("div",vn,[v.value?(i(),r("span",{key:0,class:"wl-num",textContent:E(v.value)},null,8,dn)):C("v-if",!0),te(" "+E(f.value.comment),1)]),s("ul",pn,[(i(!0),r(D,null,Z(y(Ca),z=>(i(),r("li",{key:z,class:G([z===R.value?"active":""]),onClick:F=>X(z)},E(f.value[z]),11,gn))),128))])]),s("div",hn,[(i(!0),r(D,null,Z(h.value,z=>(i(),J(cn,{key:z.objectId,"root-id":z.objectId,comment:z,reply:k.value,edit:M.value,onLog:P,onReply:L,onEdit:H,onSubmit:me,onStatus:ve,onDelete:le,onSticky:Q,onLike:oe},null,8,["root-id","comment","reply","edit"]))),128))]),o.value==="error"?(i(),r("div",fn,[s("button",{type:"button",class:"wl-btn",onClick:P,textContent:E(f.value.refresh)},null,8,yn)])):o.value==="loading"?(i(),r("div",wn,[q(y(ce),{size:30})])):h.value.length?S.value<b.value?(i(),r("div",kn,[s("button",{type:"button",class:"wl-btn",onClick:u,textContent:E(f.value.more)},null,8,Cn)])):C("v-if",!0):(i(),r("div",{key:3,class:"wl-empty",textContent:E(f.value.sofa)},null,8,bn)),d.value.noCopyright?C("v-if",!0):(i(),r("div",$n,[w[0]||(w[0]=te(" Powered by ",-1)),w[1]||(w[1]=s("a",{href:"https://github.com/walinejs/waline",target:"_blank",rel:"noopener noreferrer"}," Waline ",-1)),te(" v"+E(y(mt)),1)]))]))}});export{Ln as Waline,mt as version};
|
|
12
|
+
`)}catch(p){alert(p.message),v.value=v.value.replace(l,"")}finally{T.value=!1}},dt=c=>{var l;if((l=c.dataTransfer)!=null&&l.items){const p=st(c.dataTransfer.items);p&&de.value&&(be(p),c.preventDefault())}},pt=c=>{if(c.clipboardData){const l=st(c.clipboardData.items);l&&de.value&&be(l)}},gt=()=>{const c=h.value;c.files&&de.value&&be(c.files[0]).then(()=>{c.value=""})},ze=async()=>{var c;const{serverURL:l,lang:p,login:j,wordLimit:m,requiredMeta:N,recaptchaV3Key:B,turnstileKey:K}=o.value,_={comment:O.value,nick:S.value.nick,mail:S.value.mail,link:S.value.link,url:o.value.path,ua:await al()};if(!t.edit)if(b.value.token)_.nick=b.value.display_name,_.mail=b.value.email,_.link=b.value.url;else{if(j==="force")return;if(N.includes("nick")&&!_.nick){d.value.nick.focus(),alert(U.value.nickError);return}if(N.includes("mail")&&!_.mail||_.mail&&!Wa(_.mail)){d.value.mail.focus(),alert(U.value.mailError);return}_.nick||(_.nick=U.value.anonymous)}if(!_.comment){R.value.focus();return}if(!F.value){alert(U.value.wordHint.replace("$0",m[0].toString()).replace("$1",m[1].toString()).replace("$2",g.value.toString()));return}_.comment=ct(_.comment,$.value.map),t.replyId&&t.rootId&&(_.pid=t.replyId,_.rid=t.rootId,_.at=t.replyUser),T.value=!0;try{B&&(_.recaptchaV3=await aa(B).execute("social")),K&&(_.turnstile=await la(K).execute("social"));const pe={serverURL:l,lang:p,token:b.value.token,comment:_},ke=await(t.edit?fe({objectId:t.edit.objectId,...pe}):zt(pe));if(T.value=!1,ke.errmsg){alert(ke.errmsg);return}n("submit",ke.data),v.value="",oe.value="",await _e(),t.replyId&&n("cancelReply"),(c=t.edit)!=null&&c.objectId&&n("cancelEdit")}catch(pe){T.value=!1,alert(pe.message)}},ht=c=>{c.preventDefault();const{lang:l,serverURL:p}=o.value;Rt({serverURL:p,lang:l}).then(j=>{b.value=j,(j.remember?localStorage:sessionStorage).setItem("WALINE_USER",JSON.stringify(j)),n("log")})},ft=()=>{b.value={},localStorage.setItem("WALINE_USER","null"),sessionStorage.setItem("WALINE_USER","null"),n("log")},Re=c=>{c.preventDefault();const{lang:l,serverURL:p}=o.value,j=800,m=800,N=(window.innerWidth-j)/2,B=(window.innerHeight-m)/2,K=new URLSearchParams({lng:l,token:b.value.token}),_=window.open(`${p}/ui/profile?${K.toString()}`,"_blank",`width=${j},height=${m},left=${N},top=${B},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`);_==null||_.postMessage({type:"TOKEN",data:b.value.token},"*")},yt=c=>{var l,p,j,m;!((l=k.value)!=null&&l.contains(c.target))&&!((p=M.value)!=null&&p.contains(c.target))&&(P.value=!1),!((j=V.value)!=null&&j.contains(c.target))&&!((m=f.value)!=null&&m.contains(c.target))&&(Q.value=!1)},je=async c=>{var l;const{scrollTop:p,clientHeight:j,scrollHeight:m}=c.target,N=(j+p)/m,B=o.value.search,K=((l=A.value)==null?void 0:l.value)??"";N<.9||w.loading||ae.value||(w.loading=!0,(B.more&&w.list.length>0?await B.more(K,w.list.length):await B.search(K)).length>0?w.list=[...w.list,...B.more&&w.list.length>0?await B.more(K,w.list.length):await B.search(K)]:ae.value=!0,w.loading=!1,setTimeout(()=>{c.target.scrollTop=p},50))},Ve=At(c=>{w.list=[],ae.value=!1,je(c)},300);return Fe("click",yt),Fe("message",({data:c})=>{(c==null?void 0:c.type)==="profile"&&(b.value={...b.value,...c.data},[localStorage,sessionStorage].filter(l=>l.getItem("WALINE_USER")).forEach(l=>{l.setItem("WALINE_USER",JSON.stringify(b))}))}),se([o,g],([c,l])=>{const{wordLimit:p}=c;p?l<p[0]&&p[0]!==0?([z.value]=p,F.value=!1):l>p[1]?([,z.value]=p,F.value=!1):([,z.value]=p,F.value=!0):(z.value=0,F.value=!0)}),$e(Q,async c=>{var l;if(!c)return;const p=o.value.search;A.value&&(A.value.value=""),w.loading=!0,w.list=await(((l=p.default)==null?void 0:l.call(p))??p.search("")),w.loading=!1}),ge(()=>{var c;(c=t.edit)!=null&&c.objectId&&(v.value=t.edit.orig),se(()=>v.value,l=>{const{highlighter:p,texRenderer:j}=o.value;O.value=l,oe.value=Ja(l,{emojiMap:$.value.map,highlighter:p,texRenderer:j}),g.value=tl(l),l?Ne(R.value):Ne.destroy(R.value)}),se(()=>o.value.emoji,async l=>{$.value=await Oa(l)})}),(c,l)=>{var p,j;return i(),r("div",{key:y(b).token,class:"wl-comment"},[y(o).login!=="disable"&&ne.value&&!((p=e.edit)!=null&&p.objectId)?(i(),r("div",ll,[s("div",nl,[s("button",{type:"submit",class:"wl-logout-btn",title:U.value.logout,onClick:ft},[q(y(Be),{size:14})],8,il),s("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",title:U.value.profile,onClick:Re},[s("img",{src:y(b).avatar,alt:"avatar"},null,8,rl)],8,ol)]),s("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",title:U.value.profile,onClick:Re,textContent:E(y(b).display_name)},null,8,sl)])):C("v-if",!0),s("div",cl,[y(o).login!=="force"&&y(o).meta.length&&!ne.value?(i(),r("div",{key:0,class:G(["wl-header",`item${y(o).meta.length}`])},[(i(!0),r(D,null,Z(y(o).meta,m=>(i(),r("div",{key:m,class:"wl-header-item"},[s("label",{for:`wl-${m}`,textContent:E(U.value[m]+(y(o).requiredMeta.includes(m)||!y(o).requiredMeta.length?"":`(${U.value.optional})`))},null,8,ul),he(s("input",{id:`wl-${m}`,ref_for:!0,ref:N=>{N&&(d.value[m]=N)},"onUpdate:modelValue":N=>y(S)[m]=N,class:G(["wl-input",`wl-${m}`]),name:m,type:m==="mail"?"email":"text"},null,10,ml),[[kt,y(S)[m]]])]))),128))],2)):C("v-if",!0),he(s("textarea",{id:"wl-edit",ref:"textarea","onUpdate:modelValue":l[0]||(l[0]=m=>Ct(v)?v.value=m:null),class:"wl-editor",placeholder:e.replyUser?`@${e.replyUser}`:U.value.placeholder,onKeydown:vt,onDrop:dt,onPaste:pt},null,40,vl),[[$t,y(v)]]),he(s("div",dl,[l[7]||(l[7]=s("hr",null,null,-1)),s("h4",null,E(U.value.preview)+":",1),s("div",{class:"wl-content",innerHTML:oe.value},null,8,pl)],512),[[He,le.value]]),s("div",gl,[s("div",hl,[s("a",fl,[q(y(Wt))]),he(s("button",{ref:"emoji-button",type:"button",class:G(["wl-action",{active:P.value}]),title:U.value.emoji,onClick:l[1]||(l[1]=m=>P.value=!P.value)},[q(y(Tt))],10,yl),[[He,$.value.tabs.length]]),y(o).search?(i(),r("button",{key:0,ref:"gif-button",type:"button",class:G(["wl-action",{active:Q.value}]),title:U.value.gif,onClick:l[2]||(l[2]=m=>Q.value=!Q.value)},[q(y(Kt))],10,wl)):C("v-if",!0),s("input",{id:"wl-image-upload",ref:"image-uploader",class:"upload","aria-hidden":"true",type:"file",accept:".png,.jpg,.jpeg,.webp,.bmp,.gif",onChange:gt},null,544),de.value?(i(),r("label",{key:1,for:"wl-image-upload",class:"wl-action",title:U.value.uploadImage,"aria-label":U.value.uploadImage},[q(y(Nt))],8,bl)):C("v-if",!0),s("button",{type:"button",class:G(["wl-action",{active:le.value}]),title:U.value.preview,onClick:l[3]||(l[3]=m=>le.value=!le.value)},[q(y(Pt))],10,kl)]),s("div",Cl,[l[9]||(l[9]=s("div",{class:"wl-captcha-container"},null,-1)),s("div",$l,[te(E(g.value)+" ",1),y(o).wordLimit?(i(),r("span",Ll,[l[8]||(l[8]=te(" / ",-1)),s("span",{class:G({illegal:!F.value}),textContent:E(z.value)},null,10,Il)])):C("v-if",!0),te(" "+E(U.value.word),1)]),y(o).login!=="disable"&&!ne.value?(i(),r("button",{key:0,type:"button",class:"wl-btn",onClick:ht,textContent:E(U.value.login)},null,8,El)):C("v-if",!0),y(o).login!=="force"||ne.value?(i(),r("button",{key:1,type:"submit",class:"primary wl-btn",title:"Cmd|Ctrl + Enter",disabled:T.value,onClick:ze},[T.value?(i(),J(y(ce),{key:0,size:16})):(i(),r(D,{key:1},[te(E(U.value.submit),1)],64))],8,Al)):C("v-if",!0)]),s("div",{ref:"gif-popup",class:G(["wl-gif-popup",{display:Q.value}])},[s("input",{ref:"gif-search",type:"text",placeholder:U.value.gifSearchPlaceholder,onInput:l[4]||(l[4]=(...m)=>y(Ve)&&y(Ve)(...m))},null,40,Ml),w.list.length?(i(),J(Va,{key:0,items:w.list,"column-width":200,gap:6,onInsert:l[5]||(l[5]=m=>we(m)),onScroll:je},null,8,["items"])):C("v-if",!0),w.loading?(i(),r("div",Sl,[q(y(ce),{size:30})])):C("v-if",!0)],2),s("div",{ref:"emoji-popup",class:G(["wl-emoji-popup",{display:P.value}])},[(i(!0),r(D,null,Z($.value.tabs,(m,N)=>(i(),r(D,{key:m.name},[N===u.value?(i(),r("div",{key:0,class:"wl-tab-wrapper",onScroll:ve},[(i(!0),r(D,null,Z(m.items,B=>(i(),r("button",{key:B,type:"button",title:B,onClick:K=>we(`:${B}:`),onMouseenter:K=>me(K,B),onMouseleave:ve},[P.value?(i(),r("img",{key:0,class:"wl-emoji",src:$.value.map[B],alt:B,loading:"lazy",referrerPolicy:"no-referrer"},null,8,zl)):C("v-if",!0)],40,xl))),128))],32)):C("v-if",!0)],64))),128)),s("div",null,[X.value?(i(),r("img",{key:0,class:"wl-emoji-preview",src:$.value.map[X.value],alt:"preview",loading:"lazy",referrerPolicy:"no-referrer",style:Le(L.value)},null,12,Rl)):C("v-if",!0)]),$.value.tabs.length>1?(i(),r("div",jl,[(i(!0),r(D,null,Z($.value.tabs,(m,N)=>(i(),r("button",{key:m.name,type:"button",class:G(["wl-tab",{active:u.value===N}]),onClick:B=>u.value=N},[s("img",{class:"wl-emoji",src:m.icon,alt:m.name,title:m.name,loading:"lazy",referrerPolicy:"no-referrer"},null,8,Ul)],10,Vl))),128))])):C("v-if",!0)],2)])]),e.replyId||(j=e.edit)!=null&&j.objectId?(i(),r("button",{key:1,type:"button",class:"wl-close",title:U.value.cancelReply,onClick:l[6]||(l[6]=m=>e.replyId?n("cancelReply"):n("cancelEdit"))},[q(y(Be),{size:24})],8,_l)):C("v-if",!0)])}}});const Hl=["id"],Fl={class:"wl-user","aria-hidden":"true"},Tl=["src"],Nl={class:"wl-card"},Bl={class:"wl-head"},Pl=["href"],Wl={key:1,class:"wl-nick"},Dl=["textContent"],Gl=["textContent"],ql=["textContent"],Ol=["textContent"],Kl={class:"wl-comment-actions"},Zl=["title"],Xl=["title"],Yl={class:"wl-meta","aria-hidden":"true"},Jl=["data-value","textContent"],Ql={key:0,class:"wl-warning","aria-hidden":"true"},en={key:1,class:"wl-content"},tn={key:0},an=["href"],ln=["innerHTML"],nn={key:2,class:"wl-admin-actions"},on={class:"wl-comment-status"},rn=["disabled","onClick","textContent"],sn={key:4,class:"wl-quote"};var cn=re({__name:"CommentCard",props:{comment:{},edit:{},rootId:{},reply:{}},emits:["log","submit","delete","like","sticky","edit","reply","status"],setup(e,{emit:a}){const t=a,n=["approved","waiting","spam"],o=Ce(ye),v=Pe(),S=Mt(),b=Ie(),d=W(()=>o.value.locale),R=W(()=>{const{link:$}=e.comment;return $?it($)?$:`https://${$}`:""}),h=W(()=>v.value.includes(e.comment.objectId)),k=W(()=>Ba(new Date(e.comment.time),S.value,d.value)),M=W(()=>b.value.type==="administrator"),V=W(()=>e.comment.user_id&&b.value.objectId===e.comment.user_id),f=W(()=>{var $;return e.comment.objectId===(($=e.reply)==null?void 0:$.objectId)}),A=W(()=>{var $;return e.comment.objectId===(($=e.edit)==null?void 0:$.objectId)});return($,u)=>{var P;const X=Lt("CommentCard",!0);return i(),r("div",{id:e.comment.objectId.toString(),class:"wl-card-item"},[s("div",Fl,[e.comment.avatar?(i(),r("img",{key:0,class:"wl-user-avatar",src:e.comment.avatar,alt:""},null,8,Tl)):C("v-if",!0),e.comment.type==="guest"?(i(),J(y(qt),{key:1})):C("v-if",!0),e.comment.type==="administrator"?(i(),J(y(Ot),{key:2})):C("v-if",!0)]),s("div",Nl,[s("div",Bl,[R.value?(i(),r("a",{key:0,class:"wl-nick",href:R.value,target:"_blank",rel:"nofollow noopener noreferrer"},E(e.comment.nick),9,Pl)):(i(),r("span",Wl,E(e.comment.nick),1)),e.comment.label?(i(),r("span",{key:2,class:"wl-badge",textContent:E(e.comment.label)},null,8,Dl)):C("v-if",!0),e.comment.sticky?(i(),r("span",{key:3,class:"wl-badge",textContent:E(d.value.sticky)},null,8,Gl)):C("v-if",!0),typeof e.comment.level=="number"?(i(),r("span",{key:4,class:G(`wl-badge level${e.comment.level}`),textContent:E(d.value[`level${e.comment.level}`]||`Level ${e.comment.level}`)},null,10,ql)):C("v-if",!0),s("span",{class:"wl-time",textContent:E(k.value)},null,8,Ol),s("div",Kl,[M.value||V.value?(i(),r(D,{key:0},[s("button",{type:"button",class:"wl-edit",onClick:u[0]||(u[0]=L=>t("edit",e.comment))},[q(y(Gt))]),s("button",{type:"button",class:"wl-delete",onClick:u[1]||(u[1]=L=>t("delete",e.comment))},[q(y(Ft))])],64)):C("v-if",!0),s("button",{type:"button",class:"wl-like",title:h.value?d.value.cancelLike:d.value.like,onClick:u[2]||(u[2]=L=>t("like",e.comment))},[q(y(Bt),{active:h.value},null,8,["active"]),te(" "+E("like"in e.comment?e.comment.like:""),1)],8,Zl),s("button",{type:"button",class:G(["wl-reply",{active:f.value}]),title:f.value?d.value.cancelReply:d.value.reply,onClick:u[3]||(u[3]=L=>t("reply",f.value?null:e.comment))},[q(y(Dt))],10,Xl)])]),s("div",Yl,[(i(),r(D,null,Z(["addr","browser","os"],L=>(i(),r(D,null,[e.comment[L]?(i(),r("span",{key:L,class:G(`wl-${L}`),"data-value":e.comment[L],textContent:E(e.comment[L])},null,10,Jl)):C("v-if",!0)],64))),64))]),e.comment.status==="waiting"&&!M.value?(i(),r("div",Ql,E(d.value.commentUnderReview),1)):C("v-if",!0),A.value?C("v-if",!0):(i(),r("div",en,["reply_user"in e.comment&&e.comment.reply_user?(i(),r("p",tn,[s("a",{href:"#"+e.comment.pid},"@"+E(e.comment.reply_user.nick),9,an),u[17]||(u[17]=s("span",null,": ",-1))])):C("v-if",!0),s("div",{innerHTML:e.comment.comment},null,8,ln)])),M.value&&!A.value?(i(),r("div",nn,[s("span",on,[(i(),r(D,null,Z(n,L=>s("button",{key:L,type:"submit",class:G(`wl-btn wl-${L}`),disabled:e.comment.status===L,onClick:H=>t("status",{status:L,comment:e.comment}),textContent:E(d.value[L])},null,10,rn)),64))]),M.value&&!("rid"in e.comment)?(i(),r("button",{key:0,type:"submit",class:"wl-btn wl-sticky",onClick:u[4]||(u[4]=L=>t("sticky",e.comment))},E(e.comment.sticky?d.value.unsticky:d.value.sticky),1)):C("v-if",!0)])):C("v-if",!0),f.value||A.value?(i(),r("div",{key:3,class:G({"wl-reply-wrapper":f.value,"wl-edit-wrapper":A.value})},[q(ut,{edit:e.edit,"reply-id":(P=e.reply)==null?void 0:P.objectId,"reply-user":e.comment.nick,"root-id":e.rootId,onLog:u[5]||(u[5]=L=>t("log")),onCancelReply:u[6]||(u[6]=L=>t("reply",null)),onCancelEdit:u[7]||(u[7]=L=>t("edit",null)),onSubmit:u[8]||(u[8]=L=>t("submit",L))},null,8,["edit","reply-id","reply-user","root-id"])],2)):C("v-if",!0),"children"in e.comment?(i(),r("div",sn,[(i(!0),r(D,null,Z(e.comment.children,L=>(i(),J(X,{key:L.objectId,comment:L,reply:e.reply,edit:e.edit,"root-id":e.rootId,onLog:u[9]||(u[9]=H=>t("log")),onDelete:u[10]||(u[10]=H=>t("delete",H)),onEdit:u[11]||(u[11]=H=>t("edit",H)),onLike:u[12]||(u[12]=H=>t("like",H)),onReply:u[13]||(u[13]=H=>t("reply",H)),onStatus:u[14]||(u[14]=H=>t("status",H)),onSticky:u[15]||(u[15]=H=>t("sticky",H)),onSubmit:u[16]||(u[16]=H=>t("submit",H))},null,8,["comment","reply","edit","root-id"]))),128))])):C("v-if",!0)])],8,Hl)}}});const mt="3.11.0",un={"data-waline":""},mn={class:"wl-meta-head"},vn={class:"wl-count"},dn=["textContent"],pn={class:"wl-sort"},gn=["onClick"],hn={class:"wl-cards"},fn={key:1,class:"wl-operation"},yn=["textContent"],wn={key:2,class:"wl-loading"},bn=["textContent"],kn={key:4,class:"wl-operation"},Cn=["textContent"],$n={key:5,class:"wl-power"};var Ln=re({__name:"WalineComment",props:{serverURL:{},path:{},meta:{},requiredMeta:{},wordLimit:{},pageSize:{},lang:{},locale:{},commentSorting:{},dark:{type:[String,Boolean]},login:{},noCopyright:{type:Boolean},recaptchaV3Key:{},turnstileKey:{},reaction:{type:[Array,Boolean]},emoji:{},search:{},highlighter:{type:Function},imageUploader:{type:Function},texRenderer:{type:Function}},setup(e){const a=e,t=Ie(),n=Pe(),o=x("loading"),v=x(0),S=x(1),b=x(0),d=W(()=>Fa(a)),R=x(d.value.commentSorting),h=x([]),k=x(null),M=x(null),V=W(()=>Ta(d.value.dark)),f=W(()=>d.value.locale);St(V,{id:"waline-darkmode"});let A=null;const $=g=>{const{serverURL:w,path:z,pageSize:F}=d.value,O=new AbortController;o.value="loading",A==null||A(),Vt({serverURL:w,lang:d.value.lang,path:z,pageSize:F,sortBy:lt[R.value],page:g,signal:O.signal,token:t.value.token}).then(T=>{o.value="success",v.value=T.count,h.value.push(...T.data),S.value=g,b.value=T.totalPages}).catch(T=>{T.name!=="AbortError"&&(console.error(T.message),o.value="error")}),A=O.abort.bind(O)},u=()=>{$(S.value+1)},P=()=>{v.value=0,h.value=[],$(1)},X=g=>{R.value!==g&&(R.value=g,P())},L=g=>{k.value=g},H=g=>{M.value=g},me=g=>{if(M.value)M.value.comment=g.comment,M.value.orig=g.orig;else if("rid"in g){const w=h.value.find(({objectId:z})=>z===g.rid);if(!w)return;Array.isArray(w.children)||(w.children=[]),w.children.push(g)}else h.value.unshift(g),v.value+=1},ve=async({comment:g,status:w})=>{if(g.status===w)return;const{serverURL:z,lang:F}=d.value;await fe({serverURL:z,lang:F,token:t.value.token,objectId:g.objectId,comment:{status:w}}),g.status=w},Q=async g=>{if("rid"in g)return;const{serverURL:w,lang:z}=d.value;await fe({serverURL:w,lang:z,token:t.value.token,objectId:g.objectId,comment:{sticky:g.sticky?0:1}}),g.sticky=!g.sticky},le=async({objectId:g})=>{if(!confirm("Are you sure you want to delete this comment?"))return;const{serverURL:w,lang:z}=d.value;await jt({serverURL:w,lang:z,token:t.value.token,objectId:g}),h.value.some((F,O)=>F.objectId===g?(h.value=h.value.filter((T,ae)=>ae!==O),!0):F.children.some((T,ae)=>T.objectId===g?(h.value[O].children=F.children.filter((U,ne)=>ne!==ae),!0):!1))},oe=async g=>{const{serverURL:w,lang:z}=d.value,{objectId:F}=g,O=n.value.includes(F);await fe({serverURL:w,lang:z,objectId:F,token:t.value.token,comment:{like:!O}}),O?n.value=n.value.filter(T=>T!==F):(n.value=[...n.value,F],n.value.length>50&&(n.value=n.value.slice(-50))),g.like=Math.max(0,(g.like||0)+(O?-1:1))};return It(ye,d),ge(()=>{se(()=>[a.serverURL,a.path],()=>{P()})}),Ue(()=>{A==null||A()}),(g,w)=>(i(),r("div",un,[q(za),!k.value&&!M.value?(i(),J(ut,{key:0,onLog:P,onSubmit:me})):C("v-if",!0),s("div",mn,[s("div",vn,[v.value?(i(),r("span",{key:0,class:"wl-num",textContent:E(v.value)},null,8,dn)):C("v-if",!0),te(" "+E(f.value.comment),1)]),s("ul",pn,[(i(!0),r(D,null,Z(y(Ca),z=>(i(),r("li",{key:z,class:G([z===R.value?"active":""]),onClick:F=>X(z)},E(f.value[z]),11,gn))),128))])]),s("div",hn,[(i(!0),r(D,null,Z(h.value,z=>(i(),J(cn,{key:z.objectId,"root-id":z.objectId,comment:z,reply:k.value,edit:M.value,onLog:P,onReply:L,onEdit:H,onSubmit:me,onStatus:ve,onDelete:le,onSticky:Q,onLike:oe},null,8,["root-id","comment","reply","edit"]))),128))]),o.value==="error"?(i(),r("div",fn,[s("button",{type:"button",class:"wl-btn",onClick:P,textContent:E(f.value.refresh)},null,8,yn)])):o.value==="loading"?(i(),r("div",wn,[q(y(ce),{size:30})])):h.value.length?S.value<b.value?(i(),r("div",kn,[s("button",{type:"button",class:"wl-btn",onClick:u,textContent:E(f.value.more)},null,8,Cn)])):C("v-if",!0):(i(),r("div",{key:3,class:"wl-empty",textContent:E(f.value.sofa)},null,8,bn)),d.value.noCopyright?C("v-if",!0):(i(),r("div",$n,[w[0]||(w[0]=te(" Powered by ",-1)),w[1]||(w[1]=s("a",{href:"https://github.com/walinejs/waline",target:"_blank",rel:"noopener noreferrer"}," Waline ",-1)),te(" v"+E(y(mt)),1)]))]))}});export{Ln as Waline,mt as version};
|
|
13
13
|
//# sourceMappingURL=component.js.map
|