3 lines
4.3 KiB
JavaScript
3 lines
4.3 KiB
JavaScript
import{t as h,c as r}from"./NcLoadingIcon-ZJnsd-es.chunk.mjs";import{u as s,s as o}from"./index-CRQM6PVi.chunk.mjs";import{l as n}from"./index-Dl858C8_.chunk.mjs";import{a as l}from"./index-DxwFe63_.chunk.mjs";import{g as c,i as u}from"./NcNoteCard-Dz5-u2BY-S2qe9Sjm.chunk.mjs";import{g as p}from"./Editor.singleton-BX-M5W3F.chunk.mjs";import{R as f}from"./RichTextReader-CRQfFvOS.chunk.mjs";import{n as m}from"./_plugin-vue2_normalizer-wd1ZAbRr.chunk.mjs";import"./emoji-picker-MDCGxHB0.chunk.mjs";import"./vue.runtime.esm-CLeelJur.chunk.mjs";import"./EditorOutline-DrybdBHq.chunk.mjs";import"./logger-CoS2pszN.chunk.mjs";import"./NcCheckboxRadioSwitch-DAPHFb0L-BMVa4UgQ.chunk.mjs";import"./MediaHandler.provider-CTjO6aKX.chunk.mjs";import"./BaseReader-CEyXn00Z.chunk.mjs";const d=u(),k=l("apps/text"+(d?"/public":"")+"/workspace",2),R=h("text","Readme")+"."+n("text","default_file_extension"),a=[R,"Readme.md","README.md","readme.md"],w={name:"RichWorkspace",components:{RichTextReader:f,Editor:p},props:{content:{type:String,default:""},path:{type:String,required:!0},active:{type:Boolean,default:!0},hasRichWorkspace:{type:Boolean,default:!1}},data(){return{localHasRichWorkspace:!1,focus:!1,folder:null,file:null,loaded:!1,ready:!1,autofocus:!1,shouldAutofocus:!1,hideMenu:!0,darkTheme:window?.OCA?.Accessibility?.theme==="dark",enabled:window?.OCA?.Text?.RichWorkspaceEnabled}},computed:{shareToken(){return c()},shouldRender(){return this.enabled&&this.localHasRichWorkspace}},watch:{path(){this.reset()},ready(){this.shouldAutofocus=!1},focus(e){e||document.querySelector("#rich-workspace .text-editor__main").scrollTo(0,0)},shouldRender(e){e&&this.getFileInfo()},hasRichWorkspace(e){this.localHasRichWorkspace=e}},mounted(){this.localHasRichWorkspace=this.hasRichWorkspace,o("Text::showRichWorkspace",this.showRichWorkspace),o("Text::hideRichWorkspace",this.hideRichWorkspace),o("files:node:created",this.onFileCreated),o("files:node:deleted",this.onFileDeleted),o("files:node:renamed",this.onFileRenamed),this.listenKeydownEvents()},beforeDestroy(){s("Text::showRichWorkspace",this.showRichWorkspace),s("Text::hideRichWorkspace",this.hideRichWorkspace),s("files:node:created",this.onFileCreated),s("files:node:deleted",this.onFileDeleted),s("files:node:renamed",this.onFileRenamed),this.unlistenKeydownEvents()},methods:{onFocus(){this.focus=!0,this.hideMenu=!1,this.unlistenKeydownEvents()},reset(){this.file=null,this.focus=!1,this.shouldAutofocus=!1,this.$nextTick(()=>{this.shouldRender&&this.getFileInfo()})},getFileInfo(){this.file=null,this.ready=!1,this.loaded=!0;const e={path:this.path};return d&&(e.shareToken=this.shareToken),r.get(k,{params:e}).then(t=>{const i=t.data.ocs.data;return this.folder=i.folder||null,this.file=i.file,this.editing=!0,this.loaded=!0,this.autofocus=this.shouldAutofocus,!0}).catch(t=>(t.response.data.ocs&&t.response.data.ocs.data.folder?this.folder=t.response.data.ocs.data.folder:this.folder=null,this.file=null,this.loaded=!0,this.ready=!0,!1))},showRichWorkspace(e){this.enabled=!0},hideRichWorkspace(){this.enabled=!1},listenKeydownEvents(){window.addEventListener("keydown",this.onKeydown)},unlistenKeydownEvents(){window.removeEventListener("keydown",this.onKeydown)},onKeydown(e){e.key==="Tab"&&(this.hideMenu=!1)},onFileCreated(e){a.includes(e.basename)&&(this.shouldAutofocus=this.enabled,this.localHasRichWorkspace=!0)},onFileDeleted(e){e.path===this.file?.path&&(this.localHasRichWorkspace=!1)},onFileRenamed(e){a.includes(e.basename)?this.localHasRichWorkspace=!0:e.fileid===this.file?.id&&e.path!==this.file?.path&&(this.localHasRichWorkspace=!1)},t:h}};var y=function(){var e=this,t=e._self._c;return e.shouldRender?t("div",{class:{focus:e.focus,dark:e.darkTheme},attrs:{id:"rich-workspace"}},[!e.loaded||!e.ready?t("RichTextReader",{staticClass:"rich-workspace--preview",attrs:{content:e.content}}):e._e(),e.file?t("Editor",{directives:[{name:"show",rawName:"v-show",value:e.ready,expression:"ready"}],key:e.file.path,attrs:{"file-id":e.file.id,"relative-path":e.file.path,"share-token":e.shareToken,mime:e.file.mimetype,autofocus:e.autofocus,"hide-menu":e.hideMenu,active:"","rich-workspace":""},on:{ready:function(i){e.ready=!0},focus:e.onFocus}}):e._e()],1):e._e()},W=[],v=m(w,y,W,!1,null,"ddfd769f");const q=v.exports;export{q as default};
|
|
//# sourceMappingURL=RichWorkspace-DJbyRXWV.chunk.mjs.map
|