import{Q as d,e as O}from"./QBtn.3608f330.js";import{k as y,X as P,a0 as Z,L as j,aC as B,aD as $,ah as K,v as g,ab as c,a9 as X}from"./QTable.be20b879.js";import{Q as Y,a as W}from"./QToolbarTitle.ea422eb4.js";import{x as ee,v as te,I as oe,y as ae,R as le,r as i,i as se,k as ie,w as N,a as re,z as m,J as D,C as e,B as l,Y as ne,Z as de,H as I,F as a,D as u,E as h,G as ce,V as ue}from"./index.0affd734.js";import he from"./CodeEditor.0ca8b89f.js";/**
 * @license lucide-vue-next v0.406.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const pe=y("Columns2Icon",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]);/**
 * @license lucide-vue-next v0.406.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ve=y("FileCodeIcon",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]);/**
 * @license lucide-vue-next v0.406.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const fe=y("FileTextIcon",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
 * @license lucide-vue-next v0.406.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ye=y("RedoIcon",[["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]]);/**
 * @license lucide-vue-next v0.406.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ke=y("UndoIcon",[["path",{d:"M3 7v6h6",key:"1v2h90"}],["path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13",key:"1r6uu6"}]]),be={key:0},ge=["height","src"],f=17,Te={__name:"MarkdownEditor",props:{height:{type:Number,required:!0},width:{type:Number,required:!0},recordID:String},setup(q){const z=ee(),S=te();oe(S);const{t:n}=ae();le();const p=i(50),k=i([20,80]),H=i(null),r=q,E=se("editorData");ie(()=>{L(),U(),Q()}),N(()=>r.height,t=>{L()}),N(()=>r.recordID,t=>{M.value=0,U(),Q()});const L=()=>{b.value=r.height-A.value,R.value=b.value-6,V.value="height:"+b.value+"px"},b=i(100),R=i(100),A=i(29),V=i("height: 400px;"),v=i(!1),Q=async()=>{var t=P(r.recordID);if(t==null)try{let o="/?action=parents&id="+r.recordID+"&format=JSON";const _=(await re.get(o)).data;t=_.items.length>0?_.items[0]:null,(Z(t.id)||j(t.id))&&(t=S.database.dbs.get(t.id)),v.value=!B(r.recordID,t)||$(r.recordID)}catch(o){console.log("Catch error"),console.log(o)}else v.value=!B(r.recordID,t)||$(r.recordID)},w=i("sidebyside"),C=t=>{w.value=t,t=="sidebyside"?(k.value=[20,80],p.value=50):t=="source"?(k.value=[99,100],p.value=99):(k.value=[0,0],p.value=0)},T=t=>{var o=z.iconColor;return t==w.value&&(o=z.defaultStyles.iconColorBlue),o},G=[{icon:"icon-icons8-bold",action:"bold",tooltip:"bold"},{icon:"icon-icons8-Italic",action:"italic",tooltip:"italic"},{icon:"icon-icons8-underline",action:"underline",tooltip:"underline"},{icon:"icon-icons8-strikethrough",action:"strike",tooltip:"strikethrough"},{icon:"icon-icons8-highlight",action:"highlight",tooltip:"highlight"}],x=t=>{H.value.onAction(t)},F=i(""),M=i(0),J=()=>{M.value++},U=()=>{F.value=K(r.recordID)};return(t,o)=>(m(),D("div",null,[e(W,{class:I(a(g)("toolbar-light editor-toolbar","toolbar-dark editor-toolbar"))},{default:l(()=>[w.value!="preview"?(m(),D("div",be,[(m(),D(ne,null,de(G,s=>e(d,{key:s.action,flat:"",dense:"",onClick:_=>x(s.action),disable:v.value},{default:l(()=>[e(O,{name:s.icon,size:"17px",class:I(a(g)("toolbar-icon-light","toolbar-icon-dark"))},null,8,["name","class"]),e(c,{class:"DTTooltip",delay:1e3},{default:l(()=>[u(h(a(n)(s.tooltip)),1)]),_:2},1024)]),_:2},1032,["onClick","disable"])),64)),e(d,{flat:"",dense:"",onClick:o[0]||(o[0]=s=>x("undo")),disable:v.value},{default:l(()=>[e(a(ke),{size:f,class:I(a(g)("toolbar-icon-light","toolbar-icon-dark"))},null,8,["class"]),e(c,{class:"DTTooltip",delay:1e3},{default:l(()=>[u(h(a(n)("undo")),1)]),_:1})]),_:1},8,["disable"]),e(d,{flat:"",dense:"",onClick:o[1]||(o[1]=s=>x("redo")),disable:v.value},{default:l(()=>[e(a(ye),{size:f,class:I(a(g)("toolbar-icon-light","toolbar-icon-dark"))},null,8,["class"]),e(c,{class:"DTTooltip",delay:1e3},{default:l(()=>[u(h(a(n)("redo")),1)]),_:1})]),_:1},8,["disable"])])):ce("",!0),e(Y),e(d,{flat:"",dense:"",onClick:o[2]||(o[2]=s=>C("preview"))},{default:l(()=>[e(a(fe),{size:f,"stroke-width":"1.5",color:T("preview")},null,8,["color"]),e(c,{class:"DTTooltip",delay:1e3},{default:l(()=>[u(h(a(n)("preview")),1)]),_:1})]),_:1}),e(d,{flat:"",dense:"",onClick:o[3]||(o[3]=s=>C("source"))},{default:l(()=>[e(a(ve),{size:f,"stroke-width":"1.5",color:T("source")},null,8,["color"]),e(c,{class:"DTTooltip",delay:1e3},{default:l(()=>[u(h(a(n)("source")),1)]),_:1})]),_:1}),e(d,{flat:"",dense:"",onClick:o[4]||(o[4]=s=>C("sidebyside"))},{default:l(()=>[e(a(pe),{size:f,"stroke-width":"1.5",color:T("sidebyside")},null,8,["color"]),e(c,{class:"DTTooltip",delay:1e3},{default:l(()=>[u(h(a(n)("sidebyside")),1)]),_:1})]),_:1})]),_:1},8,["class"]),e(X,{modelValue:p.value,"onUpdate:modelValue":o[5]||(o[5]=s=>p.value=s),limits:k.value,style:ue(V.value)},{before:l(()=>[e(he,{ref_key:"actualEditor",ref:H,width:"100%",height:b.value,recordID:a(E).recordID,onTextUpdated:J},null,8,["height","recordID"])]),after:l(()=>[(m(),D("iframe",{class:"DTFrame",width:"100%",height:R.value,src:F.value,frameborder:"0",key:M.value},null,8,ge))]),_:1},8,["modelValue","limits","style"])]))}};export{Te as default};
