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-_sNkeykm.js";import{d as n}from"./index-CY1ySRal.js";import{E as m}from"./emojo-Ben6gd8J.js";import{E as v}from"./vendor-element-DupX9wXy.js";import{q as f,bR as c,bS as p,V as y,c as b,R as g,a1 as x,t as F,v as h,M as O,u as w,a0 as K}from"./vendor-core-Di0OO4oJ.js";const N={class:"editor-wrapper"},j=f((S=u({},{name:"ArtWangEditor"}),l(S,r({__name:"index",props:c({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=p(e,"modelValue"),o=y(),t=n(),i={maxFileSize:3145728,maxNumberOfFiles:10,fieldName:"file",allowedFileTypes:["image/*"]},f={maxFileSize:52428800,maxNumberOfFiles:1,fieldName:"file",allowedFileTypes:["video/*"]},c=b(()=>{var e;return(null==(e=r.uploadConfig)?void 0:e.server)||"/api/upload/image"}),j=b(()=>"/api/upload/video"),S=b(()=>{const e=t.accessToken;return e?{Authorization:e.startsWith("Bearer ")?e:`Bearer ${e}`}:{}}),T=b(()=>u(u({},i),r.uploadConfig)),E=b(()=>u({},f)),C=b(()=>{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:T.value.fieldName,maxFileSize:T.value.maxFileSize,maxNumberOfFiles:T.value.maxNumberOfFiles,allowedFileTypes:T.value.allowedFileTypes,server:c.value,headers:S.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 v.success(`图片上传成功 ${m[200]}`);v.error((null==e?void 0:e.msg)||`图片上传失败 ${m[500]}`)},onError(e,l,r){v.error(`图片上传失败 ${m[500]}`)}},uploadVideo:{fieldName:E.value.fieldName,maxFileSize:E.value.maxFileSize,maxNumberOfFiles:E.value.maxNumberOfFiles,allowedFileTypes:E.value.allowedFileTypes,server:j.value,headers:S.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 v.success(`视频上传成功 ${m[200]}`);v.error((null==e?void 0:e.msg)||`视频上传失败 ${m[500]}`)},onError(e,l,r){v.error(`视频上传失败 ${m[500]}`)}}}},z=e=>{o.value=e,e.on("fullScreen",()=>{}),$()},$=()=>{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()}}),g(()=>{}),x(()=>{const e=o.value;e&&e.destroy()}),(l,r)=>(h(),F("div",N,[O(w(s),{class:"editor-toolbar",editor:o.value,mode:e.mode,defaultConfig:C.value},null,8,["editor","mode","defaultConfig"]),O(w(d),{style:K({height:e.height,overflowY:"hidden"}),modelValue:a.value,"onUpdate:modelValue":r[0]||(r[0]=e=>a.value=e),mode:e.mode,defaultConfig:V,onOnCreated:z},null,8,["style","modelValue","mode"])]))}}))));var S;export{j as default};
