import{W as p,M as l,C as m,c as u,R as c,F as h,U as f,a as y,d as C,b as g,e as B,p as v,f as M}from"./Wrapper-g9rQ14Xc.chunk.mjs";import{M as R,R as $,A as b}from"./MenuBar-yxPsXXVM.chunk.mjs";import{g as w}from"./index-CdM8BgQf.chunk.mjs";import{w as s,p as O}from"./vue.runtime.esm-B7-PK3p1.chunk.mjs";import{A as k}from"./MediaHandler.provider-BoQN9QHH.chunk.mjs";import{n as x}from"./NcCheckboxRadioSwitch-CgbTELjq-BFpDVXaF.chunk.mjs";import"./NcLoadingIcon-CBTC2zMe.chunk.mjs";import"./emoji-picker-hi3Hwbeu.chunk.mjs";import"./index-DCzdQJ7L.chunk.mjs";import"./logger-DS8A9d_w.chunk.mjs";import"./index-Bnw2WuIx.chunk.mjs";import"./index-D3wiQe9-.chunk.mjs";import"./preload-helper-BorfeO-5.chunk.mjs";import"./NcNoteCard-CwNXZ4vV-Dyi378DT.chunk.mjs";const T={name:"MarkdownContentEditor",components:{ContentContainer:m,ReadonlyBar:$,MenuBar:R,MainContainer:l,Wrapper:p},provide(){const t={};return Object.defineProperties(t,{[k]:{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 e=[c.configure({extensions:[f]}),h],r=new y({extensions:e}),{setEditable:a,setContent:o}=g(r),{updateHeadings:i}=C(r);s(()=>t.content,n=>{o(n)}),a(!t.readOnly),s(()=>t.readOnly,n=>{a(!n)}),O(M,{isPublic:!1,isRichEditor:!0,isRichWorkspace:!1,useTableOfContents:!0}),v(r);const{applyEditorWidth:d}=B(!0);return d(),{editor:r,setContent:o,updateHeadings:i}},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=u(t.schema).serialize(t.state.doc);this.emit("update:content",{json:t.state.doc,markdown:e})}),this.fileId&&(this.$attachmentResolver=new b({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 W=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)},E=[],H=x(T,W,E,!1,null,null);const K=H.exports;export{K as default};
//# sourceMappingURL=MarkdownContentEditor-BLZA83bl.chunk.mjs.map
