@wangeditor-next/plugin-formula 0.0.7 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.js +2590 -2
- package/dist/index.mjs +1233 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -1,2 +1,1233 @@
|
|
1
|
-
import t from"katex";import n from"katex/dist/katex.css";import{i18nAddResources as r,t as e,DomEditor as o,SlateRange as i,genModalTextareaElems as u,genModalButtonElems as c,SlateTransforms as f}from"@wangeditor-next/editor";import{h as a}from"snabbdom";var l=function(t,n){return l=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])},l(t,n)};function s(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 p,v,d="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},h={};function y(){if(v)return p;v=1;var t=function(t){return t&&t.Math===Math&&t};return p=t("object"==typeof globalThis&&globalThis)||t("object"==typeof window&&window)||t("object"==typeof self&&self)||t("object"==typeof d&&d)||t("object"==typeof p&&p)||function(){return this}()||Function("return this")()}var m,g,b,w,O,x,E,S,j,T,L,P,I,_,A,M,C,R,k,N,F,D,H,z,$,B,V,U,W,q,G,K,X,Y,J,Q,Z,tt={exports:{}};function nt(){if(w)return b;w=1;var t=y(),n=Object.defineProperty;return b=function(r,e){try{n(t,r,{value:e,configurable:!0,writable:!0})}catch(n){t[r]=e}return e}}function rt(){if(O)return tt.exports;O=1;var t=g?m:(g=1,m=!1),n=y(),r=nt(),e="__core-js_shared__",o=tt.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"}),tt.exports}function et(){if(E)return x;E=1;var t=rt();return x=function(n,r){return t[n]||(t[n]=r||{})}}function ot(){return j?S:(j=1,S=function(t){try{return!!t()}catch(t){return!0}})}function it(){if(L)return T;L=1;var t=ot();return T=!t((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")}))}function ut(){if(I)return P;I=1;var t=it(),n=Function.prototype,r=n.call,e=t&&n.bind.bind(r,r);return P=t?e:function(t){return function(){return r.apply(t,arguments)}},P}function ct(){return A?_:(A=1,_=function(t){return null==t})}function ft(){if(C)return M;C=1;var t=ct(),n=TypeError;return M=function(r){if(t(r))throw new n("Can't call method on "+r);return r}}function at(){if(k)return R;k=1;var t=ft(),n=Object;return R=function(r){return n(t(r))}}function lt(){if(F)return N;F=1;var t=ut(),n=at(),r=t({}.hasOwnProperty);return N=Object.hasOwn||function(t,e){return r(n(t),e)}}function st(){if(H)return D;H=1;var t=ut(),n=0,r=Math.random(),e=t(1..toString);return D=function(t){return"Symbol("+(void 0===t?"":t)+")_"+e(++n+r,36)}}function pt(){if(V)return B;V=1;var t,n,r=y(),e=function(){if($)return z;$=1;var t=y().navigator,n=t&&t.userAgent;return z=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]),B=n}function vt(){if(W)return U;W=1;var t=pt(),n=ot(),r=y().String;return U=!!Object.getOwnPropertySymbols&&!n((function(){var n=Symbol("symbol detection");return!r(n)||!(Object(n)instanceof Symbol)||!Symbol.sham&&t&&t<41}))}function dt(){if(G)return q;G=1;var t=vt();return q=t&&!Symbol.sham&&"symbol"==typeof Symbol.iterator}function ht(){if(X)return K;X=1;var t=y(),n=et(),r=lt(),e=st(),o=vt(),i=dt(),u=t.Symbol,c=n("wks"),f=i?u.for||u:u&&u.withoutSetter||e;return K=function(t){return r(c,t)||(c[t]=o&&r(u,t)?u[t]:f("Symbol."+t)),c[t]}}function yt(){if(J)return Y;J=1;var t={};return t[ht()("toStringTag")]="z",Y="[object z]"===String(t)}function mt(){if(Z)return Q;Z=1;var t="object"==typeof document&&document.all;return Q=void 0===t&&void 0!==t?function(n){return"function"==typeof n||n===t}:function(t){return"function"==typeof t}}var gt,bt,wt,Ot,xt,Et,St,jt,Tt,Lt,Pt,It,_t,At,Mt,Ct,Rt,kt,Nt,Ft,Dt,Ht,zt,$t,Bt,Vt,Ut,Wt,qt,Gt,Kt,Xt,Yt,Jt={};function Qt(){if(bt)return gt;bt=1;var t=ot();return gt=!t((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}))}function Zt(){if(Ot)return wt;Ot=1;var t=mt();return wt=function(n){return"object"==typeof n?null!==n:t(n)}}function tn(){if(Et)return xt;Et=1;var t=y(),n=Zt(),r=t.document,e=n(r)&&n(r.createElement);return xt=function(t){return e?r.createElement(t):{}}}function nn(){if(jt)return St;jt=1;var t=Qt(),n=ot(),r=tn();return St=!t&&!n((function(){return 7!==Object.defineProperty(r("div"),"a",{get:function(){return 7}}).a}))}function rn(){if(Lt)return Tt;Lt=1;var t=Qt(),n=ot();return Tt=t&&n((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))}function en(){if(It)return Pt;It=1;var t=Zt(),n=String,r=TypeError;return Pt=function(e){if(t(e))return e;throw new r(n(e)+" is not an object")}}function on(){if(At)return _t;At=1;var t=it(),n=Function.prototype.call;return _t=t?n.bind(n):function(){return n.apply(n,arguments)},_t}function un(){if(Ct)return Mt;Ct=1;var t=y(),n=mt();return Mt=function(r,e){return arguments.length<2?(o=t[r],n(o)?o:void 0):t[r]&&t[r][e];var o},Mt}function cn(){if(Ft)return Nt;Ft=1;var t=un(),n=mt(),r=function(){if(kt)return Rt;kt=1;var t=ut();return Rt=t({}.isPrototypeOf)}(),e=dt(),o=Object;return Nt=e?function(t){return"symbol"==typeof t}:function(e){var i=t("Symbol");return n(i)&&r(i.prototype,o(e))}}function fn(){if(Ht)return Dt;Ht=1;var t=String;return Dt=function(n){try{return t(n)}catch(t){return"Object"}}}function an(){if($t)return zt;$t=1;var t=mt(),n=fn(),r=TypeError;return zt=function(e){if(t(e))return e;throw new r(n(e)+" is not a function")}}function ln(){if(Vt)return Bt;Vt=1;var t=an(),n=ct();return Bt=function(r,e){var o=r[e];return n(o)?void 0:t(o)}}function sn(){if(Wt)return Ut;Wt=1;var t=on(),n=mt(),r=Zt(),e=TypeError;return Ut=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")},Ut}function pn(){if(Gt)return qt;Gt=1;var t=on(),n=Zt(),r=cn(),e=ln(),o=sn(),i=ht(),u=TypeError,c=i("toPrimitive");return qt=function(i,f){if(!n(i)||r(i))return i;var a,l=e(i,c);if(l){if(void 0===f&&(f="default"),a=t(l,i,f),!n(a)||r(a))return a;throw new u("Can't convert object to primitive value")}return void 0===f&&(f="number"),o(i,f)}}function vn(){if(Xt)return Kt;Xt=1;var t=pn(),n=cn();return Kt=function(r){var e=t(r,"string");return n(e)?e:e+""}}function dn(){if(Yt)return Jt;Yt=1;var t=Qt(),n=nn(),r=rn(),e=en(),o=vn(),i=TypeError,u=Object.defineProperty,c=Object.getOwnPropertyDescriptor,f="enumerable",a="configurable",l="writable";return Jt.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:a in r?r[a]:i[a],enumerable:f in r?r[f]:i[f],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},Jt}var hn,yn,mn,gn,bn,wn,On,xn,En,Sn,jn,Tn,Ln,Pn,In,_n,An,Mn,Cn,Rn,kn,Nn,Fn,Dn,Hn,zn,$n={exports:{}};function Bn(){if(yn)return hn;yn=1;var t=Qt(),n=lt(),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 hn={EXISTS:o,PROPER:i,CONFIGURABLE:u}}function Vn(){if(gn)return mn;gn=1;var t=ut(),n=mt(),r=rt(),e=t(Function.toString);return n(r.inspectSource)||(r.inspectSource=function(t){return e(t)}),mn=r.inspectSource}function Un(){return xn?On:(xn=1,On=function(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}})}function Wn(){if(Sn)return En;Sn=1;var t=Qt(),n=dn(),r=Un();return En=t?function(t,e,o){return n.f(t,e,r(1,o))}:function(t,n,r){return t[n]=r,t}}function qn(){if(Tn)return jn;Tn=1;var t=et(),n=st(),r=t("keys");return jn=function(t){return r[t]||(r[t]=n(t))}}function Gn(){return Pn?Ln:(Pn=1,Ln={})}function Kn(){if(_n)return In;_n=1;var t,n,r,e=function(){if(wn)return bn;wn=1;var t=y(),n=mt(),r=t.WeakMap;return bn=n(r)&&/native code/.test(String(r))}(),o=y(),i=Zt(),u=Wn(),c=lt(),f=rt(),a=qn(),l=Gn(),s="Object already initialized",p=o.TypeError,v=o.WeakMap;if(e||f.state){var d=f.state||(f.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 h=a("state");l[h]=!0,t=function(t,n){if(c(t,h))throw new p(s);return n.facade=t,u(t,h,n),n},n=function(t){return c(t,h)?t[h]:{}},r=function(t){return c(t,h)}}return In={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 Xn(){if(An)return $n.exports;An=1;var t=ut(),n=ot(),r=mt(),e=lt(),o=Qt(),i=Bn().CONFIGURABLE,u=Vn(),c=Kn(),f=c.enforce,a=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=$n.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=f(t);return e(u,"source")||(u.source=d(y,"string"==typeof n?n:"")),t};return Function.prototype.toString=m((function(){return r(this)&&a(this).source||u(this)}),"toString"),$n.exports}function Yn(){if(Cn)return Mn;Cn=1;var t=mt(),n=dn(),r=Xn(),e=nt();return Mn=function(o,i,u,c){c||(c={});var f=c.enumerable,a=void 0!==c.name?c.name:i;if(t(u)&&r(u,a,c),c.global)f?o[i]=u:e(i,u);else{try{c.unsafe?o[i]&&(f=!0):delete o[i]}catch(t){}f?o[i]=u:n.f(o,i,{value:u,enumerable:!1,configurable:!c.nonConfigurable,writable:!c.nonWritable})}return o}}function Jn(){if(kn)return Rn;kn=1;var t=ut(),n=t({}.toString),r=t("".slice);return Rn=function(t){return r(n(t),8,-1)}}function Qn(){if(Fn)return Nn;Fn=1;var t=yt(),n=mt(),r=Jn(),e=ht()("toStringTag"),o=Object,i="Arguments"===r(function(){return arguments}());return Nn=t?r:function(t){var u,c,f;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"===(f=r(u))&&n(u.callee)?"Arguments":f}}!function(){if(zn)return h;zn=1;var t=yt(),n=Yn(),r=function(){if(Hn)return Dn;Hn=1;var t=yt(),n=Qn();return Dn=t?{}.toString:function(){return"[object "+n(this)+"]"}}();t||n(Object.prototype,"toString",r,{unsafe:!0})}();var Zn,tr,nr,rr,er,or,ir={},ur={},cr={};function fr(){if(nr)return tr;nr=1;var t=ut(),n=ot(),r=Jn(),e=Object,o=t("".split);return tr=n((function(){return!e("z").propertyIsEnumerable(0)}))?function(t){return"String"===r(t)?o(t,""):e(t)}:e}function ar(){if(er)return rr;er=1;var t=fr(),n=ft();return rr=function(r){return t(n(r))}}function lr(){if(or)return ur;or=1;var t=Qt(),n=on(),r=function(){if(Zn)return cr;Zn=1;var t={}.propertyIsEnumerable,n=Object.getOwnPropertyDescriptor,r=n&&!t.call({1:2},1);return cr.f=r?function(t){var r=n(this,t);return!!r&&r.enumerable}:t,cr}(),e=Un(),o=ar(),i=vn(),u=lt(),c=nn(),f=Object.getOwnPropertyDescriptor;return ur.f=t?f:function(t,a){if(t=o(t),a=i(a),c)try{return f(t,a)}catch(t){}if(u(t,a))return e(!n(r.f,t,a),t[a])},ur}var sr,pr,vr,dr,hr,yr,mr,gr,br,wr,Or,xr,Er,Sr,jr,Tr,Lr,Pr={};function Ir(){if(dr)return vr;dr=1;var t=function(){if(pr)return sr;pr=1;var t=Math.ceil,n=Math.floor;return sr=Math.trunc||function(r){var e=+r;return(e>0?n:t)(e)}}();return vr=function(n){var r=+n;return r!=r||0===r?0:t(r)}}function _r(){if(yr)return hr;yr=1;var t=Ir(),n=Math.max,r=Math.min;return hr=function(e,o){var i=t(e);return i<0?n(i+o,0):r(i,o)}}function Ar(){if(gr)return mr;gr=1;var t=Ir(),n=Math.min;return mr=function(r){var e=t(r);return e>0?n(e,9007199254740991):0}}function Mr(){if(wr)return br;wr=1;var t=Ar();return br=function(n){return t(n.length)}}function Cr(){if(Sr)return Er;Sr=1;var t=ut(),n=lt(),r=ar(),e=function(){if(xr)return Or;xr=1;var t=ar(),n=_r(),r=Mr(),e=function(e){return function(o,i,u){var c=t(o),f=r(c);if(0===f)return!e&&-1;var a,l=n(u,f);if(e&&i!=i){for(;f>l;)if((a=c[l++])!=a)return!0}else for(;f>l;l++)if((e||l in c)&&c[l]===i)return e||l||0;return!e&&-1}};return Or={includes:e(!0),indexOf:e(!1)}}().indexOf,o=Gn(),i=t([].push);return Er=function(t,u){var c,f=r(t),a=0,l=[];for(c in f)!n(o,c)&&n(f,c)&&i(l,c);for(;u.length>a;)n(f,c=u[a++])&&(~e(l,c)||i(l,c));return l}}function Rr(){return Tr?jr:(Tr=1,jr=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"])}var kr,Nr,Fr,Dr,Hr,zr,$r,Br,Vr,Ur,Wr,qr,Gr,Kr,Xr,Yr,Jr,Qr,Zr,te={};function ne(){if(Fr)return Nr;Fr=1;var t=un(),n=ut(),r=function(){if(Lr)return Pr;Lr=1;var t=Cr(),n=Rr().concat("length","prototype");return Pr.f=Object.getOwnPropertyNames||function(r){return t(r,n)},Pr}(),e=(kr||(kr=1,te.f=Object.getOwnPropertySymbols),te),o=en(),i=n([].concat);return Nr=t("Reflect","ownKeys")||function(t){var n=r.f(o(t)),u=e.f;return u?i(n,u(t)):n}}function re(){if(Hr)return Dr;Hr=1;var t=lt(),n=ne(),r=lr(),e=dn();return Dr=function(o,i,u){for(var c=n(i),f=e.f,a=r.f,l=0;l<c.length;l++){var s=c[l];t(o,s)||u&&t(u,s)||f(o,s,a(i,s))}}}function ee(){if(Vr)return Br;Vr=1;var t=y(),n=lr().f,r=Wn(),e=Yn(),o=nt(),i=re(),u=function(){if($r)return zr;$r=1;var t=ot(),n=mt(),r=/#|\.prototype\./,e=function(r,e){var f=i[o(r)];return f===c||f!==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 zr=e}();return Br=function(c,f){var a,l,s,p,v,d=c.target,h=c.global,y=c.stat;if(a=h?t:y?t[d]||o(d,{}):t[d]&&t[d].prototype)for(l in f){if(p=f[l],s=c.dontCallGetSet?(v=n(a,l))&&v.value:a[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(a,l,p,c)}}}function oe(){if(Gr)return qr;Gr=1;var t=ut();return qr=t([].slice)}function ie(){if(Xr)return Kr;Xr=1;var t=ut(),n=an(),r=Zt(),e=lt(),o=oe(),i=it(),u=Function,c=t([].concat),f=t([].join),a={};return Kr=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(a,n)){for(var o=[],i=0;i<n;i++)o[i]="a["+i+"]";a[n]=u("C,a","return new C("+f(o,",")+")")}return a[n](t,r)}(i,n.length,n):i.apply(t,n)};return r(l)&&(p.prototype=l),p},Kr}function ue(){if(Jr)return Yr;Jr=1;var t=ut(),n=ot(),r=mt(),e=Qn(),o=un(),i=Vn(),u=function(){},c=o("Reflect","construct"),f=/^\s*(?:class|function)\b/,a=t(f.exec),l=!f.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||!!a(f,i(t))}catch(t){return!0}};return p.sham=!0,Yr=!c||n((function(){var t;return s(s.call)||!s(Object)||!s((function(){t=!0}))||t}))?p:s}function ce(){if(Zr)return Qr;Zr=1;var t=ue(),n=fn(),r=TypeError;return Qr=function(e){if(t(e))return e;throw new r(n(e)+" is not a constructor")}}var fe,ae,le,se,pe,ve,de,he,ye={};function me(){if(ae)return fe;ae=1;var t=Cr(),n=Rr();return fe=Object.keys||function(r){return t(r,n)}}function ge(){if(de)return ve;de=1;var t,n=en(),r=function(){if(le)return ye;le=1;var t=Qt(),n=rn(),r=dn(),e=en(),o=ar(),i=me();return ye.f=t&&!n?Object.defineProperties:function(t,n){e(t);for(var u,c=o(n),f=i(n),a=f.length,l=0;a>l;)r.f(t,u=f[l++],c[u]);return t},ye}(),e=Rr(),o=Gn(),i=function(){if(pe)return se;pe=1;var t=un();return se=t("document","documentElement")}(),u=tn(),c=qn(),f="prototype",a="script",l=c("IE_PROTO"),s=function(){},p=function(t){return"<"+a+">"+t+"</"+a+">"},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"+a+":",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[f][e[c]];return d()};return o[l]=!0,ve=Object.create||function(t,e){var o;return null!==t?(s[f]=n(t),o=new s,s[f]=null,o[l]=t):o=d(),void 0===e?o:r.f(o,e)}}!function(){if(he)return ir;he=1;var t=ee(),n=un(),r=function(){if(Wr)return Ur;Wr=1;var t=it(),n=Function.prototype,r=n.apply,e=n.call;return Ur="object"==typeof Reflect&&Reflect.apply||(t?e.bind(r):function(){return e.apply(r,arguments)}),Ur}(),e=ie(),o=ce(),i=en(),u=Zt(),c=ge(),f=ot(),a=n("Reflect","construct"),l=Object.prototype,s=[].push,p=f((function(){function t(){}return!(a((function(){}),[],t)instanceof t)})),v=!f((function(){a((function(){}))})),d=p||v;t({target:"Reflect",stat:!0,forced:d,sham:d},{construct:function(t,n){o(t),i(n);var f=arguments.length<3?t:o(arguments[2]);if(v&&!p)return a(t,n,f);if(t===f){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=f.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)}}(),console.log(n);var be=function(r){function e(){var t=r.call(this)||this,e=t.attachShadow({mode:"open"}),o=e.ownerDocument,i=o.createElement("style");i.innerHTML=n,e.appendChild(i);var u=o.createElement("span");return u.style.display="inline-block",e.appendChild(u),t.span=u,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}l(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(e,r),Object.defineProperty(e,"observedAttributes",{get:function(){return["data-value"]},enumerable:!1,configurable:!0}),e.prototype.attributeChangedCallback=function(t,n,r){if("data-value"===t){if(n===r)return;this.render(r||"")}},e.prototype.render=function(n){t.render(n,this.span,{throwOnError:!1})},e}(HTMLElement);window.customElements.get("w-e-formula-card")||window.customElements.define("w-e-formula-card",be),r("en",{formula:{formula:"Formula",placeholder:"Use LateX syntax",insert:"Insert formula",edit:"Edit formula",ok:"OK"}}),r("zh-CN",{formula:{formula:"公式",placeholder:"使用 LateX 语法",insert:"插入公式",edit:"编辑公式",ok:"确定"}});var we,Oe,xe,Ee,Se,je,Te,Le,Pe,Ie,_e,Ae,Me,Ce,Re,ke={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>')}},Ne={};function Fe(){if(Ee)return xe;Ee=1;var t=function(){if(Oe)return we;Oe=1;var t=Jn(),n=ut();return we=function(r){if("Function"===t(r))return n(r)}}(),n=an(),r=it(),e=t(t.bind);return xe=function(t,o){return n(t),void 0===o?t:r?e(t,o):function(){return t.apply(o,arguments)}},xe}function De(){if(je)return Se;je=1;var t=Jn();return Se=Array.isArray||function(n){return"Array"===t(n)}}function He(){if(Le)return Te;Le=1;var t=De(),n=ue(),r=Zt(),e=ht()("species"),o=Array;return Te=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 ze(){if(Ie)return Pe;Ie=1;var t=He();return Pe=function(n,r){return new(t(n))(0===r?0:r)}}function $e(){if(Ce)return Me;Ce=1;var t=ht(),n=ge(),r=dn().f,e=t("unscopables"),o=Array.prototype;return void 0===o[e]&&r(o,e,{configurable:!0,value:n(null)}),Me=function(t){o[e][t]=!0}}!function(){if(Re)return Ne;Re=1;var t=ee(),n=function(){if(Ae)return _e;Ae=1;var t=Fe(),n=ut(),r=fr(),e=at(),o=Mr(),i=ze(),u=n([].push),c=function(n){var c=1===n,f=2===n,a=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):f||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:a||l?l:T}};return _e={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=$e(),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 Be,Ve,Ue,We,qe,Ge,Ke,Xe,Ye,Je,Qe,Ze,to,no={};function ro(){if(Ve)return Be;Ve=1;var t=Qn(),n=String;return Be=function(r){if("Symbol"===t(r))throw new TypeError("Cannot convert a Symbol value to a string");return n(r)}}function eo(){if(We)return Ue;We=1;var t=en();return Ue=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 oo(){if(Ze)return Qe;Ze=1;var t,n,r=on(),e=ut(),o=ro(),i=eo(),u=function(){if(Ge)return qe;Ge=1;var t=ot(),n=y().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 qe={BROKEN_CARET:o,MISSED_STICKY:e,UNSUPPORTED_Y:r}}(),c=et(),f=ge(),a=Kn().get,l=function(){if(Xe)return Ke;Xe=1;var t=ot(),n=y().RegExp;return Ke=t((function(){var t=n(".","s");return!(t.dotAll&&t.test("\n")&&"s"===t.flags)}))}(),s=function(){if(Je)return Ye;Je=1;var t=ot(),n=y().RegExp;return Ye=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,h=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,y,E=this,S=a(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),_=E.source,A=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"!==h(j,E.lastIndex-1))&&(_="(?: "+_+")",M=" "+M,A++),e=new RegExp("^(?:"+_+")",I)),x&&(e=new RegExp("^"+_+"$(?!\\s)",I)),w&&(u=E.lastIndex),c=r(v,P?e:E,M),P?c?(c.input=b(c.input,A),c[0]=b(c[0],A),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=f(null),l=0;l<L.length;l++)s[(y=L[l])[0]]=c[y[1]];return c}),Qe=d}!function(){if(to)return no;to=1;var t=ee(),n=oo();t({target:"RegExp",proto:!0,forced:/./.exec!==n},{exec:n})}();var io,uo,co,fo,ao,lo,so,po={};function vo(){return uo?io:(uo=1,io="\t\n\v\f\r \u2028\u2029\ufeff")}!function(){if(so)return po;so=1;var t=ee(),n=function(){if(fo)return co;fo=1;var t=ut(),n=ft(),r=ro(),e=vo(),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 co={start:c(1),end:c(2),trim:c(3)}}().trim,r=function(){if(lo)return ao;lo=1;var t=Bn().PROPER,n=ot(),r=vo();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 ho,yo,mo={};function go(t){return null!==t&&"object"==typeof t&&"constructor"in t&&t.constructor===Object}function bo(t,n){void 0===t&&(t={}),void 0===n&&(n={}),Object.keys(n).forEach((function(r){void 0===t[r]?t[r]=n[r]:go(n[r])&&go(t[r])&&Object.keys(n[r]).length>0&&bo(t[r],n[r])}))}yo||(yo=1,function(){if(ho)return mo;ho=1;var t=ee(),n=y();t({global:!0,forced:n.globalThis!==n},{globalThis:n})}());var wo={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 Oo(){var t="undefined"!=typeof document?document:{};return bo(t,wo),t}var xo={document:wo,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 Eo(){var t="undefined"!=typeof window?window:{};return bo(t,xo),t}function So(t){return So=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},So(t)}function jo(t,n){return jo=Object.setPrototypeOf||function(t,n){return t.__proto__=n,t},jo(t,n)}function To(t,n,r){return To=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&&jo(o,r.prototype),o},To.apply(null,arguments)}function Lo(t){var n="function"==typeof Map?new Map:void 0;return Lo=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 To(t,arguments,So(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),jo(e,t)},Lo(t)}var Po=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}(Lo(Array));function Io(t,n){var r=Eo(),e=Oo(),o=[];if(!n&&t instanceof Po)return t;if(!t)return new Po(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 f=0;f<c.childNodes.length;f+=1)o.push(c.childNodes[f])}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 Po)return t;o=t}return new Po(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 _o(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),Io(n).is(o))i.apply(n,r);else for(var e=Io(n).parents(),u=0;u<e.length;u+=1)Io(e[u]).is(o)&&i.apply(e[u],r)}}function f(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 a,l=e.split(" "),s=0;s<this.length;s+=1){var p=this[s];if(o)for(a=0;a<l.length;a+=1){var v=l[a];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(a=0;a<l.length;a+=1){var d=l[a];p.dom7Listeners||(p.dom7Listeners={}),p.dom7Listeners[d]||(p.dom7Listeners[d]=[]),p.dom7Listeners[d].push({listener:i,proxyListener:f}),p.addEventListener(d,f,u)}}return this}function Mo(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 Co(t){var n,r,e=Eo(),o=Oo(),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=Io(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 Po){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=Oo(),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 Po)for(var i=0;i<t.length;i+=1)this[e].appendChild(t[i]);else this[e].appendChild(t)}return this}function ko(t){for(var n=[],r=0;r<this.length;r+=1)for(var e=this[r].parentNode;e;)t?Io(e).is(t)&&n.push(e):n.push(e),e=e.parentNode;return Io(n)}function No(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 Io(n)}Io.fn=Po.prototype;var Fo="resize scroll".split(" ");var Do,Ho=(Do="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)Fo.indexOf(Do)<0&&(Do in this[e]?this[e][Do]():Io(this[e]).trigger(Do));return this}return this.on.apply(this,[Do].concat(n))});Ro&&(Io.fn.append=Ro),Mo&&(Io.fn.html=Mo),_o&&(Io.fn.val=_o),Ao&&(Io.fn.on=Ao),Ho&&(Io.fn.focus=Ho),Co&&(Io.fn.is=Co),ko&&(Io.fn.parents=ko),No&&(Io.fn.find=No);var zo,$o,Bo,Vo,Uo,Wo,qo,Go={};function Ko(){if($o)return zo;$o=1;var t=TypeError;return zo=function(n){if(n>9007199254740991)throw t("Maximum allowed index exceeded");return n}}function Xo(){if(Vo)return Bo;Vo=1;var t=Qt(),n=dn(),r=Un();return Bo=function(e,o,i){t?n.f(e,o,r(0,i)):e[o]=i}}function Yo(){if(Wo)return Uo;Wo=1;var t=ot(),n=ht(),r=pt(),e=n("species");return Uo=function(n){return r>=51||!t((function(){var t=[];return(t.constructor={})[e]=function(){return{foo:1}},1!==t[n](Boolean).foo}))}}!function(){if(qo)return Go;qo=1;var t=ee(),n=ot(),r=De(),e=Zt(),o=at(),i=Mr(),u=Ko(),c=Xo(),f=ze(),a=Yo(),l=ht(),s=pt(),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||!a("concat")},{concat:function(t){var n,r,e,a,l,s=o(this),p=f(s,0),v=0;for(n=-1,e=arguments.length;n<e;n++)if(d(l=-1===n?s:arguments[n]))for(a=i(l),u(v+a),r=0;r<a;r++,v++)r in l&&c(p,v,l[r]);else u(v+1),c(p,v++,l);return p.length=v,p}})}();let Jo=(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 Qo(t){return"".concat(t,"-").concat(Jo())}function Zo(){return Qo("w-e-insert-formula")}var ti=function(){function t(){this.title=e("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=Zo(),this.buttonId=Zo()}return t.prototype.getSelectedElem=function(t){var n=o.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||(!!i.isExpanded(n)||null==this.getSelectedElem(t))},t.prototype.getModalPositionNode=function(t){return this.getSelectedElem(t)},t.prototype.getModalContentElem=function(t){var n=this,r=this.textareaId,o=this.buttonId,i=s(u(e("formula.formula"),r,e("formula.placeholder")),2),f=i[0],a=Io(i[1]),l=s(c(o,e("formula.ok")),1)[0];if(null==this.$content){var p=Io("<div></div>");p.on("click","#".concat(o),(function(e){e.preventDefault();var o=p.find("#".concat(r)).val().trim();n.updateFormula(t,o),t.hidePanelOrModal()})),this.$content=p}var v=this.$content;v.html(""),v.append(f),v.append(l);var d=this.getValue(t);return a.val(d),setTimeout((function(){a.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 e=o.findPath(t,r),i={value:n};f.setNodes(t,i,{at:e})}}},t}();function ni(){return Qo("w-e-insert-formula")}var ri=function(){function t(){this.title=e("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=ni(),this.buttonId=ni()}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(i.isExpanded(n))return!0;var r=o.getSelectedElems(t);return!!r.some((function(n){return t.isVoid(n)}))||!!r.some((function(t){return"pre"===o.getNodeType(t)}))},t.prototype.getModalPositionNode=function(t){return null},t.prototype.getModalContentElem=function(t){var n=this,r=this.textareaId,o=this.buttonId,i=s(u(e("formula.formula"),r,e("formula.placeholder")),2),f=i[0],a=Io(i[1]),l=s(c(o,e("formula.ok")),1)[0];if(null==this.$content){var p=Io("<div></div>");p.on("click","#".concat(o),(function(e){e.preventDefault();var o=p.find("#".concat(r)).val().trim();n.insertFormula(t,o),t.hidePanelOrModal()})),this.$content=p}var v=this.$content;return v.html(""),v.append(f),v.append(l),a.val(""),setTimeout((function(){a.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 ei={editorPlugin:function(t){var n=t.isInline,r=t.isVoid,e=t;return e.isInline=function(t){return"formula"===o.getNodeType(t)||n(t)},e.isVoid=function(t){return"formula"===o.getNodeType(t)||r(t)},e},renderElems:[{type:"formula",renderElem:function(t,n,r){var e=o.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:e?"2px solid var(--w-e-textarea-selected-border-color)":"2px solid transparent",borderRadius:"3px",padding:"3px 3px"}},[u])}}],elemsToHtml:[ke],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 ri}},{key:"editFormula",factory:function(){return new ti}}]};export{ei as default};
|
2
|
-
|
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
|
+
/**
|
106
|
+
* @description 注册自定义 elem
|
107
|
+
* @author wangfupeng
|
108
|
+
*/
|
109
|
+
var WangEditorFormulaCard = /** @class */ (function (_super) {
|
110
|
+
__extends(WangEditorFormulaCard, _super);
|
111
|
+
function WangEditorFormulaCard() {
|
112
|
+
var _this = _super.call(this) || this;
|
113
|
+
var shadow = _this.attachShadow({ mode: 'open' });
|
114
|
+
var document = shadow.ownerDocument;
|
115
|
+
// 将样式通过 link 标签引入
|
116
|
+
var styleLink = document.createElement('link');
|
117
|
+
styleLink.rel = 'stylesheet';
|
118
|
+
styleLink.href = 'https://cdn.jsdelivr.net/npm/katex/dist/katex.min.css'; // 或直接引入本地路径
|
119
|
+
shadow.appendChild(styleLink);
|
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, '<').replace(/>/g, '>')
|
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 };
|