var e=Object.defineProperty,l=Object.defineProperties,r=Object.getOwnPropertyDescriptors,a=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,t=Object.prototype.propertyIsEnumerable,i=(l,r,a)=>r in l?e(l,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):l[r]=a,u=(e,l)=>{for(var r in l||(l={}))o.call(l,r)&&i(e,r,l[r]);if(a)for(var r of a(l))t.call(l,r)&&i(e,r,l[r]);return e};import{T as s,E as d}from"./vendor-wangeditor-DG1Uov8Q.js";import{a as n}from"./index-DYPGJs8A.js";import{E as m}from"./vendor-element-C6D3GHVC.js";import{t as v,bW as f,bX as c,W as p,c as y,S as b,a2 as g,v as x,x as F,O as h,u as O,a1 as w}from"./vendor-core-B-NFAs71.js";const K="^_^",N="X_X",S={class:"editor-wrapper"},T=v((j=u({},{name:"ArtWangEditor"}),l(j,r({__name:"index",props:f({height:{default:"500px"},toolbarKeys:{},insertKeys:{},excludeKeys:{default:()=>["fontFamily"]},mode:{default:"default"},placeholder:{default:"请输入内容..."},uploadConfig:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(e,{expose:l}){const r=e,a=c(e,"modelValue"),o=p(),t=n(),i={maxFileSize:3145728,maxNumberOfFiles:10,fieldName:"file",allowedFileTypes:["image/*"]},v={maxFileSize:52428800,maxNumberOfFiles:1,fieldName:"file",allowedFileTypes:["video/*"]},f=y(()=>{var e;return(null==(e=r.uploadConfig)?void 0:e.server)||"/api/upload/image"}),T=y(()=>"/api/upload/video"),j=y(()=>{const e=t.accessToken;return e?{Authorization:e.startsWith("Bearer ")?e:`Bearer ${e}`}:{}}),C=y(()=>u(u({},i),r.uploadConfig)),E=y(()=>u({},v)),z=y(()=>{const e={};return r.toolbarKeys&&r.toolbarKeys.length>0&&(e.toolbarKeys=r.toolbarKeys),r.insertKeys&&(e.insertKeys=r.insertKeys),r.excludeKeys&&r.excludeKeys.length>0&&(e.excludeKeys=r.excludeKeys),e}),V={placeholder:r.placeholder,MENU_CONF:{uploadImage:{fieldName:C.value.fieldName,maxFileSize:C.value.maxFileSize,maxNumberOfFiles:C.value.maxNumberOfFiles,allowedFileTypes:C.value.allowedFileTypes,server:f.value,headers:j.value,customInsert(e,l){var r;if(200===(null==e?void 0:e.code)&&(null==(r=null==e?void 0:e.data)?void 0:r.url))return l(e.data.url),void m.success(`图片上传成功 ${K}`);m.error((null==e?void 0:e.msg)||`图片上传失败 ${N}`)},onError(e,l,r){m.error(`图片上传失败 ${N}`)}},uploadVideo:{fieldName:E.value.fieldName,maxFileSize:E.value.maxFileSize,maxNumberOfFiles:E.value.maxNumberOfFiles,allowedFileTypes:E.value.allowedFileTypes,server:T.value,headers:j.value,customInsert(e,l){var r;if(200===(null==e?void 0:e.code)&&(null==(r=null==e?void 0:e.data)?void 0:r.url))return l(e.data.url),void m.success(`视频上传成功 ${K}`);m.error((null==e?void 0:e.msg)||`视频上传失败 ${N}`)},onError(e,l,r){m.error(`视频上传失败 ${N}`)}}}},$=e=>{o.value=e,e.on("fullScreen",()=>{}),P()},P=()=>{let e=0;const l=()=>{const r=o.value;if(!r)return void(e<10&&(e++,setTimeout(l,100)));const a=r.getEditableContainer().closest(".editor-wrapper");if(!a)return void(e<10&&(e++,setTimeout(l,100)));const t=a.querySelector(".w-e-toolbar"),i=a.querySelectorAll(".w-e-bar-item button[data-menu-key]");t&&i.length>0||e<10&&(e++,setTimeout(l,100))};requestAnimationFrame(l)};return l({getEditor:()=>o.value,setHtml:e=>{var l;return null==(l=o.value)?void 0:l.setHtml(e)},getHtml:()=>{var e;return null==(e=o.value)?void 0:e.getHtml()},clear:()=>{var e;return null==(e=o.value)?void 0:e.clear()},focus:()=>{var e;return null==(e=o.value)?void 0:e.focus()}}),b(()=>{}),g(()=>{const e=o.value;e&&e.destroy()}),(l,r)=>(F(),x("div",S,[h(O(s),{class:"editor-toolbar",editor:o.value,mode:e.mode,defaultConfig:z.value},null,8,["editor","mode","defaultConfig"]),h(O(d),{style:w({height:e.height,overflowY:"hidden"}),modelValue:a.value,"onUpdate:modelValue":r[0]||(r[0]=e=>a.value=e),mode:e.mode,defaultConfig:V,onOnCreated:$},null,8,["style","modelValue","mode"])]))}}))));var j;export{T as default};
