yzms/umeditor/third-party/mathquill/mathquill.min.js

2 lines
50 KiB
JavaScript
Raw Normal View History

2024-04-01 15:54:27 +08:00
(function(){function t(){}function e(t){var e=o.call(arguments,1);return function(){return t.apply(this,e)}}function n(t,e){if(!e)throw Error("prayer failed: "+t)}function i(t){n("a direction was passed",t===u||t===p)}function r(e,n,i,r){function s(){g=a;var t=c.selection?"$"+c.selection.latex()+"$":"";w.select(t)}function o(){l.detach()}var c,l,m,g,b,v,w,x=e.contents().detach();return i||e.addClass("mathquill-rendered-math"),n.jQ=e.attr(ce,n.id),n.revert=function(){e.empty().unbind(".mathquill").removeClass("mathquill-rendered-math mathquill-editable mathquill-textbox").append(x)},c=n.cursor=re(n),n.renderLatex(x.text()),l=n.textarea=f('<span class="textarea"><textarea></textarea></span>'),m=l.children(),n.selectionChanged=function(){g===a&&(g=setTimeout(s)),O(e[0])},e.bind("selectstart.mathquill",function(t){t.target!==m[0]&&t.preventDefault(),t.stopPropagation()}),v=c.blink,e.bind("mousedown.mathquill",function(n){function i(t){return c.seek(f(t.target),t.pageX,t.pageY),(c[u]!==b[u]||c.parent!==b.parent)&&c.selectFrom(b),!1}function s(t){return delete t.target,i(t)}function o(t){b=a,c.blink=v,c.selection||(r?c.show():l.detach()),e.unbind("mousemove",i),f(t.target.ownerDocument).unbind("mousemove",s).unbind("mouseup",o)}return setTimeout(function(){m.focus()}),c.blink=t,c.seek(f(n.target),n.pageX,n.pageY),b=d(c.parent,c[u],c[p]),r||e.prepend(l),e.mousemove(i),f(n.target.ownerDocument).mousemove(s).mouseup(o),!1}),r?(w=h(m,{container:e,key:function(t,e){c.parent.bubble("onKey",t,e)},text:function(t){c.parent.bubble("onText",t)},cut:function(t){c.selection&&setTimeout(function(){c.prepareEdit(),c.parent.bubble("redraw")}),t.stopPropagation()},paste:function(t){t="$"===t.slice(0,1)&&"$"===t.slice(-1)?t.slice(1,-1):"\\text{"+t+"}",c.writeLatex(t).show()}}),e.prepend(l),e.addClass("mathquill-editable"),i&&e.addClass("mathquill-textbox"),m.focus(function(t){c.parent||c.insAtRightEnd(n),c.parent.jQ.addClass("hasCursor"),c.selection?(c.selection.jQ.removeClass("blur"),setTimeout(n.selectionChanged)):c.show(),t.stopPropagation()}).blur(function(t){c.hide().parent.blur(),c.selection&&c.selection.jQ.addClass("blur"),t.stopPropagation()}),e.bind("focus.mathquill blur.mathquill",function(t){m.trigger(t)}).blur(),a):(w=h(m,{container:e}),e.bind("cut paste",!1).bind("copy",s).prepend('<span class="selectable">$'+n.latex()+"$</span>"),m.blur(function(){c.clearSelection(),setTimeout(o)}),a)}function s(t,e,n){return c(K,{ctrlSeq:t,htmlTemplate:"<"+e+" "+n+">&0</"+e+">"})}var a,o,c,h,l,u,p,f,d,m,g,b,v,w,x,j,k,q,y,Q,C,S,L,D,O,E,A,R,T,z,B,I,$,_,W,M,F,P,U,H,K,N,G,X,Z,Y,J,V,te,ee,ne,ie,re,se,ae=window.jQuery,oe="mathquill-command-id",ce="mathquill-block-id",he=Math.min;Math.max,o=[].slice,c=function(t,e,n){function i(t){return"object"==typeof t}function r(t){return"function"==typeof t}function s(){}function a(o,c){function h(){var t=new l;return r(t.init)&&t.init.apply(t,arguments),t}function l(){}var u,p,f;return c===n&&(c=o,o=Object),h.Bare=l,u=s[t]=o[t],p=l[t]=h[t]=new s,p.constructor=h,h.mixin=function(e){return l[t]=h[t]=a(h,e)[t],h},(h.open=function(t){if(f={},r(t)?f=t.call(h,p,u,h,o):i(t)&&(f=t),i(f))for(var n in f)e.call(f,n)&&(p[n]=f[n]);return r(p.init)||(p.init=o),h})(c)}return a}("prototype",{}.hasOwnProperty),h=function(){function e(t){var e,i=t.which||t.keyCode,r=n[i],s=[];return t.ctrlKey&&s.push("Ctrl"),t.originalEvent&&t.originalEvent.metaKey&&s.push("Meta"),t.altKey&&s.push("Alt"),t.shiftKey&&s.push("Shift"),e=r||String.fromCharCode(i),s.length||r?(s.push(e),s.join("-")):e}var n={8:"Backspace",9:"Tab",10:"Enter",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Esc",32:"Spacebar",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",45:"Insert",46:"Del",144:"NumLock"};return function(n,i){function r(t){k=t,clearTimeout(j),j=setTimeout(t)}function s(e){k(),k=t,clearTimeout(j),w.val(e),e&&w[0].select()}function a(){var t=w[0];return"selectionStart"in t?t.selectionStart!==t.selectionEnd:!1}function o(t){var e=w.val();w.val(""),e&&t(e)}function c(){g(e(q),q)}function h(t){q=t,y=null,c(
}}),te=c(V,function(t){t.init=Z.prototype.init,t.respace=function(){return this.jQ[0].className=this[u]?this[u]instanceof V&&this[p]&&!(this[p]instanceof V)?"unary-operator":"binary-operator":"",this}}),S["+"]=e(te,"+","+"),S[""]=S["-"]=e(te,"-","&minus;"),S["±"]=S.pm=S.plusmn=S.plusminus=e(te,"\\pm ","&plusmn;"),S.mp=S.mnplus=S.minusplus=e(te,"\\mp ","&#8723;"),C["*"]=S.sdot=S.cdot=e(V,"\\cdot ","&middot;"),S["="]=e(V,"=","="),S["<"]=e(V,"<","&lt;"),S[">"]=e(V,">","&gt;"),S.notin=S.sim=S.cong=S.equiv=S.oplus=S.otimes=c(V,function(t,e){t.init=function(t){e.init.call(this,"\\"+t+" ","&"+t+";")}}),S.times=e(V,"\\times ","&times;","[x]"),S["÷"]=S.div=S.divide=S.divides=e(V,"\\div ","&divide;","[/]"),S["≠"]=S.ne=S.neq=e(V,"\\ne ","&ne;"),S.ast=S.star=S.loast=S.lowast=e(V,"\\ast ","&lowast;"),S.therefor=S.therefore=e(V,"\\therefore ","&there4;"),S.cuz=S.because=e(V,"\\because ","&#8757;"),S.prop=S.propto=e(V,"\\propto ","&prop;"),S["≈"]=S.asymp=S.approx=e(V,"\\approx ","&asymp;"),S.lt=e(V,"<","&lt;"),S.gt=e(V,">","&gt;"),S["≤"]=S.le=S.leq=e(V,"\\le ","&le;"),S["≥"]=S.ge=S.geq=e(V,"\\ge ","&ge;"),S.isin=S["in"]=e(V,"\\in ","&isin;"),S.ni=S.contains=e(V,"\\ni ","&ni;"),S.notni=S.niton=S.notcontains=S.doesnotcontain=e(V,"\\not\\ni ","&#8716;"),S.sub=S.subset=e(V,"\\subset ","&sub;"),S.sup=S.supset=S.superset=e(V,"\\supset ","&sup;"),S.nsub=S.notsub=S.nsubset=S.notsubset=e(V,"\\not\\subset ","&#8836;"),S.nsup=S.notsup=S.nsupset=S.notsupset=S.nsuperset=S.notsuperset=e(V,"\\not\\supset ","&#8837;"),S.sube=S.subeq=S.subsete=S.subseteq=e(V,"\\subseteq ","&sube;"),S.supe=S.supeq=S.supsete=S.supseteq=S.supersete=S.superseteq=e(V,"\\supseteq ","&supe;"),S.nsube=S.nsubeq=S.notsube=S.notsubeq=S.nsubsete=S.nsubseteq=S.notsubsete=S.notsubseteq=e(V,"\\not\\subseteq ","&#8840;"),S.nsupe=S.nsupeq=S.notsupe=S.notsupeq=S.nsupsete=S.nsupseteq=S.notsupsete=S.notsupseteq=S.nsupersete=S.nsuperseteq=S.notsupersete=S.notsuperseteq=e(V,"\\not\\supseteq ","&#8841;"),ee=c(x,function(t,e){t.init=function(t,n){e.init.call(this,t,"<big>"+n+"</big>")}}),S["∑"]=S.sum=S.summation=e(ee,"\\sum ","&sum;"),S["∏"]=S.prod=S.product=e(ee,"\\prod ","&prod;"),S.coprod=S.coproduct=e(ee,"\\coprod ","&#8720;"),S["∫"]=S["int"]=S.integral=e(ee,"\\int ","&int;"),S.N=S.naturals=S.Naturals=e(Z,"\\mathbb{N}","&#8469;"),S.P=S.primes=S.Primes=S.projective=S.Projective=S.probability=S.Probability=e(Z,"\\mathbb{P}","&#8473;"),S.Z=S.integers=S.Integers=e(Z,"\\mathbb{Z}","&#8484;"),S.Q=S.rationals=S.Rationals=e(Z,"\\mathbb{Q}","&#8474;"),S.R=S.reals=S.Reals=e(Z,"\\mathbb{R}","&#8477;"),S.C=S.complex=S.Complex=S.complexes=S.Complexes=S.complexplane=S.Complexplane=S.ComplexPlane=e(Z,"\\mathbb{C}","&#8450;"),S.H=S.Hamiltonian=S.quaternions=S.Quaternions=e(Z,"\\mathbb{H}","&#8461;"),S.quad=S.emsp=e(Z,"\\quad "," "),S.qquad=e(Z,"\\qquad "," "),S.diamond=e(Z,"\\diamond ","&#9671;"),S.bigtriangleup=e(Z,"\\bigtriangleup ","&#9651;"),S.ominus=e(Z,"\\ominus ","&#8854;"),S.uplus=e(Z,"\\uplus ","&#8846;"),S.bigtriangledown=e(Z,"\\bigtriangledown ","&#9661;"),S.sqcap=e(Z,"\\sqcap ","&#8851;"),S.triangleleft=e(Z,"\\triangleleft ","&#8882;"),S.sqcup=e(Z,"\\sqcup ","&#8852;"),S.triangleright=e(Z,"\\triangleright ","&#8883;"),S.odot=e(Z,"\\odot ","&#8857;"),S.bigcirc=e(Z,"\\bigcirc ","&#9711;"),S.dagger=e(Z,"\\dagger ","&#0134;"),S.ddagger=e(Z,"\\ddagger ","&#135;"),S.wr=e(Z,"\\wr ","&#8768;"),S.amalg=e(Z,"\\amalg ","&#8720;"),S.models=e(Z,"\\models ","&#8872;"),S.prec=e(Z,"\\prec ","&#8826;"),S.succ=e(Z,"\\succ ","&#8827;"),S.preceq=e(Z,"\\preceq ","&#8828;"),S.succeq=e(Z,"\\succeq ","&#8829;"),S.simeq=e(Z,"\\simeq ","&#8771;"),S.mid=e(Z,"\\mid ","&#8739;"),S.ll=e(Z,"\\ll ","&#8810;"),S.gg=e(Z,"\\gg ","&#8811;"),S.parallel=e(Z,"\\parallel ","&#8741;"),S.bowtie=e(Z,"\\bowtie ","&#8904;"),S.sqsubset=e(Z,"\\sqsubset ","&#8847;"),S.sqsupset=e(Z,"\\sqsupset ","&#8848;"),S.smile=e(Z,"\\smile ","&#8995;"),S.sqsubseteq=e(Z,"\\sqsubseteq ","&#8849;"),S.sqsupseteq=e(Z,"\\sqsupseteq ","&#8850;"),S.doteq=e(Z,"\\doteq ","&#8784;"),S.frown=e(Z,"\\frown ","&#8994;"),S.vdash=e(Z,"\\vda