import{Toolbar as e,Editor as t}from"@wangeditor/editor-for-react";import{forwardRef as o,useState as r,useEffect as l,useImperativeHandle as d}from"react";import{normalizeEmptyHtml as i}from"../../utils/index.js";import"@wangeditor/editor/dist/css/style.css";import{jsx as s,Fragment as a,jsxs as n}from"react/jsx-runtime";const m=o(({value:o,onChange:m,disabled:c},g)=>{const[u,f]=r(null),[p,x]=r("");return l(()=>{x(o)},[o]),l(()=>{u&&(c?u.disable():u.enable())},[c]),l(()=>()=>{u&&(u.destroy(),f(null))},[u]),d(g,()=>({getEditorInstance:()=>u,getHtml:()=>u&&u.getHtml(),setHtml:e=>{u&&u.setHtml(e)},getText:()=>u&&u.getText()})),s(a,{children:n("div",{style:{border:"1px solid #ccc"},children:[s(e,{editor:u,defaultConfig:{excludeKeys:["group-image","group-video","insertLink","emotion","todo","fullScreen","insertTable","codeBlock"]},mode:"default",style:{borderBottom:"1px solid #ccc"}}),s(t,{defaultConfig:{placeholder:"请输入内容..."},value:p,onCreated:e=>{f(e),c&&e.disable()},onChange:e=>{x(e.getHtml()),m?.(i(e.getHtml()))},mode:"default",style:{height:"500px",overflowY:"hidden"}})]})})});m.displayName="Editor";export{m as default};
