1 |
- import{a as h,s as f,v as m,a6 as s,au as g,bp as y,o as v,j as w,i as u,cz as S,bk as b,ax as O}from"./index.f9240906.js";import{a as j,w as k,V as x}from"./worker-json.433256b7.js";const C=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(g(a))try{e.value=JSON.stringify(JSON.parse(a),null,2)}catch(_){n("format-error",a),e.value=a}else y(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(x),{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(C);export{J as C};
|