import{W as l,M as u,C as m,c,F as h,R as f,U as y,a as C,d as g,e as k,b as B,p as M,f as R}from"./Wrapper-obocs1sV.chunk.mjs";import{M as $,R as b,A as v}from"./MenuBar-BBhgnV0-.chunk.mjs";import{g as w}from"./index-xQwnxqUU.chunk.mjs";import{w as s,p as O}from"./vue.runtime.esm-CbNPNm8f.chunk.mjs";import{u as x,A as H}from"./MediaHandler.provider-BUbYNN83.chunk.mjs";import{n as T}from"./NcCheckboxRadioSwitch-D4IV4zWy-Bb19W4wJ.chunk.mjs";import"./NcLoadingIcon-Bdu4Z_fo.chunk.mjs";import"./emoji-picker-hi3Hwbeu.chunk.mjs";import"./index-DxwFe63_.chunk.mjs";import"./logger-DrmDPXkr.chunk.mjs";import"./index-DtbbSwig.chunk.mjs";import"./index-D3wiQe9-.chunk.mjs";import"./preload-helper-BorfeO-5.chunk.mjs";import"./NcNoteCard-CwNXZ4vV-CPnkYq5v.chunk.mjs";const W={name:"MarkdownContentEditor",components:{ContentContainer:m,ReadonlyBar:b,MenuBar:$,MainContainer:u,Wrapper:l},provide(){const t={};return Object.defineProperties(t,{[H]:{get:()=>this.$attachmentResolver??null}}),t},props:{fileId:{type:Number,default:null},content:{type:String,required:!0},readOnly:{type:Boolean,default:!1},relativePath:{type:String,default:""},shareToken:{type:String,default:null},showMenuBar:{type:Boolean,default:!0}},emits:["update:content"],setup(t){const{openLinkHandler:e}=x(),i=[f.configure({extensions:[y],openLink:e.openLink}),h],n=new C({extensions:i}),{setEditable:a,setContent:o}=B(n),{updateHeadings:d}=g(n);s(()=>t.content,r=>{o(r)}),a(!t.readOnly),s(()=>t.readOnly,r=>{a(!r)}),O(R,{isPublic:!1,isRichEditor:!0,isRichWorkspace:!1,useTableOfContents:!0}),M(n);const{applyEditorWidth:p}=k(!0);return p(),{editor:n,setContent:o,updateHeadings:d}},created(){this.setContent(this.content,{addToHistory:!1}),this.updateHeadings(),this.editor.on("create",()=>{this.$emit("ready"),this.$parent.$emit("ready")}),this.editor.on("update",({editor:t})=>{const e=c(t.schema).serialize(t.state.doc);this.emit("update:content",{json:t.state.doc,markdown:e})}),this.fileId&&(this.$attachmentResolver=new v({currentDirectory:this.relativePath?.match(/.*\//),user:w(),shareToken:this.shareToken,fileId:this.fileId}))},beforeDestroy(){this.editor.destroy()},methods:{emit(t,e){this.$emit(t,e),this.$parent?.$emit(t,e)}}};var E=function(){var t=this,e=t._self._c;return e("Wrapper",{attrs:{"content-loaded":!0}},[e("MainContainer",[t.showMenuBar?[t.readOnly?t._t("readonlyBar",function(){return[e("ReadonlyBar")]}):e("MenuBar",{attrs:{autohide:!1}})]:t._e(),e("ContentContainer",{attrs:{"read-only":t.readOnly}})],2)],1)},_=[],I=T(W,E,_,!1,null,null);const Q=I.exports;export{Q as default};
//# sourceMappingURL=MarkdownContentEditor-BwTzyQSN.chunk.mjs.map
