10 lines
36 KiB
JavaScript
10 lines
36 KiB
JavaScript
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=[window.OC.filePath('viewer', '', 'js/previewUtils-BWqM5-N0.chunk.mjs'),window.OC.filePath('viewer', '', 'css/previewUtils-6cpbKhU6.chunk.css'),window.OC.filePath('viewer', '', 'js/NcActionLink-C0XLXW7A.chunk.mjs'),window.OC.filePath('viewer', '', 'js/actionText-fFcUPi2g-gjw6zxAU.chunk.mjs'),window.OC.filePath('viewer', '', 'css/NcActionLink-Cay-IPuV.chunk.css'),window.OC.filePath('viewer', '', 'js/NcActionButton-C031NBgu.chunk.mjs'),window.OC.filePath('viewer', '', 'css/NcActionButton-DyH89PpO.chunk.css'),window.OC.filePath('viewer', '', 'css/index-DCp30a-3.chunk.css')])))=>i.map(i=>d[i]);
|
|
import{i as T,a as N,b as c,g as q,c as $,d as v,r as R,e as _,f as G,h as W,j as K,k as j,l as U,_ as Z,m as A,o as J,p as Y,q as Q,s as X,t as ee,u as y,v as s,w,F as L,x as S,V as f,y as E,z as V,A as te,B as ie,C as ne,D as g,E as h,G as se,H as re,I as le,J as oe}from"./previewUtils-BWqM5-N0.chunk.mjs";const ae={computed:{isFullscreen(){return T.value}}},de={computed:{isMobile(){return N.value}}};function ce(e){if(e.hideDownload)return!1;const i=typeof e?.shareAttributes=="string"?JSON.parse(e.shareAttributes||"[]"):e?.shareAttributes;return i&&i.length>0?i.find(({scope:n,key:r})=>n==="permissions"&&r==="download")?.value!==!1:!0}const k=function(e){const i=new AbortController;return{request:async function(n,r){return e(n,{...r,signal:i.signal})},cancel:()=>i.abort()}},he={name:"Error",props:{name:{type:String,default:""}}};var ue=function(){var e=this,i=e._self._c;return i("div",{attrs:{id:"emptycontent"}},[i("div",{staticClass:"icon-error"}),i("h2",[e._t("default",function(){return[e._v(e._s(e.t("viewer","Error loading {name}",{name:e.name})))]})],2)])},me=[],pe=c(he,ue,me,!1,null,"6a8e09db");const fe=pe.exports,we=async e=>{e.startsWith("/")||(e=`/${e}`);const i=q(),n=$(),r=await i.stat(`${v()}${e}`,{details:!0,data:n});return R(r.data)};function m(e,i,n){const r={mime:i,modal:n,failed:!1,loaded:!1,davPath:_(e),source:e.source??_(e)};return Object.assign({},e,r)}async function ge(e,i={}){return(await G.getDirectoryContents(e,Object.assign({data:`<?xml version="1.0"?>
|
|
<d:propfind ${W()}>
|
|
<d:prop>
|
|
<oc:tags />
|
|
${K()}
|
|
</d:prop>
|
|
</d:propfind>`,details:!0},i))).data.map(j)}async function ve(){const e=await ye();if(!e)return{key:"basename",asc:!0};const i={mtime:"lastmod"}[e.sorting_mode]||e.sorting_mode||"basename",n=e.sorting_direction==="asc"||!e.sorting_direction;return{key:i,asc:n}}async function ye(){if(U())return null;const e=Z("apps/files/api/v1/views");return await A.get(e).then(i=>i.data.data?.files).catch(()=>null)}const be={computed:{previewPath(){return this.getPreviewIfAny({fileid:this.fileid,filename:this.filename,previewUrl:this.previewUrl,hasPreview:this.hasPreview,davPath:this.davPath,etag:this.$attrs.etag})},davPath(){return _({filename:this.filename,basename:this.basename})}},methods:{getPreviewIfAny(e){return J(e)}}};var p={exports:{}},Fe=Y.platform==="win32",_e=/^(((?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?[\\\/]?)(?:[^\\\/]*[\\\/])*)((\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))[\\\/]*$/,x={};function xe(e){return _e.exec(e).slice(1)}x.parse=function(e){if(typeof e!="string")throw new TypeError("Parameter 'pathString' must be a string, not "+typeof e);var i=xe(e);if(!i||i.length!==5)throw new TypeError("Invalid path '"+e+"'");return{root:i[1],dir:i[0]===i[1]?i[0]:i[0].slice(0,-1),base:i[2],ext:i[4],name:i[3]}};var Ce=/^((\/?)(?:[^\/]*\/)*)((\.{1,2}|[^\/]+?|)(\.[^.\/]*|))[\/]*$/,b={};function Le(e){return Ce.exec(e).slice(1)}b.parse=function(e){if(typeof e!="string")throw new TypeError("Parameter 'pathString' must be a string, not "+typeof e);var i=Le(e);if(!i||i.length!==5)throw new TypeError("Invalid path '"+e+"'");return{root:i[1],dir:i[0].slice(0,-1),base:i[2],ext:i[4],name:i[3]}},Fe?p.exports=x.parse:p.exports=b.parse,p.exports.posix=b.parse,p.exports.win32=x.parse;var Se=p.exports;const H=Q(Se),Ee={inheritAttrs:!1,mixins:[be],props:{active:{type:Boolean,default:!1},basename:{type:String,required:!0},filename:{type:String,required:!0},source:{type:String,default:void 0},previewUrl:{type:String,default:void 0},hasPreview:{type:Boolean,default:!1},fileid:{type:[Number,String],required:!1},fileList:{type:Array,default:()=>[]},mime:{type:String,required:!0},canSwipe:{type:Boolean,default:!0},canZoom:{type:Boolean,default:!1},loaded:{type:Boolean,default:!1},isSidebarShown:{type:Boolean,default:!1},isFullScreen:{type:Boolean,default:!1},metadataFilesLivePhoto:{type:Number,default:void 0}},data(){return{height:null,width:null,naturalHeight:null,naturalWidth:null,isLoaded:!1}},computed:{name(){return H(this.basename).name},ext(){return H(this.basename).ext},src(){return this.source??this.davPath}},watch:{active(e,i){e===!0&&i===!1&&this.isLoaded&&this.doneLoading()},isSidebarShown(){setTimeout(this.updateHeightWidth,200)}},mounted(){this.$el.addEventListener("error",e=>{console.error("Error loading",this.filename,e),this.$emit("error",e)}),window.addEventListener("resize",X(()=>{this.updateHeightWidth()},100))},methods:{doneLoading(){this.$emit("update:loaded",!0),this.isLoaded=!0},updateHeightWidth(){const e=this.$parent.$el.querySelector(".modal-wrapper");if(e&&this.naturalHeight>0&&this.naturalWidth>0){const i=e.querySelector(".modal-container"),n=i.clientHeight,r=i.clientWidth,l=n/this.naturalHeight,d=r/this.naturalWidth;l<d&&l<1?(this.height=n,this.width=Math.round(this.naturalWidth/this.naturalHeight*n)):l>d&&d<1?(this.width=r,this.height=Math.round(this.naturalHeight/this.naturalWidth*r)):(this.height=this.naturalHeight,this.width=this.naturalWidth)}else this.height=this.naturalHeight,this.width=this.naturalWidth},enableSwipe(){this.$emit("update:canSwipe",!0)},disableSwipe(){this.$emit("update:canSwipe",!1)},toggleFullScreen(){this.isFullScreen?document.exitFullscreen():this.$el.requestFullscreen()}}},Ve={name:"TrashCanOutlineIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}};var ke=function(){var e=this,i=e._self._c;return i("span",e._b({staticClass:"material-design-icon trash-can-outline-icon",attrs:{"aria-hidden":e.title?null:"true","aria-label":e.title,role:"img"},on:{click:function(n){return e.$emit("click",n)}}},"span",e.$attrs,!1),[i("svg",{staticClass:"material-design-icon__svg",attrs:{fill:e.fillColor,width:e.size,height:e.size,viewBox:"0 0 24 24"}},[i("path",{attrs:{d:"M9,3V4H4V6H5V19A2,2 0 0,0 7,21H17A2,2 0 0,0 19,19V6H20V4H15V3H9M7,6H17V19H7V6M9,8V17H11V8H9M13,8V17H15V8H13Z"}},[e.title?i("title",[e._v(e._s(e.title))]):e._e()])])])},He=[],Me=c(Ve,ke,He,!1,null,null);const Ae=Me.exports,Ie={name:"TrayArrowDownIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}};var ze=function(){var e=this,i=e._self._c;return i("span",e._b({staticClass:"material-design-icon tray-arrow-down-icon",attrs:{"aria-hidden":e.title?null:"true","aria-label":e.title,role:"img"},on:{click:function(n){return e.$emit("click",n)}}},"span",e.$attrs,!1),[i("svg",{staticClass:"material-design-icon__svg",attrs:{fill:e.fillColor,width:e.size,height:e.size,viewBox:"0 0 24 24"}},[i("path",{attrs:{d:"M2 12H4V17H20V12H22V17C22 18.11 21.11 19 20 19H4C2.9 19 2 18.11 2 17V12M12 15L17.55 9.54L16.13 8.13L13 11.25V2H11V11.25L7.88 8.13L6.46 9.55L12 15Z"}},[e.title?i("title",[e._v(e._s(e.title))]):e._e()])])])},Oe=[],Pe=c(Ie,ze,Oe,!1,null,null);const De=Pe.exports,Be={name:"FullscreenIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}};var Te=function(){var e=this,i=e._self._c;return i("span",e._b({staticClass:"material-design-icon fullscreen-icon",attrs:{"aria-hidden":e.title?null:"true","aria-label":e.title,role:"img"},on:{click:function(n){return e.$emit("click",n)}}},"span",e.$attrs,!1),[i("svg",{staticClass:"material-design-icon__svg",attrs:{fill:e.fillColor,width:e.size,height:e.size,viewBox:"0 0 24 24"}},[i("path",{attrs:{d:"M5,5H10V7H7V10H5V5M14,5H19V10H17V7H14V5M17,14H19V19H14V17H17V14M10,17V19H5V14H7V17H10Z"}},[e.title?i("title",[e._v(e._s(e.title))]):e._e()])])])},Ne=[],qe=c(Be,Te,Ne,!1,null,null);const $e=qe.exports,Re={name:"FullscreenExitIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}};var Ge=function(){var e=this,i=e._self._c;return i("span",e._b({staticClass:"material-design-icon fullscreen-exit-icon",attrs:{"aria-hidden":e.title?null:"true","aria-label":e.title,role:"img"},on:{click:function(n){return e.$emit("click",n)}}},"span",e.$attrs,!1),[i("svg",{staticClass:"material-design-icon__svg",attrs:{fill:e.fillColor,width:e.size,height:e.size,viewBox:"0 0 24 24"}},[i("path",{attrs:{d:"M14,14H19V16H16V19H14V14M5,14H10V19H8V16H5V14M8,5H10V10H5V8H8V5M19,8V10H14V5H16V8H19Z"}},[e.title?i("title",[e._v(e._s(e.title))]):e._e()])])])},We=[],Ke=c(Re,Ge,We,!1,null,null);const je=Ke.exports,Ue={name:"PencilOutlineIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}};var Ze=function(){var e=this,i=e._self._c;return i("span",e._b({staticClass:"material-design-icon pencil-outline-icon",attrs:{"aria-hidden":e.title?null:"true","aria-label":e.title,role:"img"},on:{click:function(n){return e.$emit("click",n)}}},"span",e.$attrs,!1),[i("svg",{staticClass:"material-design-icon__svg",attrs:{fill:e.fillColor,width:e.size,height:e.size,viewBox:"0 0 24 24"}},[i("path",{attrs:{d:"M14.06,9L15,9.94L5.92,19H5V18.08L14.06,9M17.66,3C17.41,3 17.15,3.1 16.96,3.29L15.13,5.12L18.88,8.87L20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18.17,3.09 17.92,3 17.66,3M14.06,6.19L3,17.25V21H6.75L17.81,9.94L14.06,6.19Z"}},[e.title?i("title",[e._v(e._s(e.title))]):e._e()])])])},Je=[],Ye=c(Ue,Ze,Je,!1,null,null);const Qe=Ye.exports,Xe=()=>y(()=>import("./previewUtils-BWqM5-N0.chunk.mjs").then(e=>e.bg),__vite__mapDeps([0,1]),import.meta.url),et=()=>y(()=>import("./NcActionLink-C0XLXW7A.chunk.mjs"),__vite__mapDeps([2,3,0,1,4]),import.meta.url),tt=()=>y(()=>import("./NcActionButton-C031NBgu.chunk.mjs"),__vite__mapDeps([5,0,1,3,6]),import.meta.url),it=ee({name:"Viewer",components:{Delete:Ae,Download:De,Error:fe,Fullscreen:$e,FullscreenExit:je,NcActionButton:tt,NcActionLink:et,NcModal:Xe,Pencil:Qe},mixins:[ae,de],data(){return{Viewer:OCA.Viewer,Sidebar:null,handlers:OCA.Viewer.availableHandlers,components:{},mimeGroups:{},registeredHandlers:{},currentIndex:0,previousFile:{},currentFile:{},comparisonFile:null,nextFile:{},fileList:[],sortingConfig:null,isLoaded:!1,initiated:!1,editing:!1,cancelRequestFile:()=>{},cancelRequestFolder:()=>{},sidebarPosition:0,isSidebarShown:!1,isFullscreenMode:!1,canSwipe:!0,isStandalone:!1,theme:null,lightBackdrop:null,root:V,handlerId:"",trapElements:[]}},computed:{downloadPath(){return this.currentFile.source??this.currentFile.davPath},hasPrevious(){return this.fileList.length>1&&(this.canLoop||!this.isStartOfList)},hasNext(){return this.fileList.length>1&&(this.canLoop||!this.isEndOfList)},file(){return this.Viewer.file},fileInfo(){return this.Viewer.fileInfo},comparisonFileInfo(){return this.Viewer.compareFileInfo},files(){return this.Viewer.files},enableSidebar(){return this.Viewer.enableSidebar},el(){return this.Viewer.el},loadMore(){return this.Viewer.loadMore},canLoop(){return this.Viewer.canLoop},isStartOfList(){return this.currentIndex===0},isEndOfList(){return this.currentIndex===this.fileList.length-1},hasPreviousFile(){return Object.keys(this.previousFile).length>0},hasNextFile(){return Object.keys(this.nextFile).length>0},isImage(){return["image/jpeg","image/png","image/webp"].includes(this.currentFile?.mime)},sidebarFile(){return this.Sidebar&&this.Sidebar.file},sidebarOpenFilePath(){try{return this.currentFile?.davPath?.split(re)[1]?.split("/")?.map(decodeURIComponent)?.join("/")}catch{return!1}},canDelete(){return this.currentFile?.permissions?.includes("D")},canDownload(){return this.comparisonFile?!1:this.currentFile&&ce(this.currentFile)},canEdit(){return!this.isMobile&&this.canDownload&&this.currentFile?.permissions?.includes("W")&&this.isImage&&!this.comparisonFile&&(se("core","config",[])["enable_non-accessible_features"]??!0)},modalClass(){return{"icon-loading":!this.currentFile.loaded&&!this.currentFile.failed,"theme--undefined":this.theme===null,"theme--dark":this.theme==="dark","theme--light":this.theme==="light","theme--default":this.theme==="default","image--fullscreen":this.isImage&&this.isFullscreenMode}},showComparison(){return!this.isMobile},contentClass(){return{"viewer--split":this.comparisonFile}},isSameFile(){return(e=null,i=null)=>!!(i&&i===this.currentFile.path&&!this.currentFile.source||i===this.currentFile.filename||e&&e.fileid===this.currentFile.fileid&&e.mtime&&e.mtime===this.currentFile.mtime&&e.source&&e.source===this.currentFile.source)}},watch:{el(e){s.info(e),this.$nextTick(()=>{const i=document.getElementById("viewer");if(e){const n=document.querySelector(e);n?n.appendChild(i):s.warn("Could not find element ",{element:e})}else document.body.appendChild(i)})},file(e){e&&e.trim()!==""?(s.info("Opening viewer for file ",{path:e}),this.openFile(e,OCA.Viewer.overrideHandlerId)):this.cleanup()},fileInfo(e){e?(s.info("Opening viewer for fileInfo ",{fileInfo:e}),this.openFileInfo(e,OCA.Viewer.overrideHandlerId)):this.cleanup()},comparisonFileInfo(e){e?(s.info("Opening viewer for comparisonFileInfo ",{fileInfo:e}),this.compareFile(e)):this.cleanup()},files(e){if(!e||!Array.isArray(e)||e.length===0){s.warn("No files provided, skipping update");return}const i=e.findIndex(n=>n.filename===this.currentFile.filename);i>-1&&(this.currentIndex=i,s.debug("The files list changed, new current file index is "+i)),this.fileList=e},async isEndOfList(e){if(!(!e||this.el)&&this.loadMore&&typeof this.loadMore=="function"){s.debug("Fetching additional files...");const i=await this.loadMore();Array.isArray(i)&&i.length>0&&this.fileList.push(...i)}}},beforeMount(){this.isStandalone=window.OCP?.Files===void 0,this.isStandalone&&s.info("No OCP.Files app found, viewer is now in standalone mode"),document.addEventListener("DOMContentLoaded",()=>{window._oca_viewer_handlers&&window._oca_viewer_handlers.forEach(e=>{OCA.Viewer.registerHandler(e)}),this.handlers.forEach(e=>{this.registerHandler(e)}),this.handlers.forEach(e=>{this.registerHandlerAlias(e)}),this.isLoaded=!0,OCA?.Files?.Sidebar&&(this.Sidebar=OCA.Files.Sidebar.state),s.info(`${this.handlers.length} viewer handlers registered`,{handlers:this.handlers})}),window.addEventListener("resize",this.onResize)},mounted(){h("files:sidebar:opened",this.handleAppSidebarOpen),h("files:sidebar:closed",this.handleAppSidebarClose),h("files:node:updated",this.handleFileUpdated),h("viewer:trapElements:changed",this.handleTrapElementsChange),h("editor:toggle",this.toggleEditor),h("editor:file:created",this.handleNewFile),window.addEventListener("keydown",this.keyboardDeleteFile),window.addEventListener("keydown",this.keyboardDownloadFile),window.addEventListener("keydown",this.keyboardEditFile),this.addFullscreenEventListeners()},beforeDestroy(){window.removeEventListener("resize",this.onResize)},destroyed(){g("files:sidebar:opened",this.handleAppSidebarOpen),g("files:sidebar:closed",this.handleAppSidebarClose),g("viewer:trapElements:changed",this.handleTrapElementsChange),g("editor:toggle",this.toggleEditor),window.removeEventListener("keydown",this.keyboardDeleteFile),window.removeEventListener("keydown",this.keyboardDownloadFile),window.removeEventListener("keydown",this.keyboardEditFile),this.removeFullscreenEventListeners()},methods:{uniqueKey(e){return""+e.fileid+e.source},toggleEditor(e){ne(e),this.editing=e},preventContextMenu(e){this.canDownload||e.preventDefault()},async beforeOpen(){this.initiated=!0,OCA?.Files?.Sidebar?.setFullScreenMode&&OCA.Files.Sidebar.setFullScreenMode(!0),this.sortingConfig=await ve(),window.loadRoboto&&(s.debug("⚠️ Loading roboto font for visual regression tests"),y(()=>Promise.resolve({}),__vite__mapDeps([7]),import.meta.url),delete window.loadRoboto)},async openFile(e,i=null){if(await this.beforeOpen(),this.cancelRequestFile(),this.isSameFile(null,e)){s.debug("Viewer already opened with the same path, ignoring",{path:e});return}const{request:n,cancel:r}=k(le);this.cancelRequestFile=r;const[,l]=E(e);this.el||(document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden");const d=document.getElementsByTagName("head")[0].getElementsByTagName("title")[0];d&&!d.dataset.old&&l!==""&&(d.dataset.old=document.title,this.updateTitle(l));try{const a=await n(e);console.debug("File info for "+e+" fetched",a),await this.openFileInfo(a,i),!this.isStandalone&&this.canEdit&&window.OCP?.Files?.Router?.query?.editing==="true"&&this.toggleEditor(!0)}catch(a){a?.response?.status===404?(s.error("The file no longer exists, error: ",{error:a}),w(t("viewer","This file no longer exists")),this.close()):console.error("Could not open file "+e,a)}},async handleNewFile(e){let i;try{i=ie(e),this.openFile(i)}catch(n){s.error("Could not extract file path from source",{source:e,e:n})}try{const n=await we("/"+i);S("files:node:created",n)}catch(n){s.error("Could not fetch new file",{path:i,e:n})}},async openFileInfo(e,i=null){if(this.beforeOpen(),this.cancelRequestFolder(),this.isSameFile(e)){s.debug("Viewer already opened with the same fileInfo, ignoring",{fileInfo:e});return}const n=e.mime,r=n.split("/")[0];let l;if(i!==null&&(l=Object.values(this.registeredHandlers).find(u=>u.id===i)??l),l||(l=this.registeredHandlers[n]??this.registeredHandlers[r]),!l){s.error("The following file could not be displayed",{fileInfo:e}),w(t("viewer","There is no plugin available to display this file type")),this.close();return}this.theme=l.theme??"dark";const d=window.getComputedStyle(document.body).getPropertyValue("--background-invert-if-dark")!=="invert(100%)";this.lightBackdrop=l.theme==="light"||l.theme==="default"&&d,this.handlerId=l.id,this.currentFile=new m(e,n,l.component),this.comparisonFile=null,this.updatePreviousNext();const a=this.mimeGroups[n];if(this.files&&this.files.length>0)s.debug("A files list have been provided. No folder content will be fetched."),this.fileList=this.files,this.currentIndex=this.fileList.findIndex(u=>u.filename===e.filename);else if(a&&this.el===null){const u=this.mimeGroups[a]?this.mimeGroups[a]:[n],{request:I,cancel:z}=k(ge);this.cancelRequestFolder=z;const[O]=E(e.filename);this.currentIndex=0,this.fileList=[e];const C=(await I(O)).filter(o=>o.mime&&u.indexOf(o.mime)!==-1),P=C.map(o=>new L({source:V+v()+o.filename,id:o.fileid,displayname:o.displayname,mime:o.mime,mtime:new Date(o.lastmod),owner:this.currentFile.ownerId,root:v()})),D=te(P,{sortingMode:this.sortingConfig.key,sortingOrder:this.sortingConfig.asc?"asc":"desc"});this.fileList=D.map(o=>C.find(B=>B.filename===o.path)),this.currentIndex=this.fileList.findIndex(o=>o.filename===e.filename),this.updatePreviousNext()}else this.currentIndex=0,this.fileList=[e];this.changeSidebar()},openFileFromList(e){const i=e.mime;this.currentFile=new m(e,i,this.components[i]),this.changeSidebar(),this.updatePreviousNext()},async compareFile(e){this.comparisonFile=new m(e,e.mime,this.components[e.mime])},changeSidebar(){this.sidebarFile&&this.showSidebar()},updatePreviousNext(){const e=this.fileList[this.currentIndex-1],i=this.fileList[this.currentIndex+1];if(e){const n=e.mime;this.components[n]&&(this.previousFile=new m(e,n,this.components[n]))}else this.previousFile={};if(i){const n=i.mime;this.components[n]&&(this.nextFile=new m(i,n,this.components[n]))}else this.nextFile={}},updateTitle(e){document.title=`${e} - ${OCA.Theming?.name??oc_defaults.name}`},registerHandler(e){if(e.id&&Object.values(this.registeredHandlers).findIndex(i=>i.id===e.id)>-1){s.error("The following handler is already registered",{handler:e});return}if(!e.id||e.id.trim()===""||typeof e.id!="string"){s.error("The following handler doesn't have a valid id",{handler:e});return}if(!(!(e.mimes&&Array.isArray(e.mimes))&&e.mimesAliases)){if(!(e.mimes&&Array.isArray(e.mimes))&&!e.mimesAliases){s.error("The following handler doesn't have a valid mime array",{handler:e});return}if(!e.component||typeof e.component!="object"&&typeof e.component!="function"){s.error("The following handler doesn't have a valid component",{handler:e});return}e.component.mixins=[...e?.component?.mixins??[],Ee],e.mimes&&e.mimes.forEach(i=>{if(this.components[i]){s.error("The following mime is already registered",{mime:i,handler:e});return}this.registerGroups({mime:i,group:e.group}),this.components[i]=e.component,f.component(e.component.name,e.component),this.registeredHandlers[i]=e})}},registerHandlerAlias(e){e.mimesAliases&&Object.keys(e.mimesAliases).forEach(i=>{if(e.mimesAliases&&typeof e.mimesAliases!="object"){s.error("The following handler doesn't have a valid mimesAliases object",{handler:e});return}const n=e.mimesAliases[i];if(this.components[i]){s.error("The following mime is already registered",{mime:i,handler:e});return}if(!this.components[n]){s.error("The requested alias does not exists",{alias:n,mime:i,handler:e});return}this.registerGroups({mime:i,group:this.mimeGroups[n]}),this.components[i]=this.components[n],this.registeredHandlers[i]=e})},registerGroups({mime:e,group:i}){i&&(this.mimeGroups[e]=i,this.mimeGroups[i]||(this.mimeGroups[i]=[]),this.mimeGroups[i].push(e))},close(){OCA.Viewer.close(),OCA?.Files?.Sidebar&&OCA.Files.Sidebar.setFullScreenMode(!1),this.isFullscreenMode&&this.exitFullscreen()},keyboardDeleteFile(e){this.canDelete&&e.key==="Delete"&&e.ctrlKey===!0&&this.onDelete()},keyboardDownloadFile(e){e.key==="s"&&e.ctrlKey===!0&&(e.preventDefault(),this.canDownload&&this.onDownload())},keyboardEditFile(e){e.key==="e"&&e.ctrlKey===!0&&(e.preventDefault(),this.canEdit&&this.onEdit())},cleanup(){s.info("Cleaning up viewer"),this.currentFile={},this.comparisonFile=null,this.currentModal=null,this.fileList=[],this.initiated=!1,this.theme=null,this.cancelRequestFile(),this.cancelRequestFolder(),document.body.style.overflow=null,document.documentElement.style.overflow=null,this.Viewer.onClose();const e=document.getElementsByTagName("head")[0].getElementsByTagName("title")[0];e&&e.dataset.old&&(document.title=e.dataset.old,delete e.dataset.old)},previous(){this.currentIndex--,this.currentIndex<0&&(this.currentIndex=this.fileList.length-1);const e=this.fileList[this.currentIndex];this.openFileFromList(e),this.Viewer.onPrev(e),this.updateTitle(this.currentFile.basename)},next(){this.currentIndex++,this.currentIndex>this.fileList.length-1&&(this.currentIndex=0);const e=this.fileList[this.currentIndex];this.openFileFromList(e),this.Viewer.onNext(e),this.updateTitle(this.currentFile.basename)},comparisonFailed(){this.comparisonFile.failed=!0},previousFailed(){this.previousFile.failed=!0},currentFailed(){this.currentFile.failed=!0},nextFailed(){this.nextFile.failed=!0},async showSidebar(){this.enableSidebar&&OCA?.Files?.Sidebar&&await OCA.Files.Sidebar.open(this.sidebarOpenFilePath)},handleAppSidebarOpen(){this.isSidebarShown=!0;const e=document.querySelector("aside.app-sidebar");e&&(this.sidebarPosition=e.getBoundingClientRect().left,this.trapElements=[e])},handleAppSidebarClose(){this.isSidebarShown=!1,this.trapElements=[]},async handleFileUpdated(e){const i=this.fileList.findIndex(({fileid:n})=>n===e.fileid);e.etag=e.attributes.etag,this.fileList.splice(i,1,e),e.fileid===this.currentFile.fileid&&(this.currentFile.etag=e.attributes.etag)},onResize(){const e=document.querySelector("aside.app-sidebar");e&&(this.sidebarPosition=e.getBoundingClientRect().left)},async onDelete(){try{const e=this.currentFile.fileid,i=this.currentFile.source??this.currentFile.davPath,n=new L({source:i,id:e,mime:this.currentFile.mime,owner:this.currentFile.ownerId,root:i.includes("remote.php/dav")?v():void 0});await A.delete(i),S("files:node:deleted",n);const r=this.fileList.findIndex(l=>l.filename===this.currentFile.filename);this.hasPrevious||this.hasNext?(this.hasNext?this.next():this.previous(),this.fileList.splice(r,1)):this.close()}catch(e){console.error(e),w(e)}},onEdit(){this.toggleEditor(!0)},async onDownload(){if(!this.canDownload)return;const e=this.currentFile.mime,i=e?.split("/")[0],n=this.registeredHandlers[e]??this.registeredHandlers[i];if(n?.downloadCallback&&typeof n.downloadCallback=="function")try{s.debug("Calling handler downloadCallback before download"),await n.downloadCallback(this.currentFile)}catch(r){s.error("Failed to execute downloadCallback",{error:r}),w(t("viewer","Failed to save file before download"));return}this.performDownload()},performDownload(){s.debug("Performing download",{file:this.currentFile});const e=document.createElement("a");e.href=this.currentFile.source??this.currentFile.davPath,e.download=this.currentFile.basename,document.body.appendChild(e),e.click(),document.body.removeChild(e)},handleTrapElementsChange(e){this.trapElements.push(e)},toggleFullScreen(){this.isFullscreenMode?this.exitFullscreen():this.requestFullscreen()},requestFullscreen(){const e=document.documentElement;e.requestFullscreen?e.requestFullscreen():e.webkitRequestFullscreen&&e.webkitRequestFullscreen()},exitFullscreen(){document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()},addFullscreenEventListeners(){document.addEventListener("fullscreenchange",this.onFullscreenchange),document.addEventListener("webkitfullscreenchange",this.onFullscreenchange)},removeFullscreenEventListeners(){document.addEventListener("fullscreenchange",this.onFullscreenchange),document.addEventListener("webkitfullscreenchange",this.onFullscreenchange)},onFullscreenchange(){document.fullscreenElement===document.documentElement||document.webkitFullscreenElement===document.documentElement?this.isFullscreenMode=!0:this.isFullscreenMode=!1}}});var nt=function(){var e=this,i=e._self._c;return e._self._setupProxy,e.el?i("div",{attrs:{id:"viewer","data-handler":e.handlerId}},[e.currentFile.failed?i("Error",{attrs:{name:e.currentFile.basename}}):i(e.currentFile.modal,e._b({key:e.uniqueKey(e.currentFile),ref:"content",tag:"component",staticClass:"viewer__file viewer__file--active",attrs:{active:!0,"can-swipe":!1,"can-zoom":!1,"file-list":[e.currentFile],"is-full-screen":!1,loaded:e.currentFile.loaded,"is-sidebar-shown":!1},on:{"update:loaded":function(n){return e.$set(e.currentFile,"loaded",n)},error:e.currentFailed}},"component",e.currentFile,!1))],1):e.initiated||e.currentFile.modal?i("NcModal",{staticClass:"viewer",class:e.modalClass,style:{width:e.isSidebarShown?`${e.sidebarPosition}px`:null},attrs:{id:"viewer","additional-trap-elements":e.trapElements,"clear-view-delay":-1,"close-button-contained":!1,dark:!0,"light-backdrop":e.lightBackdrop,"data-handler":e.handlerId,"enable-slideshow":e.hasPrevious||e.hasNext,"slideshow-paused":e.editing,"enable-swipe":e.canSwipe&&!e.editing,"has-next":e.hasNext,"has-previous":e.hasPrevious,"inline-actions":e.canEdit?1:0,"spread-navigation":!0,name:e.currentFile.basename,size:"full"},on:{close:e.close,previous:e.previous,next:e.next},scopedSlots:e._u([{key:"actions",fn:function(){return[e.canEdit?i("NcActionButton",{attrs:{"close-after-click":!0},on:{click:e.onEdit},scopedSlots:e._u([{key:"icon",fn:function(){return[i("Pencil",{attrs:{size:20}})]},proxy:!0}],null,!1,580569589)},[e._v(" "+e._s(e.t("viewer","Edit"))+" ")]):e._e(),i("NcActionButton",{attrs:{"close-after-click":!0},on:{click:e.toggleFullScreen},scopedSlots:e._u([{key:"icon",fn:function(){return[e.isFullscreenMode?i("FullscreenExit",{attrs:{size:20}}):i("Fullscreen",{attrs:{size:20}})]},proxy:!0}])},[e._v(" "+e._s(e.isFullscreenMode?e.t("viewer","Exit full screen"):e.t("viewer","Full screen"))+" ")]),e.enableSidebar&&e.Sidebar&&e.sidebarOpenFilePath&&!e.isSidebarShown?i("NcActionButton",{attrs:{"close-after-click":!0,icon:"icon-menu-sidebar"},on:{click:e.showSidebar}},[e._v(" "+e._s(e.t("viewer","Open sidebar"))+" ")]):e._e(),e.canDownload?i("NcActionButton",{attrs:{"close-after-click":!0},on:{click:e.onDownload},scopedSlots:e._u([{key:"icon",fn:function(){return[i("Download",{attrs:{size:20}})]},proxy:!0}],null,!1,3312959228)},[e._v(" "+e._s(e.t("viewer","Download"))+" ")]):e._e(),e.canDelete?i("NcActionButton",{attrs:{"close-after-click":!0},on:{click:e.onDelete},scopedSlots:e._u([{key:"icon",fn:function(){return[i("Delete",{attrs:{size:20}})]},proxy:!0}],null,!1,2705356561)},[e._v(" "+e._s(e.t("viewer","Delete"))+" ")]):e._e()]},proxy:!0}])},[i("div",{staticClass:"viewer__content",class:e.contentClass,on:{click:function(n){return n.target!==n.currentTarget||n.ctrlKey||n.shiftKey||n.altKey||n.metaKey?null:e.close.apply(null,arguments)},contextmenu:e.preventContextMenu}},[e.comparisonFile&&!e.comparisonFile.failed&&e.showComparison?i("div",{staticClass:"viewer__file-wrapper"},[i(e.comparisonFile.modal,e._b({key:e.uniqueKey(e.comparisonFile),ref:"comparison-content",tag:"component",staticClass:"viewer__file viewer__file--active",attrs:{active:!0,"can-swipe":!1,"can-zoom":!1,editing:!1,"is-full-screen":e.isFullscreen,"is-sidebar-shown":e.isSidebarShown,loaded:e.comparisonFile.loaded},on:{"update:loaded":function(n){return e.$set(e.comparisonFile,"loaded",n)},error:e.comparisonFailed}},"component",e.comparisonFile,!1))],1):e._e(),e.hasPreviousFile?i("div",{key:e.uniqueKey(e.previousFile),staticClass:"viewer__file-wrapper viewer__file-wrapper--hidden",attrs:{"aria-hidden":"true",inert:""}},[e.previousFile.failed?i("Error",{attrs:{name:e.previousFile.basename}}):i(e.previousFile.modal,e._b({ref:"previous-content",tag:"component",staticClass:"viewer__file",attrs:{"file-list":e.fileList},on:{error:e.previousFailed}},"component",e.previousFile,!1))],1):e._e(),i("div",{key:e.uniqueKey(e.currentFile),staticClass:"viewer__file-wrapper"},[e.currentFile.failed?i("Error",{attrs:{name:e.currentFile.basename}}):i(e.currentFile.modal,e._b({ref:"content",tag:"component",staticClass:"viewer__file viewer__file--active",attrs:{active:!0,"can-swipe":e.canSwipe,"can-zoom":!0,editing:e.editing,"file-list":e.fileList,"is-full-screen":e.isFullscreen,"is-sidebar-shown":e.isSidebarShown,loaded:e.currentFile.loaded},on:{"update:canSwipe":function(n){e.canSwipe=n},"update:can-swipe":function(n){e.canSwipe=n},"update:editing":[function(n){e.editing=n},e.toggleEditor],"update:loaded":function(n){return e.$set(e.currentFile,"loaded",n)},error:e.currentFailed}},"component",e.currentFile,!1))],1),e.hasNextFile?i("div",{key:e.uniqueKey(e.nextFile),staticClass:"viewer__file-wrapper viewer__file-wrapper--hidden",attrs:{"aria-hidden":"true",inert:""}},[e.nextFile.failed?i("Error",{attrs:{name:e.nextFile.basename}}):i(e.nextFile.modal,e._b({ref:"next-content",tag:"component",staticClass:"viewer__file",attrs:{"file-list":e.fileList},on:{error:e.nextFailed}},"component",e.nextFile,!1))],1):e._e()])]):e._e()},st=[],rt=c(it,nt,st,!1,null,"06a0ad14");const lt=rt.exports;f.mixin({methods:{t:oe}}),f.prototype.OC=window.OC,f.prototype.OCA=window.OCA;const M=document.createElement("div");M.id="viewer",document.body.appendChild(M);const F=document.createElement("div");F.innerHTML='<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><symbol id="plyr-airplay" viewBox="0 0 18 18"><path d="M16 1H2a1 1 0 00-1 1v10a1 1 0 001 1h3v-2H3V3h12v8h-2v2h3a1 1 0 001-1V2a1 1 0 00-1-1z"/><path d="M4 17h10l-5-6z"/></symbol><symbol id="plyr-captions-off" viewBox="0 0 18 18"><path d="M1 1c-.6 0-1 .4-1 1v11c0 .6.4 1 1 1h4.6l2.7 2.7c.2.2.4.3.7.3.3 0 .5-.1.7-.3l2.7-2.7H17c.6 0 1-.4 1-1V2c0-.6-.4-1-1-1H1zm4.52 10.15c1.99 0 3.01-1.32 3.28-2.41l-1.29-.39c-.19.66-.78 1.45-1.99 1.45-1.14 0-2.2-.83-2.2-2.34 0-1.61 1.12-2.37 2.18-2.37 1.23 0 1.78.75 1.95 1.43l1.3-.41C8.47 4.96 7.46 3.76 5.5 3.76c-1.9 0-3.61 1.44-3.61 3.7 0 2.26 1.65 3.69 3.63 3.69zm7.57 0c1.99 0 3.01-1.32 3.28-2.41l-1.29-.39c-.19.66-.78 1.45-1.99 1.45-1.14 0-2.2-.83-2.2-2.34 0-1.61 1.12-2.37 2.18-2.37 1.23 0 1.78.75 1.95 1.43l1.3-.41c-.28-1.15-1.29-2.35-3.25-2.35-1.9 0-3.61 1.44-3.61 3.7 0 2.26 1.65 3.69 3.63 3.69z" fill-rule="evenodd" fill-opacity=".5"/></symbol><symbol id="plyr-captions-on" viewBox="0 0 18 18"><path d="M1 1c-.6 0-1 .4-1 1v11c0 .6.4 1 1 1h4.6l2.7 2.7c.2.2.4.3.7.3.3 0 .5-.1.7-.3l2.7-2.7H17c.6 0 1-.4 1-1V2c0-.6-.4-1-1-1H1zm4.52 10.15c1.99 0 3.01-1.32 3.28-2.41l-1.29-.39c-.19.66-.78 1.45-1.99 1.45-1.14 0-2.2-.83-2.2-2.34 0-1.61 1.12-2.37 2.18-2.37 1.23 0 1.78.75 1.95 1.43l1.3-.41C8.47 4.96 7.46 3.76 5.5 3.76c-1.9 0-3.61 1.44-3.61 3.7 0 2.26 1.65 3.69 3.63 3.69zm7.57 0c1.99 0 3.01-1.32 3.28-2.41l-1.29-.39c-.19.66-.78 1.45-1.99 1.45-1.14 0-2.2-.83-2.2-2.34 0-1.61 1.12-2.37 2.18-2.37 1.23 0 1.78.75 1.95 1.43l1.3-.41c-.28-1.15-1.29-2.35-3.25-2.35-1.9 0-3.61 1.44-3.61 3.7 0 2.26 1.65 3.69 3.63 3.69z" fill-rule="evenodd"/></symbol><symbol id="plyr-download" viewBox="0 0 18 18"><path d="M9 13c.3 0 .5-.1.7-.3L15.4 7 14 5.6l-4 4V1H8v8.6l-4-4L2.6 7l5.7 5.7c.2.2.4.3.7.3zm-7 2h14v2H2z"/></symbol><symbol id="plyr-enter-fullscreen" viewBox="0 0 18 18"><path d="M10 3h3.6l-4 4L11 8.4l4-4V8h2V1h-7zM7 9.6l-4 4V10H1v7h7v-2H4.4l4-4z"/></symbol><symbol id="plyr-exit-fullscreen" viewBox="0 0 18 18"><path d="M1 12h3.6l-4 4L2 17.4l4-4V17h2v-7H1zM16 .6l-4 4V1h-2v7h7V6h-3.6l4-4z"/></symbol><symbol id="plyr-fast-forward" viewBox="0 0 18 18"><path d="M7.875 7.171L0 1v16l7.875-6.171V17L18 9 7.875 1z"/></symbol><symbol id="plyr-logo-vimeo" viewBox="0 0 18 18"><path d="M17 5.3c-.1 1.6-1.2 3.7-3.3 6.4-2.2 2.8-4 4.2-5.5 4.2-.9 0-1.7-.9-2.4-2.6C5 10.9 4.4 6 3 6c-.1 0-.5.3-1.2.8l-.8-1c.8-.7 3.5-3.4 4.7-3.5 1.2-.1 2 .7 2.3 2.5.3 2 .8 6.1 1.8 6.1.9 0 2.5-3.4 2.6-4 .1-.9-.3-1.9-2.3-1.1.8-2.6 2.3-3.8 4.5-3.8 1.7.1 2.5 1.2 2.4 3.3z"/></symbol><symbol id="plyr-logo-youtube" viewBox="0 0 18 18"><path d="M16.8 5.8c-.2-1.3-.8-2.2-2.2-2.4C12.4 3 9 3 9 3s-3.4 0-5.6.4C2 3.6 1.3 4.5 1.2 5.8 1 7.1 1 9 1 9s0 1.9.2 3.2c.2 1.3.8 2.2 2.2 2.4C5.6 15 9 15 9 15s3.4 0 5.6-.4c1.4-.3 2-1.1 2.2-2.4.2-1.3.2-3.2.2-3.2s0-1.9-.2-3.2zM7 12V6l5 3-5 3z"/></symbol><symbol id="plyr-muted" viewBox="0 0 18 18"><path d="M12.4 12.5l2.1-2.1 2.1 2.1 1.4-1.4L15.9 9 18 6.9l-1.4-1.4-2.1 2.1-2.1-2.1L11 6.9 13.1 9 11 11.1zM3.786 6.008H.714C.286 6.008 0 6.31 0 6.76v4.512c0 .452.286.752.714.752h3.072l4.071 3.858c.5.3 1.143 0 1.143-.602V2.752c0-.601-.643-.977-1.143-.601L3.786 6.008z"/></symbol><symbol id="plyr-pause" viewBox="0 0 18 18"><path d="M6 1H3c-.6 0-1 .4-1 1v14c0 .6.4 1 1 1h3c.6 0 1-.4 1-1V2c0-.6-.4-1-1-1zm6 0c-.6 0-1 .4-1 1v14c0 .6.4 1 1 1h3c.6 0 1-.4 1-1V2c0-.6-.4-1-1-1h-3z"/></symbol><symbol id="plyr-pip" viewBox="0 0 18 18"><path d="M13.293 3.293L7.022 9.564l1.414 1.414 6.271-6.271L17 7V1h-6z"/><path d="M13 15H3V5h5V3H2a1 1 0 00-1 1v12a1 1 0 001 1h12a1 1 0 001-1v-6h-2v5z"/></symbol><symbol id="plyr-play" viewBox="0 0 18 18"><path d="M15.562 8.1L3.87.225c-.818-.562-1.87 0-1.87.9v15.75c0 .9 1.052 1.462 1.87.9L15.563 9.9c.584-.45.584-1.35 0-1.8z"/></symbol><symbol id="plyr-restart" viewBox="0 0 18 18"><path d="M9.7 1.2l.7 6.4 2.1-2.1c1.9 1.9 1.9 5.1 0 7-.9 1-2.2 1.5-3.5 1.5-1.3 0-2.6-.5-3.5-1.5-1.9-1.9-1.9-5.1 0-7 .6-.6 1.4-1.1 2.3-1.3l-.6-1.9C6 2.6 4.9 3.2 4 4.1 1.3 6.8 1.3 11.2 4 14c1.3 1.3 3.1 2 4.9 2 1.9 0 3.6-.7 4.9-2 2.7-2.7 2.7-7.1 0-9.9L16 1.9l-6.3-.7z"/></symbol><symbol id="plyr-rewind" viewBox="0 0 18 18"><path d="M10.125 1L0 9l10.125 8v-6.171L18 17V1l-7.875 6.171z"/></symbol><symbol id="plyr-settings" viewBox="0 0 18 18"><path d="M16.135 7.784a2 2 0 01-1.23-2.969c.322-.536.225-.998-.094-1.316l-.31-.31c-.318-.318-.78-.415-1.316-.094a2 2 0 01-2.969-1.23C10.065 1.258 9.669 1 9.219 1h-.438c-.45 0-.845.258-.997.865a2 2 0 01-2.969 1.23c-.536-.322-.999-.225-1.317.093l-.31.31c-.318.318-.415.781-.093 1.317a2 2 0 01-1.23 2.969C1.26 7.935 1 8.33 1 8.781v.438c0 .45.258.845.865.997a2 2 0 011.23 2.969c-.322.536-.225.998.094 1.316l.31.31c.319.319.782.415 1.316.094a2 2 0 012.969 1.23c.151.607.547.865.997.865h.438c.45 0 .845-.258.997-.865a2 2 0 012.969-1.23c.535.321.997.225 1.316-.094l.31-.31c.318-.318.415-.781.094-1.316a2 2 0 011.23-2.969c.607-.151.865-.547.865-.997v-.438c0-.451-.26-.846-.865-.997zM9 12a3 3 0 110-6 3 3 0 010 6z"/></symbol><symbol id="plyr-volume" viewBox="0 0 18 18"><path d="M15.6 3.3c-.4-.4-1-.4-1.4 0-.4.4-.4 1 0 1.4C15.4 5.9 16 7.4 16 9c0 1.6-.6 3.1-1.8 4.3-.4.4-.4 1 0 1.4.2.2.5.3.7.3.3 0 .5-.1.7-.3C17.1 13.2 18 11.2 18 9s-.9-4.2-2.4-5.7z"/><path d="M11.282 5.282a.909.909 0 000 1.316c.735.735.995 1.458.995 2.402 0 .936-.425 1.917-.995 2.487a.909.909 0 000 1.316c.145.145.636.262 1.018.156a.725.725 0 00.298-.156C13.773 11.733 14.13 10.16 14.13 9c0-.17-.002-.34-.011-.51-.053-.992-.319-2.005-1.522-3.208a.909.909 0 00-1.316 0zm-7.496.726H.714C.286 6.008 0 6.31 0 6.76v4.512c0 .452.286.752.714.752h3.072l4.071 3.858c.5.3 1.143 0 1.143-.602V2.752c0-.601-.643-.977-1.143-.601L3.786 6.008z"/></symbol></svg>',F.style.display="none",document.body.appendChild(F),new f({el:"#viewer",name:"ViewerRoot",render:e=>e(lt)});
|
|
//# sourceMappingURL=viewer-main.mjs.map
|