@wangeditor-next/plugin-formula 0.0.11 → 0.0.12-beta.1

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,1233 @@
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
+ // connectedCallback() {
135
+ // // 当 custom element首次被插入文档DOM时,被调用
136
+ // console.log('connected')
137
+ // }
138
+ // disconnectedCallback() {
139
+ // // 当 custom element从文档DOM中删除时,被调用
140
+ // console.log('disconnected')
141
+ // }
142
+ // adoptedCallback() {
143
+ // // 当 custom element被移动到新的文档时,被调用
144
+ // console.log('adopted')
145
+ // }
146
+ WangEditorFormulaCard.prototype.attributeChangedCallback = function (name, oldValue, newValue) {
147
+ if (name === 'data-value') {
148
+ if (oldValue === newValue) {
149
+ return;
150
+ }
151
+ this.render(newValue || '');
152
+ }
153
+ };
154
+ WangEditorFormulaCard.prototype.render = function (value) {
155
+ katex.render(value, this.span, {
156
+ throwOnError: false,
157
+ });
158
+ };
159
+ return WangEditorFormulaCard;
160
+ }(HTMLElement));
161
+ if (!window.customElements.get('w-e-formula-card')) {
162
+ window.customElements.define('w-e-formula-card', WangEditorFormulaCard);
163
+ }
164
+
165
+ /**
166
+ * @description 多语言
167
+ * @author wangfupeng
168
+ */
169
+ i18nAddResources('en', {
170
+ formula: {
171
+ formula: 'Formula',
172
+ placeholder: 'Use LateX syntax',
173
+ insert: 'Insert formula',
174
+ edit: 'Edit formula',
175
+ ok: 'OK',
176
+ },
177
+ });
178
+ i18nAddResources('zh-CN', {
179
+ formula: {
180
+ formula: '公式',
181
+ placeholder: '使用 LateX 语法',
182
+ insert: '插入公式',
183
+ edit: '编辑公式',
184
+ ok: '确定',
185
+ },
186
+ });
187
+
188
+ /**
189
+ * @description elem to html
190
+ * @author wangfupeng
191
+ */
192
+ // 生成 html 的函数
193
+ function formulaToHtml(elem, _childrenHtml) {
194
+ var _a = elem.value, value = _a === void 0 ? '' : _a;
195
+ return "<span data-w-e-type=\"formula\" data-w-e-is-void data-w-e-is-inline data-value=\"".concat(value, "\"></span>");
196
+ }
197
+ // 配置
198
+ var conf$1 = {
199
+ type: 'formula', // 节点 type ,重要!!!
200
+ elemToHtml: formulaToHtml,
201
+ };
202
+
203
+ /**
204
+ * @description icon svg
205
+ * @author wangfupeng
206
+ */
207
+ /**
208
+ * 【注意】svg 字符串的长度 ,否则会导致代码体积过大
209
+ * 尽量选择 https://www.iconfont.cn/collections/detail?spm=a313x.7781069.0.da5a778a4&cid=20293
210
+ * 找不到再从 iconfont.com 搜索
211
+ */
212
+ // 公式
213
+ 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>';
214
+ // 编辑
215
+ 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>';
216
+
217
+ /**
218
+ * SSR Window 3.0.0
219
+ * Better handling for window object in SSR environment
220
+ * https://github.com/nolimits4web/ssr-window
221
+ *
222
+ * Copyright 2020, Vladimir Kharlampidi
223
+ *
224
+ * Licensed under MIT
225
+ *
226
+ * Released on: November 9, 2020
227
+ */
228
+ /* eslint-disable no-param-reassign */
229
+ function isObject(obj) {
230
+ return (obj !== null &&
231
+ typeof obj === 'object' &&
232
+ 'constructor' in obj &&
233
+ obj.constructor === Object);
234
+ }
235
+ function extend(target, src) {
236
+ if (target === void 0) { target = {}; }
237
+ if (src === void 0) { src = {}; }
238
+ Object.keys(src).forEach(function (key) {
239
+ if (typeof target[key] === 'undefined')
240
+ target[key] = src[key];
241
+ else if (isObject(src[key]) &&
242
+ isObject(target[key]) &&
243
+ Object.keys(src[key]).length > 0) {
244
+ extend(target[key], src[key]);
245
+ }
246
+ });
247
+ }
248
+
249
+ var ssrDocument = {
250
+ body: {},
251
+ addEventListener: function () { },
252
+ removeEventListener: function () { },
253
+ activeElement: {
254
+ blur: function () { },
255
+ nodeName: '',
256
+ },
257
+ querySelector: function () {
258
+ return null;
259
+ },
260
+ querySelectorAll: function () {
261
+ return [];
262
+ },
263
+ getElementById: function () {
264
+ return null;
265
+ },
266
+ createEvent: function () {
267
+ return {
268
+ initEvent: function () { },
269
+ };
270
+ },
271
+ createElement: function () {
272
+ return {
273
+ children: [],
274
+ childNodes: [],
275
+ style: {},
276
+ setAttribute: function () { },
277
+ getElementsByTagName: function () {
278
+ return [];
279
+ },
280
+ };
281
+ },
282
+ createElementNS: function () {
283
+ return {};
284
+ },
285
+ importNode: function () {
286
+ return null;
287
+ },
288
+ location: {
289
+ hash: '',
290
+ host: '',
291
+ hostname: '',
292
+ href: '',
293
+ origin: '',
294
+ pathname: '',
295
+ protocol: '',
296
+ search: '',
297
+ },
298
+ };
299
+ function getDocument() {
300
+ var doc = typeof document !== 'undefined' ? document : {};
301
+ extend(doc, ssrDocument);
302
+ return doc;
303
+ }
304
+
305
+ var ssrWindow = {
306
+ document: ssrDocument,
307
+ navigator: {
308
+ userAgent: '',
309
+ },
310
+ location: {
311
+ hash: '',
312
+ host: '',
313
+ hostname: '',
314
+ href: '',
315
+ origin: '',
316
+ pathname: '',
317
+ protocol: '',
318
+ search: '',
319
+ },
320
+ history: {
321
+ replaceState: function () { },
322
+ pushState: function () { },
323
+ go: function () { },
324
+ back: function () { },
325
+ },
326
+ CustomEvent: function CustomEvent() {
327
+ return this;
328
+ },
329
+ addEventListener: function () { },
330
+ removeEventListener: function () { },
331
+ getComputedStyle: function () {
332
+ return {
333
+ getPropertyValue: function () {
334
+ return '';
335
+ },
336
+ };
337
+ },
338
+ Image: function () { },
339
+ Date: function () { },
340
+ screen: {},
341
+ setTimeout: function () { },
342
+ clearTimeout: function () { },
343
+ matchMedia: function () {
344
+ return {};
345
+ },
346
+ requestAnimationFrame: function (callback) {
347
+ if (typeof setTimeout === 'undefined') {
348
+ callback();
349
+ return null;
350
+ }
351
+ return setTimeout(callback, 0);
352
+ },
353
+ cancelAnimationFrame: function (id) {
354
+ if (typeof setTimeout === 'undefined') {
355
+ return;
356
+ }
357
+ clearTimeout(id);
358
+ },
359
+ };
360
+ function getWindow() {
361
+ var win = typeof window !== 'undefined' ? window : {};
362
+ extend(win, ssrWindow);
363
+ return win;
364
+ }
365
+
366
+ /**
367
+ * Dom7 3.0.0
368
+ * Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API
369
+ * https://framework7.io/docs/dom7.html
370
+ *
371
+ * Copyright 2020, Vladimir Kharlampidi
372
+ *
373
+ * Licensed under MIT
374
+ *
375
+ * Released on: November 9, 2020
376
+ */
377
+
378
+ function _inheritsLoose(subClass, superClass) {
379
+ subClass.prototype = Object.create(superClass.prototype);
380
+ subClass.prototype.constructor = subClass;
381
+ subClass.__proto__ = superClass;
382
+ }
383
+
384
+ function _getPrototypeOf(o) {
385
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
386
+ return o.__proto__ || Object.getPrototypeOf(o);
387
+ };
388
+ return _getPrototypeOf(o);
389
+ }
390
+
391
+ function _setPrototypeOf(o, p) {
392
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
393
+ o.__proto__ = p;
394
+ return o;
395
+ };
396
+
397
+ return _setPrototypeOf(o, p);
398
+ }
399
+
400
+ function _isNativeReflectConstruct() {
401
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
402
+ if (Reflect.construct.sham) return false;
403
+ if (typeof Proxy === "function") return true;
404
+
405
+ try {
406
+ Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
407
+ return true;
408
+ } catch (e) {
409
+ return false;
410
+ }
411
+ }
412
+
413
+ function _construct(Parent, args, Class) {
414
+ if (_isNativeReflectConstruct()) {
415
+ _construct = Reflect.construct;
416
+ } else {
417
+ _construct = function _construct(Parent, args, Class) {
418
+ var a = [null];
419
+ a.push.apply(a, args);
420
+ var Constructor = Function.bind.apply(Parent, a);
421
+ var instance = new Constructor();
422
+ if (Class) _setPrototypeOf(instance, Class.prototype);
423
+ return instance;
424
+ };
425
+ }
426
+
427
+ return _construct.apply(null, arguments);
428
+ }
429
+
430
+ function _isNativeFunction(fn) {
431
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
432
+ }
433
+
434
+ function _wrapNativeSuper(Class) {
435
+ var _cache = typeof Map === "function" ? new Map() : undefined;
436
+
437
+ _wrapNativeSuper = function _wrapNativeSuper(Class) {
438
+ if (Class === null || !_isNativeFunction(Class)) return Class;
439
+
440
+ if (typeof Class !== "function") {
441
+ throw new TypeError("Super expression must either be null or a function");
442
+ }
443
+
444
+ if (typeof _cache !== "undefined") {
445
+ if (_cache.has(Class)) return _cache.get(Class);
446
+
447
+ _cache.set(Class, Wrapper);
448
+ }
449
+
450
+ function Wrapper() {
451
+ return _construct(Class, arguments, _getPrototypeOf(this).constructor);
452
+ }
453
+
454
+ Wrapper.prototype = Object.create(Class.prototype, {
455
+ constructor: {
456
+ value: Wrapper,
457
+ enumerable: false,
458
+ writable: true,
459
+ configurable: true
460
+ }
461
+ });
462
+ return _setPrototypeOf(Wrapper, Class);
463
+ };
464
+
465
+ return _wrapNativeSuper(Class);
466
+ }
467
+
468
+ function _assertThisInitialized(self) {
469
+ if (self === void 0) {
470
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
471
+ }
472
+
473
+ return self;
474
+ }
475
+
476
+ /* eslint-disable no-proto */
477
+ function makeReactive(obj) {
478
+ var proto = obj.__proto__;
479
+ Object.defineProperty(obj, '__proto__', {
480
+ get: function get() {
481
+ return proto;
482
+ },
483
+ set: function set(value) {
484
+ proto.__proto__ = value;
485
+ }
486
+ });
487
+ }
488
+
489
+ var Dom7 = /*#__PURE__*/function (_Array) {
490
+ _inheritsLoose(Dom7, _Array);
491
+
492
+ function Dom7(items) {
493
+ var _this;
494
+
495
+ _this = _Array.call.apply(_Array, [this].concat(items)) || this;
496
+ makeReactive(_assertThisInitialized(_this));
497
+ return _this;
498
+ }
499
+
500
+ return Dom7;
501
+ }( /*#__PURE__*/_wrapNativeSuper(Array));
502
+ function arrayUnique(arr) {
503
+ var uniqueArray = [];
504
+
505
+ for (var i = 0; i < arr.length; i += 1) {
506
+ if (uniqueArray.indexOf(arr[i]) === -1) uniqueArray.push(arr[i]);
507
+ }
508
+
509
+ return uniqueArray;
510
+ }
511
+
512
+ function qsa(selector, context) {
513
+ if (typeof selector !== 'string') {
514
+ return [selector];
515
+ }
516
+
517
+ var a = [];
518
+ var res = context.querySelectorAll(selector);
519
+
520
+ for (var i = 0; i < res.length; i += 1) {
521
+ a.push(res[i]);
522
+ }
523
+
524
+ return a;
525
+ }
526
+
527
+ function $(selector, context) {
528
+ var window = getWindow();
529
+ var document = getDocument();
530
+ var arr = [];
531
+
532
+ if (!context && selector instanceof Dom7) {
533
+ return selector;
534
+ }
535
+
536
+ if (!selector) {
537
+ return new Dom7(arr);
538
+ }
539
+
540
+ if (typeof selector === 'string') {
541
+ var html = selector.trim();
542
+
543
+ if (html.indexOf('<') >= 0 && html.indexOf('>') >= 0) {
544
+ var toCreate = 'div';
545
+ if (html.indexOf('<li') === 0) toCreate = 'ul';
546
+ if (html.indexOf('<tr') === 0) toCreate = 'tbody';
547
+ if (html.indexOf('<td') === 0 || html.indexOf('<th') === 0) toCreate = 'tr';
548
+ if (html.indexOf('<tbody') === 0) toCreate = 'table';
549
+ if (html.indexOf('<option') === 0) toCreate = 'select';
550
+ var tempParent = document.createElement(toCreate);
551
+ tempParent.innerHTML = html;
552
+
553
+ for (var i = 0; i < tempParent.childNodes.length; i += 1) {
554
+ arr.push(tempParent.childNodes[i]);
555
+ }
556
+ } else {
557
+ arr = qsa(selector.trim(), context || document);
558
+ } // arr = qsa(selector, document);
559
+
560
+ } else if (selector.nodeType || selector === window || selector === document) {
561
+ arr.push(selector);
562
+ } else if (Array.isArray(selector)) {
563
+ if (selector instanceof Dom7) return selector;
564
+ arr = selector;
565
+ }
566
+
567
+ return new Dom7(arrayUnique(arr));
568
+ }
569
+
570
+ $.fn = Dom7.prototype;
571
+
572
+ function val(value) {
573
+ if (typeof value === 'undefined') {
574
+ // get value
575
+ var el = this[0];
576
+ if (!el) return undefined;
577
+
578
+ if (el.multiple && el.nodeName.toLowerCase() === 'select') {
579
+ var values = [];
580
+
581
+ for (var i = 0; i < el.selectedOptions.length; i += 1) {
582
+ values.push(el.selectedOptions[i].value);
583
+ }
584
+
585
+ return values;
586
+ }
587
+
588
+ return el.value;
589
+ } // set value
590
+
591
+
592
+ for (var _i = 0; _i < this.length; _i += 1) {
593
+ var _el = this[_i];
594
+
595
+ if (Array.isArray(value) && _el.multiple && _el.nodeName.toLowerCase() === 'select') {
596
+ for (var j = 0; j < _el.options.length; j += 1) {
597
+ _el.options[j].selected = value.indexOf(_el.options[j].value) >= 0;
598
+ }
599
+ } else {
600
+ _el.value = value;
601
+ }
602
+ }
603
+
604
+ return this;
605
+ }
606
+
607
+ function on() {
608
+ for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
609
+ args[_key5] = arguments[_key5];
610
+ }
611
+
612
+ var eventType = args[0],
613
+ targetSelector = args[1],
614
+ listener = args[2],
615
+ capture = args[3];
616
+
617
+ if (typeof args[1] === 'function') {
618
+ eventType = args[0];
619
+ listener = args[1];
620
+ capture = args[2];
621
+ targetSelector = undefined;
622
+ }
623
+
624
+ if (!capture) capture = false;
625
+
626
+ function handleLiveEvent(e) {
627
+ var target = e.target;
628
+ if (!target) return;
629
+ var eventData = e.target.dom7EventData || [];
630
+
631
+ if (eventData.indexOf(e) < 0) {
632
+ eventData.unshift(e);
633
+ }
634
+
635
+ if ($(target).is(targetSelector)) listener.apply(target, eventData);else {
636
+ var _parents = $(target).parents(); // eslint-disable-line
637
+
638
+
639
+ for (var k = 0; k < _parents.length; k += 1) {
640
+ if ($(_parents[k]).is(targetSelector)) listener.apply(_parents[k], eventData);
641
+ }
642
+ }
643
+ }
644
+
645
+ function handleEvent(e) {
646
+ var eventData = e && e.target ? e.target.dom7EventData || [] : [];
647
+
648
+ if (eventData.indexOf(e) < 0) {
649
+ eventData.unshift(e);
650
+ }
651
+
652
+ listener.apply(this, eventData);
653
+ }
654
+
655
+ var events = eventType.split(' ');
656
+ var j;
657
+
658
+ for (var i = 0; i < this.length; i += 1) {
659
+ var el = this[i];
660
+
661
+ if (!targetSelector) {
662
+ for (j = 0; j < events.length; j += 1) {
663
+ var event = events[j];
664
+ if (!el.dom7Listeners) el.dom7Listeners = {};
665
+ if (!el.dom7Listeners[event]) el.dom7Listeners[event] = [];
666
+ el.dom7Listeners[event].push({
667
+ listener: listener,
668
+ proxyListener: handleEvent
669
+ });
670
+ el.addEventListener(event, handleEvent, capture);
671
+ }
672
+ } else {
673
+ // Live events
674
+ for (j = 0; j < events.length; j += 1) {
675
+ var _event = events[j];
676
+ if (!el.dom7LiveListeners) el.dom7LiveListeners = {};
677
+ if (!el.dom7LiveListeners[_event]) el.dom7LiveListeners[_event] = [];
678
+
679
+ el.dom7LiveListeners[_event].push({
680
+ listener: listener,
681
+ proxyListener: handleLiveEvent
682
+ });
683
+
684
+ el.addEventListener(_event, handleLiveEvent, capture);
685
+ }
686
+ }
687
+ }
688
+
689
+ return this;
690
+ }
691
+
692
+ function html(html) {
693
+ if (typeof html === 'undefined') {
694
+ return this[0] ? this[0].innerHTML : null;
695
+ }
696
+
697
+ for (var i = 0; i < this.length; i += 1) {
698
+ this[i].innerHTML = html;
699
+ }
700
+
701
+ return this;
702
+ }
703
+
704
+ function is(selector) {
705
+ var window = getWindow();
706
+ var document = getDocument();
707
+ var el = this[0];
708
+ var compareWith;
709
+ var i;
710
+ if (!el || typeof selector === 'undefined') return false;
711
+
712
+ if (typeof selector === 'string') {
713
+ if (el.matches) return el.matches(selector);
714
+ if (el.webkitMatchesSelector) return el.webkitMatchesSelector(selector);
715
+ if (el.msMatchesSelector) return el.msMatchesSelector(selector);
716
+ compareWith = $(selector);
717
+
718
+ for (i = 0; i < compareWith.length; i += 1) {
719
+ if (compareWith[i] === el) return true;
720
+ }
721
+
722
+ return false;
723
+ }
724
+
725
+ if (selector === document) {
726
+ return el === document;
727
+ }
728
+
729
+ if (selector === window) {
730
+ return el === window;
731
+ }
732
+
733
+ if (selector.nodeType || selector instanceof Dom7) {
734
+ compareWith = selector.nodeType ? [selector] : selector;
735
+
736
+ for (i = 0; i < compareWith.length; i += 1) {
737
+ if (compareWith[i] === el) return true;
738
+ }
739
+
740
+ return false;
741
+ }
742
+
743
+ return false;
744
+ }
745
+
746
+ function append() {
747
+ var newChild;
748
+ var document = getDocument();
749
+
750
+ for (var k = 0; k < arguments.length; k += 1) {
751
+ newChild = k < 0 || arguments.length <= k ? undefined : arguments[k];
752
+
753
+ for (var i = 0; i < this.length; i += 1) {
754
+ if (typeof newChild === 'string') {
755
+ var tempDiv = document.createElement('div');
756
+ tempDiv.innerHTML = newChild;
757
+
758
+ while (tempDiv.firstChild) {
759
+ this[i].appendChild(tempDiv.firstChild);
760
+ }
761
+ } else if (newChild instanceof Dom7) {
762
+ for (var j = 0; j < newChild.length; j += 1) {
763
+ this[i].appendChild(newChild[j]);
764
+ }
765
+ } else {
766
+ this[i].appendChild(newChild);
767
+ }
768
+ }
769
+ }
770
+
771
+ return this;
772
+ }
773
+
774
+ function parents(selector) {
775
+ var parents = []; // eslint-disable-line
776
+
777
+ for (var i = 0; i < this.length; i += 1) {
778
+ var _parent = this[i].parentNode; // eslint-disable-line
779
+
780
+ while (_parent) {
781
+ if (selector) {
782
+ if ($(_parent).is(selector)) parents.push(_parent);
783
+ } else {
784
+ parents.push(_parent);
785
+ }
786
+
787
+ _parent = _parent.parentNode;
788
+ }
789
+ }
790
+
791
+ return $(parents);
792
+ }
793
+
794
+ function find(selector) {
795
+ var foundElements = [];
796
+
797
+ for (var i = 0; i < this.length; i += 1) {
798
+ var found = this[i].querySelectorAll(selector);
799
+
800
+ for (var j = 0; j < found.length; j += 1) {
801
+ foundElements.push(found[j]);
802
+ }
803
+ }
804
+
805
+ return $(foundElements);
806
+ }
807
+
808
+ var noTrigger = 'resize scroll'.split(' ');
809
+
810
+ function shortcut(name) {
811
+ function eventHandler() {
812
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
813
+ args[_key] = arguments[_key];
814
+ }
815
+
816
+ if (typeof args[0] === 'undefined') {
817
+ for (var i = 0; i < this.length; i += 1) {
818
+ if (noTrigger.indexOf(name) < 0) {
819
+ if (name in this[i]) this[i][name]();else {
820
+ $(this[i]).trigger(name);
821
+ }
822
+ }
823
+ }
824
+
825
+ return this;
826
+ }
827
+
828
+ return this.on.apply(this, [name].concat(args));
829
+ }
830
+
831
+ return eventHandler;
832
+ }
833
+ var focus = shortcut('focus');
834
+
835
+ /**
836
+ * @description DOM 操作
837
+ * @author wangfupeng
838
+ */
839
+ if (append) {
840
+ $.fn.append = append;
841
+ }
842
+ if (html) {
843
+ $.fn.html = html;
844
+ }
845
+ if (val) {
846
+ $.fn.val = val;
847
+ }
848
+ if (on) {
849
+ $.fn.on = on;
850
+ }
851
+ if (focus) {
852
+ $.fn.focus = focus;
853
+ }
854
+ if (is) {
855
+ $.fn.is = is;
856
+ }
857
+ if (parents) {
858
+ $.fn.parents = parents;
859
+ }
860
+ if (find) {
861
+ $.fn.find = find;
862
+ }
863
+
864
+ let nanoid = (size = 21) =>
865
+ crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
866
+ byte &= 63;
867
+ if (byte < 36) {
868
+ id += byte.toString(36);
869
+ } else if (byte < 62) {
870
+ id += (byte - 26).toString(36).toUpperCase();
871
+ } else if (byte > 62) {
872
+ id += '-';
873
+ } else {
874
+ id += '_';
875
+ }
876
+ return id
877
+ }, '');
878
+
879
+ /**
880
+ * @description 工具函数
881
+ * @author wangfupeng
882
+ */
883
+ /**
884
+ * 获取随机数字符串
885
+ * @param prefix 前缀
886
+ * @returns 随机数字符串
887
+ */
888
+ function genRandomStr(prefix) {
889
+ return "".concat(prefix, "-").concat(nanoid());
890
+ }
891
+ // export function replaceSymbols(str: string) {
892
+ // return str.replace(/</g, '&lt;').replace(/>/g, '&gt;')
893
+ // }
894
+
895
+ /**
896
+ * @description edit formula menu
897
+ * @author wangfupeng
898
+ */
899
+ /**
900
+ * 生成唯一的 DOM ID
901
+ */
902
+ function genDomID$1() {
903
+ return genRandomStr('w-e-insert-formula');
904
+ }
905
+ var EditFormulaMenu = /** @class */ (function () {
906
+ function EditFormulaMenu() {
907
+ this.title = t('formula.edit');
908
+ this.iconSvg = PENCIL_SVG;
909
+ this.tag = 'button';
910
+ this.showModal = true; // 点击 button 时显示 modal
911
+ this.modalWidth = 300;
912
+ this.$content = null;
913
+ this.textareaId = genDomID$1();
914
+ this.buttonId = genDomID$1();
915
+ }
916
+ EditFormulaMenu.prototype.getSelectedElem = function (editor) {
917
+ var node = DomEditor.getSelectedNodeByType(editor, 'formula');
918
+ if (node == null) {
919
+ return null;
920
+ }
921
+ return node;
922
+ };
923
+ /**
924
+ * 获取公式 value
925
+ * @param editor editor
926
+ */
927
+ EditFormulaMenu.prototype.getValue = function (editor) {
928
+ var formulaElem = this.getSelectedElem(editor);
929
+ if (formulaElem) {
930
+ return formulaElem.value || '';
931
+ }
932
+ return '';
933
+ };
934
+ EditFormulaMenu.prototype.isActive = function (_editor) {
935
+ // 无需 active
936
+ return false;
937
+ };
938
+ EditFormulaMenu.prototype.exec = function (_editor, _value) {
939
+ // 点击菜单时,弹出 modal 之前,不需要执行其他代码
940
+ // 此处空着即可
941
+ };
942
+ EditFormulaMenu.prototype.isDisabled = function (editor) {
943
+ var selection = editor.selection;
944
+ if (selection == null) {
945
+ return true;
946
+ }
947
+ if (SlateRange.isExpanded(selection)) {
948
+ return true;
949
+ } // 选区非折叠,禁用
950
+ // 未匹配到 formula node 则禁用
951
+ var formulaElem = this.getSelectedElem(editor);
952
+ if (formulaElem == null) {
953
+ return true;
954
+ }
955
+ return false;
956
+ };
957
+ // modal 定位
958
+ EditFormulaMenu.prototype.getModalPositionNode = function (editor) {
959
+ return this.getSelectedElem(editor);
960
+ };
961
+ EditFormulaMenu.prototype.getModalContentElem = function (editor) {
962
+ var _this = this;
963
+ var _a = this, textareaId = _a.textareaId, buttonId = _a.buttonId;
964
+ var _b = __read(genModalTextareaElems(t('formula.formula'), textareaId, t('formula.placeholder')), 2), textareaContainerElem = _b[0], textareaElem = _b[1];
965
+ var $textarea = $(textareaElem);
966
+ var _c = __read(genModalButtonElems(buttonId, t('formula.ok')), 1), buttonContainerElem = _c[0];
967
+ if (this.$content == null) {
968
+ // 第一次渲染
969
+ var $content_1 = $('<div></div>');
970
+ // 绑定事件(第一次渲染时绑定,不要重复绑定)
971
+ $content_1.on('click', "#".concat(buttonId), function (e) {
972
+ e.preventDefault();
973
+ var value = $content_1.find("#".concat(textareaId)).val().trim();
974
+ _this.updateFormula(editor, value);
975
+ editor.hidePanelOrModal(); // 隐藏 modal
976
+ });
977
+ // 记录属性,重要
978
+ this.$content = $content_1;
979
+ }
980
+ var $content = this.$content;
981
+ $content.html(''); // 先清空内容
982
+ // append textarea and button
983
+ $content.append(textareaContainerElem);
984
+ $content.append(buttonContainerElem);
985
+ // 设置 input val
986
+ var value = this.getValue(editor);
987
+ $textarea.val(value);
988
+ // focus 一个 input(异步,此时 DOM 尚未渲染)
989
+ setTimeout(function () {
990
+ $textarea.focus();
991
+ });
992
+ return $content[0];
993
+ };
994
+ EditFormulaMenu.prototype.updateFormula = function (editor, value) {
995
+ if (!value) {
996
+ return;
997
+ }
998
+ // 还原选区
999
+ editor.restoreSelection();
1000
+ if (this.isDisabled(editor)) {
1001
+ return;
1002
+ }
1003
+ var selectedElem = this.getSelectedElem(editor);
1004
+ if (selectedElem == null) {
1005
+ return;
1006
+ }
1007
+ var path = DomEditor.findPath(editor, selectedElem);
1008
+ var props = { value: value };
1009
+ SlateTransforms.setNodes(editor, props, { at: path });
1010
+ };
1011
+ return EditFormulaMenu;
1012
+ }());
1013
+
1014
+ /**
1015
+ * @description insert formula menu
1016
+ * @author wangfupeng
1017
+ */
1018
+ /**
1019
+ * 生成唯一的 DOM ID
1020
+ */
1021
+ function genDomID() {
1022
+ return genRandomStr('w-e-insert-formula');
1023
+ }
1024
+ var InsertFormulaMenu = /** @class */ (function () {
1025
+ function InsertFormulaMenu() {
1026
+ this.title = t('formula.insert');
1027
+ this.iconSvg = SIGMA_SVG;
1028
+ this.tag = 'button';
1029
+ this.showModal = true; // 点击 button 时显示 modal
1030
+ this.modalWidth = 300;
1031
+ this.$content = null;
1032
+ this.textareaId = genDomID();
1033
+ this.buttonId = genDomID();
1034
+ }
1035
+ InsertFormulaMenu.prototype.getValue = function (_editor) {
1036
+ // 插入菜单,不需要 value
1037
+ return '';
1038
+ };
1039
+ InsertFormulaMenu.prototype.isActive = function (_editor) {
1040
+ // 任何时候,都不用激活 menu
1041
+ return false;
1042
+ };
1043
+ InsertFormulaMenu.prototype.exec = function (_editor, _value) {
1044
+ // 点击菜单时,弹出 modal 之前,不需要执行其他代码
1045
+ // 此处空着即可
1046
+ };
1047
+ InsertFormulaMenu.prototype.isDisabled = function (editor) {
1048
+ var selection = editor.selection;
1049
+ if (selection == null) {
1050
+ return true;
1051
+ }
1052
+ if (SlateRange.isExpanded(selection)) {
1053
+ return true;
1054
+ } // 选区非折叠,禁用
1055
+ var selectedElems = DomEditor.getSelectedElems(editor);
1056
+ var hasVoidElem = selectedElems.some(function (elem) { return editor.isVoid(elem); });
1057
+ if (hasVoidElem) {
1058
+ return true;
1059
+ } // 选中了 void 元素,禁用
1060
+ var hasPreElem = selectedElems.some(function (elem) { return DomEditor.getNodeType(elem) === 'pre'; });
1061
+ if (hasPreElem) {
1062
+ return true;
1063
+ } // 选中了 pre 原则,禁用
1064
+ return false;
1065
+ };
1066
+ InsertFormulaMenu.prototype.getModalPositionNode = function (_editor) {
1067
+ return null; // modal 依据选区定位
1068
+ };
1069
+ InsertFormulaMenu.prototype.getModalContentElem = function (editor) {
1070
+ var _this = this;
1071
+ var _a = this, textareaId = _a.textareaId, buttonId = _a.buttonId;
1072
+ var _b = __read(genModalTextareaElems(t('formula.formula'), textareaId, t('formula.placeholder')), 2), textareaContainerElem = _b[0], textareaElem = _b[1];
1073
+ var $textarea = $(textareaElem);
1074
+ var _c = __read(genModalButtonElems(buttonId, t('formula.ok')), 1), buttonContainerElem = _c[0];
1075
+ if (this.$content == null) {
1076
+ // 第一次渲染
1077
+ var $content_1 = $('<div></div>');
1078
+ // 绑定事件(第一次渲染时绑定,不要重复绑定)
1079
+ $content_1.on('click', "#".concat(buttonId), function (e) {
1080
+ e.preventDefault();
1081
+ var value = $content_1.find("#".concat(textareaId)).val().trim();
1082
+ _this.insertFormula(editor, value);
1083
+ editor.hidePanelOrModal(); // 隐藏 modal
1084
+ });
1085
+ // 记录属性,重要
1086
+ this.$content = $content_1;
1087
+ }
1088
+ var $content = this.$content;
1089
+ $content.html(''); // 先清空内容
1090
+ // append textarea and button
1091
+ $content.append(textareaContainerElem);
1092
+ $content.append(buttonContainerElem);
1093
+ // 设置 input val
1094
+ $textarea.val('');
1095
+ // focus 一个 input(异步,此时 DOM 尚未渲染)
1096
+ setTimeout(function () {
1097
+ $textarea.focus();
1098
+ });
1099
+ return $content[0];
1100
+ };
1101
+ InsertFormulaMenu.prototype.insertFormula = function (editor, value) {
1102
+ if (!value) {
1103
+ return;
1104
+ }
1105
+ // 还原选区
1106
+ editor.restoreSelection();
1107
+ if (this.isDisabled(editor)) {
1108
+ return;
1109
+ }
1110
+ var formulaElem = {
1111
+ type: 'formula',
1112
+ value: value,
1113
+ children: [{ text: '' }], // void node 需要有一个空 text
1114
+ };
1115
+ editor.insertNode(formulaElem);
1116
+ };
1117
+ return InsertFormulaMenu;
1118
+ }());
1119
+
1120
+ /**
1121
+ * @description formula menu entry
1122
+ * @author wangfupeng
1123
+ */
1124
+ var insertFormulaMenuConf = {
1125
+ key: 'insertFormula', // menu key ,唯一。注册之后,可配置到工具栏
1126
+ factory: function () {
1127
+ return new InsertFormulaMenu();
1128
+ },
1129
+ };
1130
+ var editFormulaMenuConf = {
1131
+ key: 'editFormula', // menu key ,唯一。注册之后,可配置到工具栏
1132
+ factory: function () {
1133
+ return new EditFormulaMenu();
1134
+ },
1135
+ };
1136
+
1137
+ /**
1138
+ * @description parse elem html
1139
+ * @author wangfupeng
1140
+ */
1141
+ function parseHtml(elem, _children, _editor) {
1142
+ var value = elem.getAttribute('data-value') || '';
1143
+ return {
1144
+ type: 'formula',
1145
+ value: value,
1146
+ children: [{ text: '' }], // void node 必须有一个空白 text
1147
+ };
1148
+ }
1149
+ var parseHtmlConf = {
1150
+ selector: 'span[data-w-e-type="formula"]',
1151
+ parseElemHtml: parseHtml,
1152
+ };
1153
+
1154
+ /**
1155
+ * @description formula plugin
1156
+ * @author wangfupeng
1157
+ */
1158
+ function withFormula(editor) {
1159
+ var isInline = editor.isInline, isVoid = editor.isVoid;
1160
+ var newEditor = editor;
1161
+ // 重写 isInline
1162
+ newEditor.isInline = function (elem) {
1163
+ var type = DomEditor.getNodeType(elem);
1164
+ if (type === 'formula') {
1165
+ return true;
1166
+ }
1167
+ return isInline(elem);
1168
+ };
1169
+ // 重写 isVoid
1170
+ newEditor.isVoid = function (elem) {
1171
+ var type = DomEditor.getNodeType(elem);
1172
+ if (type === 'formula') {
1173
+ return true;
1174
+ }
1175
+ return isVoid(elem);
1176
+ };
1177
+ return newEditor;
1178
+ }
1179
+
1180
+ /**
1181
+ * @description render elem
1182
+ * @author wangfupeng
1183
+ */
1184
+ function renderFormula(elem, children, editor) {
1185
+ // 当前节点是否选中
1186
+ var selected = DomEditor.isNodeSelected(editor, elem);
1187
+ // 构建 formula vnode
1188
+ var _a = elem.value, value = _a === void 0 ? '' : _a;
1189
+ var formulaVnode = h('w-e-formula-card', {
1190
+ dataset: { value: value },
1191
+ }, null);
1192
+ // 构建容器 vnode
1193
+ var containerVnode = h('div', {
1194
+ props: {
1195
+ contentEditable: false, // 不可编辑
1196
+ },
1197
+ style: {
1198
+ display: 'inline-block', // inline
1199
+ marginLeft: '3px',
1200
+ marginRight: '3px',
1201
+ border: selected // 选中/不选中,样式不一样
1202
+ ? '2px solid var(--w-e-textarea-selected-border-color)' // wangEditor 提供了 css var https://www.wangeditor.com/v5/theme.html
1203
+ : '2px solid transparent',
1204
+ borderRadius: '3px',
1205
+ padding: '3px 3px',
1206
+ },
1207
+ }, [formulaVnode]);
1208
+ return containerVnode;
1209
+ }
1210
+ var conf = {
1211
+ type: 'formula', // 节点 type ,重要!!!
1212
+ renderElem: renderFormula,
1213
+ };
1214
+
1215
+ /**
1216
+ * @description formula module entry
1217
+ * @author wangfupeng
1218
+ */
1219
+ var module = {
1220
+ editorPlugin: withFormula,
1221
+ renderElems: [conf],
1222
+ elemsToHtml: [conf$1],
1223
+ parseElemsHtml: [parseHtmlConf],
1224
+ menus: [insertFormulaMenuConf, editFormulaMenuConf],
1225
+ };
1226
+
1227
+ /**
1228
+ * @description src entry
1229
+ * @author wangfupeng
1230
+ */
1231
+ // 全局注册自定义组件,用于渲染公式
1232
+
1233
+ export { module as default };