import{C as n,M as o,W as r}from"./Wrapper-B2WhJG1q.chunk.mjs";import{R as i,M as s,A as a}from"./MenuBar-D2fziTHe.chunk.mjs";import{m as d,R as l,F as m,E as h,c as u}from"./NcColorPicker-CXHUHxQL.chunk.mjs";import{H as p}from"./index-CHbIErrw.chunk.mjs";import{g as c}from"./modulepreload-polyfill-nb9XBeg7.chunk.mjs";import{c as f,b as y,I as g}from"./MediaHandler.provider-BJ1SsG4D.chunk.mjs";import{n as C}from"./_plugin-vue2_normalizer-wd1ZAbRr.chunk.mjs";import"./NcNoteCard-ChweF_5Q-DZCruKzr.chunk.mjs";import"./index-DfiDB3im.chunk.mjs";import"./emoji-picker-DlAAdvrL.chunk.mjs";import"./NcLoadingIcon-CHw5fok5.chunk.mjs";import"./vue.runtime.esm-C7aVrvtW.chunk.mjs";import"./logger-Bu78VaEB.chunk.mjs";import"./index-_QHNqdwt.chunk.mjs";import"./index-DqP6CuPc.chunk.mjs";import"./index-Dtu68Mmq.chunk.mjs";import"./NcCheckboxRadioSwitch-ip_mRd2T-kNk9kCSa.chunk.mjs";const $={name:"MarkdownContentEditor",components:{ContentContainer:n,ReadonlyBar:i,MenuBar:s,MainContainer:o,Wrapper:r},provide(){const t={};return Object.defineProperties(t,{[f]:{get:()=>this.$editor},[y]:{get:()=>this.$attachmentResolver??null},[g]:{get:()=>!0}}),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},showOutlineOutside:{type:Boolean,default:!1}},emits:["update:content"],computed:{htmlContent(){return this.renderHtml(this.content)}},watch:{content(){this.updateContent()}},created(){this.$editor=this.createEditor(),this.$editor.setEditable(!this.readOnly),this.fileId&&(this.$attachmentResolver=new a({currentDirectory:this.relativePath?.match(/.*\//),user:c(),shareToken:this.shareToken,fileId:this.fileId}))},updated(){this.$editor.setEditable(!this.readOnly)},beforeDestroy(){this.$editor.destroy()},methods:{renderHtml(t){return d.render(t)},extensions(){return[l.configure({component:this,extensions:[p]}),m]},createEditor(){return new h({content:this.htmlContent,extensions:this.extensions(),onUpdate:({editor:t})=>{const e=u(this.$editor.schema).serialize(t.state.doc);this.emit("update:content",{json:t.state.doc,markdown:e})},onCreate:({editor:t})=>{this.$emit("ready"),this.$parent.$emit("ready")}})},updateContent(){this.$editor.commands.setContent(this.htmlContent,!0)},outlineToggled(t){this.emit("outline-toggled",t)},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,"show-outline-outside":t.showOutlineOutside},on:{"outline-toggled":t.outlineToggled}},[e("MainContainer",[t.showMenuBar?[t.readOnly?t._t("readonlyBar",function(){return[e("ReadonlyBar")]}):e("MenuBar",{attrs:{autohide:!1}})]:t._e(),e("ContentContainer")],2)],1)},B=[],M=C($,w,B,!1,null,null);const z=M.exports;export{z as default};
//# sourceMappingURL=MarkdownContentEditor-CuiDXY1i.chunk.mjs.map
