svgedit/dist/editor/system/extensions/ext-mathjax/ext-mathjax.js

10 lines
111 KiB
JavaScript
Raw Normal View History

2020-09-11 23:27:47 +00:00
System.register([],(function(t){"use strict";return{execute:function(){var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(t,e,n){return t(n={path:e,exports:{},require:function(t,e){return function commonjsRequire(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&n.path)}},n.exports),n.exports}var check=function(t){return t&&t.Math==Math&&t},n=check("object"==typeof globalThis&&globalThis)||check("object"==typeof window&&window)||check("object"==typeof self&&self)||check("object"==typeof e&&e)||Function("return this")(),fails=function(t){try{return!!t()}catch(t){return!0}},r=!fails((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),i={}.propertyIsEnumerable,o=Object.getOwnPropertyDescriptor,s={f:o&&!i.call({1:2},1)?function propertyIsEnumerable(t){var e=o(this,t);return!!e&&e.enumerable}:i},createPropertyDescriptor=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},u={}.toString,classofRaw=function(t){return u.call(t).slice(8,-1)},l="".split,h=fails((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==classofRaw(t)?l.call(t,""):Object(t)}:Object,requireObjectCoercible=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},toIndexedObject=function(t){return h(requireObjectCoercible(t))},isObject=function(t){return"object"==typeof t?null!==t:"function"==typeof t},toPrimitive=function(t,e){if(!isObject(t))return t;var n,r;if(e&&"function"==typeof(n=t.toString)&&!isObject(r=n.call(t)))return r;if("function"==typeof(n=t.valueOf)&&!isObject(r=n.call(t)))return r;if(!e&&"function"==typeof(n=t.toString)&&!isObject(r=n.call(t)))return r;throw TypeError("Can't convert object to primitive value")},f={}.hasOwnProperty,has=function(t,e){return f.call(t,e)},p=n.document,d=isObject(p)&&isObject(p.createElement),documentCreateElement=function(t){return d?p.createElement(t):{}},m=!r&&!fails((function(){return 7!=Object.defineProperty(documentCreateElement("div"),"a",{get:function(){return 7}}).a})),v=Object.getOwnPropertyDescriptor,x={f:r?v:function getOwnPropertyDescriptor(t,e){if(t=toIndexedObject(t),e=toPrimitive(e,!0),m)try{return v(t,e)}catch(t){}if(has(t,e))return createPropertyDescriptor(!s.f.call(t,e),t[e])}},anObject=function(t){if(!isObject(t))throw TypeError(String(t)+" is not an object");return t},y=Object.defineProperty,S={f:r?y:function defineProperty(t,e,n){if(anObject(t),e=toPrimitive(e,!0),anObject(n),m)try{return y(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},M=r?function(t,e,n){return S.f(t,e,createPropertyDescriptor(1,n))}:function(t,e,n){return t[e]=n,t},setGlobal=function(t,e){try{M(n,t,e)}catch(r){n[t]=e}return e},w="__core-js_shared__",E=n[w]||setGlobal(w,{}),J=Function.toString;"function"!=typeof E.inspectSource&&(E.inspectSource=function(t){return J.call(t)});var T,P,k,A=E.inspectSource,C=n.WeakMap,j="function"==typeof C&&/native code/.test(A(C)),I=createCommonjsModule((function(t){(t.exports=function(t,e){return E[t]||(E[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.6.5",mode:"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})})),O=0,R=Math.random(),uid=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++O+R).toString(36)},L=I("keys"),sharedKey=function(t){return L[t]||(L[t]=uid(t))},D={},H=n.WeakMap;if(j){var U=new H,N=U.get,B=U.has,q=U.set;T=function(t,e){return q.call(U,t,e),e},P=function(t){return N.call(U,t)||{}},k=function(t){return B.call(U,t)}}else{var G=sharedKey("state");D[G]=!0,T=function(t,e){return M(t,G,e),e},P=function(t){return has(t,G)?t[G]:{}},k=function(t){return has(t,G)}}var z,$={set:T,get:P,has:k,enforce:function(t){return k(t)?P(t):T(t,{})},getterFor:function(t){return function(e){var n;if(!isObject(e)||(n=P(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return n}}},V=cr
2020-09-06 06:32:10 +00:00
/**
2020-09-11 23:27:47 +00:00
* @file ext-mathjax.js
*
2020-09-08 23:35:47 +00:00
* @license MIT
*
2020-09-11 23:27:47 +00:00
* @copyright 2013 Jo Segaert
2020-09-08 23:35:47 +00:00
*
2020-09-11 23:27:47 +00:00
*/var mi=function(){var t=_asyncToGenerator(regeneratorRuntime.mark((function _callee(t){var e;return regeneratorRuntime.wrap((function _callee$(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,__variableDynamicImportRuntime0__("./locale/".concat(t,".js"));case 3:e=n.sent,n.next=12;break;case 6:return n.prev=6,n.t0=n.catch(0),console.error("Missing translation (".concat(t,") - using 'en'")),n.next=11,Promise.resolve().then((function(){return vi}));case 11:e=n.sent;case 12:return n.abrupt("return",e.default);case 13:case"end":return n.stop()}}),_callee,null,[[0,6]])})));return function loadExtensionTranslation(e){return t.apply(this,arguments)}}(),vi=(t("default",{name:"mathjax",init:function init(t){var e=this;return _asyncToGenerator(regeneratorRuntime.mark((function _callee3(){var n,r,i,o,s,u,l,h,f,p,d;return regeneratorRuntime.wrap((function _callee3$(m){for(;;)switch(m.prev=m.next){case 0:return p=function _saveMath(){var t=n("#mathjax_code_textarea").val();MathJax.Hub.queue.Push(["Text",u,"\\displaystyle{"+t+"}"]),MathJax.Hub.queue.Push((function(){var t=n(".MathJax_SVG"),e=n(t.html());e.find("use").each((function(){var t=n(this).attr("href")?n(this).attr("href").slice(1):n(this).attr("xlink:href").slice(1),e=n("#"+t).clone().removeAttr("id"),r=n(this).attr("x"),i=n(this).attr("y"),o=n(this).attr("transform");o&&(r||i)?e.attr("transform",o+" translate("+r+","+i+")"):o?e.attr("transform",o):(r||i)&&e.attr("transform","translate("+r+","+i+")"),n(this).replaceWith(e)})),e.removeAttr("style"),e.attr("xmlns","http://www.w3.org/2000/svg"),o.importSvgString(n("<div>").append(e.clone()).html(),!0),o.ungroupSelectedElement(),o.moveSelectedElements(l,h,!0)}))},n=t.$,r=e,m.next=5,mi(r.curPrefs.lang);case 5:return i=m.sent,o=r.canvas,s=r.uiStrings,f=!1,n.extend(s,{mathjax:{embed_svg:"Save as mathematics",embed_mathml:"Save as figure",svg_save_warning:"The math will be transformed into a figure is manipulatable like everything else. You will not be able to manipulate the TeX-code anymore.",mathml_save_warning:"Advised. The math will be saved as a figure.",title:"Mathematics code editor"}}),d=[{id:"tool_mathjax",type:"mode",icon:"mathjax.png",events:{click:function click(){return _asyncToGenerator(regeneratorRuntime.mark((function _callee2(){return regeneratorRuntime.wrap((function _callee2$(t){for(;;)switch(t.prev=t.next){case 0:if(o.setMode("mathjax"),!1!==f){t.next=17;break}return n('<div id="mathjax">\x3c!-- Here is where MathJax creates the math --\x3e<div id="mathjax_creator" class="tex2jax_process" style="display:none">$${}$$</div><div id="mathjax_overlay"></div><div id="mathjax_container"><div id="tool_mathjax_back" class="toolbar_button"><button id="tool_mathjax_save">OK</button><button id="tool_mathjax_cancel">Cancel</button></div><fieldset><legend id="mathjax_legend">Mathematics Editor</legend><label><span id="mathjax_explication">Please type your mathematics in <a href="https://en.wikipedia.org/wiki/Help:Displaying_a_formula" target="_blank">TeX</a> code.</span></label><textarea id="mathjax_code_textarea" spellcheck="false"></textarea></fieldset></div></div>').insertAfter("#svg_prefs").hide(),n("#mathjax_container").draggable({cancel:"button,fieldset",containment:"window"}),n("#tool_mathjax_cancel").prepend(n.getSvgIcon("cancel",!0)).on("click touched",(function(){n("#mathjax").hide()})),n("#tool_mathjax_save").prepend(n.getSvgIcon("ok",!0)).on("click touched",(function(){p(),n("#mathjax").hide()})),n("body").addClass("tex2jax_ignore"),t.prev=7,t.next=10,Promise.resolve().then((function(){return Bo}));case 10:MathJax.Hub.queue.Push((function(){u=MathJax.Hub.getAllJax("#mathjax_creator")[0],console.log(u),f=!0,console.log("MathJax Loaded")})),t.next=17;break;case 13:t.prev=13,t.t0=t.catch(7),console.log("Failed loading MathJax."),n.alert("Failed loading MathJax. You will not be able to change the mathematics.");case 17:case"end":return t.stop()}}),_callee2,null,[[7,13]])})))()}}}],m.abrupt("return",{name:i.name,svgicons:"mathjax-icons.xml",buttons:i.buttons.map((function(t,e){return Object.assign(d[