@wangeditor-next/plugin-formula 0.0.10 → 0.0.12-beta.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -1,2 +1,1221 @@
1
- import t from"katex";import{i18nAddResources as n,t as r,DomEditor as e,SlateRange as o,genModalTextareaElems as i,genModalButtonElems as u,SlateTransforms as c}from"@wangeditor-next/editor";import{h as a}from"snabbdom";var f=function(t,n){return f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])},f(t,n)};function l(t,n){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var e,o,i=r.call(t),u=[];try{for(;(void 0===n||n-- >0)&&!(e=i.next()).done;)u.push(e.value)}catch(t){o={error:t}}finally{try{e&&!e.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u}"function"==typeof SuppressedError&&SuppressedError;var s,p,v="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},d={};function h(){if(p)return s;p=1;var t=function(t){return t&&t.Math===Math&&t};return s=t("object"==typeof globalThis&&globalThis)||t("object"==typeof window&&window)||t("object"==typeof self&&self)||t("object"==typeof v&&v)||t("object"==typeof s&&s)||function(){return this}()||Function("return this")()}var y,m,g,b,w,O,x,E,S,j,T,L,P,I,A,_,M,R,C,k,N,F,D,H,z,$,V,B,W,U,q,G,K,X,Y,J,Q,Z={exports:{}};function tt(){if(b)return g;b=1;var t=h(),n=Object.defineProperty;return g=function(r,e){try{n(t,r,{value:e,configurable:!0,writable:!0})}catch(n){t[r]=e}return e}}function nt(){if(w)return Z.exports;w=1;var t=m?y:(m=1,y=!1),n=h(),r=tt(),e="__core-js_shared__",o=Z.exports=n[e]||r(e,{});return(o.versions||(o.versions=[])).push({version:"3.38.1",mode:t?"pure":"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.1/LICENSE",source:"https://github.com/zloirock/core-js"}),Z.exports}function rt(){if(x)return O;x=1;var t=nt();return O=function(n,r){return t[n]||(t[n]=r||{})}}function et(){return S?E:(S=1,E=function(t){try{return!!t()}catch(t){return!0}})}function ot(){if(T)return j;T=1;var t=et();return j=!t((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")}))}function it(){if(P)return L;P=1;var t=ot(),n=Function.prototype,r=n.call,e=t&&n.bind.bind(r,r);return L=t?e:function(t){return function(){return r.apply(t,arguments)}},L}function ut(){return A?I:(A=1,I=function(t){return null==t})}function ct(){if(M)return _;M=1;var t=ut(),n=TypeError;return _=function(r){if(t(r))throw new n("Can't call method on "+r);return r}}function at(){if(C)return R;C=1;var t=ct(),n=Object;return R=function(r){return n(t(r))}}function ft(){if(N)return k;N=1;var t=it(),n=at(),r=t({}.hasOwnProperty);return k=Object.hasOwn||function(t,e){return r(n(t),e)}}function lt(){if(D)return F;D=1;var t=it(),n=0,r=Math.random(),e=t(1..toString);return F=function(t){return"Symbol("+(void 0===t?"":t)+")_"+e(++n+r,36)}}function st(){if(V)return $;V=1;var t,n,r=h(),e=function(){if(z)return H;z=1;var t=h().navigator,n=t&&t.userAgent;return H=n?String(n):""}(),o=r.process,i=r.Deno,u=o&&o.versions||i&&i.version,c=u&&u.v8;return c&&(n=(t=c.split("."))[0]>0&&t[0]<4?1:+(t[0]+t[1])),!n&&e&&(!(t=e.match(/Edge\/(\d+)/))||t[1]>=74)&&(t=e.match(/Chrome\/(\d+)/))&&(n=+t[1]),$=n}function pt(){if(W)return B;W=1;var t=st(),n=et(),r=h().String;return B=!!Object.getOwnPropertySymbols&&!n((function(){var n=Symbol("symbol detection");return!r(n)||!(Object(n)instanceof Symbol)||!Symbol.sham&&t&&t<41}))}function vt(){if(q)return U;q=1;var t=pt();return U=t&&!Symbol.sham&&"symbol"==typeof Symbol.iterator}function dt(){if(K)return G;K=1;var t=h(),n=rt(),r=ft(),e=lt(),o=pt(),i=vt(),u=t.Symbol,c=n("wks"),a=i?u.for||u:u&&u.withoutSetter||e;return G=function(t){return r(c,t)||(c[t]=o&&r(u,t)?u[t]:a("Symbol."+t)),c[t]}}function ht(){if(Y)return X;Y=1;var t={};return t[dt()("toStringTag")]="z",X="[object z]"===String(t)}function yt(){if(Q)return J;Q=1;var t="object"==typeof document&&document.all;return J=void 0===t&&void 0!==t?function(n){return"function"==typeof n||n===t}:function(t){return"function"==typeof t}}var mt,gt,bt,wt,Ot,xt,Et,St,jt,Tt,Lt,Pt,It,At,_t,Mt,Rt,Ct,kt,Nt,Ft,Dt,Ht,zt,$t,Vt,Bt,Wt,Ut,qt,Gt,Kt,Xt,Yt={};function Jt(){if(gt)return mt;gt=1;var t=et();return mt=!t((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}))}function Qt(){if(wt)return bt;wt=1;var t=yt();return bt=function(n){return"object"==typeof n?null!==n:t(n)}}function Zt(){if(xt)return Ot;xt=1;var t=h(),n=Qt(),r=t.document,e=n(r)&&n(r.createElement);return Ot=function(t){return e?r.createElement(t):{}}}function tn(){if(St)return Et;St=1;var t=Jt(),n=et(),r=Zt();return Et=!t&&!n((function(){return 7!==Object.defineProperty(r("div"),"a",{get:function(){return 7}}).a}))}function nn(){if(Tt)return jt;Tt=1;var t=Jt(),n=et();return jt=t&&n((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))}function rn(){if(Pt)return Lt;Pt=1;var t=Qt(),n=String,r=TypeError;return Lt=function(e){if(t(e))return e;throw new r(n(e)+" is not an object")}}function en(){if(At)return It;At=1;var t=ot(),n=Function.prototype.call;return It=t?n.bind(n):function(){return n.apply(n,arguments)},It}function on(){if(Mt)return _t;Mt=1;var t=h(),n=yt();return _t=function(r,e){return arguments.length<2?(o=t[r],n(o)?o:void 0):t[r]&&t[r][e];var o},_t}function un(){if(Nt)return kt;Nt=1;var t=on(),n=yt(),r=function(){if(Ct)return Rt;Ct=1;var t=it();return Rt=t({}.isPrototypeOf)}(),e=vt(),o=Object;return kt=e?function(t){return"symbol"==typeof t}:function(e){var i=t("Symbol");return n(i)&&r(i.prototype,o(e))}}function cn(){if(Dt)return Ft;Dt=1;var t=String;return Ft=function(n){try{return t(n)}catch(t){return"Object"}}}function an(){if(zt)return Ht;zt=1;var t=yt(),n=cn(),r=TypeError;return Ht=function(e){if(t(e))return e;throw new r(n(e)+" is not a function")}}function fn(){if(Vt)return $t;Vt=1;var t=an(),n=ut();return $t=function(r,e){var o=r[e];return n(o)?void 0:t(o)}}function ln(){if(Wt)return Bt;Wt=1;var t=en(),n=yt(),r=Qt(),e=TypeError;return Bt=function(o,i){var u,c;if("string"===i&&n(u=o.toString)&&!r(c=t(u,o)))return c;if(n(u=o.valueOf)&&!r(c=t(u,o)))return c;if("string"!==i&&n(u=o.toString)&&!r(c=t(u,o)))return c;throw new e("Can't convert object to primitive value")},Bt}function sn(){if(qt)return Ut;qt=1;var t=en(),n=Qt(),r=un(),e=fn(),o=ln(),i=dt(),u=TypeError,c=i("toPrimitive");return Ut=function(i,a){if(!n(i)||r(i))return i;var f,l=e(i,c);if(l){if(void 0===a&&(a="default"),f=t(l,i,a),!n(f)||r(f))return f;throw new u("Can't convert object to primitive value")}return void 0===a&&(a="number"),o(i,a)}}function pn(){if(Kt)return Gt;Kt=1;var t=sn(),n=un();return Gt=function(r){var e=t(r,"string");return n(e)?e:e+""}}function vn(){if(Xt)return Yt;Xt=1;var t=Jt(),n=tn(),r=nn(),e=rn(),o=pn(),i=TypeError,u=Object.defineProperty,c=Object.getOwnPropertyDescriptor,a="enumerable",f="configurable",l="writable";return Yt.f=t?r?function(t,n,r){if(e(t),n=o(n),e(r),"function"==typeof t&&"prototype"===n&&"value"in r&&l in r&&!r[l]){var i=c(t,n);i&&i[l]&&(t[n]=r.value,r={configurable:f in r?r[f]:i[f],enumerable:a in r?r[a]:i[a],writable:!1})}return u(t,n,r)}:u:function(t,r,c){if(e(t),r=o(r),e(c),n)try{return u(t,r,c)}catch(t){}if("get"in c||"set"in c)throw new i("Accessors not supported");return"value"in c&&(t[r]=c.value),t},Yt}var dn,hn,yn,mn,gn,bn,wn,On,xn,En,Sn,jn,Tn,Ln,Pn,In,An,_n,Mn,Rn,Cn,kn,Nn,Fn,Dn,Hn,zn={exports:{}};function $n(){if(hn)return dn;hn=1;var t=Jt(),n=ft(),r=Function.prototype,e=t&&Object.getOwnPropertyDescriptor,o=n(r,"name"),i=o&&"something"===function(){}.name,u=o&&(!t||t&&e(r,"name").configurable);return dn={EXISTS:o,PROPER:i,CONFIGURABLE:u}}function Vn(){if(mn)return yn;mn=1;var t=it(),n=yt(),r=nt(),e=t(Function.toString);return n(r.inspectSource)||(r.inspectSource=function(t){return e(t)}),yn=r.inspectSource}function Bn(){return On?wn:(On=1,wn=function(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}})}function Wn(){if(En)return xn;En=1;var t=Jt(),n=vn(),r=Bn();return xn=t?function(t,e,o){return n.f(t,e,r(1,o))}:function(t,n,r){return t[n]=r,t}}function Un(){if(jn)return Sn;jn=1;var t=rt(),n=lt(),r=t("keys");return Sn=function(t){return r[t]||(r[t]=n(t))}}function qn(){return Ln?Tn:(Ln=1,Tn={})}function Gn(){if(In)return Pn;In=1;var t,n,r,e=function(){if(bn)return gn;bn=1;var t=h(),n=yt(),r=t.WeakMap;return gn=n(r)&&/native code/.test(String(r))}(),o=h(),i=Qt(),u=Wn(),c=ft(),a=nt(),f=Un(),l=qn(),s="Object already initialized",p=o.TypeError,v=o.WeakMap;if(e||a.state){var d=a.state||(a.state=new v);d.get=d.get,d.has=d.has,d.set=d.set,t=function(t,n){if(d.has(t))throw new p(s);return n.facade=t,d.set(t,n),n},n=function(t){return d.get(t)||{}},r=function(t){return d.has(t)}}else{var y=f("state");l[y]=!0,t=function(t,n){if(c(t,y))throw new p(s);return n.facade=t,u(t,y,n),n},n=function(t){return c(t,y)?t[y]:{}},r=function(t){return c(t,y)}}return Pn={set:t,get:n,has:r,enforce:function(e){return r(e)?n(e):t(e,{})},getterFor:function(t){return function(r){var e;if(!i(r)||(e=n(r)).type!==t)throw new p("Incompatible receiver, "+t+" required");return e}}}}function Kn(){if(An)return zn.exports;An=1;var t=it(),n=et(),r=yt(),e=ft(),o=Jt(),i=$n().CONFIGURABLE,u=Vn(),c=Gn(),a=c.enforce,f=c.get,l=String,s=Object.defineProperty,p=t("".slice),v=t("".replace),d=t([].join),h=o&&!n((function(){return 8!==s((function(){}),"length",{value:8}).length})),y=String(String).split("String"),m=zn.exports=function(t,n,r){"Symbol("===p(l(n),0,7)&&(n="["+v(l(n),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),r&&r.getter&&(n="get "+n),r&&r.setter&&(n="set "+n),(!e(t,"name")||i&&t.name!==n)&&(o?s(t,"name",{value:n,configurable:!0}):t.name=n),h&&r&&e(r,"arity")&&t.length!==r.arity&&s(t,"length",{value:r.arity});try{r&&e(r,"constructor")&&r.constructor?o&&s(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(t){}var u=a(t);return e(u,"source")||(u.source=d(y,"string"==typeof n?n:"")),t};return Function.prototype.toString=m((function(){return r(this)&&f(this).source||u(this)}),"toString"),zn.exports}function Xn(){if(Mn)return _n;Mn=1;var t=yt(),n=vn(),r=Kn(),e=tt();return _n=function(o,i,u,c){c||(c={});var a=c.enumerable,f=void 0!==c.name?c.name:i;if(t(u)&&r(u,f,c),c.global)a?o[i]=u:e(i,u);else{try{c.unsafe?o[i]&&(a=!0):delete o[i]}catch(t){}a?o[i]=u:n.f(o,i,{value:u,enumerable:!1,configurable:!c.nonConfigurable,writable:!c.nonWritable})}return o}}function Yn(){if(Cn)return Rn;Cn=1;var t=it(),n=t({}.toString),r=t("".slice);return Rn=function(t){return r(n(t),8,-1)}}function Jn(){if(Nn)return kn;Nn=1;var t=ht(),n=yt(),r=Yn(),e=dt()("toStringTag"),o=Object,i="Arguments"===r(function(){return arguments}());return kn=t?r:function(t){var u,c,a;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(c=function(t,n){try{return t[n]}catch(t){}}(u=o(t),e))?c:i?r(u):"Object"===(a=r(u))&&n(u.callee)?"Arguments":a}}!function(){if(Hn)return d;Hn=1;var t=ht(),n=Xn(),r=function(){if(Dn)return Fn;Dn=1;var t=ht(),n=Jn();return Fn=t?{}.toString:function(){return"[object "+n(this)+"]"}}();t||n(Object.prototype,"toString",r,{unsafe:!0})}();var Qn,Zn,tr,nr,rr,er,or={},ir={},ur={};function cr(){if(tr)return Zn;tr=1;var t=it(),n=et(),r=Yn(),e=Object,o=t("".split);return Zn=n((function(){return!e("z").propertyIsEnumerable(0)}))?function(t){return"String"===r(t)?o(t,""):e(t)}:e}function ar(){if(rr)return nr;rr=1;var t=cr(),n=ct();return nr=function(r){return t(n(r))}}function fr(){if(er)return ir;er=1;var t=Jt(),n=en(),r=function(){if(Qn)return ur;Qn=1;var t={}.propertyIsEnumerable,n=Object.getOwnPropertyDescriptor,r=n&&!t.call({1:2},1);return ur.f=r?function(t){var r=n(this,t);return!!r&&r.enumerable}:t,ur}(),e=Bn(),o=ar(),i=pn(),u=ft(),c=tn(),a=Object.getOwnPropertyDescriptor;return ir.f=t?a:function(t,f){if(t=o(t),f=i(f),c)try{return a(t,f)}catch(t){}if(u(t,f))return e(!n(r.f,t,f),t[f])},ir}var lr,sr,pr,vr,dr,hr,yr,mr,gr,br,wr,Or,xr,Er,Sr,jr,Tr,Lr={};function Pr(){if(vr)return pr;vr=1;var t=function(){if(sr)return lr;sr=1;var t=Math.ceil,n=Math.floor;return lr=Math.trunc||function(r){var e=+r;return(e>0?n:t)(e)}}();return pr=function(n){var r=+n;return r!=r||0===r?0:t(r)}}function Ir(){if(hr)return dr;hr=1;var t=Pr(),n=Math.max,r=Math.min;return dr=function(e,o){var i=t(e);return i<0?n(i+o,0):r(i,o)}}function Ar(){if(mr)return yr;mr=1;var t=Pr(),n=Math.min;return yr=function(r){var e=t(r);return e>0?n(e,9007199254740991):0}}function _r(){if(br)return gr;br=1;var t=Ar();return gr=function(n){return t(n.length)}}function Mr(){if(Er)return xr;Er=1;var t=it(),n=ft(),r=ar(),e=function(){if(Or)return wr;Or=1;var t=ar(),n=Ir(),r=_r(),e=function(e){return function(o,i,u){var c=t(o),a=r(c);if(0===a)return!e&&-1;var f,l=n(u,a);if(e&&i!=i){for(;a>l;)if((f=c[l++])!=f)return!0}else for(;a>l;l++)if((e||l in c)&&c[l]===i)return e||l||0;return!e&&-1}};return wr={includes:e(!0),indexOf:e(!1)}}().indexOf,o=qn(),i=t([].push);return xr=function(t,u){var c,a=r(t),f=0,l=[];for(c in a)!n(o,c)&&n(a,c)&&i(l,c);for(;u.length>f;)n(a,c=u[f++])&&(~e(l,c)||i(l,c));return l}}function Rr(){return jr?Sr:(jr=1,Sr=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"])}var Cr,kr,Nr,Fr,Dr,Hr,zr,$r,Vr,Br,Wr,Ur,qr,Gr,Kr,Xr,Yr,Jr,Qr,Zr={};function te(){if(Nr)return kr;Nr=1;var t=on(),n=it(),r=function(){if(Tr)return Lr;Tr=1;var t=Mr(),n=Rr().concat("length","prototype");return Lr.f=Object.getOwnPropertyNames||function(r){return t(r,n)},Lr}(),e=(Cr||(Cr=1,Zr.f=Object.getOwnPropertySymbols),Zr),o=rn(),i=n([].concat);return kr=t("Reflect","ownKeys")||function(t){var n=r.f(o(t)),u=e.f;return u?i(n,u(t)):n}}function ne(){if(Dr)return Fr;Dr=1;var t=ft(),n=te(),r=fr(),e=vn();return Fr=function(o,i,u){for(var c=n(i),a=e.f,f=r.f,l=0;l<c.length;l++){var s=c[l];t(o,s)||u&&t(u,s)||a(o,s,f(i,s))}}}function re(){if(Vr)return $r;Vr=1;var t=h(),n=fr().f,r=Wn(),e=Xn(),o=tt(),i=ne(),u=function(){if(zr)return Hr;zr=1;var t=et(),n=yt(),r=/#|\.prototype\./,e=function(r,e){var a=i[o(r)];return a===c||a!==u&&(n(e)?t(e):!!e)},o=e.normalize=function(t){return String(t).replace(r,".").toLowerCase()},i=e.data={},u=e.NATIVE="N",c=e.POLYFILL="P";return Hr=e}();return $r=function(c,a){var f,l,s,p,v,d=c.target,h=c.global,y=c.stat;if(f=h?t:y?t[d]||o(d,{}):t[d]&&t[d].prototype)for(l in a){if(p=a[l],s=c.dontCallGetSet?(v=n(f,l))&&v.value:f[l],!u(h?l:d+(y?".":"#")+l,c.forced)&&void 0!==s){if(typeof p==typeof s)continue;i(p,s)}(c.sham||s&&s.sham)&&r(p,"sham",!0),e(f,l,p,c)}}}function ee(){if(qr)return Ur;qr=1;var t=it();return Ur=t([].slice)}function oe(){if(Kr)return Gr;Kr=1;var t=it(),n=an(),r=Qt(),e=ft(),o=ee(),i=ot(),u=Function,c=t([].concat),a=t([].join),f={};return Gr=i?u.bind:function(t){var i=n(this),l=i.prototype,s=o(arguments,1),p=function(){var n=c(s,o(arguments));return this instanceof p?function(t,n,r){if(!e(f,n)){for(var o=[],i=0;i<n;i++)o[i]="a["+i+"]";f[n]=u("C,a","return new C("+a(o,",")+")")}return f[n](t,r)}(i,n.length,n):i.apply(t,n)};return r(l)&&(p.prototype=l),p},Gr}function ie(){if(Yr)return Xr;Yr=1;var t=it(),n=et(),r=yt(),e=Jn(),o=on(),i=Vn(),u=function(){},c=o("Reflect","construct"),a=/^\s*(?:class|function)\b/,f=t(a.exec),l=!a.test(u),s=function(t){if(!r(t))return!1;try{return c(u,[],t),!0}catch(t){return!1}},p=function(t){if(!r(t))return!1;switch(e(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return l||!!f(a,i(t))}catch(t){return!0}};return p.sham=!0,Xr=!c||n((function(){var t;return s(s.call)||!s(Object)||!s((function(){t=!0}))||t}))?p:s}function ue(){if(Qr)return Jr;Qr=1;var t=ie(),n=cn(),r=TypeError;return Jr=function(e){if(t(e))return e;throw new r(n(e)+" is not a constructor")}}var ce,ae,fe,le,se,pe,ve,de,he={};function ye(){if(ae)return ce;ae=1;var t=Mr(),n=Rr();return ce=Object.keys||function(r){return t(r,n)}}function me(){if(ve)return pe;ve=1;var t,n=rn(),r=function(){if(fe)return he;fe=1;var t=Jt(),n=nn(),r=vn(),e=rn(),o=ar(),i=ye();return he.f=t&&!n?Object.defineProperties:function(t,n){e(t);for(var u,c=o(n),a=i(n),f=a.length,l=0;f>l;)r.f(t,u=a[l++],c[u]);return t},he}(),e=Rr(),o=qn(),i=function(){if(se)return le;se=1;var t=on();return le=t("document","documentElement")}(),u=Zt(),c=Un(),a="prototype",f="script",l=c("IE_PROTO"),s=function(){},p=function(t){return"<"+f+">"+t+"</"+f+">"},v=function(t){t.write(p("")),t.close();var n=t.parentWindow.Object;return t=null,n},d=function(){try{t=new ActiveXObject("htmlfile")}catch(t){}var n,r,o;d="undefined"!=typeof document?document.domain&&t?v(t):(r=u("iframe"),o="java"+f+":",r.style.display="none",i.appendChild(r),r.src=String(o),(n=r.contentWindow.document).open(),n.write(p("document.F=Object")),n.close(),n.F):v(t);for(var c=e.length;c--;)delete d[a][e[c]];return d()};return o[l]=!0,pe=Object.create||function(t,e){var o;return null!==t?(s[a]=n(t),o=new s,s[a]=null,o[l]=t):o=d(),void 0===e?o:r.f(o,e)}}!function(){if(de)return or;de=1;var t=re(),n=on(),r=function(){if(Wr)return Br;Wr=1;var t=ot(),n=Function.prototype,r=n.apply,e=n.call;return Br="object"==typeof Reflect&&Reflect.apply||(t?e.bind(r):function(){return e.apply(r,arguments)}),Br}(),e=oe(),o=ue(),i=rn(),u=Qt(),c=me(),a=et(),f=n("Reflect","construct"),l=Object.prototype,s=[].push,p=a((function(){function t(){}return!(f((function(){}),[],t)instanceof t)})),v=!a((function(){f((function(){}))})),d=p||v;t({target:"Reflect",stat:!0,forced:d,sham:d},{construct:function(t,n){o(t),i(n);var a=arguments.length<3?t:o(arguments[2]);if(v&&!p)return f(t,n,a);if(t===a){switch(n.length){case 0:return new t;case 1:return new t(n[0]);case 2:return new t(n[0],n[1]);case 3:return new t(n[0],n[1],n[2]);case 4:return new t(n[0],n[1],n[2],n[3])}var d=[null];return r(s,d,n),new(r(e,t,d))}var h=a.prototype,y=c(u(h)?h:l),m=r(t,y,n);return u(m)?m:y}})}(),function(){if(void 0!==window.Reflect&&void 0!==window.customElements&&!window.customElements.polyfillWrapFlushCallback){var t=HTMLElement,n=function(){return Reflect.construct(t,[],this.constructor)};window.HTMLElement=n,HTMLElement.prototype=t.prototype,HTMLElement.prototype.constructor=HTMLElement,Object.setPrototypeOf(HTMLElement,t)}}();var ge=function(n){function r(){var t=n.call(this)||this,r=t.attachShadow({mode:"open"}),e=r.ownerDocument,o=e.createElement("link");o.rel="stylesheet",o.href="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.css",o.integrity="sha384-n8MVd4RsNIU0tAv4ct0nTaAbDJwPJzDEaqSD1odI+WdtXRGWt2kTvGFasHpSy3SV",o.crossOrigin="anonymous",r.appendChild(o);var i=e.createElement("span");return i.style.display="inline-block",r.appendChild(i),t.span=i,t}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}f(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(r,n),Object.defineProperty(r,"observedAttributes",{get:function(){return["data-value"]},enumerable:!1,configurable:!0}),r.prototype.attributeChangedCallback=function(t,n,r){if("data-value"===t){if(n===r)return;this.render(r||"")}},r.prototype.render=function(n){t.render(n,this.span,{throwOnError:!1})},r}(HTMLElement);window.customElements.get("w-e-formula-card")||window.customElements.define("w-e-formula-card",ge),n("en",{formula:{formula:"Formula",placeholder:"Use LateX syntax",insert:"Insert formula",edit:"Edit formula",ok:"OK"}}),n("zh-CN",{formula:{formula:"公式",placeholder:"使用 LateX 语法",insert:"插入公式",edit:"编辑公式",ok:"确定"}});var be,we,Oe,xe,Ee,Se,je,Te,Le,Pe,Ie,Ae,_e,Me,Re,Ce={type:"formula",elemToHtml:function(t,n){var r=t.value;return'<span data-w-e-type="formula" data-w-e-is-void data-w-e-is-inline data-value="'.concat(void 0===r?"":r,'"></span>')}},ke={};function Ne(){if(xe)return Oe;xe=1;var t=function(){if(we)return be;we=1;var t=Yn(),n=it();return be=function(r){if("Function"===t(r))return n(r)}}(),n=an(),r=ot(),e=t(t.bind);return Oe=function(t,o){return n(t),void 0===o?t:r?e(t,o):function(){return t.apply(o,arguments)}},Oe}function Fe(){if(Se)return Ee;Se=1;var t=Yn();return Ee=Array.isArray||function(n){return"Array"===t(n)}}function De(){if(Te)return je;Te=1;var t=Fe(),n=ie(),r=Qt(),e=dt()("species"),o=Array;return je=function(i){var u;return t(i)&&(u=i.constructor,(n(u)&&(u===o||t(u.prototype))||r(u)&&null===(u=u[e]))&&(u=void 0)),void 0===u?o:u}}function He(){if(Pe)return Le;Pe=1;var t=De();return Le=function(n,r){return new(t(n))(0===r?0:r)}}function ze(){if(Me)return _e;Me=1;var t=dt(),n=me(),r=vn().f,e=t("unscopables"),o=Array.prototype;return void 0===o[e]&&r(o,e,{configurable:!0,value:n(null)}),_e=function(t){o[e][t]=!0}}!function(){if(Re)return ke;Re=1;var t=re(),n=function(){if(Ae)return Ie;Ae=1;var t=Ne(),n=it(),r=cr(),e=at(),o=_r(),i=He(),u=n([].push),c=function(n){var c=1===n,a=2===n,f=3===n,l=4===n,s=6===n,p=7===n,v=5===n||s;return function(d,h,y,m){for(var g,b,w=e(d),O=r(w),x=o(O),E=t(h,y),S=0,j=m||i,T=c?j(d,x):a||p?j(d,0):void 0;x>S;S++)if((v||S in O)&&(b=E(g=O[S],S,w),n))if(c)T[S]=b;else if(b)switch(n){case 3:return!0;case 5:return g;case 6:return S;case 2:u(T,g)}else switch(n){case 4:return!1;case 7:u(T,g)}return s?-1:f||l?l:T}};return Ie={forEach:c(0),map:c(1),filter:c(2),some:c(3),every:c(4),find:c(5),findIndex:c(6),filterReject:c(7)}}().find,r=ze(),e="find",o=!0;e in[]&&Array(1)[e]((function(){o=!1})),t({target:"Array",proto:!0,forced:o},{find:function(t){return n(this,t,arguments.length>1?arguments[1]:void 0)}}),r(e)}();var $e,Ve,Be,We,Ue,qe,Ge,Ke,Xe,Ye,Je,Qe,Ze,to={};function no(){if(Ve)return $e;Ve=1;var t=Jn(),n=String;return $e=function(r){if("Symbol"===t(r))throw new TypeError("Cannot convert a Symbol value to a string");return n(r)}}function ro(){if(We)return Be;We=1;var t=rn();return Be=function(){var n=t(this),r="";return n.hasIndices&&(r+="d"),n.global&&(r+="g"),n.ignoreCase&&(r+="i"),n.multiline&&(r+="m"),n.dotAll&&(r+="s"),n.unicode&&(r+="u"),n.unicodeSets&&(r+="v"),n.sticky&&(r+="y"),r}}function eo(){if(Qe)return Je;Qe=1;var t,n,r=en(),e=it(),o=no(),i=ro(),u=function(){if(qe)return Ue;qe=1;var t=et(),n=h().RegExp,r=t((function(){var t=n("a","y");return t.lastIndex=2,null!==t.exec("abcd")})),e=r||t((function(){return!n("a","y").sticky})),o=r||t((function(){var t=n("^r","gy");return t.lastIndex=2,null!==t.exec("str")}));return Ue={BROKEN_CARET:o,MISSED_STICKY:e,UNSUPPORTED_Y:r}}(),c=rt(),a=me(),f=Gn().get,l=function(){if(Ke)return Ge;Ke=1;var t=et(),n=h().RegExp;return Ge=t((function(){var t=n(".","s");return!(t.dotAll&&t.test("\n")&&"s"===t.flags)}))}(),s=function(){if(Ye)return Xe;Ye=1;var t=et(),n=h().RegExp;return Xe=t((function(){var t=n("(?<a>b)","g");return"b"!==t.exec("b").groups.a||"bc"!=="b".replace(t,"$<a>c")}))}(),p=c("native-string-replace",String.prototype.replace),v=RegExp.prototype.exec,d=v,y=e("".charAt),m=e("".indexOf),g=e("".replace),b=e("".slice),w=(n=/b*/g,r(v,t=/a/,"a"),r(v,n,"a"),0!==t.lastIndex||0!==n.lastIndex),O=u.BROKEN_CARET,x=void 0!==/()??/.exec("")[1];return(w||x||O||l||s)&&(d=function(t){var n,e,u,c,l,s,h,E=this,S=f(E),j=o(t),T=S.raw;if(T)return T.lastIndex=E.lastIndex,n=r(d,T,j),E.lastIndex=T.lastIndex,n;var L=S.groups,P=O&&E.sticky,I=r(i,E),A=E.source,_=0,M=j;if(P&&(I=g(I,"y",""),-1===m(I,"g")&&(I+="g"),M=b(j,E.lastIndex),E.lastIndex>0&&(!E.multiline||E.multiline&&"\n"!==y(j,E.lastIndex-1))&&(A="(?: "+A+")",M=" "+M,_++),e=new RegExp("^(?:"+A+")",I)),x&&(e=new RegExp("^"+A+"$(?!\\s)",I)),w&&(u=E.lastIndex),c=r(v,P?e:E,M),P?c?(c.input=b(c.input,_),c[0]=b(c[0],_),c.index=E.lastIndex,E.lastIndex+=c[0].length):E.lastIndex=0:w&&c&&(E.lastIndex=E.global?c.index+c[0].length:u),x&&c&&c.length>1&&r(p,c[0],e,(function(){for(l=1;l<arguments.length-2;l++)void 0===arguments[l]&&(c[l]=void 0)})),c&&L)for(c.groups=s=a(null),l=0;l<L.length;l++)s[(h=L[l])[0]]=c[h[1]];return c}),Je=d}!function(){if(Ze)return to;Ze=1;var t=re(),n=eo();t({target:"RegExp",proto:!0,forced:/./.exec!==n},{exec:n})}();var oo,io,uo,co,ao,fo,lo,so={};function po(){return io?oo:(io=1,oo="\t\n\v\f\r                 \u2028\u2029\ufeff")}!function(){if(lo)return so;lo=1;var t=re(),n=function(){if(co)return uo;co=1;var t=it(),n=ct(),r=no(),e=po(),o=t("".replace),i=RegExp("^["+e+"]+"),u=RegExp("(^|[^"+e+"])["+e+"]+$"),c=function(t){return function(e){var c=r(n(e));return 1&t&&(c=o(c,i,"")),2&t&&(c=o(c,u,"$1")),c}};return uo={start:c(1),end:c(2),trim:c(3)}}().trim,r=function(){if(fo)return ao;fo=1;var t=$n().PROPER,n=et(),r=po();return ao=function(e){return n((function(){return!!r[e]()||"​…᠎"!=="​…᠎"[e]()||t&&r[e].name!==e}))}}();t({target:"String",proto:!0,forced:r("trim")},{trim:function(){return n(this)}})}();var vo,ho,yo={};function mo(t){return null!==t&&"object"==typeof t&&"constructor"in t&&t.constructor===Object}function go(t,n){void 0===t&&(t={}),void 0===n&&(n={}),Object.keys(n).forEach((function(r){void 0===t[r]?t[r]=n[r]:mo(n[r])&&mo(t[r])&&Object.keys(n[r]).length>0&&go(t[r],n[r])}))}ho||(ho=1,function(){if(vo)return yo;vo=1;var t=re(),n=h();t({global:!0,forced:n.globalThis!==n},{globalThis:n})}());var bo={body:{},addEventListener:function(){},removeEventListener:function(){},activeElement:{blur:function(){},nodeName:""},querySelector:function(){return null},querySelectorAll:function(){return[]},getElementById:function(){return null},createEvent:function(){return{initEvent:function(){}}},createElement:function(){return{children:[],childNodes:[],style:{},setAttribute:function(){},getElementsByTagName:function(){return[]}}},createElementNS:function(){return{}},importNode:function(){return null},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""}};function wo(){var t="undefined"!=typeof document?document:{};return go(t,bo),t}var Oo={document:bo,navigator:{userAgent:""},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""},history:{replaceState:function(){},pushState:function(){},go:function(){},back:function(){}},CustomEvent:function(){return this},addEventListener:function(){},removeEventListener:function(){},getComputedStyle:function(){return{getPropertyValue:function(){return""}}},Image:function(){},Date:function(){},screen:{},setTimeout:function(){},clearTimeout:function(){},matchMedia:function(){return{}},requestAnimationFrame:function(t){return"undefined"==typeof setTimeout?(t(),null):setTimeout(t,0)},cancelAnimationFrame:function(t){"undefined"!=typeof setTimeout&&clearTimeout(t)}};function xo(){var t="undefined"!=typeof window?window:{};return go(t,Oo),t}function Eo(t){return Eo=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Eo(t)}function So(t,n){return So=Object.setPrototypeOf||function(t,n){return t.__proto__=n,t},So(t,n)}function jo(t,n,r){return jo=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct:function(t,n,r){var e=[null];e.push.apply(e,n);var o=new(Function.bind.apply(t,e));return r&&So(o,r.prototype),o},jo.apply(null,arguments)}function To(t){var n="function"==typeof Map?new Map:void 0;return To=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(t))return n.get(t);n.set(t,e)}function e(){return jo(t,arguments,Eo(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),So(e,t)},To(t)}var Lo=function(t){var n,r;function e(n){var r,e,o;return r=t.call.apply(t,[this].concat(n))||this,e=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(r),o=e.__proto__,Object.defineProperty(e,"__proto__",{get:function(){return o},set:function(t){o.__proto__=t}}),r}return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,n.__proto__=r,e}(To(Array));function Po(t,n){var r=xo(),e=wo(),o=[];if(!n&&t instanceof Lo)return t;if(!t)return new Lo(o);if("string"==typeof t){var i=t.trim();if(i.indexOf("<")>=0&&i.indexOf(">")>=0){var u="div";0===i.indexOf("<li")&&(u="ul"),0===i.indexOf("<tr")&&(u="tbody"),0!==i.indexOf("<td")&&0!==i.indexOf("<th")||(u="tr"),0===i.indexOf("<tbody")&&(u="table"),0===i.indexOf("<option")&&(u="select");var c=e.createElement(u);c.innerHTML=i;for(var a=0;a<c.childNodes.length;a+=1)o.push(c.childNodes[a])}else o=function(t,n){if("string"!=typeof t)return[t];for(var r=[],e=n.querySelectorAll(t),o=0;o<e.length;o+=1)r.push(e[o]);return r}(t.trim(),n||e)}else if(t.nodeType||t===r||t===e)o.push(t);else if(Array.isArray(t)){if(t instanceof Lo)return t;o=t}return new Lo(function(t){for(var n=[],r=0;r<t.length;r+=1)-1===n.indexOf(t[r])&&n.push(t[r]);return n}(o))}function Io(t){if(void 0===t){var n=this[0];if(!n)return;if(n.multiple&&"select"===n.nodeName.toLowerCase()){for(var r=[],e=0;e<n.selectedOptions.length;e+=1)r.push(n.selectedOptions[e].value);return r}return n.value}for(var o=0;o<this.length;o+=1){var i=this[o];if(Array.isArray(t)&&i.multiple&&"select"===i.nodeName.toLowerCase())for(var u=0;u<i.options.length;u+=1)i.options[u].selected=t.indexOf(i.options[u].value)>=0;else i.value=t}return this}function Ao(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var e=n[0],o=n[1],i=n[2],u=n[3];function c(t){var n=t.target;if(n){var r=t.target.dom7EventData||[];if(r.indexOf(t)<0&&r.unshift(t),Po(n).is(o))i.apply(n,r);else for(var e=Po(n).parents(),u=0;u<e.length;u+=1)Po(e[u]).is(o)&&i.apply(e[u],r)}}function a(t){var n=t&&t.target&&t.target.dom7EventData||[];n.indexOf(t)<0&&n.unshift(t),i.apply(this,n)}"function"==typeof n[1]&&(e=n[0],i=n[1],u=n[2],o=void 0),u||(u=!1);for(var f,l=e.split(" "),s=0;s<this.length;s+=1){var p=this[s];if(o)for(f=0;f<l.length;f+=1){var v=l[f];p.dom7LiveListeners||(p.dom7LiveListeners={}),p.dom7LiveListeners[v]||(p.dom7LiveListeners[v]=[]),p.dom7LiveListeners[v].push({listener:i,proxyListener:c}),p.addEventListener(v,c,u)}else for(f=0;f<l.length;f+=1){var d=l[f];p.dom7Listeners||(p.dom7Listeners={}),p.dom7Listeners[d]||(p.dom7Listeners[d]=[]),p.dom7Listeners[d].push({listener:i,proxyListener:a}),p.addEventListener(d,a,u)}}return this}function _o(t){if(void 0===t)return this[0]?this[0].innerHTML:null;for(var n=0;n<this.length;n+=1)this[n].innerHTML=t;return this}function Mo(t){var n,r,e=xo(),o=wo(),i=this[0];if(!i||void 0===t)return!1;if("string"==typeof t){if(i.matches)return i.matches(t);if(i.webkitMatchesSelector)return i.webkitMatchesSelector(t);if(i.msMatchesSelector)return i.msMatchesSelector(t);for(n=Po(t),r=0;r<n.length;r+=1)if(n[r]===i)return!0;return!1}if(t===o)return i===o;if(t===e)return i===e;if(t.nodeType||t instanceof Lo){for(n=t.nodeType?[t]:t,r=0;r<n.length;r+=1)if(n[r]===i)return!0;return!1}return!1}function Ro(){for(var t,n=wo(),r=0;r<arguments.length;r+=1){t=r<0||arguments.length<=r?void 0:arguments[r];for(var e=0;e<this.length;e+=1)if("string"==typeof t){var o=n.createElement("div");for(o.innerHTML=t;o.firstChild;)this[e].appendChild(o.firstChild)}else if(t instanceof Lo)for(var i=0;i<t.length;i+=1)this[e].appendChild(t[i]);else this[e].appendChild(t)}return this}function Co(t){for(var n=[],r=0;r<this.length;r+=1)for(var e=this[r].parentNode;e;)t?Po(e).is(t)&&n.push(e):n.push(e),e=e.parentNode;return Po(n)}function ko(t){for(var n=[],r=0;r<this.length;r+=1)for(var e=this[r].querySelectorAll(t),o=0;o<e.length;o+=1)n.push(e[o]);return Po(n)}Po.fn=Lo.prototype;var No="resize scroll".split(" ");var Fo,Do=(Fo="focus",function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];if(void 0===n[0]){for(var e=0;e<this.length;e+=1)No.indexOf(Fo)<0&&(Fo in this[e]?this[e][Fo]():Po(this[e]).trigger(Fo));return this}return this.on.apply(this,[Fo].concat(n))});Ro&&(Po.fn.append=Ro),_o&&(Po.fn.html=_o),Io&&(Po.fn.val=Io),Ao&&(Po.fn.on=Ao),Do&&(Po.fn.focus=Do),Mo&&(Po.fn.is=Mo),Co&&(Po.fn.parents=Co),ko&&(Po.fn.find=ko);var Ho,zo,$o,Vo,Bo,Wo,Uo,qo={};function Go(){if(zo)return Ho;zo=1;var t=TypeError;return Ho=function(n){if(n>9007199254740991)throw t("Maximum allowed index exceeded");return n}}function Ko(){if(Vo)return $o;Vo=1;var t=Jt(),n=vn(),r=Bn();return $o=function(e,o,i){t?n.f(e,o,r(0,i)):e[o]=i}}function Xo(){if(Wo)return Bo;Wo=1;var t=et(),n=dt(),r=st(),e=n("species");return Bo=function(n){return r>=51||!t((function(){var t=[];return(t.constructor={})[e]=function(){return{foo:1}},1!==t[n](Boolean).foo}))}}!function(){if(Uo)return qo;Uo=1;var t=re(),n=et(),r=Fe(),e=Qt(),o=at(),i=_r(),u=Go(),c=Ko(),a=He(),f=Xo(),l=dt(),s=st(),p=l("isConcatSpreadable"),v=s>=51||!n((function(){var t=[];return t[p]=!1,t.concat()[0]!==t})),d=function(t){if(!e(t))return!1;var n=t[p];return void 0!==n?!!n:r(t)};t({target:"Array",proto:!0,arity:1,forced:!v||!f("concat")},{concat:function(t){var n,r,e,f,l,s=o(this),p=a(s,0),v=0;for(n=-1,e=arguments.length;n<e;n++)if(d(l=-1===n?s:arguments[n]))for(f=i(l),u(v+f),r=0;r<f;r++,v++)r in l&&c(p,v,l[r]);else u(v+1),c(p,v++,l);return p.length=v,p}})}();let Yo=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce(((t,n)=>t+=(n&=63)<36?n.toString(36):n<62?(n-26).toString(36).toUpperCase():n>62?"-":"_"),"");function Jo(t){return"".concat(t,"-").concat(Yo())}function Qo(){return Jo("w-e-insert-formula")}var Zo=function(){function t(){this.title=r("formula.edit"),this.iconSvg='<svg viewBox="0 0 1024 1024"><path d="M864 0a160 160 0 0 1 128 256l-64 64-224-224 64-64c26.752-20.096 59.968-32 96-32zM64 736l-64 288 288-64 592-592-224-224L64 736z m651.584-372.416l-448 448-55.168-55.168 448-448 55.168 55.168z"></path></svg>',this.tag="button",this.showModal=!0,this.modalWidth=300,this.$content=null,this.textareaId=Qo(),this.buttonId=Qo()}return t.prototype.getSelectedElem=function(t){var n=e.getSelectedNodeByType(t,"formula");return null==n?null:n},t.prototype.getValue=function(t){var n=this.getSelectedElem(t);return n&&n.value||""},t.prototype.isActive=function(t){return!1},t.prototype.exec=function(t,n){},t.prototype.isDisabled=function(t){var n=t.selection;return null==n||(!!o.isExpanded(n)||null==this.getSelectedElem(t))},t.prototype.getModalPositionNode=function(t){return this.getSelectedElem(t)},t.prototype.getModalContentElem=function(t){var n=this,e=this.textareaId,o=this.buttonId,c=l(i(r("formula.formula"),e,r("formula.placeholder")),2),a=c[0],f=Po(c[1]),s=l(u(o,r("formula.ok")),1)[0];if(null==this.$content){var p=Po("<div></div>");p.on("click","#".concat(o),(function(r){r.preventDefault();var o=p.find("#".concat(e)).val().trim();n.updateFormula(t,o),t.hidePanelOrModal()})),this.$content=p}var v=this.$content;v.html(""),v.append(a),v.append(s);var d=this.getValue(t);return f.val(d),setTimeout((function(){f.focus()})),v[0]},t.prototype.updateFormula=function(t,n){if(n&&(t.restoreSelection(),!this.isDisabled(t))){var r=this.getSelectedElem(t);if(null!=r){var o=e.findPath(t,r),i={value:n};c.setNodes(t,i,{at:o})}}},t}();function ti(){return Jo("w-e-insert-formula")}var ni=function(){function t(){this.title=r("formula.insert"),this.iconSvg='<svg viewBox="0 0 1024 1024"><path d="M941.6 734.72L985.984 640H1024l-64 384H0v-74.24l331.552-391.2L0 227.008V0h980L1024 256h-34.368l-18.72-38.88C935.584 143.744 909.024 128 832 128H169.984l353.056 353.056L225.632 832H768c116 0 146.656-41.568 173.6-97.28z"></path></svg>',this.tag="button",this.showModal=!0,this.modalWidth=300,this.$content=null,this.textareaId=ti(),this.buttonId=ti()}return t.prototype.getValue=function(t){return""},t.prototype.isActive=function(t){return!1},t.prototype.exec=function(t,n){},t.prototype.isDisabled=function(t){var n=t.selection;if(null==n)return!0;if(o.isExpanded(n))return!0;var r=e.getSelectedElems(t);return!!r.some((function(n){return t.isVoid(n)}))||!!r.some((function(t){return"pre"===e.getNodeType(t)}))},t.prototype.getModalPositionNode=function(t){return null},t.prototype.getModalContentElem=function(t){var n=this,e=this.textareaId,o=this.buttonId,c=l(i(r("formula.formula"),e,r("formula.placeholder")),2),a=c[0],f=Po(c[1]),s=l(u(o,r("formula.ok")),1)[0];if(null==this.$content){var p=Po("<div></div>");p.on("click","#".concat(o),(function(r){r.preventDefault();var o=p.find("#".concat(e)).val().trim();n.insertFormula(t,o),t.hidePanelOrModal()})),this.$content=p}var v=this.$content;return v.html(""),v.append(a),v.append(s),f.val(""),setTimeout((function(){f.focus()})),v[0]},t.prototype.insertFormula=function(t,n){if(n&&(t.restoreSelection(),!this.isDisabled(t))){var r={type:"formula",value:n,children:[{text:""}]};t.insertNode(r)}},t}();var ri={editorPlugin:function(t){var n=t.isInline,r=t.isVoid,o=t;return o.isInline=function(t){return"formula"===e.getNodeType(t)||n(t)},o.isVoid=function(t){return"formula"===e.getNodeType(t)||r(t)},o},renderElems:[{type:"formula",renderElem:function(t,n,r){var o=e.isNodeSelected(r,t),i=t.value,u=a("w-e-formula-card",{dataset:{value:void 0===i?"":i}},null);return a("div",{props:{contentEditable:!1},style:{display:"inline-block",marginLeft:"3px",marginRight:"3px",border:o?"2px solid var(--w-e-textarea-selected-border-color)":"2px solid transparent",borderRadius:"3px",padding:"3px 3px"}},[u])}}],elemsToHtml:[Ce],parseElemsHtml:[{selector:'span[data-w-e-type="formula"]',parseElemHtml:function(t,n,r){return{type:"formula",value:t.getAttribute("data-value")||"",children:[{text:""}]}}}],menus:[{key:"insertFormula",factory:function(){return new ni}},{key:"editFormula",factory:function(){return new Zo}}]};export{ri as default};
2
- //# sourceMappingURL=index.mjs.map
1
+ import katex from 'katex';
2
+ import { i18nAddResources, t, DomEditor, SlateRange, genModalTextareaElems, genModalButtonElems, SlateTransforms } from '@wangeditor-next/editor';
3
+ import { h } from 'snabbdom';
4
+
5
+ /******************************************************************************
6
+ Copyright (c) Microsoft Corporation.
7
+
8
+ Permission to use, copy, modify, and/or distribute this software for any
9
+ purpose with or without fee is hereby granted.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
+ PERFORMANCE OF THIS SOFTWARE.
18
+ ***************************************************************************** */
19
+ /* global Reflect, Promise, SuppressedError, Symbol */
20
+
21
+ var extendStatics = function(d, b) {
22
+ extendStatics = Object.setPrototypeOf ||
23
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
24
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
25
+ return extendStatics(d, b);
26
+ };
27
+
28
+ function __extends(d, b) {
29
+ if (typeof b !== "function" && b !== null)
30
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
31
+ extendStatics(d, b);
32
+ function __() { this.constructor = d; }
33
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34
+ }
35
+
36
+ function __read(o, n) {
37
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
38
+ if (!m) return o;
39
+ var i = m.call(o), r, ar = [], e;
40
+ try {
41
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
42
+ }
43
+ catch (error) { e = { error: error }; }
44
+ finally {
45
+ try {
46
+ if (r && !r.done && (m = i["return"])) m.call(i);
47
+ }
48
+ finally { if (e) throw e.error; }
49
+ }
50
+ return ar;
51
+ }
52
+
53
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
54
+ var e = new Error(message);
55
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
56
+ };
57
+
58
+ // @ts-nocheck
59
+ // 参考 https://github.com/webcomponents/custom-elements/blob/master/src/native-shim.js
60
+ /**
61
+ * @license
62
+ * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
63
+ * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
64
+ * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
65
+ * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
66
+ * Code distributed by Google as part of the polymer project is also
67
+ * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
68
+ */
69
+ /**
70
+ * This shim allows elements written in, or compiled to, ES5 to work on native
71
+ * implementations of Custom Elements v1. It sets new.target to the value of
72
+ * this.constructor so that the native HTMLElement constructor can access the
73
+ * current under-construction element's definition.
74
+ */
75
+ (function () {
76
+ if (
77
+ // No Reflect, no classes, no need for shim because native custom elements
78
+ // require ES2015 classes or Reflect.
79
+ window.Reflect === undefined
80
+ || window.customElements === undefined
81
+ // The webcomponentsjs custom elements polyfill doesn't require
82
+ // ES2015-compatible construction (`super()` or `Reflect.construct`).
83
+ || window.customElements.polyfillWrapFlushCallback) {
84
+ return;
85
+ }
86
+ var BuiltInHTMLElement = HTMLElement;
87
+ /**
88
+ * With jscompiler's RECOMMENDED_FLAGS the function name will be optimized away.
89
+ * However, if we declare the function as a property on an object literal, and
90
+ * use quotes for the property name, then closure will leave that much intact,
91
+ * which is enough for the JS VM to correctly set Function.prototype.name.
92
+ */
93
+ var wrapperForTheName = {
94
+ // eslint-disable-next-line func-names
95
+ HTMLElement: /** @this {!Object} */ function HTMLElement() {
96
+ return Reflect.construct(BuiltInHTMLElement, [], /** @type {!Function} */ this.constructor);
97
+ },
98
+ };
99
+ window.HTMLElement = wrapperForTheName.HTMLElement;
100
+ HTMLElement.prototype = BuiltInHTMLElement.prototype;
101
+ HTMLElement.prototype.constructor = HTMLElement;
102
+ Object.setPrototypeOf(HTMLElement, BuiltInHTMLElement);
103
+ }());
104
+
105
+ var katexStyleContent = undefined;
106
+
107
+ /**
108
+ * @description 注册自定义 elem
109
+ * @author wangfupeng
110
+ */
111
+ var WangEditorFormulaCard = /** @class */ (function (_super) {
112
+ __extends(WangEditorFormulaCard, _super);
113
+ function WangEditorFormulaCard() {
114
+ var _this = _super.call(this) || this;
115
+ var shadow = _this.attachShadow({ mode: 'open' });
116
+ var document = shadow.ownerDocument;
117
+ var style = document.createElement('style');
118
+ style.innerHTML = katexStyleContent; // 加载 css 文本
119
+ shadow.appendChild(style);
120
+ var span = document.createElement('span');
121
+ span.style.display = 'inline-block';
122
+ shadow.appendChild(span);
123
+ _this.span = span;
124
+ return _this;
125
+ }
126
+ Object.defineProperty(WangEditorFormulaCard, "observedAttributes", {
127
+ // 监听的 attr
128
+ get: function () {
129
+ return ['data-value'];
130
+ },
131
+ enumerable: false,
132
+ configurable: true
133
+ });
134
+ WangEditorFormulaCard.prototype.attributeChangedCallback = function (name, oldValue, newValue) {
135
+ if (name === 'data-value') {
136
+ if (oldValue === newValue) {
137
+ return;
138
+ }
139
+ this.render(newValue || '');
140
+ }
141
+ };
142
+ WangEditorFormulaCard.prototype.render = function (value) {
143
+ katex.render(value, this.span, {
144
+ throwOnError: false,
145
+ });
146
+ };
147
+ return WangEditorFormulaCard;
148
+ }(HTMLElement));
149
+ if (!window.customElements.get('w-e-formula-card')) {
150
+ window.customElements.define('w-e-formula-card', WangEditorFormulaCard);
151
+ }
152
+
153
+ /**
154
+ * @description 多语言
155
+ * @author wangfupeng
156
+ */
157
+ i18nAddResources('en', {
158
+ formula: {
159
+ formula: 'Formula',
160
+ placeholder: 'Use LateX syntax',
161
+ insert: 'Insert formula',
162
+ edit: 'Edit formula',
163
+ ok: 'OK',
164
+ },
165
+ });
166
+ i18nAddResources('zh-CN', {
167
+ formula: {
168
+ formula: '公式',
169
+ placeholder: '使用 LateX 语法',
170
+ insert: '插入公式',
171
+ edit: '编辑公式',
172
+ ok: '确定',
173
+ },
174
+ });
175
+
176
+ /**
177
+ * @description elem to html
178
+ * @author wangfupeng
179
+ */
180
+ // 生成 html 的函数
181
+ function formulaToHtml(elem, _childrenHtml) {
182
+ var _a = elem.value, value = _a === void 0 ? '' : _a;
183
+ return "<span data-w-e-type=\"formula\" data-w-e-is-void data-w-e-is-inline data-value=\"".concat(value, "\"></span>");
184
+ }
185
+ // 配置
186
+ var conf$1 = {
187
+ type: 'formula', // 节点 type ,重要!!!
188
+ elemToHtml: formulaToHtml,
189
+ };
190
+
191
+ /**
192
+ * @description icon svg
193
+ * @author wangfupeng
194
+ */
195
+ /**
196
+ * 【注意】svg 字符串的长度 ,否则会导致代码体积过大
197
+ * 尽量选择 https://www.iconfont.cn/collections/detail?spm=a313x.7781069.0.da5a778a4&cid=20293
198
+ * 找不到再从 iconfont.com 搜索
199
+ */
200
+ // 公式
201
+ var SIGMA_SVG = '<svg viewBox="0 0 1024 1024"><path d="M941.6 734.72L985.984 640H1024l-64 384H0v-74.24l331.552-391.2L0 227.008V0h980L1024 256h-34.368l-18.72-38.88C935.584 143.744 909.024 128 832 128H169.984l353.056 353.056L225.632 832H768c116 0 146.656-41.568 173.6-97.28z"></path></svg>';
202
+ // 编辑
203
+ var PENCIL_SVG = '<svg viewBox="0 0 1024 1024"><path d="M864 0a160 160 0 0 1 128 256l-64 64-224-224 64-64c26.752-20.096 59.968-32 96-32zM64 736l-64 288 288-64 592-592-224-224L64 736z m651.584-372.416l-448 448-55.168-55.168 448-448 55.168 55.168z"></path></svg>';
204
+
205
+ /**
206
+ * SSR Window 3.0.0
207
+ * Better handling for window object in SSR environment
208
+ * https://github.com/nolimits4web/ssr-window
209
+ *
210
+ * Copyright 2020, Vladimir Kharlampidi
211
+ *
212
+ * Licensed under MIT
213
+ *
214
+ * Released on: November 9, 2020
215
+ */
216
+ /* eslint-disable no-param-reassign */
217
+ function isObject(obj) {
218
+ return (obj !== null &&
219
+ typeof obj === 'object' &&
220
+ 'constructor' in obj &&
221
+ obj.constructor === Object);
222
+ }
223
+ function extend(target, src) {
224
+ if (target === void 0) { target = {}; }
225
+ if (src === void 0) { src = {}; }
226
+ Object.keys(src).forEach(function (key) {
227
+ if (typeof target[key] === 'undefined')
228
+ target[key] = src[key];
229
+ else if (isObject(src[key]) &&
230
+ isObject(target[key]) &&
231
+ Object.keys(src[key]).length > 0) {
232
+ extend(target[key], src[key]);
233
+ }
234
+ });
235
+ }
236
+
237
+ var ssrDocument = {
238
+ body: {},
239
+ addEventListener: function () { },
240
+ removeEventListener: function () { },
241
+ activeElement: {
242
+ blur: function () { },
243
+ nodeName: '',
244
+ },
245
+ querySelector: function () {
246
+ return null;
247
+ },
248
+ querySelectorAll: function () {
249
+ return [];
250
+ },
251
+ getElementById: function () {
252
+ return null;
253
+ },
254
+ createEvent: function () {
255
+ return {
256
+ initEvent: function () { },
257
+ };
258
+ },
259
+ createElement: function () {
260
+ return {
261
+ children: [],
262
+ childNodes: [],
263
+ style: {},
264
+ setAttribute: function () { },
265
+ getElementsByTagName: function () {
266
+ return [];
267
+ },
268
+ };
269
+ },
270
+ createElementNS: function () {
271
+ return {};
272
+ },
273
+ importNode: function () {
274
+ return null;
275
+ },
276
+ location: {
277
+ hash: '',
278
+ host: '',
279
+ hostname: '',
280
+ href: '',
281
+ origin: '',
282
+ pathname: '',
283
+ protocol: '',
284
+ search: '',
285
+ },
286
+ };
287
+ function getDocument() {
288
+ var doc = typeof document !== 'undefined' ? document : {};
289
+ extend(doc, ssrDocument);
290
+ return doc;
291
+ }
292
+
293
+ var ssrWindow = {
294
+ document: ssrDocument,
295
+ navigator: {
296
+ userAgent: '',
297
+ },
298
+ location: {
299
+ hash: '',
300
+ host: '',
301
+ hostname: '',
302
+ href: '',
303
+ origin: '',
304
+ pathname: '',
305
+ protocol: '',
306
+ search: '',
307
+ },
308
+ history: {
309
+ replaceState: function () { },
310
+ pushState: function () { },
311
+ go: function () { },
312
+ back: function () { },
313
+ },
314
+ CustomEvent: function CustomEvent() {
315
+ return this;
316
+ },
317
+ addEventListener: function () { },
318
+ removeEventListener: function () { },
319
+ getComputedStyle: function () {
320
+ return {
321
+ getPropertyValue: function () {
322
+ return '';
323
+ },
324
+ };
325
+ },
326
+ Image: function () { },
327
+ Date: function () { },
328
+ screen: {},
329
+ setTimeout: function () { },
330
+ clearTimeout: function () { },
331
+ matchMedia: function () {
332
+ return {};
333
+ },
334
+ requestAnimationFrame: function (callback) {
335
+ if (typeof setTimeout === 'undefined') {
336
+ callback();
337
+ return null;
338
+ }
339
+ return setTimeout(callback, 0);
340
+ },
341
+ cancelAnimationFrame: function (id) {
342
+ if (typeof setTimeout === 'undefined') {
343
+ return;
344
+ }
345
+ clearTimeout(id);
346
+ },
347
+ };
348
+ function getWindow() {
349
+ var win = typeof window !== 'undefined' ? window : {};
350
+ extend(win, ssrWindow);
351
+ return win;
352
+ }
353
+
354
+ /**
355
+ * Dom7 3.0.0
356
+ * Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API
357
+ * https://framework7.io/docs/dom7.html
358
+ *
359
+ * Copyright 2020, Vladimir Kharlampidi
360
+ *
361
+ * Licensed under MIT
362
+ *
363
+ * Released on: November 9, 2020
364
+ */
365
+
366
+ function _inheritsLoose(subClass, superClass) {
367
+ subClass.prototype = Object.create(superClass.prototype);
368
+ subClass.prototype.constructor = subClass;
369
+ subClass.__proto__ = superClass;
370
+ }
371
+
372
+ function _getPrototypeOf(o) {
373
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
374
+ return o.__proto__ || Object.getPrototypeOf(o);
375
+ };
376
+ return _getPrototypeOf(o);
377
+ }
378
+
379
+ function _setPrototypeOf(o, p) {
380
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
381
+ o.__proto__ = p;
382
+ return o;
383
+ };
384
+
385
+ return _setPrototypeOf(o, p);
386
+ }
387
+
388
+ function _isNativeReflectConstruct() {
389
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
390
+ if (Reflect.construct.sham) return false;
391
+ if (typeof Proxy === "function") return true;
392
+
393
+ try {
394
+ Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
395
+ return true;
396
+ } catch (e) {
397
+ return false;
398
+ }
399
+ }
400
+
401
+ function _construct(Parent, args, Class) {
402
+ if (_isNativeReflectConstruct()) {
403
+ _construct = Reflect.construct;
404
+ } else {
405
+ _construct = function _construct(Parent, args, Class) {
406
+ var a = [null];
407
+ a.push.apply(a, args);
408
+ var Constructor = Function.bind.apply(Parent, a);
409
+ var instance = new Constructor();
410
+ if (Class) _setPrototypeOf(instance, Class.prototype);
411
+ return instance;
412
+ };
413
+ }
414
+
415
+ return _construct.apply(null, arguments);
416
+ }
417
+
418
+ function _isNativeFunction(fn) {
419
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
420
+ }
421
+
422
+ function _wrapNativeSuper(Class) {
423
+ var _cache = typeof Map === "function" ? new Map() : undefined;
424
+
425
+ _wrapNativeSuper = function _wrapNativeSuper(Class) {
426
+ if (Class === null || !_isNativeFunction(Class)) return Class;
427
+
428
+ if (typeof Class !== "function") {
429
+ throw new TypeError("Super expression must either be null or a function");
430
+ }
431
+
432
+ if (typeof _cache !== "undefined") {
433
+ if (_cache.has(Class)) return _cache.get(Class);
434
+
435
+ _cache.set(Class, Wrapper);
436
+ }
437
+
438
+ function Wrapper() {
439
+ return _construct(Class, arguments, _getPrototypeOf(this).constructor);
440
+ }
441
+
442
+ Wrapper.prototype = Object.create(Class.prototype, {
443
+ constructor: {
444
+ value: Wrapper,
445
+ enumerable: false,
446
+ writable: true,
447
+ configurable: true
448
+ }
449
+ });
450
+ return _setPrototypeOf(Wrapper, Class);
451
+ };
452
+
453
+ return _wrapNativeSuper(Class);
454
+ }
455
+
456
+ function _assertThisInitialized(self) {
457
+ if (self === void 0) {
458
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
459
+ }
460
+
461
+ return self;
462
+ }
463
+
464
+ /* eslint-disable no-proto */
465
+ function makeReactive(obj) {
466
+ var proto = obj.__proto__;
467
+ Object.defineProperty(obj, '__proto__', {
468
+ get: function get() {
469
+ return proto;
470
+ },
471
+ set: function set(value) {
472
+ proto.__proto__ = value;
473
+ }
474
+ });
475
+ }
476
+
477
+ var Dom7 = /*#__PURE__*/function (_Array) {
478
+ _inheritsLoose(Dom7, _Array);
479
+
480
+ function Dom7(items) {
481
+ var _this;
482
+
483
+ _this = _Array.call.apply(_Array, [this].concat(items)) || this;
484
+ makeReactive(_assertThisInitialized(_this));
485
+ return _this;
486
+ }
487
+
488
+ return Dom7;
489
+ }( /*#__PURE__*/_wrapNativeSuper(Array));
490
+ function arrayUnique(arr) {
491
+ var uniqueArray = [];
492
+
493
+ for (var i = 0; i < arr.length; i += 1) {
494
+ if (uniqueArray.indexOf(arr[i]) === -1) uniqueArray.push(arr[i]);
495
+ }
496
+
497
+ return uniqueArray;
498
+ }
499
+
500
+ function qsa(selector, context) {
501
+ if (typeof selector !== 'string') {
502
+ return [selector];
503
+ }
504
+
505
+ var a = [];
506
+ var res = context.querySelectorAll(selector);
507
+
508
+ for (var i = 0; i < res.length; i += 1) {
509
+ a.push(res[i]);
510
+ }
511
+
512
+ return a;
513
+ }
514
+
515
+ function $(selector, context) {
516
+ var window = getWindow();
517
+ var document = getDocument();
518
+ var arr = [];
519
+
520
+ if (!context && selector instanceof Dom7) {
521
+ return selector;
522
+ }
523
+
524
+ if (!selector) {
525
+ return new Dom7(arr);
526
+ }
527
+
528
+ if (typeof selector === 'string') {
529
+ var html = selector.trim();
530
+
531
+ if (html.indexOf('<') >= 0 && html.indexOf('>') >= 0) {
532
+ var toCreate = 'div';
533
+ if (html.indexOf('<li') === 0) toCreate = 'ul';
534
+ if (html.indexOf('<tr') === 0) toCreate = 'tbody';
535
+ if (html.indexOf('<td') === 0 || html.indexOf('<th') === 0) toCreate = 'tr';
536
+ if (html.indexOf('<tbody') === 0) toCreate = 'table';
537
+ if (html.indexOf('<option') === 0) toCreate = 'select';
538
+ var tempParent = document.createElement(toCreate);
539
+ tempParent.innerHTML = html;
540
+
541
+ for (var i = 0; i < tempParent.childNodes.length; i += 1) {
542
+ arr.push(tempParent.childNodes[i]);
543
+ }
544
+ } else {
545
+ arr = qsa(selector.trim(), context || document);
546
+ } // arr = qsa(selector, document);
547
+
548
+ } else if (selector.nodeType || selector === window || selector === document) {
549
+ arr.push(selector);
550
+ } else if (Array.isArray(selector)) {
551
+ if (selector instanceof Dom7) return selector;
552
+ arr = selector;
553
+ }
554
+
555
+ return new Dom7(arrayUnique(arr));
556
+ }
557
+
558
+ $.fn = Dom7.prototype;
559
+
560
+ function val(value) {
561
+ if (typeof value === 'undefined') {
562
+ // get value
563
+ var el = this[0];
564
+ if (!el) return undefined;
565
+
566
+ if (el.multiple && el.nodeName.toLowerCase() === 'select') {
567
+ var values = [];
568
+
569
+ for (var i = 0; i < el.selectedOptions.length; i += 1) {
570
+ values.push(el.selectedOptions[i].value);
571
+ }
572
+
573
+ return values;
574
+ }
575
+
576
+ return el.value;
577
+ } // set value
578
+
579
+
580
+ for (var _i = 0; _i < this.length; _i += 1) {
581
+ var _el = this[_i];
582
+
583
+ if (Array.isArray(value) && _el.multiple && _el.nodeName.toLowerCase() === 'select') {
584
+ for (var j = 0; j < _el.options.length; j += 1) {
585
+ _el.options[j].selected = value.indexOf(_el.options[j].value) >= 0;
586
+ }
587
+ } else {
588
+ _el.value = value;
589
+ }
590
+ }
591
+
592
+ return this;
593
+ }
594
+
595
+ function on() {
596
+ for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
597
+ args[_key5] = arguments[_key5];
598
+ }
599
+
600
+ var eventType = args[0],
601
+ targetSelector = args[1],
602
+ listener = args[2],
603
+ capture = args[3];
604
+
605
+ if (typeof args[1] === 'function') {
606
+ eventType = args[0];
607
+ listener = args[1];
608
+ capture = args[2];
609
+ targetSelector = undefined;
610
+ }
611
+
612
+ if (!capture) capture = false;
613
+
614
+ function handleLiveEvent(e) {
615
+ var target = e.target;
616
+ if (!target) return;
617
+ var eventData = e.target.dom7EventData || [];
618
+
619
+ if (eventData.indexOf(e) < 0) {
620
+ eventData.unshift(e);
621
+ }
622
+
623
+ if ($(target).is(targetSelector)) listener.apply(target, eventData);else {
624
+ var _parents = $(target).parents(); // eslint-disable-line
625
+
626
+
627
+ for (var k = 0; k < _parents.length; k += 1) {
628
+ if ($(_parents[k]).is(targetSelector)) listener.apply(_parents[k], eventData);
629
+ }
630
+ }
631
+ }
632
+
633
+ function handleEvent(e) {
634
+ var eventData = e && e.target ? e.target.dom7EventData || [] : [];
635
+
636
+ if (eventData.indexOf(e) < 0) {
637
+ eventData.unshift(e);
638
+ }
639
+
640
+ listener.apply(this, eventData);
641
+ }
642
+
643
+ var events = eventType.split(' ');
644
+ var j;
645
+
646
+ for (var i = 0; i < this.length; i += 1) {
647
+ var el = this[i];
648
+
649
+ if (!targetSelector) {
650
+ for (j = 0; j < events.length; j += 1) {
651
+ var event = events[j];
652
+ if (!el.dom7Listeners) el.dom7Listeners = {};
653
+ if (!el.dom7Listeners[event]) el.dom7Listeners[event] = [];
654
+ el.dom7Listeners[event].push({
655
+ listener: listener,
656
+ proxyListener: handleEvent
657
+ });
658
+ el.addEventListener(event, handleEvent, capture);
659
+ }
660
+ } else {
661
+ // Live events
662
+ for (j = 0; j < events.length; j += 1) {
663
+ var _event = events[j];
664
+ if (!el.dom7LiveListeners) el.dom7LiveListeners = {};
665
+ if (!el.dom7LiveListeners[_event]) el.dom7LiveListeners[_event] = [];
666
+
667
+ el.dom7LiveListeners[_event].push({
668
+ listener: listener,
669
+ proxyListener: handleLiveEvent
670
+ });
671
+
672
+ el.addEventListener(_event, handleLiveEvent, capture);
673
+ }
674
+ }
675
+ }
676
+
677
+ return this;
678
+ }
679
+
680
+ function html(html) {
681
+ if (typeof html === 'undefined') {
682
+ return this[0] ? this[0].innerHTML : null;
683
+ }
684
+
685
+ for (var i = 0; i < this.length; i += 1) {
686
+ this[i].innerHTML = html;
687
+ }
688
+
689
+ return this;
690
+ }
691
+
692
+ function is(selector) {
693
+ var window = getWindow();
694
+ var document = getDocument();
695
+ var el = this[0];
696
+ var compareWith;
697
+ var i;
698
+ if (!el || typeof selector === 'undefined') return false;
699
+
700
+ if (typeof selector === 'string') {
701
+ if (el.matches) return el.matches(selector);
702
+ if (el.webkitMatchesSelector) return el.webkitMatchesSelector(selector);
703
+ if (el.msMatchesSelector) return el.msMatchesSelector(selector);
704
+ compareWith = $(selector);
705
+
706
+ for (i = 0; i < compareWith.length; i += 1) {
707
+ if (compareWith[i] === el) return true;
708
+ }
709
+
710
+ return false;
711
+ }
712
+
713
+ if (selector === document) {
714
+ return el === document;
715
+ }
716
+
717
+ if (selector === window) {
718
+ return el === window;
719
+ }
720
+
721
+ if (selector.nodeType || selector instanceof Dom7) {
722
+ compareWith = selector.nodeType ? [selector] : selector;
723
+
724
+ for (i = 0; i < compareWith.length; i += 1) {
725
+ if (compareWith[i] === el) return true;
726
+ }
727
+
728
+ return false;
729
+ }
730
+
731
+ return false;
732
+ }
733
+
734
+ function append() {
735
+ var newChild;
736
+ var document = getDocument();
737
+
738
+ for (var k = 0; k < arguments.length; k += 1) {
739
+ newChild = k < 0 || arguments.length <= k ? undefined : arguments[k];
740
+
741
+ for (var i = 0; i < this.length; i += 1) {
742
+ if (typeof newChild === 'string') {
743
+ var tempDiv = document.createElement('div');
744
+ tempDiv.innerHTML = newChild;
745
+
746
+ while (tempDiv.firstChild) {
747
+ this[i].appendChild(tempDiv.firstChild);
748
+ }
749
+ } else if (newChild instanceof Dom7) {
750
+ for (var j = 0; j < newChild.length; j += 1) {
751
+ this[i].appendChild(newChild[j]);
752
+ }
753
+ } else {
754
+ this[i].appendChild(newChild);
755
+ }
756
+ }
757
+ }
758
+
759
+ return this;
760
+ }
761
+
762
+ function parents(selector) {
763
+ var parents = []; // eslint-disable-line
764
+
765
+ for (var i = 0; i < this.length; i += 1) {
766
+ var _parent = this[i].parentNode; // eslint-disable-line
767
+
768
+ while (_parent) {
769
+ if (selector) {
770
+ if ($(_parent).is(selector)) parents.push(_parent);
771
+ } else {
772
+ parents.push(_parent);
773
+ }
774
+
775
+ _parent = _parent.parentNode;
776
+ }
777
+ }
778
+
779
+ return $(parents);
780
+ }
781
+
782
+ function find(selector) {
783
+ var foundElements = [];
784
+
785
+ for (var i = 0; i < this.length; i += 1) {
786
+ var found = this[i].querySelectorAll(selector);
787
+
788
+ for (var j = 0; j < found.length; j += 1) {
789
+ foundElements.push(found[j]);
790
+ }
791
+ }
792
+
793
+ return $(foundElements);
794
+ }
795
+
796
+ var noTrigger = 'resize scroll'.split(' ');
797
+
798
+ function shortcut(name) {
799
+ function eventHandler() {
800
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
801
+ args[_key] = arguments[_key];
802
+ }
803
+
804
+ if (typeof args[0] === 'undefined') {
805
+ for (var i = 0; i < this.length; i += 1) {
806
+ if (noTrigger.indexOf(name) < 0) {
807
+ if (name in this[i]) this[i][name]();else {
808
+ $(this[i]).trigger(name);
809
+ }
810
+ }
811
+ }
812
+
813
+ return this;
814
+ }
815
+
816
+ return this.on.apply(this, [name].concat(args));
817
+ }
818
+
819
+ return eventHandler;
820
+ }
821
+ var focus = shortcut('focus');
822
+
823
+ /**
824
+ * @description DOM 操作
825
+ * @author wangfupeng
826
+ */
827
+ if (append) {
828
+ $.fn.append = append;
829
+ }
830
+ if (html) {
831
+ $.fn.html = html;
832
+ }
833
+ if (val) {
834
+ $.fn.val = val;
835
+ }
836
+ if (on) {
837
+ $.fn.on = on;
838
+ }
839
+ if (focus) {
840
+ $.fn.focus = focus;
841
+ }
842
+ if (is) {
843
+ $.fn.is = is;
844
+ }
845
+ if (parents) {
846
+ $.fn.parents = parents;
847
+ }
848
+ if (find) {
849
+ $.fn.find = find;
850
+ }
851
+
852
+ let nanoid = (size = 21) =>
853
+ crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
854
+ byte &= 63;
855
+ if (byte < 36) {
856
+ id += byte.toString(36);
857
+ } else if (byte < 62) {
858
+ id += (byte - 26).toString(36).toUpperCase();
859
+ } else if (byte > 62) {
860
+ id += '-';
861
+ } else {
862
+ id += '_';
863
+ }
864
+ return id
865
+ }, '');
866
+
867
+ /**
868
+ * @description 工具函数
869
+ * @author wangfupeng
870
+ */
871
+ /**
872
+ * 获取随机数字符串
873
+ * @param prefix 前缀
874
+ * @returns 随机数字符串
875
+ */
876
+ function genRandomStr(prefix) {
877
+ return "".concat(prefix, "-").concat(nanoid());
878
+ }
879
+ // export function replaceSymbols(str: string) {
880
+ // return str.replace(/</g, '&lt;').replace(/>/g, '&gt;')
881
+ // }
882
+
883
+ /**
884
+ * @description edit formula menu
885
+ * @author wangfupeng
886
+ */
887
+ /**
888
+ * 生成唯一的 DOM ID
889
+ */
890
+ function genDomID$1() {
891
+ return genRandomStr('w-e-insert-formula');
892
+ }
893
+ var EditFormulaMenu = /** @class */ (function () {
894
+ function EditFormulaMenu() {
895
+ this.title = t('formula.edit');
896
+ this.iconSvg = PENCIL_SVG;
897
+ this.tag = 'button';
898
+ this.showModal = true; // 点击 button 时显示 modal
899
+ this.modalWidth = 300;
900
+ this.$content = null;
901
+ this.textareaId = genDomID$1();
902
+ this.buttonId = genDomID$1();
903
+ }
904
+ EditFormulaMenu.prototype.getSelectedElem = function (editor) {
905
+ var node = DomEditor.getSelectedNodeByType(editor, 'formula');
906
+ if (node == null) {
907
+ return null;
908
+ }
909
+ return node;
910
+ };
911
+ /**
912
+ * 获取公式 value
913
+ * @param editor editor
914
+ */
915
+ EditFormulaMenu.prototype.getValue = function (editor) {
916
+ var formulaElem = this.getSelectedElem(editor);
917
+ if (formulaElem) {
918
+ return formulaElem.value || '';
919
+ }
920
+ return '';
921
+ };
922
+ EditFormulaMenu.prototype.isActive = function (_editor) {
923
+ // 无需 active
924
+ return false;
925
+ };
926
+ EditFormulaMenu.prototype.exec = function (_editor, _value) {
927
+ // 点击菜单时,弹出 modal 之前,不需要执行其他代码
928
+ // 此处空着即可
929
+ };
930
+ EditFormulaMenu.prototype.isDisabled = function (editor) {
931
+ var selection = editor.selection;
932
+ if (selection == null) {
933
+ return true;
934
+ }
935
+ if (SlateRange.isExpanded(selection)) {
936
+ return true;
937
+ } // 选区非折叠,禁用
938
+ // 未匹配到 formula node 则禁用
939
+ var formulaElem = this.getSelectedElem(editor);
940
+ if (formulaElem == null) {
941
+ return true;
942
+ }
943
+ return false;
944
+ };
945
+ // modal 定位
946
+ EditFormulaMenu.prototype.getModalPositionNode = function (editor) {
947
+ return this.getSelectedElem(editor);
948
+ };
949
+ EditFormulaMenu.prototype.getModalContentElem = function (editor) {
950
+ var _this = this;
951
+ var _a = this, textareaId = _a.textareaId, buttonId = _a.buttonId;
952
+ var _b = __read(genModalTextareaElems(t('formula.formula'), textareaId, t('formula.placeholder')), 2), textareaContainerElem = _b[0], textareaElem = _b[1];
953
+ var $textarea = $(textareaElem);
954
+ var _c = __read(genModalButtonElems(buttonId, t('formula.ok')), 1), buttonContainerElem = _c[0];
955
+ if (this.$content == null) {
956
+ // 第一次渲染
957
+ var $content_1 = $('<div></div>');
958
+ // 绑定事件(第一次渲染时绑定,不要重复绑定)
959
+ $content_1.on('click', "#".concat(buttonId), function (e) {
960
+ e.preventDefault();
961
+ var value = $content_1.find("#".concat(textareaId)).val().trim();
962
+ _this.updateFormula(editor, value);
963
+ editor.hidePanelOrModal(); // 隐藏 modal
964
+ });
965
+ // 记录属性,重要
966
+ this.$content = $content_1;
967
+ }
968
+ var $content = this.$content;
969
+ $content.html(''); // 先清空内容
970
+ // append textarea and button
971
+ $content.append(textareaContainerElem);
972
+ $content.append(buttonContainerElem);
973
+ // 设置 input val
974
+ var value = this.getValue(editor);
975
+ $textarea.val(value);
976
+ // focus 一个 input(异步,此时 DOM 尚未渲染)
977
+ setTimeout(function () {
978
+ $textarea.focus();
979
+ });
980
+ return $content[0];
981
+ };
982
+ EditFormulaMenu.prototype.updateFormula = function (editor, value) {
983
+ if (!value) {
984
+ return;
985
+ }
986
+ // 还原选区
987
+ editor.restoreSelection();
988
+ if (this.isDisabled(editor)) {
989
+ return;
990
+ }
991
+ var selectedElem = this.getSelectedElem(editor);
992
+ if (selectedElem == null) {
993
+ return;
994
+ }
995
+ var path = DomEditor.findPath(editor, selectedElem);
996
+ var props = { value: value };
997
+ SlateTransforms.setNodes(editor, props, { at: path });
998
+ };
999
+ return EditFormulaMenu;
1000
+ }());
1001
+
1002
+ /**
1003
+ * @description insert formula menu
1004
+ * @author wangfupeng
1005
+ */
1006
+ /**
1007
+ * 生成唯一的 DOM ID
1008
+ */
1009
+ function genDomID() {
1010
+ return genRandomStr('w-e-insert-formula');
1011
+ }
1012
+ var InsertFormulaMenu = /** @class */ (function () {
1013
+ function InsertFormulaMenu() {
1014
+ this.title = t('formula.insert');
1015
+ this.iconSvg = SIGMA_SVG;
1016
+ this.tag = 'button';
1017
+ this.showModal = true; // 点击 button 时显示 modal
1018
+ this.modalWidth = 300;
1019
+ this.$content = null;
1020
+ this.textareaId = genDomID();
1021
+ this.buttonId = genDomID();
1022
+ }
1023
+ InsertFormulaMenu.prototype.getValue = function (_editor) {
1024
+ // 插入菜单,不需要 value
1025
+ return '';
1026
+ };
1027
+ InsertFormulaMenu.prototype.isActive = function (_editor) {
1028
+ // 任何时候,都不用激活 menu
1029
+ return false;
1030
+ };
1031
+ InsertFormulaMenu.prototype.exec = function (_editor, _value) {
1032
+ // 点击菜单时,弹出 modal 之前,不需要执行其他代码
1033
+ // 此处空着即可
1034
+ };
1035
+ InsertFormulaMenu.prototype.isDisabled = function (editor) {
1036
+ var selection = editor.selection;
1037
+ if (selection == null) {
1038
+ return true;
1039
+ }
1040
+ if (SlateRange.isExpanded(selection)) {
1041
+ return true;
1042
+ } // 选区非折叠,禁用
1043
+ var selectedElems = DomEditor.getSelectedElems(editor);
1044
+ var hasVoidElem = selectedElems.some(function (elem) { return editor.isVoid(elem); });
1045
+ if (hasVoidElem) {
1046
+ return true;
1047
+ } // 选中了 void 元素,禁用
1048
+ var hasPreElem = selectedElems.some(function (elem) { return DomEditor.getNodeType(elem) === 'pre'; });
1049
+ if (hasPreElem) {
1050
+ return true;
1051
+ } // 选中了 pre 原则,禁用
1052
+ return false;
1053
+ };
1054
+ InsertFormulaMenu.prototype.getModalPositionNode = function (_editor) {
1055
+ return null; // modal 依据选区定位
1056
+ };
1057
+ InsertFormulaMenu.prototype.getModalContentElem = function (editor) {
1058
+ var _this = this;
1059
+ var _a = this, textareaId = _a.textareaId, buttonId = _a.buttonId;
1060
+ var _b = __read(genModalTextareaElems(t('formula.formula'), textareaId, t('formula.placeholder')), 2), textareaContainerElem = _b[0], textareaElem = _b[1];
1061
+ var $textarea = $(textareaElem);
1062
+ var _c = __read(genModalButtonElems(buttonId, t('formula.ok')), 1), buttonContainerElem = _c[0];
1063
+ if (this.$content == null) {
1064
+ // 第一次渲染
1065
+ var $content_1 = $('<div></div>');
1066
+ // 绑定事件(第一次渲染时绑定,不要重复绑定)
1067
+ $content_1.on('click', "#".concat(buttonId), function (e) {
1068
+ e.preventDefault();
1069
+ var value = $content_1.find("#".concat(textareaId)).val().trim();
1070
+ _this.insertFormula(editor, value);
1071
+ editor.hidePanelOrModal(); // 隐藏 modal
1072
+ });
1073
+ // 记录属性,重要
1074
+ this.$content = $content_1;
1075
+ }
1076
+ var $content = this.$content;
1077
+ $content.html(''); // 先清空内容
1078
+ // append textarea and button
1079
+ $content.append(textareaContainerElem);
1080
+ $content.append(buttonContainerElem);
1081
+ // 设置 input val
1082
+ $textarea.val('');
1083
+ // focus 一个 input(异步,此时 DOM 尚未渲染)
1084
+ setTimeout(function () {
1085
+ $textarea.focus();
1086
+ });
1087
+ return $content[0];
1088
+ };
1089
+ InsertFormulaMenu.prototype.insertFormula = function (editor, value) {
1090
+ if (!value) {
1091
+ return;
1092
+ }
1093
+ // 还原选区
1094
+ editor.restoreSelection();
1095
+ if (this.isDisabled(editor)) {
1096
+ return;
1097
+ }
1098
+ var formulaElem = {
1099
+ type: 'formula',
1100
+ value: value,
1101
+ children: [{ text: '' }], // void node 需要有一个空 text
1102
+ };
1103
+ editor.insertNode(formulaElem);
1104
+ };
1105
+ return InsertFormulaMenu;
1106
+ }());
1107
+
1108
+ /**
1109
+ * @description formula menu entry
1110
+ * @author wangfupeng
1111
+ */
1112
+ var insertFormulaMenuConf = {
1113
+ key: 'insertFormula', // menu key ,唯一。注册之后,可配置到工具栏
1114
+ factory: function () {
1115
+ return new InsertFormulaMenu();
1116
+ },
1117
+ };
1118
+ var editFormulaMenuConf = {
1119
+ key: 'editFormula', // menu key ,唯一。注册之后,可配置到工具栏
1120
+ factory: function () {
1121
+ return new EditFormulaMenu();
1122
+ },
1123
+ };
1124
+
1125
+ /**
1126
+ * @description parse elem html
1127
+ * @author wangfupeng
1128
+ */
1129
+ function parseHtml(elem, _children, _editor) {
1130
+ var value = elem.getAttribute('data-value') || '';
1131
+ return {
1132
+ type: 'formula',
1133
+ value: value,
1134
+ children: [{ text: '' }], // void node 必须有一个空白 text
1135
+ };
1136
+ }
1137
+ var parseHtmlConf = {
1138
+ selector: 'span[data-w-e-type="formula"]',
1139
+ parseElemHtml: parseHtml,
1140
+ };
1141
+
1142
+ /**
1143
+ * @description formula plugin
1144
+ * @author wangfupeng
1145
+ */
1146
+ function withFormula(editor) {
1147
+ var isInline = editor.isInline, isVoid = editor.isVoid;
1148
+ var newEditor = editor;
1149
+ // 重写 isInline
1150
+ newEditor.isInline = function (elem) {
1151
+ var type = DomEditor.getNodeType(elem);
1152
+ if (type === 'formula') {
1153
+ return true;
1154
+ }
1155
+ return isInline(elem);
1156
+ };
1157
+ // 重写 isVoid
1158
+ newEditor.isVoid = function (elem) {
1159
+ var type = DomEditor.getNodeType(elem);
1160
+ if (type === 'formula') {
1161
+ return true;
1162
+ }
1163
+ return isVoid(elem);
1164
+ };
1165
+ return newEditor;
1166
+ }
1167
+
1168
+ /**
1169
+ * @description render elem
1170
+ * @author wangfupeng
1171
+ */
1172
+ function renderFormula(elem, children, editor) {
1173
+ // 当前节点是否选中
1174
+ var selected = DomEditor.isNodeSelected(editor, elem);
1175
+ // 构建 formula vnode
1176
+ var _a = elem.value, value = _a === void 0 ? '' : _a;
1177
+ var formulaVnode = h('w-e-formula-card', {
1178
+ dataset: { value: value },
1179
+ }, null);
1180
+ // 构建容器 vnode
1181
+ var containerVnode = h('div', {
1182
+ props: {
1183
+ contentEditable: false, // 不可编辑
1184
+ },
1185
+ style: {
1186
+ display: 'inline-block', // inline
1187
+ marginLeft: '3px',
1188
+ marginRight: '3px',
1189
+ border: selected // 选中/不选中,样式不一样
1190
+ ? '2px solid var(--w-e-textarea-selected-border-color)' // wangEditor 提供了 css var https://www.wangeditor.com/v5/theme.html
1191
+ : '2px solid transparent',
1192
+ borderRadius: '3px',
1193
+ padding: '3px 3px',
1194
+ },
1195
+ }, [formulaVnode]);
1196
+ return containerVnode;
1197
+ }
1198
+ var conf = {
1199
+ type: 'formula', // 节点 type ,重要!!!
1200
+ renderElem: renderFormula,
1201
+ };
1202
+
1203
+ /**
1204
+ * @description formula module entry
1205
+ * @author wangfupeng
1206
+ */
1207
+ var module = {
1208
+ editorPlugin: withFormula,
1209
+ renderElems: [conf],
1210
+ elemsToHtml: [conf$1],
1211
+ parseElemsHtml: [parseHtmlConf],
1212
+ menus: [insertFormulaMenuConf, editFormulaMenuConf],
1213
+ };
1214
+
1215
+ /**
1216
+ * @description src entry
1217
+ * @author wangfupeng
1218
+ */
1219
+ // 全局注册自定义组件,用于渲染公式
1220
+
1221
+ export { module as default };