@waline/client 3.0.0-alpha.11 → 3.0.0-alpha.12
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/README.md +3 -1
- 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/slim.d.ts +4 -0
- package/dist/slim.js +1 -1
- 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 +4 -0
- package/dist/waline.js +4 -4
- package/dist/waline.js.map +1 -1
- package/dist/waline.umd.js +19 -19
- package/dist/waline.umd.js.map +1 -1
- package/package.json +13 -13
package/README.md
CHANGED
package/dist/comment.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const h=e=>`${e.replace(/\/?$/,"/")}api/`,i=(e,t="")=>{if(typeof e=="object"&&e.errno)throw new TypeError(`${t} failed with ${e.errno}: ${e.errmsg}`);return e},p=({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=>i(n,"Get comment count").data),g=e=>{try{e=decodeURI(e)}catch{}return e},m=(e="")=>e.replace(/\/$/u,""),u=e=>/^(https?:)?\/\//.test(e),d=e=>{const t=m(e);return u(t)?t:`https://${t}`},$=e=>{e.name!=="AbortError"&&console.error(e.message)},f=e=>e.dataset.path||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&&p({serverURL:d(e),paths:Array.from(a).map(c=>g(f(c)||t)),lang:o,signal:n.signal}).then(c=>{a.forEach((s,l)=>{s.innerText=c[l].toString()})}).catch($),n.abort.bind(n)},w="3.0.0-alpha.
|
|
1
|
+
const h=e=>`${e.replace(/\/?$/,"/")}api/`,i=(e,t="")=>{if(typeof e=="object"&&e.errno)throw new TypeError(`${t} failed with ${e.errno}: ${e.errmsg}`);return e},p=({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=>i(n,"Get comment count").data),g=e=>{try{e=decodeURI(e)}catch{}return e},m=(e="")=>e.replace(/\/$/u,""),u=e=>/^(https?:)?\/\//.test(e),d=e=>{const t=m(e);return u(t)?t:`https://${t}`},$=e=>{e.name!=="AbortError"&&console.error(e.message)},f=e=>e.dataset.path||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&&p({serverURL:d(e),paths:Array.from(a).map(c=>g(f(c)||t)),lang:o,signal:n.signal}).then(c=>{a.forEach((s,l)=>{s.innerText=c[l].toString()})}).catch($),n.abort.bind(n)},w="3.0.0-alpha.12";export{v as commentCount,w as version};
|
|
2
2
|
//# sourceMappingURL=comment.js.map
|
package/dist/component.js
CHANGED
|
@@ -6,5 +6,5 @@ import{h as R,defineComponent as ce,inject as ke,ref as L,computed as W,onMounte
|
|
|
6
6
|
Номер текущего слова: $2`,"Анонимный","Dwarves","Hobbits","Ents","Wizards","Elves","Maiar","GIF","Поиск GIF","Персональные данные","Одобренный","Ожидающий","Спам","Нелипкий","самый старый","последний","самый горячий","Что вы думаете?"]),ot=oe(["昵称","昵称不能少于3个字符","邮箱","请填写正确的邮件地址","网址","可选","欢迎评论","来发评论吧~","提交","喜欢","取消喜欢","回复","取消回复","评论","刷新","加载更多...","预览","表情","上传图片","秒前","分钟前","小时前","天前","刚刚","正在上传","登录","退出","博主","置顶","字",`评论字数应在 $0 到 $1 字之间!
|
|
7
7
|
当前字数:$2`,"匿名","潜水","冒泡","吐槽","活跃","话痨","传说","表情包","搜索表情包","个人资料","通过","待审核","垃圾","取消置顶","按倒序","按正序","按热度","你认为这篇文章怎么样?"]),El=oe(["暱稱","暱稱不能少於3個字元","郵箱","請填寫正確的郵件地址","網址","可選","歡迎留言","來發留言吧~","送出","喜歡","取消喜歡","回覆","取消回覆","留言","重整","載入更多...","預覽","表情","上傳圖片","秒前","分鐘前","小時前","天前","剛剛","正在上傳","登入","登出","管理者","置頂","字",`留言字數應在 $0 到 $1 字之間!
|
|
8
8
|
目前字數:$2`,"匿名","潛水","冒泡","吐槽","活躍","多話","傳說","表情包","搜尋表情包","個人資料","通過","待審核","垃圾","取消置頂","最早","最新","熱門","你認為這篇文章怎麼樣?"]);const it="en-US",Le={zh:ot,"zh-cn":ot,"zh-tw":El,en:tt,"en-us":tt,fr:lt,"fr-fr":lt,jp:at,"jp-jp":at,"pt-br":xl,ru:nt,"ru-ru":nt},Rl=e=>Le[e.toLowerCase()]||Le[it],_l=e=>Object.keys(Le).includes(e.toLowerCase())?e:it,Ml=e=>{const a=Je(e);return Xe(a)?a:`https://${a}`},Al=e=>Array.isArray(e)?e:e?[0,e]:!1,Ie=(e,a)=>typeof e=="function"?e:e===!1?!1:a,Sl=({serverURL:e,path:a=location.pathname,lang:l=typeof navigator>"u"?"en-US":navigator.language,locale:t,emoji:u=Qe,meta:i=["nick","mail","link"],requiredMeta:k=[],dark:M=!1,pageSize:b=10,wordLimit:I,imageUploader:C,highlighter:V,texRenderer:m,copyright:A=!0,login:z="enable",search:$,reaction:p,recaptchaV3Key:n="",turnstileKey:d="",commentSorting:F="latest",...P})=>({serverURL:Ml(e),path:dl(a),lang:_l(l),locale:{...Rl(l),...typeof t=="object"?t:{}},wordLimit:Al(I),meta:Ye(i),requiredMeta:Ye(k),imageUploader:Ie(C,hl),highlighter:Ie(V,Ll),texRenderer:Ie(m,fl),dark:M,emoji:typeof u=="boolean"?u?Qe:[]:u,pageSize:b,login:z,copyright:A,search:$===!1?!1:typeof $=="object"?$:yl(l),recaptchaV3Key:n,turnstileKey:d,reaction:Array.isArray(p)?p:p===!0?gl:[],commentSorting:F,...P}),xe=e=>typeof e=="string",Ee="{--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}",zl=e=>xe(e)?e==="auto"?`@media(prefers-color-scheme:dark){body${Ee}}`:`${e}${Ee}`:e===!0?`:root${Ee}`:"",Re=(e,a)=>{let l=e.toString();for(;l.length<a;)l="0"+l;return l},jl=e=>{const a=Re(e.getDate(),2),l=Re(e.getMonth()+1,2);return`${Re(e.getFullYear(),2)}-${l}-${a}`},Ul=(e,a,l)=>{if(!e)return"";const t=xe(e)?new Date(e.indexOf(" ")!==-1?e.replace(/-/g,"/"):e):e,u=a.getTime()-t.getTime(),i=Math.floor(u/(24*3600*1e3));if(i===0){const k=u%864e5,M=Math.floor(k/(3600*1e3));if(M===0){const b=k%36e5,I=Math.floor(b/(60*1e3));if(I===0){const C=b%6e4;return`${Math.round(C/1e3)} ${l.seconds}`}return`${I} ${l.minutes}`}return`${M} ${l.hours}`}return i<0?l.now:i<8?`${i} ${l.days}`:jl(t)},Vl=/^[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])?)*$/,Hl=e=>Vl.test(e),Tl=e=>!!/@[0-9]+\.[0-9]+\.[0-9]+/.test(e),Fl=e=>{const a=re("WALINE_EMOJI",{}),l=Tl(e);if(l){const t=a.value[e];if(t)return Promise.resolve(t)}return fetch(`${e}/info.json`).then(t=>t.json()).then(t=>{const u={folder:e,...t};return l&&(a.value[e]=u),u})},rt=(e,a="",l="",t="")=>`${a?`${a}/`:""}${l}${e}${t?`.${t}`:""}`,Nl=e=>Promise.all(e.map(a=>xe(a)?Fl(Je(a)):Promise.resolve(a))).then(a=>{const l={tabs:[],map:{}};return a.forEach(t=>{const{name:u,folder:i,icon:k,prefix:M,type:b,items:I}=t;l.tabs.push({name:u,icon:rt(k,i,M,b),items:I.map(C=>{const V=`${M||""}${C}`;return l.map[V]=rt(C,i,M,b),V})})}),l}),Wl=e=>e.type.includes("image"),st=e=>{const a=Array.from(e).find(Wl);return a?a.getAsFile():null},Dl=/\$.*?\$/,Pl=/^\$(.*?)\$/,Bl=/^(?:\s{0,3})\$\$((?:[^\n]|\n[^\n])+?)\n{0,1}\$\$/,Ol=e=>[{name:"blockMath",level:"block",tokenizer(a){const l=Bl.exec(a);if(l!==null)return{type:"html",raw:l[0],text:e(!0,l[1])}}},{name:"inlineMath",level:"inline",start(a){const l=a.search(Dl);return l!==-1?l:a.length},tokenizer(a){const l=Pl.exec(a);if(l!==null)return{type:"html",raw:l[0],text:e(!1,l[1])}}}],ct=(e="",a={})=>e.replace(/:(.+?):/g,(l,t)=>a[t]?`<img class="wl-emoji" src="${a[t]}" alt="${t}">`:l),ql=(e,{emojiMap:a,highlighter:l,texRenderer:t})=>{const u=new St;if(u.setOptions({breaks:!0}),l&&u.use(zt({highlight:l})),t){const i=Ol(t);u.use({extensions:i})}return u.parse(ct(e,a))},Kl=e=>e.match(/[\w\d\s,.\u00C0-\u024F\u0400-\u04FF]+/giu),Zl=e=>e.match(/[\u4E00-\u9FD5]/gu),Gl=e=>{var a,l;return(((a=Kl(e))==null?void 0:a.reduce((t,u)=>t+(["",",","."].includes(u.trim())?0:u.trim().split(/\s+/u).length),0))||0)+(((l=Zl(e))==null?void 0:l.length)||0)},Jl=async()=>{if(!navigator)return"";const{userAgentData:e}=navigator;let a=navigator.userAgent;if(!e||e.platform!=="Windows")return a;const{platformVersion:l}=await e.getHighEntropyValues(["platformVersion"]);return l&&parseInt(l.split(".")[0])>=13&&(a=a.replace("Windows NT 10.0","Windows NT 11.0")),a},Xl={class:"wl-comment"},Yl={key:0,class:"wl-login-info"},Ql={class:"wl-avatar"},ea=["title"],ta=["title"],la=["src"],aa=["title","textContent"],na={class:"wl-panel"},oa=["for","textContent"],ia=["id","onUpdate:modelValue","name","type"],ra=["placeholder"],sa={class:"wl-preview"},ca=v("hr",null,null,-1),ua=["innerHTML"],va={class:"wl-footer"},ma={class:"wl-actions"},da={href:"https://guides.github.com/features/mastering-markdown/",title:"Markdown Guide","aria-label":"Markdown is supported",class:"wl-action",target:"_blank",rel:"noopener noreferrer"},pa=["title"],ga=["title"],ha=["title"],fa=["title"],ya={class:"wl-info"},wa=v("div",{class:"wl-captcha-container"},null,-1),ka={class:"wl-text-number"},ba={key:0},Ca=["textContent"],$a=["textContent"],La=["disabled"],Ia=["placeholder"],xa={key:1,class:"wl-loading"},Ea={key:0,class:"wl-tab-wrapper"},Ra=["title","onClick"],_a=["src","alt"],Ma={key:0,class:"wl-tabs"},Aa=["onClick"],Sa=["src","alt","title"],za=["title"];var ja=ce({__name:"CommentBox",props:{edit:{default:null},rootId:{default:""},replyId:{default:""},replyUser:{default:""}},emits:["log","cancelEdit","cancelReply","submit"],setup(e,{expose:a,emit:l}){const t=e,u=l;a();const i=ke("config"),k=qt(),M=Ot(),b=Ce(),I=L({}),C=L(null),V=L(null),m=L(null),A=L(null),z=L(null),$=L(null),p=L(null),n=L({tabs:[],map:{}}),d=L(0),F=L(!1),P=L(!1),E=L(!1),j=L(""),ie=L(0),H=ft({loading:!0,list:[]}),ne=L(0),ee=L(!1),me=L(""),Y=L(!1),y=L(!1),g=W(()=>i.value.locale),S=W(()=>{var c;return!!((c=b.value)!=null&&c.token)}),K=W(()=>i.value.imageUploader!==!1),B=c=>{const r=C.value,h=r.selectionStart,U=r.selectionEnd||0,f=r.scrollTop;k.value=r.value.substring(0,h)+c+r.value.substring(U,r.value.length),r.focus(),r.selectionStart=h+c.length,r.selectionEnd=h+c.length,r.scrollTop=f},J=c=>{const r=c.key;(c.ctrlKey||c.metaKey)&&r==="Enter"&&Me()},Z=c=>{const r=`![${i.value.locale.uploading} ${c.name}]()`;return B(r),Y.value=!0,Promise.resolve().then(()=>i.value.imageUploader(c)).then(h=>{k.value=k.value.replace(r,`\r
|
|
9
|
-
`)}).catch(h=>{alert(h.message),k.value=k.value.replace(r,"")}).then(()=>{Y.value=!1})},se=c=>{var r;if((r=c.dataTransfer)!=null&&r.items){const h=st(c.dataTransfer.items);h&&K.value&&(Z(h),c.preventDefault())}},_e=c=>{if(c.clipboardData){const r=st(c.clipboardData.items);r&&K.value&&Z(r)}},ye=()=>{const c=V.value;c.files&&K.value&&Z(c.files[0]).then(()=>{c.value=""})},Me=async()=>{var c,r,h,U,f,O;const{serverURL:N,lang:Q,login:de,wordLimit:Ve,requiredMeta:He,recaptchaV3Key:Te,turnstileKey:Fe}=i.value,pt=await Jl(),T={comment:me.value,nick:M.value.nick,mail:M.value.mail,link:M.value.link,url:i.value.path,ua:pt};if((c=b.value)!=null&&c.token)T.nick=b.value.display_name,T.mail=b.value.email,T.link=b.value.url;else{if(de==="force")return;if(He.indexOf("nick")>-1&&!T.nick)return(r=I.value.nick)==null||r.focus(),alert(g.value.nickError);if(He.indexOf("mail")>-1&&!T.mail||T.mail&&!Hl(T.mail))return(h=I.value.mail)==null||h.focus(),alert(g.value.mailError);T.nick||(T.nick=g.value.anonymous)}if(!T.comment){(U=C.value)==null||U.focus();return}if(!ee.value)return alert(g.value.wordHint.replace("$0",Ve[0].toString()).replace("$1",Ve[1].toString()).replace("$2",ie.value.toString()));T.comment=ct(T.comment,n.value.map),t.replyId&&t.rootId&&(T.pid=t.replyId,T.rid=t.rootId,T.at=t.replyUser),Y.value=!0;try{Te&&(T.recaptchaV3=await Jt(Te).execute("social")),Fe&&(T.turnstile=await Xt(Fe).execute("social"));const pe={serverURL:N,lang:Q,token:(f=b.value)==null?void 0:f.token,comment:T},we=await(t.edit?fe({objectId:t.edit.objectId,...pe}):Rt(pe));if(Y.value=!1,we.errmsg)return alert(we.errmsg);u("submit",we.data),k.value="",j.value="",t.replyId&&u("cancelReply"),(O=t.edit)!=null&&O.objectId&&u("cancelEdit")}catch(pe){Y.value=!1,alert(pe.message)}},mt=c=>{c.preventDefault();const{lang:r,serverURL:h}=i.value;_t({serverURL:h,lang:r}).then(U=>{b.value=U,(U.remember?localStorage:sessionStorage).setItem("WALINE_USER",JSON.stringify(U)),u("log")})},dt=()=>{b.value={},localStorage.setItem("WALINE_USER","null"),sessionStorage.setItem("WALINE_USER","null"),u("log")},Ae=c=>{c.preventDefault();const{lang:r,serverURL:h}=i.value,U=800,f=800,O=(window.innerWidth-U)/2,N=(window.innerHeight-f)/2,Q=new URLSearchParams({lng:r,token:b.value.token}),de=window.open(`${h}/ui/profile?${Q.toString()}`,"_blank",`width=${U},height=${f},left=${O},top=${N},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`);de==null||de.postMessage({type:"TOKEN",data:b.value.token},"*")},Se=c=>{var r,h,U,f;!((r=m.value)!=null&&r.contains(c.target))&&!((h=A.value)!=null&&h.contains(c.target))&&(F.value=!1),!((U=z.value)!=null&&U.contains(c.target))&&!((f=$.value)!=null&&f.contains(c.target))&&(P.value=!1)},ze=async c=>{var r;const{scrollTop:h,clientHeight:U,scrollHeight:f}=c.target,O=(U+h)/f,N=i.value.search,Q=((r=p.value)==null?void 0:r.value)||"";O<.9||H.loading||y.value||(H.loading=!0,(N.more&&H.list.length?await N.more(Q,H.list.length):await N.search(Q)).length?H.list=[...H.list,...N.more&&H.list.length?await N.more(Q,H.list.length):await N.search(Q)]:y.value=!0,H.loading=!1,setTimeout(()=>{c.target.scrollTop=h},50))},je=Lt(c=>{H.list=[],y.value=!1,ze(c)},300);te([i,ie],([c,r])=>{const{wordLimit:h}=c;h?r<h[0]&&h[0]!==0?(ne.value=h[0],ee.value=!1):r>h[1]?(ne.value=h[1],ee.value=!1):(ne.value=h[1],ee.value=!0):(ne.value=0,ee.value=!0)},{immediate:!0});const Ue=({data:c})=>{!c||c.type!=="profile"||(b.value={...b.value,...c.data},[localStorage,sessionStorage].filter(r=>r.getItem("WALINE_USER")).forEach(r=>r.setItem("WALINE_USER",JSON.stringify(b))))};return ge(()=>{var c;document.body.addEventListener("click",Se),window.addEventListener("message",Ue),(c=t.edit)!=null&&c.objectId&&(k.value=t.edit.orig),te(P,async r=>{if(!r)return;const h=i.value.search;p.value&&(p.value.value=""),H.loading=!0,H.list=h.default?await h.default():await h.search(""),H.loading=!1}),te(()=>k.value,r=>{const{highlighter:h,texRenderer:U}=i.value;me.value=r,j.value=ql(r,{emojiMap:n.value.map,highlighter:h,texRenderer:U}),ie.value=Gl(r),r?Pe(C.value):Pe.destroy(C.value)},{immediate:!0}),te(()=>i.value.emoji,r=>Nl(r).then(h=>{n.value=h}),{immediate:!0})}),be(()=>{document.body.removeEventListener("click",Se),window.removeEventListener("message",Ue)}),(c,r)=>{var h,U;return o(),s("div",Xl,[w(i).login!=="disable"&&S.value&&!((h=c.edit)!=null&&h.objectId)?(o(),s("div",Yl,[v("div",Ql,[v("button",{type:"submit",class:"wl-logout-btn",title:g.value.logout,onClick:dt},[G(w(Be),{size:14})],8,ea),v("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",title:g.value.profile,onClick:Ae},[v("img",{src:w(b).avatar,alt:"avatar"},null,8,la)],8,ta)]),v("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",title:g.value.profile,onClick:Ae,textContent:_(w(b).display_name)},null,8,aa)])):x("v-if",!0),v("div",na,[w(i).login!=="force"&&w(i).meta.length&&!S.value?(o(),s("div",{key:0,class:q(["wl-header",`item${w(i).meta.length}`])},[(o(!0),s(D,null,X(w(i).meta,f=>(o(),s("div",{key:f,class:"wl-header-item"},[v("label",{for:`wl-${f}`,textContent:_(g.value[f]+(w(i).requiredMeta.includes(f)||!w(i).requiredMeta.length?"":`(${g.value.optional})`))},null,8,oa),he(v("input",{id:`wl-${f}`,ref_for:!0,ref:O=>{O&&(I.value[f]=O)},"onUpdate:modelValue":O=>w(M)[f]=O,class:q(["wl-input",`wl-${f}`]),name:f,type:f==="mail"?"email":"text"},null,10,ia),[[yt,w(M)[f]]])]))),128))],2)):x("v-if",!0),he(v("textarea",{id:"wl-edit",ref_key:"editorRef",ref:C,"onUpdate:modelValue":r[0]||(r[0]=f=>wt(k)?k.value=f:null),class:"wl-editor",placeholder:c.replyUser?`@${c.replyUser}`:g.value.placeholder,onKeydown:J,onDrop:se,onPaste:_e},null,40,ra),[[kt,w(k)]]),he(v("div",sa,[ca,v("h4",null,_(g.value.preview)+":",1),v("div",{class:"wl-content",innerHTML:j.value},null,8,ua)],512),[[We,E.value]]),v("div",va,[v("div",ma,[v("a",da,[G(w(Nt))]),he(v("button",{ref_key:"emojiButtonRef",ref:m,type:"button",class:q(["wl-action",{active:F.value}]),title:g.value.emoji,onClick:r[1]||(r[1]=f=>F.value=!F.value)},[G(w(Vt))],10,pa),[[We,n.value.tabs.length]]),w(i).search?(o(),s("button",{key:0,ref_key:"gifButtonRef",ref:z,type:"button",class:q(["wl-action",{active:P.value}]),title:g.value.gif,onClick:r[2]||(r[2]=f=>P.value=!P.value)},[G(w(Bt))],10,ga)):x("v-if",!0),v("input",{id:"wl-image-upload",ref_key:"imageUploadRef",ref:V,class:"upload",type:"file",accept:".png,.jpg,.jpeg,.webp,.bmp,.gif",onChange:ye},null,544),K.value?(o(),s("label",{key:1,for:"wl-image-upload",class:"wl-action",title:g.value.uploadImage},[G(w(Ht))],8,ha)):x("v-if",!0),v("button",{type:"button",class:q(["wl-action",{active:E.value}]),title:g.value.preview,onClick:r[3]||(r[3]=f=>E.value=!E.value)},[G(w(Ft))],10,fa)]),v("div",ya,[wa,v("div",ka,[ae(_(ie.value)+" ",1),w(i).wordLimit?(o(),s("span",ba,[ae(" / "),v("span",{class:q({illegal:!ee.value}),textContent:_(ne.value)},null,10,Ca)])):x("v-if",!0),ae(" "+_(g.value.word),1)]),w(i).login!=="disable"&&!S.value?(o(),s("button",{key:0,type:"button",class:"wl-btn",onClick:mt,textContent:_(g.value.login)},null,8,$a)):x("v-if",!0),w(i).login!=="force"||S.value?(o(),s("button",{key:1,type:"submit",class:"primary wl-btn",title:"Cmd|Ctrl + Enter",disabled:Y.value,onClick:Me},[Y.value?(o(),le(w(ue),{key:0,size:16})):(o(),s(D,{key:1},[ae(_(g.value.submit),1)],64))],8,La)):x("v-if",!0)]),v("div",{ref_key:"gifPopupRef",ref:$,class:q(["wl-gif-popup",{display:P.value}])},[v("input",{ref_key:"gifSearchInputRef",ref:p,type:"text",placeholder:g.value.gifSearchPlaceholder,onInput:r[4]||(r[4]=(...f)=>w(je)&&w(je)(...f))},null,40,Ia),H.list.length?(o(),le(ml,{key:0,items:H.list,"column-width":200,gap:6,onInsert:r[5]||(r[5]=f=>B(f)),onScroll:ze},null,8,["items"])):x("v-if",!0),H.loading?(o(),s("div",xa,[G(w(ue),{size:30})])):x("v-if",!0)],2),v("div",{ref_key:"emojiPopupRef",ref:A,class:q(["wl-emoji-popup",{display:F.value}])},[(o(!0),s(D,null,X(n.value.tabs,(f,O)=>(o(),s(D,{key:f.name},[O===d.value?(o(),s("div",Ea,[(o(!0),s(D,null,X(f.items,N=>(o(),s("button",{key:N,type:"button",title:N,onClick:Q=>B(`:${N}:`)},[F.value?(o(),s("img",{key:0,class:"wl-emoji",src:n.value.map[N],alt:N,loading:"lazy",referrerPolicy:"no-referrer"},null,8,_a)):x("v-if",!0)],8,Ra))),128))])):x("v-if",!0)],64))),128)),n.value.tabs.length>1?(o(),s("div",Ma,[(o(!0),s(D,null,X(n.value.tabs,(f,O)=>(o(),s("button",{key:f.name,type:"button",class:q(["wl-tab",{active:d.value===O}]),onClick:N=>d.value=O},[v("img",{class:"wl-emoji",src:f.icon,alt:f.name,title:f.name,loading:"lazy",referrerPolicy:"no-referrer"},null,8,Sa)],10,Aa))),128))])):x("v-if",!0)],2)])]),c.replyId||(U=c.edit)!=null&&U.objectId?(o(),s("button",{key:1,type:"button",class:"wl-close",title:g.value.cancelReply,onClick:r[6]||(r[6]=f=>c.$emit(c.replyId?"cancelReply":"cancelEdit"))},[G(w(Be),{size:24})],8,za)):x("v-if",!0)])}}}),ut=ve(ja,[["__file","CommentBox.vue"]]);const Ua=["id"],Va={class:"wl-user","aria-hidden":"true"},Ha=["src"],Ta={class:"wl-card"},Fa={class:"wl-head"},Na=["href"],Wa={key:1,class:"wl-nick"},Da=["textContent"],Pa=["textContent"],Ba=["textContent"],Oa=["textContent"],qa=["textContent"],Ka={class:"wl-comment-actions"},Za=["title"],Ga=["title"],Ja={class:"wl-meta","aria-hidden":"true"},Xa=["data-value","textContent"],Ya=["innerHTML"],Qa={key:1,class:"wl-admin-actions"},en={class:"wl-comment-status"},tn=["disabled","onClick","textContent"],ln={key:3,class:"wl-quote"};var an=ce({__name:"CommentCard",props:{comment:{},edit:{default:null},rootId:{},reply:{default:null}},emits:["log","submit","delete","edit","like","status","sticky","reply"],setup(e,{emit:a}){const l=e,t=a,u=["approved","waiting","spam"],i=ke("config"),k=qe(),M=It(),b=Ce(),I=W(()=>i.value.locale),C=W(()=>{const{link:n}=l.comment;return n?Xe(n)?n:`https://${n}`:""}),V=W(()=>k.value.includes(l.comment.objectId)),m=W(()=>Ul(new Date(l.comment.time),M.value,I.value)),A=W(()=>b.value.type==="administrator"),z=W(()=>l.comment.user_id&&b.value.objectId===l.comment.user_id),$=W(()=>{var n;return l.comment.objectId===((n=l.reply)==null?void 0:n.objectId)}),p=W(()=>{var n;return l.comment.objectId===((n=l.edit)==null?void 0:n.objectId)});return(n,d)=>{var F;const P=bt("CommentCard",!0);return o(),s("div",{id:n.comment.objectId,class:"wl-card-item"},[v("div",Va,[n.comment.avatar?(o(),s("img",{key:0,class:"wl-user-avatar",src:n.comment.avatar},null,8,Ha)):x("v-if",!0),n.comment.type?(o(),le(w(Pt),{key:1})):x("v-if",!0)]),v("div",Ta,[v("div",Fa,[C.value?(o(),s("a",{key:0,class:"wl-nick",href:C.value,target:"_blank",rel:"nofollow noopener noreferrer"},_(n.comment.nick),9,Na)):(o(),s("span",Wa,_(n.comment.nick),1)),n.comment.type==="administrator"?(o(),s("span",{key:2,class:"wl-badge",textContent:_(I.value.admin)},null,8,Da)):x("v-if",!0),n.comment.label?(o(),s("span",{key:3,class:"wl-badge",textContent:_(n.comment.label)},null,8,Pa)):x("v-if",!0),n.comment.sticky?(o(),s("span",{key:4,class:"wl-badge",textContent:_(I.value.sticky)},null,8,Ba)):x("v-if",!0),typeof n.comment.level=="number"?(o(),s("span",{key:5,class:q(`wl-badge level${n.comment.level}`),textContent:_(I.value[`level${n.comment.level}`]||`Level ${n.comment.level}`)},null,10,Oa)):x("v-if",!0),v("span",{class:"wl-time",textContent:_(m.value)},null,8,qa),v("div",Ka,[A.value||z.value?(o(),s(D,{key:0},[v("button",{type:"button",class:"wl-edit",onClick:d[0]||(d[0]=E=>t("edit",n.comment))},[G(w(Dt))]),v("button",{type:"button",class:"wl-delete",onClick:d[1]||(d[1]=E=>t("delete",n.comment))},[G(w(Ut))])],64)):x("v-if",!0),v("button",{type:"button",class:"wl-like",title:V.value?I.value.cancelLike:I.value.like,onClick:d[2]||(d[2]=E=>t("like",n.comment))},[G(w(Tt),{active:V.value},null,8,["active"]),ae(" "+_("like"in n.comment?n.comment.like:""),1)],8,Za),v("button",{type:"button",class:q(["wl-reply",{active:$.value}]),title:$.value?I.value.cancelReply:I.value.reply,onClick:d[3]||(d[3]=E=>t("reply",$.value?null:n.comment))},[G(w(Wt))],10,Ga)])]),v("div",Ja,[(o(),s(D,null,X(["addr","browser","os"],E=>(o(),s(D,null,[n.comment[E]?(o(),s("span",{key:E,class:q(`wl-${E}`),"data-value":n.comment[E],textContent:_(n.comment[E])},null,10,Xa)):x("v-if",!0)],64))),64))]),p.value?x("v-if",!0):(o(),s("div",{key:0,class:"wl-content",innerHTML:n.comment.comment},null,8,Ya)),A.value&&!p.value?(o(),s("div",Qa,[v("span",en,[(o(),s(D,null,X(u,E=>v("button",{key:E,type:"submit",class:q(`wl-btn wl-${E}`),disabled:n.comment.status===E,onClick:j=>t("status",{status:E,comment:n.comment}),textContent:_(I.value[E])},null,10,tn)),64))]),A.value&&!("rid"in n.comment)?(o(),s("button",{key:0,type:"submit",class:"wl-btn wl-sticky",onClick:d[4]||(d[4]=E=>t("sticky",n.comment))},_(n.comment.sticky?I.value.unsticky:I.value.sticky),1)):x("v-if",!0)])):x("v-if",!0),$.value||p.value?(o(),s("div",{key:2,class:q({"wl-reply-wrapper":$.value,"wl-edit-wrapper":p.value})},[G(ut,{edit:n.edit,"reply-id":(F=n.reply)==null?void 0:F.objectId,"reply-user":n.comment.nick,"root-id":n.rootId,onLog:d[5]||(d[5]=E=>t("log")),onCancelReply:d[6]||(d[6]=E=>t("reply",null)),onCancelEdit:d[7]||(d[7]=E=>t("edit",null)),onSubmit:d[8]||(d[8]=E=>t("submit",E))},null,8,["edit","reply-id","reply-user","root-id"])],2)):x("v-if",!0),"children"in n.comment?(o(),s("div",ln,[(o(!0),s(D,null,X(n.comment.children,E=>(o(),le(P,{key:E.objectId,comment:E,reply:n.reply,edit:n.edit,"root-id":n.rootId,onLog:d[9]||(d[9]=j=>t("log")),onDelete:d[10]||(d[10]=j=>t("delete",j)),onEdit:d[11]||(d[11]=j=>t("edit",j)),onLike:d[12]||(d[12]=j=>t("like",j)),onReply:d[13]||(d[13]=j=>t("reply",j)),onStatus:d[14]||(d[14]=j=>t("status",j)),onSticky:d[15]||(d[15]=j=>t("sticky",j)),onSubmit:d[16]||(d[16]=j=>t("submit",j))},null,8,["comment","reply","edit","root-id"]))),128))])):x("v-if",!0)])],8,Ua)}}}),nn=ve(an,[["__file","CommentCard.vue"]]);const vt="3.0.0-alpha.11",on={"data-waline":""},rn={class:"wl-meta-head"},sn={class:"wl-count"},cn=["textContent"],un={class:"wl-sort"},vn=["onClick"],mn={class:"wl-cards"},dn={key:1,class:"wl-operation"},pn=["textContent"],gn={key:2,class:"wl-loading"},hn=["textContent"],fn={key:4,class:"wl-operation"},yn=["textContent"],wn={key:5,class:"wl-power"},kn=v("a",{href:"https://github.com/walinejs/waline",target:"_blank",rel:"noopener noreferrer"}," Waline ",-1);var bn=ce({__name:"WalineComment",props:["serverURL","path","meta","requiredMeta","dark","commentSorting","lang","locale","pageSize","wordLimit","emoji","login","highlighter","texRenderer","imageUploader","search","copyright","recaptchaV3Key","turnstileKey","reaction"],setup(e){const a=e,l={latest:"insertedAt_desc",oldest:"insertedAt_asc",hottest:"like_desc"},t=Object.keys(l),u=Ce(),i=qe(),k=L("loading"),M=L(0),b=L(1),I=L(0),C=W(()=>Sl(a)),V=L(C.value.commentSorting),m=L([]),A=L(null),z=L(null),$=W(()=>zl(C.value.dark)),p=W(()=>C.value.locale);xt($,{id:"waline-darkmode"});let n;const d=y=>{var g;const{serverURL:S,path:K,pageSize:B}=C.value,J=new AbortController;k.value="loading",n==null||n(),At({serverURL:S,lang:C.value.lang,path:K,pageSize:B,sortBy:l[V.value],page:y,signal:J.signal,token:(g=u.value)==null?void 0:g.token}).then(Z=>{k.value="success",M.value=Z.count,m.value.push(...Z.data),b.value=y,I.value=Z.totalPages}).catch(Z=>{Z.name!=="AbortError"&&(console.error(Z.message),k.value="error")}),n=J.abort.bind(J)},F=()=>d(b.value+1),P=()=>{M.value=0,m.value=[],d(1)},E=y=>{V.value!==y&&(V.value=y,P())},j=y=>{A.value=y},ie=y=>{z.value=y},H=y=>{if(z.value)z.value.comment=y.comment,z.value.orig=y.orig;else if("rid"in y){const g=m.value.find(({objectId:S})=>S===y.rid);if(!g)return;Array.isArray(g.children)||(g.children=[]),g.children.push(y)}else m.value.unshift(y),M.value+=1},ne=async({comment:y,status:g})=>{var S;if(y.status===g)return;const{serverURL:K,lang:B}=C.value;await fe({serverURL:K,lang:B,token:(S=u.value)==null?void 0:S.token,objectId:y.objectId,comment:{status:g}}),y.status=g},ee=async y=>{var g;if("rid"in y)return;const{serverURL:S,lang:K}=C.value;await fe({serverURL:S,lang:K,token:(g=u.value)==null?void 0:g.token,objectId:y.objectId,comment:{sticky:y.sticky?0:1}}),y.sticky=!y.sticky},me=async({objectId:y})=>{var g;if(!confirm("Are you sure you want to delete this comment?"))return;const{serverURL:S,lang:K}=C.value;await Mt({serverURL:S,lang:K,token:(g=u.value)==null?void 0:g.token,objectId:y}),m.value.some((B,J)=>B.objectId===y?(m.value=m.value.filter((Z,se)=>se!==J),!0):B.children.some((Z,se)=>Z.objectId===y?(m.value[J].children=B.children.filter((_e,ye)=>ye!==se),!0):!1))},Y=async y=>{var g;const{serverURL:S,lang:K}=C.value,{objectId:B}=y,J=i.value.includes(B);await fe({serverURL:S,lang:K,objectId:B,token:(g=u.value)==null?void 0:g.token,comment:{like:!J}}),J?i.value=i.value.filter(Z=>Z!==B):(i.value=[...i.value,B],i.value.length>50&&(i.value=i.value.slice(-50))),y.like=(y.like||0)+(J?-1:1)};return Ct("config",C),ge(()=>{te(()=>[a.serverURL,a.path],()=>P(),{immediate:!0})}),be(()=>n==null?void 0:n()),(y,g)=>(o(),s("div",on,[G(sl),A.value?x("v-if",!0):(o(),le(ut,{key:0,onLog:P,onSubmit:H})),v("div",rn,[v("div",sn,[M.value?(o(),s("span",{key:0,class:"wl-num",textContent:_(M.value)},null,8,cn)):x("v-if",!0),ae(" "+_(p.value.comment),1)]),v("ul",un,[(o(!0),s(D,null,X(w(t),S=>(o(),s("li",{key:S,class:q([S===V.value?"active":""]),onClick:K=>E(S)},_(p.value[S]),11,vn))),128))])]),v("div",mn,[(o(!0),s(D,null,X(m.value,S=>(o(),le(nn,{key:S.objectId,"root-id":S.objectId,comment:S,reply:A.value,edit:z.value,onLog:P,onReply:j,onEdit:ie,onSubmit:H,onStatus:ne,onDelete:me,onSticky:ee,onLike:Y},null,8,["root-id","comment","reply","edit"]))),128))]),k.value==="error"?(o(),s("div",dn,[v("button",{type:"button",class:"wl-btn",onClick:P,textContent:_(p.value.refresh)},null,8,pn)])):k.value==="loading"?(o(),s("div",gn,[G(w(ue),{size:30})])):m.value.length?b.value<I.value?(o(),s("div",fn,[v("button",{type:"button",class:"wl-btn",onClick:F,textContent:_(p.value.more)},null,8,yn)])):x("v-if",!0):(o(),s("div",{key:3,class:"wl-empty",textContent:_(p.value.sofa)},null,8,hn)),C.value.copyright?(o(),s("div",wn,[ae(" Powered by "),kn,ae(" v"+_(w(vt)),1)])):x("v-if",!0)]))}}),Cn=ve(bn,[["__file","WalineComment.vue"]]);export{Cn as Waline,vt as version};
|
|
9
|
+
`)}).catch(h=>{alert(h.message),k.value=k.value.replace(r,"")}).then(()=>{Y.value=!1})},se=c=>{var r;if((r=c.dataTransfer)!=null&&r.items){const h=st(c.dataTransfer.items);h&&K.value&&(Z(h),c.preventDefault())}},_e=c=>{if(c.clipboardData){const r=st(c.clipboardData.items);r&&K.value&&Z(r)}},ye=()=>{const c=V.value;c.files&&K.value&&Z(c.files[0]).then(()=>{c.value=""})},Me=async()=>{var c,r,h,U,f,O;const{serverURL:N,lang:Q,login:de,wordLimit:Ve,requiredMeta:He,recaptchaV3Key:Te,turnstileKey:Fe}=i.value,pt=await Jl(),T={comment:me.value,nick:M.value.nick,mail:M.value.mail,link:M.value.link,url:i.value.path,ua:pt};if((c=b.value)!=null&&c.token)T.nick=b.value.display_name,T.mail=b.value.email,T.link=b.value.url;else{if(de==="force")return;if(He.indexOf("nick")>-1&&!T.nick)return(r=I.value.nick)==null||r.focus(),alert(g.value.nickError);if(He.indexOf("mail")>-1&&!T.mail||T.mail&&!Hl(T.mail))return(h=I.value.mail)==null||h.focus(),alert(g.value.mailError);T.nick||(T.nick=g.value.anonymous)}if(!T.comment){(U=C.value)==null||U.focus();return}if(!ee.value)return alert(g.value.wordHint.replace("$0",Ve[0].toString()).replace("$1",Ve[1].toString()).replace("$2",ie.value.toString()));T.comment=ct(T.comment,n.value.map),t.replyId&&t.rootId&&(T.pid=t.replyId,T.rid=t.rootId,T.at=t.replyUser),Y.value=!0;try{Te&&(T.recaptchaV3=await Jt(Te).execute("social")),Fe&&(T.turnstile=await Xt(Fe).execute("social"));const pe={serverURL:N,lang:Q,token:(f=b.value)==null?void 0:f.token,comment:T},we=await(t.edit?fe({objectId:t.edit.objectId,...pe}):Rt(pe));if(Y.value=!1,we.errmsg)return alert(we.errmsg);u("submit",we.data),k.value="",j.value="",t.replyId&&u("cancelReply"),(O=t.edit)!=null&&O.objectId&&u("cancelEdit")}catch(pe){Y.value=!1,alert(pe.message)}},mt=c=>{c.preventDefault();const{lang:r,serverURL:h}=i.value;_t({serverURL:h,lang:r}).then(U=>{b.value=U,(U.remember?localStorage:sessionStorage).setItem("WALINE_USER",JSON.stringify(U)),u("log")})},dt=()=>{b.value={},localStorage.setItem("WALINE_USER","null"),sessionStorage.setItem("WALINE_USER","null"),u("log")},Ae=c=>{c.preventDefault();const{lang:r,serverURL:h}=i.value,U=800,f=800,O=(window.innerWidth-U)/2,N=(window.innerHeight-f)/2,Q=new URLSearchParams({lng:r,token:b.value.token}),de=window.open(`${h}/ui/profile?${Q.toString()}`,"_blank",`width=${U},height=${f},left=${O},top=${N},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`);de==null||de.postMessage({type:"TOKEN",data:b.value.token},"*")},Se=c=>{var r,h,U,f;!((r=m.value)!=null&&r.contains(c.target))&&!((h=A.value)!=null&&h.contains(c.target))&&(F.value=!1),!((U=z.value)!=null&&U.contains(c.target))&&!((f=$.value)!=null&&f.contains(c.target))&&(P.value=!1)},ze=async c=>{var r;const{scrollTop:h,clientHeight:U,scrollHeight:f}=c.target,O=(U+h)/f,N=i.value.search,Q=((r=p.value)==null?void 0:r.value)||"";O<.9||H.loading||y.value||(H.loading=!0,(N.more&&H.list.length?await N.more(Q,H.list.length):await N.search(Q)).length?H.list=[...H.list,...N.more&&H.list.length?await N.more(Q,H.list.length):await N.search(Q)]:y.value=!0,H.loading=!1,setTimeout(()=>{c.target.scrollTop=h},50))},je=Lt(c=>{H.list=[],y.value=!1,ze(c)},300);te([i,ie],([c,r])=>{const{wordLimit:h}=c;h?r<h[0]&&h[0]!==0?(ne.value=h[0],ee.value=!1):r>h[1]?(ne.value=h[1],ee.value=!1):(ne.value=h[1],ee.value=!0):(ne.value=0,ee.value=!0)},{immediate:!0});const Ue=({data:c})=>{!c||c.type!=="profile"||(b.value={...b.value,...c.data},[localStorage,sessionStorage].filter(r=>r.getItem("WALINE_USER")).forEach(r=>r.setItem("WALINE_USER",JSON.stringify(b))))};return ge(()=>{var c;document.body.addEventListener("click",Se),window.addEventListener("message",Ue),(c=t.edit)!=null&&c.objectId&&(k.value=t.edit.orig),te(P,async r=>{if(!r)return;const h=i.value.search;p.value&&(p.value.value=""),H.loading=!0,H.list=h.default?await h.default():await h.search(""),H.loading=!1}),te(()=>k.value,r=>{const{highlighter:h,texRenderer:U}=i.value;me.value=r,j.value=ql(r,{emojiMap:n.value.map,highlighter:h,texRenderer:U}),ie.value=Gl(r),r?Pe(C.value):Pe.destroy(C.value)},{immediate:!0}),te(()=>i.value.emoji,r=>Nl(r).then(h=>{n.value=h}),{immediate:!0})}),be(()=>{document.body.removeEventListener("click",Se),window.removeEventListener("message",Ue)}),(c,r)=>{var h,U;return o(),s("div",Xl,[w(i).login!=="disable"&&S.value&&!((h=c.edit)!=null&&h.objectId)?(o(),s("div",Yl,[v("div",Ql,[v("button",{type:"submit",class:"wl-logout-btn",title:g.value.logout,onClick:dt},[G(w(Be),{size:14})],8,ea),v("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",title:g.value.profile,onClick:Ae},[v("img",{src:w(b).avatar,alt:"avatar"},null,8,la)],8,ta)]),v("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",title:g.value.profile,onClick:Ae,textContent:_(w(b).display_name)},null,8,aa)])):x("v-if",!0),v("div",na,[w(i).login!=="force"&&w(i).meta.length&&!S.value?(o(),s("div",{key:0,class:q(["wl-header",`item${w(i).meta.length}`])},[(o(!0),s(D,null,X(w(i).meta,f=>(o(),s("div",{key:f,class:"wl-header-item"},[v("label",{for:`wl-${f}`,textContent:_(g.value[f]+(w(i).requiredMeta.includes(f)||!w(i).requiredMeta.length?"":`(${g.value.optional})`))},null,8,oa),he(v("input",{id:`wl-${f}`,ref_for:!0,ref:O=>{O&&(I.value[f]=O)},"onUpdate:modelValue":O=>w(M)[f]=O,class:q(["wl-input",`wl-${f}`]),name:f,type:f==="mail"?"email":"text"},null,10,ia),[[yt,w(M)[f]]])]))),128))],2)):x("v-if",!0),he(v("textarea",{id:"wl-edit",ref_key:"editorRef",ref:C,"onUpdate:modelValue":r[0]||(r[0]=f=>wt(k)?k.value=f:null),class:"wl-editor",placeholder:c.replyUser?`@${c.replyUser}`:g.value.placeholder,onKeydown:J,onDrop:se,onPaste:_e},null,40,ra),[[kt,w(k)]]),he(v("div",sa,[ca,v("h4",null,_(g.value.preview)+":",1),v("div",{class:"wl-content",innerHTML:j.value},null,8,ua)],512),[[We,E.value]]),v("div",va,[v("div",ma,[v("a",da,[G(w(Nt))]),he(v("button",{ref_key:"emojiButtonRef",ref:m,type:"button",class:q(["wl-action",{active:F.value}]),title:g.value.emoji,onClick:r[1]||(r[1]=f=>F.value=!F.value)},[G(w(Vt))],10,pa),[[We,n.value.tabs.length]]),w(i).search?(o(),s("button",{key:0,ref_key:"gifButtonRef",ref:z,type:"button",class:q(["wl-action",{active:P.value}]),title:g.value.gif,onClick:r[2]||(r[2]=f=>P.value=!P.value)},[G(w(Bt))],10,ga)):x("v-if",!0),v("input",{id:"wl-image-upload",ref_key:"imageUploadRef",ref:V,class:"upload",type:"file",accept:".png,.jpg,.jpeg,.webp,.bmp,.gif",onChange:ye},null,544),K.value?(o(),s("label",{key:1,for:"wl-image-upload",class:"wl-action",title:g.value.uploadImage},[G(w(Ht))],8,ha)):x("v-if",!0),v("button",{type:"button",class:q(["wl-action",{active:E.value}]),title:g.value.preview,onClick:r[3]||(r[3]=f=>E.value=!E.value)},[G(w(Ft))],10,fa)]),v("div",ya,[wa,v("div",ka,[ae(_(ie.value)+" ",1),w(i).wordLimit?(o(),s("span",ba,[ae(" / "),v("span",{class:q({illegal:!ee.value}),textContent:_(ne.value)},null,10,Ca)])):x("v-if",!0),ae(" "+_(g.value.word),1)]),w(i).login!=="disable"&&!S.value?(o(),s("button",{key:0,type:"button",class:"wl-btn",onClick:mt,textContent:_(g.value.login)},null,8,$a)):x("v-if",!0),w(i).login!=="force"||S.value?(o(),s("button",{key:1,type:"submit",class:"primary wl-btn",title:"Cmd|Ctrl + Enter",disabled:Y.value,onClick:Me},[Y.value?(o(),le(w(ue),{key:0,size:16})):(o(),s(D,{key:1},[ae(_(g.value.submit),1)],64))],8,La)):x("v-if",!0)]),v("div",{ref_key:"gifPopupRef",ref:$,class:q(["wl-gif-popup",{display:P.value}])},[v("input",{ref_key:"gifSearchInputRef",ref:p,type:"text",placeholder:g.value.gifSearchPlaceholder,onInput:r[4]||(r[4]=(...f)=>w(je)&&w(je)(...f))},null,40,Ia),H.list.length?(o(),le(ml,{key:0,items:H.list,"column-width":200,gap:6,onInsert:r[5]||(r[5]=f=>B(f)),onScroll:ze},null,8,["items"])):x("v-if",!0),H.loading?(o(),s("div",xa,[G(w(ue),{size:30})])):x("v-if",!0)],2),v("div",{ref_key:"emojiPopupRef",ref:A,class:q(["wl-emoji-popup",{display:F.value}])},[(o(!0),s(D,null,X(n.value.tabs,(f,O)=>(o(),s(D,{key:f.name},[O===d.value?(o(),s("div",Ea,[(o(!0),s(D,null,X(f.items,N=>(o(),s("button",{key:N,type:"button",title:N,onClick:Q=>B(`:${N}:`)},[F.value?(o(),s("img",{key:0,class:"wl-emoji",src:n.value.map[N],alt:N,loading:"lazy",referrerPolicy:"no-referrer"},null,8,_a)):x("v-if",!0)],8,Ra))),128))])):x("v-if",!0)],64))),128)),n.value.tabs.length>1?(o(),s("div",Ma,[(o(!0),s(D,null,X(n.value.tabs,(f,O)=>(o(),s("button",{key:f.name,type:"button",class:q(["wl-tab",{active:d.value===O}]),onClick:N=>d.value=O},[v("img",{class:"wl-emoji",src:f.icon,alt:f.name,title:f.name,loading:"lazy",referrerPolicy:"no-referrer"},null,8,Sa)],10,Aa))),128))])):x("v-if",!0)],2)])]),c.replyId||(U=c.edit)!=null&&U.objectId?(o(),s("button",{key:1,type:"button",class:"wl-close",title:g.value.cancelReply,onClick:r[6]||(r[6]=f=>c.$emit(c.replyId?"cancelReply":"cancelEdit"))},[G(w(Be),{size:24})],8,za)):x("v-if",!0)])}}}),ut=ve(ja,[["__file","CommentBox.vue"]]);const Ua=["id"],Va={class:"wl-user","aria-hidden":"true"},Ha=["src"],Ta={class:"wl-card"},Fa={class:"wl-head"},Na=["href"],Wa={key:1,class:"wl-nick"},Da=["textContent"],Pa=["textContent"],Ba=["textContent"],Oa=["textContent"],qa=["textContent"],Ka={class:"wl-comment-actions"},Za=["title"],Ga=["title"],Ja={class:"wl-meta","aria-hidden":"true"},Xa=["data-value","textContent"],Ya=["innerHTML"],Qa={key:1,class:"wl-admin-actions"},en={class:"wl-comment-status"},tn=["disabled","onClick","textContent"],ln={key:3,class:"wl-quote"};var an=ce({__name:"CommentCard",props:{comment:{},edit:{default:null},rootId:{},reply:{default:null}},emits:["log","submit","delete","edit","like","status","sticky","reply"],setup(e,{emit:a}){const l=e,t=a,u=["approved","waiting","spam"],i=ke("config"),k=qe(),M=It(),b=Ce(),I=W(()=>i.value.locale),C=W(()=>{const{link:n}=l.comment;return n?Xe(n)?n:`https://${n}`:""}),V=W(()=>k.value.includes(l.comment.objectId)),m=W(()=>Ul(new Date(l.comment.time),M.value,I.value)),A=W(()=>b.value.type==="administrator"),z=W(()=>l.comment.user_id&&b.value.objectId===l.comment.user_id),$=W(()=>{var n;return l.comment.objectId===((n=l.reply)==null?void 0:n.objectId)}),p=W(()=>{var n;return l.comment.objectId===((n=l.edit)==null?void 0:n.objectId)});return(n,d)=>{var F;const P=bt("CommentCard",!0);return o(),s("div",{id:n.comment.objectId,class:"wl-card-item"},[v("div",Va,[n.comment.avatar?(o(),s("img",{key:0,class:"wl-user-avatar",src:n.comment.avatar},null,8,Ha)):x("v-if",!0),n.comment.type?(o(),le(w(Pt),{key:1})):x("v-if",!0)]),v("div",Ta,[v("div",Fa,[C.value?(o(),s("a",{key:0,class:"wl-nick",href:C.value,target:"_blank",rel:"nofollow noopener noreferrer"},_(n.comment.nick),9,Na)):(o(),s("span",Wa,_(n.comment.nick),1)),n.comment.type==="administrator"?(o(),s("span",{key:2,class:"wl-badge",textContent:_(I.value.admin)},null,8,Da)):x("v-if",!0),n.comment.label?(o(),s("span",{key:3,class:"wl-badge",textContent:_(n.comment.label)},null,8,Pa)):x("v-if",!0),n.comment.sticky?(o(),s("span",{key:4,class:"wl-badge",textContent:_(I.value.sticky)},null,8,Ba)):x("v-if",!0),typeof n.comment.level=="number"?(o(),s("span",{key:5,class:q(`wl-badge level${n.comment.level}`),textContent:_(I.value[`level${n.comment.level}`]||`Level ${n.comment.level}`)},null,10,Oa)):x("v-if",!0),v("span",{class:"wl-time",textContent:_(m.value)},null,8,qa),v("div",Ka,[A.value||z.value?(o(),s(D,{key:0},[v("button",{type:"button",class:"wl-edit",onClick:d[0]||(d[0]=E=>t("edit",n.comment))},[G(w(Dt))]),v("button",{type:"button",class:"wl-delete",onClick:d[1]||(d[1]=E=>t("delete",n.comment))},[G(w(Ut))])],64)):x("v-if",!0),v("button",{type:"button",class:"wl-like",title:V.value?I.value.cancelLike:I.value.like,onClick:d[2]||(d[2]=E=>t("like",n.comment))},[G(w(Tt),{active:V.value},null,8,["active"]),ae(" "+_("like"in n.comment?n.comment.like:""),1)],8,Za),v("button",{type:"button",class:q(["wl-reply",{active:$.value}]),title:$.value?I.value.cancelReply:I.value.reply,onClick:d[3]||(d[3]=E=>t("reply",$.value?null:n.comment))},[G(w(Wt))],10,Ga)])]),v("div",Ja,[(o(),s(D,null,X(["addr","browser","os"],E=>(o(),s(D,null,[n.comment[E]?(o(),s("span",{key:E,class:q(`wl-${E}`),"data-value":n.comment[E],textContent:_(n.comment[E])},null,10,Xa)):x("v-if",!0)],64))),64))]),p.value?x("v-if",!0):(o(),s("div",{key:0,class:"wl-content",innerHTML:n.comment.comment},null,8,Ya)),A.value&&!p.value?(o(),s("div",Qa,[v("span",en,[(o(),s(D,null,X(u,E=>v("button",{key:E,type:"submit",class:q(`wl-btn wl-${E}`),disabled:n.comment.status===E,onClick:j=>t("status",{status:E,comment:n.comment}),textContent:_(I.value[E])},null,10,tn)),64))]),A.value&&!("rid"in n.comment)?(o(),s("button",{key:0,type:"submit",class:"wl-btn wl-sticky",onClick:d[4]||(d[4]=E=>t("sticky",n.comment))},_(n.comment.sticky?I.value.unsticky:I.value.sticky),1)):x("v-if",!0)])):x("v-if",!0),$.value||p.value?(o(),s("div",{key:2,class:q({"wl-reply-wrapper":$.value,"wl-edit-wrapper":p.value})},[G(ut,{edit:n.edit,"reply-id":(F=n.reply)==null?void 0:F.objectId,"reply-user":n.comment.nick,"root-id":n.rootId,onLog:d[5]||(d[5]=E=>t("log")),onCancelReply:d[6]||(d[6]=E=>t("reply",null)),onCancelEdit:d[7]||(d[7]=E=>t("edit",null)),onSubmit:d[8]||(d[8]=E=>t("submit",E))},null,8,["edit","reply-id","reply-user","root-id"])],2)):x("v-if",!0),"children"in n.comment?(o(),s("div",ln,[(o(!0),s(D,null,X(n.comment.children,E=>(o(),le(P,{key:E.objectId,comment:E,reply:n.reply,edit:n.edit,"root-id":n.rootId,onLog:d[9]||(d[9]=j=>t("log")),onDelete:d[10]||(d[10]=j=>t("delete",j)),onEdit:d[11]||(d[11]=j=>t("edit",j)),onLike:d[12]||(d[12]=j=>t("like",j)),onReply:d[13]||(d[13]=j=>t("reply",j)),onStatus:d[14]||(d[14]=j=>t("status",j)),onSticky:d[15]||(d[15]=j=>t("sticky",j)),onSubmit:d[16]||(d[16]=j=>t("submit",j))},null,8,["comment","reply","edit","root-id"]))),128))])):x("v-if",!0)])],8,Ua)}}}),nn=ve(an,[["__file","CommentCard.vue"]]);const vt="3.0.0-alpha.12",on={"data-waline":""},rn={class:"wl-meta-head"},sn={class:"wl-count"},cn=["textContent"],un={class:"wl-sort"},vn=["onClick"],mn={class:"wl-cards"},dn={key:1,class:"wl-operation"},pn=["textContent"],gn={key:2,class:"wl-loading"},hn=["textContent"],fn={key:4,class:"wl-operation"},yn=["textContent"],wn={key:5,class:"wl-power"},kn=v("a",{href:"https://github.com/walinejs/waline",target:"_blank",rel:"noopener noreferrer"}," Waline ",-1);var bn=ce({__name:"WalineComment",props:["serverURL","path","meta","requiredMeta","dark","commentSorting","lang","locale","pageSize","wordLimit","emoji","login","highlighter","texRenderer","imageUploader","search","copyright","recaptchaV3Key","turnstileKey","reaction"],setup(e){const a=e,l={latest:"insertedAt_desc",oldest:"insertedAt_asc",hottest:"like_desc"},t=Object.keys(l),u=Ce(),i=qe(),k=L("loading"),M=L(0),b=L(1),I=L(0),C=W(()=>Sl(a)),V=L(C.value.commentSorting),m=L([]),A=L(null),z=L(null),$=W(()=>zl(C.value.dark)),p=W(()=>C.value.locale);xt($,{id:"waline-darkmode"});let n;const d=y=>{var g;const{serverURL:S,path:K,pageSize:B}=C.value,J=new AbortController;k.value="loading",n==null||n(),At({serverURL:S,lang:C.value.lang,path:K,pageSize:B,sortBy:l[V.value],page:y,signal:J.signal,token:(g=u.value)==null?void 0:g.token}).then(Z=>{k.value="success",M.value=Z.count,m.value.push(...Z.data),b.value=y,I.value=Z.totalPages}).catch(Z=>{Z.name!=="AbortError"&&(console.error(Z.message),k.value="error")}),n=J.abort.bind(J)},F=()=>d(b.value+1),P=()=>{M.value=0,m.value=[],d(1)},E=y=>{V.value!==y&&(V.value=y,P())},j=y=>{A.value=y},ie=y=>{z.value=y},H=y=>{if(z.value)z.value.comment=y.comment,z.value.orig=y.orig;else if("rid"in y){const g=m.value.find(({objectId:S})=>S===y.rid);if(!g)return;Array.isArray(g.children)||(g.children=[]),g.children.push(y)}else m.value.unshift(y),M.value+=1},ne=async({comment:y,status:g})=>{var S;if(y.status===g)return;const{serverURL:K,lang:B}=C.value;await fe({serverURL:K,lang:B,token:(S=u.value)==null?void 0:S.token,objectId:y.objectId,comment:{status:g}}),y.status=g},ee=async y=>{var g;if("rid"in y)return;const{serverURL:S,lang:K}=C.value;await fe({serverURL:S,lang:K,token:(g=u.value)==null?void 0:g.token,objectId:y.objectId,comment:{sticky:y.sticky?0:1}}),y.sticky=!y.sticky},me=async({objectId:y})=>{var g;if(!confirm("Are you sure you want to delete this comment?"))return;const{serverURL:S,lang:K}=C.value;await Mt({serverURL:S,lang:K,token:(g=u.value)==null?void 0:g.token,objectId:y}),m.value.some((B,J)=>B.objectId===y?(m.value=m.value.filter((Z,se)=>se!==J),!0):B.children.some((Z,se)=>Z.objectId===y?(m.value[J].children=B.children.filter((_e,ye)=>ye!==se),!0):!1))},Y=async y=>{var g;const{serverURL:S,lang:K}=C.value,{objectId:B}=y,J=i.value.includes(B);await fe({serverURL:S,lang:K,objectId:B,token:(g=u.value)==null?void 0:g.token,comment:{like:!J}}),J?i.value=i.value.filter(Z=>Z!==B):(i.value=[...i.value,B],i.value.length>50&&(i.value=i.value.slice(-50))),y.like=(y.like||0)+(J?-1:1)};return Ct("config",C),ge(()=>{te(()=>[a.serverURL,a.path],()=>P(),{immediate:!0})}),be(()=>n==null?void 0:n()),(y,g)=>(o(),s("div",on,[G(sl),A.value?x("v-if",!0):(o(),le(ut,{key:0,onLog:P,onSubmit:H})),v("div",rn,[v("div",sn,[M.value?(o(),s("span",{key:0,class:"wl-num",textContent:_(M.value)},null,8,cn)):x("v-if",!0),ae(" "+_(p.value.comment),1)]),v("ul",un,[(o(!0),s(D,null,X(w(t),S=>(o(),s("li",{key:S,class:q([S===V.value?"active":""]),onClick:K=>E(S)},_(p.value[S]),11,vn))),128))])]),v("div",mn,[(o(!0),s(D,null,X(m.value,S=>(o(),le(nn,{key:S.objectId,"root-id":S.objectId,comment:S,reply:A.value,edit:z.value,onLog:P,onReply:j,onEdit:ie,onSubmit:H,onStatus:ne,onDelete:me,onSticky:ee,onLike:Y},null,8,["root-id","comment","reply","edit"]))),128))]),k.value==="error"?(o(),s("div",dn,[v("button",{type:"button",class:"wl-btn",onClick:P,textContent:_(p.value.refresh)},null,8,pn)])):k.value==="loading"?(o(),s("div",gn,[G(w(ue),{size:30})])):m.value.length?b.value<I.value?(o(),s("div",fn,[v("button",{type:"button",class:"wl-btn",onClick:F,textContent:_(p.value.more)},null,8,yn)])):x("v-if",!0):(o(),s("div",{key:3,class:"wl-empty",textContent:_(p.value.sofa)},null,8,hn)),C.value.copyright?(o(),s("div",wn,[ae(" Powered by "),kn,ae(" v"+_(w(vt)),1)])):x("v-if",!0)]))}}),Cn=ve(bn,[["__file","WalineComment.vue"]]);export{Cn as Waline,vt as version};
|
|
10
10
|
//# sourceMappingURL=component.js.map
|