index.d63cc30b.js 1.3 KB

1
  1. import{a as h,s as f,v as m,a7 as s,av as y,bp as g,o as v,j as w,i as u,cz as S,bk as b,ay as O}from"./index.7e08ba81.js";import{a as j,w as k,V as C}from"./worker-json.743ca174.js";const _=h({__name:"CodeEditor",props:{value:{type:[String,Object],default:""},readonly:{type:Boolean,default:!1},width:{type:String,default:"100%"},height:{type:String,default:"300px"},theme:{type:String,default:"chrome"}},emits:["update:value","format-error"],setup(d,{emit:p}){j.config.setModuleUrl("ace/mode/json_worker",k);const n=p;let e=f(""),r=d;const t=m({lang:"json",theme:"chrome",readOnly:!1,width:"100%",height:"300px",options:{enableBasicAutocompletion:!0,enableSnippets:!0,enableLiveAutocompletion:!0,tabSize:2,showPrintMargin:!1,fontSize:13,useWorker:"true"}});s(r,()=>{const{value:a,readonly:o,width:i,height:l}=r;if(y(a))try{e.value=JSON.stringify(JSON.parse(a),null,2)}catch(x){n("format-error",a),e.value=a}else g(a)&&(e.value=JSON.stringify(a,null,2));i&&(t.width=i),l&&(t.height=l),o&&(t.readOnly=o)}),s(e,()=>{n("update:value",e.value)});const c=()=>{};return(a,o)=>(v(),w(u(C),{value:u(e),"onUpdate:value":o[0]||(o[0]=i=>S(e)?e.value=i:e=i),onInit:c,lang:"json",theme:t.theme,options:t.options,readonly:t.readOnly,style:b({height:t.height,width:t.width}),class:"ace-editor"},null,8,["value","theme","options","readonly","style"]))}}),J=O(_);export{J as C};