(function(C,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("react"),require("quill")):typeof define=="function"&&define.amd?define(["exports","react","quill"],c):(C=typeof globalThis<"u"?globalThis:C||self,c(C["react-quill-editor"]={},C.React,C.Quill))})(this,function(C,c,z){"use strict";const yr="",hr="",Rr="";var G={exports:{}},W={};/** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var oe;function Ae(){if(oe)return W;oe=1;var l=c,R=Symbol.for("react.element"),s=Symbol.for("react.fragment"),f=Object.prototype.hasOwnProperty,y=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,g={key:!0,ref:!0,__self:!0,__source:!0};function h(T,d,x){var b,S={},O=null,D=null;x!==void 0&&(O=""+x),d.key!==void 0&&(O=""+d.key),d.ref!==void 0&&(D=d.ref);for(b in d)f.call(d,b)&&!g.hasOwnProperty(b)&&(S[b]=d[b]);if(T&&T.defaultProps)for(b in d=T.defaultProps,d)S[b]===void 0&&(S[b]=d[b]);return{$$typeof:R,type:T,key:O,ref:D,props:S,_owner:y.current}}return W.Fragment=s,W.jsx=h,W.jsxs=h,W}var Y={};/** * @license React * react-jsx-runtime.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var ie;function Ie(){return ie||(ie=1,process.env.NODE_ENV!=="production"&&function(){var l=c,R=Symbol.for("react.element"),s=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),g=Symbol.for("react.profiler"),h=Symbol.for("react.provider"),T=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),b=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),D=Symbol.for("react.offscreen"),j=Symbol.iterator,X="@@iterator";function Q(e){if(e===null||typeof e!="object")return null;var r=j&&e[j]||e[X];return typeof r=="function"?r:null}var F=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function m(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n=1&&p>=0&&a[v]!==E[p];)p--;for(;v>=1&&p>=0;v--,p--)if(a[v]!==E[p]){if(v!==1||p!==1)do if(v--,p--,p<0||a[v]!==E[p]){var _=` `+a[v].replace(" at new "," at ");return e.displayName&&_.includes("")&&(_=_.replace("",e.displayName)),typeof e=="function"&&V.set(e,_),_}while(v>=1&&p>=0);break}}}finally{$=!1,Z.current=u,Xe(),Error.prepareStackTrace=i}var I=e?e.displayName||e.name:"",Fe=I?U(I):"";return typeof e=="function"&&V.set(e,Fe),Fe}function Ze(e,r,t){return he(e,!1)}function qe(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function H(e,r,t){if(e==null)return"";if(typeof e=="function")return he(e,qe(e));if(typeof e=="string")return U(e);switch(e){case x:return U("Suspense");case b:return U("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case d:return Ze(e.render);case S:return H(e.type,r,t);case O:{var n=e,i=n._payload,u=n._init;try{return H(u(i),r,t)}catch{}}}return""}var B=Object.prototype.hasOwnProperty,Re={},_e=F.ReactDebugCurrentFrame;function J(e){if(e){var r=e._owner,t=H(e.type,e._source,r?r.type:null);_e.setExtraStackFrame(t)}else _e.setExtraStackFrame(null)}function $e(e,r,t,n,i){{var u=Function.call.bind(B);for(var o in e)if(u(e,o)){var a=void 0;try{if(typeof e[o]!="function"){var E=Error((n||"React class")+": "+t+" type `"+o+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[o]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw E.name="Invariant Violation",E}a=e[o](r,o,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(v){a=v}a&&!(a instanceof Error)&&(J(i),m("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",t,o,typeof a),J(null)),a instanceof Error&&!(a.message in Re)&&(Re[a.message]=!0,J(i),m("Failed %s type: %s",t,a.message),J(null))}}}var er=Array.isArray;function ee(e){return er(e)}function rr(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function tr(e){try{return Te(e),!1}catch{return!0}}function Te(e){return""+e}function Se(e){if(tr(e))return m("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",rr(e)),Te(e)}var M=F.ReactCurrentOwner,nr={key:!0,ref:!0,__self:!0,__source:!0},Ce,Oe,re;re={};function ar(e){if(B.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function or(e){if(B.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function ir(e,r){if(typeof e.ref=="string"&&M.current&&r&&M.current.stateNode!==r){var t=w(M.current.type);re[t]||(m('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',w(M.current.type),e.ref),re[t]=!0)}}function sr(e,r){{var t=function(){Ce||(Ce=!0,m("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function ur(e,r){{var t=function(){Oe||(Oe=!0,m("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var lr=function(e,r,t,n,i,u,o){var a={$$typeof:R,type:e,key:r,ref:t,props:o,_owner:u};return a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(a,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(a,"_source",{configurable:!1,enumerable:!1,writable:!1,value:i}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a};function fr(e,r,t,n,i){{var u,o={},a=null,E=null;t!==void 0&&(Se(t),a=""+t),or(r)&&(Se(r.key),a=""+r.key),ar(r)&&(E=r.ref,ir(r,i));for(u in r)B.call(r,u)&&!nr.hasOwnProperty(u)&&(o[u]=r[u]);if(e&&e.defaultProps){var v=e.defaultProps;for(u in v)o[u]===void 0&&(o[u]=v[u])}if(a||E){var p=typeof e=="function"?e.displayName||e.name||"Unknown":e;a&&sr(o,p),E&&ur(o,p)}return lr(e,a,E,i,n,M.current,o)}}var te=F.ReactCurrentOwner,we=F.ReactDebugCurrentFrame;function A(e){if(e){var r=e._owner,t=H(e.type,e._source,r?r.type:null);we.setExtraStackFrame(t)}else we.setExtraStackFrame(null)}var ne;ne=!1;function ae(e){return typeof e=="object"&&e!==null&&e.$$typeof===R}function Pe(){{if(te.current){var e=w(te.current.type);if(e)return` Check the render method of \``+e+"`."}return""}}function cr(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),t=e.lineNumber;return` Check your code at `+r+":"+t+"."}return""}}var xe={};function dr(e){{var r=Pe();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=` Check the top-level render call using <`+t+">.")}return r}}function je(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=dr(r);if(xe[t])return;xe[t]=!0;var n="";e&&e._owner&&e._owner!==te.current&&(n=" It was passed a child from "+w(e._owner.type)+"."),A(e),m('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),A(null)}}function ke(e,r){{if(typeof e!="object")return;if(ee(e))for(var t=0;t",a=" Did you accidentally export a JSX literal instead of a component?"):v=typeof e,m("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",v,a)}var p=fr(e,r,t,i,u);if(p==null)return p;if(o){var _=r.children;if(_!==void 0)if(n)if(ee(_)){for(var I=0;I<_.length;I++)ke(_[I],e);Object.freeze&&Object.freeze(_)}else m("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ke(_,e)}return e===f?pr(p):vr(p),p}}function br(e,r,t){return De(e,r,t,!0)}function mr(e,r,t){return De(e,r,t,!1)}var Er=mr,gr=br;Y.Fragment=f,Y.jsx=Er,Y.jsxs=gr}()),Y}process.env.NODE_ENV==="production"?G.exports=Ae():G.exports=Ie();var N=G.exports;const K={debug:"false",modules:{toolbar:[["bold","italic","underline","strike"],["blockquote","code-block"],[{header:1},{header:2}],[{list:"ordered"},{list:"bullet"}],[{script:"sub"},{script:"super"}],[{indent:"-1"},{indent:"+1"}],[{direction:"rtl"}],[{size:["small",!1,"large","huge"]}],[{header:[1,2,3,4,5,6,!1]}],[{color:[]},{background:[]}],[{font:[]}],[{align:[]}],["clean"]]},placeholder:"Let's write...",theme:"snow"},se=[],We={editor:null,quill:null,options:K,editorRef:null,content:{delta:void 0,html:""}},ue=c.createContext(We),Ye=({config:l,children:R})=>{const[s,f]=c.useState(null),[y,g]=c.useState(!1),[h,T]=c.useState(null),[d,x]=c.useState(K),b=c.useRef(null);c.useEffect(()=>{x({...K,...l.options})},[l.options]),c.useEffect(()=>{if(b.current&&(T(b.current),h))if(y)console.log("Quill is on...");else{const j=z.import("attributors/class/font");j.whitelist=l.fonts?[...se,...l.fonts]:se,z.register(j,!0),console.log("Starting quill..."),f(new z(h,d)),g(!0)}},[h,y]);const[S,O]=c.useState({delta:s==null?void 0:s.getContents(),html:s==null?void 0:s.root.innerHTML});c.useEffect(()=>{const j=()=>{const X=s==null?void 0:s.getContents(),Q=s==null?void 0:s.root.innerHTML;O({delta:X,html:Q})};return s&&s.on("editor-change",j),()=>{s&&s.off("editor-change",j)}},[s]);const D={editor:h,quill:s,options:d,editorRef:b,content:S};return N.jsx(ue.Provider,{value:D,children:R})},le=()=>c.useContext(ue),Le=(l,R)=>{const[s,f]=c.useState(l);return c.useEffect(()=>{const y=document.querySelector(".ql-toolbar"),g=y==null?void 0:y.getBoundingClientRect().height;R&&(g&&g>0?typeof l=="string"?l.trim().endsWith("%")?f(`calc(100% - ${g}px)`):f(`calc(${l} - ${g}px)`):typeof l=="number"&&f(l-g):typeof l=="string"?l.trim().endsWith("%")?f("100%"):f(l):typeof l=="number"&&f(l))},[R,l]),{editorHeight:s}},Me=({height:l,children:R,initialValue:s})=>{const{quill:f,options:y,editorRef:g}=le(),{editorHeight:h}=Le(l,f);c.useEffect(()=>{f&&f.focus()},[f]);const T=()=>{var d;return typeof((d=y.modules)==null?void 0:d.toolbar)=="string"?N.jsx("div",{id:"toolbar",children:R}):null};return c.useEffect(()=>{s&&f&&f.setContents(s)},[s,f]),N.jsxs("div",{className:"editor-container",style:{height:l},children:[T(),N.jsx("div",{ref:g,style:{height:h,maxHeight:h}})]})};C.Editor=Me,C.Provider=Ye,C.useEditor=le,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});