Files
nextcloud-server-mirror/dist/CommentView-CUZn_DeA.chunk.mjs
2026-10-07 08:58:40 +00:00

13 lines
14 KiB
JavaScript

const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=[window.OC.filePath('', '', 'dist/index-BueGcLEj.chunk.mjs'),window.OC.filePath('', '', 'dist/File-xDTWu8L0.chunk.mjs'),window.OC.filePath('', '', 'dist/PencilOutline-C4ZkKkas.chunk.mjs'),window.OC.filePath('', '', 'dist/star-outline-BpDZzOb8.chunk.mjs'),window.OC.filePath('', '', 'dist/translations-pLZlvQeM.chunk.mjs'),window.OC.filePath('', '', 'dist/NcAvatar-RT0QIft7.chunk.mjs'),window.OC.filePath('', '', 'dist/livePhotoUtils-CVUhgL4S.chunk.mjs'),window.OC.filePath('', '', 'dist/index-D6fZh9CR.chunk.mjs'),window.OC.filePath('', '', 'dist/index-DHyMMYTN.chunk.mjs'),window.OC.filePath('', '', 'dist/NcModal-BxLzaUZK.chunk.mjs'),window.OC.filePath('', '', 'dist/formatRelative-uuSCBZ1C.chunk.mjs'),window.OC.filePath('', '', 'dist/TrayArrowDown-vMg8Cl05.chunk.mjs'),window.OC.filePath('', '', 'dist/_l10n-CK24vgHE.chunk.mjs'),window.OC.filePath('', '', 'dist/Web-BMG0zIln.chunk.mjs'),window.OC.filePath('', '', 'dist/Link-CUdpEe-t.chunk.mjs'),window.OC.filePath('', '', 'dist/common-Link-3plNpBrB.chunk.css'),window.OC.filePath('', '', 'dist/MapMarkerOutline-Ip3bQdll.chunk.mjs'),window.OC.filePath('', '', 'dist/ArrowRight-COu6qSN5.chunk.mjs'),window.OC.filePath('', '', 'dist/common-ArrowRight-C_oBIsvc.chunk.css'),window.OC.filePath('', '', 'dist/common-NcModal-Cclh_O_-.chunk.css'),window.OC.filePath('', '', 'dist/autolink-D1sObkXs.chunk.mjs'),window.OC.filePath('', '', 'dist/common-autolink-B8CEsDGb.chunk.css'),window.OC.filePath('', '', 'dist/colors-B1T-jIOW.chunk.mjs'),window.OC.filePath('', '', 'dist/NcUserStatusIcon-CWV4DI9J.chunk.mjs'),window.OC.filePath('', '', 'dist/common-NcUserStatusIcon-Bq_6hmXG.chunk.css'),window.OC.filePath('', '', 'dist/NcActionButton-BvGszxyz.chunk.mjs'),window.OC.filePath('', '', 'dist/common-NcActionButton-BQBDvDX2.chunk.css'),window.OC.filePath('', '', 'dist/NcActionLink-DvEArNRM.chunk.mjs'),window.OC.filePath('', '', 'dist/common-NcActionLink-iJnZg6ii.chunk.css'),window.OC.filePath('', '', 'dist/NcActionRouter-X9XmAaxE.chunk.mjs'),window.OC.filePath('', '', 'dist/common-NcActionRouter-C1KErZDl.chunk.css'),window.OC.filePath('', '', 'dist/NcActionText-BWO7oBCL.chunk.mjs'),window.OC.filePath('', '', 'dist/common-NcActionText-BzbAkUEn.chunk.css'),window.OC.filePath('', '', 'dist/Check-CEU1oy_I.chunk.mjs'),window.OC.filePath('', '', 'dist/common-Check-BYHcrfvW.chunk.css'),window.OC.filePath('', '', 'dist/common-NcAvatar-o8Woel4F.chunk.css'),window.OC.filePath('', '', 'dist/emoji-Cbe4MxhY.chunk.mjs'),window.OC.filePath('', '', 'dist/NcRichText-BQgo5yW3.chunk.mjs'),window.OC.filePath('', '', 'dist/NcCheckboxRadioSwitch-BgZXg73g.chunk.mjs'),window.OC.filePath('', '', 'dist/common-NcCheckboxRadioSwitch-BAaFbykd.chunk.css'),window.OC.filePath('', '', 'dist/common-NcRichText-DVtX8ulO.chunk.css'),window.OC.filePath('', '', 'dist/index-DDsCA2or.chunk.mjs'),window.OC.filePath('', '', 'dist/index-BJ-wBpMs.chunk.mjs'),window.OC.filePath('', '', 'dist/NcHighlight.vue_vue_type_script_lang-CT7Xx-zK.chunk.mjs'),window.OC.filePath('', '', 'dist/NcInputField-wKF2DDSn.chunk.mjs'),window.OC.filePath('', '', 'dist/common-NcInputField-B5YBBomo.chunk.css'),window.OC.filePath('', '', 'dist/common-index-CRfKBhKV.chunk.css'),window.OC.filePath('', '', 'dist/MenuUp-DiApqAR0.chunk.mjs'),window.OC.filePath('', '', 'dist/common-MenuUp-Don1d5Bd.chunk.css'),window.OC.filePath('', '', 'dist/common-index-Bkq_iXjX.chunk.css'),window.OC.filePath('', '', 'dist/common-index-DBjOe6uk.chunk.css')])))=>i.map(i=>d[i]);
import{c as F,_ as D,d as U,l as W}from"./star-outline-BpDZzOb8.chunk.mjs";import{a as g}from"./livePhotoUtils-CVUhgL4S.chunk.mjs";import{t as G}from"./translations-pLZlvQeM.chunk.mjs";import{S as H,a4 as x,a5 as K,a6 as Q,d as T,j as n,Q as J,R as X,o as m,k as u,w as c,l as p,p as d,t as y,f as b,G as Y,z as C,h as I,y as Z,n as A,K as ee,e as te}from"./PencilOutline-C4ZkKkas.chunk.mjs";import{N as oe}from"./NcActionButton-BvGszxyz.chunk.mjs";import{a as ie}from"./NcModal-BxLzaUZK.chunk.mjs";import{N as se}from"./star-Dwot5QHD.chunk.mjs";import{N as ae}from"./NcAvatar-RT0QIft7.chunk.mjs";import{N as re}from"./Link-CUdpEe-t.chunk.mjs";import{_ as ne}from"./AlertCircleOutline-jA3ki2Uu.chunk.mjs";import{N as me}from"./Check-CEU1oy_I.chunk.mjs";import{N as ce}from"./history-D6oDzA1t.chunk.mjs";import{A as de}from"./ArrowRight-COu6qSN5.chunk.mjs";import{D as le}from"./File-xDTWu8L0.chunk.mjs";import{b as N,T as ue,j as pe}from"./index-UXL_i2di.chunk.mjs";import{l as h}from"./activity-Budsvikq.chunk.mjs";import{c as k,a as he}from"./GetComments-BFr6onyA.chunk.mjs";import{c as S}from"./index-DHyMMYTN.chunk.mjs";async function ge(e,o,i){const a=["",e,o,i].join("/");await k.deleteFile(a)}async function ye(e,o,i,a){const r=["",e,o,i].join("/");return await k.customRequest(r,{method:"PROPPATCH",data:`<?xml version="1.0"?>
<d:propertyupdate
xmlns:d="DAV:"
xmlns:oc="http://owncloud.org/ns">
<d:set>
<d:prop>
<oc:message>${a}</oc:message>
</d:prop>
</d:set>
</d:propertyupdate>`})}function v(e,o=1){const i=new DOMParser;let a=e;for(let r=0;r<o;r++)a=i.parseFromString(a,"text/html").documentElement.textContent;return a}async function fe(e,o,i){const a=["",e,o].join("/"),r=await S.post(he()+a,{actorDisplayName:g().displayName,actorId:g().uid,actorType:"users",creationDateTime:new Date().toUTCString(),message:i,objectType:e,verb:"comment"}),s=parseInt(r.headers["content-location"].split("/").pop()),_=a+"/"+s,f=await k.stat(_,{details:!0}),l=f.data.props;return l.actorDisplayName=v(l.actorDisplayName,2),l.message=v(l.message,2),f.data}const E=H("deletedCommentLimbo",{state:()=>({idsInLimbo:[]}),actions:{addId(e){this.idsInLimbo.push(e)},removeId(e){const o=this.idsInLimbo.indexOf(e);o>-1&&this.idsInLimbo.splice(o,1)},checkForId(e){return this.idsInLimbo.includes(e)}}}),_e={props:{id:{type:Number,default:null},message:{type:String,default:""},resourceId:{type:[String,Number],required:!0},resourceType:{type:String,default:"files"}},data(){return{deleted:!1,editing:!1,loading:!1}},computed:{...x(E)},methods:{onEdit(){this.editing=!0},onEditCancel(){this.editing=!1,this.updateLocalMessage(this.message)},async onEditComment(e){this.loading=!0;try{await ye(this.resourceType,this.resourceId,this.id,e),h.debug("Comment edited",{resourceType:this.resourceType,resourceId:this.resourceId,id:this.id,message:e}),this.$emit("update:message",e),this.editing=!1}catch(o){N(t("comments","An error occurred while trying to edit the comment")),h.error("An error occurred while trying to edit the comment",{error:o})}finally{this.loading=!1}},onDeleteWithUndo(){this.$emit("delete"),this.deleted=!0,this.deletedCommentLimboStore.addId(this.id);const e=setTimeout(this.onDelete,ue);pe(t("comments","Comment deleted"),()=>{clearTimeout(e),this.deleted=!1,this.deletedCommentLimboStore.removeId(this.id)})},async onDelete(){try{await ge(this.resourceType,this.resourceId,this.id),h.debug("Comment deleted",{resourceType:this.resourceType,resourceId:this.resourceId,id:this.id}),this.$emit("delete",this.id)}catch(e){N(t("comments","An error occurred while trying to delete the comment")),h.error("An error occurred while trying to delete the comment",{error:e}),this.deleted=!1,this.deletedCommentLimboStore.removeId(this.id)}},async onNewComment(e){this.loading=!0;try{const o=await fe(this.resourceType,this.resourceId,e);h.debug("New comment posted",{resourceType:this.resourceType,resourceId:this.resourceId,newComment:o}),this.$emit("new",o),this.$emit("update:message",""),this.localMessage=""}catch(o){N(t("comments","An error occurred while trying to create the comment")),h.error("An error occurred while trying to create the comment",{error:o})}finally{this.loading=!1}}}},be=T(()=>D(()=>import("./index-BueGcLEj.chunk.mjs"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50]),import.meta.url)),Ce=T(()=>D(()=>import("./index-DDsCA2or.chunk.mjs"),__vite__mapDeps([41,37,3,1,2,4,38,17,18,33,34,12,13,39,6,7,8,11,14,10,15,16,20,21,40,42,9,19,43,44,45,46,47,48,49]),import.meta.url)),Ie=T(()=>D(()=>import("./index-DDsCA2or.chunk.mjs"),__vite__mapDeps([41,37,3,1,2,4,38,17,18,33,34,12,13,39,6,7,8,11,14,10,15,16,20,21,40,42,9,19,43,44,45,46,47,48,49]),import.meta.url).then(e=>e.NcReferenceList)),Ne={name:"CommentEntry",components:{IconArrowRight:de,IconClose:Q,IconTrashCanOutline:le,IconPencilOutline:K,NcActionButton:oe,NcActions:ie,NcActionSeparator:se,NcAvatar:ae,NcButton:re,NcDateTime:ne,NcLoadingIcon:me,NcReferenceList:Ie,NcRichContenteditable:be,NcRichText:Ce},mixins:[_e],inheritAttrs:!1,props:{actorDisplayName:{type:String,required:!0},actorId:{type:String,required:!0},creationDateTime:{type:String,default:null},editor:{type:Boolean,default:!1},autoComplete:{type:Function,required:!0},userData:{type:Object,default:()=>({})},tag:{type:String,default:"div"}},data(){return{expanded:!1,localMessage:"",submitted:!1}},computed:{...x(E),isOwnComment(){return g().uid===this.actorId},richContent(){const e={};let o=this.localMessage;return Object.keys(this.userData).forEach((i,a)=>{const r=`mention-${a}`,s=new RegExp(`@${i}|@"${i}"`,"g");o=o.replace(s,`{${r}}`),e[r]={component:ce,props:{user:i,displayName:this.userData[i].label,primary:this.userData[i].primary}}}),{mentions:e,message:o}},isEmptyMessage(){return!this.localMessage||this.localMessage.trim()===""},timestamp(){return Date.parse(this.creationDateTime)},isLimbo(){return this.deletedCommentLimboStore.checkForId(this.id)}},watch:{message(e){this.updateLocalMessage(e)}},beforeMount(){this.updateLocalMessage(this.message)},methods:{t:G,updateLocalMessage(e){this.localMessage=e.toString(),this.submitted=!1},onSubmit(){if(this.localMessage.trim()!==""){if(this.editor){this.onNewComment(this.localMessage.trim()),this.$nextTick(()=>{this.$refs.editor.$el.focus()});return}this.onEditComment(this.localMessage.trim())}},onExpand(){this.expanded=!0}}},De={class:"comment__side"},Te={class:"comment__body"},ke={class:"comment__header"},we={class:"comment__author"},Ae={key:1,class:"comment_loading icon-loading-small"},ve={class:"comment__editor-group"},xe={class:"comment__submit"},Se={id:"tab-comments__editor-description",class:"comment__editor-description"};function Ee(e,o,i,a,r,s){const _=n("NcAvatar"),f=n("IconPencilOutline"),l=n("NcActionButton"),L=n("NcActionSeparator"),M=n("IconTrashCanOutline"),R=n("IconClose"),O=n("NcActions"),$=n("NcDateTime"),j=n("NcRichContenteditable"),P=n("NcLoadingIcon"),V=n("IconArrowRight"),q=n("NcButton"),z=n("NcRichText"),B=n("NcReferenceList");return J((m(),u(ee(i.tag),{class:A([{"comment--loading":e.loading},"comment"])},{default:c(()=>[p("div",De,[d(_,{class:"comment__avatar",displayName:i.actorDisplayName,user:i.actorId,size:32},null,8,["displayName","user"])]),p("div",Te,[p("div",ke,[p("span",we,y(i.actorDisplayName),1),s.isOwnComment&&e.id&&!e.loading?(m(),u(O,{key:0,class:"comment__actions"},{default:c(()=>[e.editing?(m(),u(l,{key:1,onClick:e.onEditCancel},{icon:c(()=>[d(R,{size:20})]),default:c(()=>[C(" "+y(s.t("comments","Cancel edit")),1)]),_:1},8,["onClick"])):(m(),b(Y,{key:0},[d(l,{closeAfterClick:"",onClick:e.onEdit},{icon:c(()=>[d(f,{size:20})]),default:c(()=>[C(" "+y(s.t("comments","Edit comment")),1)]),_:1},8,["onClick"]),d(L),d(l,{closeAfterClick:"",onClick:e.onDeleteWithUndo},{icon:c(()=>[d(M,{size:20})]),default:c(()=>[C(" "+y(s.t("comments","Delete comment")),1)]),_:1},8,["onClick"])],64))]),_:1})):I("",!0),e.id&&e.loading?(m(),b("div",Ae)):i.creationDateTime?(m(),u($,{key:2,class:"comment__timestamp",timestamp:s.timestamp,ignoreSeconds:!0},null,8,["timestamp"])):I("",!0)]),i.editor||e.editing?(m(),b("form",{key:0,class:"comment__editor",onSubmit:o[2]||(o[2]=Z(()=>{},["prevent"]))},[p("div",ve,[d(j,{ref:"editor",modelValue:r.localMessage,"onUpdate:modelValue":[o[0]||(o[0]=w=>r.localMessage=w),o[1]||(o[1]=w=>r.submitted=!1)],autoComplete:i.autoComplete,contenteditable:!e.loading,label:i.editor?s.t("comments","New comment"):s.t("comments","Edit comment"),placeholder:s.t("comments","Write a comment …"),userData:i.userData,"aria-describedby":"tab-comments__editor-description",onSubmit:s.onSubmit},null,8,["modelValue","autoComplete","contenteditable","label","placeholder","userData","onSubmit"]),p("div",xe,[d(q,{variant:"tertiary-no-background",type:"submit","aria-label":s.t("comments","Post comment"),disabled:s.isEmptyMessage,onClick:s.onSubmit},{icon:c(()=>[e.loading?(m(),u(P,{key:0})):(m(),u(V,{key:1,size:20}))]),_:1},8,["aria-label","disabled","onClick"])])]),p("div",Se,y(s.t("comments","@ for mentions, : for emoji, / for smart picker")),1)],32)):(m(),u(z,{key:1,class:A(["comment__message",{"comment__message--expanded":r.expanded}]),text:s.richContent.message,arguments:s.richContent.mentions,useMarkdown:"",onClick:s.onExpand},null,8,["class","text","arguments","onClick"])),!i.editor&&!e.editing?(m(),u(B,{key:2,class:"comment__reference-list",text:s.richContent.message,interactiveOptIn:""},null,8,["text"])):I("",!0)])]),_:1},8,["class"])),[[X,!e.deleted&&!s.isLimbo]])}const Je=F(Ne,[["render",Ee],["__scopeId","data-v-365fe8ac"]]),Xe=te({props:{resourceId:{type:Number,required:!0},resourceType:{type:String,default:"files"}},data(){return{editorData:{actorDisplayName:g().displayName,actorId:g().uid,key:"editor"},userData:{},currentResourceId:this.resourceId}},methods:{async autoComplete(e,o){const{data:i}=await S.get(U("core/autocomplete/get"),{params:{search:e,itemType:this.resourceType,itemId:this.currentResourceId,sorter:"commenters|share-recipients",limit:W("comments","maxAutoCompleteResults")}});return i.ocs.data.forEach(a=>{this.userData[a.id]=a}),o(Object.values(this.userData))},genMentionsData(e){return Object.values(e).flat().forEach(o=>{this.userData[o.mentionId]={icon:"icon-user",id:o.mentionId,label:o.mentionDisplayName,source:"users",primary:g()?.uid===o.mentionId}}),this.userData}}});export{Xe as C,Je as a};
//# sourceMappingURL=CommentView-CUZn_DeA.chunk.mjs.map