"use strict";(this.webpackChunk_lingxiteam_pcfactory=this.webpackChunk_lingxiteam_pcfactory||[]).push([[578],{6567:function(e,t,n){n.r(t),n.d(t,{default:function(){return v}});var i=n(32723),a=n(34795),r=n(37930),l=n(90359),u=n.n(l),o=n(8617),c=n.n(o),s=n(72779),g=n.n(s),d=n(70247),p=n(84707),f=function(e){var t=e.engineApis,n=(0,l.useRef)(null),r=(0,p.b)(t).getLocale,u=(0,l.useState)({toolbar:{container:[[{header:[1,2,!1]}],["bold","italic","underline"],[{color:[]}],[{list:"ordered"},{list:"bullet"}],["link","image"]],handlers:{image:function(){var e=n.current.getEditor(),l=document.createElement("input");l.style.display="none",l.setAttribute("type","file"),l.setAttribute("accept",".jpg,.gif,.png"),l.click(),l.onchange=(0,a.Z)((0,i.Z)().mark((function n(){var a,u,o,c,s,g;return(0,i.Z)().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(u=l.files&&l.files[0],/\.(jpg|gif|png)$/.test(u.name.toLowerCase())){n.next=4;break}return d.message.warn(r("Quill.uploadImages")),n.abrupt("return");case 4:if(!(u.size>3e6)){n.next=7;break}return d.message.warn(r("Quill.imageSizeLimit")),n.abrupt("return");case 7:if((o=new FormData).append("attach",u,u.name),null==t||null===(a=t.service)||void 0===a||!a.uploadFileByFetch){n.next=14;break}return n.next=12,t.service.uploadFileByFetch(o);case 12:null!=(c=n.sent)&&c.fileId&&(s=e.getSelection(),g=null==t?void 0:t.getAppFileUrlById(null==c?void 0:c.fileId),e.insertEmbed(s.index,"image",g));case 14:case"end":return n.stop()}}),n)})))},link:function(e){var t,i=null==n||null===(t=n.current)||void 0===t?void 0:t.getEditor();if(e){var a=null==i?void 0:i.getSelection(),l=null==i?void 0:i.getText(a);if(null!=a&&0!==a.length&&l){if(l){/^\S+@\S+\.\S+$/.test(l)&&0!==l.indexOf("mailto:")&&(l="mailto:".concat(l)),i.theme.tooltip.edit("link",l)}}else d.message.info(r("Quill.selectZh"))}else null==i||i.format("link",!1)}}}})[0];return[n,u]},m=(n(73645),n(69517)),h=u().forwardRef((function(e,t){var n=e.value,o=e.disabled,s=e.className,d=e.imageType,p=e.heightType,m=e.minHeight,h=e.maxHeight,v=e.height,b=e.engineApis,y=e.onChange,x=(0,l.useRef)(!1),k=(0,l.useMemo)((function(){return"auto"===p?{minHeight:m,maxHeight:h}:{height:v}}),[p,v,h,m]),w=f({engineApis:b}),A=w[0],F=w[1],E=(0,l.useMemo)((function(){return d&&"base64"===d?{toolbar:(0,r.Z)(F.toolbar.container)}:F}),[d,F]),B=function(e){var t=e.match(/<img src="data:.*?(?:>|\/>)/gi);if(!t||!t[0])return null;var n=t[0].split('"')[1],i=window.atob(n.split(",")[1]),a=new ArrayBuffer(i.length),r=new Uint8Array(a);return r.forEach((function(e,t){r[t]=i.charCodeAt(t)})),new Blob([r],{type:n.split(",")[0].split(":")[1].split(";")[0]})};return(0,l.useEffect)((function(){x.current&&(x.current=!1)}),[n]),u().createElement(c(),{ref:A,readOnly:o,modules:E,style:k,value:"number"==typeof n?"".concat(n):n,className:g()("ued-quill-editor",s),onChange:function(){var e=(0,a.Z)((0,i.Z)().mark((function e(t){var a,r,l,u,o,c;return(0,i.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("<p><br></p>"!==t||""!==n){e.next=2;break}return e.abrupt("return");case 2:if(x.current=!0,a=t,r=null,"base64"===d){e.next=14;break}if(!(r=B(t))){e.next=14;break}return(u=new FormData).append("attach",r,"tmpfile"),e.next=12,null==b||null===(l=b.service)||void 0===l?void 0:l.uploadFileByFetch(u);case 12:null!=(o=e.sent)&&o.fileId&&(c=null==b?void 0:b.getAppFileUrlById(null==o?void 0:o.fileId),a=t.replace(/<img src="data:.*?(?:>|\/>)/gi,'<img src="'.concat(c,'" />')));case 14:!r&&y&&y(a);case 15:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()})})),v=(0,m.UB)((function(e,t){var n=e.height,i=e.onChange,a=e.className,r=e.imageType,l=e.heightType,o=void 0===l?"fixed":l,c=e.maxHeight,s=e.minHeight,g=e.getEngineApis,d=e.value,p=e.disabled,f=(null==g?void 0:g())||{};return u().createElement(h,{engineApis:f,className:a,imageType:r,height:n,disabled:p,heightType:o,maxHeight:c,minHeight:s,onChange:i,value:d})}))}}]);