import { _ as _slicedToArray } from '../_verture/slicedToArray-76060636.js';
import { jsx, jsxs } from 'react/jsx-runtime';
import { forwardRef, useState, useEffect, useImperativeHandle, useMemo } from 'react';
import Label from '../Label/index.js';
import { Toolbar, Editor } from '@wangeditor/editor-for-react';
import { i18nChangeLanguage } from '@wangeditor/editor';
import HelperText from '../HelperText/index.js';
import { $ as $prefixCls } from '../_verture/constant-66aa48a1.js';
import { u as useFormatMessage } from '../_verture/useFormatMessage-703f8b20.js';
import { UUID } from '@iam-com/lib';
import { s as styleInject } from '../_verture/style-inject.es-300983ab.js';
import '../_verture/unsupportedIterableToArray-cb478f24.js';
import '../_verture/tslib.es6-55ed4bd2.js';
import '../Help/index.js';
import '../Tooltip/index.js';
import 'rc-tooltip';
import 'rc-tooltip/lib/placements';
import 'clsx';
import '@iam-com/icons/Help';
import '@para-ui/core/GlobalContext';

/**
 * @author xh
 * @date 2022/09/06 18:00
 * @description  存放富文本编辑器的一些默认配置
 */
var TOOL_BAR_CONFIG = ["headerSelect", "blockquote", "|", "bold", "underline", "italic", {
  key: "group-more-style",
  title: "更多",
  iconSvg: '<svg viewBox="0 0 1024 1024"><path d="M204.8 505.6m-76.8 0a76.8 76.8 0 1 0 153.6 0 76.8 76.8 0 1 0-153.6 0Z"></path><path d="M505.6 505.6m-76.8 0a76.8 76.8 0 1 0 153.6 0 76.8 76.8 0 1 0-153.6 0Z"></path><path d="M806.4 505.6m-76.8 0a76.8 76.8 0 1 0 153.6 0 76.8 76.8 0 1 0-153.6 0Z"></path></svg>',
  menuKeys: ["through", "code", "sup", "sub", "clearStyle"]
}, "color", "bgColor", "|", "fontSize", "fontFamily", "lineHeight", "|", "bulletedList", "numberedList", "todo", {
  key: "group-justify",
  title: "对齐",
  iconSvg: '<svg viewBox="0 0 1024 1024"><path d="M768 793.6v102.4H51.2v-102.4h716.8z m204.8-230.4v102.4H51.2v-102.4h921.6z m-204.8-230.4v102.4H51.2v-102.4h716.8zM972.8 102.4v102.4H51.2V102.4h921.6z"></path></svg>',
  menuKeys: ["justifyLeft", "justifyRight", "justifyCenter", "justifyJustify"]
}, {
  key: "group-indent",
  title: "缩进",
  iconSvg: '<svg viewBox="0 0 1024 1024"><path d="M0 64h1024v128H0z m384 192h640v128H384z m0 192h640v128H384z m0 192h640v128H384zM0 832h1024v128H0z m0-128V320l256 192z"></path></svg>',
  menuKeys: ["indent", "delIndent"]
}, "|", "emotion", "insertLink", {
  key: "group-image",
  title: "图片",
  iconSvg: '<svg viewBox="0 0 1024 1024"><path d="M959.877 128l0.123 0.123v767.775l-0.123 0.122H64.102l-0.122-0.122V128.123l0.122-0.123h895.775zM960 64H64C28.795 64 0 92.795 0 128v768c0 35.205 28.795 64 64 64h896c35.205 0 64-28.795 64-64V128c0-35.205-28.795-64-64-64zM832 288.01c0 53.023-42.988 96.01-96.01 96.01s-96.01-42.987-96.01-96.01S682.967 192 735.99 192 832 234.988 832 288.01zM896 832H128V704l224.01-384 256 320h64l224.01-192z"></path></svg>',
  menuKeys: ["insertImage", "uploadImage"]
}, {
  key: "group-video",
  title: "视频",
  iconSvg: '<svg viewBox="0 0 1024 1024"><path d="M981.184 160.096C837.568 139.456 678.848 128 512 128S186.432 139.456 42.816 160.096C15.296 267.808 0 386.848 0 512s15.264 244.16 42.816 351.904C186.464 884.544 345.152 896 512 896s325.568-11.456 469.184-32.096C1008.704 756.192 1024 637.152 1024 512s-15.264-244.16-42.816-351.904zM384 704V320l320 192-320 192z"></path></svg>',
  menuKeys: ["insertVideo", "uploadVideo"]
}, "insertTable", "codeBlock", "divider", "|", "undo", "redo", "|", "fullScreen"];

var en = {
  please: 'Please Enter Contet'
};

var zh = {
  please: '请输入内容'
};

var localeJson = {
  zh: zh,
  en: en
};

var css_248z$1 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/10/20 下午2:08\n* @description color\n*/\n.paraui-v3-text-editor .w-e-full-screen-container {\n  z-index: 1000;\n}\n.paraui-v3-text-editor .text-editor-content {\n  border: 1px solid rgba(171, 176, 185, 0.4);\n  border-radius: 4px;\n  padding: 1px 0;\n  background-color: #fff;\n}\n.paraui-v3-text-editor .text-editor-content > div:nth-child(1) {\n  border-bottom: 1px solid rgba(171, 176, 185, 0.4);\n}\n.paraui-v3-text-editor .text-editor-content div[contenteditable=false] {\n  background-color: rgba(171, 176, 185, 0.12);\n}\n.paraui-v3-text-editor .text-editor-content div[contenteditable=false]:hover {\n  border-color: rgba(171, 176, 185, 0.4);\n  cursor: not-allowed;\n}\n.paraui-v3-text-editor .preview-mode > div:nth-child(1) {\n  border-bottom: none;\n}";
styleInject(css_248z$1);

var css_248z = ":root,\n:host {\n  --w-e-textarea-bg-color: #fff;\n  --w-e-textarea-color: #333;\n  --w-e-textarea-border-color: #ccc;\n  --w-e-textarea-slight-border-color: #e8e8e8;\n  --w-e-textarea-slight-color: #d4d4d4;\n  --w-e-textarea-slight-bg-color: #f5f2f0;\n  --w-e-textarea-selected-border-color: #B4D5FF;\n  --w-e-textarea-handler-bg-color: #4290f7;\n  --w-e-toolbar-color: #595959;\n  --w-e-toolbar-bg-color: #fff;\n  --w-e-toolbar-active-color: #333;\n  --w-e-toolbar-active-bg-color: #f1f1f1;\n  --w-e-toolbar-disabled-color: #999;\n  --w-e-toolbar-border-color: #e8e8e8;\n  --w-e-modal-button-bg-color: #fafafa;\n  --w-e-modal-button-border-color: #d9d9d9;\n}\n\n.w-e-text-container *,.w-e-toolbar *{box-sizing:border-box;margin:0;outline:none;padding:0}.w-e-text-container blockquote,.w-e-text-container li,.w-e-text-container p,.w-e-text-container td,.w-e-text-container th,.w-e-toolbar *{line-height:1.5}.w-e-text-container{background-color:var(--w-e-textarea-bg-color);color:var(--w-e-textarea-color);height:100%;position:relative}.w-e-text-container .w-e-scroll{-webkit-overflow-scrolling:touch;height:100%}.w-e-text-container [data-slate-editor]{word-wrap:break-word;border-top:1px solid transparent;min-height:100%;outline:0;padding:0 10px;white-space:pre-wrap}.w-e-text-container [data-slate-editor] p{margin:15px 0}.w-e-text-container [data-slate-editor] h1,.w-e-text-container [data-slate-editor] h2,.w-e-text-container [data-slate-editor] h3,.w-e-text-container [data-slate-editor] h4,.w-e-text-container [data-slate-editor] h5{margin:20px 0}.w-e-text-container [data-slate-editor] img{cursor:default;display:inline!important;max-width:100%;min-height:20px;min-width:20px}.w-e-text-container [data-slate-editor] span{text-indent:0}.w-e-text-container [data-slate-editor] [data-selected=true]{box-shadow:0 0 0 2px var(--w-e-textarea-selected-border-color)}.w-e-text-placeholder{font-style:italic;left:10px;top:17px;width:90%}.w-e-max-length-info,.w-e-text-placeholder{color:var(--w-e-textarea-slight-color);pointer-events:none;position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none}.w-e-max-length-info{bottom:.5em;right:1em}.w-e-bar{background-color:var(--w-e-toolbar-bg-color);color:var(--w-e-toolbar-color);font-size:14px;padding:0 5px}.w-e-bar svg{fill:var(--w-e-toolbar-color);height:14px;width:14px}.w-e-bar-show{display:flex}.w-e-bar-hidden{display:none}.w-e-hover-bar{border:1px solid var(--w-e-toolbar-border-color);border-radius:3px;box-shadow:0 2px 5px #0000001f;position:absolute}.w-e-toolbar{flex-wrap:wrap;position:relative}.w-e-bar-divider{background-color:var(--w-e-toolbar-border-color);display:inline-flex;height:40px;margin:0 5px;width:1px}.w-e-bar-item{display:flex;height:40px;padding:4px;position:relative;text-align:center}.w-e-bar-item,.w-e-bar-item button{align-items:center;justify-content:center}.w-e-bar-item button{background:transparent;border:none;color:var(--w-e-toolbar-color);cursor:pointer;display:inline-flex;height:32px;overflow:hidden;padding:0 8px;white-space:nowrap}.w-e-bar-item button:hover{background-color:var(--w-e-toolbar-active-bg-color);color:var(--w-e-toolbar-active-color)}.w-e-bar-item button .title{margin-left:5px}.w-e-bar-item .active{background-color:var(--w-e-toolbar-active-bg-color);color:var(--w-e-toolbar-active-color)}.w-e-bar-item .disabled{color:var(--w-e-toolbar-disabled-color);cursor:not-allowed}.w-e-bar-item .disabled svg{fill:var(--w-e-toolbar-disabled-color)}.w-e-bar-item .disabled:hover{background-color:var(--w-e-toolbar-bg-color);color:var(--w-e-toolbar-disabled-color)}.w-e-bar-item .disabled:hover svg{fill:var(--w-e-toolbar-disabled-color)}.w-e-menu-tooltip-v5:before{background-color:var(--w-e-toolbar-active-color);border-radius:5px;color:var(--w-e-toolbar-bg-color);content:attr(data-tooltip);font-size:.75em;opacity:0;padding:5px 10px;position:absolute;text-align:center;top:40px;transition:opacity .6s;visibility:hidden;white-space:pre;z-index:1}.w-e-menu-tooltip-v5:after{border:5px solid transparent;border-bottom:5px solid var(--w-e-toolbar-active-color);content:\"\";opacity:0;position:absolute;top:30px;transition:opacity .6s;visibility:hidden}.w-e-menu-tooltip-v5:hover:after,.w-e-menu-tooltip-v5:hover:before{opacity:1;visibility:visible}.w-e-menu-tooltip-v5.tooltip-right:before{left:100%;top:10px}.w-e-menu-tooltip-v5.tooltip-right:after{border-bottom-color:transparent;border-left-color:transparent;border-right-color:var(--w-e-toolbar-active-color);border-top-color:transparent;left:100%;margin-left:-10px;top:16px}.w-e-bar-item-group .w-e-bar-item-menus-container{background-color:var(--w-e-toolbar-bg-color);border:1px solid var(--w-e-toolbar-border-color);border-radius:3px;box-shadow:0 2px 10px #0000001f;display:none;left:0;margin-top:40px;position:absolute;top:0;z-index:1}.w-e-bar-item-group:hover .w-e-bar-item-menus-container{display:block}.w-e-select-list{background-color:var(--w-e-toolbar-bg-color);border:1px solid var(--w-e-toolbar-border-color);border-radius:3px;box-shadow:0 2px 10px #0000001f;left:0;margin-top:40px;max-height:350px;min-width:100px;overflow-y:auto;position:absolute;top:0;z-index:1}.w-e-select-list ul{line-height:1;list-style:none}.w-e-select-list ul .selected{background-color:var(--w-e-toolbar-active-bg-color)}.w-e-select-list ul li{cursor:pointer;padding:7px 0 7px 25px;position:relative;text-align:left;white-space:nowrap}.w-e-select-list ul li:hover{background-color:var(--w-e-toolbar-active-bg-color)}.w-e-select-list ul li svg{left:0;margin-left:5px;margin-top:-7px;position:absolute;top:50%}.w-e-bar-bottom .w-e-select-list{bottom:0;margin-bottom:40px;margin-top:0;top:inherit}.w-e-drop-panel{background-color:var(--w-e-toolbar-bg-color);border:1px solid var(--w-e-toolbar-border-color);border-radius:3px;box-shadow:0 2px 10px #0000001f;margin-top:40px;min-width:200px;padding:10px;position:absolute;top:0;z-index:1}.w-e-bar-bottom .w-e-drop-panel{bottom:0;margin-bottom:40px;margin-top:0;top:inherit}.w-e-modal{background-color:var(--w-e-toolbar-bg-color);border:1px solid var(--w-e-toolbar-border-color);border-radius:3px;box-shadow:0 2px 10px #0000001f;color:var(--w-e-toolbar-color);font-size:14px;min-height:40px;min-width:100px;padding:20px 15px 0;position:absolute;text-align:left;z-index:1}.w-e-modal .btn-close{cursor:pointer;line-height:1;padding:5px;position:absolute;right:8px;top:7px}.w-e-modal .btn-close svg{fill:var(--w-e-toolbar-color);height:10px;width:10px}.w-e-modal .babel-container{display:block;margin-bottom:15px}.w-e-modal .babel-container span{display:block;margin-bottom:10px}.w-e-modal .button-container{margin-bottom:15px}.w-e-modal button{background-color:var(--w-e-modal-button-bg-color);border:1px solid var(--w-e-modal-button-border-color);border-radius:4px;color:var(--w-e-toolbar-color);cursor:pointer;font-weight:400;height:32px;padding:4.5px 15px;text-align:center;touch-action:manipulation;transition:all .3s cubic-bezier(.645,.045,.355,1);-webkit-user-select:none;-moz-user-select:none;user-select:none;white-space:nowrap}.w-e-modal input[type=number],.w-e-modal input[type=text],.w-e-modal textarea{font-feature-settings:\"tnum\";background-color:var(--w-e-toolbar-bg-color);border:1px solid var(--w-e-modal-button-border-color);border-radius:4px;color:var(--w-e-toolbar-color);font-variant:tabular-nums;padding:4.5px 11px;transition:all .3s;width:100%}.w-e-modal textarea{min-height:60px}body .w-e-modal,body .w-e-modal *{box-sizing:border-box}.w-e-progress-bar{background-color:var(--w-e-textarea-handler-bg-color);height:1px;position:absolute;transition:width .3s;width:0}.w-e-full-screen-container{bottom:0!important;display:flex!important;flex-direction:column!important;height:100%!important;left:0!important;margin:0!important;padding:0!important;position:fixed;right:0!important;top:0!important;width:100%!important}.w-e-full-screen-container [data-w-e-textarea=true]{flex:1!important}\n.w-e-text-container [data-slate-editor] code{background-color:var(--w-e-textarea-slight-bg-color);border-radius:3px;font-family:monospace;padding:3px}.w-e-panel-content-color{list-style:none;text-align:left;width:230px}.w-e-panel-content-color li{border:1px solid var(--w-e-toolbar-bg-color);border-radius:3px 3px;cursor:pointer;display:inline-block;padding:2px}.w-e-panel-content-color li:hover{border-color:var(--w-e-toolbar-color)}.w-e-panel-content-color li .color-block{border:1px solid var(--w-e-toolbar-border-color);border-radius:3px 3px;height:17px;width:17px}.w-e-panel-content-color .active{border-color:var(--w-e-toolbar-color)}.w-e-panel-content-color .clear{line-height:1.5;margin-bottom:5px;width:100%}.w-e-panel-content-color .clear svg{height:16px;margin-bottom:-4px;width:16px}.w-e-text-container [data-slate-editor] blockquote{background-color:var(--w-e-textarea-slight-bg-color);border-left:8px solid var(--w-e-textarea-selected-border-color);display:block;font-size:100%;line-height:1.5;margin:10px 0;padding:10px}.w-e-panel-content-emotion{font-size:20px;list-style:none;text-align:left;width:300px}.w-e-panel-content-emotion li{border-radius:3px 3px;cursor:pointer;display:inline-block;padding:0 5px}.w-e-panel-content-emotion li:hover{background-color:var(--w-e-textarea-slight-bg-color)}.w-e-textarea-divider{border-radius:3px;margin:20px auto;padding:20px}.w-e-textarea-divider hr{background-color:var(--w-e-textarea-border-color);border:0;display:block;height:1px}.w-e-text-container [data-slate-editor] pre>code{background-color:var(--w-e-textarea-slight-bg-color);border:1px solid var(--w-e-textarea-slight-border-color);border-radius:4px 4px;display:block;font-size:14px;padding:10px;text-indent:0}.w-e-text-container [data-slate-editor] .w-e-image-container{display:inline-block;margin:0 3px}.w-e-text-container [data-slate-editor] .w-e-image-container:hover{box-shadow:0 0 0 2px var(--w-e-textarea-selected-border-color)}.w-e-text-container [data-slate-editor] .w-e-selected-image-container{overflow:hidden;position:relative}.w-e-text-container [data-slate-editor] .w-e-selected-image-container .w-e-image-dragger{background-color:var(--w-e-textarea-handler-bg-color);height:7px;position:absolute;width:7px}.w-e-text-container [data-slate-editor] .w-e-selected-image-container .left-top{cursor:nwse-resize;left:0;top:0}.w-e-text-container [data-slate-editor] .w-e-selected-image-container .right-top{cursor:nesw-resize;right:0;top:0}.w-e-text-container [data-slate-editor] .w-e-selected-image-container .left-bottom{bottom:0;cursor:nesw-resize;left:0}.w-e-text-container [data-slate-editor] .w-e-selected-image-container .right-bottom{bottom:0;cursor:nwse-resize;right:0}.w-e-text-container [data-slate-editor] .w-e-selected-image-container:hover{box-shadow:none}.w-e-text-container [contenteditable=false] .w-e-image-container:hover{box-shadow:none}\n\n.w-e-text-container [data-slate-editor] .table-container{border:1px dashed var(--w-e-textarea-border-color);border-radius:5px;margin-top:10px;overflow-x:auto;padding:10px;width:100%}.w-e-text-container [data-slate-editor] table{border-collapse:collapse}.w-e-text-container [data-slate-editor] table td,.w-e-text-container [data-slate-editor] table th{border:1px solid var(--w-e-textarea-border-color);line-height:1.5;min-width:30px;padding:3px 5px;text-align:left}.w-e-text-container [data-slate-editor] table th{background-color:var(--w-e-textarea-slight-bg-color);font-weight:700;text-align:center}.w-e-panel-content-table{background-color:var(--w-e-toolbar-bg-color)}.w-e-panel-content-table table{border-collapse:collapse}.w-e-panel-content-table td{border:1px solid var(--w-e-toolbar-border-color);cursor:pointer;height:15px;padding:3px 5px;width:20px}.w-e-panel-content-table td.active{background-color:var(--w-e-toolbar-active-bg-color)}\n.w-e-textarea-video-container{background-image:linear-gradient(45deg,#eee 25%,transparent 0,transparent 75%,#eee 0,#eee),linear-gradient(45deg,#eee 25%,#fff 0,#fff 75%,#eee 0,#eee);background-position:0 0,10px 10px;background-size:20px 20px;border:1px dashed var(--w-e-textarea-border-color);border-radius:5px;margin:10px auto 0;padding:10px 0;text-align:center}\n\n.w-e-text-container [data-slate-editor] pre>code{word-wrap:normal;font-family:Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace;-webkit-hyphens:none;hyphens:none;line-height:1.5;margin:.5em 0;overflow:auto;padding:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;text-align:left;text-shadow:0 1px #fff;white-space:pre;word-break:normal;word-spacing:normal}.w-e-text-container [data-slate-editor] pre>code .token.cdata,.w-e-text-container [data-slate-editor] pre>code .token.comment,.w-e-text-container [data-slate-editor] pre>code .token.doctype,.w-e-text-container [data-slate-editor] pre>code .token.prolog{color:#708090}.w-e-text-container [data-slate-editor] pre>code .token.punctuation{color:#999}.w-e-text-container [data-slate-editor] pre>code .token.namespace{opacity:.7}.w-e-text-container [data-slate-editor] pre>code .token.boolean,.w-e-text-container [data-slate-editor] pre>code .token.constant,.w-e-text-container [data-slate-editor] pre>code .token.deleted,.w-e-text-container [data-slate-editor] pre>code .token.number,.w-e-text-container [data-slate-editor] pre>code .token.property,.w-e-text-container [data-slate-editor] pre>code .token.symbol,.w-e-text-container [data-slate-editor] pre>code .token.tag{color:#905}.w-e-text-container [data-slate-editor] pre>code .token.attr-name,.w-e-text-container [data-slate-editor] pre>code .token.builtin,.w-e-text-container [data-slate-editor] pre>code .token.char,.w-e-text-container [data-slate-editor] pre>code .token.inserted,.w-e-text-container [data-slate-editor] pre>code .token.selector,.w-e-text-container [data-slate-editor] pre>code .token.string{color:#690}.w-e-text-container [data-slate-editor] pre>code .language-css .token.string,.w-e-text-container [data-slate-editor] pre>code .style .token.string,.w-e-text-container [data-slate-editor] pre>code .token.entity,.w-e-text-container [data-slate-editor] pre>code .token.operator,.w-e-text-container [data-slate-editor] pre>code .token.url{color:#9a6e3a}.w-e-text-container [data-slate-editor] pre>code .token.atrule,.w-e-text-container [data-slate-editor] pre>code .token.attr-value,.w-e-text-container [data-slate-editor] pre>code .token.keyword{color:#07a}.w-e-text-container [data-slate-editor] pre>code .token.class-name,.w-e-text-container [data-slate-editor] pre>code .token.function{color:#dd4a68}.w-e-text-container [data-slate-editor] pre>code .token.important,.w-e-text-container [data-slate-editor] pre>code .token.regex,.w-e-text-container [data-slate-editor] pre>code .token.variable{color:#e90}.w-e-text-container [data-slate-editor] pre>code .token.bold,.w-e-text-container [data-slate-editor] pre>code .token.important{font-weight:700}.w-e-text-container [data-slate-editor] pre>code .token.italic{font-style:italic}.w-e-text-container [data-slate-editor] pre>code .token.entity{cursor:help}";
styleInject(css_248z);

var TextEditor = /*#__PURE__*/forwardRef(function (props, ref) {
  var intl = useFormatMessage('TextEditor', localeJson);
  var style = props.style,
    _props$toolbarStyle = props.toolbarStyle,
    toolbarStyle = _props$toolbarStyle === void 0 ? {} : _props$toolbarStyle,
    _props$editorStyle = props.editorStyle,
    editorStyle = _props$editorStyle === void 0 ? {
      height: '300px',
      overflowY: 'hidden'
    } : _props$editorStyle,
    hideErrorDom = props.hideErrorDom,
    className = props.className,
    error = props.error,
    server = props.server,
    helperText = props.helperText,
    required = props.required,
    labelSign = props.labelSign,
    label = props.label,
    labelTooltip = props.labelTooltip,
    _props$placeholder = props.placeholder,
    placeholder = _props$placeholder === void 0 ? intl({
      id: 'please'
    }) : _props$placeholder,
    onChange = props.onChange,
    onFocus = props.onFocus,
    onBlur = props.onBlur,
    onDestroyed = props.onDestroyed,
    _props$readOnly = props.readOnly,
    readOnly = _props$readOnly === void 0 ? false : _props$readOnly,
    _props$autoFocus = props.autoFocus,
    autoFocus = _props$autoFocus === void 0 ? false : _props$autoFocus,
    max = props.max,
    in18 = props.in18,
    defaultValue = props.defaultValue,
    value = props.value,
    excludeKeys = props.excludeKeys,
    insertKeys = props.insertKeys,
    _props$menuConfig = props.menuConfig,
    menuConfig = _props$menuConfig === void 0 ? {} : _props$menuConfig,
    _props$toolbarKeys = props.toolbarKeys,
    toolbarKeys = _props$toolbarKeys === void 0 ? TOOL_BAR_CONFIG : _props$toolbarKeys,
    _props$uploadImage = props.uploadImage,
    uploadImage = _props$uploadImage === void 0 ? {
      base64LimitSize: 5 * 1024 * 1024,
      timeout: 15 * 1000
    } : _props$uploadImage,
    _props$uploadVideo = props.uploadVideo,
    uploadVideo = _props$uploadVideo === void 0 ? {
      timeout: 15 * 1000
    } : _props$uploadVideo;
  // editor 实例
  var _useState = useState(null),
    _useState2 = _slicedToArray(_useState, 2),
    editor = _useState2[0],
    setEditor = _useState2[1];
  // 编辑器内容
  var _useState3 = useState(''),
    _useState4 = _slicedToArray(_useState3, 2),
    valueCom = _useState4[0],
    setValueCom = _useState4[1]; // 组件值
  // 强制更新ToolBar变量
  var _useState5 = useState(UUID),
    _useState6 = _slicedToArray(_useState5, 2),
    toolBarKey = _useState6[0],
    setToolBarKey = _useState6[1];
  // 是否是预览模式
  var _useState7 = useState(false),
    _useState8 = _slicedToArray(_useState7, 2),
    isPreview = _useState8[0],
    setIsPreview = _useState8[1];
  useEffect(function () {
    setIsPreview(toolbarKeys.length < 1);
  }, [toolbarKeys]);
  /** 聚焦 */
  var onFocusCom = function onFocusCom(editor) {
    onFocus && onFocus(editor);
  };
  /** 失去焦点 */
  var onBlurCom = function onBlurCom(editor) {
    onBlur && onBlur(editor);
  };
  /** 销毁钩子 */
  var onDestroyedCom = function onDestroyedCom(editor) {
    onDestroyed && onDestroyed(editor);
  };
  /** 改变事件 */
  var onChangeCom = function onChangeCom(editor) {
    if (props.value === undefined) setValueCom(editor.getHtml());
    onChange && onChange(editor.getHtml(), editor.getText());
  };
  // 工具栏配置
  var toolbarConfig = {
    excludeKeys: excludeKeys,
    toolbarKeys: toolbarKeys,
    insertKeys: insertKeys
  };
  // 编辑器配置
  var editorConfig = {
    placeholder: placeholder,
    onFocus: onFocusCom,
    onBlur: onBlurCom,
    onDestroyed: onDestroyedCom,
    readOnly: readOnly,
    autoFocus: autoFocus,
    maxLength: max,
    MENU_CONF: Object.assign({
      uploadImage: Object.assign(Object.assign({}, uploadImage), {
        server: server
      }),
      uploadVideo: Object.assign(Object.assign({}, uploadVideo), {
        server: server
      })
    }, menuConfig)
  };
  // 国际化
  useEffect(function () {
    if (in18) {
      i18nChangeLanguage(in18);
    }
    setToolBarKey(Math.random().toString(36).slice(-8));
  }, [in18]);
  // 非受控组件赋值
  useEffect(function () {
    if (defaultValue !== undefined) {
      setValueCom(defaultValue);
    }
  }, []);
  // 受控组件监听value变化赋值
  useEffect(function () {
    if (value !== undefined) {
      setValueCom(value);
    }
  }, [value]);
  // 获取html格式的内容
  var getContent = function getContent() {
    if (!editor) return;
    return editor.getHtml();
  };
  // 获取纯文本
  var getText = function getText() {
    if (!editor) return;
    return editor.getText();
  };
  // 清空编辑器
  var clearEditor = function clearEditor() {
    if (!editor) return;
    editor.clear();
  };
  //设置值
  var setContent = function setContent(content) {
    if (!editor) return;
    editor.setHtml(content);
    // 重新聚焦放到下一次事件队列，否则会有bug
    setTimeout(function () {
      editor.focus(true);
    });
  };
  // 获取富文本实例
  var getEditor = function getEditor() {
    return editor;
  };
  // 销毁 editor
  useEffect(function () {
    return function () {
      if (editor == null) return;
      editor.destroy();
      setEditor(null);
    };
  }, [editor]);
  useImperativeHandle(ref, function () {
    return {
      getContent: getContent,
      getText: getText,
      clearEditor: clearEditor,
      setContent: setContent,
      getEditor: getEditor
    };
  });
  /**
  * 处理class
  * @return {string}
  */
  var handClass = function handClass() {
    var str = $prefixCls + '-text-editor';
    if (className) str += ' ' + className;
    return str;
  };
  /** 标题 */
  var labelMemo = useMemo(function () {
    var handLabelClass = function handLabelClass() {
      var str = 'text-editor-label';
      if (labelTooltip && labelTooltip.className) {
        str += ' ' + labelTooltip.className;
      }
      return str;
    };
    return jsx(Label, Object.assign({
      label: label,
      required: required,
      labelSign: labelSign
    }, labelTooltip, {
      className: handLabelClass()
    }));
  }, [label, labelSign, required, labelTooltip]);
  return jsxs("div", Object.assign({
    className: handClass(),
    style: style
  }, {
    children: [labelMemo, jsxs("div", Object.assign({
      className: "text-editor-content ".concat(isPreview ? "preview-mode" : "")
    }, {
      children: [jsx(Toolbar, {
        editor: editor,
        defaultConfig: toolbarConfig,
        mode: "default",
        style: toolbarStyle
      }, toolBarKey), jsx(Editor, {
        defaultConfig: editorConfig,
        value: valueCom,
        onCreated: setEditor,
        onChange: onChangeCom,
        mode: "default",
        style: editorStyle
      })]
    })), jsx(HelperText, {
      className: "text-editor-error-text",
      error: error,
      helperText: helperText,
      hideErrorDom: hideErrorDom
    })]
  }));
});

export { TextEditor as default };
