import{a as g}from"./index-CwjlnuSf.chunk.mjs";import{c as k,M as B,C as M,d as O,F as R,R as b,U as I,a as L,e as v,f as E,b as w,p as H,g as T}from"./UserColor-CmRVWiS0.chunk.mjs";import{M as x,R as z,A as W}from"./AttachmentResolver-DF12faEd.chunk.mjs";import{u as P,A as S}from"./Editor.provider-B06-rpyP.chunk.mjs";import{_,r as s,o as c,c as h,w as y,b as u,a as $,F as j,j as A,h as F,m as U,f as m,s as q,p as f}from"./emoji-picker-BElz8-Hr.chunk.mjs";const D={name:"MarkdownContentEditor",components:{ContentContainer:M,ReadonlyBar:z,MenuBar:x,MainContainer:B,EditorWrapper:k},props:{fileId:{type:Number,default:null},content:{type:String,required:!0},readOnly:{type:Boolean},relativePath:{type:String,default:""},shareToken:{type:String,default:null},hideMenuBar:{type:Boolean},noLazyImages:{type:Boolean,default:!1}},emits:["ready","update:content"],setup(e){const{openLinkHandler:o}=P(),t=[b.configure({extensions:[I],openLink:o.openLink,noLazyImages:e.noLazyImages}),R],a=U(new L({extensions:t})),{setEditable:i,setContent:d}=w(a),{updateHeadings:l}=v(a);m(()=>e.content,n=>{d(n)}),i(!e.readOnly),m(()=>e.readOnly,n=>{i(!n)}),f(T,{isPublic:!1,isRichEditor:!0,isRichWorkspace:!1,hasTableOfContents:!0}),H(a);const{applyEditorWidth:p}=E(!0);p();const r=q(null);return f(S,r),{attachmentResolver:r,editor:a,setContent:d,updateHeadings:l}},created(){this.setContent(this.content,{addToHistory:!1}),this.updateHeadings(),this.editor.on("create",()=>{this.$emit("ready")}),this.editor.on("update",({editor:e})=>{const o=O(e.schema).serialize(e.state.doc);this.$emit("update:content",{json:e.state.doc,markdown:o})}),this.fileId&&(this.attachmentResolver=new W({currentDirectory:this.relativePath?.match(/.*\//),user:g(),shareToken:this.shareToken,fileId:this.fileId}))},beforeUnmount(){this.editor.destroy()}};function N(e,o,t,a,i,d){const l=s("MenuBar"),p=s("ReadonlyBar"),r=s("ContentContainer"),n=s("MainContainer"),C=s("EditorWrapper");return c(),h(C,{contentLoaded:""},{default:y(()=>[u(n,null,{default:y(()=>[t.hideMenuBar?F("",!0):(c(),$(j,{key:0},[t.readOnly?A(e.$slots,"readonlyBar",{},()=>[u(p)],void 0,1):(c(),h(l,{key:0,autohide:!1}))],64)),u(r,{readOnly:t.readOnly},null,8,["readOnly"])]),_:3})]),_:3})}const X=_(D,[["render",N]]);export{X as M};
0 commit comments